1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-04-05 18:16:23 +03:00

0023951: Visibility of free, simple shapes not saved when writing XCAF Document into STEP

Delete check for top-level shape during writing invisibility property.
Added QA command OCC23951.
Fix crash in QA command OCC23951: initialize document, initialize shape.
Added test case bugs/xde/bug23951
Modified QABugs/QABugs_19.cxx to avoid warnings
This commit is contained in:
ika 2014-05-29 16:14:45 +04:00 committed by apn
parent 70167e6982
commit 574d723693
3 changed files with 75 additions and 19 deletions

View File

@ -1735,6 +1735,38 @@ struct QABugs_NHandleClass
}
};
#include <XCAFDoc_ColorTool.hxx>
#include <STEPControl_StepModelType.hxx>
#include <STEPCAFControl_Writer.hxx>
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;
}

View File

@ -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;

23
tests/bugs/xde/bug23951 Normal file
View File

@ -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