0030087: Invalid result of the translation of the assembly when relating and related...
authorgka <gka@opencascade.com>
Fri, 24 Aug 2018 16:08:38 +0000 (19:08 +0300)
committerbugmaster <bugmaster@opencascade.com>
Mon, 3 Sep 2018 12:48:41 +0000 (15:48 +0300)
Detection of specific case of error in the definition of transformation matrix describing position of the component within assembly, when it has Axis Placements swapped, is corrected to handle the case when one of these Axis Placements is contained in both Shape Representations (of the assembly and its component).
This allows the problematic STEP file to be translated correctly.

Added test bugs step bug30087

src/STEPControl/STEPControl_ActorRead.cxx
tests/bugs/step/bug30087 [new file with mode: 0644]
tests/de/step_2/F3

index 3ea8eb4..4c9dc89 100644 (file)
@@ -1612,22 +1612,32 @@ Standard_Boolean STEPControl_ActorRead::ComputeTransformation (const Handle(Step
   // corresponding reps and fix case of inversion error
   Handle(StepGeom_Axis2Placement3d) org = Origin;
   Handle(StepGeom_Axis2Placement3d) trg = Target;
-  Standard_Integer code1=0, code2=0, i;
-  for ( i=1; code1 != 1 && i <= OrigContext->NbItems(); i++ ) {
-    if ( OrigContext->ItemsValue(i) == org ) code1 = 1;
-    else if ( OrigContext->ItemsValue(i) == trg ) code1 = -1;
+  Standard_Boolean isOKOrigin = Standard_False, isSwapOrigin = Standard_False;
+  Standard_Boolean isOKTarget = Standard_False, isSwapTarget = Standard_False;
+  for (Standard_Integer i=1; i <= OrigContext->NbItems(); i++)
+  {
+    if (OrigContext->ItemsValue(i) == org) 
+      isOKOrigin = Standard_True;
+    else if (OrigContext->ItemsValue(i) == trg) 
+      isSwapTarget = Standard_True;
   }
-  for ( i=1; code2 != 1 && i <= TargContext->NbItems(); i++ ) {
-    if ( TargContext->ItemsValue(i) == org ) code2 = -1;
-    else if ( TargContext->ItemsValue(i) == trg ) code2 = 1;
+  for (Standard_Integer i=1; i <= TargContext->NbItems(); i++)
+  {
+    if (TargContext->ItemsValue(i) == trg)
+      isOKTarget = Standard_True;
+    else if (TargContext->ItemsValue(i) == org)
+      isSwapOrigin = Standard_True;
   }
-  if ( code1 != 1 && code2 != 1 ) {
-    if ( code1 == -1 && code2 == -1 ) {
-      Handle(StepGeom_Axis2Placement3d) swp = org; org = trg; trg = swp;
+  if (! isOKOrigin || ! isOKTarget)
+  {
+    if (isSwapOrigin && isSwapTarget)
+    {
+      std::swap (org, trg);
       TP->AddWarning ( org, "Axis placements are swapped in SRRWT; corrected" );
     }
-    else {
-      TP->AddWarning ( ( code1 == 1 ? trg : org ), 
+    else
+    {
+      TP->AddWarning ( (isOKOrigin ? trg : org),
                        "Axis placement used by SRRWT does not belong to corresponding representation" );
     }
   }
diff --git a/tests/bugs/step/bug30087 b/tests/bugs/step/bug30087
new file mode 100644 (file)
index 0000000..ce22247
--- /dev/null
@@ -0,0 +1,19 @@
+puts "# ====================================================================="
+puts "# 30087: Data Exchange, STEP - invalid result of translation of assembly when relating and related products are mixed in the SRR entity"
+puts "# ====================================================================="
+puts ""
+
+set filepath [locate_data_file bug30087.stp]
+stepread $filepath a *
+tpcompound result
+
+puts "Check dimensions of the result -- will be different if some parts are misplaced"
+set values [bounding result]
+set expected { -0.66 -0.33 -11. 70.66 140.66 10. }
+set components {XMin YMin ZMin XMax YMax ZMax }
+for {set i 0} {$i < 6} {incr i} {
+  checkreal [lindex $components $i] [lindex $values $i] [lindex $expected $i] 0.1 0
+}
+
+puts "Make snapshot to have visual check as well"
+checkview -display result -2d -path ${imagedir}/${test_image}.png
index c116800..9bead17 100644 (file)
@@ -1,5 +1,4 @@
 # !!!! This file is generated automatically, do not edit manually! See end script
-puts "TODO CR23096 ALL: TPSTAT : Faulty" 
 puts "TODO CR23096 ALL: NBSHAPES : Faulty" 
 puts "TODO CR23096 ALL: LABELS : Faulty" 
 puts "TODO CR23096 ALL: LAYERS : Faulty" 
@@ -9,7 +8,7 @@ set filename bm4_db_conn_d.stp
 
 set ref_data {
 DATA        : Faulties = 0  ( 0 )  Warnings = 0  ( 0 )  Summary  = 0  ( 0 )
-TPSTAT      : Faulties = 0  ( 0 )  Warnings = 16  ( 8 )  Summary  = 16  ( 8 )
+TPSTAT      : Faulties = 0  ( 0 )  Warnings = 16  ( 40 )  Summary  = 16  ( 40 )
 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 )