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_GTrsf.hxx>
17 #include <gp_Trsf.hxx>
19 #define MY_TRSF implPtr<gp_Trsf>()
23 //=================================================================================================
24 GeomAPI_Trsf::GeomAPI_Trsf()
25 : GeomAPI_Interface(new gp_Trsf())
29 //=================================================================================================
30 GeomAPI_Trsf::GeomAPI_Trsf(void* theTrsf)
31 : GeomAPI_Interface(theTrsf)
35 //=================================================================================================
36 void GeomAPI_Trsf::setTranslation(const std::shared_ptr<GeomAPI_Ax1> theAxis,
37 const double theDistance)
39 MY_TRSF->SetTranslation(gp_Vec(theAxis->impl<gp_Ax1>().Direction()) * theDistance);
42 //=================================================================================================
43 void GeomAPI_Trsf::setTranslation(const double theDx, const double theDy, const double theDz)
45 MY_TRSF->SetTranslation(gp_Vec(theDx, theDy, theDz));
48 //=================================================================================================
49 void GeomAPI_Trsf::setTranslation(const std::shared_ptr<GeomAPI_Pnt> theStartPoint,
50 const std::shared_ptr<GeomAPI_Pnt> theEndPoint)
52 MY_TRSF->SetTranslation(theStartPoint->impl<gp_Pnt>(), theEndPoint->impl<gp_Pnt>());
55 //=================================================================================================
56 void GeomAPI_Trsf::setRotation(const std::shared_ptr<GeomAPI_Ax1> theAxis,
57 const double theAngle)
59 MY_TRSF->SetRotation(theAxis->impl<gp_Ax1>(), theAngle / 180.0 * M_PI);
62 //=================================================================================================
63 void GeomAPI_Trsf::setRotation(const std::shared_ptr<GeomAPI_Pnt> theCenterPoint,
64 const std::shared_ptr<GeomAPI_Pnt> theStartPoint,
65 const std::shared_ptr<GeomAPI_Pnt> theEndPoint)
67 gp_Pnt aCenterPoint = theCenterPoint->impl<gp_Pnt>();
68 gp_Pnt aStartPoint = theStartPoint->impl<gp_Pnt>();
69 gp_Pnt aEndPoint = theEndPoint->impl<gp_Pnt>();
71 gp_Vec aVec1(aCenterPoint, aStartPoint);
72 gp_Vec aVec2(aCenterPoint, aEndPoint);
73 gp_Dir aDir(aVec1 ^ aVec2);
74 gp_Ax1 anAxis(aCenterPoint, aDir);
75 double anAngle = aVec1.Angle(aVec2);
76 if (fabs(anAngle) < Precision::Angular()) anAngle += 2.*M_PI; // Taken from old GEOM code
78 MY_TRSF->SetRotation(anAxis, anAngle);
81 //=================================================================================================
82 void GeomAPI_Trsf::setSymmetry(const std::shared_ptr<GeomAPI_Pnt> thePoint)
84 MY_TRSF->SetMirror(thePoint->impl<gp_Pnt>());
87 //=================================================================================================
88 void GeomAPI_Trsf::setSymmetry(const std::shared_ptr<GeomAPI_Ax1> theAxis)
90 MY_TRSF->SetMirror(theAxis->impl<gp_Ax1>());
93 //=================================================================================================
94 void GeomAPI_Trsf::setSymmetry(const std::shared_ptr<GeomAPI_Ax2> thePlane)
96 MY_TRSF->SetMirror(thePlane->impl<gp_Ax2>());