42cf5bc1 |
1 | // Created on: 1992-10-20 |
2 | // Created by: Remi GILET |
3 | // Copyright (c) 1992-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 _Geom2dGcc_Circ2d3Tan_HeaderFile |
18 | #define _Geom2dGcc_Circ2d3Tan_HeaderFile |
19 | |
20 | #include <Standard.hxx> |
21 | #include <Standard_DefineAlloc.hxx> |
22 | #include <Standard_Handle.hxx> |
23 | |
24 | #include <TColgp_Array1OfCirc2d.hxx> |
25 | #include <Standard_Real.hxx> |
26 | #include <Standard_Boolean.hxx> |
27 | #include <GccEnt_Array1OfPosition.hxx> |
28 | #include <TColStd_Array1OfInteger.hxx> |
29 | #include <TColgp_Array1OfPnt2d.hxx> |
30 | #include <TColStd_Array1OfReal.hxx> |
31 | #include <Standard_Integer.hxx> |
32 | #include <GccEnt_Position.hxx> |
33 | class StdFail_NotDone; |
34 | class Standard_OutOfRange; |
35 | class Geom2dGcc_QualifiedCurve; |
36 | class Geom2d_Point; |
37 | class GccAna_Circ2d3Tan; |
38 | class gp_Circ2d; |
39 | class gp_Pnt2d; |
40 | |
41 | |
42 | //! This class implements the algorithms used to |
43 | //! create 2d circles tangent to 3 points/lines/circles/ |
44 | //! curves with one curve or more. |
45 | //! The arguments of all construction methods are : |
46 | //! - The three qualifiied elements for the |
47 | //! tangency constrains (QualifiedCirc, QualifiedLine, |
48 | //! Qualifiedcurv, Points). |
49 | //! - A parameter for each QualifiedCurv. |
50 | //! Describes functions for building a 2D circle: |
51 | //! - tangential to 3 curves, or |
52 | //! - tangential to 2 curves and passing through a point, or |
53 | //! - tangential to a curve and passing through 2 points, or |
54 | //! - passing through 3 points. |
55 | //! A Circ2d3Tan object provides a framework for: |
56 | //! - defining the construction of 2D circles(s), |
57 | //! - implementing the construction algorithm, and |
58 | //! - consulting the result(s). |
59 | class Geom2dGcc_Circ2d3Tan |
60 | { |
61 | public: |
62 | |
63 | DEFINE_STANDARD_ALLOC |
64 | |
65 | |
66 | //! Constructs one or more 2D circles |
67 | //! tangential to three curves Qualified1, Qualified2 and |
68 | //! Qualified3, where Param1, Param2 and Param3 are |
69 | //! used, respectively, as the initial values of the |
70 | //! parameters on Qualified1, Qualified2 and Qualified3 |
71 | //! of the tangency point between these arguments and |
72 | //! the solution sought, if the algorithm chooses an |
73 | //! iterative method to find the solution (i.e. if either |
74 | //! Qualified1, Qualified2 or Qualified3 is more complex |
75 | //! than a line or a circle). |
76 | Standard_EXPORT Geom2dGcc_Circ2d3Tan(const Geom2dGcc_QualifiedCurve& Qualified1, const Geom2dGcc_QualifiedCurve& Qualified2, const Geom2dGcc_QualifiedCurve& Qualified3, const Standard_Real Tolerance, const Standard_Real Param1, const Standard_Real Param2, const Standard_Real Param3); |
77 | |
78 | //! Constructs one or more 2D circles |
79 | //! tangential to two curves Qualified1 and Qualified2 |
80 | //! and passing through the point Point, where Param1 |
81 | //! and Param2 are used, respectively, as the initial |
82 | //! values of the parameters on Qualified1 and |
83 | //! Qualified2 of the tangency point between this |
84 | //! argument and the solution sought, if the algorithm |
85 | //! chooses an iterative method to find the solution (i.e. if |
86 | //! either Qualified1 or Qualified2 is more complex than |
87 | //! a line or a circle). |
88 | Standard_EXPORT Geom2dGcc_Circ2d3Tan(const Geom2dGcc_QualifiedCurve& Qualified1, const Geom2dGcc_QualifiedCurve& Qualified2, const Handle(Geom2d_Point)& Point, const Standard_Real Tolerance, const Standard_Real Param1, const Standard_Real Param2); |
89 | |
90 | //! Constructs one or more 2D circles tangential to the curve Qualified1 and passing |
91 | //! through two points Point1 and Point2, where Param1 |
92 | //! is used as the initial value of the parameter on |
93 | //! Qualified1 of the tangency point between this |
94 | //! argument and the solution sought, if the algorithm |
95 | //! chooses an iterative method to find the solution (i.e. if |
96 | //! Qualified1 is more complex than a line or a circle) |
97 | Standard_EXPORT Geom2dGcc_Circ2d3Tan(const Geom2dGcc_QualifiedCurve& Qualified1, const Handle(Geom2d_Point)& Point1, const Handle(Geom2d_Point)& Point2, const Standard_Real Tolerance, const Standard_Real Param1); |
98 | |
99 | //! Constructs one or more 2D circles passing through three points Point1, Point2 and Point3. |
100 | //! Tolerance is a tolerance criterion used by the algorithm |
101 | //! to find a solution when, mathematically, the problem |
102 | //! posed does not have a solution, but where there is |
103 | //! numeric uncertainty attached to the arguments. |
104 | //! For example, take: |
105 | //! - two circles C1 and C2, such that C2 is inside C1, |
106 | //! and almost tangential to C1; there is in fact no point |
107 | //! of intersection between C1 and C2; and |
108 | //! - a circle C3 outside C1. |
109 | //! You now want to find a circle which is tangential to C1, |
110 | //! C2 and C3: a pure mathematical resolution will not find |
111 | //! a solution. This is where the tolerance criterion is used: |
112 | //! the algorithm considers that C1 and C2 are tangential if |
113 | //! the shortest distance between these two circles is less |
114 | //! than or equal to Tolerance. Thus, the algorithm finds a solution. |
115 | //! Warning |
116 | //! An iterative algorithm is used if Qualified1, Qualified2 or |
117 | //! Qualified3 is more complex than a line or a circle. In |
118 | //! such cases, the algorithm constructs only one solution. |
119 | //! Exceptions |
120 | //! GccEnt_BadQualifier if a qualifier is inconsistent with |
121 | //! the argument it qualifies (for example, enclosing for a line). |
122 | Standard_EXPORT Geom2dGcc_Circ2d3Tan(const Handle(Geom2d_Point)& Point1, const Handle(Geom2d_Point)& Point2, const Handle(Geom2d_Point)& Point3, const Standard_Real Tolerance); |
123 | |
124 | Standard_EXPORT void Results (const GccAna_Circ2d3Tan& Circ, const Standard_Integer Rank1, const Standard_Integer Rank2, const Standard_Integer Rank3); |
125 | |
126 | //! Returns true if the construction algorithm does not fail (even if it finds no solution). |
127 | //! Note: IsDone protects against a failure arising from a |
128 | //! more internal intersection algorithm, which has reached its numeric limits. |
129 | Standard_EXPORT Standard_Boolean IsDone() const; |
130 | |
131 | //! This method returns the number of solutions. |
132 | //! NotDone is raised if the algorithm failed. |
133 | Standard_EXPORT Standard_Integer NbSolutions() const; |
134 | |
135 | //! Returns the solution number Index and raises OutOfRange |
136 | //! exception if Index is greater than the number of solutions. |
137 | //! Be carefull: the Index is only a way to get all the |
138 | //! solutions, but is not associated to theses outside the context |
139 | //! of the algorithm-object. |
140 | Standard_EXPORT gp_Circ2d ThisSolution (const Standard_Integer Index) const; |
141 | |
142 | //! It returns the informations about the qualifiers of the tangency |
143 | //! arguments concerning the solution number Index. |
144 | //! It returns the real qualifiers (the qualifiers given to the |
145 | //! constructor method in case of enclosed, enclosing and outside |
146 | //! and the qualifiers computedin case of unqualified). |
147 | Standard_EXPORT void WhichQualifier (const Standard_Integer Index, GccEnt_Position& Qualif1, GccEnt_Position& Qualif2, GccEnt_Position& Qualif3) const; |
148 | |
149 | //! Returns informations about the tangency point between the |
150 | //! result and the first argument. |
151 | //! ParSol is the intrinsic parameter of the point PntSol on the solution curv. |
152 | //! ParArg is the intrinsic parameter of the point PntSol on the argument curv. |
153 | Standard_EXPORT void Tangency1 (const Standard_Integer Index, Standard_Real& ParSol, Standard_Real& ParArg, gp_Pnt2d& PntSol) const; |
154 | |
155 | //! Returns informations about the tangency point between the |
156 | //! result and the second argument. |
157 | //! ParSol is the intrinsic parameter of the point PntSol on the solution curv. |
158 | //! ParArg is the intrinsic parameter of the point PntSol on the argument curv. |
159 | Standard_EXPORT void Tangency2 (const Standard_Integer Index, Standard_Real& ParSol, Standard_Real& ParArg, gp_Pnt2d& PntSol) const; |
160 | |
161 | //! Returns informations about the tangency point between the |
162 | //! result and the third argument. |
163 | //! ParSol is the intrinsic parameter of the point PntSol on the solution curv. |
164 | //! ParArg is the intrinsic parameter of the point PntSol on the argument curv. |
165 | Standard_EXPORT void Tangency3 (const Standard_Integer Index, Standard_Real& ParSol, Standard_Real& ParArg, gp_Pnt2d& PntSol) const; |
166 | |
167 | //! Returns True if the solution is equal to the first argument. |
168 | Standard_EXPORT Standard_Boolean IsTheSame1 (const Standard_Integer Index) const; |
169 | |
170 | //! Returns True if the solution is equal to the second argument. |
171 | Standard_EXPORT Standard_Boolean IsTheSame2 (const Standard_Integer Index) const; |
172 | |
173 | //! Returns True if the solution is equal to the third argument. |
174 | //! If Rarg is the radius of the first, second or third |
175 | //! argument, Rsol is the radius of the solution and dist |
176 | //! is the distance between the two centers, we consider |
177 | //! the two circles to be identical if |Rarg - Rsol| and |
178 | //! dist are less than or equal to the tolerance criterion |
179 | //! given at the time of construction of this algorithm. |
180 | //! Exceptions |
181 | //! Standard_OutOfRange if Index is less than zero or |
182 | //! greater than the number of solutions computed by this algorithm. |
183 | //! StdFail_NotDone if the construction fails. |
184 | Standard_EXPORT Standard_Boolean IsTheSame3 (const Standard_Integer Index) const; |
185 | |
186 | |
187 | |
188 | |
189 | protected: |
190 | |
191 | |
192 | |
193 | |
194 | |
195 | private: |
196 | |
197 | |
198 | |
199 | TColgp_Array1OfCirc2d cirsol; |
200 | Standard_Real NbrSol; |
201 | Standard_Boolean WellDone; |
202 | GccEnt_Array1OfPosition qualifier1; |
203 | GccEnt_Array1OfPosition qualifier2; |
204 | GccEnt_Array1OfPosition qualifier3; |
205 | TColStd_Array1OfInteger TheSame1; |
206 | TColStd_Array1OfInteger TheSame2; |
207 | TColStd_Array1OfInteger TheSame3; |
208 | TColgp_Array1OfPnt2d pnttg1sol; |
209 | TColgp_Array1OfPnt2d pnttg2sol; |
210 | TColgp_Array1OfPnt2d pnttg3sol; |
211 | TColStd_Array1OfReal par1sol; |
212 | TColStd_Array1OfReal par2sol; |
213 | TColStd_Array1OfReal par3sol; |
214 | TColStd_Array1OfReal pararg1; |
215 | TColStd_Array1OfReal pararg2; |
216 | TColStd_Array1OfReal pararg3; |
217 | |
218 | |
219 | }; |
220 | |
221 | |
222 | |
223 | |
224 | |
225 | |
226 | |
227 | #endif // _Geom2dGcc_Circ2d3Tan_HeaderFile |