1 // Created on: 1992-07-09
2 // Created by: Christophe MARION
3 // Copyright (c) 1992-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
6 // This file is part of Open CASCADE Technology software library.
8 // This library is free software; you can redistribute it and/or modify it under
9 // the terms of the GNU Lesser General Public License version 2.1 as published
10 // by the Free Software Foundation, with special exception defined in the file
11 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12 // distribution for complete text of the license and disclaimer of any warranty.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
17 #include <Graphic3d_Mat4d.hxx>
18 #include <Standard_Assert.hxx>
23 //=======================================================================
24 //function : Perspective
26 //=======================================================================
27 inline Standard_Boolean Select3D_Projector::Perspective() const
32 //=======================================================================
33 //function : ProjectionTransformation
35 //=======================================================================
36 inline const Graphic3d_Mat4d& Select3D_Projector::Projection() const
41 //=======================================================================
42 //function : Transformation
44 //=======================================================================
45 inline const gp_GTrsf& Select3D_Projector::Transformation() const
50 //=======================================================================
51 //function : InvertedTransformation
53 //=======================================================================
54 inline const gp_GTrsf& Select3D_Projector::InvertedTransformation() const
59 //=======================================================================
60 //function : FullTransformation
62 //=======================================================================
63 inline const gp_Trsf& Select3D_Projector::FullTransformation() const
68 //=======================================================================
71 //=======================================================================
72 inline Standard_Real Select3D_Projector::Focus() const
74 Standard_ASSERT_RAISE (myPersp, "Not a simplified Perspective.");
78 //=======================================================================
79 //function : Transform
81 //=======================================================================
82 inline void Select3D_Projector::Transform (gp_Vec& theD) const
84 gp_XYZ aXYZ = theD.XYZ();
86 if (myGTrsf.Form() == gp_PntMirror)
90 else if (myGTrsf.Form() != gp_Identity && myGTrsf.Form() != gp_Translation)
92 aXYZ.Multiply (myGTrsf.VectorialPart());
98 //=======================================================================
99 //function : Transform
101 //=======================================================================
102 inline void Select3D_Projector::Transform (gp_Pnt& thePnt) const
104 Transform (thePnt, myGTrsf);
107 //=======================================================================
108 //function : Transform
110 //=======================================================================
111 inline void Select3D_Projector::Transform (gp_Lin& theLin, const gp_GTrsf& theTrsf) const
113 gp_Ax1 anAx1 = theLin.Position();
114 gp_XYZ aXYZ = anAx1.Location().XYZ();
115 theTrsf.Transforms (aXYZ);
116 anAx1.SetLocation (gp_Pnt (aXYZ));
117 gp_Dir aDir = anAx1.Direction();
118 gp_XYZ aDirXYZ = aDir.XYZ();
120 if (theTrsf.Form() == gp_PntMirror)
124 else if (theTrsf.Form() != gp_Identity && theTrsf.Form() != gp_Translation)
126 aDirXYZ.Multiply (theTrsf.VectorialPart());
127 Standard_Real aModulus = aDirXYZ.Modulus();
128 aDirXYZ.Divide (aModulus);
131 aDir.SetXYZ (aDirXYZ);
132 anAx1.SetDirection (aDir);
133 theLin.SetPosition (anAx1);
136 //=======================================================================
137 //function : Transform
139 //=======================================================================
140 inline void Select3D_Projector::Transform (gp_Pnt& thePnt, const gp_GTrsf& theTrsf) const
142 gp_XYZ aXYZ = thePnt.XYZ();
143 theTrsf.Transforms (aXYZ);
144 thePnt = gp_Pnt (aXYZ);