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