42cf5bc1 |
1 | // Created on: 1997-09-22 |
2 | // Created by: Roman BORISOV |
3 | // Copyright (c) 1997-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_CompProjectedCurve_HeaderFile |
18 | #define _ProjLib_CompProjectedCurve_HeaderFile |
19 | |
20 | #include <Standard.hxx> |
21 | #include <Standard_DefineAlloc.hxx> |
22 | #include <Standard_Handle.hxx> |
23 | |
24 | #include <Standard_Integer.hxx> |
25 | #include <ProjLib_HSequenceOfHSequenceOfPnt.hxx> |
26 | #include <Standard_Real.hxx> |
27 | #include <TColStd_HArray1OfBoolean.hxx> |
28 | #include <TColStd_HArray1OfReal.hxx> |
29 | #include <Adaptor2d_Curve2d.hxx> |
30 | #include <Standard_Boolean.hxx> |
31 | #include <GeomAbs_Shape.hxx> |
32 | #include <TColStd_Array1OfReal.hxx> |
33 | #include <GeomAbs_CurveType.hxx> |
34 | class Adaptor3d_HSurface; |
35 | class Adaptor3d_HCurve; |
36 | class Standard_OutOfRange; |
37 | class Standard_NoSuchObject; |
38 | class Standard_DomainError; |
39 | class Standard_NotImplemented; |
40 | class gp_Pnt2d; |
41 | class gp_Vec2d; |
42 | class Adaptor2d_HCurve2d; |
43 | |
44 | |
45 | |
46 | class ProjLib_CompProjectedCurve : public Adaptor2d_Curve2d |
47 | { |
48 | public: |
49 | |
50 | DEFINE_STANDARD_ALLOC |
51 | |
52 | |
53 | Standard_EXPORT ProjLib_CompProjectedCurve(); |
54 | |
55 | //! try to find all solutions |
56 | Standard_EXPORT ProjLib_CompProjectedCurve(const Handle(Adaptor3d_HSurface)& S, const Handle(Adaptor3d_HCurve)& C, const Standard_Real TolU, const Standard_Real TolV); |
57 | |
58 | //! this constructor tries to optimize the search using the |
db2a696d |
59 | //! assumption that maximum distance between surface and curve less or |
42cf5bc1 |
60 | //! equal then MaxDist. |
61 | //! if MaxDist < 0 then algorithm works as above. |
62 | Standard_EXPORT ProjLib_CompProjectedCurve(const Handle(Adaptor3d_HSurface)& S, const Handle(Adaptor3d_HCurve)& C, const Standard_Real TolU, const Standard_Real TolV, const Standard_Real MaxDist); |
63 | |
64 | //! computes a set of projected point and determine the |
65 | //! continuous parts of the projected curves. The points |
66 | //! corresponding to a projection on the bounds of the surface are |
67 | //! included in this set of points. |
68 | Standard_EXPORT void Init(); |
69 | |
70 | //! Changes the surface. |
71 | Standard_EXPORT void Load (const Handle(Adaptor3d_HSurface)& S); |
72 | |
73 | //! Changes the curve. |
74 | Standard_EXPORT void Load (const Handle(Adaptor3d_HCurve)& C); |
75 | |
76 | Standard_EXPORT const Handle(Adaptor3d_HSurface)& GetSurface() const; |
77 | |
78 | Standard_EXPORT const Handle(Adaptor3d_HCurve)& GetCurve() const; |
79 | |
80 | Standard_EXPORT void GetTolerance (Standard_Real& TolU, Standard_Real& TolV) const; |
81 | |
82 | //! returns the number of continuous part of the projected curve |
83 | Standard_EXPORT Standard_Integer NbCurves() const; |
84 | |
85 | //! returns the bounds of the continuous part corresponding to Index |
86 | Standard_EXPORT void Bounds (const Standard_Integer Index, Standard_Real& Udeb, Standard_Real& Ufin) const; |
87 | |
db2a696d |
88 | //! returns True if part of projection with number Index is a single point and writes its coordinates in P |
42cf5bc1 |
89 | Standard_EXPORT Standard_Boolean IsSinglePnt (const Standard_Integer Index, gp_Pnt2d& P) const; |
90 | |
91 | //! returns True if part of projection with number Index is an u-isoparametric curve of input surface |
92 | Standard_EXPORT Standard_Boolean IsUIso (const Standard_Integer Index, Standard_Real& U) const; |
93 | |
94 | //! returns True if part of projection with number Index is an v-isoparametric curve of input surface |
95 | Standard_EXPORT Standard_Boolean IsVIso (const Standard_Integer Index, Standard_Real& V) const; |
96 | |
97 | //! Computes the point of parameter U on the curve. |
98 | Standard_EXPORT gp_Pnt2d Value (const Standard_Real U) const Standard_OVERRIDE; |
99 | |
100 | //! Computes the point of parameter U on the curve. |
101 | Standard_EXPORT void D0 (const Standard_Real U, gp_Pnt2d& P) const Standard_OVERRIDE; |
102 | |
103 | //! Computes the point of parameter U on the curve with its |
104 | //! first derivative. |
105 | //! Raised if the continuity of the current interval |
106 | //! is not C1. |
107 | Standard_EXPORT void D1 (const Standard_Real U, gp_Pnt2d& P, gp_Vec2d& V) const Standard_OVERRIDE; |
108 | |
109 | |
110 | //! Returns the point P of parameter U, the first and second |
111 | //! derivatives V1 and V2. |
112 | //! Raised if the continuity of the current interval |
113 | //! is not C2. |
114 | Standard_EXPORT void D2 (const Standard_Real U, gp_Pnt2d& P, gp_Vec2d& V1, gp_Vec2d& V2) const Standard_OVERRIDE; |
115 | |
116 | |
117 | //! The returned vector gives the value of the derivative for the |
118 | //! order of derivation N. |
119 | //! Raised if N < 1. |
120 | //! Raised if N > 2. |
121 | Standard_EXPORT gp_Vec2d DN (const Standard_Real U, const Standard_Integer N) const Standard_OVERRIDE; |
122 | |
123 | //! Returns the first parameter of the curve C |
124 | //! which has a projection on S. |
125 | Standard_EXPORT Standard_Real FirstParameter() const Standard_OVERRIDE; |
126 | |
127 | //! Returns the last parameter of the curve C |
128 | //! which has a projection on S. |
129 | Standard_EXPORT Standard_Real LastParameter() const Standard_OVERRIDE; |
130 | |
131 | //! Returns the number of intervals which define |
132 | //! an S continuous part of the projected curve |
133 | Standard_EXPORT Standard_Integer NbIntervals (const GeomAbs_Shape S) const Standard_OVERRIDE; |
134 | |
135 | //! Returns a curve equivalent of <me> between |
136 | //! parameters <First> and <Last>. <Tol> is used to |
137 | //! test for 2d points confusion. |
138 | //! If <First> >= <Last> |
139 | Standard_EXPORT Handle(Adaptor2d_HCurve2d) Trim (const Standard_Real FirstParam, const Standard_Real LastParam, const Standard_Real Tol) const Standard_OVERRIDE; |
140 | |
141 | //! Returns the parameters corresponding to |
142 | //! S discontinuities. |
143 | //! |
5333268d |
144 | //! The array must provide enough room to accommodate |
42cf5bc1 |
145 | //! for the parameters. i.e. T.Length() > NbIntervals() |
146 | Standard_EXPORT void Intervals (TColStd_Array1OfReal& T, const GeomAbs_Shape S) const Standard_OVERRIDE; |
147 | |
148 | //! returns the maximum distance between |
149 | //! curve to project and surface |
150 | Standard_EXPORT Standard_Real MaxDistance (const Standard_Integer Index) const; |
151 | |
152 | Standard_EXPORT const Handle(ProjLib_HSequenceOfHSequenceOfPnt)& GetSequence() const; |
153 | |
154 | //! Returns the type of the curve in the current |
155 | //! interval : Line, Circle, Ellipse, Hyperbola, |
156 | //! Parabola, BezierCurve, BSplineCurve, OtherCurve. |
157 | Standard_EXPORT GeomAbs_CurveType GetType() const Standard_OVERRIDE; |
158 | |
159 | |
160 | |
161 | |
162 | protected: |
163 | |
164 | |
165 | |
166 | |
167 | |
168 | private: |
169 | |
5333268d |
170 | //! This method performs check possibility of optimization traps and tries to go out from them. |
db2a696d |
171 | //@return thePoint - input / corrected point. |
172 | Standard_EXPORT void UpdateTripleByTrapCriteria(gp_Pnt &thePoint) const; |
173 | |
42cf5bc1 |
174 | Standard_EXPORT void BuildIntervals (const GeomAbs_Shape S) const; |
175 | |
176 | |
177 | Handle(Adaptor3d_HSurface) mySurface; |
178 | Handle(Adaptor3d_HCurve) myCurve; |
179 | Standard_Integer myNbCurves; |
180 | Handle(ProjLib_HSequenceOfHSequenceOfPnt) mySequence; |
181 | Standard_Real myTolU; |
182 | Standard_Real myTolV; |
183 | Standard_Real myMaxDist; |
184 | Handle(TColStd_HArray1OfBoolean) myUIso; |
185 | Handle(TColStd_HArray1OfBoolean) myVIso; |
186 | Handle(TColStd_HArray1OfBoolean) mySnglPnts; |
187 | Handle(TColStd_HArray1OfReal) myMaxDistance; |
188 | Handle(TColStd_HArray1OfReal) myTabInt; |
42cf5bc1 |
189 | }; |
190 | |
191 | |
192 | |
193 | |
194 | |
195 | |
196 | |
197 | #endif // _ProjLib_CompProjectedCurve_HeaderFile |