0027961: Visualization - remove unused and no more working OpenGl_AVIWriter
[occt.git] / src / Geom / Geom_TrimmedCurve.cxx
CommitLineData
b311480e 1// Created on: 1993-03-10
2// Created by: JCV
3// Copyright (c) 1993-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
7fd59977 17
42cf5bc1 18#include <ElCLib.hxx>
7fd59977 19#include <Geom_BezierCurve.hxx>
42cf5bc1 20#include <Geom_BSplineCurve.hxx>
7fd59977 21#include <Geom_Circle.hxx>
42cf5bc1 22#include <Geom_Curve.hxx>
7fd59977 23#include <Geom_Ellipse.hxx>
42cf5bc1 24#include <Geom_Geometry.hxx>
7fd59977 25#include <Geom_Hyperbola.hxx>
42cf5bc1 26#include <Geom_Line.hxx>
27#include <Geom_OffsetCurve.hxx>
7fd59977 28#include <Geom_Parabola.hxx>
42cf5bc1 29#include <Geom_TrimmedCurve.hxx>
30#include <Geom_UndefinedDerivative.hxx>
31#include <Geom_UndefinedValue.hxx>
32#include <gp.hxx>
33#include <gp_Pnt.hxx>
34#include <gp_Trsf.hxx>
35#include <gp_Vec.hxx>
36#include <Precision.hxx>
7fd59977 37#include <Standard_ConstructionError.hxx>
42cf5bc1 38#include <Standard_NoSuchObject.hxx>
7fd59977 39#include <Standard_RangeError.hxx>
42cf5bc1 40#include <Standard_Type.hxx>
7fd59977 41
92efcf78 42IMPLEMENT_STANDARD_RTTIEXT(Geom_TrimmedCurve,Geom_BoundedCurve)
43
7fd59977 44typedef Geom_TrimmedCurve TrimmedCurve;
7fd59977 45typedef gp_Ax1 Ax1;
46typedef gp_Ax2 Ax2;
47typedef gp_Pnt Pnt;
48typedef gp_Trsf Trsf;
49typedef gp_Vec Vec;
50
51//=======================================================================
52//function : Copy
53//purpose :
54//=======================================================================
55
56Handle(Geom_Geometry) Geom_TrimmedCurve::Copy () const {
57
c04c30b3 58 Handle(Geom_TrimmedCurve) Tc = new TrimmedCurve (basisCurve, uTrim1, uTrim2);
7fd59977 59 return Tc;
60}
61
62
63//=======================================================================
64//function : Geom_TrimmedCurve
65//purpose :
66//=======================================================================
67
68Geom_TrimmedCurve::Geom_TrimmedCurve (const Handle(Geom_Curve)& C,
8ac0cf52 69 const Standard_Real U1,
70 const Standard_Real U2,
71 const Standard_Boolean Sense,
72 const Standard_Boolean theAdjustPeriodic) :
7fd59977 73 uTrim1 (U1),
74 uTrim2 (U2)
75{
76 // kill trimmed basis curves
77 Handle(Geom_TrimmedCurve) T = Handle(Geom_TrimmedCurve)::DownCast(C);
78 if (!T.IsNull())
c04c30b3 79 basisCurve = Handle(Geom_Curve)::DownCast(T->BasisCurve()->Copy());
7fd59977 80 else
c04c30b3 81 basisCurve = Handle(Geom_Curve)::DownCast(C->Copy());
7fd59977 82
8ac0cf52 83 SetTrim(U1, U2, Sense, theAdjustPeriodic);
7fd59977 84}
85
86//=======================================================================
87//function : Reverse
88//purpose :
89//=======================================================================
90
91void Geom_TrimmedCurve::Reverse ()
92{
93 Standard_Real U1 = basisCurve->ReversedParameter(uTrim2);
94 Standard_Real U2 = basisCurve->ReversedParameter(uTrim1);
95 basisCurve->Reverse();
8ac0cf52 96 SetTrim(U1, U2, Standard_True, Standard_False);
7fd59977 97}
98
99
100//=======================================================================
101//function : ReversedParameter
102//purpose :
103//=======================================================================
104
105Standard_Real Geom_TrimmedCurve::ReversedParameter
106 (const Standard_Real U) const
107{
108 return basisCurve->ReversedParameter(U);
109}
110
111
112//=======================================================================
113//function : SetTrim
114//purpose :
115//=======================================================================
116
117void Geom_TrimmedCurve::SetTrim (const Standard_Real U1,
8ac0cf52 118 const Standard_Real U2,
119 const Standard_Boolean Sense,
120 const Standard_Boolean theAdjustPeriodic)
7fd59977 121{
122 Standard_Boolean sameSense = Standard_True;
123 if (U1 == U2)
124 Standard_ConstructionError::Raise("Geom_TrimmedCurve::U1 == U2");
125
126 Standard_Real Udeb = basisCurve->FirstParameter();
127 Standard_Real Ufin = basisCurve->LastParameter();
128
129 if (basisCurve->IsPeriodic()) {
130 sameSense = Sense;
131
132 // set uTrim1 in the range Udeb , Ufin
133 // set uTrim2 in the range uTrim1 , uTrim1 + Period()
134 uTrim1 = U1;
135 uTrim2 = U2;
8ac0cf52 136 if (theAdjustPeriodic)
137 ElCLib::AdjustPeriodic(Udeb, Ufin,
138 Min(Abs(uTrim2-uTrim1)/2,Precision::PConfusion()),
139 uTrim1, uTrim2);
7fd59977 140 }
141
142 else {
143 if (U1 < U2) {
144 sameSense = Sense;
145 uTrim1 = U1;
146 uTrim2 = U2;
147 }
148 else {
149 sameSense = !Sense;
150 uTrim1 = U2;
151 uTrim2 = U1;
152 }
153
154 if ((Udeb - uTrim1 > Precision::PConfusion()) ||
155 (uTrim2 - Ufin > Precision::PConfusion()))
156 Standard_ConstructionError::Raise
157 ("Geom_TrimmedCurve::parameters out of range");
158
159
160 }
161 if (!sameSense) {
162 Reverse();
163 }
164}
165
166
167//=======================================================================
168//function : IsClosed
169//purpose :
170//=======================================================================
171
172Standard_Boolean Geom_TrimmedCurve::IsClosed () const
173{
174 return ( StartPoint().Distance(EndPoint()) <= gp::Resolution());
175}
176
177//=======================================================================
178//function : IsPeriodic
179//purpose :
180//=======================================================================
181
182Standard_Boolean Geom_TrimmedCurve::IsPeriodic () const
183{
184 //return basisCurve->IsPeriodic();
185 return Standard_False;
186}
187
188
189//=======================================================================
190//function : Period
191//purpose :
192//=======================================================================
193
194Standard_Real Geom_TrimmedCurve::Period() const
195{
196 return basisCurve->Period();
197}
198
199
200//=======================================================================
201//function : Continuity
202//purpose :
203//=======================================================================
204
205GeomAbs_Shape Geom_TrimmedCurve::Continuity () const {
206
207 return basisCurve->Continuity ();
208}
209
210
211//=======================================================================
212//function : BasisCurve
213//purpose :
214//=======================================================================
215
c04c30b3 216Handle(Geom_Curve) Geom_TrimmedCurve::BasisCurve () const {
7fd59977 217
218 return basisCurve;
219}
220
221
222//=======================================================================
223//function : D0
224//purpose :
225//=======================================================================
226
227void Geom_TrimmedCurve::D0 (const Standard_Real U, Pnt& P) const {
228
229 basisCurve->D0( U, P);
230}
231
232
233//=======================================================================
234//function : D1
235//purpose :
236//=======================================================================
237
238void Geom_TrimmedCurve::D1 (const Standard_Real U, Pnt& P, Vec& V1) const {
239
240 basisCurve->D1 (U, P, V1);
241}
242
243
244//=======================================================================
245//function : D2
246//purpose :
247//=======================================================================
248
249void Geom_TrimmedCurve::D2 ( const Standard_Real U,
250 Pnt& P,
251 Vec& V1, Vec& V2) const {
252
253 basisCurve->D2 (U, P, V1, V2);
254}
255
256
257//=======================================================================
258//function : D3
259//purpose :
260//=======================================================================
261
262void Geom_TrimmedCurve::D3 (const Standard_Real U,
263 Pnt& P,
264 Vec& V1, Vec& V2, Vec& V3) const {
265
266 basisCurve->D3 (U, P, V1, V2, V3);
267}
268
269
270//=======================================================================
271//function : DN
272//purpose :
273//=======================================================================
274
275Vec Geom_TrimmedCurve::DN (const Standard_Real U,
276 const Standard_Integer N) const
277{
278 return basisCurve->DN (U, N);
279}
280
281
282//=======================================================================
283//function : EndPoint
284//purpose :
285//=======================================================================
286
287Pnt Geom_TrimmedCurve::EndPoint () const {
288
289 return basisCurve->Value (uTrim2);
290}
291
292
293//=======================================================================
294//function : FirstParameter
295//purpose :
296//=======================================================================
297
298Standard_Real Geom_TrimmedCurve::FirstParameter () const {
299
300 return uTrim1;
301}
302
303//=======================================================================
304//function : LastParameter
305//purpose :
306//=======================================================================
307
308Standard_Real Geom_TrimmedCurve::LastParameter () const {
309
310 return uTrim2;
311}
312
313//=======================================================================
314//function : StartPoint
315//purpose :
316//=======================================================================
317
318Pnt Geom_TrimmedCurve::StartPoint () const {
319
320 return basisCurve->Value (uTrim1);
321}
322
323
324//=======================================================================
325//function : IsCN
326//purpose :
327//=======================================================================
328
329Standard_Boolean Geom_TrimmedCurve::IsCN (const Standard_Integer N) const {
330
331 Standard_RangeError_Raise_if (N < 0, " ");
332 return basisCurve->IsCN (N);
333}
334
335
336//=======================================================================
337//function : Transform
338//purpose :
339//=======================================================================
340
341void Geom_TrimmedCurve::Transform (const Trsf& T)
342{
343 basisCurve->Transform (T);
344 Standard_Real U1 = basisCurve->TransformedParameter(uTrim1,T);
345 Standard_Real U2 = basisCurve->TransformedParameter(uTrim2,T);
8ac0cf52 346 SetTrim(U1, U2, Standard_True, Standard_False);
7fd59977 347}
348
349
350//=======================================================================
351//function : TransformedParameter
352//purpose :
353//=======================================================================
354
355Standard_Real Geom_TrimmedCurve::TransformedParameter(const Standard_Real U,
356 const gp_Trsf& T) const
357{
358 return basisCurve->TransformedParameter(U,T);
359}
360
361//=======================================================================
362//function : ParametricTransformation
363//purpose :
364//=======================================================================
365
366Standard_Real Geom_TrimmedCurve::ParametricTransformation(const gp_Trsf& T)
367const
368{
369 return basisCurve->ParametricTransformation(T);
370}
371