]> SALOME platform Git repositories - modules/geom.git/blob - src/GEOMUtils/GEOMUtils_Trsf2d.cxx
Salome HOME
4938d497907f568bbead03f529f5a91e4a57c667
[modules/geom.git] / src / GEOMUtils / GEOMUtils_Trsf2d.cxx
1 // Copyright (C) 2007-2014  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License, or (at your option) any later version.
10 //
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 // Lesser General Public License for more details.
15 //
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19 //
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22
23
24 #include <GEOMUtils_Trsf2d.hxx>
25
26
27 //=======================================================================
28 //function : Trsf2d
29 //purpose  :
30 //=======================================================================
31 GEOMUtils::Trsf2d::Trsf2d(const Standard_Real a11,
32                           const Standard_Real a12,
33                           const Standard_Real a13,
34                           const Standard_Real a21,
35                           const Standard_Real a22,
36                           const Standard_Real a23)
37 : myA11(a11),
38   myA12(a12),
39   myA13(a13),
40   myA21(a21),
41   myA22(a22),
42   myA23(a23)
43 {
44 }
45
46 //=======================================================================
47 //function : TransformD0
48 //purpose  :
49 //=======================================================================
50 void GEOMUtils::Trsf2d::TransformD0(gp_Pnt2d &thePnt) const
51 {
52   const Standard_Real aX = myA11*thePnt.X() + myA12*thePnt.Y() + myA13;
53   const Standard_Real aY = myA21*thePnt.X() + myA22*thePnt.Y() + myA23;
54
55   thePnt.SetCoord(aX, aY);
56 }
57
58 //=======================================================================
59 //function : TransformD1
60 //purpose  :
61 //=======================================================================
62 void GEOMUtils::Trsf2d::TransformD1(gp_Pnt2d &thePnt,
63                                     gp_Vec2d &theVec1) const
64 {
65   TransformVector(thePnt, theVec1);
66   TransformD0(thePnt);
67 }
68
69 //=======================================================================
70 //function : TransformD2
71 //purpose  :
72 //=======================================================================
73 void GEOMUtils::Trsf2d::TransformD2(gp_Pnt2d &thePnt,
74                                     gp_Vec2d &theVec1,
75                                     gp_Vec2d &theVec2) const
76 {
77   TransformVector(thePnt, theVec1);
78   TransformVector(thePnt, theVec2);
79   TransformD0(thePnt);
80 }
81
82 //=======================================================================
83 //function : TransformD3
84 //purpose  :
85 //=======================================================================
86 void GEOMUtils::Trsf2d::TransformD3(gp_Pnt2d &thePnt,
87                                     gp_Vec2d &theVec1,
88                                     gp_Vec2d &theVec2,
89                                     gp_Vec2d &theVec3) const
90 {
91   TransformVector(thePnt, theVec1);
92   TransformVector(thePnt, theVec2);
93   TransformVector(thePnt, theVec3);
94   TransformD0(thePnt);
95 }
96
97 //=======================================================================
98 //function : TransformVector
99 //purpose  :
100 //=======================================================================
101 void GEOMUtils::Trsf2d::TransformVector(const gp_Pnt2d &thePnt,
102                                               gp_Vec2d &theVec) const
103 {
104   gp_Pnt2d aP0(thePnt.XY());
105   gp_Pnt2d aP1(thePnt.XY().Added(theVec.XY()));
106
107   TransformD0(aP0);
108   TransformD0(aP1);
109   theVec.SetXY(aP1.XY().Subtracted(aP0.XY()));
110 }