42cf5bc1 |
1 | // Created on: 1994-03-18 |
2 | // Created by: Bruno DUMORTIER |
3 | // Copyright (c) 1994-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 _GeomAPI_ExtremaCurveCurve_HeaderFile |
18 | #define _GeomAPI_ExtremaCurveCurve_HeaderFile |
19 | |
20 | #include <Standard.hxx> |
21 | #include <Standard_DefineAlloc.hxx> |
22 | #include <Standard_Handle.hxx> |
23 | |
24 | #include <Standard_Boolean.hxx> |
25 | #include <Standard_Integer.hxx> |
26 | #include <Extrema_ExtCC.hxx> |
27 | #include <GeomAdaptor_Curve.hxx> |
28 | #include <Standard_Real.hxx> |
29 | #include <gp_Pnt.hxx> |
30 | #include <Quantity_Parameter.hxx> |
31 | #include <Quantity_Length.hxx> |
32 | class Standard_OutOfRange; |
33 | class StdFail_NotDone; |
34 | class Geom_Curve; |
35 | class gp_Pnt; |
36 | class Extrema_ExtCC; |
37 | |
38 | |
39 | //! Describes functions for computing all the extrema |
40 | //! between two 3D curves. |
41 | //! An ExtremaCurveCurve algorithm minimizes or |
42 | //! maximizes the distance between a point on the first |
43 | //! curve and a point on the second curve. Thus, it |
44 | //! computes start and end points of perpendiculars |
45 | //! common to the two curves (an intersection point is |
46 | //! not an extremum unless the two curves are tangential at this point). |
47 | //! Solutions consist of pairs of points, and an extremum |
48 | //! is considered to be a segment joining the two points of a solution. |
49 | //! An ExtremaCurveCurve object provides a framework for: |
50 | //! - defining the construction of the extrema, |
51 | //! - implementing the construction algorithm, and |
52 | //! - consulting the results. |
53 | //! Warning |
54 | //! In some cases, the nearest points between two |
55 | //! curves do not correspond to one of the computed |
56 | //! extrema. Instead, they may be given by: |
57 | //! - a limit point of one curve and one of the following: |
58 | //! - its orthogonal projection on the other curve, |
59 | //! - a limit point of the other curve; or |
60 | //! - an intersection point between the two curves. |
61 | class GeomAPI_ExtremaCurveCurve |
62 | { |
63 | public: |
64 | |
65 | DEFINE_STANDARD_ALLOC |
66 | |
67 | |
68 | //! Constructs an empty algorithm for computing |
69 | //! extrema between two curves. Use an Init function |
70 | //! to define the curves on which it is going to work. |
71 | Standard_EXPORT GeomAPI_ExtremaCurveCurve(); |
72 | |
73 | //! Computes the extrema between the curves C1 and C2. |
74 | Standard_EXPORT GeomAPI_ExtremaCurveCurve(const Handle(Geom_Curve)& C1, const Handle(Geom_Curve)& C2); |
75 | |
76 | //! Computes the portion of the curve C1 limited by the two |
77 | //! points of parameter (U1min,U1max), and |
78 | //! - the portion of the curve C2 limited by the two |
79 | //! points of parameter (U2min,U2max). |
80 | //! Warning |
81 | //! Use the function NbExtrema to obtain the number |
82 | //! of solutions. If this algorithm fails, NbExtrema returns 0. |
83 | Standard_EXPORT GeomAPI_ExtremaCurveCurve(const Handle(Geom_Curve)& C1, const Handle(Geom_Curve)& C2, const Quantity_Parameter U1min, const Quantity_Parameter U1max, const Quantity_Parameter U2min, const Quantity_Parameter U2max); |
84 | |
85 | //! Initializes this algorithm with the given arguments |
86 | //! and computes the extrema between the curves C1 and C2 |
87 | Standard_EXPORT void Init (const Handle(Geom_Curve)& C1, const Handle(Geom_Curve)& C2); |
88 | |
89 | //! Initializes this algorithm with the given arguments |
90 | //! and computes the extrema between : |
91 | //! - the portion of the curve C1 limited by the two |
92 | //! points of parameter (U1min,U1max), and |
93 | //! - the portion of the curve C2 limited by the two |
94 | //! points of parameter (U2min,U2max). |
95 | //! Warning |
96 | //! Use the function NbExtrema to obtain the number |
97 | //! of solutions. If this algorithm fails, NbExtrema returns 0. |
98 | Standard_EXPORT void Init (const Handle(Geom_Curve)& C1, const Handle(Geom_Curve)& C2, const Quantity_Parameter U1min, const Quantity_Parameter U1max, const Quantity_Parameter U2min, const Quantity_Parameter U2max); |
99 | |
100 | //! Returns the number of extrema computed by this algorithm. |
101 | //! Note: if this algorithm fails, NbExtrema returns 0. |
102 | Standard_EXPORT Standard_Integer NbExtrema() const; |
103 | Standard_EXPORT operator Standard_Integer() const; |
104 | |
105 | //! Returns the points P1 on the first curve and P2 on |
106 | //! the second curve, which are the ends of the |
107 | //! extremum of index Index computed by this algorithm. |
108 | //! Exceptions |
109 | //! Standard_OutOfRange if Index is not in the range [ |
110 | //! 1,NbExtrema ], where NbExtrema is the |
111 | //! number of extrema computed by this algorithm. |
112 | Standard_EXPORT void Points (const Standard_Integer Index, gp_Pnt& P1, gp_Pnt& P2) const; |
113 | |
114 | //! Returns the parameters U1 of the point on the first |
115 | //! curve and U2 of the point on the second curve, which |
116 | //! are the ends of the extremum of index Index computed by this algorithm. |
117 | //! Exceptions |
118 | //! Standard_OutOfRange if Index is not in the range [ |
119 | //! 1,NbExtrema ], where NbExtrema is the |
120 | //! number of extrema computed by this algorithm. |
121 | Standard_EXPORT void Parameters (const Standard_Integer Index, Quantity_Parameter& U1, Quantity_Parameter& U2) const; |
122 | |
123 | //! Computes the distance between the end points of the |
124 | //! extremum of index Index computed by this algorithm. |
125 | //! Exceptions |
126 | //! Standard_OutOfRange if Index is not in the range [ |
127 | //! 1,NbExtrema ], where NbExtrema is the |
128 | //! number of extrema computed by this algorithm. |
129 | Standard_EXPORT Quantity_Length Distance (const Standard_Integer Index) const; |
130 | |
131 | //! Returns the points P1 on the first curve and P2 on |
132 | //! the second curve, which are the ends of the shortest |
133 | //! extremum computed by this algorithm. |
134 | //! Exceptions StdFail_NotDone if this algorithm fails. |
135 | Standard_EXPORT void NearestPoints (gp_Pnt& P1, gp_Pnt& P2) const; |
136 | |
137 | //! Returns the parameters U1 of the point on the first |
138 | //! curve and U2 of the point on the second curve, which |
139 | //! are the ends of the shortest extremum computed by this algorithm. |
140 | //! Exceptions StdFail_NotDone if this algorithm fails. |
141 | Standard_EXPORT void LowerDistanceParameters (Quantity_Parameter& U1, Quantity_Parameter& U2) const; |
142 | |
143 | //! Computes the distance between the end points of the |
144 | //! shortest extremum computed by this algorithm. |
145 | //! Exceptions StdFail_NotDone if this algorithm fails. |
146 | Standard_EXPORT Quantity_Length LowerDistance() const; |
147 | Standard_EXPORT operator Standard_Real() const; |
148 | |
149 | //! return the algorithmic object from Extrema |
150 | const Extrema_ExtCC& Extrema() const; |
151 | |
152 | //! set in <P1> and <P2> the couple solution points |
153 | //! such a the distance [P1,P2] is the minimum. taking in account |
154 | //! extremity points of curves. |
155 | Standard_EXPORT Standard_Boolean TotalNearestPoints (gp_Pnt& P1, gp_Pnt& P2); |
156 | |
157 | //! set in <U1> and <U2> the parameters of the couple |
158 | //! solution points which represents the total nearest |
159 | //! solution. |
160 | Standard_EXPORT Standard_Boolean TotalLowerDistanceParameters (Quantity_Parameter& U1, Quantity_Parameter& U2); |
161 | |
162 | //! return the distance of the total nearest couple solution |
163 | //! point. |
164 | //! if <myExtCC> is not done |
165 | Standard_EXPORT Quantity_Length TotalLowerDistance(); |
166 | |
167 | |
168 | |
169 | |
170 | protected: |
171 | |
172 | |
173 | |
174 | |
175 | |
176 | private: |
177 | |
178 | |
179 | Standard_EXPORT void TotalPerform(); |
180 | |
181 | |
182 | Standard_Boolean myIsDone; |
183 | Standard_Integer myIndex; |
184 | Extrema_ExtCC myExtCC; |
185 | GeomAdaptor_Curve myC1; |
186 | GeomAdaptor_Curve myC2; |
187 | Standard_Boolean myTotalExt; |
188 | Standard_Boolean myIsInfinite; |
189 | Standard_Real myTotalDist; |
190 | gp_Pnt myTotalPoints[2]; |
191 | Standard_Real myTotalPars[2]; |
192 | |
193 | |
194 | }; |
195 | |
196 | |
197 | #include <GeomAPI_ExtremaCurveCurve.lxx> |
198 | |
199 | |
200 | |
201 | |
202 | |
203 | #endif // _GeomAPI_ExtremaCurveCurve_HeaderFile |