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