0022627: Change OCCT memory management defaults
[occt.git] / src / ProjLib / ProjLib_Projector.cxx
1 // File:        ProjLib_Projector.cxx
2 // Created:     Tue Aug 24 12:05:40 1993
3 // Author:      Bruno DUMORTIER
4 //              <dub@topsn3>
5
6 //  Modified by skv - Wed Aug 11 15:45:58 2004 OCC6272
7
8
9 #include <ProjLib_Projector.ixx>
10
11 #include <ElCLib.hxx>
12
13
14 //=======================================================================
15 //function : ProjLib_Projector
16 //purpose  : 
17 //=======================================================================
18
19 ProjLib_Projector::ProjLib_Projector()
20 {}
21
22
23 //=======================================================================
24 void ProjLib_Projector::Delete()
25 {}
26
27
28
29 //=======================================================================
30 //function : IsDone
31 //purpose  : 
32 //=======================================================================
33
34 Standard_Boolean ProjLib_Projector::IsDone() const
35 {
36   return isDone;
37 }
38
39
40 //=======================================================================
41 //function : Done
42 //purpose  : 
43 //=======================================================================
44
45 void ProjLib_Projector::Done()
46 {
47   isDone = Standard_True;
48 }
49
50
51 //=======================================================================
52 //function : GetType
53 //purpose  : 
54 //=======================================================================
55
56 GeomAbs_CurveType  ProjLib_Projector::GetType() const 
57 {
58   return myType;
59 }
60
61
62 //=======================================================================
63 //function : SetType
64 //purpose  : 
65 //=======================================================================
66
67 void ProjLib_Projector::SetType( const GeomAbs_CurveType Type)
68 {
69   myType = Type;
70 }
71
72
73 //=======================================================================
74 //function : IsPeriodic
75 //purpose  : 
76 //=======================================================================
77
78 Standard_Boolean ProjLib_Projector::IsPeriodic() const 
79 {
80   return myIsPeriodic;
81 }
82
83
84 //=======================================================================
85 //function : SetPeriodic
86 //purpose  : 
87 //=======================================================================
88
89 void ProjLib_Projector::SetPeriodic()
90 {
91   myIsPeriodic = Standard_True;
92 }
93
94
95 //=======================================================================
96 //function : Line
97 //purpose  : 
98 //=======================================================================
99
100 const gp_Lin2d&  ProjLib_Projector::Line()const 
101 {
102   if (myType != GeomAbs_Line)
103     Standard_NoSuchObject::Raise("ProjLib_Projector::Line");
104   return myLin;
105 }
106
107
108 //=======================================================================
109 //function : Circle
110 //purpose  : 
111 //=======================================================================
112
113 const gp_Circ2d&  ProjLib_Projector::Circle()const 
114 {
115   if (myType != GeomAbs_Circle)
116     Standard_NoSuchObject::Raise("ProjLib_Projector::Circle");
117   return myCirc;
118 }
119
120
121 //=======================================================================
122 //function : Ellipse
123 //purpose  : 
124 //=======================================================================
125
126 const gp_Elips2d&  ProjLib_Projector::Ellipse()const 
127 {
128   if (myType != GeomAbs_Ellipse)
129     Standard_NoSuchObject::Raise("ProjLib_Projector::Ellipse");
130   return myElips;
131 }
132
133
134 //=======================================================================
135 //function : Hyperbola
136 //purpose  : 
137 //=======================================================================
138
139 const gp_Hypr2d&  ProjLib_Projector::Hyperbola()const 
140 {
141   if (myType != GeomAbs_Hyperbola)
142     Standard_NoSuchObject::Raise("ProjLib_Projector::Hyperbola");
143   return myHypr;
144 }
145
146
147 //=======================================================================
148 //function : Parabola
149 //purpose  : 
150 //=======================================================================
151
152 const gp_Parab2d&  ProjLib_Projector::Parabola()const 
153 {
154   if (myType != GeomAbs_Parabola)
155     Standard_NoSuchObject::Raise("ProjLib_Projector::Parabola");
156   return myParab;
157 }
158
159
160
161
162 //=======================================================================
163 //function : Project
164 //purpose  : 
165 //=======================================================================
166
167 void  ProjLib_Projector::Project(const gp_Lin& )
168 {
169   myType = GeomAbs_OtherCurve;
170 }
171
172
173 //=======================================================================
174 //function : Project
175 //purpose  : 
176 //=======================================================================
177
178 void  ProjLib_Projector::Project(const gp_Circ& )
179 {
180   myType = GeomAbs_OtherCurve;
181 }
182
183
184 //=======================================================================
185 //function : Project
186 //purpose  : 
187 //=======================================================================
188
189 void  ProjLib_Projector::Project(const gp_Elips& )
190 {
191   myType = GeomAbs_OtherCurve;
192 }
193
194
195 //=======================================================================
196 //function : Project
197 //purpose  : 
198 //=======================================================================
199
200 void  ProjLib_Projector::Project(const gp_Parab& )
201 {
202   myType = GeomAbs_OtherCurve;
203 }
204
205
206 //=======================================================================
207 //function : Project
208 //purpose  : 
209 //=======================================================================
210
211 void  ProjLib_Projector::Project(const gp_Hypr& )
212 {
213   myType = GeomAbs_OtherCurve;
214 }
215
216
217 //=======================================================================
218 //function : UFrame
219 //purpose  : 
220 //=======================================================================
221
222 void ProjLib_Projector::UFrame(const Standard_Real CFirst, 
223 //                             const Standard_Real CLast, 
224                                const Standard_Real , 
225                                const Standard_Real UFirst, 
226                                const Standard_Real Period)
227 {
228   if (myType == GeomAbs_Line) {
229 //  Modified by skv - Wed Aug 11 15:45:58 2004 OCC6272 Begin
230 //     if ( myLin.Direction().Y() == 0.) {
231 //  Modified by skv - Wed Aug 11 15:45:58 2004 OCC6272 End
232 //      gp_Pnt2d PFirst, PLast;
233     gp_Pnt2d PFirst;
234     PFirst = ElCLib::Value(CFirst,myLin);
235     //PLast  = ElCLib::Value(CLast ,myLin);
236     //Standard_Real U = Min( PFirst.X(), PLast.X());
237     Standard_Real U = PFirst.X();
238     Standard_Real NewU = ElCLib::InPeriod(U,UFirst, UFirst + Period);
239     myLin.Translate(gp_Vec2d(NewU-U,0.));
240   }
241 }
242
243 //=======================================================================
244 //function : VFrame
245 //purpose  : 
246 //=======================================================================
247
248 void ProjLib_Projector::VFrame(const Standard_Real CFirst,
249 //                             const Standard_Real CLast, 
250                                const Standard_Real , 
251                                const Standard_Real VFirst, 
252                                const Standard_Real Period)
253 {
254   if (myType == GeomAbs_Line) {
255 //  Modified by skv - Wed Aug 11 15:45:58 2004 OCC6272 Begin
256 //     if ( myLin.Direction().X() == 0.) {
257 //  Modified by skv - Wed Aug 11 15:45:58 2004 OCC6272 End
258 //      gp_Pnt2d PFirst, PLast;
259     gp_Pnt2d PFirst;
260     PFirst = ElCLib::Value(CFirst,myLin);
261     //PLast  = ElCLib::Value(CLast ,myLin);
262     //Standard_Real V = Min( PFirst.Y(), PLast.Y());
263     Standard_Real V = PFirst.Y();
264     Standard_Real NewV = ElCLib::InPeriod(V,VFirst, VFirst + Period);
265     myLin.Translate(gp_Vec2d(0.,NewV-V));
266   }
267 }
268
269 //=======================================================================
270 //function : SetBezier
271 //purpose  : 
272 //=======================================================================
273
274 void  ProjLib_Projector::SetBezier(const Handle(Geom2d_BezierCurve)&  C) 
275 {
276  myBezier = C ;
277 }
278 //=======================================================================
279 //function : Bezier
280 //purpose  : 
281 //=======================================================================
282
283 Handle(Geom2d_BezierCurve)ProjLib_Projector::Bezier() const 
284
285   return myBezier ;
286 }
287 //=======================================================================
288 //function : SetBSpline
289 //purpose  : 
290 //=======================================================================
291
292 void  ProjLib_Projector::SetBSpline(const Handle(Geom2d_BSplineCurve)&  C) 
293 {
294  myBSpline = C ;
295 }
296 //=======================================================================
297 //function : BSpline
298 //purpose  : 
299 //=======================================================================
300
301 Handle(Geom2d_BSplineCurve) ProjLib_Projector::BSpline()  const 
302
303  return myBSpline ;
304 }