0031687: Draw Harness, ViewerTest - extend command vrenderparams with option updating...
[occt.git] / src / GeomAdaptor / GeomAdaptor_Curve.hxx
CommitLineData
42cf5bc1 1// Created on: 1992-09-01
2// Created by: Modelistation
3// Copyright (c) 1992-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#ifndef _GeomAdaptor_Curve_HeaderFile
18#define _GeomAdaptor_Curve_HeaderFile
19
20#include <Standard.hxx>
21#include <Standard_DefineAlloc.hxx>
22#include <Standard_Handle.hxx>
23
24#include <GeomAbs_CurveType.hxx>
25#include <Standard_Real.hxx>
26#include <BSplCLib_Cache.hxx>
27#include <Adaptor3d_Curve.hxx>
28#include <GeomAbs_Shape.hxx>
29#include <Standard_Integer.hxx>
30#include <TColStd_Array1OfReal.hxx>
31#include <Standard_Boolean.hxx>
d660a72a 32#include <GeomEvaluator_Curve.hxx>
33
42cf5bc1 34class Geom_Curve;
35class Adaptor3d_HCurve;
36class Standard_NoSuchObject;
37class Standard_ConstructionError;
38class Standard_OutOfRange;
39class Standard_DomainError;
40class GeomAdaptor_Surface;
41class gp_Pnt;
42class gp_Vec;
43class gp_Lin;
44class gp_Circ;
45class gp_Elips;
46class gp_Hypr;
47class gp_Parab;
48class Geom_BezierCurve;
49class Geom_BSplineCurve;
f4dee9bb 50class Geom_OffsetCurve;
42cf5bc1 51
52
53//! This class provides an interface between the services provided by any
54//! curve from the package Geom and those required of the curve by algorithms which use it.
55//! Creation of the loaded curve the curve is C1 by piece.
34e4e9f2
BB
56//!
57//! Polynomial coefficients of BSpline curves used for their evaluation are
58//! cached for better performance. Therefore these evaluations are not
59//! thread-safe and parallel evaluations need to be prevented.
42cf5bc1 60class GeomAdaptor_Curve : public Adaptor3d_Curve
61{
62public:
63
64 DEFINE_STANDARD_ALLOC
65
66
67 GeomAdaptor_Curve();
68
69 GeomAdaptor_Curve(const Handle(Geom_Curve)& C);
70
71 //! ConstructionError is raised if Ufirst>Ulast
72 GeomAdaptor_Curve(const Handle(Geom_Curve)& C, const Standard_Real UFirst, const Standard_Real ULast);
4ba5491a 73
74 //! Reset currently loaded curve (undone Load()).
75 Standard_EXPORT void Reset();
76
42cf5bc1 77 void Load (const Handle(Geom_Curve)& C);
78
79 //! ConstructionError is raised if Ufirst>Ulast
80 void Load (const Handle(Geom_Curve)& C, const Standard_Real UFirst, const Standard_Real ULast);
81
82
83 //! Provides a curve inherited from Hcurve from Adaptor.
84 //! This is inherited to provide easy to use constructors.
85 const Handle(Geom_Curve)& Curve() const;
86
87 Standard_Real FirstParameter() const Standard_OVERRIDE;
88
89 Standard_Real LastParameter() const Standard_OVERRIDE;
90
91 Standard_EXPORT GeomAbs_Shape Continuity() const Standard_OVERRIDE;
92
93 //! Returns the number of intervals for continuity
94 //! <S>. May be one if Continuity(me) >= <S>
95 Standard_EXPORT Standard_Integer NbIntervals (const GeomAbs_Shape S) const Standard_OVERRIDE;
96
97 //! Stores in <T> the parameters bounding the intervals
98 //! of continuity <S>.
99 //!
100 //! The array must provide enough room to accomodate
101 //! for the parameters. i.e. T.Length() > NbIntervals()
102 Standard_EXPORT void Intervals (TColStd_Array1OfReal& T, const GeomAbs_Shape S) const Standard_OVERRIDE;
103
104 //! Returns a curve equivalent of <me> between
105 //! parameters <First> and <Last>. <Tol> is used to
106 //! test for 3d points confusion.
107 //! If <First> >= <Last>
108 Standard_EXPORT Handle(Adaptor3d_HCurve) Trim (const Standard_Real First, const Standard_Real Last, const Standard_Real Tol) const Standard_OVERRIDE;
109
110 Standard_EXPORT Standard_Boolean IsClosed() const Standard_OVERRIDE;
111
112 Standard_EXPORT Standard_Boolean IsPeriodic() const Standard_OVERRIDE;
113
114 Standard_EXPORT Standard_Real Period() const Standard_OVERRIDE;
115
116 //! Computes the point of parameter U on the curve
117 Standard_EXPORT gp_Pnt Value (const Standard_Real U) const Standard_OVERRIDE;
118
119 //! Computes the point of parameter U.
120 Standard_EXPORT void D0 (const Standard_Real U, gp_Pnt& P) const Standard_OVERRIDE;
121
122 //! Computes the point of parameter U on the curve
123 //! with its first derivative.
124 //!
125 //! Warning : On the specific case of BSplineCurve:
126 //! if the curve is cut in interval of continuity at least C1, the
127 //! derivatives are computed on the current interval.
128 //! else the derivatives are computed on the basis curve.
129 Standard_EXPORT void D1 (const Standard_Real U, gp_Pnt& P, gp_Vec& V) const Standard_OVERRIDE;
130
131
132 //! Returns the point P of parameter U, the first and second
133 //! derivatives V1 and V2.
134 //!
135 //! Warning : On the specific case of BSplineCurve:
136 //! if the curve is cut in interval of continuity at least C2, the
137 //! derivatives are computed on the current interval.
138 //! else the derivatives are computed on the basis curve.
139 Standard_EXPORT void D2 (const Standard_Real U, gp_Pnt& P, gp_Vec& V1, gp_Vec& V2) const Standard_OVERRIDE;
140
141
142 //! Returns the point P of parameter U, the first, the second
143 //! and the third derivative.
144 //!
145 //! Warning : On the specific case of BSplineCurve:
146 //! if the curve is cut in interval of continuity at least C3, the
147 //! derivatives are computed on the current interval.
148 //! else the derivatives are computed on the basis curve.
149 Standard_EXPORT void D3 (const Standard_Real U, gp_Pnt& P, gp_Vec& V1, gp_Vec& V2, gp_Vec& V3) const Standard_OVERRIDE;
150
151
152 //! The returned vector gives the value of the derivative for the
153 //! order of derivation N.
154 //! Warning : On the specific case of BSplineCurve:
155 //! if the curve is cut in interval of continuity CN, the
156 //! derivatives are computed on the current interval.
157 //! else the derivatives are computed on the basis curve.
158 //! Raised if N < 1.
159 Standard_EXPORT gp_Vec DN (const Standard_Real U, const Standard_Integer N) const Standard_OVERRIDE;
160
161 //! returns the parametric resolution
162 Standard_EXPORT Standard_Real Resolution (const Standard_Real R3d) const Standard_OVERRIDE;
163
164 GeomAbs_CurveType GetType() const Standard_OVERRIDE;
165
166 Standard_EXPORT gp_Lin Line() const Standard_OVERRIDE;
167
168 Standard_EXPORT gp_Circ Circle() const Standard_OVERRIDE;
169
170 Standard_EXPORT gp_Elips Ellipse() const Standard_OVERRIDE;
171
172 Standard_EXPORT gp_Hypr Hyperbola() const Standard_OVERRIDE;
173
174 Standard_EXPORT gp_Parab Parabola() const Standard_OVERRIDE;
175
176
177 //! this should NEVER make a copy
178 //! of the underlying curve to read
179 //! the relevant information
180 Standard_EXPORT Standard_Integer Degree() const Standard_OVERRIDE;
181
182
183 //! this should NEVER make a copy
184 //! of the underlying curve to read
185 //! the relevant information
186 Standard_EXPORT Standard_Boolean IsRational() const Standard_OVERRIDE;
187
188
189 //! this should NEVER make a copy
190 //! of the underlying curve to read
191 //! the relevant information
192 Standard_EXPORT Standard_Integer NbPoles() const Standard_OVERRIDE;
193
194
195 //! this should NEVER make a copy
196 //! of the underlying curve to read
197 //! the relevant information
198 Standard_EXPORT Standard_Integer NbKnots() const Standard_OVERRIDE;
199
200 //! this will NOT make a copy of the
201 //! Bezier Curve : If you want to modify
202 //! the Curve please make a copy yourself
203 //! Also it will NOT trim the surface to
204 //! myFirst/Last.
205 Standard_EXPORT Handle(Geom_BezierCurve) Bezier() const Standard_OVERRIDE;
206
207 //! this will NOT make a copy of the
208 //! BSpline Curve : If you want to modify
209 //! the Curve please make a copy yourself
210 //! Also it will NOT trim the surface to
211 //! myFirst/Last.
212 Standard_EXPORT Handle(Geom_BSplineCurve) BSpline() const Standard_OVERRIDE;
213
f4dee9bb 214 Standard_EXPORT Handle(Geom_OffsetCurve) OffsetCurve() const Standard_OVERRIDE;
42cf5bc1 215
216friend class GeomAdaptor_Surface;
217
218
219protected:
220
221
222
223
224
225private:
226
42cf5bc1 227 Standard_EXPORT GeomAbs_Shape LocalContinuity (const Standard_Real U1, const Standard_Real U2) const;
228
229 Standard_EXPORT void load (const Handle(Geom_Curve)& C, const Standard_Real UFirst, const Standard_Real ULast);
230
d660a72a 231 //! Check theU relates to start or finish point of B-spline curve and return indices of span the point is located
232 Standard_Boolean IsBoundary(const Standard_Real theU, Standard_Integer& theSpanStart, Standard_Integer& theSpanFinish) const;
233
42cf5bc1 234 //! Rebuilds B-spline cache
235 //! \param theParameter the value on the knot axis which identifies the caching span
d660a72a 236 void RebuildCache (const Standard_Real theParameter) const;
42cf5bc1 237
238
239 Handle(Geom_Curve) myCurve;
240 GeomAbs_CurveType myTypeCurve;
241 Standard_Real myFirst;
242 Standard_Real myLast;
3b25c0e8
IC
243
244 Handle(Geom_BSplineCurve) myBSplineCurve; ///< B-spline representation to prevent castings
81093856 245 mutable Handle(BSplCLib_Cache) myCurveCache; ///< Cached data for B-spline or Bezier curve
d660a72a 246 Handle(GeomEvaluator_Curve) myNestedEvaluator; ///< Calculates value of offset curve
42cf5bc1 247
248
249};
250
251
252#include <GeomAdaptor_Curve.lxx>
253
254
255
256
257
258#endif // _GeomAdaptor_Curve_HeaderFile