OCC22357 Hidden face selection
[occt.git] / src / Select3D / Select3D_Projector.lxx
1 // File:        Select3D_Projector.lxx
2 // Created:     Thu Jul  9 12:50:25 1992
3 // Author:      Christophe MARION
4 //              <cma@sdsun1>
5
6 #include <Standard_NoSuchObject.hxx>
7 #include <gp_Vec.hxx>
8 #include <gp_Pnt.hxx>
9 #include <gp_Lin.hxx>
10 #include <V3d_View.hxx>
11 #include <V3d.hxx>
12
13 //=======================================================================
14 //function : Directions
15 //purpose  :
16 //=======================================================================
17
18 inline void Select3D_Projector::Directions
19   (gp_Vec2d& D1, gp_Vec2d& D2, gp_Vec2d& D3) const
20 {
21   D1 = myD1;
22   D2 = myD2;
23   D3 = myD3;
24 }
25
26 //=======================================================================
27 //function : Perspective
28 //purpose  :
29 //=======================================================================
30
31 inline Standard_Boolean Select3D_Projector::Perspective() const
32 { return myPersp; }
33
34 //=======================================================================
35 //function : Transformation
36 //purpose  :
37 //=======================================================================
38
39 inline const gp_GTrsf& Select3D_Projector::Transformation() const
40 { return myGTrsf; }
41
42 //=======================================================================
43 //function : InvertedTransformation
44 //purpose  :
45 //=======================================================================
46
47 inline const gp_GTrsf& Select3D_Projector::InvertedTransformation() const
48 { return myInvTrsf; }
49
50 //=======================================================================
51 //function : FullTransformation
52 //purpose  :
53 //=======================================================================
54
55 inline const gp_Trsf& Select3D_Projector::FullTransformation() const
56 { return myScaledTrsf; }
57
58 //=======================================================================
59 //function : Focus
60 //purpose  :
61 //=======================================================================
62
63 inline Standard_Real Select3D_Projector::Focus() const
64 {
65   Standard_NoSuchObject_Raise_if(!myPersp,
66                                  "Select3D_Projector::Not a Perpective");
67   return myFocus;
68 }
69
70 //=======================================================================
71 //function : Transform
72 //purpose  :
73 //=======================================================================
74
75 inline void Select3D_Projector::Transform (gp_Vec& D) const
76 {
77   gp_XYZ coord = D.XYZ();
78   if (myGTrsf.Form() == gp_Identity || myGTrsf.Form() == gp_Translation) { }
79   else if (myGTrsf.Form() == gp_PntMirror) { coord.Reverse(); }
80   else { coord.Multiply (myGTrsf.VectorialPart()); }
81   D.SetXYZ(coord);
82 }
83
84 //=======================================================================
85 //function : Transform
86 //purpose  :
87 //=======================================================================
88
89 inline void Select3D_Projector::Transform (gp_Pnt& Pnt) const
90 {
91   gp_XYZ xyz = Pnt.XYZ();
92   myGTrsf.Transforms(xyz);
93   Pnt = gp_Pnt(xyz);
94 }
95
96
97 inline const Handle(V3d_View)& Select3D_Projector::View() const
98 {return myView;}
99
100 inline void Select3D_Projector::Transform (gp_Lin& Lin, const gp_GTrsf& T) const
101 {
102   gp_Ax1 ax1 = Lin.Position();
103   gp_XYZ xyz = ax1.Location().XYZ();
104   T.Transforms(xyz);
105   ax1.SetLocation(gp_Pnt(xyz));
106   gp_Dir dir = ax1.Direction();
107   gp_XYZ coord = dir.XYZ();
108   if (T.Form() == gp_Identity ||  T.Form() == gp_Translation)    { }
109   else if (T.Form() == gp_PntMirror) { coord.Reverse(); }
110   else {
111     coord.Multiply (T.VectorialPart());
112     Standard_Real D = coord.Modulus();
113     coord.Divide(D);
114   }
115   dir.SetXYZ(coord);
116   ax1.SetDirection(dir);
117   Lin.SetPosition(ax1);
118 }
119
120 inline void Select3D_Projector::Transform (gp_Pnt& Pnt, const gp_GTrsf& T) const
121 {
122   gp_XYZ xyz = Pnt.XYZ();
123   T.Transforms(xyz);
124   Pnt = gp_Pnt(xyz);
125 }
126
127 inline Standard_Real Select3D_Projector::DepthMin() const
128 {
129   return myDepthMin;
130 }
131
132 inline Standard_Real Select3D_Projector::DepthMax() const
133 {
134   return myDepthMax;
135 }