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
6 // This file is part of Open CASCADE Technology software library.
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.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
17 // Modified by skv - Wed Aug 11 15:45:58 2004 OCC6272
20 #include <Geom2d_BezierCurve.hxx>
21 #include <Geom2d_BSplineCurve.hxx>
22 #include <gp_Circ.hxx>
23 #include <gp_Circ2d.hxx>
24 #include <gp_Elips.hxx>
25 #include <gp_Elips2d.hxx>
26 #include <gp_Hypr.hxx>
27 #include <gp_Hypr2d.hxx>
29 #include <gp_Lin2d.hxx>
30 #include <gp_Parab.hxx>
31 #include <gp_Parab2d.hxx>
32 #include <ProjLib_Projector.hxx>
33 #include <Standard_NoSuchObject.hxx>
34 #include <Standard_NotImplemented.hxx>
36 //=======================================================================
37 //function : ProjLib_Projector
39 //=======================================================================
40 ProjLib_Projector::ProjLib_Projector()
42 isDone = Standard_False;
43 myType = GeomAbs_BSplineCurve;
47 //=======================================================================
48 //function : ~ProjLib_Projector
49 //purpose : Destructor
50 //=======================================================================
52 ProjLib_Projector::~ProjLib_Projector()
57 //=======================================================================
60 //=======================================================================
62 Standard_Boolean ProjLib_Projector::IsDone() const
68 //=======================================================================
71 //=======================================================================
73 void ProjLib_Projector::Done()
75 isDone = Standard_True;
79 //=======================================================================
82 //=======================================================================
84 GeomAbs_CurveType ProjLib_Projector::GetType() const
90 //=======================================================================
93 //=======================================================================
95 void ProjLib_Projector::SetType( const GeomAbs_CurveType Type)
101 //=======================================================================
102 //function : IsPeriodic
104 //=======================================================================
106 Standard_Boolean ProjLib_Projector::IsPeriodic() const
112 //=======================================================================
113 //function : SetPeriodic
115 //=======================================================================
117 void ProjLib_Projector::SetPeriodic()
119 myIsPeriodic = Standard_True;
123 //=======================================================================
126 //=======================================================================
128 const gp_Lin2d& ProjLib_Projector::Line()const
130 if (myType != GeomAbs_Line)
131 throw Standard_NoSuchObject("ProjLib_Projector::Line");
136 //=======================================================================
139 //=======================================================================
141 const gp_Circ2d& ProjLib_Projector::Circle()const
143 if (myType != GeomAbs_Circle)
144 throw Standard_NoSuchObject("ProjLib_Projector::Circle");
149 //=======================================================================
152 //=======================================================================
154 const gp_Elips2d& ProjLib_Projector::Ellipse()const
156 if (myType != GeomAbs_Ellipse)
157 throw Standard_NoSuchObject("ProjLib_Projector::Ellipse");
162 //=======================================================================
163 //function : Hyperbola
165 //=======================================================================
167 const gp_Hypr2d& ProjLib_Projector::Hyperbola()const
169 if (myType != GeomAbs_Hyperbola)
170 throw Standard_NoSuchObject("ProjLib_Projector::Hyperbola");
175 //=======================================================================
176 //function : Parabola
178 //=======================================================================
180 const gp_Parab2d& ProjLib_Projector::Parabola()const
182 if (myType != GeomAbs_Parabola)
183 throw Standard_NoSuchObject("ProjLib_Projector::Parabola");
190 //=======================================================================
193 //=======================================================================
195 void ProjLib_Projector::Project(const gp_Lin& )
197 myType = GeomAbs_OtherCurve;
201 //=======================================================================
204 //=======================================================================
206 void ProjLib_Projector::Project(const gp_Circ& )
208 myType = GeomAbs_OtherCurve;
212 //=======================================================================
215 //=======================================================================
217 void ProjLib_Projector::Project(const gp_Elips& )
219 myType = GeomAbs_OtherCurve;
223 //=======================================================================
226 //=======================================================================
228 void ProjLib_Projector::Project(const gp_Parab& )
230 myType = GeomAbs_OtherCurve;
234 //=======================================================================
237 //=======================================================================
239 void ProjLib_Projector::Project(const gp_Hypr& )
241 myType = GeomAbs_OtherCurve;
245 //=======================================================================
248 //=======================================================================
250 void ProjLib_Projector::UFrame(const Standard_Real CFirst,
251 // const Standard_Real CLast,
252 const Standard_Real ,
253 const Standard_Real UFirst,
254 const Standard_Real Period)
256 if (myType == GeomAbs_Line) {
257 // Modified by skv - Wed Aug 11 15:45:58 2004 OCC6272 Begin
258 // if ( myLin.Direction().Y() == 0.) {
259 // Modified by skv - Wed Aug 11 15:45:58 2004 OCC6272 End
260 // gp_Pnt2d PFirst, PLast;
262 PFirst = ElCLib::Value(CFirst,myLin);
263 //PLast = ElCLib::Value(CLast ,myLin);
264 //Standard_Real U = Min( PFirst.X(), PLast.X());
265 Standard_Real U = PFirst.X();
266 Standard_Real NewU = ElCLib::InPeriod(U,UFirst, UFirst + Period);
267 myLin.Translate(gp_Vec2d(NewU-U,0.));
271 //=======================================================================
274 //=======================================================================
276 void ProjLib_Projector::VFrame(const Standard_Real CFirst,
277 // const Standard_Real CLast,
278 const Standard_Real ,
279 const Standard_Real VFirst,
280 const Standard_Real Period)
282 if (myType == GeomAbs_Line) {
283 // Modified by skv - Wed Aug 11 15:45:58 2004 OCC6272 Begin
284 // if ( myLin.Direction().X() == 0.) {
285 // Modified by skv - Wed Aug 11 15:45:58 2004 OCC6272 End
286 // gp_Pnt2d PFirst, PLast;
288 PFirst = ElCLib::Value(CFirst,myLin);
289 //PLast = ElCLib::Value(CLast ,myLin);
290 //Standard_Real V = Min( PFirst.Y(), PLast.Y());
291 Standard_Real V = PFirst.Y();
292 Standard_Real NewV = ElCLib::InPeriod(V,VFirst, VFirst + Period);
293 myLin.Translate(gp_Vec2d(0.,NewV-V));
297 //=======================================================================
298 //function : SetBezier
300 //=======================================================================
302 void ProjLib_Projector::SetBezier(const Handle(Geom2d_BezierCurve)& C)
306 //=======================================================================
309 //=======================================================================
311 Handle(Geom2d_BezierCurve)ProjLib_Projector::Bezier() const
315 //=======================================================================
316 //function : SetBSpline
318 //=======================================================================
320 void ProjLib_Projector::SetBSpline(const Handle(Geom2d_BSplineCurve)& C)
324 //=======================================================================
327 //=======================================================================
329 Handle(Geom2d_BSplineCurve) ProjLib_Projector::BSpline() const