From c8382619ef38cf99efa1771f46e567becfe1a114 Mon Sep 17 00:00:00 2001 From: Artem Zhidkov Date: Wed, 16 Sep 2020 16:16:09 +0300 Subject: [PATCH] Fix regressions after resolving issue #19890 (part II) --- src/Model/Model_ResultPart.cpp | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/src/Model/Model_ResultPart.cpp b/src/Model/Model_ResultPart.cpp index 7c42dd987..fb3eb3bed 100644 --- a/src/Model/Model_ResultPart.cpp +++ b/src/Model/Model_ResultPart.cpp @@ -189,6 +189,26 @@ bool Model_ResultPart::setDisabled(std::shared_ptr 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(); + 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(new gp_Trsf(theTrsf)); + GeomAlgoAPI_Transform aTransform(theShape, aTrsf); + aResult = aTransform.shape(); + } + return aResult; +} + std::shared_ptr Model_ResultPart::shape() { std::shared_ptr aResult(new GeomAPI_Shape); @@ -199,9 +219,7 @@ std::shared_ptr Model_ResultPart::shape() ResultPtr anOrigResult = baseRef(); std::shared_ptr anOrigShape = anOrigResult->shape(); if (anOrigShape.get()) { - GeomTrsfPtr aTrsf = std::make_shared(new gp_Trsf(*myTrsf)); - GeomAlgoAPI_Transform aTransform(anOrigShape, aTrsf); - aResult = aTransform.shape(); + aResult = transformShape(anOrigShape, *myTrsf); myShape = aResult->impl(); } if (!myShape.IsNull() && aToSendUpdate) { -- 2.30.2