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