1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
3 // File: GeomAlgoAPI_Rotation.cpp
4 // Created: 12 May 2015
5 // Author: Dmitry Bobylev
7 #include "GeomAlgoAPI_Rotation.h"
9 #include <BRepBuilderAPI_Transform.hxx>
11 //=================================================================================================
12 GeomAlgoAPI_Rotation::GeomAlgoAPI_Rotation(std::shared_ptr<GeomAPI_Shape> theSourceShape,
13 std::shared_ptr<GeomAPI_Ax1> theAxis,
16 build(theSourceShape, theAxis, theAngle);
19 //=================================================================================================
20 void GeomAlgoAPI_Rotation::build(std::shared_ptr<GeomAPI_Shape> theSourceShape,
21 std::shared_ptr<GeomAPI_Ax1> theAxis,
24 if(!theSourceShape || !theAxis) {
28 const TopoDS_Shape& aSourceShape = theSourceShape->impl<TopoDS_Shape>();
29 const gp_Ax1& anAxis = theAxis->impl<gp_Ax1>();
31 if(aSourceShape.IsNull()) {
35 gp_Trsf* aTrsf = new gp_Trsf();
36 aTrsf->SetRotation(anAxis, theAngle / 180.0 * M_PI);
38 // Transform the shape with copying it.
39 BRepBuilderAPI_Transform* aBuilder = new BRepBuilderAPI_Transform(aSourceShape, *aTrsf, true);
43 this->setImpl(aBuilder);
44 this->setBuilderType(OCCT_BRepBuilderAPI_MakeShape);
46 if(aBuilder->IsDone() != Standard_True) {
49 TopoDS_Shape aResult = aBuilder->Shape();
51 std::shared_ptr<GeomAPI_Shape> aShape(new GeomAPI_Shape());
52 aShape->setImpl(new TopoDS_Shape(aResult));
53 this->setShape(aShape);