42cf5bc1 |
1 | // Created on: 1993-08-25 |
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 | #ifndef _ProjLib_ProjectedCurve_HeaderFile |
18 | #define _ProjLib_ProjectedCurve_HeaderFile |
19 | |
20 | #include <Standard.hxx> |
21 | #include <Standard_DefineAlloc.hxx> |
22 | #include <Standard_Handle.hxx> |
23 | |
24 | #include <Standard_Real.hxx> |
25 | #include <ProjLib_Projector.hxx> |
26 | #include <Adaptor2d_Curve2d.hxx> |
27 | #include <GeomAbs_Shape.hxx> |
28 | #include <Standard_Integer.hxx> |
29 | #include <TColStd_Array1OfReal.hxx> |
30 | #include <Standard_Boolean.hxx> |
31 | #include <GeomAbs_CurveType.hxx> |
f998596a |
32 | #include <AppParCurves_Constraint.hxx> |
42cf5bc1 |
33 | class Adaptor3d_HSurface; |
34 | class Adaptor3d_HCurve; |
35 | class Standard_OutOfRange; |
36 | class Standard_NoSuchObject; |
37 | class Standard_DomainError; |
38 | class Standard_NotImplemented; |
39 | class Adaptor2d_HCurve2d; |
40 | class gp_Pnt2d; |
41 | class gp_Vec2d; |
42 | class gp_Lin2d; |
43 | class gp_Circ2d; |
44 | class gp_Elips2d; |
45 | class gp_Hypr2d; |
46 | class gp_Parab2d; |
47 | class Geom2d_BezierCurve; |
48 | class Geom2d_BSplineCurve; |
49 | |
50 | |
51 | //! Compute the 2d-curve. Try to solve the particular |
52 | //! case if possible. Otherwize, an approximation is |
f998596a |
53 | //! done. For approximation some parameters are used, including |
54 | //! required tolerance of approximation. |
55 | //! Tolerance is maximal possible value of 3d deviation of 3d projection of projected curve from |
56 | //! "exact" 3d projection. Since algorithm searches 2d curve on surface, required 2d tolerance is computed |
57 | //! from 3d tolerance with help of U,V resolutions of surface. |
58 | //! 3d and 2d tolerances have sence only for curves on surface, it defines precision of projecting and approximation |
59 | //! and have nothing to do with distance between the projected curve and the surface. |
42cf5bc1 |
60 | class ProjLib_ProjectedCurve : public Adaptor2d_Curve2d |
61 | { |
62 | public: |
63 | |
64 | DEFINE_STANDARD_ALLOC |
65 | |
f998596a |
66 | //! Empty constructor, it only sets some initial values for class fields. |
42cf5bc1 |
67 | Standard_EXPORT ProjLib_ProjectedCurve(); |
68 | |
f998596a |
69 | //! Constructor with initialisation field mySurface |
42cf5bc1 |
70 | Standard_EXPORT ProjLib_ProjectedCurve(const Handle(Adaptor3d_HSurface)& S); |
f998596a |
71 | |
72 | //! Constructor, which performs projecting. |
73 | //! If projecting uses approximation, default parameters are used, in particular, 3d tolerance of approximation |
74 | //! is Precision::Confusion() |
42cf5bc1 |
75 | Standard_EXPORT ProjLib_ProjectedCurve(const Handle(Adaptor3d_HSurface)& S, const Handle(Adaptor3d_HCurve)& C); |
76 | |
f998596a |
77 | //! Constructor, which performs projecting. |
78 | //! If projecting uses approximation, 3d tolerance is Tol, default parameters are used, |
42cf5bc1 |
79 | Standard_EXPORT ProjLib_ProjectedCurve(const Handle(Adaptor3d_HSurface)& S, const Handle(Adaptor3d_HCurve)& C, const Standard_Real Tol); |
80 | |
81 | //! Changes the tolerance used to project |
82 | //! the curve on the surface |
83 | Standard_EXPORT void Load (const Standard_Real Tolerance); |
84 | |
85 | //! Changes the Surface. |
86 | Standard_EXPORT void Load (const Handle(Adaptor3d_HSurface)& S); |
87 | |
f998596a |
88 | //! Performs projecting for given curve. |
89 | //! If projecting uses approximation, |
90 | //! approximation parameters can be set before by corresponding methods |
91 | //! SetDegree(...), SetMaxSegmets(...), SetBndPnt(...), SetMaxDist(...) |
92 | Standard_EXPORT void Perform (const Handle(Adaptor3d_HCurve)& C); |
42cf5bc1 |
93 | |
f998596a |
94 | //! Set min and max possible degree of result BSpline curve2d, which is got by approximation. |
95 | //! If theDegMin/Max < 0, algorithm uses values that are chosen depending of types curve 3d |
96 | //! and surface. |
97 | Standard_EXPORT void SetDegree(const Standard_Integer theDegMin, const Standard_Integer theDegMax); |
98 | |
99 | //! Set the parameter, which defines maximal value of parametric intervals the projected |
100 | //! curve can be cut for approximation. If theMaxSegments < 0, algorithm uses default |
101 | //! value = 1000. |
102 | Standard_EXPORT void SetMaxSegments(const Standard_Integer theMaxSegments); |
103 | |
104 | //! Set the parameter, which defines type of boundary condition between segments during approximation. |
105 | //! It can be AppParCurves_PassPoint or AppParCurves_TangencyPoint. |
106 | //! Default value is AppParCurves_TangencyPoint; |
107 | Standard_EXPORT void SetBndPnt(const AppParCurves_Constraint theBndPnt); |
108 | |
109 | //! Set the parameter, which degines maximal possible distance between projected curve and surface. |
110 | //! It uses only for projecting on not analytical surfaces. |
111 | //! If theMaxDist < 0, algoritm uses default value 100.*Tolerance. |
112 | //! If real distance between curve and surface more then theMaxDist, algorithm stops working. |
113 | Standard_EXPORT void SetMaxDist(const Standard_Real theMaxDist); |
114 | |
42cf5bc1 |
115 | Standard_EXPORT const Handle(Adaptor3d_HSurface)& GetSurface() const; |
116 | |
117 | Standard_EXPORT const Handle(Adaptor3d_HCurve)& GetCurve() const; |
118 | |
119 | //! returns the tolerance reached if an approximation |
120 | //! is Done. |
121 | Standard_EXPORT Standard_Real GetTolerance() const; |
122 | |
123 | Standard_EXPORT Standard_Real FirstParameter() const Standard_OVERRIDE; |
124 | |
125 | Standard_EXPORT Standard_Real LastParameter() const Standard_OVERRIDE; |
126 | |
127 | Standard_EXPORT GeomAbs_Shape Continuity() const Standard_OVERRIDE; |
128 | |
129 | //! If necessary, breaks the curve in intervals of |
130 | //! continuity <S>. And returns the number of |
131 | //! intervals. |
132 | Standard_EXPORT Standard_Integer NbIntervals (const GeomAbs_Shape S) const Standard_OVERRIDE; |
133 | |
134 | //! Stores in <T> the parameters bounding the intervals |
135 | //! of continuity <S>. |
136 | //! |
137 | //! The array must provide enough room to accomodate |
138 | //! for the parameters. i.e. T.Length() > NbIntervals() |
139 | Standard_EXPORT void Intervals (TColStd_Array1OfReal& T, const GeomAbs_Shape S) const Standard_OVERRIDE; |
140 | |
141 | //! Returns a curve equivalent of <me> between |
142 | //! parameters <First> and <Last>. <Tol> is used to |
143 | //! test for 3d points confusion. |
144 | //! If <First> >= <Last> |
145 | Standard_EXPORT Handle(Adaptor2d_HCurve2d) Trim (const Standard_Real First, const Standard_Real Last, const Standard_Real Tol) const Standard_OVERRIDE; |
146 | |
147 | Standard_EXPORT Standard_Boolean IsClosed() const Standard_OVERRIDE; |
148 | |
149 | Standard_EXPORT Standard_Boolean IsPeriodic() const Standard_OVERRIDE; |
150 | |
151 | Standard_EXPORT Standard_Real Period() const Standard_OVERRIDE; |
152 | |
153 | //! Computes the point of parameter U on the curve. |
154 | Standard_EXPORT gp_Pnt2d Value (const Standard_Real U) const Standard_OVERRIDE; |
155 | |
156 | //! Computes the point of parameter U on the curve. |
157 | Standard_EXPORT void D0 (const Standard_Real U, gp_Pnt2d& P) const Standard_OVERRIDE; |
158 | |
159 | //! Computes the point of parameter U on the curve with its |
160 | //! first derivative. |
161 | //! Raised if the continuity of the current interval |
162 | //! is not C1. |
163 | Standard_EXPORT void D1 (const Standard_Real U, gp_Pnt2d& P, gp_Vec2d& V) const Standard_OVERRIDE; |
164 | |
165 | |
166 | //! Returns the point P of parameter U, the first and second |
167 | //! derivatives V1 and V2. |
168 | //! Raised if the continuity of the current interval |
169 | //! is not C2. |
170 | Standard_EXPORT void D2 (const Standard_Real U, gp_Pnt2d& P, gp_Vec2d& V1, gp_Vec2d& V2) const Standard_OVERRIDE; |
171 | |
172 | |
173 | //! Returns the point P of parameter U, the first, the second |
174 | //! and the third derivative. |
175 | //! Raised if the continuity of the current interval |
176 | //! is not C3. |
177 | Standard_EXPORT void D3 (const Standard_Real U, gp_Pnt2d& P, gp_Vec2d& V1, gp_Vec2d& V2, gp_Vec2d& V3) const Standard_OVERRIDE; |
178 | |
179 | |
180 | //! The returned vector gives the value of the derivative for the |
181 | //! order of derivation N. |
182 | //! Raised if the continuity of the current interval |
183 | //! is not CN. |
184 | //! Raised if N < 1. |
185 | Standard_EXPORT gp_Vec2d DN (const Standard_Real U, const Standard_Integer N) const Standard_OVERRIDE; |
186 | |
187 | //! Returns the parametric resolution corresponding |
188 | //! to the real space resolution <R3d>. |
189 | Standard_EXPORT Standard_Real Resolution (const Standard_Real R3d) const Standard_OVERRIDE; |
190 | |
191 | //! Returns the type of the curve in the current |
192 | //! interval : Line, Circle, Ellipse, Hyperbola, |
193 | //! Parabola, BezierCurve, BSplineCurve, OtherCurve. |
194 | Standard_EXPORT GeomAbs_CurveType GetType() const Standard_OVERRIDE; |
195 | |
196 | Standard_EXPORT gp_Lin2d Line() const Standard_OVERRIDE; |
197 | |
198 | Standard_EXPORT gp_Circ2d Circle() const Standard_OVERRIDE; |
199 | |
200 | Standard_EXPORT gp_Elips2d Ellipse() const Standard_OVERRIDE; |
201 | |
202 | Standard_EXPORT gp_Hypr2d Hyperbola() const Standard_OVERRIDE; |
203 | |
204 | Standard_EXPORT gp_Parab2d Parabola() const Standard_OVERRIDE; |
205 | |
206 | Standard_EXPORT Standard_Integer Degree() const Standard_OVERRIDE; |
207 | |
208 | Standard_EXPORT Standard_Boolean IsRational() const Standard_OVERRIDE; |
209 | |
210 | Standard_EXPORT Standard_Integer NbPoles() const Standard_OVERRIDE; |
211 | |
212 | Standard_EXPORT Standard_Integer NbKnots() const Standard_OVERRIDE; |
213 | |
214 | //! Warning ! This will NOT make a copy of the -- Bezier Curve - |
215 | //! If you want to modify -- the Curve please make a copy |
216 | //! yourself -- Also it will NOT trim the surface to -- |
217 | //! myFirst/Last. |
218 | Standard_EXPORT Handle(Geom2d_BezierCurve) Bezier() const Standard_OVERRIDE; |
219 | |
220 | //! Warning ! This will NOT make a copy of the BSpline Curve - If |
221 | //! you want to modify the Curve please make a copy |
222 | //! yourself Also it will NOT trim the surface to |
223 | //! myFirst/Last. |
224 | Standard_EXPORT Handle(Geom2d_BSplineCurve) BSpline() const Standard_OVERRIDE; |
225 | |
226 | |
227 | |
228 | |
229 | protected: |
230 | |
231 | |
232 | |
233 | |
234 | |
235 | private: |
236 | |
237 | |
238 | |
239 | Standard_Real myTolerance; |
240 | Handle(Adaptor3d_HSurface) mySurface; |
241 | Handle(Adaptor3d_HCurve) myCurve; |
242 | ProjLib_Projector myResult; |
f998596a |
243 | Standard_Integer myDegMin; |
244 | Standard_Integer myDegMax; |
245 | Standard_Integer myMaxSegments; |
246 | Standard_Real myMaxDist; |
247 | AppParCurves_Constraint myBndPnt; |
42cf5bc1 |
248 | }; |
249 | |
250 | |
251 | |
252 | |
253 | |
254 | |
255 | |
256 | #endif // _ProjLib_ProjectedCurve_HeaderFile |