Now roots-references in XCAF Document can be exported to STEP without losing structure of assembly/sharing/metadata of this root. New auxiliary root assembly with each root-reference is created to save all necessary data.
TDF_LabelSequence sublabels;
for ( Standard_Integer i=1; i <= labels.Length(); i++ ) {
TDF_Label L = labels.Value(i);
- TopoDS_Shape dummy;
if ( myLabels.IsBound ( L ) ) continue; // already processed
TopoDS_Shape shape = XCAFDoc_ShapeTool::GetShape ( L );
if ( shape.IsNull() ) continue;
-
+
// write shape either as a whole, or as multifile (with extern refs)
if ( ! multi ) {
Actor->SetStdMode ( Standard_False );
TDF_LabelSequence comp;
- //for case when only part of assemby structure should be written in the document
+ //For case when only part of assemby structure should be written in the document
//if specified label is component of the assembly then
//in order to save location of this component in the high-level assembly
//and save name of high-level assembly it is necessary to represent structure of high-level assembly
//as assembly with one component specified by current label.
//For that compound containing only specified component is binded to the label of the high-level assembly.
//The such way full structure of high-level assembly was replaced on the assembly contaning one component.
- if ( XCAFDoc_ShapeTool::IsComponent ( L ) )
+ //For case when free shape reference is (located root) also create an auxiliary assembly.
+ if ( XCAFDoc_ShapeTool::IsReference ( L ) )
{
TopoDS_Compound aComp;
BRep_Builder aB;
if(XCAFDoc_ShapeTool::IsAssembly ( ref))
XCAFDoc_ShapeTool::GetComponents ( ref, comp, Standard_True );
}
- L = L.Father();
+ if ( !XCAFDoc_ShapeTool::IsFree ( L ) )
+ L = L.Father();
}
else
{
}
myLabels.Bind ( L, shape );
sublabels.Append ( L );
- if ( XCAFDoc_ShapeTool::IsAssembly ( L ) )
+
+ if ( XCAFDoc_ShapeTool::IsAssembly ( L ) || XCAFDoc_ShapeTool::IsReference ( L ) )
Actor->RegisterAssembly ( shape );
writer.Transfer(shape,mode,Standard_False);
--- /dev/null
+########################################
+# Wrong export to STEP of located root.
+########################################
+
+pload OCAF
+
+XOpen [locate_data_file bug30189.xbf] D
+WriteStep D $imagedir/${casename}.stp
+ReadStep DD $imagedir/${casename}.stp
+
+# Check location
+XGetOneShape res DD
+set props [lprops res]
+
+if {[lindex $props 9] != "90"} {
+ puts "Error: wrong location on shape."
+}
+if {[lindex $props 12] != "75"} {
+ puts "Error: wrong location on shape."
+}
+if {[lindex $props 15] != "60"} {
+ puts "Error: wrong location on shape."
+}
+
+# Check structure
+set top_level [XGetTopLevelShapes DD]
+if {$top_level != "0:1:1:1 0:1:1:2 0:1:1:3 0:1:1:4 "} {
+ puts "Error: wrong structure of document."
+}
+set nb [XNbComponents DD 0:1:1:1]
+if {$nb != "1"} {
+ puts "Error: wrong structure of document."
+}
+set nb [XNbComponents DD 0:1:1:2]
+if {$nb != "3"} {
+ puts "Error: wrong structure of document."
+}
+
+# Check colors
+set color [XGetShapeColor DD 0:1:1:3 surf]
+if {$color != "RED"} {
+ puts "Error: wrong color."
+}
+set color [XGetShapeColor DD 0:1:1:4 surf]
+if {$color != "DARKORANGE1"} {
+ puts "Error: wrong color."
+}
+
+Close D
+Close DD
+file delete $imagedir/${casename}.stp
--- /dev/null
+########################################
+# Wrong export to STEP of located root.
+########################################
+
+pload OCAF
+
+XNewDoc D
+box b 1 1 1
+box bb 2 0 0 1 1 1
+box bbb 4 0 0 1 1 1
+compound b bb c
+copy c cc
+ttranslate cc 0 2 0
+compound bbb c s
+XAddShape D s
+XAddShape D cc
+WriteStep D $imagedir/${casename}.stp
+ReadStep DD $imagedir/${casename}.stp
+
+# Check structure
+set top_level [XGetTopLevelShapes DD]
+if {$top_level != "0:1:1:1 0:1:1:2 0:1:1:3 0:1:1:4 0:1:1:5 0:1:1:6 "} {
+ puts "Error: wrong structure of document."
+}
+
+# Check sharing
+set nb [XNbComponents DD 0:1:1:6]
+if {$nb != "1"} {
+ puts "Error: wrong structure of document."
+}
+set nb [XGetUsers DD 0:1:1:3]
+if {$nb != "2"} {
+ puts "Error: wrong structure of document."
+}
+
+Close D
+Close DD
+file delete $imagedir/${casename}.stp
--- /dev/null
+########################################
+# Wrong export to STEP of located root.
+########################################
+
+pload OCAF
+
+box b 1 1 1
+copy b bb
+copy b bbb
+ttranslate b 2 0 0
+ttranslate bb 0 2 0
+ttranslate bbb 0 0 2
+XNewDoc D
+XAddShape D b
+XAddShape D bb
+XAddShape D bbb
+SetName D 0:1:1:2 box
+SetName D 0:1:1:1 ref1_box
+SetName D 0:1:1:3 ref2_box
+SetName D 0:1:1:4 ref3_box
+WriteStep D $imagedir/${casename}.stp
+ReadStep DD $imagedir/${casename}.stp
+
+# Check structure
+set top_level [XGetTopLevelShapes DD]
+if {$top_level != "0:1:1:1 0:1:1:2 0:1:1:3 0:1:1:4 "} {
+ puts "Error: wrong structure of document."
+}
+
+# Check sharing
+set nb [XGetUsers DD 0:1:1:2]
+if {$nb != "3"} {
+ puts "Error: wrong structure of document."
+}
+
+# Check names
+set name [GetName DD 0:1:1:1]
+if {$name != "ref1_box"} {
+ puts "Error: wrong name."
+}
+set name [GetName DD 0:1:1:2]
+if {$name != "box"} {
+ puts "Error: wrong name."
+}
+set name [GetName DD 0:1:1:3]
+if {$name != "ref2_box"} {
+ puts "Error: wrong name."
+}
+set name [GetName DD 0:1:1:4]
+if {$name != "ref3_box"} {
+ puts "Error: wrong name."
+}
+
+Close D
+Close DD
+file delete $imagedir/${casename}.stp
NBSHAPES : Solid = 1 ( 1 ) Shell = 1 ( 1 ) Face = 1 ( 1 )
STATSHAPE : Solid = 1 ( 1 ) Shell = 1 ( 1 ) Face = 1 ( 1 ) FreeWire = 0 ( 0 )
TOLERANCE : MaxTol = 1e-007 ( 1e-007 ) AvgTol = 1e-007 ( 1e-007 )
-LABELS : N0Labels = 1 ( 2 ) N1Labels = 0 ( 0 ) N2Labels = 0 ( 0 ) TotalLabels = 1 ( 2 ) NameLabels = 1 ( 2 ) ColorLabels = 0 ( 0 ) LayerLabels = 0 ( 0 )
+LABELS : N0Labels = 2 ( 2 ) N1Labels = 1 ( 0 ) N2Labels = 0 ( 0 ) TotalLabels = 3 ( 2 ) NameLabels = 3 ( 2 ) ColorLabels = 0 ( 0 ) LayerLabels = 0 ( 0 )
PROPS : Centroid = 0 ( 0 ) Volume = 0 ( 0 ) Area = 0 ( 0 )
NCOLORS : NColors = 0 ( 0 )
COLORS : Colors = ( )
NBSHAPES : Solid = 1 ( 1 ) Shell = 1 ( 1 ) Face = 6 ( 6 )
STATSHAPE : Solid = 1 ( 1 ) Shell = 1 ( 1 ) Face = 6 ( 6 ) FreeWire = 0 ( 0 )
TOLERANCE : MaxTol = 1e-007 ( 1e-007 ) AvgTol = 1e-007 ( 1e-007 )
-LABELS : N0Labels = 1 ( 2 ) N1Labels = 0 ( 0 ) N2Labels = 0 ( 0 ) TotalLabels = 1 ( 2 ) NameLabels = 1 ( 2 ) ColorLabels = 0 ( 0 ) LayerLabels = 0 ( 0 )
+LABELS : N0Labels = 2 ( 2 ) N1Labels = 1 ( 0 ) N2Labels = 0 ( 0 ) TotalLabels = 3 ( 2 ) NameLabels = 3 ( 2 ) ColorLabels = 0 ( 0 ) LayerLabels = 0 ( 0 )
PROPS : Centroid = 0 ( 0 ) Volume = 0 ( 0 ) Area = 0 ( 0 )
NCOLORS : NColors = 0 ( 0 )
COLORS : Colors = ( )
NBSHAPES : Solid = 0 ( 0 ) Shell = 48 ( 48 ) Face = 48 ( 48 )
STATSHAPE : Solid = 0 ( 0 ) Shell = 48 ( 48 ) Face = 48 ( 48 ) FreeWire = 0 ( 0 )
TOLERANCE : MaxTol = 0.001635034952 ( 0.001635034951 ) AvgTol = 1.541289792e-005 ( 1.541289793e-005 )
-LABELS : N0Labels = 1 ( 2 ) N1Labels = 0 ( 0 ) N2Labels = 0 ( 0 ) TotalLabels = 1 ( 2 ) NameLabels = 1 ( 2 ) ColorLabels = 0 ( 0 ) LayerLabels = 0 ( 0 )
+LABELS : N0Labels = 2 ( 2 ) N1Labels = 1 ( 0 ) N2Labels = 0 ( 0 ) TotalLabels = 3 ( 2 ) NameLabels = 3 ( 2 ) ColorLabels = 0 ( 0 ) LayerLabels = 0 ( 0 )
PROPS : Centroid = 0 ( 0 ) Volume = 0 ( 0 ) Area = 0 ( 0 )
NCOLORS : NColors = 0 ( 0 )
COLORS : Colors = ( )
set ref_data {
DATA : Faulties = 0 ( 0 ) Warnings = 0 ( 0 ) Summary = 0 ( 0 )
-TPSTAT : Faulties = 0 ( 0 ) Warnings = 0 ( 0 ) Summary = 0 ( 0 )
+TPSTAT : Faulties = 0 ( 0 ) Warnings = 0 ( 32 ) Summary = 0 ( 32 )
CHECKSHAPE : Wires = 0 ( 0 ) Faces = 0 ( 0 ) Shells = 0 ( 0 ) Solids = 0 ( 0 )
NBSHAPES : Solid = 60 ( 3 ) Shell = 60 ( 3 ) Face = 2526 ( 504 )
STATSHAPE : Solid = 114 ( 114 ) Shell = 114 ( 114 ) Face = 4044 ( 4044 ) FreeWire = 0 ( 0 )
TOLERANCE : MaxTol = 1.593765994e-007 ( 1.593765994e-007 ) AvgTol = 1.001764514e-007 ( 1.001764514e-007 )
-LABELS : N0Labels = 6 ( 7 ) N1Labels = 31 ( 33 ) N2Labels = 0 ( 0 ) TotalLabels = 37 ( 40 ) NameLabels = 37 ( 36 ) ColorLabels = 3 ( 3 ) LayerLabels = 3 ( 35 )
+LABELS : N0Labels = 7 ( 7 ) N1Labels = 33 ( 33 ) N2Labels = 0 ( 0 ) TotalLabels = 40 ( 40 ) NameLabels = 39 ( 36 ) ColorLabels = 3 ( 3 ) LayerLabels = 4 ( 35 )
PROPS : Centroid = 0 ( 0 ) Volume = 0 ( 0 ) Area = 0 ( 0 )
NCOLORS : NColors = 3 ( 3 )
COLORS : Colors = CYAN1 WHITE YELLOW ( CYAN1 WHITE YELLOW )
-NLAYERS : NLayers = 3 ( 6 )
-LAYERS : Layers = 1 10 5 ( { 0} { 1} { 5} { 10} 200 255 )
+NLAYERS : NLayers = 4 ( 6 )
+LAYERS : Layers = 1 10 255 5 ( { 0} { 1} { 5} { 10} 200 255 )
}
NBSHAPES : Solid = 60 ( 3 ) Shell = 60 ( 3 ) Face = 2526 ( 504 )
STATSHAPE : Solid = 114 ( 114 ) Shell = 114 ( 114 ) Face = 4044 ( 4044 ) FreeWire = 0 ( 0 )
TOLERANCE : MaxTol = 1e-007 ( 1e-007 ) AvgTol = 1e-007 ( 1e-007 )
-LABELS : N0Labels = 6 ( 7 ) N1Labels = 31 ( 33 ) N2Labels = 0 ( 0 ) TotalLabels = 37 ( 40 ) NameLabels = 37 ( 36 ) ColorLabels = 3 ( 3 ) LayerLabels = 3 ( 35 )
+LABELS : N0Labels = 7 ( 7 ) N1Labels = 33 ( 33 ) N2Labels = 0 ( 0 ) TotalLabels = 40 ( 40 ) NameLabels = 39 ( 36 ) ColorLabels = 3 ( 3 ) LayerLabels = 4 ( 35 )
PROPS : Centroid = 0 ( 0 ) Volume = 0 ( 0 ) Area = 0 ( 0 )
NCOLORS : NColors = 3 ( 3 )
COLORS : Colors = CYAN1 WHITE YELLOW ( CYAN1 WHITE YELLOW )
-NLAYERS : NLayers = 3 ( 6 )
-LAYERS : Layers = 1 10 5 ( { 0} { 1} { 5} { 10} 200 255 )
+NLAYERS : NLayers = 4 ( 6 )
+LAYERS : Layers = 1 10 255 5 ( { 0} { 1} { 5} { 10} 200 255 )
}