X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FGeomAlgoAPI%2FGeomAlgoAPI_Rotation.cpp;h=21815311070d170e47f4c714519a95895bfec868;hb=c39f725bfe98395871c5853dacb89ab1a6ecc6f2;hp=81c3ca6e334a4437cd96dd53cac39a819636df1b;hpb=c34eecb3e188cf8b533505764f48d4e034088d86;p=modules%2Fshaper.git diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_Rotation.cpp b/src/GeomAlgoAPI/GeomAlgoAPI_Rotation.cpp index 81c3ca6e3..218153110 100644 --- a/src/GeomAlgoAPI/GeomAlgoAPI_Rotation.cpp +++ b/src/GeomAlgoAPI/GeomAlgoAPI_Rotation.cpp @@ -16,19 +16,21 @@ //================================================================================================= GeomAlgoAPI_Rotation::GeomAlgoAPI_Rotation(std::shared_ptr theSourceShape, std::shared_ptr theAxis, - double theAngle) + double theAngle, + bool theSimpleTransform) : myDone(false), myShape(new GeomAPI_Shape()), myMap(new GeomAPI_DataMapOfShapeShape()), myMkShape(new GeomAlgoAPI_MakeShape()) { - build(theSourceShape, theAxis, theAngle); + build(theSourceShape, theAxis, theAngle, theSimpleTransform); } //================================================================================================= void GeomAlgoAPI_Rotation::build(std::shared_ptr theSourceShape, std::shared_ptr theAxis, - double theAngle) + double theAngle, + bool theSimpleTransform) { if(!theSourceShape || !theAxis) { return; @@ -44,28 +46,35 @@ void GeomAlgoAPI_Rotation::build(std::shared_ptr theSourceShape, gp_Trsf aTrsf; aTrsf.SetRotation(anAxis, theAngle / 180.0 * M_PI); + TopoDS_Shape aResult; // Transform the shape with copying it. - BRepBuilderAPI_Transform* aBuilder = new BRepBuilderAPI_Transform(aSourceShape, aTrsf, true); - if(!aBuilder) { - return; - } - - myDone = aBuilder->IsDone() == Standard_True; - - if(!myDone) { - return; - } - - TopoDS_Shape aResult = aBuilder->Shape(); - // Fill data map to keep correct orientation of sub-shapes. - for(TopExp_Explorer anExp(aResult, TopAbs_FACE); anExp.More(); anExp.Next()) { - std::shared_ptr aCurrentShape(new GeomAPI_Shape()); - aCurrentShape->setImpl(new TopoDS_Shape(anExp.Current())); - myMap->bind(aCurrentShape, aCurrentShape); + if (theSimpleTransform) { + TopLoc_Location aDelta(aTrsf); + aResult = aSourceShape.Moved(aDelta); + myDone = true; // is OK for sure + } else { + BRepBuilderAPI_Transform* aBuilder = new BRepBuilderAPI_Transform(aSourceShape, aTrsf, true); + if(!aBuilder) { + return; + } + + myDone = aBuilder->IsDone() == Standard_True; + + if(!myDone) { + return; + } + + aResult = aBuilder->Shape(); + // Fill data map to keep correct orientation of sub-shapes. + for(TopExp_Explorer anExp(aResult, TopAbs_FACE); anExp.More(); anExp.Next()) { + std::shared_ptr aCurrentShape(new GeomAPI_Shape()); + aCurrentShape->setImpl(new TopoDS_Shape(anExp.Current())); + myMap->bind(aCurrentShape, aCurrentShape); + } + myMkShape->setImpl(aBuilder); } myShape->setImpl(new TopoDS_Shape(aResult)); - myMkShape->setImpl(aBuilder); } //=================================================================================================