0025991: Cyclic dependency in OCCT detected by WOK compiler
[occt.git] / src / Select3D / Select3D_Projector.lxx
CommitLineData
b311480e 1// Created on: 1992-07-09
2// Created by: Christophe MARION
3// Copyright (c) 1992-1999 Matra Datavision
973c2be1 4// Copyright (c) 1999-2014 OPEN CASCADE SAS
b311480e 5//
973c2be1 6// This file is part of Open CASCADE Technology software library.
b311480e 7//
d5f74e42 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
973c2be1 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.
b311480e 13//
973c2be1 14// Alternatively, this file may be used under the terms of Open CASCADE
15// commercial license or contractual agreement.
7fd59977 16
197ac94e 17#include <Graphic3d_Mat4d.hxx>
18#include <Standard_Assert.hxx>
7fd59977 19#include <gp_Vec.hxx>
20#include <gp_Pnt.hxx>
21#include <gp_Lin.hxx>
7fd59977 22
7fd59977 23//=======================================================================
24//function : Perspective
4952a30a 25//purpose :
7fd59977 26//=======================================================================
7fd59977 27inline Standard_Boolean Select3D_Projector::Perspective() const
197ac94e 28{
29 return myPersp;
30}
7fd59977 31
32//=======================================================================
197ac94e 33//function : ProjectionTransformation
4952a30a 34//purpose :
7fd59977 35//=======================================================================
197ac94e 36inline const Graphic3d_Mat4d& Select3D_Projector::Projection() const
37{
38 return myProjTrsf;
39}
7fd59977 40
197ac94e 41//=======================================================================
42//function : Transformation
43//purpose :
44//=======================================================================
7fd59977 45inline const gp_GTrsf& Select3D_Projector::Transformation() const
197ac94e 46{
47 return myGTrsf;
48}
7fd59977 49
50//=======================================================================
51//function : InvertedTransformation
4952a30a 52//purpose :
7fd59977 53//=======================================================================
7fd59977 54inline const gp_GTrsf& Select3D_Projector::InvertedTransformation() const
197ac94e 55{
56 return myInvTrsf;
57}
7fd59977 58
59//=======================================================================
60//function : FullTransformation
4952a30a 61//purpose :
7fd59977 62//=======================================================================
7fd59977 63inline const gp_Trsf& Select3D_Projector::FullTransformation() const
197ac94e 64{
65 return myScaledTrsf;
66}
7fd59977 67
68//=======================================================================
69//function : Focus
4952a30a 70//purpose :
7fd59977 71//=======================================================================
7fd59977 72inline Standard_Real Select3D_Projector::Focus() const
73{
197ac94e 74 Standard_ASSERT_RAISE (myPersp, "Not a simplified Perspective.");
7fd59977 75 return myFocus;
76}
77
78//=======================================================================
79//function : Transform
4952a30a 80//purpose :
7fd59977 81//=======================================================================
197ac94e 82inline void Select3D_Projector::Transform (gp_Vec& theD) const
7fd59977 83{
197ac94e 84 gp_XYZ aXYZ = theD.XYZ();
85
86 if (myGTrsf.Form() == gp_PntMirror)
87 {
88 aXYZ.Reverse();
89 }
90 else if (myGTrsf.Form() != gp_Identity && myGTrsf.Form() != gp_Translation)
91 {
92 aXYZ.Multiply (myGTrsf.VectorialPart());
93 }
94
95 theD.SetXYZ (aXYZ);
7fd59977 96}
97
98//=======================================================================
99//function : Transform
4952a30a 100//purpose :
7fd59977 101//=======================================================================
197ac94e 102inline void Select3D_Projector::Transform (gp_Pnt& thePnt) const
4952a30a 103{
197ac94e 104 Transform (thePnt, myGTrsf);
7fd59977 105}
106
197ac94e 107//=======================================================================
108//function : Transform
109//purpose :
110//=======================================================================
111inline void Select3D_Projector::Transform (gp_Lin& theLin, const gp_GTrsf& theTrsf) const
4952a30a 112{
197ac94e 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();
119
120 if (theTrsf.Form() == gp_PntMirror)
121 {
122 aDirXYZ.Reverse();
7fd59977 123 }
197ac94e 124 else if (theTrsf.Form() != gp_Identity && theTrsf.Form() != gp_Translation)
125 {
126 aDirXYZ.Multiply (theTrsf.VectorialPart());
127 Standard_Real aModulus = aDirXYZ.Modulus();
128 aDirXYZ.Divide (aModulus);
129 }
130
131 aDir.SetXYZ (aDirXYZ);
132 anAx1.SetDirection (aDir);
133 theLin.SetPosition (anAx1);
7fd59977 134}
135
197ac94e 136//=======================================================================
137//function : Transform
138//purpose :
139//=======================================================================
140inline void Select3D_Projector::Transform (gp_Pnt& thePnt, const gp_GTrsf& theTrsf) const
4952a30a 141{
197ac94e 142 gp_XYZ aXYZ = thePnt.XYZ();
143 theTrsf.Transforms (aXYZ);
144 thePnt = gp_Pnt (aXYZ);
7fd59977 145}