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 | |
17 | #include <Standard_NoSuchObject.hxx> |
18 | #include <gp_Vec.hxx> |
19 | #include <gp_Pnt.hxx> |
20 | #include <gp_Lin.hxx> |
21 | #include <V3d_View.hxx> |
22 | #include <V3d.hxx> |
23 | |
7fd59977 |
24 | //======================================================================= |
25 | //function : Perspective |
4952a30a |
26 | //purpose : |
7fd59977 |
27 | //======================================================================= |
28 | |
29 | inline Standard_Boolean Select3D_Projector::Perspective() const |
30 | { return myPersp; } |
31 | |
32 | //======================================================================= |
33 | //function : Transformation |
4952a30a |
34 | //purpose : |
7fd59977 |
35 | //======================================================================= |
36 | |
37 | inline const gp_GTrsf& Select3D_Projector::Transformation() const |
38 | { return myGTrsf; } |
39 | |
40 | //======================================================================= |
41 | //function : InvertedTransformation |
4952a30a |
42 | //purpose : |
7fd59977 |
43 | //======================================================================= |
44 | |
45 | inline const gp_GTrsf& Select3D_Projector::InvertedTransformation() const |
46 | { return myInvTrsf; } |
47 | |
48 | //======================================================================= |
49 | //function : FullTransformation |
4952a30a |
50 | //purpose : |
7fd59977 |
51 | //======================================================================= |
52 | |
53 | inline const gp_Trsf& Select3D_Projector::FullTransformation() const |
54 | { return myScaledTrsf; } |
55 | |
56 | //======================================================================= |
57 | //function : Focus |
4952a30a |
58 | //purpose : |
7fd59977 |
59 | //======================================================================= |
60 | |
61 | inline Standard_Real Select3D_Projector::Focus() const |
62 | { |
63 | Standard_NoSuchObject_Raise_if(!myPersp, |
64 | "Select3D_Projector::Not a Perpective"); |
65 | return myFocus; |
66 | } |
67 | |
68 | //======================================================================= |
69 | //function : Transform |
4952a30a |
70 | //purpose : |
7fd59977 |
71 | //======================================================================= |
72 | |
73 | inline void Select3D_Projector::Transform (gp_Vec& D) const |
74 | { |
75 | gp_XYZ coord = D.XYZ(); |
76 | if (myGTrsf.Form() == gp_Identity || myGTrsf.Form() == gp_Translation) { } |
77 | else if (myGTrsf.Form() == gp_PntMirror) { coord.Reverse(); } |
78 | else { coord.Multiply (myGTrsf.VectorialPart()); } |
79 | D.SetXYZ(coord); |
80 | } |
81 | |
82 | //======================================================================= |
83 | //function : Transform |
4952a30a |
84 | //purpose : |
7fd59977 |
85 | //======================================================================= |
86 | |
87 | inline void Select3D_Projector::Transform (gp_Pnt& Pnt) const |
4952a30a |
88 | { |
7fd59977 |
89 | gp_XYZ xyz = Pnt.XYZ(); |
90 | myGTrsf.Transforms(xyz); |
91 | Pnt = gp_Pnt(xyz); |
92 | } |
93 | |
94 | |
95 | inline const Handle(V3d_View)& Select3D_Projector::View() const |
96 | {return myView;} |
97 | |
98 | inline void Select3D_Projector::Transform (gp_Lin& Lin, const gp_GTrsf& T) const |
4952a30a |
99 | { |
7fd59977 |
100 | gp_Ax1 ax1 = Lin.Position(); |
101 | gp_XYZ xyz = ax1.Location().XYZ(); |
102 | T.Transforms(xyz); |
103 | ax1.SetLocation(gp_Pnt(xyz)); |
104 | gp_Dir dir = ax1.Direction(); |
105 | gp_XYZ coord = dir.XYZ(); |
106 | if (T.Form() == gp_Identity || T.Form() == gp_Translation) { } |
107 | else if (T.Form() == gp_PntMirror) { coord.Reverse(); } |
108 | else { |
109 | coord.Multiply (T.VectorialPart()); |
110 | Standard_Real D = coord.Modulus(); |
111 | coord.Divide(D); |
112 | } |
113 | dir.SetXYZ(coord); |
114 | ax1.SetDirection(dir); |
115 | Lin.SetPosition(ax1); |
116 | } |
117 | |
118 | inline void Select3D_Projector::Transform (gp_Pnt& Pnt, const gp_GTrsf& T) const |
4952a30a |
119 | { |
7fd59977 |
120 | gp_XYZ xyz = Pnt.XYZ(); |
121 | T.Transforms(xyz); |
122 | Pnt = gp_Pnt(xyz); |
123 | } |