0022922: Clean up warnings on uninitialized / unused variables
[occt.git] / src / BRepOffset / BRepOffset_Inter2d.cxx
CommitLineData
7fd59977 1// File: BRepOffset_Inter2d.cxx
2// Created: Tue Sep 3 16:37:35 1996
3// Author: Yves FRICAUD
4// <yfr@claquox.paris1.matra-dtv.fr>
5
6// Modified by skv - Wed Dec 24 18:08:39 2003 OCC4455
7
8#include <stdio.h>
9
10#include <BRepOffset_Inter2d.ixx>
11#include <BRepAlgo_AsDes.hxx>
12#include <BRepOffset_Offset.hxx>
13#include <BRepOffset_Tool.hxx>
14
15#include <BRep_Builder.hxx>
16#include <BRep_Tool.hxx>
17#include <BRepLib_MakeVertex.hxx>
18#include <BRepAdaptor_Curve.hxx>
19#include <BRepAdaptor_Surface.hxx>
20#include <BRepTools_WireExplorer.hxx>
21#include <TopExp.hxx>
22#include <TopExp_Explorer.hxx>
23#include <TopoDS_Iterator.hxx>
24
25#include <TopoDS.hxx>
26#include <TopoDS_Edge.hxx>
27#include <TopoDS_Vertex.hxx>
28#include <TopoDS_Wire.hxx>
29#include <TopTools_ListOfShape.hxx>
30#include <TopTools_ListIteratorOfListOfShape.hxx>
31#include <TopTools_DataMapIteratorOfDataMapOfShapeListOfShape.hxx>
32#include <gp_Pnt.hxx>
33#include <BRep_TEdge.hxx>
34#include <BRep_ListIteratorOfListOfCurveRepresentation.hxx>
35#include <BRep_CurveRepresentation.hxx>
36#include <BRep_GCurve.hxx>
37
38#ifdef DRAW
39#include <DBRep.hxx>
40#endif
41#ifdef DEB
42#ifndef WNT
43extern Standard_Integer AffichInt2d;
44#else
45Standard_IMPORT Standard_Boolean AffichInt2d;
46#endif
47static Standard_Integer NbF2d = 0;
48static Standard_Integer NbE2d = 0;
49static Standard_Integer NbNewVertices = 0;
50#endif
51
52#include <Geom_Line.hxx>
53#include <Geom_TrimmedCurve.hxx>
54#include <GeomConvert_CompCurveToBSplineCurve.hxx>
55#include <Precision.hxx>
56#include <Geom2d_TrimmedCurve.hxx>
57#include <Geom2d_BezierCurve.hxx>
58#include <Geom2d_BSplineCurve.hxx>
59#include <Geom2d_Line.hxx>
60#include <Geom2dConvert_CompCurveToBSplineCurve.hxx>
61
62#include <BRepLib.hxx>
63#include <BRepAdaptor_Curve2d.hxx>
64#include <Adaptor3d_HSurface.hxx>
65#include <Adaptor3d_CurveOnSurface.hxx>
66#include <Geom_BSplineSurface.hxx>
67#include <Geom_CylindricalSurface.hxx>
68#include <Geom_ConicalSurface.hxx>
69#include <Adaptor2d_HCurve2d.hxx>
70#include <TColGeom2d_SequenceOfCurve.hxx>
71#include <Geom2dInt_GInter.hxx>
72#include <IntRes2d_IntersectionPoint.hxx>
73#include <IntRes2d_IntersectionSegment.hxx>
74#include <GeomAPI_ProjectPointOnCurve.hxx>
75#include <GeomAdaptor_Surface.hxx>
76#include <Geom2dAdaptor_HCurve.hxx>
77#include <GeomAdaptor_HSurface.hxx>
78#include <GeomLib.hxx>
79#include <GeomProjLib.hxx>
80#include <TColgp_SequenceOfPnt.hxx>
81#include <TColgp_Array1OfPnt2d.hxx>
82#include <Bnd_Box.hxx>
83#include <BndLib_Add3dCurve.hxx>
84#include <BRepTools.hxx>
85
86
87//=======================================================================
88//function : CommonVertex
89//purpose :
90//=======================================================================
91
92static TopoDS_Vertex CommonVertex(TopoDS_Edge& E1,
93 TopoDS_Edge& E2)
94{
95 TopoDS_Vertex V1[2],V2[2],V;
96 // Modified by skv - Wed Dec 24 18:08:39 2003 OCC4455 Begin
97// TopExp::Vertices(E1,V1[0],V1[1]);
98// TopExp::Vertices(E2,V2[0],V2[1]);
99
100 TopExp::Vertices(E1,V1[0],V1[1], Standard_True);
101 TopExp::Vertices(E2,V2[0],V2[1], Standard_True);
102 // The first edge is the current one, the second edge is the next one.
103 // We check last vertex of the first edge first.
104// if (V1[0].IsSame(V2[0]) || V1[0].IsSame(V2[1])) return V1[0];
105// if (V1[1].IsSame(V2[0]) || V1[1].IsSame(V2[1])) return V1[1];
106 if (V1[1].IsSame(V2[0]) || V1[1].IsSame(V2[1])) return V1[1];
107 if (V1[0].IsSame(V2[0]) || V1[0].IsSame(V2[1])) return V1[0];
108 // Modified by skv - Wed Dec 24 18:08:40 2003 OCC4455 End
109 return V;
110}
111
112//=======================================================================
113//function : Store
114//purpose :
115//=======================================================================
116
117static void Store (const TopoDS_Edge& E1,
118 const TopoDS_Edge& E2,
119 TopTools_ListOfShape& LV1,
120 TopTools_ListOfShape& LV2,
121 Handle(BRepAlgo_AsDes) AsDes,
122 Standard_Real Tol)
123{
124 //-------------------------------------------------------------
0d969553
Y
125 // Test if the points of intersection correspond to existing
126 // vertices. Otherwise add edges in the descendants.
127 // Note: at this stage only vertices of intersection are in the descendants.
7fd59977 128 //-------------------------------------------------------------
129 const TopTools_ListOfShape& VOnE1 = AsDes->Descendant(E1);
130 const TopTools_ListOfShape& VOnE2 = AsDes->Descendant(E2);
131 TopTools_ListOfShape NewVOnE1;
132 TopTools_ListOfShape NewVOnE2;
133 gp_Pnt P,P1,P2;
134 TopoDS_Vertex V1,V2;
135 TopTools_ListIteratorOfListOfShape it, itLV1, itLV2;
136 BRep_Builder B;
137 TopAbs_Orientation O1,O2;
138 Standard_Real U1,U2;
139 Standard_Boolean OnE1,OnE2;
140
141 for (itLV1.Initialize(LV1),itLV2.Initialize(LV2);
142 itLV1.More();
143 itLV1.Next() ,itLV2.Next()) {
144
145 TopoDS_Vertex V = TopoDS::Vertex(itLV1.Value());
146
975ec82a
J
147 U1 = (BRep_Tool::Degenerated(E1))?
148 BRep_Tool::Parameter(TopoDS::Vertex(V.Oriented(TopAbs_INTERNAL)), E1) :
149 BRep_Tool::Parameter(V, E1);
150 U2 = (BRep_Tool::Degenerated(E2))?
151 BRep_Tool::Parameter(TopoDS::Vertex(V.Oriented(TopAbs_INTERNAL)), E2) :
152 BRep_Tool::Parameter(V, E2);
7fd59977 153 O1 = V.Orientation();
154 O2 = itLV2.Value().Orientation();
155 P = BRep_Tool::Pnt(V);
156 OnE1 = OnE2 = Standard_False;
157
158 if (!VOnE1.IsEmpty()) {
159 //-----------------------------------------------------------------
0d969553 160 // Find if the point of intersection corresponds to a vertex of E1.
7fd59977 161 //-----------------------------------------------------------------
162 for (it.Initialize(VOnE1); it.More(); it.Next()) {
163 P1 = BRep_Tool::Pnt(TopoDS::Vertex(it.Value()));
164 if (P.IsEqual(P1,Tol)) {
165 V = TopoDS::Vertex(it.Value());
166 V1 = V;
167 OnE1 = Standard_True;
168 break;
169 }
170 }
171 }
172 if (!VOnE2.IsEmpty()) {
173 if (OnE1) {
174 //-----------------------------------------------------------------
0d969553 175 // Find if the vertex found on E1 is not already on E2.
7fd59977 176 //-----------------------------------------------------------------
177 for (it.Initialize(VOnE2); it.More(); it.Next()) {
178 if (it.Value().IsSame(V)) {
179 OnE2 = Standard_True;
180 V2 = V;
181 break;
182 }
183 }
184 }
185 for (it.Initialize(VOnE2); it.More(); it.Next()) {
186 //-----------------------------------------------------------------
0d969553 187 // Find if the point of intersection corresponds to a vertex of E2.
7fd59977 188 //-----------------------------------------------------------------
189 P2 = BRep_Tool::Pnt(TopoDS::Vertex(it.Value()));
190 if (P.IsEqual(P2,Tol)) {
191 V = TopoDS::Vertex(it.Value());
192 V2 = V;
193 OnE2 = Standard_True;
194 break;
195 }
196 }
197 }
198 if (OnE1 && OnE2) {
199 if (!V1.IsSame(V2)) {
200 //---------------------------------------------------------------
0d969553
Y
201 // Two vertices are actually the same.
202 // V2 will be replaced by V1.
203 // update the parameters of vertex on edges.
7fd59977 204 //---------------------------------------------------------------
205 Standard_Real UV2;
206 TopoDS_Edge EWE2;
207 const TopTools_ListOfShape& EdgeWithV2 = AsDes->Ascendant(V2);
208
209 for (it.Initialize(EdgeWithV2); it.More(); it.Next()) {
210 EWE2 = TopoDS::Edge(it.Value());
211 TopoDS_Shape aLocalShape =V2.Oriented(TopAbs_INTERNAL);
212 UV2 = BRep_Tool::Parameter(TopoDS::Vertex(aLocalShape),EWE2);
213// UV2 =
214// BRep_Tool::Parameter(TopoDS::Vertex(V2.Oriented(TopAbs_INTERNAL)),EWE2);
215 aLocalShape = V1.Oriented(TopAbs_INTERNAL);
216 B.UpdateVertex(TopoDS::Vertex(aLocalShape),UV2,EWE2,Tol);
217// B.UpdateVertex(TopoDS::Vertex(V1.Oriented(TopAbs_INTERNAL)),
218// UV2,EWE2,Tol);
219 }
220 AsDes->Replace(V2,V1);
221 }
222 }
223 if (!OnE1) {
224 if (OnE2) {
225 TopoDS_Shape aLocalShape = V.Oriented(TopAbs_INTERNAL);
226 B.UpdateVertex(TopoDS::Vertex(aLocalShape),U1,E1,Tol);
227// B.UpdateVertex(TopoDS::Vertex(V.Oriented(TopAbs_INTERNAL)),
228// U1,E1,Tol);
229 }
230 NewVOnE1.Append(V.Oriented(O1));
231 }
232 if (!OnE2) {
233 if (OnE1) {
234 TopoDS_Shape aLocalShape = V.Oriented(TopAbs_INTERNAL);
235 B.UpdateVertex(TopoDS::Vertex(aLocalShape),U2,E2,Tol);
236// B.UpdateVertex(TopoDS::Vertex(V.Oriented(TopAbs_INTERNAL)),
237// U2,E2,Tol);
238 }
239 NewVOnE2.Append(V.Oriented(O2));
240 }
241
242#ifdef DRAW
243 if (AffichInt2d) {
244 if (!OnE1 && !OnE2) {
245 //POP pour NT
246 char* name = new char[100];
247 sprintf(name,"VV_%d",NbNewVertices++);
248 DBRep::Set(name,V);
249 }
250 }
251#endif
252 }
253 if (!NewVOnE1.IsEmpty()) AsDes->Add(E1,NewVOnE1);
254 if (!NewVOnE2.IsEmpty()) AsDes->Add(E2,NewVOnE2);
255}
256
257
258//=======================================================================
259//function : EdgeInter
260//purpose :
261//=======================================================================
262
263static void EdgeInter(const TopoDS_Face& F,
264 const TopoDS_Edge& E1,
265 const TopoDS_Edge& E2,
266 const Handle(BRepAlgo_AsDes)& AsDes,
267 Standard_Real Tol,
268 Standard_Boolean WithOri)
269{
270#ifdef DRAW
271 if (AffichInt2d) {
272 //POP pour NT
273 char* name = new char[100];
274 sprintf(name,"E2d_%d_%d",NbF2d,NbE2d++);
275 DBRep::Set(name,E1);
276 sprintf(name,"E2d_%d_%d",NbF2d,NbE2d++);
277 DBRep::Set(name,E2);
278 }
279#endif
280
281 if (E1.IsSame(E2))
282 return;
283
284 Standard_Real f[3],l[3];
285 Standard_Real MilTol2 = 1000*Tol*Tol;
975ec82a 286 Standard_Real TolDub = 1.e-7;
7fd59977 287 Standard_Integer i;
288
289 BRep_Tool::Range(E1, f[1], l[1]);
290 BRep_Tool::Range(E2, f[2], l[2]);
291
292 BRepAdaptor_Curve CE1(E1,F);
293 BRepAdaptor_Curve CE2(E2,F);
294
295 TopoDS_Edge EI[3]; EI[1] = E1; EI[2] = E2;
296 TopTools_ListOfShape LV1;
297 TopTools_ListOfShape LV2;
298 BRep_Builder B;
299
300 TopoDS_Vertex CV;
301 if (!TopExp::CommonVertex( E1, E2, CV ))
302 {
303 BRepLib::BuildCurve3d(E1);
304 BRepLib::BuildCurve3d(E2);
305
306 Standard_Real TolSum = BRep_Tool::Tolerance(E1) + BRep_Tool::Tolerance(E2);
307 TolSum = Max( TolSum, 1.e-5 );
308
309 TColgp_SequenceOfPnt ResPoints;
310 TColStd_SequenceOfReal ResParamsOnE1, ResParamsOnE2;
311 gp_Pnt DegPoint;
312 Standard_Boolean WithDegen = BRep_Tool::Degenerated(E1) || BRep_Tool::Degenerated(E2);
313
314 if (WithDegen)
315 {
316 Standard_Integer ideg = (BRep_Tool::Degenerated(E1))? 1 : 2;
317 TopoDS_Iterator iter( EI[ideg] );
318 if (iter.More())
319 {
320 const TopoDS_Vertex& vdeg = TopoDS::Vertex(iter.Value());
321 DegPoint = BRep_Tool::Pnt(vdeg);
322 }
323 else
324 {
325 BRepAdaptor_Curve CEdeg( EI[ideg], F );
326 DegPoint = CEdeg.Value( CEdeg.FirstParameter() );
327 }
328 }
329 BRepAdaptor_Surface BAsurf(F);
330 Handle(Geom2d_Curve) pcurve1 = BRep_Tool::CurveOnSurface(E1, F, f[1], l[1]);
331 Handle(Geom2d_Curve) pcurve2 = BRep_Tool::CurveOnSurface(E2, F, f[2], l[2]);
332 Geom2dAdaptor_Curve GAC1(pcurve1, f[1], l[1]);
333 Geom2dAdaptor_Curve GAC2(pcurve2, f[2], l[2]);
334 Geom2dInt_GInter Inter2d( GAC1, GAC2, TolDub, TolDub );
335 for (i = 1; i <= Inter2d.NbPoints(); i++)
336 {
337 gp_Pnt P3d;
338 if (WithDegen)
339 P3d = DegPoint;
340 else
341 {
342 gp_Pnt2d P2d = Inter2d.Point(i).Value();
343 P3d = BAsurf.Value( P2d.X(), P2d.Y() );
344 }
345 ResPoints.Append( P3d );
346 ResParamsOnE1.Append( Inter2d.Point(i).ParamOnFirst() );
347 ResParamsOnE2.Append( Inter2d.Point(i).ParamOnSecond() );
348 }
349
350 for (i = 1; i <= ResPoints.Length(); i++)
351 {
352 Standard_Real aT1 = ResParamsOnE1(i); //ponc1.Parameter();
353 Standard_Real aT2 = ResParamsOnE2(i); //ponc2.Parameter();
354 if (Precision::IsInfinite(aT1) || Precision::IsInfinite(aT2))
355 {
356#ifdef DEB
357 cout << "Inter2d : Solution rejected due to infinite parameter"<<endl;
358#endif
359 continue;
360 }
361
362 gp_Pnt P = ResPoints(i); //ponc1.Value();
363 TopoDS_Vertex aNewVertex = BRepLib_MakeVertex(P);
975ec82a 364 aNewVertex.Orientation(TopAbs_INTERNAL);
7fd59977 365 B.UpdateVertex( aNewVertex, aT1, E1, Tol );
366 B.UpdateVertex( aNewVertex, aT2, E2, Tol );
367 gp_Pnt P1 = CE1.Value(aT1);
368 gp_Pnt P2 = CE2.Value(aT2);
369 Standard_Real dist1, dist2, dist3;
370 dist1 = P1.Distance(P);
371 dist2 = P2.Distance(P);
372 dist3 = P1.Distance(P2);
373 dist1 = Max( dist1, dist2 );
374 dist1 = Max( dist1, dist3 );
375 B.UpdateVertex( aNewVertex, dist1 );
376
377#ifdef DEB
378 if (aT1 < f[1]-Tol || aT1 > l[1]+Tol)
379 {
0d969553 380 cout << "out of limit"<<endl;
7fd59977 381 cout<<"aT1 = "<<aT1<<", f[1] = "<<f[1]<<", l[1] = "<<l[1]<<endl;
382 }
383 if (aT2 < f[2]-Tol || aT2 > l[2]+Tol)
384 {
0d969553 385 cout << "out of limit"<<endl;
7fd59977 386 cout<<"aT2 = "<<aT2<<", f[2] = "<<f[2]<<", l[2] = "<<l[2]<<endl;
387 }
388 if (P1.SquareDistance(P) > MilTol2 || P2.SquareDistance(P) > MilTol2 || P1.Distance(P2) > 2.*Tol)
389 {
0d969553 390 cout << "Inter2d : Solution rejected "<<endl;
7fd59977 391 cout<<"P = "<<P.X()<<" "<<P.Y()<<" "<<P.Z()<<endl;
392 cout<<"P1 = "<<P1.X()<<" "<<P1.Y()<<" "<<P1.Z()<<endl;
393 cout<<"P2 = "<<P2.X()<<" "<<P2.Y()<<" "<<P2.Z()<<endl;
394 cout<<"MaxDist = "<<dist1<<endl;
395 }
396#endif
397 //define the orientation of a new vertex
398 TopAbs_Orientation OO1 = TopAbs_REVERSED;
399 TopAbs_Orientation OO2 = TopAbs_REVERSED;
400 if (WithOri)
401 {
402 BRepAdaptor_Curve2d PCE1( E1, F );
403 BRepAdaptor_Curve2d PCE2( E2, F );
404 gp_Pnt2d P2d1, P2d2;
405 gp_Vec2d V1, V2, V1or, V2or;
406 PCE1.D1( aT1, P2d1, V1 );
407 PCE2.D1( aT2, P2d2, V2 );
408 V1or = V1; V2or = V2;
409 if (E1.Orientation() == TopAbs_REVERSED) V1or.Reverse();
410 if (E2.Orientation() == TopAbs_REVERSED) V2or.Reverse();
411 Standard_Real CrossProd = V2or ^ V1;
412#ifdef DEB
413 if (Abs(CrossProd) <= gp::Resolution())
414 cout<<endl<<"CrossProd = "<<CrossProd<<endl;
415#endif
416 if (CrossProd > 0.)
417 OO1 = TopAbs_FORWARD;
418 CrossProd = V1or ^ V2;
419 if (CrossProd > 0.)
420 OO2 = TopAbs_FORWARD;
421 }
422 LV1.Append( aNewVertex.Oriented(OO1) );
423 LV2.Append( aNewVertex.Oriented(OO2) );
424 }
425 }
426
427 //----------------------------------
0d969553 428 // Test at end.
7fd59977 429 //---------------------------------
430 Standard_Real U1,U2;
431 Standard_Real TolConf = Tol;
432 TopoDS_Vertex V1[2],V2[2];
433 TopExp::Vertices(E1,V1[0],V1[1]);
434 TopExp::Vertices(E2,V2[0],V2[1]);
435
436 Standard_Integer j;
437 for (j = 0; j < 2; j++) {
438 if (V1[j].IsNull()) continue;
439 for (Standard_Integer k = 0; k < 2; k++) {
440 if (V2[k].IsNull()) continue;
441 gp_Pnt P1 = BRep_Tool::Pnt(V1[j]);
442 gp_Pnt P2 = BRep_Tool::Pnt(V2[k]);
443 Standard_Real Dist = P1.Distance(P2);
444 if (Dist < TolConf) {
445 TopoDS_Vertex V = BRepLib_MakeVertex(P1);
446 U1 = (j == 0) ? f[1] : l[1];
447 U2 = (k == 0) ? f[2] : l[2];
448 TopoDS_Shape aLocalShape = V.Oriented(TopAbs_INTERNAL);
449// Modified by skv - Thu Jan 22 18:16:01 2004 OCC4455 Begin
450 Standard_Real aTol = BRep_Tool::Tolerance(V1[j]);
451
452 if (!V1[j].IsSame(V2[k])) {
453 Standard_Real aTol2 = BRep_Tool::Tolerance(V2[k]);
454
455 aTol = Max(aTol, aTol2);
456 }
457
458 B.UpdateVertex(TopoDS::Vertex(aLocalShape),U1,E1,aTol);
459 B.UpdateVertex(TopoDS::Vertex(aLocalShape),U2,E2,aTol);
460// B.UpdateVertex(TopoDS::Vertex(aLocalShape),U1,E1,Tol);
461// B.UpdateVertex(TopoDS::Vertex(aLocalShape),U2,E2,Tol);
462// B.UpdateVertex(TopoDS::Vertex(V.Oriented(TopAbs_INTERNAL)),
463// U1,E1,Tol);
464// B.UpdateVertex(TopoDS::Vertex(V.Oriented(TopAbs_INTERNAL)),
465// U2,E2,Tol);
466// Modified by skv - Thu Jan 22 18:16:01 2004 OCC4455 End
467 LV1.Prepend(V.Oriented(V1[j].Orientation()));
468 LV2.Prepend(V.Oriented(V2[k].Orientation()));
469 }
470 }
471 }
472
473 Standard_Boolean AffichPurge = Standard_False;
474
475 if ( !LV1.IsEmpty()) {
476 //----------------------------------
0d969553
Y
477 // Remove all vertices.
478 // There can be doubles
7fd59977 479 //----------------------------------
480 TopTools_ListIteratorOfListOfShape it1LV1,it1LV2,it2LV1;
481 gp_Pnt P1,P2;
482 Standard_Boolean Purge = Standard_True;
483
484 while (Purge) {
485 i = 1;
486 Purge = Standard_False;
487 for (it1LV1.Initialize(LV1),it1LV2.Initialize(LV2);
488 it1LV1.More(); it1LV1.Next(),it1LV2.Next()) {
489 j = 1;
490 it2LV1.Initialize(LV1);
491 while (j < i) {
492 P1 = BRep_Tool::Pnt(TopoDS::Vertex(it1LV1.Value()));
493 P2 = BRep_Tool::Pnt(TopoDS::Vertex(it2LV1.Value()));
494// Modified by skv - Thu Jan 22 18:19:04 2004 OCC4455 Begin
495// if (P1.IsEqual(P2,10*Tol)) {
496 Standard_Real aTol;
497
498 aTol = Max(BRep_Tool::Tolerance(TopoDS::Vertex(it1LV1.Value())),
499 BRep_Tool::Tolerance(TopoDS::Vertex(it2LV1.Value())));
500 if (P1.IsEqual(P2,aTol)) {
501// Modified by skv - Thu Jan 22 18:19:05 2004 OCC4455 End
502 LV1.Remove(it1LV1);
503 LV2.Remove(it1LV2);
0d969553 504 if (AffichPurge) cout <<"Doubles removed in EdgeInter."<<endl;
7fd59977 505 Purge = Standard_True;
506 break;
507 }
508 j++;
509 it2LV1.Next();
510 }
511 if (Purge) break;
512 i++;
513 }
514 }
515 //---------------------------------
0d969553 516 // Vertex storage in DS.
7fd59977 517 //---------------------------------
518// Modified by skv - Tue Jan 13 15:14:30 2004 Begin
519 Standard_Real TolStore = BRep_Tool::Tolerance(E1) + BRep_Tool::Tolerance(E2);
520
521 TolStore = Max(TolStore, 10.*Tol);
522
523 Store (E1,E2,LV1,LV2,AsDes,TolStore);
524// Store (E1,E2,LV1,LV2,AsDes,10.*Tol);
525// Store (E1,E2,LV1,LV2,AsDes,Tol);
526// Modified by skv - Tue Jan 13 15:14:30 2004 End
527 }
528}
529//=======================================================================
530//function : EdgeInter
531//purpose :
532//=======================================================================
533
534static void RefEdgeInter(const TopoDS_Face& F,
535 const TopoDS_Edge& E1,
536 const TopoDS_Edge& E2,
537 const Handle(BRepAlgo_AsDes)& AsDes,
538 Standard_Real Tol,
539 Standard_Boolean WithOri,
540 gp_Pnt& Pref)
541{
542#ifdef DRAW
543 if (AffichInt2d) {
0d969553 544 //POP for NT
7fd59977 545 char* name = new char[100];
546 sprintf(name,"E2d_%d_%d",NbF2d,NbE2d++);
547 DBRep::Set(name,E1);
548 sprintf(name,"E2d_%d_%d",NbF2d,NbE2d++);
549 DBRep::Set(name,E2);
550 }
551#endif
552
553 if (E1.IsSame(E2))
554 return;
555
556 Standard_Real f[3],l[3];
557 Standard_Real MilTol2 = 1000*Tol*Tol;
975ec82a 558 Standard_Real TolDub = 1.e-7;
7fd59977 559 Standard_Integer i;
560
561 //BRep_Tool::Range(E1, f[1], l[1]);
562 //BRep_Tool::Range(E2, f[2], l[2]);
563
564 BRepAdaptor_Curve CE1(E1,F);
565 BRepAdaptor_Curve CE2(E2,F);
566
567 TopoDS_Edge EI[3]; EI[1] = E1; EI[2] = E2;
568 TopTools_ListOfShape LV1;
569 TopTools_ListOfShape LV2;
570 BRep_Builder B;
571
572 BRepLib::BuildCurve3d(E1);
573 BRepLib::BuildCurve3d(E2);
574
575 Standard_Real TolSum = BRep_Tool::Tolerance(E1) + BRep_Tool::Tolerance(E2);
576 TolSum = Max( TolSum, 1.e-5 );
577
578 TColgp_SequenceOfPnt ResPoints;
579 TColStd_SequenceOfReal ResParamsOnE1, ResParamsOnE2;
580 gp_Pnt DegPoint;
581 Standard_Boolean WithDegen = BRep_Tool::Degenerated(E1) || BRep_Tool::Degenerated(E2);
582
583 if (WithDegen)
584 {
585 Standard_Integer ideg = (BRep_Tool::Degenerated(E1))? 1 : 2;
586 TopoDS_Iterator iter( EI[ideg] );
587 if (iter.More())
588 {
589 const TopoDS_Vertex& vdeg = TopoDS::Vertex(iter.Value());
590 DegPoint = BRep_Tool::Pnt(vdeg);
591 }
592 else
593 {
594 BRepAdaptor_Curve CEdeg( EI[ideg], F );
595 DegPoint = CEdeg.Value( CEdeg.FirstParameter() );
596 }
597 }
598 BRepAdaptor_Surface BAsurf(F);
599 Handle(Geom2d_Curve) pcurve1 = BRep_Tool::CurveOnSurface(E1, F, f[1], l[1]);
600 Handle(Geom2d_Curve) pcurve2 = BRep_Tool::CurveOnSurface(E2, F, f[2], l[2]);
601 Geom2dAdaptor_Curve GAC1(pcurve1, f[1], l[1]);
602 Geom2dAdaptor_Curve GAC2(pcurve2, f[2], l[2]);
603 Geom2dInt_GInter Inter2d( GAC1, GAC2, TolDub, TolDub );
604 for (i = 1; i <= Inter2d.NbPoints(); i++)
605 {
606 gp_Pnt P3d;
607 if (WithDegen)
608 P3d = DegPoint;
609 else
610 {
611 gp_Pnt2d P2d = Inter2d.Point(i).Value();
612 P3d = BAsurf.Value( P2d.X(), P2d.Y() );
613 }
614 ResPoints.Append( P3d );
615 ResParamsOnE1.Append( Inter2d.Point(i).ParamOnFirst() );
616 ResParamsOnE2.Append( Inter2d.Point(i).ParamOnSecond() );
617 }
618
619 for (i = 1; i <= ResPoints.Length(); i++)
620 {
621 Standard_Real aT1 = ResParamsOnE1(i); //ponc1.Parameter();
622 Standard_Real aT2 = ResParamsOnE2(i); //ponc2.Parameter();
623 if (Precision::IsInfinite(aT1) || Precision::IsInfinite(aT2))
624 {
625#ifdef DEB
626 cout << "Inter2d : Solution rejected due to infinite parameter"<<endl;
627#endif
628 continue;
629 }
630
631 gp_Pnt P = ResPoints(i); //ponc1.Value();
632 TopoDS_Vertex aNewVertex = BRepLib_MakeVertex(P);
975ec82a 633 aNewVertex.Orientation(TopAbs_INTERNAL);
7fd59977 634 B.UpdateVertex( aNewVertex, aT1, E1, Tol );
635 B.UpdateVertex( aNewVertex, aT2, E2, Tol );
636 gp_Pnt P1 = CE1.Value(aT1);
637 gp_Pnt P2 = CE2.Value(aT2);
638 Standard_Real dist1, dist2, dist3;
639 dist1 = P1.Distance(P);
640 dist2 = P2.Distance(P);
641 dist3 = P1.Distance(P2);
642 dist1 = Max( dist1, dist2 );
643 dist1 = Max( dist1, dist3 );
644 B.UpdateVertex( aNewVertex, dist1 );
645
646#ifdef DEB
647 if (aT1 < f[1]-Tol || aT1 > l[1]+Tol)
648 {
0d969553 649 cout << "out of limit"<<endl;
7fd59977 650 cout<<"aT1 = "<<aT1<<", f[1] = "<<f[1]<<", l[1] = "<<l[1]<<endl;
651 }
652 if (aT2 < f[2]-Tol || aT2 > l[2]+Tol)
653 {
0d969553 654 cout << "out of limit"<<endl;
7fd59977 655 cout<<"aT2 = "<<aT2<<", f[2] = "<<f[2]<<", l[2] = "<<l[2]<<endl;
656 }
657 if (P1.SquareDistance(P) > MilTol2 || P2.SquareDistance(P) > MilTol2 || P1.Distance(P2) > 2.*Tol)
658 {
0d969553 659 cout << "Inter2d : Solution rejected"<<endl;
7fd59977 660 cout<<"P = "<<P.X()<<" "<<P.Y()<<" "<<P.Z()<<endl;
661 cout<<"P1 = "<<P1.X()<<" "<<P1.Y()<<" "<<P1.Z()<<endl;
662 cout<<"P2 = "<<P2.X()<<" "<<P2.Y()<<" "<<P2.Z()<<endl;
663 cout<<"MaxDist = "<<dist1<<endl;
664 }
665#endif
666 //define the orientation of a new vertex
667 TopAbs_Orientation OO1 = TopAbs_REVERSED;
668 TopAbs_Orientation OO2 = TopAbs_REVERSED;
669 if (WithOri)
670 {
671 BRepAdaptor_Curve2d PCE1( E1, F );
672 BRepAdaptor_Curve2d PCE2( E2, F );
673 gp_Pnt2d P2d1, P2d2;
674 gp_Vec2d V1, V2, V1or, V2or;
675 PCE1.D1( aT1, P2d1, V1 );
676 PCE2.D1( aT2, P2d2, V2 );
677 V1or = V1; V2or = V2;
678 if (E1.Orientation() == TopAbs_REVERSED) V1or.Reverse();
679 if (E2.Orientation() == TopAbs_REVERSED) V2or.Reverse();
680 Standard_Real CrossProd = V2or ^ V1;
681#ifdef DEB
682 if (Abs(CrossProd) <= gp::Resolution())
683 cout<<endl<<"CrossProd = "<<CrossProd<<endl;
684#endif
685 if (CrossProd > 0.)
686 OO1 = TopAbs_FORWARD;
687 CrossProd = V1or ^ V2;
688 if (CrossProd > 0.)
689 OO2 = TopAbs_FORWARD;
690 }
691 LV1.Append( aNewVertex.Oriented(OO1) );
692 LV2.Append( aNewVertex.Oriented(OO2) );
693 }
694
695 //----------------------------------
0d969553 696 // Test at end.
7fd59977 697 //---------------------------------
698 Standard_Real U1,U2;
699 Standard_Real TolConf = Tol;
700 TopoDS_Vertex V1[2],V2[2];
701 TopExp::Vertices(E1,V1[0],V1[1]);
702 TopExp::Vertices(E2,V2[0],V2[1]);
703
704 Standard_Integer j;
705 for (j = 0; j < 2; j++) {
706 if (V1[j].IsNull()) continue;
707 for (Standard_Integer k = 0; k < 2; k++) {
708 if (V2[k].IsNull()) continue;
709 gp_Pnt P1 = BRep_Tool::Pnt(V1[j]);
710 gp_Pnt P2 = BRep_Tool::Pnt(V2[k]);
711 Standard_Real Dist = P1.Distance(P2);
712 if (Dist < TolConf) {
713 TopoDS_Vertex V = BRepLib_MakeVertex(P1);
714 U1 = (j == 0) ? f[1] : l[1];
715 U2 = (k == 0) ? f[2] : l[2];
716 TopoDS_Shape aLocalShape = V.Oriented(TopAbs_INTERNAL);
717 B.UpdateVertex(TopoDS::Vertex(aLocalShape),U1,E1,Tol);
718 B.UpdateVertex(TopoDS::Vertex(aLocalShape),U2,E2,Tol);
719// B.UpdateVertex(TopoDS::Vertex(V.Oriented(TopAbs_INTERNAL)),
720// U1,E1,Tol);
721// B.UpdateVertex(TopoDS::Vertex(V.Oriented(TopAbs_INTERNAL)),
722// U2,E2,Tol);
723 LV1.Prepend(V.Oriented(V1[j].Orientation()));
724 LV2.Prepend(V.Oriented(V2[k].Orientation()));
725 }
726 }
727 }
728
729 Standard_Boolean AffichPurge = Standard_False;
730
731 if ( !LV1.IsEmpty()) {
732 //----------------------------------
0d969553
Y
733 // Remove all vertices.
734 // there can be doubles
7fd59977 735 //----------------------------------
736 TopTools_ListIteratorOfListOfShape it1LV1,it1LV2,it2LV1;
737 gp_Pnt P1,P2;
738 Standard_Boolean Purge = Standard_True;
739
740 while (Purge) {
741 i = 1;
742 Purge = Standard_False;
743 for (it1LV1.Initialize(LV1),it1LV2.Initialize(LV2);
744 it1LV1.More(); it1LV1.Next(),it1LV2.Next()) {
745 j = 1;
746 it2LV1.Initialize(LV1);
747 while (j < i) {
748 P1 = BRep_Tool::Pnt(TopoDS::Vertex(it1LV1.Value()));
749 P2 = BRep_Tool::Pnt(TopoDS::Vertex(it2LV1.Value()));
750 if (P1.IsEqual(P2,10*Tol)) {
751 LV1.Remove(it1LV1);
752 LV2.Remove(it1LV2);
0d969553 753 if (AffichPurge) cout <<"Doubles removed in EdgeInter."<<endl;
7fd59977 754 Purge = Standard_True;
755 break;
756 }
757 j++;
758 it2LV1.Next();
759 }
760 if (Purge) break;
761 i++;
762 }
763 }
764 //---------------------------------
0d969553 765 // Vertex storage in SD.
7fd59977 766 //---------------------------------
767////-----------------------------------------------------
768 if(LV1.Extent() > 1) {
769 //cout << "IFV - RefEdgeInter: remove vertex" << endl;
770 Standard_Real dmin = RealLast();
771 TopoDS_Vertex Vmin;
772 for (it1LV1.Initialize(LV1); it1LV1.More(); it1LV1.Next()) {
773 gp_Pnt P = BRep_Tool::Pnt(TopoDS::Vertex(it1LV1.Value()));
774 Standard_Real d = P.SquareDistance(Pref);
775 if(d < dmin) {
776 dmin = d;
777 Vmin = TopoDS::Vertex(it1LV1.Value());
778 }
779 }
780 for (it1LV1.Initialize(LV1),it1LV2.Initialize(LV2);
781 it1LV1.More(); it1LV1.Next(),it1LV2.Next()) {
782 if(!Vmin.IsSame(it1LV1.Value())) {
783 LV1.Remove(it1LV1);
784 LV2.Remove(it1LV2);
785 if(!it1LV1.More()) break;
786 }
787 }
788 }
789
790////-----------------------------------------------------
791
792// Modified by skv - Tue Jan 13 15:14:30 2004 Begin
793 Standard_Real TolStore = BRep_Tool::Tolerance(E1) + BRep_Tool::Tolerance(E2);
794
795 TolStore = Max(TolStore, 10.*Tol);
796
797 Store (E1,E2,LV1,LV2,AsDes,TolStore);
798// Store (E1,E2,LV1,LV2,AsDes,10.*Tol);
799// Store (E1,E2,LV1,LV2,AsDes,Tol);
800// Modified by skv - Tue Jan 13 15:14:30 2004 End
801 }
802}
803
804
805//======================================================================
806//function : EvaluateMaxSegment
807//purpose : return MaxSegment to pass in approximation
808//======================================================================
809
810static Standard_Integer evaluateMaxSegment(const Adaptor3d_CurveOnSurface& aCurveOnSurface)
811{
812 Handle(Adaptor3d_HSurface) aSurf = aCurveOnSurface.GetSurface();
813 Handle(Adaptor2d_HCurve2d) aCurv2d = aCurveOnSurface.GetCurve();
814
815 Standard_Real aNbSKnots = 0, aNbC2dKnots = 0;
816
817 if (aSurf->GetType() == GeomAbs_BSplineSurface) {
818 Handle(Geom_BSplineSurface) aBSpline = aSurf->BSpline();
819 aNbSKnots = Max(aBSpline->NbUKnots(), aBSpline->NbVKnots());
820 }
821 if (aCurv2d->GetType() == GeomAbs_BSplineCurve) {
822 aNbC2dKnots = aCurv2d->NbKnots();
823 }
824 Standard_Integer aReturn = (Standard_Integer) ( 30 + Max(aNbSKnots, aNbC2dKnots) ) ;
825 return aReturn;
826}
827
828
829//=======================================================================
830//function : ExtendPCurve
831//purpose :
832//=======================================================================
833
834static Standard_Boolean ExtendPCurve(const Handle(Geom2d_Curve)& aPCurve,
835 const Standard_Real anEf,
836 const Standard_Real anEl,
837 const Standard_Real a2Offset,
838 Handle(Geom2d_Curve)& NewPCurve)
839{
840 NewPCurve = aPCurve;
841 if (NewPCurve->IsInstance(STANDARD_TYPE(Geom2d_TrimmedCurve)))
842 NewPCurve = (*((Handle(Geom2d_TrimmedCurve)*)&NewPCurve))->BasisCurve();
843
844 Standard_Real FirstPar = NewPCurve->FirstParameter();
845 Standard_Real LastPar = NewPCurve->LastParameter();
846
847 if (NewPCurve->IsKind(STANDARD_TYPE(Geom2d_BoundedCurve)) &&
848 (FirstPar > anEf - a2Offset || LastPar < anEl + a2Offset))
849 {
850 if (NewPCurve->IsInstance(STANDARD_TYPE(Geom2d_BezierCurve)))
851 {
852 Handle(Geom2d_BezierCurve) aBezier = *((Handle(Geom2d_BezierCurve)*)&NewPCurve);
853 if (aBezier->NbPoles() == 2)
854 {
855 TColgp_Array1OfPnt2d thePoles(1,2);
856 aBezier->Poles(thePoles);
857 gp_Vec2d aVec(thePoles(1), thePoles(2));
858 NewPCurve = new Geom2d_Line(thePoles(1), aVec);
859 return Standard_True;
860 }
861 }
862 else if (NewPCurve->IsInstance(STANDARD_TYPE(Geom2d_BSplineCurve)))
863 {
864 Handle(Geom2d_BSplineCurve) aBSpline = *((Handle(Geom2d_BSplineCurve)*)&NewPCurve);
865 if (aBSpline->NbKnots() == 2 && aBSpline->NbPoles() == 2)
866 {
867 TColgp_Array1OfPnt2d thePoles(1,2);
868 aBSpline->Poles(thePoles);
869 gp_Vec2d aVec(thePoles(1), thePoles(2));
870 NewPCurve = new Geom2d_Line(thePoles(1), aVec);
871 return Standard_True;
872 }
873 }
874 }
875
876 FirstPar = aPCurve->FirstParameter();
877 LastPar = aPCurve->LastParameter();
878 Handle(Geom2d_TrimmedCurve) aTrCurve =
879 new Geom2d_TrimmedCurve(aPCurve, FirstPar, LastPar);
880
881 // The curve is not prolonged on begin or end.
882 // Trying to prolong it adding a segment to its bound.
883 gp_Pnt2d aPBnd;
884 gp_Vec2d aVBnd;
885 gp_Pnt2d aPBeg;
886 gp_Dir2d aDBnd;
887 Handle(Geom2d_Line) aLin;
888 Handle(Geom2d_TrimmedCurve) aSegment;
889 Geom2dConvert_CompCurveToBSplineCurve aCompCurve(aTrCurve, Convert_RationalC1);
890 Standard_Real aTol = Precision::Confusion();
891 Standard_Real aDelta = Max(a2Offset, 1.);
892
893 if (FirstPar > anEf - a2Offset) {
894 aPCurve->D1(FirstPar, aPBnd, aVBnd);
895 aDBnd.SetXY(aVBnd.XY());
896 aPBeg = aPBnd.Translated(gp_Vec2d(-aDelta*aDBnd.XY()));
897 aLin = new Geom2d_Line(aPBeg, aDBnd);
898 aSegment = new Geom2d_TrimmedCurve(aLin, 0, aDelta);
899
900 if (!aCompCurve.Add(aSegment, aTol))
901 return Standard_False;
902 }
903
904 if (LastPar < anEl + a2Offset) {
905 aPCurve->D1(LastPar, aPBeg, aVBnd);
906 aDBnd.SetXY(aVBnd.XY());
907 aLin = new Geom2d_Line(aPBeg, aDBnd);
908 aSegment = new Geom2d_TrimmedCurve(aLin, 0, aDelta);
909
910 if (!aCompCurve.Add(aSegment, aTol))
911 return Standard_False;
912 }
913
914 NewPCurve = aCompCurve.BSplineCurve();
915 return Standard_True;
916}
917
918//=======================================================================
919//function : ExtentEdge
920//purpose :
921//=======================================================================
922
923// Modified by skv - Fri Dec 26 17:00:55 2003 OCC4455 Begin
924//static void ExtentEdge(const TopoDS_Edge& E,TopoDS_Edge& NE)
925static void ExtentEdge(const TopoDS_Edge& E,TopoDS_Edge& NE, const Standard_Real theOffset)
926{
927 //BRepLib::BuildCurve3d(E);
928
929 TopoDS_Shape aLocalShape = E.EmptyCopied();
930 Standard_Real anEf;
931 Standard_Real anEl;
932 Standard_Real a2Offset = 2.*Abs(theOffset);
933 BRep_Builder BB;
934 Standard_Integer i, j;
935
936 BRep_Tool::Range(E, anEf, anEl);
937 NE = TopoDS::Edge(aLocalShape);
938// NE = TopoDS::Edge(E.EmptyCopied());
0d969553
Y
939 // Enough for analytic edges, for general case reconstruct the
940 // geometry of the edge recalculating the intersection of surfaces.
7fd59977 941
942 //BRepLib::BuildCurve3d(E);
943
944 Standard_Integer NbPCurves = 0;
945 Standard_Real FirstParOnPC = RealFirst(), LastParOnPC = RealLast();
946 Handle(Geom2d_Curve) MinPC;
947 Handle(Geom_Surface) MinSurf;
948 TopLoc_Location MinLoc;
949
950 BRep_ListIteratorOfListOfCurveRepresentation itr( (Handle(BRep_TEdge)::DownCast(NE.TShape()))->ChangeCurves() );
951 for (; itr.More(); itr.Next())
952 {
953 Handle( BRep_CurveRepresentation ) CurveRep = itr.Value();
954 Standard_Real FirstPar, LastPar;
955 if (CurveRep->IsCurveOnSurface())
956 {
957 NbPCurves++;
958 Handle(Geom2d_Curve) theCurve = CurveRep->PCurve();
959 FirstPar = theCurve->FirstParameter();
960 LastPar = theCurve->LastParameter();
961
962 if (theCurve->IsKind(STANDARD_TYPE(Geom2d_BoundedCurve)) &&
963 (FirstPar > anEf - a2Offset || LastPar < anEl + a2Offset))
964 {
965 Handle(Geom2d_Curve) NewPCurve;
966 if (ExtendPCurve(theCurve, anEf, anEl, a2Offset, NewPCurve))
967 {
968 CurveRep->PCurve(NewPCurve);
969 FirstPar = NewPCurve->FirstParameter();
970 LastPar = NewPCurve->LastParameter();
971 if (CurveRep->IsCurveOnClosedSurface())
972 {
973 Handle(Geom2d_Curve) PCurve2 = CurveRep->PCurve2();
974 if (ExtendPCurve(PCurve2, anEf, anEl, a2Offset, NewPCurve))
975 CurveRep->PCurve2(NewPCurve);
976 }
977 }
978 }
979 else if (theCurve->IsPeriodic())
980 {
981 Standard_Real delta = (theCurve->Period() - (anEl - anEf))*0.5;
982 delta *= 0.95;
983 FirstPar = anEf - delta;
984 LastPar = anEl + delta;
985 }
986 else if (theCurve->IsClosed())
987 LastPar -= 0.05*(LastPar - FirstPar);
988
989 //check FirstPar and LastPar: the pcurve should be in its surface
990 theCurve = CurveRep->PCurve();
991 Handle(Geom_Surface) theSurf = CurveRep->Surface();
992 Standard_Real Umin, Umax, Vmin, Vmax;
993 theSurf->Bounds(Umin, Umax, Vmin, Vmax);
994 TColGeom2d_SequenceOfCurve BoundLines;
995 if (!Precision::IsInfinite(Vmin))
996 {
997 Handle(Geom2d_Line) aLine = new Geom2d_Line(gp_Pnt2d( 0., Vmin ),
998 gp_Dir2d( 1., 0. ));
999 BoundLines.Append(aLine);
1000 }
1001 if (!Precision::IsInfinite(Umin))
1002 {
1003 Handle(Geom2d_Line) aLine = new Geom2d_Line(gp_Pnt2d( Umin, 0. ),
1004 gp_Dir2d( 0., 1. ));
1005 BoundLines.Append(aLine);
1006 }
1007 if (!Precision::IsInfinite(Vmax))
1008 {
1009 Handle(Geom2d_Line) aLine = new Geom2d_Line(gp_Pnt2d( 0., Vmax ),
1010 gp_Dir2d( 1., 0. ));
1011 BoundLines.Append(aLine);
1012 }
1013 if (!Precision::IsInfinite(Umax))
1014 {
1015 Handle(Geom2d_Line) aLine = new Geom2d_Line(gp_Pnt2d( Umax, 0. ),
1016 gp_Dir2d( 0., 1. ));
1017 BoundLines.Append(aLine);
1018 }
1019
1020 TColStd_SequenceOfReal params;
1021 Geom2dInt_GInter IntCC;
1022 Geom2dAdaptor_Curve GAcurve(theCurve);
1023 for (i = 1; i <= BoundLines.Length(); i++)
1024 {
1025 Geom2dAdaptor_Curve GAline( BoundLines(i) );
1026 IntCC.Perform( GAcurve, GAline, Precision::PConfusion(), Precision::PConfusion());
1027 if (IntCC.IsDone())
1028 {
1029 for (j = 1; j <= IntCC.NbPoints(); j++)
1030 {
1031 const IntRes2d_IntersectionPoint& ip = IntCC.Point(j);
1032 gp_Pnt2d aPoint = ip.Value();
1033 if (aPoint.X() >= Umin && aPoint.X() <= Umax &&
1034 aPoint.Y() >= Vmin && aPoint.Y() <= Vmax)
1035 params.Append( ip.ParamOnFirst() );
1036 }
1037 for (j = 1; j <= IntCC.NbSegments(); j++)
1038 {
1039 const IntRes2d_IntersectionSegment& is = IntCC.Segment(j);
1040 if (is.HasFirstPoint())
1041 {
1042 const IntRes2d_IntersectionPoint& ip = is.FirstPoint();
1043 gp_Pnt2d aPoint = ip.Value();
1044 if (aPoint.X() >= Umin && aPoint.X() <= Umax &&
1045 aPoint.Y() >= Vmin && aPoint.Y() <= Vmax)
1046 params.Append( ip.ParamOnFirst() );
1047 }
1048 if (is.HasLastPoint())
1049 {
1050 const IntRes2d_IntersectionPoint& ip = is.LastPoint();
1051 gp_Pnt2d aPoint = ip.Value();
1052 if (aPoint.X() >= Umin && aPoint.X() <= Umax &&
1053 aPoint.Y() >= Vmin && aPoint.Y() <= Vmax)
1054 params.Append( ip.ParamOnFirst() );
1055 }
1056 }
1057 }
1058 }
1059 if (!params.IsEmpty())
1060 {
1061 if (params.Length() == 1)
1062 {
1063 gp_Pnt2d PntFirst = theCurve->Value(FirstPar);
1064 if (PntFirst.X() >= Umin && PntFirst.X() <= Umax &&
1065 PntFirst.Y() >= Vmin && PntFirst.Y() <= Vmax)
1066 {
1067 if (LastPar > params(1))
1068 LastPar = params(1);
1069 }
1070 else if (FirstPar < params(1))
1071 FirstPar = params(1);
1072 }
1073 else
1074 {
1075 Standard_Real fpar = RealLast(), lpar = RealFirst();
1076 for (i = 1; i <= params.Length(); i++)
1077 {
1078 if (params(i) < fpar)
1079 fpar = params(i);
1080 if (params(i) > lpar)
1081 lpar = params(i);
1082 }
1083 if (FirstPar < fpar)
1084 FirstPar = fpar;
1085 if (LastPar > lpar)
1086 LastPar = lpar;
1087 }
1088 }
1089 //// end of check ////
1090 (Handle(BRep_GCurve)::DownCast(CurveRep))->SetRange( FirstPar, LastPar );
1091 //gp_Pnt2d Pfirst = theCurve->Value(FirstPar);
1092 //gp_Pnt2d Plast = theCurve->Value(LastPar);
1093 //(Handle(BRep_CurveOnSurface)::DownCast(CurveRep))->SetUVPoints( Pfirst, Plast );
1094
1095 //update FirstParOnPC and LastParOnPC
1096 if (FirstPar > FirstParOnPC)
1097 {
1098 FirstParOnPC = FirstPar;
1099 MinPC = theCurve;
1100 MinSurf = theSurf;
1101 MinLoc = CurveRep->Location();
1102 }
1103 if (LastPar < LastParOnPC)
1104 {
1105 LastParOnPC = LastPar;
1106 MinPC = theCurve;
1107 MinSurf = theSurf;
1108 MinLoc = CurveRep->Location();
1109 }
1110 }
1111 }
1112
1113 Standard_Real f, l;
1114 Handle(Geom_Curve) C3d = BRep_Tool::Curve( NE, f, l );
1115 if (NbPCurves)
1116 {
1117 MinLoc = E.Location() * MinLoc;
1118 if (!C3d.IsNull())
1119 {
7fd59977 1120 if (MinPC->IsClosed())
1121 {
1122 f = FirstParOnPC;
1123 l = LastParOnPC;
1124 }
1125 else if (C3d->IsPeriodic())
1126 {
1127 Standard_Real delta = (C3d->Period() - (l - f))*0.5;
1128 delta *= 0.95;
1129 f -= delta;
1130 l += delta;
1131 }
1132 else if (C3d->IsClosed())
1133 l -= 0.05*(l - f);
1134 else
1135 {
1136 f = FirstParOnPC;
1137 l = LastParOnPC;
1138 GeomAPI_ProjectPointOnCurve Projector;
1139 if (!Precision::IsInfinite(FirstParOnPC))
1140 {
1141 gp_Pnt2d P2d1 = MinPC->Value(FirstParOnPC);
1142 gp_Pnt P1 = MinSurf->Value( P2d1.X(), P2d1.Y() );
1143 P1.Transform(MinLoc.Transformation());
1144 Projector.Init( P1, C3d );
1145 if (Projector.NbPoints() > 0)
1146 f = Projector.LowerDistanceParameter();
1147#ifdef DEB
1148 else
1149 cout<<"ProjectPointOnCurve not done"<<endl;
1150#endif
1151 }
1152 if (!Precision::IsInfinite(LastParOnPC))
1153 {
1154 gp_Pnt2d P2d2 = MinPC->Value(LastParOnPC);
1155 gp_Pnt P2 = MinSurf->Value( P2d2.X(), P2d2.Y() );
1156 P2.Transform(MinLoc.Transformation());
1157 Projector.Init( P2, C3d );
1158 if (Projector.NbPoints() > 0)
1159 l = Projector.LowerDistanceParameter();
1160#ifdef DEB
1161 else
1162 cout<<"ProjectPointOnCurve not done"<<endl;
1163#endif
1164 }
1165 }
1166 BB.Range( NE, f, l );
1167 if (!Precision::IsInfinite(f) && !Precision::IsInfinite(l))
1168 BRepLib::SameParameter( NE, Precision::Confusion(), Standard_True );
1169 }
975ec82a 1170 else if (!BRep_Tool::Degenerated(E)) //no 3d curve
7fd59977 1171 {
1172 MinSurf = Handle(Geom_Surface)::DownCast
1173 (MinSurf->Transformed(MinLoc.Transformation()));
1174 Standard_Real max_deviation = 0.;
1175 if (Precision::IsInfinite(FirstParOnPC) || Precision::IsInfinite(LastParOnPC))
1176 {
1177 if (MinPC->IsInstance(STANDARD_TYPE(Geom2d_Line)))
1178 {
1179 Standard_Boolean IsLine = Standard_False;
1180 if (MinSurf->IsInstance(STANDARD_TYPE(Geom_Plane)))
1181 IsLine = Standard_True;
1182 else if (MinSurf->IsInstance(STANDARD_TYPE(Geom_CylindricalSurface)) ||
1183 MinSurf->IsInstance(STANDARD_TYPE(Geom_ConicalSurface)))
1184 {
1185 Handle(Geom2d_Line) theLine = *((Handle(Geom2d_Line)*)&MinPC);
1186 gp_Dir2d LineDir = theLine->Direction();
1187 if (LineDir.IsParallel( gp::DY2d(), Precision::Angular() ))
1188 IsLine = Standard_True;
1189 }
1190 if (IsLine)
1191 {
1192 gp_Pnt2d P2d1 = MinPC->Value(0.), P2d2 = MinPC->Value(1.);
1193 gp_Pnt P1 = MinSurf->Value(P2d1.X(), P2d1.Y());
1194 gp_Pnt P2 = MinSurf->Value(P2d2.X(), P2d2.Y());
1195 gp_Vec aVec(P1, P2);
1196 C3d = new Geom_Line( P1, aVec );
1197 }
1198 }
1199 }
1200 else
1201 {
1202 Geom2dAdaptor_Curve AC2d( MinPC, FirstParOnPC, LastParOnPC );
1203 GeomAdaptor_Surface GAsurf( MinSurf );
1204 Handle(Geom2dAdaptor_HCurve) HC2d = new Geom2dAdaptor_HCurve( AC2d );
1205 Handle(GeomAdaptor_HSurface) HSurf = new GeomAdaptor_HSurface( GAsurf );
1206 Adaptor3d_CurveOnSurface ConS( HC2d, HSurf );
1207 Standard_Real /*max_deviation,*/ average_deviation;
1208 GeomAbs_Shape Continuity = GeomAbs_C1;
1209 Standard_Integer MaxDegree = 14;
1210 Standard_Integer MaxSegment = evaluateMaxSegment(ConS);
1211 GeomLib::BuildCurve3d(Precision::Confusion(),
1212 ConS, FirstParOnPC, LastParOnPC,
1213 C3d, max_deviation, average_deviation,
1214 Continuity, MaxDegree, MaxSegment);
1215 }
1216 BB.UpdateEdge( NE, C3d, max_deviation );
1217 //BB.Range( NE, FirstParOnPC, LastParOnPC );
1218 Standard_Boolean ProjectionSuccess = Standard_True;
1219 if (NbPCurves > 1)
1220 //BRepLib::SameParameter( NE, Precision::Confusion(), Standard_True );
1221 for (itr.Initialize((Handle(BRep_TEdge)::DownCast(NE.TShape()))->ChangeCurves());
1222 itr.More();
1223 itr.Next())
1224 {
1225 Handle( BRep_CurveRepresentation ) CurveRep = itr.Value();
1226 Standard_Real FirstPar, LastPar;
1227 if (CurveRep->IsCurveOnSurface())
1228 {
1229 Handle(Geom2d_Curve) theCurve = CurveRep->PCurve();
1230 Handle(Geom_Surface) theSurf = CurveRep->Surface();
1231 TopLoc_Location theLoc = CurveRep->Location();
1232 if (theCurve == MinPC && theSurf == MinSurf && theLoc == MinLoc)
1233 continue;
1234 FirstPar = (Handle(BRep_GCurve)::DownCast(CurveRep))->First();
1235 LastPar = (Handle(BRep_GCurve)::DownCast(CurveRep))->Last();
1236 if (Abs(FirstPar - FirstParOnPC) > Precision::PConfusion() ||
1237 Abs(LastPar - LastParOnPC) > Precision::PConfusion())
1238 {
1239 theLoc = E.Location() * theLoc;
1240 theSurf = Handle(Geom_Surface)::DownCast
1241 (theSurf->Transformed(theLoc.Transformation()));
1242
1243 if (theCurve->IsInstance(STANDARD_TYPE(Geom2d_Line)) &&
1244 theSurf->IsKind(STANDARD_TYPE(Geom_BoundedSurface)))
1245 {
1246 gp_Dir2d theDir = (*((Handle(Geom2d_Line)*)&theCurve))->Direction();
1247 if (theDir.IsParallel(gp::DX2d(), Precision::Angular()) ||
1248 theDir.IsParallel(gp::DY2d(), Precision::Angular()))
1249 {
1250 Standard_Real U1, U2, V1, V2;
1251 theSurf->Bounds(U1, U2, V1, V2);
1252 gp_Pnt2d Origin = (*((Handle(Geom2d_Line)*)&theCurve))->Location();
1253 if (Abs(Origin.X()-U1) <= Precision::Confusion() ||
1254 Abs(Origin.X()-U2) <= Precision::Confusion() ||
1255 Abs(Origin.Y()-V1) <= Precision::Confusion() ||
1256 Abs(Origin.Y()-V2) <= Precision::Confusion())
1257 {
1258 BRepLib::SameParameter( NE, Precision::Confusion(), Standard_True );
1259 break;
1260 }
1261 }
1262 }
1263
1264 Handle(Geom2d_Curve) ProjPCurve =
1265 GeomProjLib::Curve2d( C3d, FirstParOnPC, LastParOnPC, theSurf );
1266 if (ProjPCurve.IsNull())
1267 ProjectionSuccess = Standard_False;
1268 else
1269 CurveRep->PCurve( ProjPCurve );
1270 }
1271 }
1272 }
1273 if (ProjectionSuccess)
1274 BB.Range( NE, FirstParOnPC, LastParOnPC );
1275 else
1276 {
1277 BB.Range( NE, FirstParOnPC, LastParOnPC, Standard_True );
1278 BRepLib::SameParameter( NE, Precision::Confusion(), Standard_True );
1279 }
1280 }
1281 }
1282 else //no pcurves
1283 {
1284 Standard_Real FirstPar = C3d->FirstParameter();
1285 Standard_Real LastPar = C3d->LastParameter();
1286
1287 if (C3d->IsKind(STANDARD_TYPE(Geom_BoundedCurve)) &&
9c12265e 1288 (FirstPar > anEf - a2Offset || LastPar < anEl + a2Offset))
7fd59977 1289 {
1290 Handle(Geom_TrimmedCurve) aTrCurve =
1291 new Geom_TrimmedCurve(C3d, FirstPar, LastPar);
1292
1293 // The curve is not prolonged on begin or end.
1294 // Trying to prolong it adding a segment to its bound.
1295 gp_Pnt aPBnd;
1296 gp_Vec aVBnd;
1297 gp_Pnt aPBeg;
1298 gp_Dir aDBnd;
1299 Handle(Geom_Line) aLin;
1300 Handle(Geom_TrimmedCurve) aSegment;
1301 GeomConvert_CompCurveToBSplineCurve aCompCurve(aTrCurve, Convert_RationalC1);
1302 Standard_Real aTol = Precision::Confusion();
1303 Standard_Real aDelta = Max(a2Offset, 1.);
1304
1305 if (FirstPar > anEf - a2Offset) {
1306 C3d->D1(FirstPar, aPBnd, aVBnd);
1307 aDBnd.SetXYZ(aVBnd.XYZ());
1308 aPBeg = aPBnd.Translated(gp_Vec(-aDelta*aDBnd.XYZ()));
1309 aLin = new Geom_Line(aPBeg, aDBnd);
1310 aSegment = new Geom_TrimmedCurve(aLin, 0, aDelta);
1311
1312 if (!aCompCurve.Add(aSegment, aTol))
1313 return;
1314 }
1315
1316 if (LastPar < anEl + a2Offset) {
1317 C3d->D1(LastPar, aPBeg, aVBnd);
1318 aDBnd.SetXYZ(aVBnd.XYZ());
1319 aLin = new Geom_Line(aPBeg, aDBnd);
1320 aSegment = new Geom_TrimmedCurve(aLin, 0, aDelta);
1321
1322 if (!aCompCurve.Add(aSegment, aTol))
1323 return;
1324 }
1325
1326 C3d = aCompCurve.BSplineCurve();
1327 FirstPar = C3d->FirstParameter();
1328 LastPar = C3d->LastParameter();
1329 BB.UpdateEdge(NE, C3d, Precision::Confusion());
1330 }
1331 else if (C3d->IsPeriodic())
1332 {
1333 Standard_Real delta = (C3d->Period() - (anEl - anEf))*0.5;
1334 delta *= 0.95;
1335 FirstPar = anEf - delta;
1336 LastPar = anEl + delta;
1337 }
1338 else if (C3d->IsClosed())
1339 LastPar -= 0.05*(LastPar - FirstPar);
1340
1341 BB.Range( NE, FirstPar, LastPar );
1342 }
1343}
1344// Modified by skv - Fri Dec 26 17:00:57 2003 OCC4455 End
1345
1346
1347//=======================================================================
1348//function : UpdateVertex
1349//purpose :
1350//=======================================================================
1351
1352static Standard_Boolean UpdateVertex(TopoDS_Vertex V,
1353 TopoDS_Edge& OE,
1354 TopoDS_Edge& NE,
1355 Standard_Real TolConf)
1356{
1357 BRepAdaptor_Curve OC(OE);
1358 BRepAdaptor_Curve NC(NE);
1359 Standard_Real Of = OC.FirstParameter(); Standard_Real Ol = OC.LastParameter();
1360 Standard_Real Nf = NC.FirstParameter(); Standard_Real Nl = NC.LastParameter();
1361#ifndef DEB
1362 Standard_Real U = 0.;
1363#else
1364 Standard_Real U;
1365#endif
1366 Standard_Real ParTol = Precision::PConfusion();
1367 gp_Pnt P = BRep_Tool::Pnt(V);
1368 Standard_Boolean OK = Standard_False;
1369
1370 if (P.Distance(OC.Value(Of)) < TolConf) {
1371 if (Of >= Nf + ParTol && Of <= Nl + ParTol && P.Distance(NC.Value(Of)) < TolConf) {
1372 OK = Standard_True;
1373 U = Of;
1374 }
1375 }
1376 if (P.Distance(OC.Value(Ol)) < TolConf) {
1377 if (Ol >= Nf + ParTol && Ol <= Nl + ParTol && P.Distance(NC.Value(Ol)) < TolConf) {
1378 OK = Standard_True;
1379 U = Ol;
1380 }
1381 }
1382 if (OK) {
1383 BRep_Builder B;
1384 TopoDS_Shape aLocalShape = NE.Oriented(TopAbs_FORWARD);
1385 TopoDS_Edge EE = TopoDS::Edge(aLocalShape);
1386// TopoDS_Edge EE = TopoDS::Edge(NE.Oriented(TopAbs_FORWARD));
1387 aLocalShape = V.Oriented(TopAbs_INTERNAL);
1388 B.UpdateVertex(TopoDS::Vertex(aLocalShape),
1389 U,NE,BRep_Tool::Tolerance(NE));
1390// B.UpdateVertex(TopoDS::Vertex(V.Oriented(TopAbs_INTERNAL)),
1391// U,NE,BRep_Tool::Tolerance(NE));
1392 }
1393 return OK;
1394}
1395
1396//=======================================================================
1397//function : Compute
1398//purpose :
1399//=======================================================================
1400
975ec82a
J
1401void BRepOffset_Inter2d::Compute (const Handle(BRepAlgo_AsDes)& AsDes,
1402 const TopoDS_Face& F,
1403 const TopTools_IndexedMapOfShape& NewEdges,
1404 const Standard_Real Tol)
7fd59977 1405{
1406#ifdef DEB
1407 NbF2d++;
1408 NbE2d = 0;
1409#endif
1410
1411 //Do not intersect the edges of face
1412 TopTools_MapOfShape EdgesOfFace;
1413 TopExp_Explorer Explo( F, TopAbs_EDGE );
1414 for (; Explo.More(); Explo.Next())
1415 EdgesOfFace.Add( Explo.Current() );
1416
1417 //-----------------------------------------------------------
0d969553 1418 // calculate intersections2d on faces touched by
7fd59977 1419 // intersection3d
1420 //---------------------------------------------------------
1421 TopTools_ListIteratorOfListOfShape it1LE ;
1422 TopTools_ListIteratorOfListOfShape it2LE ;
1423
1424 //-----------------------------------------------
0d969553 1425 // Intersection of edges 2*2.
7fd59977 1426 //-----------------------------------------------
1427 const TopTools_ListOfShape& LE = AsDes->Descendant(F);
1428 TopoDS_Vertex V1,V2;
1429 Standard_Integer j, i = 1;
1430
1431 for ( it1LE.Initialize(LE) ; it1LE.More(); it1LE.Next()) {
1432 const TopoDS_Edge& E1 = TopoDS::Edge(it1LE.Value());
1433 j = 1;
1434 it2LE.Initialize(LE);
1435
1436 while (j < i && it2LE.More()) {
1437 const TopoDS_Edge& E2 = TopoDS::Edge(it2LE.Value());
1438 //--------------------------------------------------------------
0d969553
Y
1439 // Intersections of New edges obtained by intersection
1440 // between them and with edges of restrictions
7fd59977 1441 //------------------------------------------------------
1442 if ( (!EdgesOfFace.Contains(E1) || !EdgesOfFace.Contains(E2)) &&
1443 (NewEdges.Contains(E1) || NewEdges.Contains(E2)) ) {
1444 TopoDS_Shape aLocalShape = F.Oriented(TopAbs_FORWARD);
1445 EdgeInter(TopoDS::Face(aLocalShape),E1,E2,AsDes,Tol,Standard_True);
1446// EdgeInter(TopoDS::Face(F.Oriented(TopAbs_FORWARD)),E1,E2,AsDes,Tol,Standard_True);
1447 }
1448 it2LE.Next();
1449 j++;
1450 }
1451 i++;
1452 }
1453}
1454
1455//=======================================================================
1456//function : ConnexIntByInt
1457//purpose :
1458//=======================================================================
1459
1460// Modified by skv - Fri Dec 26 16:53:16 2003 OCC4455 Begin
1461// Add another parameter: offset value.
1462void BRepOffset_Inter2d::ConnexIntByInt
1463(const TopoDS_Face& FI,
1464 BRepOffset_Offset& OFI,
1465 TopTools_DataMapOfShapeShape& MES,
1466 const TopTools_DataMapOfShapeShape& Build,
1467 const Handle(BRepAlgo_AsDes)& AsDes,
1468 const Standard_Real Offset,
1469 const Standard_Real Tol)
1470// Modified by skv - Fri Dec 26 16:53:18 2003 OCC4455 End
1471{
1472
1473 TopTools_DataMapOfShapeListOfShape MVE;
1474 BRepOffset_Tool::MapVertexEdges(FI,MVE);
1475
1476 //---------------------
0d969553 1477 // Extension of edges.
7fd59977 1478 //---------------------
1479 TopoDS_Edge NE;
1480 TopTools_DataMapIteratorOfDataMapOfShapeListOfShape it(MVE);
1481 for ( ; it.More(); it.Next()) {
1482 const TopTools_ListOfShape& L = it.Value();
1483 Standard_Boolean YaBuild = 0;
1484 TopTools_ListIteratorOfListOfShape itL(L);
1485 for (; itL.More(); itL.Next()) {
1486 YaBuild = Build.IsBound(itL.Value());
1487 if (YaBuild) break;
1488 }
1489 if (YaBuild) {
1490 for (itL.Initialize(L); itL.More(); itL.Next()) {
1491 const TopoDS_Edge& EI = TopoDS::Edge(itL.Value());
1492 TopoDS_Shape aLocalShape = OFI.Generated(EI);
1493 const TopoDS_Edge& OE = TopoDS::Edge(aLocalShape);
1494// const TopoDS_Edge& OE = TopoDS::Edge(OFI.Generated(EI));
1495 if (!MES.IsBound(OE) && !Build.IsBound(EI)) {
1496// Modified by skv - Fri Dec 26 16:59:52 2003 OCC4455 Begin
1497// ExtentEdge(OE,NE);
1498 ExtentEdge(OE,NE, Offset);
1499// Modified by skv - Fri Dec 26 16:59:54 2003 OCC4455 End
1500 MES.Bind (OE,NE);
1501 }
1502 }
1503 }
1504 }
1505
1506 TopoDS_Face FIO = TopoDS::Face(OFI.Face());
1507 if (MES.IsBound(FIO)) FIO = TopoDS::Face(MES(FIO));
1508
1509 TopExp_Explorer exp(FI.Oriented(TopAbs_FORWARD),TopAbs_WIRE);
1510 for (; exp.More(); exp.Next()) {
1511 const TopoDS_Wire& W = TopoDS::Wire(exp.Current());
1512 BRepTools_WireExplorer wexp;
1513 Standard_Boolean end = Standard_False ;
1514 TopoDS_Edge FirstE,CurE,NextE;
1515
1516 TopoDS_Shape aLocalWire = W .Oriented(TopAbs_FORWARD);
1517 TopoDS_Shape aLocalFace = FI.Oriented(TopAbs_FORWARD);
1518 wexp.Init(TopoDS::Wire(aLocalWire),TopoDS::Face(aLocalFace));
1519// wexp.Init(TopoDS::Wire(W .Oriented(TopAbs_FORWARD)),
1520// TopoDS::Face(FI.Oriented(TopAbs_FORWARD)));
1521 CurE = FirstE = wexp.Current();
1522 while (!end) {
1523 wexp.Next();
1524 if (wexp.More()) {
1525 NextE = wexp.Current();
1526 }
1527 else {
1528 NextE = FirstE; end = Standard_True;
1529 }
1530 if (CurE.IsSame(NextE)) continue;
1531
1532 //IFV------------
1533 TopoDS_Vertex Vref = CommonVertex(CurE, NextE);
1534 gp_Pnt Pref = BRep_Tool::Pnt(Vref);
1535 //IFV------------
1536
1537 TopoDS_Shape aLocalShape = OFI.Generated(CurE);
1538 TopoDS_Edge CEO = TopoDS::Edge(aLocalShape);
1539 aLocalShape = OFI.Generated(NextE);
1540 TopoDS_Edge NEO = TopoDS::Edge(aLocalShape);
1541// TopoDS_Edge CEO = TopoDS::Edge(OFI.Generated(CurE));
1542// TopoDS_Edge NEO = TopoDS::Edge(OFI.Generated(NextE));
1543 //------------------------------------------
0d969553 1544 // Inter processing of images of CurE NextE.
7fd59977 1545 //------------------------------------------
1546 TopTools_ListOfShape LV1,LV2;
1547 Standard_Boolean DoInter = 1;
1548 TopoDS_Shape NE1,NE2;
1549
1550 if (Build.IsBound(CurE) && Build.IsBound(NextE)) {
1551 NE1 = Build(CurE );
1552 NE2 = Build(NextE);
1553 }
1554 else if (Build.IsBound(CurE) && MES.IsBound(NEO)) {
1555 NE1 = Build(CurE);
1556 NE2 = MES (NEO);
1557 }
1558 else if (Build.IsBound(NextE) && MES.IsBound(CEO)) {
1559 NE1 = Build(NextE);
1560 NE2 = MES(CEO);
1561 }
1562 else {
1563 DoInter = 0;
1564 }
1565 if (DoInter) {
1566 //------------------------------------
1567 // NE1,NE2 can be a compound of Edges.
1568 //------------------------------------
1569 TopExp_Explorer Exp1,Exp2;
1570 for (Exp1.Init(NE1,TopAbs_EDGE) ; Exp1.More(); Exp1.Next()) {
1571 for (Exp2.Init(NE2,TopAbs_EDGE) ; Exp2.More(); Exp2.Next()) {
1572 RefEdgeInter(FIO,TopoDS::Edge(Exp1.Current()),TopoDS::Edge(Exp2.Current()),
1573 AsDes,Tol,Standard_True/*Standard_False*/, Pref);
1574 }
1575 }
1576 }
1577 else {
1578 if (MES.IsBound(CEO)) {
1579 TopoDS_Vertex V = CommonVertex(CEO,NEO);
1580 UpdateVertex (V,CEO,TopoDS::Edge(MES(CEO)),Tol);
1581 AsDes->Add (MES(CEO),V);
1582 }
1583 else if (MES.IsBound(NEO)) {
1584 TopoDS_Vertex V = CommonVertex(CEO,NEO);
1585 UpdateVertex (V,NEO,TopoDS::Edge(MES(NEO)),Tol);
1586 AsDes->Add (MES(NEO),V);
1587 }
1588 }
1589 CurE = NextE;
1590 }
1591 }
1592}
1593
1594
1595