From 87efa821fa499bc5d01178dd31f68ab3fbe8c7b2 Mon Sep 17 00:00:00 2001 From: ika Date: Tue, 2 Oct 2018 18:29:40 +0300 Subject: [PATCH] 0030189: Data Exchange - Wrong export to STEP of located root. 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. --- src/STEPCAFControl/STEPCAFControl_Writer.cxx | 14 ++--- tests/bugs/step/bug30189_1 | 51 ++++++++++++++++++ tests/bugs/step/bug30189_2 | 38 +++++++++++++ tests/bugs/step/bug30189_3 | 56 ++++++++++++++++++++ tests/de/step_1/ZD3 | 2 +- tests/de/step_1/ZD4 | 2 +- tests/de/step_2/A1 | 2 +- tests/de/step_2/F2 | 8 +-- tests/de/step_2/F3 | 6 +-- 9 files changed, 163 insertions(+), 16 deletions(-) create mode 100644 tests/bugs/step/bug30189_1 create mode 100644 tests/bugs/step/bug30189_2 create mode 100644 tests/bugs/step/bug30189_3 diff --git a/src/STEPCAFControl/STEPCAFControl_Writer.cxx b/src/STEPCAFControl/STEPCAFControl_Writer.cxx index f0580416e6..05b18401ec 100644 --- a/src/STEPCAFControl/STEPCAFControl_Writer.cxx +++ b/src/STEPCAFControl/STEPCAFControl_Writer.cxx @@ -512,26 +512,26 @@ Standard_Boolean STEPCAFControl_Writer::Transfer (STEPControl_Writer &writer, 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; @@ -545,7 +545,8 @@ Standard_Boolean STEPCAFControl_Writer::Transfer (STEPControl_Writer &writer, if(XCAFDoc_ShapeTool::IsAssembly ( ref)) XCAFDoc_ShapeTool::GetComponents ( ref, comp, Standard_True ); } - L = L.Father(); + if ( !XCAFDoc_ShapeTool::IsFree ( L ) ) + L = L.Father(); } else { @@ -568,7 +569,8 @@ Standard_Boolean STEPCAFControl_Writer::Transfer (STEPControl_Writer &writer, } 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); diff --git a/tests/bugs/step/bug30189_1 b/tests/bugs/step/bug30189_1 new file mode 100644 index 0000000000..bf75b49f61 --- /dev/null +++ b/tests/bugs/step/bug30189_1 @@ -0,0 +1,51 @@ +######################################## +# 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 diff --git a/tests/bugs/step/bug30189_2 b/tests/bugs/step/bug30189_2 new file mode 100644 index 0000000000..c5598320e1 --- /dev/null +++ b/tests/bugs/step/bug30189_2 @@ -0,0 +1,38 @@ +######################################## +# 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 diff --git a/tests/bugs/step/bug30189_3 b/tests/bugs/step/bug30189_3 new file mode 100644 index 0000000000..903407e2ef --- /dev/null +++ b/tests/bugs/step/bug30189_3 @@ -0,0 +1,56 @@ +######################################## +# 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 diff --git a/tests/de/step_1/ZD3 b/tests/de/step_1/ZD3 index 1b9335929b..4102d6eeaf 100644 --- a/tests/de/step_1/ZD3 +++ b/tests/de/step_1/ZD3 @@ -12,7 +12,7 @@ CHECKSHAPE : Wires = 0 ( 0 ) Faces = 0 ( 0 ) Shells = 0 ( 0 ) So 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 = ( ) diff --git a/tests/de/step_1/ZD4 b/tests/de/step_1/ZD4 index 7bd0defb0f..d0d5e7fe91 100644 --- a/tests/de/step_1/ZD4 +++ b/tests/de/step_1/ZD4 @@ -12,7 +12,7 @@ CHECKSHAPE : Wires = 0 ( 0 ) Faces = 0 ( 0 ) Shells = 0 ( 0 ) So 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 = ( ) diff --git a/tests/de/step_2/A1 b/tests/de/step_2/A1 index 56cda7049d..04754bc909 100644 --- a/tests/de/step_2/A1 +++ b/tests/de/step_2/A1 @@ -12,7 +12,7 @@ CHECKSHAPE : Wires = 0 ( 0 ) Faces = 0 ( 0 ) Shells = 0 ( 0 ) So 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 = ( ) diff --git a/tests/de/step_2/F2 b/tests/de/step_2/F2 index 00187595a9..d3e1fb14d2 100644 --- a/tests/de/step_2/F2 +++ b/tests/de/step_2/F2 @@ -8,16 +8,16 @@ set filename bm4_db_conn_a.stp 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 ) } diff --git a/tests/de/step_2/F3 b/tests/de/step_2/F3 index 9bead17619..de376bd6f8 100644 --- a/tests/de/step_2/F3 +++ b/tests/de/step_2/F3 @@ -13,11 +13,11 @@ CHECKSHAPE : Wires = 0 ( 0 ) Faces = 0 ( 0 ) Shells = 0 ( 0 ) So 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 ) }