7fd59977 |
1 | // File : IntImpParGen_Intersector.gxx |
2 | // Created : Mon Mar 2 14:00:00 1992 |
3 | // Author : Laurent BUCHARD |
4 | // <lbr@phobox> |
5 | // Copyright: Matra Datavision 1992 |
6 | |
7 | |
8 | #include <Standard_ConstructionError.hxx> |
9 | #include <IntRes2d_Domain.hxx> |
10 | #include <IntRes2d_IntersectionPoint.hxx> |
11 | #include <IntRes2d_IntersectionSegment.hxx> |
12 | #include <IntRes2d_SequenceOfIntersectionPoint.hxx> |
13 | #include <IntRes2d_SequenceOfIntersectionSegment.hxx> |
14 | #include <IntRes2d_Transition.hxx> |
15 | #include <IntRes2d_Position.hxx> |
16 | |
17 | #include <IntImpParGen.hxx> |
18 | |
19 | #include <math_FunctionSample.hxx> |
20 | #include <math_FunctionAllRoots.hxx> |
21 | |
22 | #include <TColStd_Array1OfReal.hxx> |
23 | #include <gp.hxx> |
24 | #include <gp_Vec2d.hxx> |
25 | |
26 | //====================================================================== |
27 | #define EPSDIST Tol |
28 | #define EPSNUL TolConf |
29 | #define EPSX ParTool::EpsX(TheParCurve) |
30 | #define NB_ECHANTILLONS |
31 | |
32 | static Standard_Real PIpPI = Standard_PI+Standard_PI; |
33 | |
34 | |
35 | |
36 | //====================================================================== |
37 | void IntImpParGen_Intersector::And_Domaine_Objet1_Intersections(const ImpTool& TheImpTool, |
38 | const ParCurve& TheParCurve, |
39 | const IntRes2d_Domain& TheImpCurveDomain, |
40 | const IntRes2d_Domain& TheParCurveDomain, |
41 | Standard_Integer& NbResultats, |
42 | TColStd_Array1OfReal& Inter2_And_Domain2, |
43 | TColStd_Array1OfReal& Inter1, |
44 | TColStd_Array1OfReal& Resultat1, |
45 | TColStd_Array1OfReal& Resultat2, |
46 | const Standard_Real EpsNul) const { |
47 | |
48 | |
49 | Standard_Integer Nb_Bornes_Intersection=NbResultats; |
50 | NbResultats=0; |
51 | |
52 | for(Standard_Integer i=1; i<=Nb_Bornes_Intersection; i+=2) { |
53 | Standard_Boolean reverse=Standard_False; |
54 | |
55 | Standard_Real param1=Inter1.Value(i); |
56 | Standard_Real param2=Inter1.Value(i+1); |
57 | |
58 | Standard_Integer indice_1=i; |
59 | Standard_Integer indice_2=i+1; |
60 | |
61 | if(param1>param2) { |
62 | Standard_Real t=param1; param1=param2; param2=t; |
63 | indice_1=i+1; |
64 | indice_2=i; |
65 | reverse=Standard_True; |
66 | } |
67 | |
68 | gp_Pnt2d Pt1=TheImpTool.Value(param1); |
69 | gp_Pnt2d Pt2=TheImpTool.Value(param2); |
70 | gp_Pnt2d Pt; |
71 | |
72 | Standard_Boolean IsOnTheImpCurveDomain1=Standard_True; |
73 | Standard_Boolean IsOnABoundary1=Standard_False; |
74 | |
75 | Standard_Boolean IsOnTheImpCurveDomain2=Standard_True; |
76 | Standard_Boolean IsOnABoundary2=Standard_False; |
77 | //-------------------------------------------------------------------- |
78 | if(TheImpCurveDomain.HasFirstPoint()) { |
79 | if(param1<TheImpCurveDomain.FirstParameter()) { |
80 | if(Pt1.Distance(TheImpCurveDomain.FirstPoint()) |
81 | > TheImpCurveDomain.FirstTolerance()) { |
82 | IsOnTheImpCurveDomain1=Standard_False; |
83 | } |
84 | else { IsOnABoundary1=Standard_True; } |
85 | } |
86 | } |
87 | if(IsOnTheImpCurveDomain1 && TheImpCurveDomain.HasLastPoint()) { |
88 | if(param1>TheImpCurveDomain.LastParameter()) { |
89 | if(Pt1.Distance(TheImpCurveDomain.LastPoint()) |
90 | > TheImpCurveDomain.FirstTolerance()) { |
91 | IsOnTheImpCurveDomain1=Standard_False; |
92 | } |
93 | else { IsOnABoundary1=Standard_True; } |
94 | } |
95 | } |
96 | //-------------------------------------------------------------------- |
97 | if(TheImpCurveDomain.HasFirstPoint()) { |
98 | if(param2<TheImpCurveDomain.FirstParameter()) { |
99 | if(Pt2.Distance(TheImpCurveDomain.FirstPoint()) |
100 | > TheImpCurveDomain.FirstTolerance()) { |
101 | IsOnTheImpCurveDomain2=Standard_False; |
102 | } |
103 | else { IsOnABoundary2=Standard_True; } |
104 | } |
105 | } |
106 | if(IsOnTheImpCurveDomain2 && TheImpCurveDomain.HasLastPoint()) { |
107 | if(param2>TheImpCurveDomain.LastParameter()) { |
108 | if(Pt2.Distance(TheImpCurveDomain.LastPoint()) |
109 | > TheImpCurveDomain.FirstTolerance()) { |
110 | IsOnTheImpCurveDomain2=Standard_False; |
111 | } |
112 | else { IsOnABoundary2=Standard_True; } |
113 | } |
114 | } |
115 | |
116 | if(IsOnTheImpCurveDomain1) { |
117 | //------------------------------------------------------------------ |
118 | //--- la borne 1 est sur le domaine -- |
119 | NbResultats++; |
120 | Resultat1.SetValue(NbResultats,Inter1.Value(indice_1)); |
121 | Resultat2.SetValue(NbResultats,Inter2_And_Domain2.Value(indice_1)); |
122 | //--- la borne2 est aussi sur le domaine --- |
123 | if(IsOnTheImpCurveDomain2) { |
124 | NbResultats++; |
125 | Resultat1.SetValue(NbResultats,Inter1.Value(indice_2)); |
126 | Resultat2.SetValue(NbResultats,Inter2_And_Domain2.Value(indice_2)); |
127 | } |
128 | else { |
129 | //--- Borne1 sur domaine et Borne 2 Hors Domaine --- |
130 | Standard_Real t; |
131 | NbResultats++; |
132 | t=TheImpCurveDomain.LastParameter(); |
133 | Resultat1.SetValue(NbResultats,t); |
134 | // Standard_Real popResult = FindV(t,Pt,TheImpTool,TheParCurve, |
135 | // TheParCurveDomain, |
136 | // Inter2_And_Domain2.Value(indice_1), |
137 | // Inter2_And_Domain2.Value(indice_2), |
138 | // EpsNul); |
139 | // |
140 | // Resultat2.SetValue(NbResultats,popResult); |
141 | Resultat2.SetValue(NbResultats, |
142 | IntImpParGen_Intersector::FindV(t,Pt,TheImpTool,TheParCurve, |
143 | TheParCurveDomain, |
144 | Inter2_And_Domain2.Value(indice_1), |
145 | Inter2_And_Domain2.Value(indice_2), |
146 | EpsNul)); |
147 | } |
148 | } |
149 | else { //======= la borne1 n est pas sur le domaine ======== |
150 | if(IsOnTheImpCurveDomain2) { |
151 | Standard_Real t; |
152 | NbResultats++; |
153 | t=TheImpCurveDomain.FirstParameter(); |
154 | |
155 | Resultat1.SetValue(NbResultats,t); |
156 | Resultat2.SetValue(NbResultats, |
157 | IntImpParGen_Intersector::FindV(t,Pt,TheImpTool,TheParCurve, |
158 | TheParCurveDomain, |
159 | Inter2_And_Domain2.Value(indice_1), |
160 | Inter2_And_Domain2.Value(indice_2), |
161 | EpsNul)); |
162 | |
163 | NbResultats++; |
164 | Resultat1.SetValue(NbResultats,Inter1.Value(indice_2)); |
165 | Resultat2.SetValue(NbResultats,Inter2_And_Domain2.Value(indice_2)); |
166 | } |
167 | else { //====== la borne2 et la borne1 sont hors domaine ===== |
168 | if(param1<TheImpCurveDomain.FirstParameter() |
169 | && param2>TheImpCurveDomain.LastParameter()) { |
170 | Standard_Real t; |
171 | NbResultats++; |
172 | t=TheImpCurveDomain.FirstParameter(); |
173 | Resultat1.SetValue(NbResultats,t); |
174 | Resultat2.SetValue(NbResultats, |
175 | IntImpParGen_Intersector::FindV(t,Pt,TheImpTool,TheParCurve, |
176 | TheParCurveDomain, |
177 | Inter2_And_Domain2.Value(indice_1), |
178 | Inter2_And_Domain2.Value(indice_2), |
179 | EpsNul)); |
180 | |
181 | |
182 | |
183 | NbResultats++; |
184 | t=TheImpCurveDomain.LastParameter(); |
185 | Resultat1.SetValue(NbResultats,t); |
186 | Resultat2.SetValue(NbResultats, |
187 | IntImpParGen_Intersector::FindV(t,Pt,TheImpTool,TheParCurve, |
188 | TheParCurveDomain, |
189 | Inter2_And_Domain2.Value(indice_1), |
190 | Inter2_And_Domain2.Value(indice_2), |
191 | EpsNul)); |
192 | |
193 | } |
194 | } |
195 | } |
196 | } |
197 | } |
198 | //====================================================================== |
199 | //-- C o n s t r u c t e u r s e t P e r f o r m |
200 | IntImpParGen_Intersector::IntImpParGen_Intersector() { |
201 | done=Standard_False; |
202 | } |
203 | //---------------------------------------------------------------------- |
204 | //-- |
205 | IntImpParGen_Intersector::IntImpParGen_Intersector(const ImpTool& TheImpTool, |
206 | const IntRes2d_Domain& TheImpCurveDomain, |
207 | const ParCurve& TheParCurve, |
208 | const IntRes2d_Domain& TheParCurveDomain, |
209 | const Standard_Real TolConf, |
210 | const Standard_Real Tol) { |
211 | Perform(TheImpTool,TheImpCurveDomain,TheParCurve,TheParCurveDomain,TolConf,Tol); |
212 | } |
213 | //---------------------------------------------------------------------- |
214 | //-- |
215 | void IntImpParGen_Intersector::Perform(const ImpTool& TheImpTool, |
216 | const IntRes2d_Domain& TheImpCurveDomain, |
217 | const ParCurve& TheParCurve, |
218 | const IntRes2d_Domain& TheParCurveDomain, |
219 | const Standard_Real TolConf, |
220 | const Standard_Real Tol) { |
221 | |
222 | |
223 | Standard_Integer i,nb_segments_solution, nb_points_solution; |
224 | Standard_Real param1,param2,EpsX, EpsNul, EpsDist; |
225 | |
226 | IntRes2d_Transition Trans1,Trans2; |
227 | gp_Pnt2d pt1,pt2; |
228 | gp_Vec2d Tan1,Tan2,Norm1,Norm2; |
229 | IntRes2d_Position Pos1,Pos2; |
230 | |
231 | |
232 | //---------------------------------------------- |
233 | //-- On teste apres appel aux maths si les bornes |
234 | //-- des domaines sont des solutions |
235 | //-- |
236 | Standard_Boolean HeadOnImp =Standard_False; |
237 | Standard_Boolean HeadOnPar =Standard_False; |
238 | Standard_Boolean EndOnImp =Standard_False; |
239 | Standard_Boolean EndOnPar =Standard_False; |
240 | |
241 | this->ResetFields(); |
242 | |
243 | IntImpParGen_MyImpParTool TheImpParTool(TheImpTool,TheParCurve); |
244 | |
245 | if (! (TheParCurveDomain.HasFirstPoint() && |
246 | TheParCurveDomain.HasLastPoint())) { |
247 | Standard_ConstructionError::Raise("Domaine sur courbe incorrect"); |
248 | } |
249 | |
250 | Standard_Integer nb_echantillons = ParTool::NbSamples(TheParCurve, |
251 | TheParCurveDomain.FirstParameter(), |
252 | TheParCurveDomain.LastParameter()); |
253 | |
254 | EpsX = EPSX; |
255 | if(EpsX>1.0e-10) EpsX = 1.0e-10; |
256 | EpsNul=(TolConf<=1.0e-10)? 1.0e-10: TolConf; |
257 | EpsDist=(Tol<=1.0e-10)? 1.0e-10: Tol; |
258 | |
259 | Standard_Real Tolerance_Angulaire=EpsDist; |
260 | |
261 | |
262 | |
263 | if((TheParCurveDomain.LastParameter() - TheParCurveDomain.FirstParameter()) < 100.0*EpsX) { |
264 | EpsX = (TheParCurveDomain.LastParameter() - TheParCurveDomain.FirstParameter())*0.01; |
265 | } |
266 | |
267 | math_FunctionSample Sample2(TheParCurveDomain.FirstParameter(), |
268 | TheParCurveDomain.LastParameter(), |
269 | nb_echantillons); |
270 | |
271 | math_FunctionAllRoots Sol(TheImpParTool, |
272 | Sample2, |
273 | EpsX, |
274 | EpsDist, |
275 | EpsNul); |
276 | |
277 | if(!Sol.IsDone()) {done = Standard_False; return; } |
278 | |
279 | nb_segments_solution=Sol.NbIntervals(); |
280 | nb_points_solution=Sol.NbPoints(); |
281 | |
282 | //-------------------------------------------------------------------- |
283 | //-- T r a i t e m e n t d e s P o i n t s S o l u t i o n s |
284 | for(i=1; i<=nb_points_solution; i++) { |
285 | gp_Pnt2d Pt; |
286 | param2=Sol.GetPoint(i); |
287 | param1=FindU(param2,Pt,TheParCurve,TheImpTool); |
288 | |
289 | if(TheImpCurveDomain.IsClosed()) { |
290 | param1 = IntImpParGen::NormalizeOnDomain( param1 |
291 | ,TheImpCurveDomain); |
292 | } |
293 | |
294 | Standard_Boolean IsOnTheImpCurveDomain=Standard_True; |
295 | if(TheImpCurveDomain.HasFirstPoint()) { |
296 | if(param1<TheImpCurveDomain.FirstParameter()) { |
297 | if(Pt.Distance(TheImpCurveDomain.FirstPoint()) |
298 | > TheImpCurveDomain.FirstTolerance()) { |
299 | IsOnTheImpCurveDomain=Standard_False; |
300 | } |
301 | } |
302 | } |
303 | if(IsOnTheImpCurveDomain && TheImpCurveDomain.HasLastPoint()) { |
304 | if(param1>TheImpCurveDomain.LastParameter()) { |
305 | if(Pt.Distance(TheImpCurveDomain.LastPoint()) |
306 | > TheImpCurveDomain.FirstTolerance()) { |
307 | IsOnTheImpCurveDomain=Standard_False; |
308 | } |
309 | } |
310 | } |
311 | |
312 | if(IsOnTheImpCurveDomain) { |
313 | TheImpTool.D2(param1,pt1,Tan1,Norm1); |
314 | ParTool::D2(TheParCurve,param2,pt2,Tan2,Norm2); |
315 | |
316 | IntImpParGen::DeterminePosition(Pos1,TheImpCurveDomain,pt1,param1); |
317 | IntImpParGen::DeterminePosition(Pos2,TheParCurveDomain,pt2,param2); |
318 | |
319 | if(Pos1==IntRes2d_End) EndOnImp = Standard_True; |
320 | else if(Pos1==IntRes2d_Head) HeadOnImp = Standard_True; |
321 | if(Pos2==IntRes2d_End) EndOnPar = Standard_True; |
322 | else if(Pos2==IntRes2d_Head) HeadOnPar = Standard_True; |
323 | |
324 | IntImpParGen::DetermineTransition(Pos1,Tan1,Norm1,Trans1, |
325 | Pos2,Tan2,Norm2,Trans2, |
326 | Tolerance_Angulaire); |
327 | |
328 | IntRes2d_IntersectionPoint IP(pt1,param1,param2 |
329 | ,Trans1,Trans2 |
330 | ,ReversedParameters()); |
331 | Insert(IP); |
332 | } |
333 | } |
334 | //-- F i n d u T r a i t e m e n t d e s P t s S o l. |
335 | |
336 | |
337 | //-------------------------------------------------------------------- |
338 | //-- T r a i t e m e n t D e s S e g m e n t s --- |
339 | //-------------------------------------------------------------------- |
340 | //-- On a N segments solution sur le domaine de V soit au pire : |
341 | //-- --> N segments solution sur le domaine de U |
342 | //-- -->2N segments si la courbe en U est fermee |
343 | //-- |
344 | |
345 | TColStd_Array1OfReal Inter2_and_Domaine2(1,2+8*nb_segments_solution); |
346 | TColStd_Array1OfReal Inter1(1,2+8*nb_segments_solution); |
347 | |
348 | Standard_Integer nb_segments_crees=0; |
349 | |
350 | for (Standard_Integer j2=1,j=1;j<=nb_segments_solution;j++,j2+=2) { |
351 | Standard_Real param2_inf,param2_sup; |
352 | Standard_Real param1_inf,param1_sup; |
353 | gp_Pnt2d Ptemp; |
354 | |
355 | Sol.GetInterval(j,param2_inf,param2_sup); |
356 | param1_inf=FindU(param2_inf,Ptemp,TheParCurve,TheImpTool); |
357 | param1_sup=FindU(param2_sup,Ptemp,TheParCurve,TheImpTool); |
358 | |
359 | //---------------------------------------------------------------------- |
360 | //-- C o u r b e I m p l i c i t e F e r m e e |
361 | |
362 | if(TheImpCurveDomain.IsClosed()) { |
363 | |
364 | gp_Pnt2d Ptemp; |
365 | gp_Vec2d T1,T2,N1,N2; |
366 | Standard_Real param1_origine,param1_fin; |
367 | |
368 | TheImpCurveDomain.EquivalentParameters(param1_origine,param1_fin); |
369 | Standard_Real Periode=param1_fin-param1_origine; |
370 | |
371 | while(param1_inf<param1_origine) { param1_inf+=Periode; } |
372 | while(param1_sup<param1_origine) { param1_sup+=Periode; } |
373 | |
374 | ParTool::D2(TheParCurve,param2_inf,Ptemp,T2,N2); |
375 | TheImpTool.D2(param1_inf,Ptemp,T1,N1); |
376 | if(T1.Magnitude()<=gp::Resolution()) T1=N1; |
377 | if(T2.Magnitude()<=gp::Resolution()) T2=N2; |
378 | |
379 | if(T1.Dot(T2) >=0.0) { |
380 | //--- param1_inf designe un point entrant (et T1 est vers la matiere) |
381 | if(param1_inf>=param1_sup) { param1_sup+=Periode; } |
382 | } |
383 | else { //--- param1_inf : point sortant (et T1 est Hors matiere) |
384 | if(param1_inf<=param1_sup) { param1_inf+=Periode; } |
385 | } |
386 | //--- On cree un nouveau segment decale de Periode |
387 | //-- Exemple de Pb : Domaine PI/4 PI/2 et intervalle 0,PI |
388 | //-- Domaine 1.5PI 2.5PI et intervalle 0,PI |
389 | //-- -2pi 0 2pi |
390 | //-- ------|--------------------|-----------------|----------- |
391 | //-- [----------------------------] Domaine |
392 | //-- [~~~~~~~~~~~~~~~~~] Inters. |
393 | //-- |
394 | //-- On cree un nouvel intervalle |
395 | //-- interv decale |
396 | //-- [a~~~~~~~~~~~~b] [a~~~~~~~~~~~~~~~b] et [a~~~] |
397 | //-- |
398 | // |
399 | |
400 | if(TheImpCurveDomain.LastParameter() |
401 | > ((param1_inf>param1_sup)? (param1_sup+Periode): |
402 | (param1_inf+Periode))) { |
403 | Inter2_and_Domaine2.SetValue(j2,param2_inf); |
404 | Inter1.SetValue(j2,param1_inf+Periode); |
405 | |
406 | Inter2_and_Domaine2.SetValue(j2+1,param2_sup); |
407 | Inter1.SetValue(j2+1,param1_sup+Periode); |
408 | j2+=2; |
409 | nb_segments_crees++; |
410 | } |
411 | |
412 | if(TheImpCurveDomain.FirstParameter() |
413 | <((param1_inf<param1_sup)? (param1_sup-Periode): (param1_inf-Periode))) { |
414 | Inter2_and_Domaine2.SetValue(j2,param2_inf); |
415 | Inter1.SetValue(j2,param1_inf-Periode); |
416 | |
417 | Inter2_and_Domaine2.SetValue(j2+1,param2_sup); |
418 | Inter1.SetValue(j2+1,param1_sup-Periode); |
419 | j2+=2; |
420 | nb_segments_crees++; |
421 | } |
422 | } |
423 | //-- F i n C o u r b e I m p l i c i t e F e r m e e |
424 | //---------------------------------------------------------------------- |
425 | |
426 | |
427 | Inter2_and_Domaine2.SetValue(j2,param2_inf); |
428 | Inter1.SetValue(j2,param1_inf); |
429 | |
430 | Inter2_and_Domaine2.SetValue(j2+1,param2_sup); |
431 | Inter1.SetValue(j2+1,param1_sup); |
432 | } |
433 | |
434 | //------------------------------------------------------------------ |
435 | //-- INTER2_DOMAINE2 : Intersection AND CurveDomain : Function of PARAM2 |
436 | //-- INTER1 : Intersection AND CurveDomain : Function of PARAM1 |
437 | //------------------------------------------------------------------ |
438 | //-- |
439 | TColStd_Array1OfReal Resultat1(1,2+(1+nb_segments_solution)*2); |
440 | TColStd_Array1OfReal Resultat2(1,2+(1+nb_segments_solution)*2); |
441 | nb_segments_solution+=nb_segments_crees; |
442 | Standard_Integer NbResultats=nb_segments_solution*2; |
443 | |
444 | And_Domaine_Objet1_Intersections(TheImpTool, |
445 | TheParCurve, |
446 | TheImpCurveDomain, |
447 | TheParCurveDomain, |
448 | NbResultats, |
449 | Inter2_and_Domaine2,Inter1, |
450 | Resultat1,Resultat2,EpsNul); |
451 | |
452 | //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
453 | //Calcule_Toutes_Transitions(NbResultats, |
454 | // Resultat1,Resultat2, |
455 | // TheImpTool, |
456 | // TheImpCurveDomain, |
457 | // TheParCurve, |
458 | // TheParCurveDomain); |
459 | //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
460 | //~~~ Fonction Calcule_Toutes_Transitions Repportee ici pour cause ~~~~~ |
461 | //~~~~~ D acces aux methodes Protected APPEND |
462 | //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
463 | { |
464 | IntRes2d_Position Pos1,Pos2; |
465 | IntRes2d_Transition Trans1,Trans2; |
466 | gp_Vec2d Tan1,Tan2,Norm1,Norm2; |
467 | gp_Pnt2d Pt1_on1,Pt2_on1,Pt1_on2,Pt2_on2; |
468 | Standard_Real Param1_on1,Param2_on1,Param1_on2,Param2_on2; |
469 | |
470 | Standard_Real Dist_Mini_ImpCurve=EPSNUL; |
471 | Standard_Real Tolerance_Angulaire=Dist_Mini_ImpCurve; |
472 | |
473 | |
474 | for(Standard_Integer i=1; i<=NbResultats ; i+=2) { |
475 | Standard_Integer ip1=i+1; |
476 | Standard_Boolean OnlyOnePoint=Standard_False; |
477 | |
478 | Param1_on1=Resultat1.Value(i); |
479 | Param1_on2=Resultat2.Value(i); |
480 | Param2_on1=Resultat1.Value(ip1); |
481 | Param2_on2=Resultat2.Value(ip1); |
482 | |
483 | Pt1_on1=TheImpTool.Value(Param1_on1); |
484 | Pt2_on1=TheImpTool.Value(Param2_on1); |
485 | Pt1_on2=ParTool::Value(TheParCurve,Param1_on2); |
486 | Pt2_on2=ParTool::Value(TheParCurve,Param2_on2); |
487 | |
488 | if(!TheImpCurveDomain.IsClosed()) { |
489 | if( Pt1_on1.Distance(Pt2_on1) <= Dist_Mini_ImpCurve ) { |
490 | if( Pt1_on2.Distance(Pt2_on2) <= Dist_Mini_ImpCurve ) { |
491 | OnlyOnePoint=Standard_True; |
492 | } |
493 | } |
494 | } |
495 | |
496 | Param1_on1=IntImpParGen::NormalizeOnDomain(Param1_on1,TheImpCurveDomain); |
497 | Param1_on2=IntImpParGen::NormalizeOnDomain(Param1_on2,TheParCurveDomain); |
498 | |
499 | TheImpTool.D2(Param1_on1,Pt1_on1,Tan1,Norm1); |
500 | ParTool::D2(TheParCurve,Param1_on2,Pt1_on2,Tan2,Norm2); |
501 | |
502 | IntImpParGen::DeterminePosition(Pos1,TheImpCurveDomain,Pt1_on1,Param1_on1); |
503 | IntImpParGen::DeterminePosition(Pos2,TheParCurveDomain,Pt1_on2,Param1_on2); |
504 | |
505 | if(Pos1==IntRes2d_End) EndOnImp = Standard_True; |
506 | else if(Pos1==IntRes2d_Head) HeadOnImp = Standard_True; |
507 | if(Pos2==IntRes2d_End) EndOnPar = Standard_True; |
508 | else if(Pos2==IntRes2d_Head) HeadOnPar = Standard_True; |
509 | |
510 | |
511 | IntImpParGen::DetermineTransition(Pos1,Tan1,Norm1,Trans1, |
512 | Pos2,Tan2,Norm2,Trans2, |
513 | Tolerance_Angulaire); |
514 | |
515 | //============== Detection du cas : L intersection est en bout |
516 | //============== sur les 2 domaines |
517 | |
518 | if(Pos1!=IntRes2d_Middle && Pos2!=IntRes2d_Middle) { |
519 | Standard_Real m=0.5*(Pt1_on1.X() + Pt1_on2.X()); |
520 | Pt1_on1.SetX(m); |
521 | m=0.5*(Pt1_on1.Y() + Pt1_on2.Y()); |
522 | Pt1_on1.SetY(m); |
523 | } |
524 | |
525 | IntRes2d_IntersectionPoint new_p1(Pt1_on1 |
526 | ,Param1_on1,Param1_on2 |
527 | ,Trans1,Trans2 |
528 | ,ReversedParameters()); |
529 | if(!OnlyOnePoint) { |
530 | IntRes2d_IntersectionPoint new_p2; |
531 | |
532 | Param2_on1=IntImpParGen::NormalizeOnDomain(Param2_on1,TheImpCurveDomain); |
533 | Param2_on2=IntImpParGen::NormalizeOnDomain(Param2_on2,TheParCurveDomain); |
534 | |
535 | TheImpTool.D2(Param2_on1,Pt2_on1,Tan1,Norm1); |
536 | ParTool::D2(TheParCurve,Param2_on2,Pt2_on2,Tan2,Norm2); |
537 | |
538 | IntImpParGen::DeterminePosition(Pos1,TheImpCurveDomain,Pt2_on1,Param2_on1); |
539 | IntImpParGen::DeterminePosition(Pos2,TheParCurveDomain,Pt2_on2,Param2_on2); |
540 | |
541 | if(Pos1==IntRes2d_End) EndOnImp = Standard_True; |
542 | else if(Pos1==IntRes2d_Head) HeadOnImp = Standard_True; |
543 | if(Pos2==IntRes2d_End) EndOnPar = Standard_True; |
544 | else if(Pos2==IntRes2d_Head) HeadOnPar = Standard_True; |
545 | |
546 | IntImpParGen::DetermineTransition(Pos1,Tan1,Norm1,Trans1, |
547 | Pos2,Tan2,Norm2,Trans2, |
548 | Tolerance_Angulaire); |
549 | |
550 | |
551 | //============== Detection du cas : L intersection est en bout |
552 | //============== sur les 2 domaines |
553 | |
554 | if(Pos1!=IntRes2d_Middle && Pos2!=IntRes2d_Middle) { |
555 | Standard_Real m=0.5*(Pt2_on1.X() + Pt2_on2.X() ); |
556 | Pt2_on1.SetX(m); |
557 | m=0.5*(Pt2_on1.Y() + Pt2_on2.Y()); |
558 | Pt2_on1.SetY(m); |
559 | } |
560 | |
561 | new_p2.SetValues(Pt2_on1,Param2_on1,Param2_on2 |
562 | ,Trans1,Trans2 |
563 | ,ReversedParameters()); |
564 | |
565 | Standard_Boolean segopposite=((Tan1.Dot(Tan2) < 0.0)? |
566 | Standard_True : Standard_False); |
567 | |
568 | IntRes2d_IntersectionSegment new_seg(new_p1,new_p2 |
569 | ,segopposite |
570 | ,ReversedParameters()); |
571 | Append(new_seg); |
572 | } |
573 | else { |
574 | Insert(new_p1); |
575 | } |
576 | } |
577 | } //~~~~~~~~~~~~ Fin du corps de la fonction Calc...Transitions~~~~~~~~~~ |
578 | |
579 | //------------------------------------------- |
580 | //-- On teste les points en bouts solutions |
581 | //-- |
582 | if(!HeadOnImp && TheImpCurveDomain.HasFirstPoint()) { |
583 | if(!HeadOnPar) { |
584 | if(TheImpCurveDomain.FirstPoint().Distance(TheParCurveDomain.FirstPoint()) |
585 | <= Max(TheImpCurveDomain.FirstTolerance(),TheParCurveDomain.FirstTolerance())) { |
586 | param1 = TheImpCurveDomain.FirstParameter(); |
587 | param2 = TheParCurveDomain.FirstParameter(); |
588 | TheImpTool.D2(param1,pt1,Tan1,Norm1); |
589 | ParTool::D2(TheParCurve,param2,pt2,Tan2,Norm2); |
590 | IntImpParGen::DetermineTransition(IntRes2d_Head,Tan1,Norm1,Trans1, |
591 | IntRes2d_Head,Tan2,Norm2,Trans2, |
592 | Tolerance_Angulaire); |
593 | IntRes2d_IntersectionPoint IP(TheImpCurveDomain.FirstPoint(), |
594 | param1,param2, |
595 | Trans1,Trans2, |
596 | ReversedParameters()); |
597 | Insert(IP); |
598 | } |
599 | } |
600 | if(!EndOnPar) { |
601 | if(TheImpCurveDomain.FirstPoint().Distance(TheParCurveDomain.LastPoint()) |
602 | <= Max(TheImpCurveDomain.FirstTolerance(),TheParCurveDomain.LastTolerance())) { |
603 | param1 = TheImpCurveDomain.FirstParameter(); |
604 | param2 = TheParCurveDomain.LastParameter(); |
605 | TheImpTool.D2(param1,pt1,Tan1,Norm1); |
606 | ParTool::D2(TheParCurve,param2,pt2,Tan2,Norm2); |
607 | IntImpParGen::DetermineTransition(IntRes2d_Head,Tan1,Norm1,Trans1, |
608 | IntRes2d_End ,Tan2,Norm2,Trans2, |
609 | Tolerance_Angulaire); |
610 | IntRes2d_IntersectionPoint IP(TheImpCurveDomain.FirstPoint(), |
611 | param1,param2, |
612 | Trans1,Trans2, |
613 | ReversedParameters()); |
614 | Insert(IP); |
615 | } |
616 | } |
617 | } |
618 | |
619 | if(!EndOnImp && TheImpCurveDomain.HasLastPoint()) { |
620 | if(!HeadOnPar) { |
621 | if(TheImpCurveDomain.LastPoint().Distance(TheParCurveDomain.FirstPoint()) |
622 | <= Max(TheImpCurveDomain.LastTolerance(),TheParCurveDomain.FirstTolerance())) { |
623 | param1 = TheImpCurveDomain.LastParameter(); |
624 | param2 = TheParCurveDomain.FirstParameter(); |
625 | TheImpTool.D2(param1,pt1,Tan1,Norm1); |
626 | ParTool::D2(TheParCurve,param2,pt2,Tan2,Norm2); |
627 | IntImpParGen::DetermineTransition(IntRes2d_End,Tan1,Norm1,Trans1, |
628 | IntRes2d_Head,Tan2,Norm2,Trans2, |
629 | Tolerance_Angulaire); |
630 | IntRes2d_IntersectionPoint IP(TheImpCurveDomain.LastPoint(), |
631 | param1,param2, |
632 | Trans1,Trans2, |
633 | ReversedParameters()); |
634 | Insert(IP); |
635 | } |
636 | } |
637 | if(!EndOnPar) { |
638 | if(TheImpCurveDomain.LastPoint().Distance(TheParCurveDomain.LastPoint()) |
639 | <= Max(TheImpCurveDomain.LastTolerance(),TheParCurveDomain.LastTolerance())) { |
640 | param1 = TheImpCurveDomain.LastParameter(); |
641 | param2 = TheParCurveDomain.LastParameter(); |
642 | TheImpTool.D2(param1,pt1,Tan1,Norm1); |
643 | ParTool::D2(TheParCurve,param2,pt2,Tan2,Norm2); |
644 | IntImpParGen::DetermineTransition(IntRes2d_End,Tan1,Norm1,Trans1, |
645 | IntRes2d_End,Tan2,Norm2,Trans2, |
646 | Tolerance_Angulaire); |
647 | IntRes2d_IntersectionPoint IP(TheImpCurveDomain.LastPoint(), |
648 | param1,param2, |
649 | Trans1,Trans2, |
650 | ReversedParameters()); |
651 | Insert(IP); |
652 | } |
653 | } |
654 | } |
655 | done=Standard_True; |
656 | } |
657 | |
658 | |
659 | |
660 | |
661 | |
662 | |
663 | Standard_Real IntImpParGen_Intersector::FindU(const Standard_Real parameter |
664 | ,gp_Pnt2d& point |
665 | ,const ParCurve& TheParCurve |
666 | ,const ImpTool& TheImpTool) const |
667 | { |
668 | point=ParTool::Value(TheParCurve,parameter); |
669 | return(TheImpTool.FindParameter(point)); |
670 | } |
671 | |
672 | Standard_Real IntImpParGen_Intersector::FindV(const Standard_Real parameter |
673 | ,gp_Pnt2d& point |
674 | ,const ImpTool& TheImpTool |
675 | ,const ParCurve& TheParCurve |
676 | ,const IntRes2d_Domain& TheParCurveDomain |
677 | ,const Standard_Real V0 |
678 | ,const Standard_Real V1 |
679 | ,const Standard_Real Tolerance) const |
680 | { |
681 | point=TheImpTool.Value(parameter); |
682 | if(TheParCurveDomain.IsClosed()) { |
683 | Standard_Real V = ProjectOnPCurveTool::FindParameter(TheParCurve, |
684 | point, |
685 | Tolerance); |
686 | return(IntImpParGen::NormalizeOnDomain(V,TheParCurveDomain)); |
687 | } |
688 | else { |
689 | Standard_Real VV0 = V0; |
690 | Standard_Real VV1 = V1; |
691 | if(V1<V0) { VV0 = V1; VV1 = V0; } |
692 | //-- ?????????????????????????????????????????????????????????????????????? |
693 | //-- Modif le 15 Septembre 1992 : On Teste le parametre retourne |
694 | //--?????????????????????????????????????????????????????????????????????? |
695 | Standard_Real X = ProjectOnPCurveTool::FindParameter(TheParCurve, |
696 | point, |
697 | VV0,VV1,Tolerance); |
698 | if(X>VV1) X=VV1; else if(X<VV0) X=VV0; |
699 | return(X); |
700 | } |
701 | } |