1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-09 13:22:24 +03:00

0031550: Data Exchange, STEP Import - surface transparency is ignored (SURFACE_STYLE_TRANSPARENT)

Implemented reading and writing transparency to/from step files
This commit is contained in:
Igor Khozhanov
2020-05-18 13:04:19 +03:00
committed by bugmaster
parent 8189cc72d0
commit 691711cd3e
33 changed files with 1565 additions and 41 deletions

View File

@@ -968,10 +968,11 @@ Standard_Boolean STEPCAFControl_Reader::ReadColors(const Handle(XSControl_WorkSe
break;
}
Handle(StepVisual_Colour) SurfCol, BoundCol, CurveCol;
Handle(StepVisual_Colour) SurfCol, BoundCol, CurveCol, RenderCol;
Standard_Real RenderTransp;
// check if it is component style
Standard_Boolean IsComponent = Standard_False;
if (!Styles.GetColors(style, SurfCol, BoundCol, CurveCol, IsComponent) && IsVisible)
if (!Styles.GetColors(style, SurfCol, BoundCol, CurveCol, RenderCol, RenderTransp, IsComponent) && IsVisible)
continue;
// collect styled items
@@ -1042,23 +1043,30 @@ Standard_Boolean STEPCAFControl_Reader::ReadColors(const Handle(XSControl_WorkSe
if (S.IsNull())
continue;
if (!SurfCol.IsNull() || !BoundCol.IsNull() || !CurveCol.IsNull() || !IsVisible)
if (!SurfCol.IsNull() || !BoundCol.IsNull() || !CurveCol.IsNull() || !RenderCol.IsNull() || !IsVisible)
{
TDF_Label aL;
Standard_Boolean isFound = STool->SearchUsingMap(S, aL, Standard_False, Standard_True);
if (!SurfCol.IsNull() || !BoundCol.IsNull() || !CurveCol.IsNull())
if (!SurfCol.IsNull() || !BoundCol.IsNull() || !CurveCol.IsNull() || !RenderCol.IsNull())
{
Quantity_Color aSCol, aBCol, aCCol;
if (!SurfCol.IsNull())
Quantity_Color aSCol, aBCol, aCCol, aRCol;
Quantity_ColorRGBA aFullSCol;
if (!SurfCol.IsNull()) {
Styles.DecodeColor(SurfCol, aSCol);
aFullSCol = Quantity_ColorRGBA(aSCol);
}
if (!BoundCol.IsNull())
Styles.DecodeColor(BoundCol, aBCol);
if (!CurveCol.IsNull())
Styles.DecodeColor(CurveCol, aCCol);
if (!RenderCol.IsNull()) {
Styles.DecodeColor(RenderCol, aRCol);
aFullSCol = Quantity_ColorRGBA(aRCol, static_cast<float>(1.0f - RenderTransp));
}
if (isFound)
{
if (!SurfCol.IsNull())
CTool->SetColor(aL, aSCol, XCAFDoc_ColorSurf);
if (!SurfCol.IsNull() || !RenderCol.IsNull())
CTool->SetColor(aL, aFullSCol, XCAFDoc_ColorSurf);
if (!BoundCol.IsNull())
CTool->SetColor(aL, aBCol, XCAFDoc_ColorCurv);
if (!CurveCol.IsNull())
@@ -1071,8 +1079,8 @@ Standard_Boolean STEPCAFControl_Reader::ReadColors(const Handle(XSControl_WorkSe
TDF_Label aL1;
if (STool->SearchUsingMap(it.Value(), aL1, Standard_False, Standard_True))
{
if (!SurfCol.IsNull())
CTool->SetColor(aL1, aSCol, XCAFDoc_ColorSurf);
if (!SurfCol.IsNull() || !RenderCol.IsNull())
CTool->SetColor(aL1, aFullSCol, XCAFDoc_ColorSurf);
if (!BoundCol.IsNull())
CTool->SetColor(aL1, aBCol, XCAFDoc_ColorCurv);
if (!CurveCol.IsNull())
@@ -1622,10 +1630,11 @@ Standard_Boolean STEPCAFControl_Reader::ReadSHUOs(const Handle(XSControl_WorkSes
break;
}
Handle(StepVisual_Colour) SurfCol, BoundCol, CurveCol;
Handle(StepVisual_Colour) SurfCol, BoundCol, CurveCol, RenderCol;
Standard_Real RenderTransp;
// check if it is component style
Standard_Boolean IsComponent = Standard_False;
if (!Styles.GetColors(style, SurfCol, BoundCol, CurveCol, IsComponent) && IsVisible)
if (!Styles.GetColors(style, SurfCol, BoundCol, CurveCol, RenderCol, RenderTransp, IsComponent) && IsVisible)
continue;
if (!IsComponent)
continue;
@@ -1660,10 +1669,18 @@ Standard_Boolean STEPCAFControl_Reader::ReadSHUOs(const Handle(XSControl_WorkSes
continue;
}
// now set the style to the SHUO main label.
if (!SurfCol.IsNull()) {
if (!SurfCol.IsNull() || !RenderCol.IsNull()) {
Quantity_Color col;
Styles.DecodeColor(SurfCol, col);
CTool->SetColor(aLabelForStyle, col, XCAFDoc_ColorSurf);
Quantity_ColorRGBA colRGBA;
if (!SurfCol.IsNull()) {
Styles.DecodeColor(SurfCol, col);
colRGBA = Quantity_ColorRGBA(col);
}
if (!RenderCol.IsNull()) {
Styles.DecodeColor(RenderCol, col);
colRGBA = Quantity_ColorRGBA(col, static_cast<float>(1.0 - RenderTransp));
}
CTool->SetColor(aLabelForStyle, colRGBA, XCAFDoc_ColorSurf);
}
if (!BoundCol.IsNull()) {
Quantity_Color col;

View File

@@ -1062,13 +1062,17 @@ static void MakeSTEPStyles (STEPConstruct_Styles &Styles,
XCAFPrs_Style own = settings.FindFromKey(S);
if ( !own.IsVisible() ) style.SetVisibility ( Standard_False );
if ( own.IsSetColorCurv() ) style.SetColorCurv ( own.GetColorCurv() );
if ( own.IsSetColorSurf() ) style.SetColorSurf ( own.GetColorSurf() );
if ( own.IsSetColorSurf() ) style.SetColorSurf ( own.GetColorSurfRGBA() );
}
// translate colors to STEP
Handle(StepVisual_Colour) surfColor, curvColor;
if ( style.IsSetColorSurf() )
surfColor = Styles.EncodeColor(style.GetColorSurf(),DPDCs,ColRGBs);
Standard_Real RenderTransp = 0.0;
if ( style.IsSetColorSurf() ) {
Quantity_ColorRGBA sCol = style.GetColorSurfRGBA();
RenderTransp = 1.0 - sCol.Alpha();
surfColor = Styles.EncodeColor(sCol.GetRGB(),DPDCs,ColRGBs);
}
if ( style.IsSetColorCurv() )
curvColor = Styles.EncodeColor(style.GetColorCurv(),DPDCs,ColRGBs);
@@ -1096,12 +1100,12 @@ static void MakeSTEPStyles (STEPConstruct_Styles &Styles,
Handle(StepRepr_RepresentationItem)::DownCast(seqRI(i));
Handle(StepVisual_PresentationStyleAssignment) PSA;
if ( style.IsVisible() || !surfColor.IsNull() || !curvColor.IsNull() ) {
PSA = Styles.MakeColorPSA ( item, surfColor, curvColor, isComponent );
PSA = Styles.MakeColorPSA ( item, surfColor, curvColor, surfColor, RenderTransp, isComponent );
}
else {
// default white color
surfColor = Styles.EncodeColor(Quantity_Color(Quantity_NOC_WHITE),DPDCs,ColRGBs);
PSA = Styles.MakeColorPSA ( item, surfColor, curvColor, isComponent );
PSA = Styles.MakeColorPSA ( item, surfColor, curvColor, surfColor, 0.0, isComponent );
if ( isComponent )
setDefaultInstanceColor( override, PSA);
@@ -1219,7 +1223,7 @@ Standard_Boolean STEPCAFControl_Writer::WriteColors (const Handle(XSControl_Work
for ( Standard_Integer j = 1; j <= seq.Length(); j++ ) {
TDF_Label lab = seq.Value(j);
XCAFPrs_Style style;
Quantity_Color C;
Quantity_ColorRGBA C;
if ( lab == L ) {
// check for invisible status of object on label
if ( !CTool->IsVisible( lab ) ) {
@@ -1228,13 +1232,13 @@ Standard_Boolean STEPCAFControl_Writer::WriteColors (const Handle(XSControl_Work
}
}
if ( CTool->GetColor ( lab, XCAFDoc_ColorGen, C ) ) {
style.SetColorCurv ( C );
style.SetColorCurv ( C.GetRGB() );
style.SetColorSurf ( C );
}
if ( CTool->GetColor ( lab, XCAFDoc_ColorSurf, C ) )
style.SetColorSurf ( C );
if ( CTool->GetColor ( lab, XCAFDoc_ColorCurv, C ) )
style.SetColorCurv ( C );
style.SetColorCurv ( C.GetRGB() );
if (!style.IsSetColorSurf())
{
Handle(XCAFDoc_VisMaterial) aVisMat = aMatTool->GetShapeMaterial (lab);
@@ -1872,8 +1876,12 @@ static Standard_Boolean createSHUOStyledItem (const XCAFPrs_Style& style,
STEPConstruct_Styles Styles( WS );
// translate colors to STEP
Handle(StepVisual_Colour) surfColor, curvColor;
if ( style.IsSetColorSurf() )
surfColor = Styles.EncodeColor ( style.GetColorSurf() );
Standard_Real RenderTransp = 0.0;
if ( style.IsSetColorSurf() ) {
Quantity_ColorRGBA sCol = style.GetColorSurfRGBA();
RenderTransp = 1.0 - sCol.Alpha();
surfColor = Styles.EncodeColor ( sCol.GetRGB() );
}
if ( style.IsSetColorCurv() )
curvColor = Styles.EncodeColor ( style.GetColorCurv() );
Standard_Boolean isComponent = Standard_True;// cause need to get PSBC
@@ -1885,7 +1893,7 @@ static Standard_Boolean createSHUOStyledItem (const XCAFPrs_Style& style,
isSetDefaultColor = Standard_True;
}
Handle(StepVisual_PresentationStyleAssignment) PSA =
Styles.MakeColorPSA ( item, surfColor, curvColor, isComponent );
Styles.MakeColorPSA ( item, surfColor, curvColor, surfColor, RenderTransp, isComponent );
Handle(StepVisual_StyledItem) override; //null styled item
// find the repr item of the shape
@@ -3742,7 +3750,7 @@ Standard_Boolean STEPCAFControl_Writer::WriteDGTsAP242 (const Handle(XSControl_W
STEPConstruct_Styles aStyles (WS);
Handle(StepVisual_Colour) aCurvColor = aStyles.EncodeColor(Quantity_NOC_WHITE);
Handle(StepRepr_RepresentationItem) anItem = NULL;
myGDTPrsCurveStyle->SetValue(1, aStyles.MakeColorPSA(anItem, aCurvColor, aCurvColor));
myGDTPrsCurveStyle->SetValue(1, aStyles.MakeColorPSA(anItem, aCurvColor, aCurvColor, aCurvColor, 0.0));
Interface_EntityIterator aModelIter = aModel->Entities();
for (; aModelIter.More() && myGDTCommonPDS.IsNull(); aModelIter.Next())
myGDTCommonPDS = Handle(StepRepr_ProductDefinitionShape)::DownCast(aModelIter.Value());