Salome HOME
Issue #20167: checkPythonDump() errors V9_6_0b1
authorArtem Zhidkov <Artem.Zhidkov@opencascade.com>
Fri, 16 Oct 2020 08:37:21 +0000 (11:37 +0300)
committerArtem Zhidkov <Artem.Zhidkov@opencascade.com>
Fri, 16 Oct 2020 08:37:21 +0000 (11:37 +0300)
Improve performance of bounding box calculation while dumping.

src/FeaturesPlugin/Test/TestFillet_MultiLevelCompound_v0_3.py
src/FeaturesPlugin/Test/TestFillet_MultiLevelCompound_v0_4.py
src/FeaturesPlugin/Test/TestFillet_MultiLevelCompound_v95_3.py
src/FeaturesPlugin/Test/TestFillet_MultiLevelCompound_v95_4.py
src/FeaturesPlugin/Test/TestScale_MultiLevelCompound_v95_2.py
src/GeomAPI/GeomAPI_Shape.cpp

index e035002b6d64cdf2232351d9220e873391b67a2e..b15634542b8c91df069147281c6f1aafc60b6828 100644 (file)
@@ -124,7 +124,7 @@ model.testNbSubShapes(Fillet_6, GeomAPI_Shape.FACE, [23])
 model.testNbSubShapes(Fillet_6, GeomAPI_Shape.EDGE, [95])
 model.testNbSubShapes(Fillet_6, GeomAPI_Shape.VERTEX, [190])
 model.testResultsVolumes(Fillet_6, [1565.568094166])
-refPoint = GeomAPI_Pnt(2.50004995, 2.50004995, 5.00005)
+refPoint = GeomAPI_Pnt(2.7448, 2.7448, 5)
 midPoint = Fillet_6.defaultResult().shape().middlePoint()
 assert(midPoint.distance(refPoint) < TOLERANCE)
 
index 258f7ef0167b42192bebf57a94b28a452148654c..b1b177b6581e683f5dc6aae51a4f8748ec87fc09 100644 (file)
@@ -127,7 +127,7 @@ model.testNbSubShapes(Fillet_6, GeomAPI_Shape.FACE, [23])
 model.testNbSubShapes(Fillet_6, GeomAPI_Shape.EDGE, [95])
 model.testNbSubShapes(Fillet_6, GeomAPI_Shape.VERTEX, [190])
 model.testResultsVolumes(Fillet_6, [1565.568094166])
-refPoint = GeomAPI_Pnt(2.50004995, 2.50004995, 5.00005)
+refPoint = GeomAPI_Pnt(2.7448, 2.7448, 5)
 midPoint = Fillet_6.defaultResult().shape().middlePoint()
 assert(midPoint.distance(refPoint) < TOLERANCE)
 
index d02ae88274f0ec9326d5ee444aa3200cb6dd4fd4..4ad363735f8ca42bbc5d773f5cb9efd11479c1d5 100644 (file)
@@ -124,7 +124,7 @@ model.testNbSubShapes(Fillet_6, GeomAPI_Shape.FACE, [23])
 model.testNbSubShapes(Fillet_6, GeomAPI_Shape.EDGE, [95])
 model.testNbSubShapes(Fillet_6, GeomAPI_Shape.VERTEX, [190])
 model.testResultsVolumes(Fillet_6, [1565.568094166])
-refPoint = GeomAPI_Pnt(2.50004995, 2.50004995, 5.00005)
+refPoint = GeomAPI_Pnt(2.7448, 2.7448, 5)
 midPoint = Fillet_6.defaultResult().shape().middlePoint()
 assert(midPoint.distance(refPoint) < TOLERANCE)
 
@@ -136,7 +136,7 @@ model.testNbSubShapes(Fillet_7, GeomAPI_Shape.FACE, [23])
 model.testNbSubShapes(Fillet_7, GeomAPI_Shape.EDGE, [98])
 model.testNbSubShapes(Fillet_7, GeomAPI_Shape.VERTEX, [196])
 model.testResultsVolumes(Fillet_7, [2976.0685684791988])
-refPoint = GeomAPI_Pnt(-20.9807621135, 42.5, 5)
+refPoint = GeomAPI_Pnt(-20.9807621135, 42.806, 5)
 midPoint = Fillet_7.defaultResult().shape().middlePoint()
 assert(midPoint.distance(refPoint) < TOLERANCE)
 model.end()
index f4545a1f58d21df3050aa086c0d0a3e6de99c5f1..ebd1bf9d3e765ed5c895e257967a245a13717d76 100644 (file)
@@ -142,7 +142,7 @@ VOLUME = 5565.117188528191
 assertResult(Fillet_5)
 
 Fillet_6 = model.addFillet(Part_1_doc, [model.selection("EDGE", "[Compound_1_1_7_2/Modified_Face&Box_2_1/Top][Compound_1_1_7_2/Modified_Face&Box_2_1/Front]"), model.selection("FACE", "Compound_1_1_7_2/Modified_Face&Box_2_1/Right")], RADIUS_1, RADIUS_2, keepSubResults = True)
-REFERENCE[6] = GeomAPI_Pnt(2.50004995, 2.50004995, 5.00005)
+REFERENCE[6] = GeomAPI_Pnt(2.7448, 2.7448, 5)
 NB_FACES += 6
 NB_EDGES += 29
 NB_VERTICES += 58
