b311480e |
1 | // Created on: 1993-08-24 |
2 | // Created by: Bruno DUMORTIER |
3 | // Copyright (c) 1993-1999 Matra Datavision |
4 | // Copyright (c) 1999-2012 OPEN CASCADE SAS |
5 | // |
6 | // The content of this file is subject to the Open CASCADE Technology Public |
7 | // License Version 6.5 (the "License"). You may not use the content of this file |
8 | // except in compliance with the License. Please obtain a copy of the License |
9 | // at http://www.opencascade.org and read it completely before using this file. |
10 | // |
11 | // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its |
12 | // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. |
13 | // |
14 | // The Original Code and all software distributed under the License is |
15 | // distributed on an "AS IS" basis, without warranty of any kind, and the |
16 | // Initial Developer hereby disclaims all such warranties, including without |
17 | // limitation, any warranties of merchantability, fitness for a particular |
18 | // purpose or non-infringement. Please see the License for the specific terms |
19 | // and conditions governing the rights and limitations under the License. |
20 | |
7fd59977 |
21 | |
22 | |
23 | #include <ProjLib_Plane.ixx> |
24 | |
25 | #include <gp_Vec.hxx> |
26 | |
27 | //======================================================================= |
28 | //function : ProjLib_Plane |
29 | //purpose : |
30 | //======================================================================= |
31 | |
32 | ProjLib_Plane::ProjLib_Plane() |
33 | { |
34 | } |
35 | |
36 | |
37 | //======================================================================= |
38 | //function : ProjLib_Plane |
39 | //purpose : |
40 | //======================================================================= |
41 | |
42 | ProjLib_Plane::ProjLib_Plane(const gp_Pln& Pl) |
43 | { |
44 | Init(Pl); |
45 | } |
46 | |
47 | |
48 | //======================================================================= |
49 | //function : ProjLib_Plane |
50 | //purpose : |
51 | //======================================================================= |
52 | |
53 | ProjLib_Plane::ProjLib_Plane(const gp_Pln& Pl, const gp_Lin& L) |
54 | { |
55 | Init(Pl); |
56 | Project(L); |
57 | } |
58 | |
59 | |
60 | //======================================================================= |
61 | //function : ProjLib_Plane |
62 | //purpose : |
63 | //======================================================================= |
64 | |
65 | ProjLib_Plane::ProjLib_Plane(const gp_Pln& Pl, const gp_Circ& C) |
66 | { |
67 | Init(Pl); |
68 | Project(C); |
69 | } |
70 | |
71 | |
72 | //======================================================================= |
73 | //function : ProjLib_Plane |
74 | //purpose : |
75 | //======================================================================= |
76 | |
77 | ProjLib_Plane::ProjLib_Plane(const gp_Pln& Pl, const gp_Elips& E) |
78 | { |
79 | Init(Pl); |
80 | Project(E); |
81 | } |
82 | |
83 | |
84 | //======================================================================= |
85 | //function : ProjLib_Plane |
86 | //purpose : |
87 | //======================================================================= |
88 | |
89 | ProjLib_Plane::ProjLib_Plane(const gp_Pln& Pl, const gp_Parab& P) |
90 | { |
91 | Init(Pl); |
92 | Project(P); |
93 | } |
94 | |
95 | |
96 | //======================================================================= |
97 | //function : ProjLib_Plane |
98 | //purpose : |
99 | //======================================================================= |
100 | |
101 | ProjLib_Plane::ProjLib_Plane(const gp_Pln& Pl, const gp_Hypr& H) |
102 | { |
103 | Init(Pl); |
104 | Project(H); |
105 | } |
106 | |
107 | |
108 | //======================================================================= |
109 | //function : Init |
110 | //purpose : |
111 | //======================================================================= |
112 | |
113 | void ProjLib_Plane::Init(const gp_Pln& Pl) |
114 | { |
115 | myType = GeomAbs_OtherCurve; |
116 | isDone = Standard_False; |
117 | myIsPeriodic = Standard_False; |
118 | myPlane = Pl; |
119 | } |
120 | |
121 | //======================================================================= |
122 | //function : EvalPnt2d / EvalDir2d |
123 | //purpose : returns the Projected Pnt / Dir in the parametrization range |
124 | // of myPlane. |
125 | //======================================================================= |
126 | |
127 | static gp_Pnt2d EvalPnt2d( const gp_Pnt P, const gp_Pln& Pl) |
128 | { |
129 | gp_Vec OP( Pl.Location(),P); |
130 | return gp_Pnt2d( OP.Dot(gp_Vec(Pl.Position().XDirection())), |
131 | OP.Dot(gp_Vec(Pl.Position().YDirection()))); |
132 | } |
133 | |
134 | static gp_Dir2d EvalDir2d( const gp_Dir& D, const gp_Pln& Pl) |
135 | { |
136 | return gp_Dir2d( D.Dot(Pl.Position().XDirection()), |
137 | D.Dot(Pl.Position().YDirection())); |
138 | } |
139 | |
140 | |
141 | //======================================================================= |
142 | //function : Project |
143 | //purpose : |
144 | //======================================================================= |
145 | |
146 | void ProjLib_Plane::Project(const gp_Lin& L) |
147 | { |
148 | myType = GeomAbs_Line; |
149 | myLin = gp_Lin2d(EvalPnt2d(L.Location() ,myPlane), |
150 | EvalDir2d(L.Direction(),myPlane) ); |
151 | isDone = Standard_True; |
152 | } |
153 | |
154 | |
155 | //======================================================================= |
156 | //function : Project |
157 | //purpose : |
158 | //======================================================================= |
159 | |
160 | void ProjLib_Plane::Project(const gp_Circ& C) |
161 | { |
162 | |
163 | myType = GeomAbs_Circle; |
164 | |
165 | gp_Pnt2d P2d = EvalPnt2d(C.Location(),myPlane); |
166 | gp_Dir2d X2d = EvalDir2d(C.Position().XDirection(),myPlane); |
167 | gp_Dir2d Y2d = EvalDir2d(C.Position().YDirection(),myPlane); |
168 | gp_Ax22d Ax(P2d,X2d,Y2d); |
169 | |
170 | myCirc = gp_Circ2d(Ax, C.Radius()); |
171 | myIsPeriodic = Standard_True; |
172 | isDone = Standard_True; |
173 | } |
174 | |
175 | |
176 | //======================================================================= |
177 | //function : Project |
178 | //purpose : |
179 | //======================================================================= |
180 | |
181 | void ProjLib_Plane::Project(const gp_Elips& E) |
182 | { |
183 | myType = GeomAbs_Ellipse; |
184 | |
185 | gp_Pnt2d P2d = EvalPnt2d(E.Location(),myPlane); |
186 | gp_Dir2d X2d = EvalDir2d(E.Position().XDirection(),myPlane); |
187 | gp_Dir2d Y2d = EvalDir2d(E.Position().YDirection(),myPlane); |
188 | gp_Ax22d Ax(P2d,X2d,Y2d); |
189 | |
190 | myElips = gp_Elips2d(Ax,E.MajorRadius(),E.MinorRadius()); |
191 | myIsPeriodic = Standard_True; |
192 | isDone = Standard_True; |
193 | } |
194 | |
195 | |
196 | //======================================================================= |
197 | //function : Project |
198 | //purpose : |
199 | //======================================================================= |
200 | |
201 | void ProjLib_Plane::Project(const gp_Parab& P) |
202 | { |
203 | myType = GeomAbs_Parabola; |
204 | |
205 | gp_Pnt2d P2d = EvalPnt2d(P.Location(),myPlane); |
206 | gp_Dir2d X2d = EvalDir2d(P.Position().XDirection(),myPlane); |
207 | gp_Dir2d Y2d = EvalDir2d(P.Position().YDirection(),myPlane); |
208 | gp_Ax22d Ax(P2d,X2d,Y2d); |
209 | |
210 | myParab = gp_Parab2d(Ax,P.Focal()); |
211 | isDone = Standard_True; |
212 | } |
213 | |
214 | |
215 | //======================================================================= |
216 | //function : Project |
217 | //purpose : |
218 | //======================================================================= |
219 | |
220 | void ProjLib_Plane::Project(const gp_Hypr& H) |
221 | { |
222 | myType = GeomAbs_Hyperbola; |
223 | |
224 | gp_Pnt2d P2d = EvalPnt2d(H.Location(),myPlane); |
225 | gp_Dir2d X2d = EvalDir2d(H.Position().XDirection(),myPlane); |
226 | gp_Dir2d Y2d = EvalDir2d(H.Position().YDirection(),myPlane); |
227 | gp_Ax22d Ax(P2d,X2d,Y2d); |
228 | |
229 | myHypr = gp_Hypr2d(Ax,H.MajorRadius(),H.MinorRadius()); |
230 | isDone = Standard_True; |
231 | } |