Commit | Line | Data |
---|---|---|
b311480e | 1 | // Created on: 1992-04-06 |
2 | // Created by: Jacques GOUSSARD | |
3 | // Copyright (c) 1992-1999 Matra Datavision | |
973c2be1 | 4 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
b311480e | 5 | // |
973c2be1 | 6 | // This file is part of Open CASCADE Technology software library. |
b311480e | 7 | // |
d5f74e42 | 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 | |
973c2be1 | 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. | |
b311480e | 13 | // |
973c2be1 | 14 | // Alternatively, this file may be used under the terms of Open CASCADE |
15 | // commercial license or contractual agreement. | |
7fd59977 | 16 | |
42cf5bc1 | 17 | |
18 | #include <gp_Circ.hxx> | |
19 | #include <gp_Elips.hxx> | |
20 | #include <gp_Hypr.hxx> | |
21 | #include <gp_Lin.hxx> | |
22 | #include <gp_Parab.hxx> | |
23 | #include <IntPatch_GLine.hxx> | |
24 | #include <IntPatch_Point.hxx> | |
25 | #include <Standard_DomainError.hxx> | |
26 | #include <Standard_OutOfRange.hxx> | |
27 | #include <Standard_Type.hxx> | |
7fd59977 | 28 | |
92efcf78 | 29 | IMPLEMENT_STANDARD_RTTIEXT(IntPatch_GLine,IntPatch_Line) |
30 | ||
7fd59977 | 31 | #define DEBUG 0 |
32 | ||
33 | // modified by Edward AGAPOV (eap) Wed Mar 6 2002 (bug occ212) | |
34 | // -- case: points with equal params == PI/2 | |
b311480e | 35 | |
7fd59977 | 36 | //-- Precision::PConfusion()*1000.0 -> 1e-6 |
37 | //#define PrecisionPConfusion ( Precision::PConfusion()*1000.0 ) | |
38 | ||
39 | #include <gp_Pln.hxx> | |
40 | ||
41 | //======================================================================= | |
42 | //function : IntPatch_GLine | |
43 | //purpose : Creates a Line as intersection line | |
44 | // when the transitions are In or Out. | |
45 | //======================================================================= | |
46 | ||
47 | IntPatch_GLine::IntPatch_GLine (const gp_Lin& L, | |
48 | const Standard_Boolean Tang, | |
49 | const IntSurf_TypeTrans Trans1, | |
50 | const IntSurf_TypeTrans Trans2) : | |
51 | IntPatch_Line(Tang,Trans1,Trans2), | |
52 | par1(0.0), par2(0.0), | |
53 | fipt(Standard_False),lapt(Standard_False), | |
54 | indf(0), indl(0) | |
55 | { | |
56 | typ = IntPatch_Lin; | |
57 | pos = gp_Pln(L.Location(),L.Direction()).Position().Ax2(); | |
58 | } | |
59 | ||
60 | //======================================================================= | |
61 | //function : IntPatch_GLine | |
62 | //purpose : Creates a Line as intersection line | |
63 | // when the transitions are Touch. | |
64 | //======================================================================= | |
65 | ||
66 | IntPatch_GLine::IntPatch_GLine (const gp_Lin& L, | |
67 | const Standard_Boolean Tang, | |
68 | const IntSurf_Situation Situ1, | |
69 | const IntSurf_Situation Situ2) : | |
70 | IntPatch_Line(Tang,Situ1,Situ2), | |
71 | par1(0.0), par2(0.0), | |
72 | fipt(Standard_False),lapt(Standard_False), | |
73 | indf(0), indl(0) | |
74 | { | |
75 | typ = IntPatch_Lin; | |
76 | pos = gp_Pln(L.Location(),L.Direction()).Position().Ax2(); | |
77 | } | |
78 | ||
79 | //======================================================================= | |
80 | //function : IntPatch_GLine | |
81 | //purpose : Creates a Line as intersection line | |
82 | // when the transitions are Undecided. | |
83 | //======================================================================= | |
84 | ||
85 | IntPatch_GLine::IntPatch_GLine (const gp_Lin& L, | |
86 | const Standard_Boolean Tang) : | |
87 | IntPatch_Line(Tang), | |
88 | par1(0.0), par2(0.0), | |
89 | fipt(Standard_False),lapt(Standard_False), | |
90 | indf(0), indl(0) | |
91 | { | |
92 | typ = IntPatch_Lin; | |
93 | pos = gp_Pln(L.Location(),L.Direction()).Position().Ax2(); | |
94 | } | |
95 | ||
96 | //======================================================================= | |
97 | //function : IntPatch_GLine | |
98 | //purpose : Creates a circle as intersection line | |
99 | // when the transitions are In or Out. | |
100 | //======================================================================= | |
101 | ||
102 | IntPatch_GLine::IntPatch_GLine (const gp_Circ& C, | |
103 | const Standard_Boolean Tang, | |
104 | const IntSurf_TypeTrans Trans1, | |
105 | const IntSurf_TypeTrans Trans2) : | |
106 | IntPatch_Line(Tang,Trans1,Trans2), | |
107 | pos(C.Position()), | |
108 | par1(C.Radius()), par2(0.0), | |
109 | fipt(Standard_False),lapt(Standard_False), | |
110 | indf(0), indl(0) | |
111 | { | |
112 | typ = IntPatch_Circle; | |
113 | } | |
114 | ||
115 | //======================================================================= | |
116 | //function : IntPatch_GLine | |
117 | //purpose : Creates a circle as intersection line | |
118 | // when the transitions are Touch. | |
119 | //======================================================================= | |
120 | ||
121 | IntPatch_GLine::IntPatch_GLine (const gp_Circ& C, | |
122 | const Standard_Boolean Tang, | |
123 | const IntSurf_Situation Situ1, | |
124 | const IntSurf_Situation Situ2) : | |
125 | IntPatch_Line(Tang,Situ1,Situ2), | |
126 | pos(C.Position()), | |
127 | par1(C.Radius()), par2(0.0), | |
128 | fipt(Standard_False),lapt(Standard_False), | |
129 | indf(0), indl(0) | |
130 | { | |
131 | typ = IntPatch_Circle; | |
132 | } | |
133 | ||
134 | //======================================================================= | |
135 | //function : IntPatch_GLine | |
136 | //purpose : Creates a circle as intersection line | |
137 | // when the transitions are Undecided. | |
138 | //======================================================================= | |
139 | ||
140 | IntPatch_GLine::IntPatch_GLine (const gp_Circ& C, | |
141 | const Standard_Boolean Tang) : | |
142 | IntPatch_Line(Tang), | |
143 | pos(C.Position()), | |
144 | par1(C.Radius()), par2(0.0), | |
145 | fipt(Standard_False),lapt(Standard_False), | |
146 | indf(0), indl(0) | |
147 | { | |
148 | typ = IntPatch_Circle; | |
149 | } | |
150 | ||
151 | //======================================================================= | |
152 | //function : IntPatch_GLine | |
153 | //purpose : Creates an ellipse as intersection line | |
154 | // when the transitions are In or Out. | |
155 | //======================================================================= | |
156 | ||
157 | IntPatch_GLine::IntPatch_GLine (const gp_Elips& E, | |
158 | const Standard_Boolean Tang, | |
159 | const IntSurf_TypeTrans Trans1, | |
160 | const IntSurf_TypeTrans Trans2) : | |
161 | IntPatch_Line(Tang,Trans1,Trans2), | |
162 | pos(E.Position()), | |
163 | par1(E.MajorRadius()), | |
164 | par2(E.MinorRadius()), | |
165 | fipt(Standard_False),lapt(Standard_False), | |
166 | indf(0), indl(0) | |
167 | { | |
168 | typ = IntPatch_Ellipse; | |
169 | } | |
170 | ||
171 | //======================================================================= | |
172 | //function : IntPatch_GLine | |
173 | //purpose : Creates an ellispe as intersection line | |
174 | // when the transitions are Touch. | |
175 | //======================================================================= | |
176 | ||
177 | IntPatch_GLine::IntPatch_GLine (const gp_Elips& E, | |
178 | const Standard_Boolean Tang, | |
179 | const IntSurf_Situation Situ1, | |
180 | const IntSurf_Situation Situ2) : | |
181 | IntPatch_Line(Tang,Situ1,Situ2), | |
182 | pos(E.Position()), | |
183 | par1(E.MajorRadius()), | |
184 | par2(E.MinorRadius()), | |
185 | fipt(Standard_False),lapt(Standard_False), | |
186 | indf(0), indl(0) | |
187 | { | |
188 | typ = IntPatch_Ellipse; | |
189 | } | |
190 | ||
191 | //======================================================================= | |
192 | //function : IntPatch_GLine | |
193 | //purpose : Creates an ellipse as intersection line | |
194 | // when the transitions are Undecided. | |
195 | //======================================================================= | |
196 | ||
197 | IntPatch_GLine::IntPatch_GLine (const gp_Elips& E, | |
198 | const Standard_Boolean Tang) : | |
199 | IntPatch_Line(Tang), | |
200 | pos(E.Position()), | |
201 | par1(E.MajorRadius()), | |
202 | par2(E.MinorRadius()), | |
203 | fipt(Standard_False),lapt(Standard_False), | |
204 | indf(0), indl(0) | |
205 | { | |
206 | typ = IntPatch_Ellipse; | |
207 | } | |
208 | ||
209 | //======================================================================= | |
210 | //function : IntPatch_GLine | |
211 | //purpose : Creates a parabola as intersection line | |
212 | // when the transitions are In or Out. | |
213 | //======================================================================= | |
214 | ||
215 | IntPatch_GLine::IntPatch_GLine (const gp_Parab& P, | |
216 | const Standard_Boolean Tang, | |
217 | const IntSurf_TypeTrans Trans1, | |
218 | const IntSurf_TypeTrans Trans2) : | |
219 | IntPatch_Line(Tang,Trans1,Trans2), | |
220 | pos(P.Position()), | |
221 | par1(P.Focal()), par2(0.0), | |
222 | fipt(Standard_False),lapt(Standard_False), | |
223 | indf(0), indl(0) | |
224 | { | |
225 | typ = IntPatch_Parabola; | |
226 | } | |
227 | ||
228 | //======================================================================= | |
229 | //function : IntPatch_GLine | |
230 | //purpose : Creates a parabola as intersection line | |
231 | // when the transitions are Touch. | |
232 | //======================================================================= | |
233 | ||
234 | IntPatch_GLine::IntPatch_GLine (const gp_Parab& P, | |
235 | const Standard_Boolean Tang, | |
236 | const IntSurf_Situation Situ1, | |
237 | const IntSurf_Situation Situ2) : | |
238 | IntPatch_Line(Tang,Situ1,Situ2), | |
239 | pos(P.Position()), | |
240 | par1(P.Focal()), par2(0.0), | |
241 | fipt(Standard_False),lapt(Standard_False), | |
242 | indf(0), indl(0) | |
243 | { | |
244 | typ = IntPatch_Parabola; | |
245 | } | |
246 | ||
247 | //======================================================================= | |
248 | //function : IntPatch_GLine | |
249 | //purpose : Creates a parabola as intersection line | |
250 | // when the transitions are Undecided. | |
251 | //======================================================================= | |
252 | ||
253 | IntPatch_GLine::IntPatch_GLine (const gp_Parab& P, | |
254 | const Standard_Boolean Tang) : | |
255 | IntPatch_Line(Tang), | |
256 | pos(P.Position()), | |
257 | par1(P.Focal()), par2(0.0), | |
258 | fipt(Standard_False),lapt(Standard_False), | |
259 | indf(0), indl(0) | |
260 | { | |
261 | typ = IntPatch_Parabola; | |
262 | } | |
263 | ||
264 | //======================================================================= | |
265 | //function : IntPatch_GLine | |
266 | //purpose : Creates an hyperbola as intersection line | |
267 | // when the transitions are In or Out. | |
268 | //======================================================================= | |
269 | ||
270 | IntPatch_GLine::IntPatch_GLine (const gp_Hypr& H, | |
271 | const Standard_Boolean Tang, | |
272 | const IntSurf_TypeTrans Trans1, | |
273 | const IntSurf_TypeTrans Trans2) : | |
274 | IntPatch_Line(Tang,Trans1,Trans2), | |
275 | pos(H.Position()), | |
276 | par1(H.MajorRadius()), | |
277 | par2(H.MinorRadius()), | |
278 | fipt(Standard_False),lapt(Standard_False), | |
279 | indf(0), indl(0) | |
280 | { | |
281 | typ = IntPatch_Hyperbola; | |
282 | } | |
283 | ||
284 | //======================================================================= | |
285 | //function : IntPatch_GLine | |
286 | //purpose : Creates an hyperbola as intersection line | |
287 | // when the transitions are Touch. | |
288 | //======================================================================= | |
289 | ||
290 | IntPatch_GLine::IntPatch_GLine (const gp_Hypr& H, | |
291 | const Standard_Boolean Tang, | |
292 | const IntSurf_Situation Situ1, | |
293 | const IntSurf_Situation Situ2) : | |
294 | IntPatch_Line(Tang,Situ1,Situ2), | |
295 | pos(H.Position()), | |
296 | par1(H.MajorRadius()), | |
297 | par2(H.MinorRadius()), | |
298 | fipt(Standard_False),lapt(Standard_False), | |
299 | indf(0), indl(0) | |
300 | { | |
301 | typ = IntPatch_Hyperbola; | |
302 | } | |
303 | ||
304 | //======================================================================= | |
305 | //function : IntPatch_GLine | |
306 | //purpose : Creates an hyperbola as intersection line | |
307 | // when the transitions are Undecided. | |
308 | //======================================================================= | |
309 | ||
310 | IntPatch_GLine::IntPatch_GLine (const gp_Hypr& H, | |
311 | const Standard_Boolean Tang) : | |
312 | IntPatch_Line(Tang), | |
313 | pos(H.Position()), | |
314 | par1(H.MajorRadius()), | |
315 | par2(H.MinorRadius()), | |
316 | fipt(Standard_False),lapt(Standard_False), | |
317 | indf(0), indl(0) | |
318 | { | |
319 | typ = IntPatch_Hyperbola; | |
320 | } | |
321 | ||
322 | //======================================================================= | |
323 | //function : Replace | |
324 | //purpose : To replace the element of range Index in the list | |
325 | // of points. | |
326 | //======================================================================= | |
327 | ||
328 | void IntPatch_GLine::Replace (const Standard_Integer /*Index*/, | |
329 | const IntPatch_Point& Pnt) | |
330 | { | |
331 | svtx.Append(Pnt); | |
332 | //-- svtx(Index) = Pnt; | |
333 | } | |
334 | ||
335 | //======================================================================= | |
336 | //function : AddVertex | |
337 | //purpose : To add a vertex in the list. | |
338 | //======================================================================= | |
339 | ||
340 | void IntPatch_GLine::AddVertex (const IntPatch_Point& Pnt) | |
341 | { | |
342 | //-- On detecte le cas de 2 points 3d identiques | |
343 | //-- pour les ramener au meme parametre sur la | |
344 | //-- GLine | |
345 | if (NbVertex()) | |
346 | { | |
347 | const Standard_Real pf = (fipt? svtx.Value(indf).ParameterOnLine() : 0.0); | |
348 | const Standard_Real pl = (lapt? svtx.Value(indl).ParameterOnLine() : 0.0); | |
349 | Standard_Real par = Pnt.ParameterOnLine(); | |
350 | if(ArcType()==IntPatch_Circle || ArcType()==IntPatch_Ellipse) | |
351 | { | |
352 | if(fipt && lapt) { | |
c6541a0c D |
353 | while(par<pf) par+=M_PI+M_PI; |
354 | while(par>pl) par-=M_PI+M_PI; | |
7fd59977 | 355 | if(par<pf) { |
356 | const Standard_Real PrecisionPConfusion ( Precision::PConfusion()*1000.0 ); | |
357 | if((pf-par)>PrecisionPConfusion) { | |
358 | return; | |
359 | } | |
360 | } | |
361 | IntPatch_Point ParModif = Pnt; | |
362 | ParModif.SetParameter(par); | |
363 | svtx.Append(ParModif); | |
364 | return; | |
365 | } | |
366 | } | |
367 | else | |
368 | { | |
369 | if(fipt && lapt) { | |
370 | if(pl<par || par<pf) | |
371 | return; | |
372 | } | |
373 | } | |
374 | } | |
375 | svtx.Append(Pnt); | |
376 | } | |
377 | ||
378 | //======================================================================= | |
379 | //function : ComputeVertexParameters | |
380 | //purpose : Set the parameters of all the vertex on the line. | |
381 | // if a vertex is already in the line, | |
382 | // its parameter is modified | |
383 | // else a new point in the line is inserted. | |
384 | //======================================================================= | |
385 | ||
386 | void IntPatch_GLine::ComputeVertexParameters(const Standard_Real /*Tol*/) | |
387 | { | |
388 | Standard_Boolean SortIsOK,APointDeleted; | |
389 | Standard_Boolean SortAgain = Standard_True; | |
390 | Standard_Integer i,j; | |
391 | const Standard_Real ParamMinOnLine = (fipt? Vertex(indf).ParameterOnLine() : -100000.0); | |
392 | const Standard_Real ParamMaxOnLine = (lapt? Vertex(indl).ParameterOnLine() : 100000.0); | |
393 | ||
394 | //---------------------------------------------------------- | |
395 | //-- F i l t r e s u r r e s t r i c t i o n s -- | |
396 | //---------------------------------------------------------- | |
397 | //-- deux vertex sur la meme restriction et seulement | |
398 | //-- sur celle ci ne doivent pas avoir le meme parametre | |
399 | //========================================================== | |
400 | //-- 2 vertices on the same restriction and only | |
401 | //-- on that one must not have the same parametres | |
402 | ||
403 | Standard_Integer nbvtx = NbVertex(); | |
404 | ||
405 | const Standard_Real PrecisionPConfusion ( Precision::PConfusion()*1000.0 ); | |
406 | ||
407 | do { | |
408 | APointDeleted = Standard_False; | |
409 | for(i=1; (i<=nbvtx) && (!APointDeleted); i++) | |
410 | { | |
411 | const IntPatch_Point& VTXi = svtx.Value(i); | |
412 | if(VTXi.IsOnDomS1() || VTXi.IsOnDomS2()) | |
413 | { | |
414 | for(j=1; (j<=nbvtx) && (!APointDeleted); j++) | |
415 | { | |
416 | if(i!=j) | |
417 | { | |
418 | const IntPatch_Point& VTXj = svtx.Value(j); | |
419 | if((!VTXj.IsOnDomS1()) && (!VTXj.IsOnDomS2())) | |
420 | { | |
421 | if(Abs(VTXi.ParameterOnLine()-VTXj.ParameterOnLine())<=PrecisionPConfusion) | |
422 | { | |
423 | svtx.Remove(j); | |
424 | nbvtx--; | |
425 | if(lapt) { if(indl>j) indl--; } | |
426 | if(fipt) { if(indf>j) indf--; } | |
427 | APointDeleted = Standard_True; | |
428 | } | |
429 | } | |
430 | } | |
431 | } | |
432 | } | |
433 | } | |
434 | } | |
435 | while(APointDeleted && nbvtx > 2); | |
436 | ||
437 | do { | |
438 | APointDeleted = Standard_False; | |
439 | for(i=1; (i<=nbvtx) && (!APointDeleted); i++) | |
440 | { | |
441 | const IntPatch_Point& VTXi = svtx.Value(i); | |
442 | if(VTXi.IsOnDomS1() && (!VTXi.IsOnDomS2())) | |
443 | { | |
444 | for(j=1; (j<=nbvtx) && (!APointDeleted); j++) | |
445 | { | |
446 | if(i!=j) | |
447 | { | |
448 | const IntPatch_Point& VTXj = svtx.Value(j); | |
449 | if(VTXj.IsOnDomS1() && (!VTXj.IsOnDomS2())) | |
450 | { | |
451 | if(Abs(VTXi.ParameterOnArc1()-VTXj.ParameterOnArc1())<=PrecisionPConfusion) | |
452 | { | |
453 | if(VTXi.ArcOnS1() == VTXj.ArcOnS1()) | |
454 | { | |
455 | if(VTXi.IsVertexOnS1()) | |
456 | { | |
457 | svtx.Remove(j); | |
458 | nbvtx--; | |
459 | if(lapt) { if(indl>j) indl--; } | |
460 | if(fipt) { if(indf>j) indf--; } | |
461 | } | |
462 | else | |
463 | { | |
464 | svtx.Remove(i); | |
465 | nbvtx--; | |
466 | if(lapt) { if(indl>i) indl--; } | |
467 | if(fipt) { if(indf>i) indf--; } | |
468 | } | |
469 | APointDeleted = Standard_True; | |
470 | } | |
471 | } | |
472 | } | |
473 | } | |
474 | } | |
475 | } | |
476 | } | |
477 | } | |
478 | while(APointDeleted); | |
479 | ||
480 | do { | |
481 | APointDeleted = Standard_False; | |
482 | for(i=1; (i<=nbvtx) && (!APointDeleted); i++) | |
483 | { | |
484 | const IntPatch_Point& VTXi = svtx.Value(i); | |
485 | if(VTXi.IsOnDomS2() && (!VTXi.IsOnDomS1())) | |
486 | { | |
487 | for(j=1; (j<=nbvtx) && (!APointDeleted); j++) | |
488 | { | |
489 | if(i!=j) | |
490 | { | |
491 | const IntPatch_Point& VTXj = svtx.Value(j); | |
492 | if(VTXj.IsOnDomS2() && (!VTXj.IsOnDomS1())) | |
493 | { | |
494 | if(Abs(VTXi.ParameterOnArc2()-VTXj.ParameterOnArc2())<=PrecisionPConfusion) | |
495 | { | |
496 | if(VTXi.ArcOnS2() == VTXj.ArcOnS2()) | |
497 | { | |
498 | if(VTXi.IsVertexOnS1()) | |
499 | { | |
500 | svtx.Remove(j); | |
501 | nbvtx--; | |
502 | if(lapt) { if(indl>j) indl--; } | |
503 | if(fipt) { if(indf>j) indf--; } | |
504 | } | |
505 | else | |
506 | { | |
507 | svtx.Remove(i); | |
508 | nbvtx--; | |
509 | if(lapt) { if(indl>i) indl--; } | |
510 | if(fipt) { if(indf>i) indf--; } | |
511 | } | |
512 | APointDeleted = Standard_True; | |
513 | } | |
514 | } | |
515 | } | |
516 | } | |
517 | } | |
518 | } | |
519 | } | |
520 | } | |
521 | while(APointDeleted); | |
522 | ||
523 | ||
524 | //---------------------------------------------------------- | |
525 | //-- Tri des vertex et suppression des Vtx superflus | |
526 | //-- | |
527 | //// modified by jgv, 2.11.01 for BUC61033 //// | |
528 | Standard_Real u1min = RealLast(), u1max = RealFirst(); | |
529 | Standard_Real u2min = RealLast(), u2max = RealFirst(); | |
530 | Standard_Boolean ToBreak = Standard_False; | |
531 | /////////////////////////////////////////////// | |
532 | do { | |
533 | nbvtx = NbVertex(); | |
534 | if(SortAgain) | |
535 | { | |
536 | do | |
537 | { | |
538 | SortIsOK = Standard_True; | |
539 | for(i=2; i<=nbvtx; i++) | |
540 | { | |
541 | if(svtx.Value(i-1).ParameterOnLine() > svtx.Value(i).ParameterOnLine()) | |
542 | { | |
543 | SortIsOK = Standard_False; | |
544 | svtx.Exchange(i-1,i); | |
545 | if(fipt) { if(indf==i) indf=i-1; else if(indf==i-1) indf=i; } | |
546 | if(lapt) { if(indl==i) indl=i-1; else if(indl==i-1) indl=i; } | |
547 | } | |
548 | } | |
549 | } | |
550 | while(!SortIsOK); | |
551 | } | |
552 | ||
553 | //// modified by jgv, 2.11.01 for BUC61033 //// | |
554 | if (ToBreak) | |
555 | break; | |
556 | /////////////////////////////////////////////// | |
557 | ||
558 | SortAgain = Standard_False; | |
559 | SortIsOK = Standard_True; | |
788cbaf4 | 560 | for(i=2; i<=nbvtx && SortIsOK; i++) |
561 | { | |
7fd59977 | 562 | IntPatch_Point& VTX = svtx.ChangeValue(i); |
788cbaf4 | 563 | for(j=1; j<=nbvtx && SortIsOK; j++) |
564 | { | |
565 | if(i!=j) | |
566 | { | |
567 | IntPatch_Point& VTXM1 = svtx.ChangeValue(j); | |
568 | Standard_Boolean kill = Standard_False; | |
569 | Standard_Boolean killm1 = Standard_False; | |
570 | if(Abs(VTXM1.ParameterOnLine()-VTX.ParameterOnLine())<PrecisionPConfusion) | |
571 | { | |
572 | if(VTXM1.IsOnDomS1() && VTX.IsOnDomS1()) //-- OnS1 OnS1 | |
573 | { | |
574 | if(VTXM1.ArcOnS1() == VTX.ArcOnS1())//-- OnS1 == OnS1 | |
575 | { | |
576 | if(VTXM1.IsOnDomS2()) //-- OnS1 == OnS1 OnS2 | |
577 | { | |
578 | if(VTX.IsOnDomS2()==Standard_False)//-- OnS1 == OnS1 OnS2 PasOnS2 | |
579 | { | |
580 | kill=Standard_True; | |
581 | } | |
582 | else | |
583 | { | |
584 | if(VTXM1.ArcOnS2() == VTX.ArcOnS2()) //-- OnS1 == OnS1 OnS2 == OnS2 | |
585 | { | |
586 | if(VTXM1.IsVertexOnS2()) | |
587 | { | |
588 | kill=Standard_True; | |
589 | } | |
590 | else | |
591 | { | |
592 | killm1=Standard_True; | |
593 | } | |
594 | } | |
595 | } | |
596 | } | |
597 | else //-- OnS1 == OnS1 PasOnS2 | |
598 | { | |
599 | if(VTX.IsOnDomS2()) //-- OnS1 == OnS1 PasOnS2 OnS2 | |
600 | { | |
601 | killm1=Standard_True; | |
602 | } | |
603 | } | |
604 | } | |
605 | } | |
606 | else //-- Pas OnS1 et OnS1 | |
607 | { | |
608 | if(VTXM1.IsOnDomS2()==Standard_False && VTX.IsOnDomS2()==Standard_False) | |
609 | { | |
610 | if(VTXM1.IsOnDomS1() && VTX.IsOnDomS1()==Standard_False) | |
611 | { | |
612 | kill=Standard_True; | |
613 | } | |
614 | else if(VTX.IsOnDomS1() && VTXM1.IsOnDomS1()==Standard_False) | |
615 | { | |
616 | killm1=Standard_True; | |
617 | } | |
618 | } | |
619 | } | |
620 | ||
621 | if(!(kill || killm1)) | |
622 | { | |
623 | if(VTXM1.IsOnDomS2() && VTX.IsOnDomS2()) //-- OnS2 OnS2 | |
624 | { | |
625 | if(VTXM1.ArcOnS2() == VTX.ArcOnS2()) //-- OnS2 == OnS2 | |
626 | { | |
627 | if(VTXM1.IsOnDomS1()) //-- OnS2 == OnS2 OnS1 | |
628 | { | |
629 | if(VTX.IsOnDomS1()==Standard_False) //-- OnS2 == OnS2 OnS1 PasOnS1 | |
630 | { | |
631 | kill=Standard_True; | |
632 | } | |
633 | else | |
634 | { | |
635 | if(VTXM1.ArcOnS1() == VTX.ArcOnS1()) //-- OnS2 == OnS2 OnS1 == OnS1 | |
636 | { | |
637 | if(VTXM1.IsVertexOnS1()) | |
638 | { | |
639 | kill=Standard_True; //-- OnS2 == OnS2 OnS1 == OnS1 Vtx PasVtx | |
640 | } | |
641 | else | |
642 | { | |
643 | killm1=Standard_True; //-- OnS2 == OnS2 OnS1 == OnS1 PasVtx Vtx | |
644 | } | |
645 | } | |
646 | } | |
647 | } | |
648 | else | |
649 | { //-- OnS2 == OnS2 PasOnS1 | |
650 | if(VTX.IsOnDomS1()) //-- OnS2 == OnS2 PasOnS1 OnS1 | |
651 | { | |
652 | killm1=Standard_True; | |
653 | } | |
654 | } | |
655 | } | |
656 | } | |
657 | else //-- Pas OnS2 et OnS2 | |
658 | { | |
659 | if(VTXM1.IsOnDomS1()==Standard_False && VTX.IsOnDomS1()==Standard_False) | |
660 | { | |
661 | if(VTXM1.IsOnDomS2() && VTX.IsOnDomS2()==Standard_False) | |
662 | { | |
663 | kill=Standard_True; | |
664 | } | |
665 | else if(VTX.IsOnDomS2() && VTXM1.IsOnDomS2()==Standard_False) | |
666 | { | |
667 | killm1=Standard_True; | |
668 | } | |
669 | } | |
670 | } | |
671 | } | |
672 | ||
673 | //-- On a j < i | |
674 | if(kill) | |
675 | { | |
676 | SortIsOK = Standard_False; | |
677 | if(lapt) | |
678 | { | |
679 | if(indl>i) | |
680 | indl--; | |
681 | else if(indl==i) | |
682 | indl=j; | |
683 | } | |
684 | ||
685 | if(fipt) | |
686 | { | |
687 | if(indf>i) | |
688 | indf--; | |
689 | else if(indf==i) | |
690 | indf=j; | |
691 | } | |
692 | ||
693 | svtx.Remove(i); | |
694 | nbvtx--; | |
695 | } | |
696 | else if(killm1) | |
697 | { | |
698 | SortIsOK = Standard_False; | |
699 | if(lapt) | |
700 | { | |
701 | if(indl>j) | |
702 | indl--; | |
703 | else if(indl==j) | |
704 | indl=i-1; | |
705 | } | |
706 | ||
707 | if(fipt) | |
708 | { | |
709 | if(indf>j) | |
710 | indf--; | |
711 | else if(indf==j) | |
712 | indf=i-1; | |
713 | } | |
714 | ||
715 | svtx.Remove(j); | |
716 | nbvtx--; | |
717 | }// else | |
718 | else if(ArcType()==IntPatch_Circle || ArcType()==IntPatch_Ellipse) // eap | |
719 | { | |
720 | //-- deux points de meme parametre qui ne peuvent etre confondus | |
721 | //-- On change les parametres d un des points si les points UV sont | |
722 | //-- differents. Ceci distingue le cas des aretes de couture. | |
723 | // ========================================================== | |
724 | //-- 2 points with the same parameters | |
725 | //-- Change parametres of one point if points UV are | |
726 | //-- different. This is the case of seam edge | |
727 | ||
728 | Standard_Real ponline = VTX.ParameterOnLine(); | |
729 | // eap, =>> | |
730 | Standard_Real newParam = ponline; | |
731 | const Standard_Real PiPi = M_PI+M_PI; | |
732 | Standard_Boolean is2PI = ( Abs(ponline-PiPi) <= PrecisionPConfusion ); | |
733 | ||
734 | if (nbvtx > 2 && // do this check if seam edge only gives vertices | |
735 | !is2PI) // but always change 2PI -> 0 | |
736 | continue; | |
737 | ||
738 | if (is2PI) | |
739 | newParam = 0; | |
740 | else if (Abs(ponline) <= PrecisionPConfusion) | |
741 | newParam = PiPi; | |
742 | else | |
743 | newParam -= PiPi; | |
744 | ||
745 | // if( (Abs(ponline)<=PrecisionPConfusion) | |
746 | // ||(Abs(ponline-M_PI-M_PI) <=PrecisionPConfusion)) | |
747 | // eap, <<= | |
748 | ||
749 | Standard_Real u1a,v1a,u2a,v2a,u1b,v1b,u2b,v2b; | |
750 | VTXM1.Parameters(u1a,v1a,u2a,v2a); | |
751 | VTX.Parameters(u1b,v1b,u2b,v2b); | |
752 | Standard_Integer flag = 0; | |
753 | ||
754 | if( (Abs(u1a-u1b)<=PrecisionPConfusion) ) | |
755 | flag|=1; | |
756 | ||
757 | if( (Abs(v1a-v1b)<=PrecisionPConfusion) ) | |
758 | flag|=2; | |
759 | if( (Abs(u2a-u2b)<=PrecisionPConfusion) ) | |
760 | flag|=4; | |
761 | ||
762 | if( (Abs(v2a-v2b)<=PrecisionPConfusion) ) | |
763 | flag|=8; | |
764 | ||
765 | Standard_Boolean TestOn1 = Standard_False; | |
766 | Standard_Boolean TestOn2 = Standard_False; | |
767 | ||
768 | switch(flag) | |
769 | { | |
770 | case 3: //-- meme point U1 V1 | |
771 | case 7: //-- meme point U1 V1 meme U2 | |
772 | case 12: //-- meme U2 V2 | |
773 | case 13: //-- meme point U1 meme U2 V2 | |
774 | case 10: //-- meme point V1 meme V2 Test si U1a=U1b Mod 2PI et Test si U2a=U2b Mod 2PI | |
775 | break; | |
776 | case 11: //-- meme point U1 V1 meme V2 Test si U2a=U2b Mod 2PI | |
777 | { | |
778 | TestOn2 = Standard_True; | |
779 | break; | |
780 | } | |
781 | ||
782 | case 14: //-- meme point V1 meme U2 V2 Test si U1a=U1b Mod 2PI | |
783 | { | |
784 | TestOn1 = Standard_True; | |
785 | break; | |
786 | } | |
787 | default: | |
788 | break; | |
789 | }; | |
790 | ||
791 | // eap | |
792 | //if(ArcType()==IntPatch_Circle || ArcType()==IntPatch_Ellipse) {} | |
793 | if(TestOn1) | |
794 | { | |
795 | //// modified by jgv, 2.11.01 for BUC61033 //// | |
796 | Standard_Real U1A = (u1a < u1b)? u1a : u1b; | |
797 | Standard_Real U1B = (u1a < u1b)? u1b : u1a; | |
798 | ||
799 | if (u1min == RealLast()) | |
800 | { | |
801 | u1min = U1A; | |
802 | u1max = U1B; | |
803 | } | |
804 | else | |
805 | { | |
806 | if (Abs(U1A-u1min) > PrecisionPConfusion) | |
807 | ToBreak = Standard_True; | |
808 | if (Abs(U1B-u1max) > PrecisionPConfusion) | |
809 | ToBreak = Standard_True; | |
810 | } | |
7fd59977 | 811 | /////////////////////////////////////////////// |
812 | // eap, =>> | |
813 | // if (Abs(ponline) <= PrecisionPConfusion) { | |
c6541a0c | 814 | // const Standard_Real PiPi = M_PI+M_PI; |
788cbaf4 | 815 | if(newParam >= ParamMinOnLine && newParam <= ParamMaxOnLine |
816 | /*PiPi >= ParamMinOnLine && PiPi<=ParamMaxOnLine*/) | |
817 | { | |
818 | SortAgain = Standard_True; | |
819 | SortIsOK = Standard_False; | |
820 | if (newParam > ponline) | |
821 | { | |
822 | if(u1a < u1b) | |
823 | { | |
824 | VTX.SetParameter(newParam); | |
825 | } | |
826 | else | |
827 | { | |
828 | VTXM1.SetParameter(newParam); | |
829 | } | |
830 | } | |
831 | else | |
832 | { | |
833 | if(u1a > u1b) | |
834 | { | |
835 | VTX.SetParameter(newParam); | |
836 | } | |
837 | else | |
838 | { | |
839 | VTXM1.SetParameter(newParam); | |
840 | } | |
841 | } | |
842 | } | |
7fd59977 | 843 | // } |
844 | // else { | |
845 | // if(0.0 >= ParamMinOnLine && 0.0<=ParamMaxOnLine) { | |
846 | // SortAgain = Standard_True; | |
847 | // SortIsOK = Standard_False; | |
848 | // if(u1a > u1b) { VTX.SetParameter(0.0); } | |
849 | // else { VTXM1.SetParameter(0.0); } | |
850 | // } | |
851 | // } | |
852 | // eap, <<= | |
788cbaf4 | 853 | } |
854 | ||
855 | if(TestOn2) | |
856 | { | |
857 | //// modified by jgv, 2.11.01 for BUC61033 //// | |
858 | Standard_Real U2A = (u2a < u2b)? u2a : u2b; | |
859 | Standard_Real U2B = (u2a < u2b)? u2b : u2a; | |
860 | if (u2min == RealLast()) | |
861 | { | |
862 | u2min = U2A; | |
863 | u2max = U2B; | |
864 | } | |
865 | else | |
866 | { | |
867 | if (Abs(U2A-u2min) > PrecisionPConfusion) | |
868 | ToBreak = Standard_True; | |
869 | ||
870 | if (Abs(U2B-u2max) > PrecisionPConfusion) | |
871 | ToBreak = Standard_True; | |
872 | ||
873 | } | |
7fd59977 | 874 | /////////////////////////////////////////////// |
875 | // eap, =>> | |
876 | // if (Abs(ponline) <= PrecisionPConfusion) { | |
c6541a0c | 877 | // const Standard_Real PiPi = M_PI+M_PI; |
788cbaf4 | 878 | if(newParam >= ParamMinOnLine && newParam <= ParamMaxOnLine |
879 | /*PiPi >= ParamMinOnLine && PiPi<=ParamMaxOnLine*/) | |
880 | { | |
881 | SortAgain = Standard_True; | |
882 | SortIsOK = Standard_False; | |
883 | if (newParam > ponline) | |
884 | { | |
885 | if(u2a < u2b) | |
886 | { | |
887 | VTX.SetParameter(newParam); | |
888 | } | |
889 | else | |
890 | { | |
891 | VTXM1.SetParameter(newParam); | |
892 | } | |
893 | } | |
894 | else | |
895 | { | |
896 | if(u2a > u2b) | |
897 | { | |
898 | VTX.SetParameter(newParam); | |
899 | } | |
900 | else | |
901 | { | |
902 | VTXM1.SetParameter(newParam); | |
903 | } | |
904 | } | |
905 | } | |
7fd59977 | 906 | // } |
907 | // else { | |
908 | // if(0.0 >= ParamMinOnLine && 0.0<=ParamMaxOnLine) { | |
909 | // SortAgain = Standard_True; | |
910 | // SortIsOK = Standard_False; | |
911 | // if(u2a > u2b) { VTX.SetParameter(0.0); } | |
912 | // else { VTXM1.SetParameter(0.0); } | |
913 | // } | |
914 | // } | |
915 | // } | |
916 | // } | |
917 | // eap, <<= | |
788cbaf4 | 918 | } |
919 | } | |
920 | } | |
921 | } | |
7fd59977 | 922 | } //-- if(i!=j) |
923 | } | |
924 | } | |
925 | while(!SortIsOK); | |
926 | ||
927 | //-- Recalcul de fipt et lapt | |
928 | //-- | |
929 | nbvtx=NbVertex(); | |
930 | if(nbvtx) | |
931 | { | |
932 | do { | |
933 | SortIsOK = Standard_True; | |
934 | for(i=2; i<=nbvtx; i++) | |
935 | { | |
936 | if(svtx.Value(i-1).ParameterOnLine() > svtx.Value(i).ParameterOnLine()) | |
937 | { | |
938 | SortIsOK = Standard_False; | |
939 | svtx.Exchange(i-1,i); | |
940 | } | |
941 | } | |
942 | } | |
943 | while(!SortIsOK); | |
788cbaf4 | 944 | |
7fd59977 | 945 | indl=nbvtx; |
946 | indf=1; | |
947 | } | |
948 | } |