diff --git a/src/QABugs/QABugs_19.cxx b/src/QABugs/QABugs_19.cxx index 4d8b65470c..8886120533 100755 --- a/src/QABugs/QABugs_19.cxx +++ b/src/QABugs/QABugs_19.cxx @@ -1735,6 +1735,38 @@ struct QABugs_NHandleClass } }; +#include +#include +#include +static Standard_Integer OCC23951 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv) +{ + if (argc != 1) { + di << "Usage: " << argv[0] << " invalid number of arguments" << "\n"; + return 1; + } + Handle(TDocStd_Document) aDoc = new TDocStd_Document("dummy");; + TopoDS_Shape s1 = BRepPrimAPI_MakeBox(1,1,1).Shape(); + TDF_Label lab1 = XCAFDoc_DocumentTool::ShapeTool (aDoc->Main ())->NewShape(); + XCAFDoc_DocumentTool::ShapeTool (aDoc->Main ())->SetShape(lab1, s1); + TDataStd_Name::Set(lab1, "Box1"); + + Quantity_Color yellow(1,1,0, Quantity_TOC_RGB); + XCAFDoc_DocumentTool::ColorTool (aDoc->Main())->SetColor(lab1, yellow, XCAFDoc_ColorGen); + XCAFDoc_DocumentTool::ColorTool(aDoc->Main())->SetVisibility(lab1, 0); + + STEPControl_StepModelType mode = STEPControl_AsIs; + STEPCAFControl_Writer writer; + if ( ! writer.Transfer (aDoc, mode ) ) + { + di << "The document cannot be translated or gives no result" << "\n"; + return 1; + } + + writer.Write("test_box.step"); + return 0; +} + + //======================================================================= //function : OCC24622 //purpose : The command tests sourcing Image_PixMap to AIS_TexturedShape @@ -2277,6 +2309,7 @@ void QABugs::Commands_19(Draw_Interpretor& theCommands) { theCommands.Add ("OCC24565", "OCC24565 FileNameIGS FileNameSTOR", __FILE__, OCC24565, group); theCommands.Add ("OCC24755", "OCC24755", __FILE__, OCC24755, group); theCommands.Add ("OCC24834", "OCC24834", __FILE__, OCC24834, group); + theCommands.Add ("OCC23951", "OCC23951", __FILE__, OCC23951, group); theCommands.Add ("OCC24931", "OCC24931", __FILE__, OCC24931, group); return; } diff --git a/src/STEPCAFControl/STEPCAFControl_Writer.cxx b/src/STEPCAFControl/STEPCAFControl_Writer.cxx index 89c51c2b3c..1b8c342ddb 100644 --- a/src/STEPCAFControl/STEPCAFControl_Writer.cxx +++ b/src/STEPCAFControl/STEPCAFControl_Writer.cxx @@ -1079,7 +1079,7 @@ Standard_Boolean STEPCAFControl_Writer::WriteColors (const Handle(XSControl_Work TDF_Label lab = seq.Value(j); XCAFPrs_Style style; Quantity_Color C; - if ( isComponent && lab == L ) { + if ( lab == L ) { // check for invisible status of object on label if ( !CTool->IsVisible( lab ) ) { isVisible = Standard_False; @@ -1167,28 +1167,28 @@ Standard_Boolean STEPCAFControl_Writer::WriteColors (const Handle(XSControl_Work newItems->SetValue( el++, Handle(StepRepr_RepresentationItem)::DownCast(Styles.Style(si))); // WP->Model()->AddWithRefs ( Handle(StepRepr_RepresentationItem)::DownCast (Styles.Style(si))); } - if ( !isVisible ) { - // create invisibility item and refer for stiledItem - Handle(StepVisual_Invisibility) Invsblt = new StepVisual_Invisibility(); - Handle(StepVisual_HArray1OfInvisibleItem) HInvsblItm = - new StepVisual_HArray1OfInvisibleItem (1,Styles.NbStyles()); - // put all style item into the harray - for ( si=1; si <= Styles.NbStyles(); si++ ) { - Handle(StepRepr_RepresentationItem) styledItm = - Handle(StepRepr_RepresentationItem)::DownCast(Styles.Style(si)); - StepVisual_InvisibleItem anInvItem; - anInvItem.SetValue( styledItm ); - HInvsblItm->SetValue( si, anInvItem ); - } - // set the invisibility of items - Invsblt->Init( HInvsblItm ); - WS->Model()->AddWithRefs( Invsblt ); - } - + if (newItems->Length() > 0) aMDGPR->SetItems( newItems ); } //end of work with CDSR } + if ( !isVisible ) { + // create invisibility item and refer for stiledItem + Handle(StepVisual_Invisibility) Invsblt = new StepVisual_Invisibility(); + Handle(StepVisual_HArray1OfInvisibleItem) HInvsblItm = + new StepVisual_HArray1OfInvisibleItem (1,Styles.NbStyles()); + // put all style item into the harray + for ( Standard_Integer si=1; si <= Styles.NbStyles(); si++ ) { + Handle(StepRepr_RepresentationItem) styledItm = + Handle(StepRepr_RepresentationItem)::DownCast(Styles.Style(si)); + StepVisual_InvisibleItem anInvItem; + anInvItem.SetValue( styledItm ); + HInvsblItm->SetValue( si, anInvItem ); + } + // set the invisibility of items + Invsblt->Init( HInvsblItm ); + WS->Model()->AddWithRefs( Invsblt ); + } } return Standard_True; diff --git a/tests/bugs/xde/bug23951 b/tests/bugs/xde/bug23951 new file mode 100644 index 0000000000..72c6f837e5 --- /dev/null +++ b/tests/bugs/xde/bug23951 @@ -0,0 +1,23 @@ +puts "==========" +puts "OCC23951" +puts "==========" +puts "" +##################################################################################### +# Visibility of free, simple shapes not saved when writing XCAF Document info STEP +##################################################################################### + +pload QAcommands + +set info [OCC23951] + +if { [regexp "Write Done" $info] != 1 } { + puts "Error: file was not written" +} else { + puts "OK: file was written" +} + +stepread test_box.step a * +axo +fit + +set only_screen_axo 1