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