@@ -150,7 +150,7 @@ VOLUME = 5541.63666
 assertResult(Fillet_6)
 
 Fillet_7 = model.addFillet(Part_1_doc, [model.selection("EDGE", "[Compound_1_1_8_1/Modified_Face&Box_3_1/Back][Compound_1_1_8_1/Modified_Face&Box_3_1/Top]"), model.selection("FACE", "Compound_1_1_8_2/Modified_Face&Box_3_1/Left")], RADIUS_1, RADIUS_2, keepSubResults = True)
-REFERENCE[7] = GeomAPI_Pnt(-20.9807621135, 42.5, 5)
+REFERENCE[7] = GeomAPI_Pnt(-20.9807621135, 42.806, 5)
 NB_FACES += 5
 NB_EDGES += 26
 NB_VERTICES += 52
@@ -163,7 +163,7 @@ NB_EDGES += 12
 NB_VERTICES += 24
 VOLUME = 5507.602043482
 REFERENCE[5] = GeomAPI_Pnt(55.041662114, 5.021870383, 5.009557179275)
-REFERENCE[7] = GeomAPI_Pnt(-20.9807621135, 42.5, 5)
+REFERENCE[7] = GeomAPI_Pnt(-20.9807621135, 42.5409962, 5)
 assertResult(Fillet_8)
 
 model.end()
index 077241b697ed248d6efab0c47ea9cd77cd144a8c..7975a6792f00158957a1f6953233d1279fb2eb37 100644 (file)
@@ -107,14 +107,14 @@ assert(Scale_1.feature().error() != "")
 model.begin()
 Scale_1.setMainObjects([model.selection("COMPSOLID", "Compound_2_1_1")])
 REFERENCE[0] = GeomAPI_Pnt(REFERENCE[0].x() * SCALE_X, REFERENCE[0].y() * SCALE_Y, REFERENCE[0].z() * SCALE_Z)
-##REFERENCE[0].setX(0) # <= B-spline poles are used to calculate the bounding box and thus the middle point
+REFERENCE[0].setX(0) # <= B-spline poles are used to calculate the bounding box and thus the middle point
 assertResult(Scale_1, 74139.07479)
 
 Scale_2 = model.addScale(Part_1_doc, [model.selection("SOLID", "Scale_1_1_2_1")], model.selection("VERTEX", "PartSet/Origin"), SCALE_X, SCALE_Y, SCALE_Z, keepSubResults = True)
 subs = subsRefPoints(Compound_2.result().subResult(1))
 subs[0] = GeomAPI_Pnt(subs[0].xyz().added(GeomAPI_XYZ(5, -5, 5)))
 subs[0] = GeomAPI_Pnt(subs[0].x() * SCALE_X, subs[0].y() * SCALE_Y, subs[0].z() * SCALE_Z)
-##subs[0].setY(-117.3204876) # <= B-spline poles are used to calculate the bounding box and thus the middle point
+subs[0].setY(-117.3204876) # <= B-spline poles are used to calculate the bounding box and thus the middle point
 subs[1] = GeomAPI_Pnt(subs[1].xyz().added(GeomAPI_XYZ(-5, 5, -5)))
 REFERENCE[1] = average(subs)
 assertResult(Scale_2, 78066.07487341)
@@ -133,8 +133,8 @@ Scale_4.setMainObjects([model.selection("COMPSOLID", "Scale_3_1_1"), model.selec
 REFERENCE[0] = GeomAPI_Pnt(REFERENCE[0].x() / SCALE_X, REFERENCE[0].y() / SCALE_Y, REFERENCE[0].z() / SCALE_Z)
 subs[1] = GeomAPI_Pnt(subs[1].x() / SCALE_X, subs[1].y() / SCALE_Y, subs[1].z() / SCALE_Z)
 # B-spline poles are used to calculate the bounding box and thus the middle point
-##subs[1].setX(-30.59017)
-##subs[1].setY(-2.83826244)
+subs[1].setX(-30.59017)
+subs[1].setY(-2.83826244)
 REFERENCE[1] = average(subs)
 REFERENCE[2] = GeomAPI_Pnt(REFERENCE[2].x() / SCALE_X, REFERENCE[2].y() / SCALE_Y, REFERENCE[2].z() / SCALE_Z)
 assertResult(Scale_4, 17592.5112883)
index ea59ae09b468ba0bf9a403cc5c97dc9f43624401..cd044b69a2b600b08a58e9bd270e68278cfb2dd7 100644 (file)
@@ -593,7 +593,19 @@ bool GeomAPI_Shape::computeSize(double& theXmin, double& theYmin, double& theZmi
   if (aShape.IsNull())
     return false;
   Bnd_Box aBndBox;
-  BRepBndLib::AddOptimal(aShape, aBndBox, false, true);
+  // Workaround: compute optimal bounding box for the compounds of edges/vertices, because sometimes
+  // the bounding box of sketch is calculated if the transformation is applied twice (issue #20167).
+  bool isShape1D = false;
+  if (aShape.ShapeType() == TopAbs_COMPOUND) {
+    isShape1D = true;
+    for (TopoDS_Iterator anIt(aShape); anIt.More() && isShape1D; anIt.Next())
+      if (anIt.Value().ShapeType() < TopAbs_WIRE)
+        isShape1D = false;
+  }
+  if (isShape1D)
+    BRepBndLib::AddOptimal(aShape, aBndBox, false, true);
+  else
+    BRepBndLib::Add(aShape, aBndBox, false);
   if (aBndBox.IsVoid())
     return false;
   aBndBox.Get(theXmin, theYmin, theZmin, theXmax, theYmax, theZmax);