42cf5bc1 |
1 | // Created on: 1993-02-22 |
2 | // Created by: Modelistation |
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 _Adaptor3d_CurveOnSurface_HeaderFile |
18 | #define _Adaptor3d_CurveOnSurface_HeaderFile |
19 | |
20 | #include <Standard.hxx> |
21 | #include <Standard_DefineAlloc.hxx> |
22 | #include <Standard_Handle.hxx> |
23 | |
24 | #include <GeomAbs_CurveType.hxx> |
25 | #include <gp_Circ.hxx> |
26 | #include <gp_Lin.hxx> |
27 | #include <TColStd_HSequenceOfReal.hxx> |
28 | #include <GeomAbs_Shape.hxx> |
29 | #include <Adaptor3d_Curve.hxx> |
30 | #include <Standard_Real.hxx> |
31 | #include <Standard_Integer.hxx> |
32 | #include <TColStd_Array1OfReal.hxx> |
33 | #include <Standard_Boolean.hxx> |
34 | class Adaptor3d_HSurface; |
35 | class Adaptor2d_HCurve2d; |
36 | class Standard_NoSuchObject; |
37 | class Standard_DomainError; |
38 | class Standard_OutOfRange; |
39 | class Adaptor3d_HCurve; |
40 | class gp_Pnt; |
41 | class gp_Vec; |
42 | class gp_Lin; |
43 | class gp_Circ; |
44 | class gp_Elips; |
45 | class gp_Hypr; |
46 | class gp_Parab; |
47 | class Geom_BezierCurve; |
48 | class Geom_BSplineCurve; |
49 | class gp_Pnt2d; |
50 | class gp_Vec2d; |
51 | |
52 | |
53 | //! An interface between the services provided by a curve |
54 | //! lying on a surface from the package Geom and those |
55 | //! required of the curve by algorithms which use it. The |
56 | //! curve is defined as a 2D curve from the Geom2d |
57 | //! package, in the parametric space of the surface. |
58 | class Adaptor3d_CurveOnSurface : public Adaptor3d_Curve |
59 | { |
60 | public: |
61 | |
62 | DEFINE_STANDARD_ALLOC |
63 | |
64 | |
65 | Standard_EXPORT Adaptor3d_CurveOnSurface(); |
66 | |
67 | Standard_EXPORT Adaptor3d_CurveOnSurface(const Handle(Adaptor3d_HSurface)& S); |
68 | |
69 | //! Creates a CurveOnSurface from the 2d curve <C> and |
70 | //! the surface <S>. |
71 | Standard_EXPORT Adaptor3d_CurveOnSurface(const Handle(Adaptor2d_HCurve2d)& C, const Handle(Adaptor3d_HSurface)& S); |
72 | |
73 | //! Changes the surface. |
74 | Standard_EXPORT void Load (const Handle(Adaptor3d_HSurface)& S); |
75 | |
76 | //! Changes the 2d curve. |
77 | Standard_EXPORT void Load (const Handle(Adaptor2d_HCurve2d)& C); |
78 | |
79 | //! Load both curve and surface. |
80 | Standard_EXPORT void Load (const Handle(Adaptor2d_HCurve2d)& C, const Handle(Adaptor3d_HSurface)& S); |
81 | |
82 | Standard_EXPORT const Handle(Adaptor2d_HCurve2d)& GetCurve() const; |
83 | |
84 | Standard_EXPORT const Handle(Adaptor3d_HSurface)& GetSurface() const; |
85 | |
86 | Standard_EXPORT Handle(Adaptor2d_HCurve2d)& ChangeCurve(); |
87 | |
88 | Standard_EXPORT Handle(Adaptor3d_HSurface)& ChangeSurface(); |
89 | |
90 | Standard_EXPORT Standard_Real FirstParameter() const Standard_OVERRIDE; |
91 | |
92 | Standard_EXPORT Standard_Real LastParameter() const Standard_OVERRIDE; |
93 | |
94 | Standard_EXPORT GeomAbs_Shape Continuity() const Standard_OVERRIDE; |
95 | |
96 | //! Returns the number of intervals for continuity |
97 | //! <S>. May be one if Continuity(me) >= <S> |
98 | Standard_EXPORT Standard_Integer NbIntervals (const GeomAbs_Shape S) const Standard_OVERRIDE; |
99 | |
100 | //! Stores in <T> the parameters bounding the intervals |
101 | //! of continuity <S>. |
102 | //! |
103 | //! The array must provide enough room to accomodate |
104 | //! for the parameters. i.e. T.Length() > NbIntervals() |
105 | Standard_EXPORT void Intervals (TColStd_Array1OfReal& T, const GeomAbs_Shape S) const Standard_OVERRIDE; |
106 | |
107 | //! Returns a curve equivalent of <me> between |
108 | //! parameters <First> and <Last>. <Tol> is used to |
109 | //! test for 3d points confusion. |
110 | //! If <First> >= <Last> |
111 | Standard_EXPORT Handle(Adaptor3d_HCurve) Trim (const Standard_Real First, const Standard_Real Last, const Standard_Real Tol) const Standard_OVERRIDE; |
112 | |
113 | Standard_EXPORT Standard_Boolean IsClosed() const Standard_OVERRIDE; |
114 | |
115 | Standard_EXPORT Standard_Boolean IsPeriodic() const Standard_OVERRIDE; |
116 | |
117 | Standard_EXPORT Standard_Real Period() const Standard_OVERRIDE; |
118 | |
119 | //! Computes the point of parameter U on the curve. |
120 | Standard_EXPORT gp_Pnt Value (const Standard_Real U) const Standard_OVERRIDE; |
121 | |
122 | //! Computes the point of parameter U on the curve. |
123 | Standard_EXPORT void D0 (const Standard_Real U, gp_Pnt& P) const Standard_OVERRIDE; |
124 | |
125 | //! Computes the point of parameter U on the curve with its |
126 | //! first derivative. |
127 | //! Raised if the continuity of the current interval |
128 | //! is not C1. |
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 | //! Raised if the continuity of the current interval |
135 | //! is not C2. |
136 | Standard_EXPORT void D2 (const Standard_Real U, gp_Pnt& P, gp_Vec& V1, gp_Vec& V2) const Standard_OVERRIDE; |
137 | |
138 | |
139 | //! Returns the point P of parameter U, the first, the second |
140 | //! and the third derivative. |
141 | //! Raised if the continuity of the current interval |
142 | //! is not C3. |
143 | Standard_EXPORT void D3 (const Standard_Real U, gp_Pnt& P, gp_Vec& V1, gp_Vec& V2, gp_Vec& V3) const Standard_OVERRIDE; |
144 | |
145 | |
146 | //! The returned vector gives the value of the derivative for the |
147 | //! order of derivation N. |
148 | //! Raised if the continuity of the current interval |
149 | //! is not CN. |
150 | //! Raised if N < 1. |
151 | Standard_EXPORT gp_Vec DN (const Standard_Real U, const Standard_Integer N) const Standard_OVERRIDE; |
152 | |
153 | //! Returns the parametric resolution corresponding |
154 | //! to the real space resolution <R3d>. |
155 | Standard_EXPORT Standard_Real Resolution (const Standard_Real R3d) const Standard_OVERRIDE; |
156 | |
157 | //! Returns the type of the curve in the current |
158 | //! interval : Line, Circle, Ellipse, Hyperbola, |
159 | //! Parabola, BezierCurve, BSplineCurve, OtherCurve. |
160 | Standard_EXPORT GeomAbs_CurveType GetType() const Standard_OVERRIDE; |
161 | |
162 | Standard_EXPORT gp_Lin Line() const Standard_OVERRIDE; |
163 | |
164 | Standard_EXPORT gp_Circ Circle() const Standard_OVERRIDE; |
165 | |
166 | Standard_EXPORT gp_Elips Ellipse() const Standard_OVERRIDE; |
167 | |
168 | Standard_EXPORT gp_Hypr Hyperbola() const Standard_OVERRIDE; |
169 | |
170 | Standard_EXPORT gp_Parab Parabola() const Standard_OVERRIDE; |
171 | |
172 | Standard_EXPORT Standard_Integer Degree() const Standard_OVERRIDE; |
173 | |
174 | Standard_EXPORT Standard_Boolean IsRational() const Standard_OVERRIDE; |
175 | |
176 | Standard_EXPORT Standard_Integer NbPoles() const Standard_OVERRIDE; |
177 | |
178 | Standard_EXPORT Standard_Integer NbKnots() const Standard_OVERRIDE; |
179 | |
180 | Standard_EXPORT Handle(Geom_BezierCurve) Bezier() const Standard_OVERRIDE; |
181 | |
182 | Standard_EXPORT Handle(Geom_BSplineCurve) BSpline() const Standard_OVERRIDE; |
183 | |
184 | |
185 | |
186 | |
187 | protected: |
188 | |
189 | |
190 | |
191 | |
192 | |
193 | private: |
194 | |
195 | |
196 | Standard_EXPORT void EvalKPart(); |
197 | |
198 | //! Evaluates myFirstSurf and myLastSurf |
199 | //! for trimming the curve on surface. |
200 | //! Following methods output left-bottom and right-top points |
201 | //! of located part on surface |
202 | //! for trimming the curve on surface. |
203 | Standard_EXPORT void EvalFirstLastSurf(); |
204 | |
205 | Standard_EXPORT void LocatePart (const gp_Pnt2d& UV, const gp_Vec2d& DUV, const Handle(Adaptor3d_HSurface)& S, gp_Pnt2d& LeftBot, gp_Pnt2d& RightTop) const; |
206 | |
207 | Standard_EXPORT Standard_Boolean LocatePart_RevExt (const gp_Pnt2d& UV, const gp_Vec2d& DUV, const Handle(Adaptor3d_HSurface)& S, gp_Pnt2d& LeftBot, gp_Pnt2d& RightTop) const; |
208 | |
209 | Standard_EXPORT Standard_Boolean LocatePart_Offset (const gp_Pnt2d& UV, const gp_Vec2d& DUV, const Handle(Adaptor3d_HSurface)& S, gp_Pnt2d& LeftBot, gp_Pnt2d& RightTop) const; |
210 | |
211 | //! Extracts the numbers of knots which equal |
212 | //! the point and checks derivative components |
213 | //! by zero equivalence. |
214 | Standard_EXPORT void FindBounds (const TColStd_Array1OfReal& Arr, const Standard_Real XYComp, const Standard_Real DUVComp, Standard_Integer& Bnd1, Standard_Integer& Bnd2, Standard_Boolean& DerIsNull) const; |
215 | |
216 | |
217 | Handle(Adaptor3d_HSurface) mySurface; |
218 | Handle(Adaptor2d_HCurve2d) myCurve; |
219 | GeomAbs_CurveType myType; |
220 | gp_Circ myCirc; |
221 | gp_Lin myLin; |
222 | Handle(Adaptor3d_HSurface) myFirstSurf; |
223 | Handle(Adaptor3d_HSurface) myLastSurf; |
224 | Handle(TColStd_HSequenceOfReal) myIntervals; |
225 | GeomAbs_Shape myIntCont; |
226 | |
227 | |
228 | }; |
229 | |
230 | |
231 | |
232 | |
233 | |
234 | |
235 | |
236 | #endif // _Adaptor3d_CurveOnSurface_HeaderFile |