42cf5bc1 |
1 | // Created on: 1994-07-06 |
2 | // Created by: Laurent PAINNOT |
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 _Extrema_ExtCC_HeaderFile |
18 | #define _Extrema_ExtCC_HeaderFile |
19 | |
20 | #include <Standard.hxx> |
21 | #include <Standard_DefineAlloc.hxx> |
22 | #include <Standard_Handle.hxx> |
23 | |
24 | #include <Extrema_ECC.hxx> |
25 | #include <Standard_Boolean.hxx> |
26 | #include <Extrema_SequenceOfPOnCurv.hxx> |
27 | #include <TColStd_SequenceOfReal.hxx> |
28 | #include <Standard_Integer.hxx> |
29 | #include <Standard_Address.hxx> |
30 | #include <Standard_Real.hxx> |
31 | #include <gp_Pnt.hxx> |
32 | class StdFail_InfiniteSolutions; |
33 | class StdFail_NotDone; |
34 | class Standard_OutOfRange; |
35 | class Adaptor3d_Curve; |
36 | class Extrema_POnCurv; |
37 | class gp_Pnt; |
38 | class Extrema_ExtElC; |
39 | class Extrema_ECC; |
40 | |
41 | |
42 | //! It calculates all the distance between two curves. |
43 | //! These distances can be maximum or minimum. |
44 | class Extrema_ExtCC |
45 | { |
46 | public: |
47 | |
48 | DEFINE_STANDARD_ALLOC |
49 | |
50 | |
51 | Standard_EXPORT Extrema_ExtCC(const Standard_Real TolC1 = 1.0e-10, const Standard_Real TolC2 = 1.0e-10); |
52 | |
53 | //! It calculates all the distances. |
54 | Standard_EXPORT Extrema_ExtCC(const Adaptor3d_Curve& C1, const Adaptor3d_Curve& C2, const Standard_Real TolC1 = 1.0e-10, const Standard_Real TolC2 = 1.0e-10); |
55 | |
56 | //! It calculates all the distances. |
57 | Standard_EXPORT Extrema_ExtCC(const Adaptor3d_Curve& C1, const Adaptor3d_Curve& C2, const Standard_Real U1, const Standard_Real U2, const Standard_Real V1, const Standard_Real V2, const Standard_Real TolC1 = 1.0e-10, const Standard_Real TolC2 = 1.0e-10); |
58 | |
59 | Standard_EXPORT void SetCurve (const Standard_Integer theRank, const Adaptor3d_Curve& C); |
60 | |
61 | Standard_EXPORT void SetCurve (const Standard_Integer theRank, const Adaptor3d_Curve& C, const Standard_Real Uinf, const Standard_Real Usup); |
62 | |
63 | Standard_EXPORT void SetRange (const Standard_Integer theRank, const Standard_Real Uinf, const Standard_Real Usup); |
64 | |
65 | Standard_EXPORT void SetTolerance (const Standard_Integer theRank, const Standard_Real Tol); |
66 | |
67 | Standard_EXPORT void Perform(); |
68 | |
69 | //! Returns True if the distances are found. |
70 | Standard_EXPORT Standard_Boolean IsDone() const; |
71 | |
72 | //! Returns the number of extremum distances. |
73 | Standard_EXPORT Standard_Integer NbExt() const; |
74 | |
75 | //! Returns True if the two curves are parallel. |
76 | Standard_EXPORT Standard_Boolean IsParallel() const; |
77 | |
78 | //! Returns the value of the Nth extremum square distance. |
79 | Standard_EXPORT Standard_Real SquareDistance (const Standard_Integer N = 1) const; |
80 | |
81 | //! Returns the points of the Nth extremum distance. |
82 | //! P1 is on the first curve, P2 on the second one. |
83 | Standard_EXPORT void Points (const Standard_Integer N, Extrema_POnCurv& P1, Extrema_POnCurv& P2) const; |
84 | |
85 | //! if the curve is a trimmed curve, |
86 | //! dist11 is a square distance between the point on C1 |
87 | //! of parameter FirstParameter and the point of |
88 | //! parameter FirstParameter on C2. |
89 | Standard_EXPORT void TrimmedSquareDistances (Standard_Real& dist11, Standard_Real& distP12, Standard_Real& distP21, Standard_Real& distP22, gp_Pnt& P11, gp_Pnt& P12, gp_Pnt& P21, gp_Pnt& P22) const; |
90 | |
836d7b64 |
91 | //! Set flag for single extrema computation. Works on parametric solver only. |
92 | Standard_EXPORT void SetSingleSolutionFlag (const Standard_Boolean theSingleSolutionFlag); |
42cf5bc1 |
93 | |
836d7b64 |
94 | //! Get flag for single extrema computation. Works on parametric solver only. |
95 | Standard_EXPORT Standard_Boolean GetSingleSolutionFlag () const; |
42cf5bc1 |
96 | |
97 | protected: |
98 | |
638ad7f3 |
99 | //! Prepares the extrema result(s) for analytical cases (line, circle, ellipsis etc.) |
100 | Standard_EXPORT void PrepareResults (const Extrema_ExtElC& AlgExt, |
101 | const Standard_Boolean theIsInverse, |
102 | const Standard_Real Ut11, |
103 | const Standard_Real Ut12, |
104 | const Standard_Real Ut21, |
105 | const Standard_Real Ut22); |
106 | |
107 | //! Prepares the extrema result(s) for general cases (e.g. with B-spline curves). |
108 | Standard_EXPORT void PrepareResults (const Extrema_ECC& AlgExt, |
109 | const Standard_Real Ut11, |
110 | const Standard_Real Ut12, |
111 | const Standard_Real Ut21, |
112 | const Standard_Real Ut22); |
113 | |
114 | //! Prepares the extrema result(s) in case when the given curves are parallel. |
115 | Standard_EXPORT void PrepareParallelResult(const Standard_Real theUt11, |
116 | const Standard_Real theUt12, |
117 | const Standard_Real theUt21, |
118 | const Standard_Real theUt22, |
119 | const Standard_Real theSqDist); |
120 | |
121 | // Clears all found extremas. |
122 | // This method does not change any flags (e.g. Done or IsParallel) |
123 | void ClearSolutions() |
124 | { |
125 | mySqDist.Clear(); |
126 | mypoints.Clear(); |
127 | } |
42cf5bc1 |
128 | |
129 | private: |
130 | |
131 | |
836d7b64 |
132 | Standard_Boolean myIsFindSingleSolution; // Default value is false. |
42cf5bc1 |
133 | Extrema_ECC myECC; |
134 | Standard_Boolean myDone; |
135 | Standard_Boolean myIsPar; |
136 | Extrema_SequenceOfPOnCurv mypoints; |
137 | TColStd_SequenceOfReal mySqDist; |
42cf5bc1 |
138 | Standard_Address myC[2]; |
139 | Standard_Real myInf[2]; |
140 | Standard_Real mySup[2]; |
141 | Standard_Real myTol[2]; |
142 | gp_Pnt P1f; |
143 | gp_Pnt P1l; |
144 | gp_Pnt P2f; |
145 | gp_Pnt P2l; |
146 | Standard_Real mydist11; |
147 | Standard_Real mydist12; |
148 | Standard_Real mydist21; |
149 | Standard_Real mydist22; |
150 | |
151 | |
152 | }; |
153 | |
154 | |
155 | |
156 | |
157 | |
158 | |
159 | |
160 | #endif // _Extrema_ExtCC_HeaderFile |