Commit | Line | Data |
---|---|---|
b311480e | 1 | // Created on: 1995-02-07 |
2 | // Created by: Jacques GOUSSARD | |
3 | // Copyright (c) 1995-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 | #include <GeomInt_LineConstructor.ixx> | |
23 | ||
24 | #include <GeomInt_LineTool.hxx> | |
25 | #include <GeomInt_SequenceOfParameterAndOrientation.hxx> | |
26 | #include <GeomInt_ParameterAndOrientation.hxx> | |
27 | ||
28 | #include <IntPatch_Point.hxx> | |
29 | #include <IntPatch_GLine.hxx> | |
30 | #include <IntPatch_WLine.hxx> | |
31 | #include <IntPatch_ALine.hxx> | |
32 | #include <IntSurf_Transition.hxx> | |
33 | #include <TopAbs_Orientation.hxx> | |
34 | ||
35 | #include <Precision.hxx> | |
36 | #include <gp_Pnt2d.hxx> | |
37 | #include <Adaptor2d_HCurve2d.hxx> | |
38 | ||
39 | #include <GeomAdaptor_HSurface.hxx> | |
40 | #include <Standard_ConstructionError.hxx> | |
41 | #include <IntSurf_Quadric.hxx> | |
42 | #include <IntSurf_PntOn2S.hxx> | |
43 | #include <ElCLib.hxx> | |
44 | #include <GeomAbs_SurfaceType.hxx> | |
45 | ||
46 | ||
47 | //======================================================================= | |
48 | //function : Recadre | |
49 | //purpose : | |
50 | //======================================================================= | |
51 | static void Recadre(const Handle(GeomAdaptor_HSurface)& myHS1, | |
52 | const Handle(GeomAdaptor_HSurface)& myHS2, | |
53 | Standard_Real& u1, | |
54 | Standard_Real& v1, | |
55 | Standard_Real& u2, | |
56 | Standard_Real& v2) | |
57 | { | |
58 | Standard_Boolean myHS1IsUPeriodic,myHS1IsVPeriodic; | |
59 | const GeomAbs_SurfaceType typs1 = myHS1->GetType(); | |
60 | switch (typs1) | |
61 | { | |
62 | case GeomAbs_Cylinder: | |
63 | case GeomAbs_Cone: | |
64 | case GeomAbs_Sphere: | |
65 | { | |
66 | myHS1IsUPeriodic = Standard_True; | |
67 | myHS1IsVPeriodic = Standard_False; | |
68 | break; | |
69 | } | |
70 | case GeomAbs_Torus: | |
71 | { | |
72 | myHS1IsUPeriodic = myHS1IsVPeriodic = Standard_True; | |
73 | break; | |
74 | } | |
75 | default: | |
76 | { | |
77 | //-- Le cas de biparametrees periodiques est gere en amont | |
78 | myHS1IsUPeriodic = myHS1IsVPeriodic = Standard_False; | |
79 | break; | |
80 | } | |
81 | } | |
82 | Standard_Boolean myHS2IsUPeriodic,myHS2IsVPeriodic; | |
83 | const GeomAbs_SurfaceType typs2 = myHS2->GetType(); | |
84 | switch (typs2) | |
85 | { | |
86 | case GeomAbs_Cylinder: | |
87 | case GeomAbs_Cone: | |
88 | case GeomAbs_Sphere: | |
89 | { | |
90 | myHS2IsUPeriodic = Standard_True; | |
91 | myHS2IsVPeriodic = Standard_False; | |
92 | break; | |
93 | } | |
94 | case GeomAbs_Torus: | |
95 | { | |
96 | myHS2IsUPeriodic = myHS2IsVPeriodic = Standard_True; | |
97 | break; | |
98 | } | |
99 | default: | |
100 | { | |
101 | //-- Le cas de biparametrees periodiques est gere en amont | |
102 | myHS2IsUPeriodic = myHS2IsVPeriodic = Standard_False; | |
103 | break; | |
104 | } | |
105 | } | |
106 | if(myHS1IsUPeriodic) { | |
c6541a0c | 107 | const Standard_Real lmf = M_PI+M_PI; //-- myHS1->UPeriod(); |
7fd59977 | 108 | const Standard_Real f = myHS1->FirstUParameter(); |
109 | const Standard_Real l = myHS1->LastUParameter(); | |
110 | while(u1 < f) { u1+=lmf; } | |
111 | while(u1 > l) { u1-=lmf; } | |
112 | } | |
113 | if(myHS1IsVPeriodic) { | |
c6541a0c | 114 | const Standard_Real lmf = M_PI+M_PI; //-- myHS1->VPeriod(); |
7fd59977 | 115 | const Standard_Real f = myHS1->FirstVParameter(); |
116 | const Standard_Real l = myHS1->LastVParameter(); | |
117 | while(v1 < f) { v1+=lmf; } | |
118 | while(v1 > l) { v1-=lmf; } | |
119 | } | |
120 | if(myHS2IsUPeriodic) { | |
c6541a0c | 121 | const Standard_Real lmf = M_PI+M_PI; //-- myHS2->UPeriod(); |
7fd59977 | 122 | const Standard_Real f = myHS2->FirstUParameter(); |
123 | const Standard_Real l = myHS2->LastUParameter(); | |
124 | while(u2 < f) { u2+=lmf; } | |
125 | while(u2 > l) { u2-=lmf; } | |
126 | } | |
127 | if(myHS2IsVPeriodic) { | |
c6541a0c | 128 | const Standard_Real lmf = M_PI+M_PI; //-- myHS2->VPeriod(); |
7fd59977 | 129 | const Standard_Real f = myHS2->FirstVParameter(); |
130 | const Standard_Real l = myHS2->LastVParameter(); | |
131 | while(v2 < f) { v2+=lmf; } | |
132 | while(v2 > l) { v2-=lmf; } | |
133 | } | |
134 | } | |
135 | ||
136 | ||
137 | //======================================================================= | |
138 | //function : Parameters | |
139 | //purpose : | |
140 | //======================================================================= | |
141 | static void Parameters(const Handle(GeomAdaptor_HSurface)& myHS1, | |
142 | const Handle(GeomAdaptor_HSurface)& myHS2, | |
143 | const gp_Pnt& Ptref, | |
144 | Standard_Real& U1, | |
145 | Standard_Real& V1, | |
146 | Standard_Real& U2, | |
147 | Standard_Real& V2) | |
148 | { | |
149 | IntSurf_Quadric quad1,quad2; | |
150 | switch (myHS1->Surface().GetType()) | |
151 | { | |
152 | case GeomAbs_Plane: quad1.SetValue(myHS1->Surface().Plane()); break; | |
153 | case GeomAbs_Cylinder: quad1.SetValue(myHS1->Surface().Cylinder()); break; | |
154 | case GeomAbs_Cone: quad1.SetValue(myHS1->Surface().Cone()); break; | |
155 | case GeomAbs_Sphere: quad1.SetValue(myHS1->Surface().Sphere()); break; | |
156 | default: Standard_ConstructionError::Raise("GeomInt_LineConstructor::Parameters"); | |
157 | } | |
158 | switch (myHS2->Surface().GetType()) | |
159 | { | |
160 | case GeomAbs_Plane: quad2.SetValue(myHS2->Surface().Plane()); break; | |
161 | case GeomAbs_Cylinder: quad2.SetValue(myHS2->Surface().Cylinder()); break; | |
162 | case GeomAbs_Cone: quad2.SetValue(myHS2->Surface().Cone()); break; | |
163 | case GeomAbs_Sphere: quad2.SetValue(myHS2->Surface().Sphere()); break; | |
164 | default: Standard_ConstructionError::Raise("GeomInt_LineConstructor::Parameters"); | |
165 | } | |
166 | quad1.Parameters(Ptref,U1,V1); | |
167 | quad2.Parameters(Ptref,U2,V2); | |
168 | } | |
169 | ||
170 | ||
171 | //======================================================================= | |
172 | //function : Perform | |
173 | //purpose : | |
174 | //======================================================================= | |
175 | void GeomInt_LineConstructor::Perform(const Handle(IntPatch_Line)& L) | |
176 | { | |
177 | Standard_Integer i,nbvtx; | |
178 | Standard_Real firstp,lastp; | |
179 | const Standard_Real Tol = Precision::PConfusion() * 35.0; | |
180 | ||
181 | const IntPatch_IType typl = L->ArcType(); | |
182 | if(typl == IntPatch_Analytic) | |
183 | { | |
184 | Standard_Real u1,v1,u2,v2; | |
185 | Handle(IntPatch_ALine)& ALine = *((Handle(IntPatch_ALine) *)&L); | |
186 | seqp.Clear(); | |
187 | nbvtx = GeomInt_LineTool::NbVertex(L); | |
188 | for(i=1;i<nbvtx;i++) | |
189 | { | |
190 | firstp = GeomInt_LineTool::Vertex(L,i).ParameterOnLine(); | |
191 | lastp = GeomInt_LineTool::Vertex(L,i+1).ParameterOnLine(); | |
192 | if(firstp!=lastp) | |
193 | { | |
194 | const Standard_Real pmid = (firstp+lastp)*0.5; | |
195 | const gp_Pnt Pmid = ALine->Value(pmid); | |
196 | Parameters(myHS1,myHS2,Pmid,u1,v1,u2,v2); | |
197 | Recadre(myHS1,myHS2,u1,v1,u2,v2); | |
198 | const TopAbs_State in1 = myDom1->Classify(gp_Pnt2d(u1,v1),Tol); | |
199 | if(in1 != TopAbs_OUT) { | |
200 | const TopAbs_State in2 = myDom2->Classify(gp_Pnt2d(u2,v2),Tol); | |
201 | if(in2 != TopAbs_OUT) { | |
202 | seqp.Append(firstp); | |
203 | seqp.Append(lastp); | |
204 | } | |
205 | } | |
206 | } | |
207 | } | |
208 | done = Standard_True; | |
209 | return; | |
210 | } | |
211 | else if(typl == IntPatch_Walking) | |
212 | { | |
213 | Standard_Real u1,v1,u2,v2; | |
214 | Handle(IntPatch_WLine)& WLine = *((Handle(IntPatch_WLine) *)&L); | |
215 | seqp.Clear(); | |
216 | nbvtx = GeomInt_LineTool::NbVertex(L); | |
217 | for(i=1;i<nbvtx;i++) | |
218 | { | |
219 | firstp = GeomInt_LineTool::Vertex(L,i).ParameterOnLine(); | |
220 | lastp = GeomInt_LineTool::Vertex(L,i+1).ParameterOnLine(); | |
221 | if(firstp!=lastp) | |
222 | { | |
223 | const Standard_Integer pmid = (Standard_Integer )( (firstp+lastp)/2); | |
224 | const IntSurf_PntOn2S& Pmid = WLine->Point(pmid); | |
225 | Pmid.Parameters(u1,v1,u2,v2); | |
226 | Recadre(myHS1,myHS2,u1,v1,u2,v2); | |
227 | const TopAbs_State in1 = myDom1->Classify(gp_Pnt2d(u1,v1),Tol); | |
228 | if(in1 != TopAbs_OUT) { //-- !=ON donne Pb | |
229 | const TopAbs_State in2 = myDom2->Classify(gp_Pnt2d(u2,v2),Tol); | |
230 | if(in2 != TopAbs_OUT) { //-- !=ON | |
231 | seqp.Append(firstp); | |
232 | seqp.Append(lastp); | |
233 | } | |
234 | } | |
235 | } | |
236 | } | |
237 | done = Standard_True; | |
238 | return; | |
239 | } | |
240 | else if (typl != IntPatch_Restriction) | |
241 | { | |
242 | Standard_Real u1,v1,u2,v2; | |
243 | Handle(IntPatch_GLine)& GLine = *((Handle(IntPatch_GLine) *)&L); | |
244 | seqp.Clear(); | |
245 | nbvtx = GeomInt_LineTool::NbVertex(L); | |
246 | Standard_Boolean intrvtested = Standard_False; | |
247 | for(i=1;i<nbvtx;i++) | |
248 | { | |
249 | firstp = GeomInt_LineTool::Vertex(L,i).ParameterOnLine(); | |
250 | lastp = GeomInt_LineTool::Vertex(L,i+1).ParameterOnLine(); | |
251 | if(Abs(firstp-lastp)>Precision::PConfusion()) | |
252 | { | |
253 | intrvtested = Standard_True; | |
254 | const Standard_Real pmid = (firstp+lastp)*0.5; | |
255 | gp_Pnt Pmid; | |
256 | switch (typl) | |
257 | { | |
258 | case IntPatch_Lin: Pmid = ElCLib::Value(pmid,GLine->Line()); break; | |
259 | case IntPatch_Circle: Pmid = ElCLib::Value(pmid,GLine->Circle()); break; | |
260 | case IntPatch_Ellipse: Pmid = ElCLib::Value(pmid,GLine->Ellipse()); break; | |
261 | case IntPatch_Hyperbola: Pmid = ElCLib::Value(pmid,GLine->Hyperbola()); break; | |
262 | case IntPatch_Parabola: Pmid = ElCLib::Value(pmid,GLine->Parabola()); break; | |
566f8441 | 263 | case IntPatch_Analytic: |
264 | case IntPatch_Walking: | |
265 | case IntPatch_Restriction: break; // cases Analytic, Walking and Restriction are handled above | |
7fd59977 | 266 | } |
267 | Parameters(myHS1,myHS2,Pmid,u1,v1,u2,v2); | |
268 | Recadre(myHS1,myHS2,u1,v1,u2,v2); | |
269 | const TopAbs_State in1 = myDom1->Classify(gp_Pnt2d(u1,v1),Tol); | |
270 | if(in1 != TopAbs_OUT) { | |
271 | const TopAbs_State in2 = myDom2->Classify(gp_Pnt2d(u2,v2),Tol); | |
272 | if(in2 != TopAbs_OUT) { | |
273 | seqp.Append(firstp); | |
274 | seqp.Append(lastp); | |
275 | } | |
276 | } | |
277 | } | |
278 | } | |
279 | if(typl == IntPatch_Circle || typl == IntPatch_Ellipse) | |
280 | { | |
281 | firstp = GeomInt_LineTool::Vertex(L,nbvtx).ParameterOnLine(); | |
c6541a0c | 282 | lastp = M_PI + M_PI + GeomInt_LineTool::Vertex(L,1).ParameterOnLine(); |
7fd59977 | 283 | const Standard_Real cadrinf = GeomInt_LineTool::FirstParameter(L); |
284 | const Standard_Real cadrsup = GeomInt_LineTool::LastParameter(L); | |
285 | Standard_Real acadr = (firstp+lastp)*0.5; | |
c6541a0c D |
286 | while(acadr < cadrinf) { acadr+=M_PI+M_PI; } |
287 | while(acadr > cadrsup) { acadr-=M_PI+M_PI; } | |
7fd59977 | 288 | if(acadr>=cadrinf && acadr<=cadrsup) |
289 | { | |
290 | if(Abs(firstp-lastp)>Precision::PConfusion()) | |
291 | { | |
292 | intrvtested = Standard_True; | |
293 | const Standard_Real pmid = (firstp+lastp)*0.5; | |
294 | gp_Pnt Pmid; | |
295 | if (typl == IntPatch_Circle) | |
296 | Pmid = ElCLib::Value(pmid,GLine->Circle()); | |
297 | else | |
298 | Pmid = ElCLib::Value(pmid,GLine->Ellipse()); | |
299 | Parameters(myHS1,myHS2,Pmid,u1,v1,u2,v2); | |
300 | Recadre(myHS1,myHS2,u1,v1,u2,v2); | |
301 | const TopAbs_State in1 = myDom1->Classify(gp_Pnt2d(u1,v1),Tol); | |
302 | if(in1 != TopAbs_OUT) { | |
303 | const TopAbs_State in2 = myDom2->Classify(gp_Pnt2d(u2,v2),Tol); | |
304 | if(in2 != TopAbs_OUT) { | |
305 | seqp.Append(firstp); | |
306 | seqp.Append(lastp); | |
307 | } | |
308 | } | |
309 | } | |
310 | } | |
311 | } | |
312 | if (!intrvtested) { | |
313 | // on garde a priori. Il faudrait un point 2d sur chaque | |
314 | // surface pour prendre la decision. Sera fait dans | |
315 | // l`appelant | |
316 | seqp.Append(GeomInt_LineTool::FirstParameter(L)); | |
317 | seqp.Append(GeomInt_LineTool::LastParameter(L)); | |
318 | } | |
319 | done = Standard_True; | |
320 | return; | |
321 | } | |
322 | ||
323 | done = Standard_False; | |
324 | seqp.Clear(); | |
325 | nbvtx = GeomInt_LineTool::NbVertex(L); | |
326 | if (nbvtx == 0) { // on garde a priori. Il faudrait un point 2d sur chaque | |
327 | // surface pour prendre la decision. Sera fait dans | |
328 | // l`appelant | |
329 | seqp.Append(GeomInt_LineTool::FirstParameter(L)); | |
330 | seqp.Append(GeomInt_LineTool::LastParameter(L)); | |
331 | done = Standard_True; | |
332 | return; | |
333 | } | |
334 | ||
335 | GeomInt_SequenceOfParameterAndOrientation seqpss; | |
336 | TopAbs_Orientation or1=TopAbs_FORWARD,or2=TopAbs_FORWARD; | |
337 | ||
338 | for (i=1; i<=nbvtx; i++) | |
339 | { | |
340 | const IntPatch_Point& thevtx = GeomInt_LineTool::Vertex(L,i); | |
341 | const Standard_Real prm = thevtx.ParameterOnLine(); | |
342 | if (thevtx.IsOnDomS1()) | |
343 | { | |
344 | switch (thevtx.TransitionLineArc1().TransitionType()) | |
345 | { | |
346 | case IntSurf_In: or1 = TopAbs_FORWARD; break; | |
347 | case IntSurf_Out: or1 = TopAbs_REVERSED; break; | |
348 | case IntSurf_Touch: or1 = TopAbs_INTERNAL; break; | |
349 | case IntSurf_Undecided: or1 = TopAbs_INTERNAL; break; | |
350 | } | |
351 | } | |
352 | else | |
353 | or1 = TopAbs_INTERNAL; | |
354 | ||
355 | if (thevtx.IsOnDomS2()) | |
356 | { | |
357 | switch (thevtx.TransitionLineArc2().TransitionType()) | |
358 | { | |
359 | case IntSurf_In: or2 = TopAbs_FORWARD; break; | |
360 | case IntSurf_Out: or2 = TopAbs_REVERSED; break; | |
361 | case IntSurf_Touch: or2 = TopAbs_INTERNAL; break; | |
362 | case IntSurf_Undecided: or2 = TopAbs_INTERNAL; break; | |
363 | } | |
364 | } | |
365 | else | |
366 | or2 = TopAbs_INTERNAL; | |
367 | ||
368 | const Standard_Integer nbinserted = seqpss.Length(); | |
369 | Standard_Boolean inserted = Standard_False; | |
370 | for (Standard_Integer j=1; j<=nbinserted;j++) | |
371 | { | |
372 | if (Abs(prm-seqpss(j).Parameter()) <= Tol) | |
373 | { | |
374 | // on cumule | |
375 | GeomInt_ParameterAndOrientation& valj = seqpss.ChangeValue(j); | |
376 | if (or1 != TopAbs_INTERNAL) { | |
377 | if (valj.Orientation1() != TopAbs_INTERNAL) { | |
378 | if (or1 != valj.Orientation1()) { | |
379 | valj.SetOrientation1(TopAbs_INTERNAL); | |
380 | } | |
381 | } | |
382 | else { | |
383 | valj.SetOrientation1(or1); | |
384 | } | |
385 | } | |
386 | ||
387 | if (or2 != TopAbs_INTERNAL) { | |
388 | if (valj.Orientation2() != TopAbs_INTERNAL) { | |
389 | if (or2 != valj.Orientation2()) { | |
390 | valj.SetOrientation2(TopAbs_INTERNAL); | |
391 | } | |
392 | } | |
393 | else { | |
394 | valj.SetOrientation2(or2); | |
395 | } | |
396 | } | |
397 | ||
398 | inserted = Standard_True; | |
399 | break; | |
400 | } | |
401 | ||
402 | if (prm < seqpss(j).Parameter()-Tol ) { | |
403 | // on insere avant la position j | |
404 | seqpss.InsertBefore(j,GeomInt_ParameterAndOrientation(prm,or1,or2)); | |
405 | inserted = Standard_True; | |
406 | break; | |
407 | } | |
408 | } | |
409 | if (!inserted) { | |
410 | seqpss.Append(GeomInt_ParameterAndOrientation(prm,or1,or2)); | |
411 | } | |
412 | } | |
413 | ||
414 | // on determine l`etat en debut de ligne | |
415 | Standard_Boolean trim = Standard_False; | |
416 | Standard_Boolean dansS1 = Standard_False; | |
417 | Standard_Boolean dansS2 = Standard_False; | |
418 | ||
419 | nbvtx = seqpss.Length(); | |
420 | for (i=1; i<= nbvtx; i++) | |
421 | { | |
422 | or1 = seqpss(i).Orientation1(); | |
423 | if (or1 != TopAbs_INTERNAL) | |
424 | { | |
425 | trim = Standard_True; | |
426 | dansS1 = (or1 != TopAbs_FORWARD); | |
427 | break; | |
428 | } | |
429 | } | |
430 | ||
431 | if (i > nbvtx) | |
432 | { | |
433 | Standard_Real U,V; | |
434 | for (i=1; i<=GeomInt_LineTool::NbVertex(L); i++ ) | |
435 | { | |
436 | if (!GeomInt_LineTool::Vertex(L,i).IsOnDomS1() ) | |
437 | { | |
438 | GeomInt_LineTool::Vertex(L,i).ParametersOnS1(U,V); | |
439 | gp_Pnt2d PPCC(U,V); | |
440 | if (myDom1->Classify(PPCC,Tol) == TopAbs_OUT) { | |
441 | done = Standard_True; | |
442 | return; | |
443 | } | |
444 | break; | |
445 | } | |
446 | } | |
447 | dansS1 = Standard_True; // on garde dans le doute | |
448 | } | |
449 | ||
450 | for (i=1; i<= nbvtx; i++) | |
451 | { | |
452 | or2 = seqpss(i).Orientation2(); | |
453 | if (or2 != TopAbs_INTERNAL) | |
454 | { | |
455 | trim = Standard_True; | |
456 | dansS2 = (or2 != TopAbs_FORWARD); | |
457 | break; | |
458 | } | |
459 | } | |
460 | ||
461 | if (i > nbvtx) | |
462 | { | |
463 | Standard_Real U,V; | |
464 | for (i=1; i<=GeomInt_LineTool::NbVertex(L); i++ ) | |
465 | { | |
466 | if (!GeomInt_LineTool::Vertex(L,i).IsOnDomS2() ) | |
467 | { | |
468 | GeomInt_LineTool::Vertex(L,i).ParametersOnS2(U,V); | |
469 | if (myDom2->Classify(gp_Pnt2d(U,V),Tol) == TopAbs_OUT) { | |
470 | done = Standard_True; | |
471 | return; | |
472 | } | |
473 | break; | |
474 | } | |
475 | } | |
476 | dansS2 = Standard_True; // on garde dans le doute | |
477 | } | |
478 | ||
479 | if (!trim) { // on a necessairement dansS1 == dansS2 == Standard_True | |
480 | seqp.Append(GeomInt_LineTool::FirstParameter(L)); | |
481 | seqp.Append(GeomInt_LineTool::LastParameter(L)); | |
482 | done = Standard_True; | |
483 | return; | |
484 | } | |
485 | ||
486 | // On epluche la sequence seqpss pour constituer les bouts valides | |
487 | // et les stocker dans seqp(2*i+1) et seqp(2*i+2) | |
488 | Standard_Real thefirst = GeomInt_LineTool::FirstParameter(L); | |
489 | Standard_Real thelast = GeomInt_LineTool::LastParameter(L); | |
490 | firstp = thefirst; | |
491 | ||
492 | for (i=1; i<=nbvtx; i++) | |
493 | { | |
494 | or1 = seqpss(i).Orientation1(); | |
495 | or2 = seqpss(i).Orientation2(); | |
496 | if (dansS1 && dansS2) | |
497 | { | |
498 | if (or1 == TopAbs_REVERSED) | |
499 | dansS1 = Standard_False; | |
500 | /*else if (or1 == TopAbs_FORWARD) { | |
501 | }*/ | |
502 | if (or2 == TopAbs_REVERSED) | |
503 | dansS2 = Standard_False; | |
504 | /*else if (or2 == TopAbs_FORWARD) { | |
505 | }*/ | |
506 | if (!dansS1 || !dansS2) | |
507 | { | |
508 | lastp = seqpss(i).Parameter(); | |
509 | Standard_Real stofirst = Max(firstp, thefirst); | |
510 | Standard_Real stolast = Min(lastp, thelast) ; | |
511 | if (stolast > stofirst) { | |
512 | seqp.Append(stofirst); | |
513 | seqp.Append(stolast); | |
514 | } | |
515 | if (lastp > thelast) | |
516 | break; | |
517 | } | |
518 | } | |
519 | else | |
520 | { | |
521 | if (dansS1) | |
522 | { | |
523 | if (or1 == TopAbs_REVERSED) | |
524 | dansS1 = Standard_False; | |
525 | /*else if (or1 == TopAbs_FORWARD) { | |
526 | }*/ | |
527 | } | |
528 | else | |
529 | { | |
530 | if (or1 == TopAbs_FORWARD) | |
531 | dansS1 = Standard_True; | |
532 | /*else if (or1 == TopAbs_REVERSED) { | |
533 | }*/ | |
534 | } | |
535 | if (dansS2) | |
536 | { | |
537 | if (or2 == TopAbs_REVERSED) | |
538 | dansS2 = Standard_False; | |
539 | /*else if (or2 == TopAbs_FORWARD) { | |
540 | }*/ | |
541 | } | |
542 | else | |
543 | { | |
544 | if (or2 == TopAbs_FORWARD) | |
545 | dansS2 = Standard_True; | |
546 | /*else if (or2 == TopAbs_REVERSED) { | |
547 | }*/ | |
548 | } | |
549 | if (dansS1 && dansS2) | |
550 | firstp = seqpss(i).Parameter(); | |
551 | } | |
552 | } | |
553 | ||
554 | // le petit dernier a rajouter | |
555 | if (dansS1 && dansS2) | |
556 | { | |
557 | lastp = thelast; | |
558 | firstp = Max(firstp,thefirst); | |
559 | if (lastp > firstp) { | |
560 | seqp.Append(firstp); | |
561 | seqp.Append(lastp); | |
562 | } | |
563 | } | |
564 | done = Standard_True; | |
565 | } | |
566 | ||
567 | ||
568 | //======================================================================= | |
569 | //function : PeriodicLine | |
570 | //purpose : | |
571 | //======================================================================= | |
572 | void GeomInt_LineConstructor::PeriodicLine (const Handle(IntPatch_Line)& L) const | |
573 | { | |
574 | const IntPatch_IType typl = L->ArcType(); | |
575 | if (typl != IntPatch_Circle && typl != IntPatch_Ellipse) | |
576 | return; | |
577 | ||
578 | const Standard_Real Tol = Precision::PConfusion(); | |
579 | Handle(IntPatch_GLine) glin = Handle(IntPatch_GLine)::DownCast(L); | |
580 | Standard_Integer i,j,nbvtx = glin->NbVertex(); | |
581 | for (i=1; i<=nbvtx; i++) | |
582 | { | |
583 | IntPatch_Point thevtx = glin->Vertex(i); | |
584 | const Standard_Real prm = thevtx.ParameterOnLine(); | |
585 | Standard_Boolean changevtx = Standard_False; | |
586 | if (thevtx.IsOnDomS1() || thevtx.IsOnDomS2()) | |
587 | { | |
588 | for (j=1; j<=nbvtx; j++) | |
589 | { | |
590 | if (j!=i) | |
591 | { | |
592 | const IntPatch_Point& thevtxbis = glin->Vertex(j); | |
593 | const Standard_Real prmbis = thevtxbis.ParameterOnLine(); | |
594 | if (Abs(prm-prmbis) <= Tol) | |
595 | { | |
596 | Standard_Real u,v; | |
597 | gp_Pnt2d p2d; | |
598 | if (thevtx.IsOnDomS1() && thevtxbis.IsOnDomS1() && | |
599 | thevtxbis.TransitionLineArc1().TransitionType()==IntSurf_In) | |
600 | { | |
601 | p2d = thevtx.ArcOnS1()->Value(thevtx.ParameterOnArc1()); | |
602 | u = p2d.X(); v = p2d.Y(); | |
603 | p2d = thevtxbis.ArcOnS1()->Value(thevtxbis.ParameterOnArc1()); | |
604 | if (Abs(u-p2d.X()) > Tol || Abs(v-p2d.Y()) > Tol) | |
605 | { | |
606 | changevtx = Standard_True; | |
607 | break; | |
608 | } | |
609 | } | |
610 | if (thevtx.IsOnDomS2() && thevtxbis.IsOnDomS2() && | |
611 | thevtxbis.TransitionLineArc2().TransitionType()==IntSurf_In) | |
612 | { | |
613 | p2d = thevtx.ArcOnS2()->Value(thevtx.ParameterOnArc2()); | |
614 | u = p2d.X(); v = p2d.Y(); | |
615 | p2d = thevtxbis.ArcOnS2()->Value(thevtxbis.ParameterOnArc2()); | |
616 | if (Abs(u-p2d.X()) > Tol || Abs(v-p2d.Y()) > Tol) | |
617 | { | |
618 | changevtx = Standard_True; | |
619 | break; | |
620 | } | |
621 | } | |
622 | } | |
623 | } | |
624 | } | |
625 | } | |
626 | if (changevtx) { | |
c6541a0c | 627 | thevtx.SetParameter(prm + 2.*M_PI); |
7fd59977 | 628 | glin->Replace(i,thevtx); |
629 | } | |
630 | } | |
631 | } |