Salome HOME
Fix regressions after resolving issue #19890 (part II)
authorArtem Zhidkov <Artem.Zhidkov@opencascade.com>
Wed, 16 Sep 2020 13:16:09 +0000 (16:16 +0300)
committerArtem Zhidkov <Artem.Zhidkov@opencascade.com>
Wed, 16 Sep 2020 13:16:09 +0000 (16:16 +0300)
src/Model/Model_ResultPart.cpp

index 7c42dd987e0148edfc40ce12a2d3d543fe67f00f..fb3eb3bed05b69273ecb6673fa0f0f6bdf2578dd 100644 (file)
@@ -189,6 +189,26 @@ bool Model_ResultPart::setDisabled(std::shared_ptr<ModelAPI_Result> theThis,
   return false;
 }
 
+static GeomShapePtr transformShape(const GeomShapePtr theShape, const gp_Trsf& theTrsf)
+{
+  GeomShapePtr aResult(new GeomAPI_Shape);
+  if (theTrsf.ScaleFactor() > 0) {
+    // just update the location of the shape in case of affine transformation
+    TopoDS_Shape aShape = theShape->impl<TopoDS_Shape>();
+    if (!aShape.IsNull()) {
+      aShape.Move(theTrsf);
+      aResult->setImpl(new TopoDS_Shape(aShape));
+    }
+  }
+  else {
+    // all other transformations will modify the shape
+    GeomTrsfPtr aTrsf = std::make_shared<GeomAPI_Trsf>(new gp_Trsf(theTrsf));
+    GeomAlgoAPI_Transform aTransform(theShape, aTrsf);
+    aResult = aTransform.shape();
+  }
+  return aResult;
+}
+
 std::shared_ptr<GeomAPI_Shape> Model_ResultPart::shape()
 {
   std::shared_ptr<GeomAPI_Shape> aResult(new GeomAPI_Shape);
@@ -199,9 +219,7 @@ std::shared_ptr<GeomAPI_Shape> Model_ResultPart::shape()
       ResultPtr anOrigResult = baseRef();
       std::shared_ptr<GeomAPI_Shape> anOrigShape = anOrigResult->shape();
       if (anOrigShape.get()) {
-        GeomTrsfPtr aTrsf = std::make_shared<GeomAPI_Trsf>(new gp_Trsf(*myTrsf));
-        GeomAlgoAPI_Transform aTransform(anOrigShape, aTrsf);
-        aResult = aTransform.shape();
+        aResult = transformShape(anOrigShape, *myTrsf);
         myShape = aResult->impl<TopoDS_Shape>();
       }
       if (!myShape.IsNull() && aToSendUpdate) {