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_Pnt.hxx> |
19 | #include <gp_Vec.hxx> |
20 | #include <IntAna_Curve.hxx> |
21 | #include <IntPatch_ALine.hxx> |
22 | #include <IntPatch_Point.hxx> |
23 | #include <Standard_DomainError.hxx> |
24 | #include <Standard_OutOfRange.hxx> |
25 | #include <Standard_Type.hxx> |
7fd59977 |
26 | |
92efcf78 |
27 | IMPLEMENT_STANDARD_RTTIEXT(IntPatch_ALine,IntPatch_Line) |
28 | |
7fd59977 |
29 | #define DEBUG 0 |
30 | |
31 | IntPatch_ALine::IntPatch_ALine (const IntAna_Curve& C, |
32 | const Standard_Boolean Tang, |
33 | const IntSurf_TypeTrans Trans1, |
34 | const IntSurf_TypeTrans Trans2) : |
35 | IntPatch_Line(Tang,Trans1,Trans2), |
36 | fipt(Standard_False),lapt(Standard_False) |
37 | |
38 | { |
39 | typ = IntPatch_Analytic; |
40 | curv = C; |
41 | } |
42 | |
43 | |
44 | IntPatch_ALine::IntPatch_ALine (const IntAna_Curve& C, |
45 | const Standard_Boolean Tang, |
46 | const IntSurf_Situation Situ1, |
47 | const IntSurf_Situation Situ2) : |
48 | IntPatch_Line(Tang,Situ1,Situ2), |
49 | fipt(Standard_False),lapt(Standard_False) |
50 | |
51 | { |
52 | typ = IntPatch_Analytic; |
53 | curv = C; |
54 | } |
55 | |
56 | |
57 | IntPatch_ALine::IntPatch_ALine (const IntAna_Curve& C, |
58 | const Standard_Boolean Tang) : |
59 | IntPatch_Line(Tang), |
60 | fipt(Standard_False),lapt(Standard_False) |
61 | |
62 | { |
63 | typ = IntPatch_Analytic; |
64 | curv = C; |
65 | } |
66 | |
67 | const IntAna_Curve& IntPatch_ALine::Curve() const { |
68 | return(curv); |
69 | } |
70 | |
71 | |
72 | #define PCONFUSION 0.00001 |
73 | |
74 | |
75 | void IntPatch_ALine::AddVertex (const IntPatch_Point& VTXj) { |
76 | #if 0 |
77 | Standard_Integer n = NbVertex(); |
78 | if(n>=1) { |
79 | Standard_Real par = VTXj.ParameterOnLine(); |
80 | |
81 | for(int i=1; i<=n ;i++) { |
82 | const IntPatch_Point& VTXi = svtx.Value(i); |
83 | if((VTXj.IsOnDomS1()==Standard_False) && (VTXj.IsOnDomS2()==Standard_False)) { |
84 | if((VTXi.IsOnDomS1()==Standard_False) && (VTXi.IsOnDomS2()==Standard_False)) { |
85 | if(Abs(par-VTXi.ParameterOnLine())<=PCONFUSION) { |
86 | #if DEBUG |
04232180 |
87 | std::cout<<" Rejet IntPatch_ALine::AddVertex (0) "<<std::endl; |
7fd59977 |
88 | #endif |
89 | return; |
90 | } |
91 | } |
92 | } |
93 | } |
94 | for(i=1; i<=n ;i++) { |
95 | const IntPatch_Point& VTXi = svtx.Value(i); |
96 | if((VTXj.IsOnDomS1()==Standard_True) && (VTXj.IsOnDomS2()==Standard_False)) { |
97 | if((VTXi.IsOnDomS1()==Standard_True) && (VTXi.IsOnDomS2()==Standard_False)) { |
98 | if(Abs(VTXi.ParameterOnArc1()-VTXj.ParameterOnArc1())<=PCONFUSION) { |
99 | if(VTXi.ArcOnS1() == VTXj.ArcOnS1()) { |
100 | #if DEBUG |
04232180 |
101 | std::cout<<" Rejet IntPatch_ALine::AddVertex (1) "<<std::endl; |
7fd59977 |
102 | #endif |
103 | return; |
104 | } |
105 | } |
106 | } |
107 | } |
108 | } |
109 | for(i=1; i<=n ;i++) { |
110 | const IntPatch_Point& VTXi = svtx.Value(i); |
111 | if((VTXj.IsOnDomS2()==Standard_True) && (VTXj.IsOnDomS1()==Standard_False)) { |
112 | if((VTXi.IsOnDomS2()==Standard_True) && (VTXi.IsOnDomS1()==Standard_False)) { |
113 | if(Abs(VTXi.ParameterOnArc2()-VTXj.ParameterOnArc2())<=PCONFUSION) { |
114 | if(VTXi.ArcOnS2() == VTXj.ArcOnS2()) { |
115 | #if DEBUG |
04232180 |
116 | std::cout<<" Rejet IntPatch_ALine::AddVertex (2) "<<std::endl; |
7fd59977 |
117 | #endif |
118 | return; |
119 | } |
120 | } |
121 | } |
122 | } |
123 | } |
124 | for(i=1; i<=n ;i++) { |
125 | const IntPatch_Point& VTXi = svtx.Value(i); |
126 | if((VTXj.IsOnDomS2()==Standard_True) && (VTXj.IsOnDomS1()==Standard_True)) { |
127 | if((VTXi.IsOnDomS2()==Standard_True) && (VTXi.IsOnDomS1()==Standard_True)) { |
128 | if(Abs(VTXi.ParameterOnArc2()-VTXj.ParameterOnArc2())<=PCONFUSION) { |
129 | if(Abs(VTXi.ParameterOnArc1()-VTXj.ParameterOnArc1())<=PCONFUSION) { |
130 | if(VTXi.ArcOnS2() == VTXj.ArcOnS2()) { |
131 | if(VTXi.ArcOnS1() == VTXj.ArcOnS1()) { |
132 | #if DEBUG |
04232180 |
133 | std::cout<<" Rejet IntPatch_ALine::AddVertex (3) "<<std::endl; |
7fd59977 |
134 | #endif |
135 | return; |
136 | } |
137 | } |
138 | } |
139 | } |
140 | } |
141 | } |
142 | } |
143 | |
144 | //-- Est ce que VTXj present sur 1 et 2 remplace un point VTXi present sur 1 |
145 | for(i=1; i<=n ;i++) { |
146 | const IntPatch_Point& VTXi = svtx.Value(i); |
147 | if((VTXj.IsOnDomS2()==Standard_True) && (VTXj.IsOnDomS1()==Standard_True)) { |
148 | if((VTXi.IsOnDomS2()==Standard_False) && (VTXi.IsOnDomS1()==Standard_True)) { |
149 | Standard_Real p = Abs(VTXi.ParameterOnArc1()-VTXj.ParameterOnArc1()); |
150 | #if DEBUG |
04232180 |
151 | std::cout<<" Est ce que VTXj present sur 1 et 2 remplace un point VTXi present sur 1 : "<<p<<std::endl; |
7fd59977 |
152 | #endif |
153 | if(p<=PCONFUSION) { |
154 | if(VTXi.ArcOnS1() == VTXj.ArcOnS1()) { |
155 | #if DEBUG |
04232180 |
156 | std::cout<<" Replace IntPatch_ALine::AddVertex (1) "<<std::endl; |
7fd59977 |
157 | #endif |
158 | Replace(i,VTXj); |
159 | return; |
160 | } |
161 | } |
162 | } |
163 | } |
164 | } |
165 | //-- Est ce que VTXj present sur 1 et 2 remplace un point VTXi present sur 2 |
166 | for(i=1; i<=n ;i++) { |
167 | const IntPatch_Point& VTXi = svtx.Value(i); |
168 | if((VTXj.IsOnDomS2()==Standard_True) && (VTXj.IsOnDomS1()==Standard_True)) { |
169 | if((VTXi.IsOnDomS2()==Standard_True) && (VTXi.IsOnDomS1()==Standard_False)) { |
170 | Standard_Real p = Abs(VTXi.ParameterOnArc2()-VTXj.ParameterOnArc2()); |
171 | #if DEBUG |
04232180 |
172 | std::cout<<" Est ce que VTXj present sur 1 et 2 remplace un point VTXi present sur 2 : "<<p<<std::endl; |
7fd59977 |
173 | #endif |
174 | if(p<=PCONFUSION) { |
175 | if(VTXi.ArcOnS2() == VTXj.ArcOnS2()) { |
176 | #if DEBUG |
04232180 |
177 | std::cout<<" Replace IntPatch_ALine::AddVertex (2) "<<std::endl; |
7fd59977 |
178 | #endif |
179 | Replace(i,VTXj); |
180 | return; |
181 | } |
182 | } |
183 | } |
184 | } |
185 | } |
186 | |
187 | |
188 | //-- Est ce que VTXi deja present sur 1 et 2 et un point VTXj present sur 1 |
189 | for(i=1; i<=n ;i++) { |
190 | const IntPatch_Point& VTXi = svtx.Value(i); |
191 | if((VTXi.IsOnDomS2()==Standard_True) && (VTXi.IsOnDomS1()==Standard_True)) { |
192 | if((VTXj.IsOnDomS2()==Standard_False) && (VTXj.IsOnDomS1()==Standard_True)) { |
193 | Standard_Real p = Abs(VTXi.ParameterOnArc1()-VTXj.ParameterOnArc1()); |
194 | if(p<=PCONFUSION) { |
195 | if(VTXi.ArcOnS1() == VTXj.ArcOnS1()) { |
196 | #if DEBUG |
04232180 |
197 | std::cout<<" Replace IntPatch_ALine::AddVertex (1) -> RIEN "<<std::endl; |
7fd59977 |
198 | #endif |
199 | return; |
200 | } |
201 | } |
202 | } |
203 | } |
204 | } |
205 | //-- Est ce que VTXj present sur 1 et 2 remplace un point VTXi present sur 2 |
206 | for(i=1; i<=n ;i++) { |
207 | const IntPatch_Point& VTXi = svtx.Value(i); |
208 | if((VTXi.IsOnDomS2()==Standard_True) && (VTXi.IsOnDomS1()==Standard_True)) { |
209 | if((VTXj.IsOnDomS2()==Standard_True) && (VTXj.IsOnDomS1()==Standard_False)) { |
210 | Standard_Real p = Abs(VTXi.ParameterOnArc2()-VTXj.ParameterOnArc2()); |
211 | if(p<=PCONFUSION) { |
212 | if(VTXi.ArcOnS2() == VTXj.ArcOnS2()) { |
213 | return; |
214 | } |
215 | } |
216 | } |
217 | } |
218 | } |
219 | svtx.Append(VTXj); |
220 | |
221 | } |
222 | else { |
223 | svtx.Append(VTXj); |
224 | } |
225 | #else |
226 | svtx.Append(VTXj); |
227 | #endif |
228 | } |
229 | |
230 | |
231 | |
232 | |
233 | |
234 | void IntPatch_ALine::ComputeVertexParameters(const Standard_Real Tol) { |
235 | Standard_Boolean SortIsOK,APointDeleted; |
236 | Standard_Boolean SortAgain = Standard_True; |
237 | Standard_Integer nbvtx,i,j; |
238 | Standard_Real ParamMinOnLine,ParamMaxOnLine; |
239 | Standard_Boolean OpenFirst,OpenLast; |
240 | |
241 | ParamMinOnLine = FirstParameter(OpenFirst); |
242 | ParamMaxOnLine = LastParameter(OpenLast); |
243 | |
244 | |
245 | //---------------------------------------------------------- |
246 | //-- F i l t r e s u r r e s t r i c t i o n s -- |
247 | //---------------------------------------------------------- |
248 | //-- deux vertex sur la meme restriction et seulement |
249 | //-- sur celle ci ne doivent pas avoir le meme parametre |
250 | //-- |
251 | //-- |
252 | |
253 | //-- Le tri est necessaire si suppression du first ou du last point |
254 | nbvtx = NbVertex(); |
255 | |
256 | |
257 | //-- On verifie qu un vertex a bien toute ses representations : |
258 | //-- Cas tres rare : point de tangence sur un debut de ligne |
259 | //-- et la ligne fait 2 * 2 PI de parametrage. |
260 | |
261 | for(i=1; i<=nbvtx; i++) { |
262 | IntPatch_Point& VTX = svtx.ChangeValue(i); |
263 | Standard_Real p=VTX.ParameterOnLine(); |
c6541a0c |
264 | Standard_Real pmpimpi=p-M_PI-M_PI; |
7fd59977 |
265 | if(pmpimpi >= ParamMinOnLine) { |
266 | gp_Pnt P1 = Value(pmpimpi); |
267 | Standard_Real d1 = P1.Distance(VTX.Value()); |
268 | if(d1<Tol) { |
269 | IntPatch_Point OVTX(VTX); |
270 | OVTX.SetParameter(pmpimpi); |
271 | svtx.Append(OVTX); |
272 | } |
273 | } |
c6541a0c |
274 | pmpimpi=p+M_PI+M_PI; |
7fd59977 |
275 | if(pmpimpi <= ParamMaxOnLine) { |
276 | gp_Pnt P1 = Value(pmpimpi); |
277 | Standard_Real d1 = P1.Distance(VTX.Value()); |
278 | if(d1<Tol) { |
279 | IntPatch_Point OVTX(VTX); |
280 | OVTX.SetParameter(pmpimpi); |
281 | svtx.Append(OVTX); |
282 | } |
283 | } |
284 | } |
285 | |
286 | |
287 | nbvtx=NbVertex(); |
288 | |
289 | |
290 | |
291 | if(nbvtx<=0) return; |
292 | do { |
293 | SortIsOK = Standard_True; |
294 | for(i=2; i<=nbvtx; i++) { |
295 | if(svtx.Value(i-1).ParameterOnLine() > svtx.Value(i).ParameterOnLine()) { |
296 | SortIsOK = Standard_False; |
297 | svtx.Exchange(i-1,i); |
298 | if(fipt) { if(indf==i) indf=i-1; else if(indf==i-1) indf=i; } |
299 | if(lapt) { if(indl==i) indl=i-1; else if(indl==i-1) indl=i; } |
300 | } |
301 | } |
302 | } |
303 | while(!SortIsOK); |
304 | |
305 | do { |
306 | APointDeleted = Standard_False; |
307 | for(i=1; (i<=nbvtx) && (APointDeleted==Standard_False) ;i++) { |
308 | const IntPatch_Point& VTXi = svtx.Value(i); |
309 | if((VTXi.IsOnDomS1()==Standard_True) && (VTXi.IsOnDomS2()==Standard_False)) { |
310 | for(j=1; (j<=nbvtx) && (APointDeleted==Standard_False) ;j++) { |
311 | if(i!=j) { |
312 | const IntPatch_Point& VTXj = svtx.Value(j); |
313 | if((VTXj.IsOnDomS1()==Standard_True) && (VTXj.IsOnDomS2()==Standard_False)) { |
314 | if(Abs(VTXi.ParameterOnArc1()-VTXj.ParameterOnArc1())<=PCONFUSION) { |
315 | if(Abs(VTXi.ParameterOnLine()-VTXj.ParameterOnLine())<=PCONFUSION) { |
316 | if(VTXi.ArcOnS1() == VTXj.ArcOnS1()) { |
317 | svtx.Remove(j); |
318 | nbvtx--; |
319 | if(lapt) { if(indl>=j) indl--; } |
320 | if(fipt) { if(indf>=j) indf--; } |
321 | APointDeleted = Standard_True; |
322 | } |
323 | } |
324 | } |
325 | } |
326 | } |
327 | } |
328 | } |
329 | } |
330 | } |
331 | while(APointDeleted == Standard_True); |
332 | |
333 | do { |
334 | APointDeleted = Standard_False; |
335 | for(i=1; (i<=nbvtx) && (APointDeleted==Standard_False) ;i++) { |
336 | const IntPatch_Point& VTXi = svtx.Value(i); |
337 | if((VTXi.IsOnDomS2()==Standard_True) && (VTXi.IsOnDomS1()==Standard_False)) { |
338 | for(j=1; (j<=nbvtx) && (APointDeleted==Standard_False) ;j++) { |
339 | if(i!=j) { |
340 | const IntPatch_Point& VTXj = svtx.Value(j); |
341 | if((VTXj.IsOnDomS2()==Standard_True) && (VTXj.IsOnDomS1()==Standard_False)) { |
342 | if(Abs(VTXi.ParameterOnArc2()-VTXj.ParameterOnArc2())<=PCONFUSION) { |
343 | if(Abs(VTXi.ParameterOnLine()-VTXj.ParameterOnLine())<=PCONFUSION) { |
344 | if(VTXi.ArcOnS2() == VTXj.ArcOnS2()) { |
345 | svtx.Remove(j); |
346 | nbvtx--; |
347 | if(lapt) { if(indl>=j) indl--; } |
348 | if(fipt) { if(indf>=j) indf--; } |
349 | APointDeleted = Standard_True; |
350 | } |
351 | } |
352 | } |
353 | } |
354 | } |
355 | } |
356 | } |
357 | } |
358 | } |
359 | while(APointDeleted == Standard_True); |
360 | |
361 | |
362 | //---------------------------------------------------------- |
363 | //-- Tri des vertex et suppression des Vtx superflus |
364 | //-- |
365 | do { |
366 | nbvtx = NbVertex(); |
367 | if(SortAgain) { |
368 | do { |
369 | SortIsOK = Standard_True; |
370 | for(i=2; i<=nbvtx; i++) { |
371 | if(svtx.Value(i-1).ParameterOnLine() > svtx.Value(i).ParameterOnLine()) { |
372 | SortIsOK = Standard_False; |
373 | svtx.Exchange(i-1,i); |
374 | if(fipt) { if(indf==i) indf=i-1; else if(indf==i-1) indf=i; } |
375 | if(lapt) { if(indl==i) indl=i-1; else if(indl==i-1) indl=i; } |
376 | } |
377 | } |
378 | } |
379 | while(!SortIsOK); |
380 | } |
381 | SortAgain = Standard_False; |
382 | SortIsOK = Standard_True; |
383 | for(i=2; i<=nbvtx && SortIsOK; i++) { |
384 | IntPatch_Point& VTX = svtx.ChangeValue(i); |
385 | for(j=1; j<i && SortIsOK; j++) { |
386 | IntPatch_Point& VTXM1 = svtx.ChangeValue(j); |
387 | Standard_Boolean kill = Standard_False; |
388 | Standard_Boolean killm1 = Standard_False; |
389 | if(Abs(VTXM1.ParameterOnLine()-VTX.ParameterOnLine())<PCONFUSION) { |
390 | if(VTXM1.IsOnDomS1() && VTX.IsOnDomS1()) { //-- OnS1 OnS1 |
391 | if(VTXM1.ArcOnS1() == VTX.ArcOnS1()) { //-- OnS1 == OnS1 |
392 | if(VTXM1.IsOnDomS2()) { //-- OnS1 == OnS1 OnS2 |
393 | if(VTX.IsOnDomS2()==Standard_False) { //-- OnS1 == OnS1 OnS2 PasOnS2 |
394 | kill=Standard_True; |
395 | } |
396 | else { |
397 | if(VTXM1.ArcOnS2() == VTX.ArcOnS2()) { //-- OnS1 == OnS1 OnS2 == OnS2 |
398 | kill=Standard_True; |
399 | } |
400 | } |
401 | } |
402 | else { //-- OnS1 == OnS1 PasOnS2 |
403 | if(VTX.IsOnDomS2()) { //-- OnS1 == OnS1 PasOnS2 OnS2 |
404 | killm1=Standard_True; |
405 | } |
406 | } |
407 | } |
408 | } |
409 | else { //-- Pas OnS1 et OnS1 |
410 | if(VTXM1.IsOnDomS2()==Standard_False && VTX.IsOnDomS2()==Standard_False) { |
411 | if(VTXM1.IsOnDomS1() && VTX.IsOnDomS1()==Standard_False) { |
412 | kill=Standard_True; |
413 | } |
414 | else if(VTX.IsOnDomS1() && VTXM1.IsOnDomS1()==Standard_False) { |
415 | killm1=Standard_True; |
416 | } |
417 | } |
418 | } |
419 | |
420 | if(!(kill || killm1)) { |
421 | if(VTXM1.IsOnDomS2() && VTX.IsOnDomS2()) { //-- OnS2 OnS2 |
422 | if(VTXM1.ArcOnS2() == VTX.ArcOnS2()) { //-- OnS2 == OnS2 |
423 | if(VTXM1.IsOnDomS1()) { //-- OnS2 == OnS2 OnS1 |
424 | if(VTX.IsOnDomS1()==Standard_False) { //-- OnS2 == OnS2 OnS1 PasOnS1 |
425 | kill=Standard_True; |
426 | } |
427 | else { |
428 | if(VTXM1.ArcOnS1() == VTX.ArcOnS1()) { //-- OnS2 == OnS2 OnS1 == OnS1 |
429 | kill=Standard_True; |
430 | } |
431 | } |
432 | } |
433 | else { //-- OnS2 == OnS2 PasOnS1 |
434 | if(VTX.IsOnDomS1()) { //-- OnS2 == OnS2 PasOnS1 OnS1 |
435 | killm1=Standard_True; |
436 | } |
437 | } |
438 | } |
439 | } |
440 | else { //-- Pas OnS2 et OnS2 |
441 | if(VTXM1.IsOnDomS1()==Standard_False && VTX.IsOnDomS1()==Standard_False) { |
442 | if(VTXM1.IsOnDomS2() && VTX.IsOnDomS2()==Standard_False) { |
443 | kill=Standard_True; |
444 | } |
445 | else if(VTX.IsOnDomS2() && VTXM1.IsOnDomS2()==Standard_False) { |
446 | killm1=Standard_True; |
447 | } |
448 | } |
449 | } |
450 | } |
451 | //-- On a j < i |
452 | if(kill) { |
453 | SortIsOK = Standard_False; |
454 | if(lapt) { if(indl>i) indl--; else if(indl==i) indl=j; } |
455 | if(fipt) { if(indf>i) indf--; else if(indf==i) indf=j; } |
456 | svtx.Remove(i); |
457 | nbvtx--; |
458 | } |
459 | else if(killm1) { |
460 | SortIsOK = Standard_False; |
461 | if(lapt) { if(indl>j) indl--; else if(indl==j) indl=i-1;} |
462 | if(fipt) { if(indf>j) indf--; else if(indf==j) indf=i-1;} |
463 | svtx.Remove(j); |
464 | nbvtx--; |
465 | } |
466 | } |
467 | } |
468 | } |
469 | } |
470 | while(!SortIsOK); |
471 | |
472 | |
473 | //---------------------------------------------------------- |
474 | //-- Traitement des lignes periodiques -- |
475 | //---------------------------------------------------------- |
476 | if(OpenFirst == Standard_False && OpenLast == Standard_False) { |
477 | nbvtx = NbVertex(); |
478 | |
479 | IntPatch_Point& VTX0 = svtx.ChangeValue(1); |
480 | IntPatch_Point& VTXN = svtx.ChangeValue(nbvtx); |
481 | if(VTX0.ParameterOnLine() == ParamMinOnLine) { |
482 | if(VTXN.ParameterOnLine() !=ParamMaxOnLine) { |
483 | gp_Pnt PN=Value(ParamMaxOnLine); |
484 | Standard_Real d = PN.Distance(VTX0.Value()); |
485 | if(d<=Tol) { |
486 | IntPatch_Point OVTX(VTX0); |
487 | OVTX.SetParameter(ParamMaxOnLine); |
488 | svtx.Append(OVTX); |
489 | } |
490 | } |
491 | else { |
492 | if(VTXN.ParameterOnLine() == ParamMaxOnLine) { |
493 | if(VTX0.ParameterOnLine() !=ParamMinOnLine) { |
494 | gp_Pnt P0=Value(ParamMinOnLine); |
495 | Standard_Real d = P0.Distance(VTX0.Value()); |
496 | if(d<=Tol) { |
497 | IntPatch_Point OVTX(VTXN); |
498 | OVTX.SetParameter(ParamMinOnLine); |
499 | svtx.Prepend(OVTX); |
500 | } |
501 | } |
502 | } |
503 | } |
504 | } |
505 | } |
506 | //--------------------------------------------------------- |
507 | //-- Faut il supprimer le premier et le dernier point |
508 | //-- |
509 | nbvtx = NbVertex(); |
510 | if(nbvtx>1) { |
511 | IntPatch_Point& VTX0 = svtx.ChangeValue(1); |
7fd59977 |
512 | if( (VTX0.IsOnDomS1() == Standard_False) |
513 | && (VTX0.IsOnDomS2() == Standard_False)) { |
514 | svtx.Remove(1); |
515 | nbvtx--; |
516 | if(lapt) { |
517 | indl--; |
518 | } |
519 | } |
520 | } |
521 | if(nbvtx>1) { |
522 | IntPatch_Point& VTX0 = svtx.ChangeValue(nbvtx); |
7fd59977 |
523 | if( (VTX0.IsOnDomS1() == Standard_False) |
524 | && (VTX0.IsOnDomS2() == Standard_False)) { |
525 | svtx.Remove(nbvtx); |
498ce76b |
526 | if(lapt) { |
527 | indl--; |
7fd59977 |
528 | } |
529 | } |
530 | } |
531 | |
532 | //-- Si 2 vertex ont le meme parametre on identifie le p3d |
533 | nbvtx = NbVertex(); |
534 | do { |
535 | SortIsOK = Standard_True; |
536 | for(i=2; i<=nbvtx; i++) { |
537 | IntPatch_Point& VTX = svtx.ChangeValue(i); |
538 | IntPatch_Point& VTXm1 = svtx.ChangeValue(i-1); |
539 | if(Abs(VTX.ParameterOnLine()-VTXm1.ParameterOnLine())<PCONFUSION) { |
540 | if(VTX.IsOnDomS1() && VTXm1.IsOnDomS1()==Standard_False) { |
541 | VTXm1.SetArc(Standard_True, |
542 | VTX.ArcOnS1(), |
543 | VTX.ParameterOnArc1(), |
544 | VTX.TransitionLineArc1(), |
545 | VTX.TransitionOnS1()); |
546 | } |
547 | else if(VTXm1.IsOnDomS1() && VTX.IsOnDomS1()==Standard_False) { |
548 | VTX.SetArc(Standard_True, |
549 | VTXm1.ArcOnS1(), |
550 | VTXm1.ParameterOnArc1(), |
551 | VTXm1.TransitionLineArc1(), |
552 | VTXm1.TransitionOnS1()); |
553 | } |
554 | if(VTX.IsVertexOnS1() && VTXm1.IsVertexOnS1()==Standard_False) { |
555 | VTXm1.SetVertex(Standard_True, VTX.VertexOnS1()); |
556 | VTXm1.SetArc(Standard_True, |
557 | VTX.ArcOnS1(), |
558 | VTX.ParameterOnArc1(), |
559 | VTX.TransitionLineArc1(), |
560 | VTX.TransitionOnS1()); |
561 | } |
562 | else if(VTXm1.IsVertexOnS1() && VTX.IsVertexOnS1()==Standard_False) { |
563 | VTX.SetVertex(Standard_True, VTXm1.VertexOnS1()); |
564 | VTX.SetArc(Standard_True, |
565 | VTXm1.ArcOnS1(), |
566 | VTXm1.ParameterOnArc1(), |
567 | VTXm1.TransitionLineArc1(), |
568 | VTXm1.TransitionOnS1()); |
569 | } |
570 | |
571 | if(VTX.IsOnDomS2() && VTXm1.IsOnDomS2()==Standard_False) { |
572 | VTXm1.SetArc(Standard_False, |
573 | VTX.ArcOnS2(), |
574 | VTX.ParameterOnArc2(), |
575 | VTX.TransitionLineArc2(), |
576 | VTX.TransitionOnS2()); |
577 | } |
578 | else if(VTXm1.IsOnDomS2() && VTX.IsOnDomS2()==Standard_False) { |
579 | VTX.SetArc(Standard_False, |
580 | VTXm1.ArcOnS2(), |
581 | VTXm1.ParameterOnArc2(), |
582 | VTXm1.TransitionLineArc2(), |
583 | VTXm1.TransitionOnS2()); |
584 | } |
585 | if(VTX.IsVertexOnS2() && VTXm1.IsVertexOnS2()==Standard_False) { |
586 | VTXm1.SetVertex(Standard_False, VTX.VertexOnS2()); |
587 | VTXm1.SetArc(Standard_False, |
588 | VTX.ArcOnS2(), |
589 | VTX.ParameterOnArc2(), |
590 | VTX.TransitionLineArc2(), |
591 | VTX.TransitionOnS2()); |
592 | } |
593 | else if(VTXm1.IsVertexOnS2() && VTX.IsVertexOnS2()==Standard_False) { |
594 | VTX.SetVertex(Standard_False, VTXm1.VertexOnS2()); |
595 | VTX.SetArc(Standard_False, |
596 | VTXm1.ArcOnS2(), |
597 | VTXm1.ParameterOnArc2(), |
598 | VTXm1.TransitionLineArc2(), |
599 | VTXm1.TransitionOnS2()); |
600 | } |
601 | |
602 | if(VTX.Value().SquareDistance(VTXm1.Value()) > 1e-12) { |
603 | IntPatch_Point CopyVtx = VTXm1; |
604 | VTXm1.SetParameter(VTX.ParameterOnLine()); |
605 | VTXm1.SetValue(VTX.Value(),VTX.Tolerance(),VTX.IsTangencyPoint()); |
606 | Standard_Real u1,v1,u2,v2; |
607 | VTX.Parameters(u1,v1,u2,v2); |
608 | VTXm1.SetParameters(u1,v1,u2,v2); |
609 | if(CopyVtx.IsOnDomS1()) { |
610 | VTXm1.SetArc(Standard_True, |
611 | CopyVtx.ArcOnS1(), |
612 | CopyVtx.ParameterOnArc1(), |
613 | CopyVtx.TransitionLineArc1(), |
614 | CopyVtx.TransitionOnS1()); |
615 | } |
616 | if(CopyVtx.IsOnDomS2()) { |
617 | VTXm1.SetArc(Standard_False, |
618 | CopyVtx.ArcOnS2(), |
619 | CopyVtx.ParameterOnArc2(), |
620 | CopyVtx.TransitionLineArc2(), |
621 | CopyVtx.TransitionOnS2()); |
622 | } |
623 | if(CopyVtx.IsVertexOnS1()) { |
624 | VTXm1.SetVertex(Standard_True,CopyVtx.VertexOnS1()); |
625 | VTXm1.SetArc(Standard_True, |
626 | CopyVtx.ArcOnS1(), |
627 | CopyVtx.ParameterOnArc1(), |
628 | CopyVtx.TransitionLineArc1(), |
629 | CopyVtx.TransitionOnS1()); |
630 | } |
631 | if(CopyVtx.IsVertexOnS2()) { |
632 | VTXm1.SetVertex(Standard_False,CopyVtx.VertexOnS2()); |
633 | VTXm1.SetArc(Standard_False, |
634 | CopyVtx.ArcOnS2(), |
635 | CopyVtx.ParameterOnArc2(), |
636 | CopyVtx.TransitionLineArc2(), |
637 | CopyVtx.TransitionOnS2()); |
638 | } |
639 | |
640 | |
641 | SortIsOK=Standard_False; |
04232180 |
642 | //-- std::cout<<" IntPatch_ALine : ComputeVertexParameters : Ajust "<<std::endl; |
7fd59977 |
643 | } |
644 | } |
645 | } |
646 | } |
647 | while(!SortIsOK); |
648 | |
649 | /*nbvtx = NbVertex(); |
650 | for(Standard_Integer opopo = 1; opopo<=nbvtx; opopo++) { |
651 | svtx.Value(opopo).Dump(); |
652 | }*/ |
653 | } |