b311480e |
1 | -- Created on: 1992-10-20 |
2 | -- Created by: Remi GILET |
3 | -- Copyright (c) 1992-1999 Matra Datavision |
4 | -- Copyright (c) 1999-2012 OPEN CASCADE SAS |
5 | -- |
6 | -- The content of this file is subject to the Open CASCADE Technology Public |
7 | -- License Version 6.5 (the "License"). You may not use the content of this file |
8 | -- except in compliance with the License. Please obtain a copy of the License |
9 | -- at http://www.opencascade.org and read it completely before using this file. |
10 | -- |
11 | -- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its |
12 | -- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. |
13 | -- |
14 | -- The Original Code and all software distributed under the License is |
15 | -- distributed on an "AS IS" basis, without warranty of any kind, and the |
16 | -- Initial Developer hereby disclaims all such warranties, including without |
17 | -- limitation, any warranties of merchantability, fitness for a particular |
18 | -- purpose or non-infringement. Please see the License for the specific terms |
19 | -- and conditions governing the rights and limitations under the License. |
20 | |
7fd59977 |
21 | |
22 | class Circ2dTanOnRad from Geom2dGcc |
23 | |
24 | ---Purpose: This class implements the algorithms used to |
25 | -- create a 2d circle tangent to a 2d entity, |
26 | -- centered on a 2d entity and with a given radius. |
27 | -- More than one argument must be a curve. |
28 | -- The arguments of all construction methods are : |
29 | -- - The qualified element for the tangency constrains |
30 | -- (QualifiedCirc, QualifiedLin, QualifiedCurvPoints). |
31 | -- - The Center element (circle, line, curve). |
32 | -- - A real Tolerance. |
33 | -- Tolerance is only used in the limits cases. |
34 | -- For example : |
35 | -- We want to create a circle tangent to an OutsideCurv Cu1 |
36 | -- centered on a line OnLine with a radius Radius and with |
37 | -- a tolerance Tolerance. |
38 | -- If we did not used Tolerance it is impossible to |
39 | -- find a solution in the the following case : OnLine is |
40 | -- outside Cu1. There is no intersection point between Cu1 |
41 | -- and OnLine. The distance between the line and the |
42 | -- circle is greater than Radius. |
43 | -- With Tolerance we will give a solution if the |
44 | -- distance between Cu1 and OnLine is lower than or |
45 | -- equal Tolerance. |
46 | |
47 | -- inherits Entity from Standard |
48 | |
49 | uses Lin2d from gp, |
50 | Circ2d from gp, |
51 | Pnt2d from gp, |
52 | Point from Geom2d, |
53 | Array1OfCirc2d from TColgp, |
54 | Array1OfPnt2d from TColgp, |
55 | Curve from Geom2dAdaptor, |
56 | QualifiedCurve from Geom2dGcc, |
57 | Array1OfReal from TColStd, |
58 | Array1OfInteger from TColStd, |
59 | Circ2dTanOnRad from GccAna, |
60 | MyCirc2dTanOnRad from Geom2dGcc, |
61 | Position from GccEnt, |
62 | Array1OfPosition from GccEnt |
63 | |
64 | raises NegativeValue from Standard, |
65 | OutOfRange from Standard, |
66 | BadQualifier from GccEnt, |
67 | NotDone from StdFail |
68 | |
69 | is |
70 | |
71 | Create(Qualified1 : QualifiedCurve from Geom2dGcc ; |
72 | OnCurv : Curve from Geom2dAdaptor; |
73 | Radius : Real from Standard ; |
74 | Tolerance : Real from Standard ) |
75 | returns Circ2dTanOnRad from Geom2dGcc |
76 | raises NegativeValue,BadQualifier; |
77 | ---Purpose: Constructs one or more 2D circles of radius Radius, |
78 | -- centered on the 2D curve OnCurv and: |
79 | -- - tangential to the curve Qualified1 |
80 | |
81 | Create(Point1 : Point from Geom2d ; |
82 | OnCurv : Curve from Geom2dAdaptor; |
83 | Radius : Real from Standard ; |
84 | Tolerance : Real from Standard ) |
85 | returns Circ2dTanOnRad from Geom2dGcc |
86 | raises NegativeValue; |
87 | ---Purpose: Constructs one or more 2D circles of radius Radius, |
88 | -- centered on the 2D curve OnCurv and: |
89 | -- passing through the point Point1. |
90 | -- OnCurv is an adapted curve, i.e. an object which is an |
91 | -- interface between: |
92 | -- - the services provided by a 2D curve from the package Geom2d, |
93 | -- - and those required on the curve by the construction algorithm. |
94 | -- Similarly, the qualified curve Qualified1 is created from |
95 | -- an adapted curve. |
96 | -- Adapted curves are created in the following way: |
97 | -- Handle(Geom2d_Curve) myCurveOn = ... ; |
98 | -- Geom2dAdaptor_Curve OnCurv ( myCurveOn ) ; |
99 | -- The algorithm is then constructed with this object: |
100 | -- Handle(Geom2d_Curve) myCurve1 = ... |
101 | -- ; |
102 | -- Geom2dAdaptor_Curve Adapted1 ( myCurve1 ) ; |
103 | -- Geom2dGcc_QualifiedCurve |
104 | -- Qualified1 = Geom2dGcc::Outside(Adapted1); |
105 | -- Standard_Real Radius = ... , Tolerance = ... ; |
106 | -- Geom2dGcc_Circ2dTanOnRad |
107 | -- myAlgo ( Qualified1 , OnCurv , Radius , Tolerance ) ; |
108 | -- if ( myAlgo.IsDone() ) |
109 | -- { Standard_Integer Nbr = myAlgo.NbSolutions() ; |
110 | -- gp_Circ2d Circ ; |
111 | -- for ( Standard_Integer i = 1 ; |
112 | -- i <= nbr ; i++ ) |
113 | -- { Circ = myAlgo.ThisSolution (i) ; |
114 | -- ... |
115 | -- } |
116 | -- } |
117 | |
118 | Results(me : in out ; |
119 | Circ : Circ2dTanOnRad from GccAna) |
120 | is static; |
121 | |
122 | Results(me : in out ; |
123 | Circ : MyCirc2dTanOnRad from Geom2dGcc) |
124 | is static; |
125 | |
126 | IsDone(me) returns Boolean from Standard |
127 | is static; |
128 | ---Purpose: Returns true if the construction algorithm does not fail |
129 | -- (even if it finds no solution). |
130 | -- Note: IsDone protects against a failure arising from a |
131 | -- more internal intersection algorithm which has reached |
132 | -- its numeric limits. |
133 | NbSolutions(me) returns Integer from Standard |
134 | raises NotDone |
135 | is static; |
136 | ---Purpose: Returns the number of circles, representing solutions |
137 | -- computed by this algorithm. |
138 | -- Exceptions: StdFail_NotDone if the construction fails. |
139 | |
140 | ThisSolution(me ; Index : Integer from Standard) returns Circ2d from gp |
141 | raises OutOfRange, NotDone |
142 | is static; |
143 | ---Purpose: Returns the solution number Index and raises OutOfRange |
144 | -- exception if Index is greater than the number of solutions. |
145 | -- Be carefull: the Index is only a way to get all the |
146 | -- solutions, but is not associated to theses outside the context |
147 | -- of the algorithm-object. |
148 | -- Exceptions |
149 | -- Standard_OutOfRange if Index is less than zero or |
150 | -- greater than the number of solutions computed by this algorithm. |
151 | -- StdFail_NotDone if the construction fails. |
152 | |
153 | WhichQualifier(me ; |
154 | Index : Integer from Standard; |
155 | Qualif1 : out Position from GccEnt ) |
156 | raises OutOfRange, NotDone |
157 | is static; |
158 | --- Purpose: Returns the qualifier Qualif1 of the tangency argument |
159 | -- for the solution of index Index computed by this algorithm. |
160 | -- The returned qualifier is: |
161 | -- - that specified at the start of construction when the |
162 | -- solutions are defined as enclosed, enclosing or |
163 | -- outside with respect to the arguments, or |
164 | -- - that computed during construction (i.e. enclosed, |
165 | -- enclosing or outside) when the solutions are defined |
166 | -- as unqualified with respect to the arguments, or |
167 | -- - GccEnt_noqualifier if the tangency argument is a point. |
168 | -- Exceptions |
169 | -- Standard_OutOfRange if Index is less than zero or |
170 | -- greater than the number of solutions computed by this algorithm. |
171 | -- StdFail_NotDone if the construction fails. |
172 | |
173 | Tangency1(me ; |
174 | Index : Integer from Standard; |
175 | ParSol,ParArg : out Real from Standard; |
176 | PntSol : out Pnt2d from gp ) |
177 | raises OutOfRange, NotDone |
178 | is static; |
179 | ---Purpose: Returns informations about the tangency point between the |
180 | -- result number Index and the first argument. |
181 | -- ParSol is the intrinsic parameter of the point on the solution curv. |
182 | -- ParArg is the intrinsic parameter of the point on the argument curv. |
183 | -- PntSol is the tangency point on the solution curv. |
184 | -- PntArg is the tangency point on the argument curv. |
185 | -- Exceptions |
186 | -- Standard_OutOfRange if Index is less than zero or |
187 | -- greater than the number of solutions computed by this algorithm. |
188 | -- StdFail_NotDone if the construction fails. |
189 | |
190 | CenterOn3 (me ; |
191 | Index : Integer from Standard; |
192 | ParArg : out Real from Standard; |
193 | PntSol : out Pnt2d from gp ) |
194 | raises OutOfRange, NotDone |
195 | is static; |
196 | ---Purpose: Returns the center PntSol on the second argument (i.e. |
197 | -- line or circle) of the solution of index Index computed by |
198 | -- this algorithm. |
199 | -- ParArg is the intrinsic parameter of the point on the argument curv. |
200 | -- PntSol is the center point of the solution curv. |
201 | -- PntArg is the projection of PntSol on the argument curv. |
202 | -- Exceptions: |
203 | -- Standard_OutOfRange if Index is less than zero or |
204 | -- greater than the number of solutions computed by this algorithm. |
205 | -- StdFail_NotDone if the construction fails. |
206 | |
207 | IsTheSame1(me ; |
208 | Index : Integer from Standard) returns Boolean from Standard |
209 | raises OutOfRange, NotDone |
210 | is static; |
211 | ---Purpose: Returns true if the solution of index Index and the first |
212 | -- argument of this algorithm are the same (i.e. there are 2 |
213 | -- identical circles). |
214 | -- If Rarg is the radius of the first argument, Rsol is the |
215 | -- radius of the solution and dist is the distance between |
216 | -- the two centers, we consider the two circles to be |
217 | -- identical if |Rarg - Rsol| and dist are less than |
218 | -- or equal to the tolerance criterion given at the time of |
219 | -- construction of this algorithm. |
220 | -- OutOfRange is raised if Index is greater than the number of solutions. |
221 | -- notDone is raised if the construction algorithm did not succeed. |
222 | |
223 | fields |
224 | |
225 | WellDone : Boolean from Standard; |
226 | -- True if the algorithm succeeded. |
227 | |
228 | NbrSol : Integer from Standard; |
229 | -- The number of possible solutions. We have to decide about the |
230 | -- status of the multiple solutions... |
231 | |
232 | cirsol : Array1OfCirc2d from TColgp; |
233 | ---Purpose : The solutions. |
234 | |
235 | qualifier1 : Array1OfPosition from GccEnt; |
236 | -- The qualifiers of the first argument. |
237 | |
238 | TheSame1 : Array1OfInteger from TColStd; |
239 | |
240 | pnttg1sol : Array1OfPnt2d from TColgp; |
241 | -- The tangency point between the solution and the first argument on |
242 | -- the solution. |
243 | |
244 | par1sol : Array1OfReal from TColStd; |
245 | -- The parameter of the tangency point between the solution and the |
246 | -- first argument on the solution. |
247 | |
248 | pararg1 : Array1OfReal from TColStd; |
249 | -- The parameter of the tangency point between the solution and the first |
250 | -- argument on the first argument. |
251 | |
252 | pntcen3 : Array1OfPnt2d from TColgp; |
253 | -- The center point of the solution on the first argument. |
254 | |
255 | parcen3 : Array1OfReal from TColStd; |
256 | -- The parameter of the center point of the solution on the second |
257 | -- argument. |
258 | |
259 | end Circ2dTanOnRad; |
260 | |
261 | |