1 // Copyright (C) 2014-2016 CEA/DEN, EDF R&D
3 // File: GeomAPI_Trsf.cpp
4 // Created: 13 Jul 2015
5 // Author: Mikhail PONIKAROV
7 // Modified by Clarisse Genrault (CEA) : 17 Nov 2016
9 #include<GeomAPI_Trsf.h>
11 #include <GeomAPI_Ax1.h>
12 #include <GeomAPI_Ax2.h>
16 #include <gp_Trsf.hxx>
18 #define MY_TRSF implPtr<gp_Trsf>()
22 //=================================================================================================
23 GeomAPI_Trsf::GeomAPI_Trsf()
24 : GeomAPI_Interface(new gp_Trsf())
28 //=================================================================================================
29 GeomAPI_Trsf::GeomAPI_Trsf(void* theTrsf)
30 : GeomAPI_Interface(theTrsf)
34 //=================================================================================================
35 void GeomAPI_Trsf::setTranslation(const std::shared_ptr<GeomAPI_Ax1> theAxis,
36 const double theDistance)
38 MY_TRSF->SetTranslation(gp_Vec(theAxis->impl<gp_Ax1>().Direction()) * theDistance);
41 //=================================================================================================
42 void GeomAPI_Trsf::setTranslation(const double theDx, const double theDy, const double theDz)
44 MY_TRSF->SetTranslation(gp_Vec(theDx, theDy, theDz));
47 //=================================================================================================
48 void GeomAPI_Trsf::setTranslation(const std::shared_ptr<GeomAPI_Pnt> theStartPoint,
49 const std::shared_ptr<GeomAPI_Pnt> theEndPoint)
51 MY_TRSF->SetTranslation(theStartPoint->impl<gp_Pnt>(), theEndPoint->impl<gp_Pnt>());
54 //=================================================================================================
55 void GeomAPI_Trsf::setRotation(const std::shared_ptr<GeomAPI_Ax1> theAxis,
56 const double theAngle)
58 MY_TRSF->SetRotation(theAxis->impl<gp_Ax1>(), theAngle / 180.0 * M_PI);
61 //=================================================================================================
62 void GeomAPI_Trsf::setRotation(const std::shared_ptr<GeomAPI_Pnt> theCenterPoint,
63 const std::shared_ptr<GeomAPI_Pnt> theStartPoint,
64 const std::shared_ptr<GeomAPI_Pnt> theEndPoint)
66 gp_Pnt aCenterPoint = theCenterPoint->impl<gp_Pnt>();
67 gp_Pnt aStartPoint = theStartPoint->impl<gp_Pnt>();
68 gp_Pnt aEndPoint = theEndPoint->impl<gp_Pnt>();
70 gp_Vec aVec1(aCenterPoint, aStartPoint);
71 gp_Vec aVec2(aCenterPoint, aEndPoint);
72 gp_Dir aDir(aVec1 ^ aVec2);
73 gp_Ax1 anAxis(aCenterPoint, aDir);
74 double anAngle = aVec1.Angle(aVec2);
75 if (fabs(anAngle) < Precision::Angular()) anAngle += 2.*M_PI; // Taken from old GEOM code
77 MY_TRSF->SetRotation(anAxis, anAngle);
80 //=================================================================================================
81 void GeomAPI_Trsf::setSymmetry(const std::shared_ptr<GeomAPI_Pnt> thePoint)
83 MY_TRSF->SetMirror(thePoint->impl<gp_Pnt>());
86 //=================================================================================================
87 void GeomAPI_Trsf::setSymmetry(const std::shared_ptr<GeomAPI_Ax1> theAxis)
89 MY_TRSF->SetMirror(theAxis->impl<gp_Ax1>());
92 //=================================================================================================
93 void GeomAPI_Trsf::setSymmetry(const std::shared_ptr<GeomAPI_Ax2> thePlane)
95 MY_TRSF->SetMirror(thePlane->impl<gp_Ax2>());