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_Circ2d2TanRad_HeaderFile |
18 | #define _Geom2dGcc_Circ2d2TanRad_HeaderFile |
19 | |
20 | #include <Standard.hxx> |
21 | #include <Standard_DefineAlloc.hxx> |
22 | #include <Standard_Handle.hxx> |
23 | |
24 | #include <Standard_Boolean.hxx> |
25 | #include <TColgp_Array1OfCirc2d.hxx> |
26 | #include <Standard_Integer.hxx> |
27 | #include <GccEnt_Array1OfPosition.hxx> |
28 | #include <TColStd_Array1OfInteger.hxx> |
29 | #include <TColgp_Array1OfPnt2d.hxx> |
30 | #include <TColStd_Array1OfReal.hxx> |
31 | #include <Standard_Real.hxx> |
32 | #include <GccEnt_Position.hxx> |
33 | class Standard_OutOfRange; |
34 | class GccEnt_BadQualifier; |
35 | class StdFail_NotDone; |
36 | class Standard_NegativeValue; |
37 | class Geom2dGcc_QualifiedCurve; |
38 | class Geom2d_Point; |
39 | class GccAna_Circ2d2TanRad; |
40 | class Geom2dGcc_Circ2d2TanRadGeo; |
41 | class gp_Circ2d; |
42 | class gp_Pnt2d; |
43 | |
44 | |
45 | //! This class implements the algorithms used to |
46 | //! create 2d circles tangent to one curve and a |
47 | //! point/line/circle/curv and with a given radius. |
48 | //! For each construction methods arguments are: |
49 | //! - Two Qualified elements for tangency constrains. |
50 | //! (for example EnclosedCirc if we want the |
51 | //! solution inside the argument EnclosedCirc). |
52 | //! - Two Reals. One (Radius) for the radius and the |
53 | //! other (Tolerance) for the tolerance. |
54 | //! Tolerance is only used for the limit cases. |
55 | //! For example : |
56 | //! We want to create a circle inside a circle C1 and |
57 | //! inside a curve Cu2 with a radius Radius and a |
58 | //! tolerance Tolerance. |
59 | //! If we did not used Tolerance it is impossible to |
60 | //! find a solution in the the following case : Cu2 is |
61 | //! inside C1 and there is no intersection point |
62 | //! between the two elements. |
63 | //! with Tolerance we will give a solution if the |
64 | //! lowest distance between C1 and Cu2 is lower than or |
65 | //! equal Tolerance. |
66 | class Geom2dGcc_Circ2d2TanRad |
67 | { |
68 | public: |
69 | |
70 | DEFINE_STANDARD_ALLOC |
71 | |
72 | |
73 | Standard_EXPORT Geom2dGcc_Circ2d2TanRad(const Geom2dGcc_QualifiedCurve& Qualified1, const Geom2dGcc_QualifiedCurve& Qualified2, const Standard_Real Radius, const Standard_Real Tolerance); |
74 | |
75 | Standard_EXPORT Geom2dGcc_Circ2d2TanRad(const Geom2dGcc_QualifiedCurve& Qualified1, const Handle(Geom2d_Point)& Point, const Standard_Real Radius, const Standard_Real Tolerance); |
76 | |
77 | //! These constructors create one or more 2D circles of radius Radius either |
78 | //! - tangential to the 2 curves Qualified1 and Qualified2, or |
79 | //! - tangential to the curve Qualified1 and passing through the point Point, or |
80 | //! - passing through two points Point1 and Point2. |
81 | //! Tolerance is a tolerance criterion used by the algorithm |
82 | //! to find a solution when, mathematically, the problem |
83 | //! posed does not have a solution, but where there is |
84 | //! numeric uncertainty attached to the arguments. |
85 | //! For example, take two circles C1 and C2, such that C2 |
86 | //! is inside C1, and almost tangential to C1. There is, in |
87 | //! fact, no point of intersection between C1 and C2. You |
88 | //! now want to find a circle of radius R (smaller than the |
89 | //! radius of C2), which is tangential to C1 and C2, and |
90 | //! inside these two circles: a pure mathematical resolution |
91 | //! will not find a solution. This is where the tolerance |
92 | //! criterion is used: the algorithm considers that C1 and |
93 | //! C2 are tangential if the shortest distance between these |
94 | //! two circles is less than or equal to Tolerance. Thus, a |
95 | //! solution is found by the algorithm. |
96 | //! Exceptions |
97 | //! GccEnt_BadQualifier if a qualifier is inconsistent with |
98 | //! the argument it qualifies (for example, enclosing for a line). |
99 | //! Standard_NegativeValue if Radius is negative. |
100 | Standard_EXPORT Geom2dGcc_Circ2d2TanRad(const Handle(Geom2d_Point)& Point1, const Handle(Geom2d_Point)& Point2, const Standard_Real Radius, const Standard_Real Tolerance); |
101 | |
102 | Standard_EXPORT void Results (const GccAna_Circ2d2TanRad& Circ); |
103 | |
104 | Standard_EXPORT void Results (const Geom2dGcc_Circ2d2TanRadGeo& Circ); |
105 | |
106 | //! This method returns True if the algorithm succeeded. |
107 | //! Note: IsDone protects against a failure arising from a |
108 | //! more internal intersection algorithm, which has reached its numeric limits. |
109 | Standard_EXPORT Standard_Boolean IsDone() const; |
110 | |
111 | //! This method returns the number of solutions. |
112 | //! NotDone is raised if the algorithm failed. |
113 | //! Exceptions |
114 | //! StdFail_NotDone if the construction fails. |
115 | Standard_EXPORT Standard_Integer NbSolutions() const; |
116 | |
117 | //! Returns the solution number Index and raises OutOfRange |
118 | //! exception if Index is greater than the number of solutions. |
119 | //! Be carefull: the Index is only a way to get all the |
120 | //! solutions, but is not associated to theses outside the context of the algorithm-object. |
121 | //! Warning |
122 | //! This indexing simply provides a means of consulting the |
123 | //! solutions. The index values are not associated with |
124 | //! these solutions outside the context of the algorithm object. |
125 | //! Exceptions |
126 | //! Standard_OutOfRange if Index is less than zero or |
127 | //! greater than the number of solutions computed by this algorithm. |
128 | //! StdFail_NotDone if the construction fails. |
129 | Standard_EXPORT gp_Circ2d ThisSolution (const Standard_Integer Index) const; |
130 | |
131 | //! Returns the qualifiers Qualif1 and Qualif2 of the |
132 | //! tangency arguments for the solution of index Index |
133 | //! computed by this algorithm. |
134 | //! The returned qualifiers are: |
135 | //! - those specified at the start of construction when the |
136 | //! solutions are defined as enclosed, enclosing or |
137 | //! outside with respect to the arguments, or |
138 | //! - those computed during construction (i.e. enclosed, |
139 | //! enclosing or outside) when the solutions are defined |
140 | //! as unqualified with respect to the arguments, or |
141 | //! - GccEnt_noqualifier if the tangency argument is a point, or |
142 | //! - GccEnt_unqualified in certain limit cases where it |
143 | //! is impossible to qualify the solution as enclosed, enclosing or outside. |
144 | //! Exceptions |
145 | //! Standard_OutOfRange if Index is less than zero or |
146 | //! greater than the number of solutions computed by this algorithm. |
147 | //! StdFail_NotDone if the construction fails. |
148 | Standard_EXPORT void WhichQualifier (const Standard_Integer Index, GccEnt_Position& Qualif1, GccEnt_Position& Qualif2) const; |
149 | |
150 | //! Returns informations about the tangency point between the |
151 | //! result number Index and the first argument. |
152 | //! ParSol is the intrinsic parameter of the point PntSol on the solution curv. |
153 | //! ParArg is the intrinsic parameter of the point PntSol on the argument curv. |
154 | //! OutOfRange is raised if Index is greater than the number of solutions. |
155 | //! notDone is raised if the construction algorithm did not succeed. |
156 | Standard_EXPORT void Tangency1 (const Standard_Integer Index, Standard_Real& ParSol, Standard_Real& ParArg, gp_Pnt2d& PntSol) const; |
157 | |
158 | //! Returns informations about the tangency point between the |
159 | //! result number Index and the second argument. |
160 | //! ParSol is the intrinsic parameter of the point PntSol on the solution curv. |
161 | //! ParArg is the intrinsic parameter of the point PntSol on the argument curv. |
162 | //! OutOfRange is raised if Index is greater than the number of solutions. |
163 | //! notDone is raised if the construction algorithm did not succeed. |
164 | Standard_EXPORT void Tangency2 (const Standard_Integer Index, Standard_Real& ParSol, Standard_Real& ParArg, gp_Pnt2d& PntSol) const; |
165 | |
166 | //! Returns true if the solution of index Index and, |
167 | //! respectively, the first or second argument of this |
168 | //! algorithm are the same (i.e. there are 2 identical circles). |
169 | //! If Rarg is the radius of the first or second argument, |
170 | //! Rsol is the radius of the solution and dist is the |
171 | //! distance between the two centers, we consider the two |
172 | //! circles to be identical if |Rarg - Rsol| and dist |
173 | //! are less than or equal to the tolerance criterion given at |
174 | //! the time of construction of this algorithm. |
175 | //! OutOfRange is raised if Index is greater than the number of solutions. |
176 | //! notDone is raised if the construction algorithm did not succeed. |
177 | Standard_EXPORT Standard_Boolean IsTheSame1 (const Standard_Integer Index) const; |
178 | |
179 | //! Returns true if the solution of index Index and, |
180 | //! respectively, the first or second argument of this |
181 | //! algorithm are the same (i.e. there are 2 identical circles). |
182 | //! If Rarg is the radius of the first or second argument, |
183 | //! Rsol is the radius of the solution and dist is the |
184 | //! distance between the two centers, we consider the two |
185 | //! circles to be identical if |Rarg - Rsol| and dist |
186 | //! are less than or equal to the tolerance criterion given at |
187 | //! the time of construction of this algorithm. |
188 | //! OutOfRange is raised if Index is greater than the number of solutions. |
189 | //! notDone is raised if the construction algorithm did not succeed. |
190 | Standard_EXPORT Standard_Boolean IsTheSame2 (const Standard_Integer Index) const; |
191 | |
192 | |
193 | |
194 | |
195 | protected: |
196 | |
197 | |
198 | |
199 | |
200 | |
201 | private: |
202 | |
203 | |
204 | |
205 | Standard_Boolean WellDone; |
206 | TColgp_Array1OfCirc2d cirsol; |
207 | Standard_Integer NbrSol; |
208 | GccEnt_Array1OfPosition qualifier1; |
209 | GccEnt_Array1OfPosition qualifier2; |
210 | TColStd_Array1OfInteger TheSame1; |
211 | TColStd_Array1OfInteger TheSame2; |
212 | TColgp_Array1OfPnt2d pnttg1sol; |
213 | TColgp_Array1OfPnt2d pnttg2sol; |
214 | TColStd_Array1OfReal par1sol; |
215 | TColStd_Array1OfReal par2sol; |
216 | TColStd_Array1OfReal pararg1; |
217 | TColStd_Array1OfReal pararg2; |
218 | Standard_Boolean Invert; |
219 | |
220 | |
221 | }; |
222 | |
223 | |
224 | |
225 | |
226 | |
227 | |
228 | |
229 | #endif // _Geom2dGcc_Circ2d2TanRad_HeaderFile |