0033661: Data Exchange, Step Import - Tessellated GDTs are not imported
[occt.git] / src / HLRTopoBRep / HLRTopoBRep_DSFiller.cxx
1 // Created on: 1993-08-10
2 // Created by: Christophe MARION
3 // Copyright (c) 1993-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
5 //
6 // This file is part of Open CASCADE Technology software library.
7 //
8 // This library is free software; you can redistribute it and/or modify it under
9 // the terms of the GNU Lesser General Public License version 2.1 as published
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.
13 //
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
16
17
18 #include <AppDef_BSplineCompute.hxx>
19 #include <AppDef_MultiLine.hxx>
20 #include <AppParCurves_MultiBSpCurve.hxx>
21 #include <BRep_Builder.hxx>
22 #include <BRep_TEdge.hxx>
23 #include <BRep_Tool.hxx>
24 #include <BRepApprox_Approx.hxx>
25 #include <BRepApprox_ApproxLine.hxx>
26 #include <BRepExtrema_ExtPC.hxx>
27 #include <BRepTopAdaptor_HVertex.hxx>
28 #include <BRepTopAdaptor_TopolTool.hxx>
29 #include <Contap_Contour.hxx>
30 #include <Contap_Line.hxx>
31 #include <Contap_Point.hxx>
32 #include <Extrema_LocateExtPC.hxx>
33 #include <Geom2d_BSplineCurve.hxx>
34 #include <Geom2d_Curve.hxx>
35 #include <Geom_BSplineCurve.hxx>
36 #include <Geom_Circle.hxx>
37 #include <Geom_Line.hxx>
38 #include <Geom_Surface.hxx>
39 #include <GeomProjLib.hxx>
40 #include <HLRTopoBRep_Data.hxx>
41 #include <HLRTopoBRep_DSFiller.hxx>
42 #include <HLRTopoBRep_FaceIsoLiner.hxx>
43 #include <math_Vector.hxx>
44 #include <Precision.hxx>
45 #include <Standard_ProgramError.hxx>
46 #include <TColgp_Array1OfPnt.hxx>
47 #include <TColgp_Array1OfPnt2d.hxx>
48 #include <TColStd_Array1OfInteger.hxx>
49 #include <TColStd_Array1OfReal.hxx>
50 #include <TopExp.hxx>
51 #include <TopExp_Explorer.hxx>
52 #include <TopoDS.hxx>
53 #include <TopoDS_Edge.hxx>
54 #include <TopoDS_Face.hxx>
55 #include <TopoDS_Shape.hxx>
56 #include <TopoDS_Vertex.hxx>
57
58 //=======================================================================
59 //function : Insert
60 //purpose  : explore the faces and insert them
61 //=======================================================================
62
63 void  HLRTopoBRep_DSFiller::Insert (const TopoDS_Shape& S,
64                                     Contap_Contour& FO,
65                                     HLRTopoBRep_Data& DS,
66                                     BRepTopAdaptor_MapOfShapeTool& MST,
67                                     const Standard_Integer nbIso)
68 {
69   TopTools_MapOfShape ShapeMap;
70   TopExp_Explorer ex(S,TopAbs_FACE);
71   DS.Clear();
72   Standard_Boolean withPCurve = Standard_True; // instead of nbIso != 0;
73   Standard_Integer f = 0;
74   
75   while (ex.More()) {
76     if (ShapeMap.Add(ex.Current())) {
77       f++;
78       TopoDS_Face S1 = TopoDS::Face(ex.Current());
79       S1.Orientation(TopAbs_FORWARD);
80       Handle(BRepTopAdaptor_TopolTool) Domain; 
81       Handle(Adaptor3d_Surface)         Surface;
82       if(MST.IsBound(S1)) {  
83         BRepTopAdaptor_Tool& BRT = MST.ChangeFind(S1);
84         Domain  = BRT.GetTopolTool();
85         Surface = BRT.GetSurface();
86       }
87       else { 
88         BRepTopAdaptor_Tool BRT(S1,Precision::PConfusion());
89         MST.Bind(S1,BRT);
90         Domain  = BRT.GetTopolTool();
91         Surface = BRT.GetSurface();
92       }
93       FO.Perform(Surface, Domain);
94       if (FO.IsDone()) {
95         if (!FO.IsEmpty())
96           InsertFace(f,S1,FO,DS,withPCurve);
97       }
98       if (nbIso != 0) HLRTopoBRep_FaceIsoLiner::Perform(f,S1,DS,nbIso);
99     }
100     ex.Next();
101   }
102   ProcessEdges(DS);
103 }
104
105 //=======================================================================
106 //function : InsertFace
107 //purpose  : private, insert the outlines of a face
108 //=======================================================================
109
110 void  HLRTopoBRep_DSFiller::InsertFace (const Standard_Integer /*FI*/,
111                                         const TopoDS_Face& F,
112                                         Contap_Contour& FO,
113                                         HLRTopoBRep_Data& DS,
114                                         const Standard_Boolean withPCurve)
115 {
116   // Insert the intersections of FO in DS
117
118   const Standard_Real tol = BRep_Tool::Tolerance(F);
119   TopTools_ListOfShape& IntL = DS.AddIntL(F);
120   TopTools_ListOfShape& OutL = DS.AddOutL(F);
121
122   TopoDS_Vertex VF,VL;
123   /*
124   TopTools_MapOfShape VM;
125   TopExp_Explorer ex(F,TopAbs_EDGE);
126   while (ex.More()) {
127     const TopoDS_Edge& E = TopoDS::Edge(ex.Current());
128     if (BRep_Tool::IsClosed(E,F)) {
129       TopExp::Vertices(E,VF,VL);
130       VM.Add(VF);
131       VM.Add(VL);
132     }
133     ex.Next();
134   }
135   */
136
137   const Standard_Integer NbLines = FO.NbLines();
138   Standard_Integer CurLine;
139   for (CurLine = 1; CurLine <= NbLines; CurLine++)
140   {
141     const Contap_Line& Line = FO.Line(CurLine);
142     const Standard_Integer NbPoints = Line.NbVertex();
143     Standard_Integer CurPoint;
144     if (Line.TypeContour() == Contap_Restriction)
145     {
146       // OutLine on restriction
147       TopoDS_Edge E = (*(BRepAdaptor_Curve2d*)(Line.Arc().get())).Edge();
148       OutL.Append(E);
149       TopExp::Vertices(E,VF,VL);
150       // insert the Internal points.
151
152       for (CurPoint = 1; CurPoint <= NbPoints; CurPoint++) {
153         Contap_Point P = Line.Vertex(CurPoint);
154         if (P.IsInternal()) {
155           if (P.Value().IsEqual(BRep_Tool::Pnt(VF),BRep_Tool::Tolerance(VF))) {
156             if (P.Value().IsEqual(BRep_Tool::Pnt(VL),BRep_Tool::Tolerance(VL))) {
157               InsertVertex(P,tol,E,DS);
158             }
159           }
160         }
161       }
162     }
163     else
164     {
165       for (CurPoint = 1; CurPoint <= NbPoints; CurPoint++) {
166
167         const Contap_Point PF = Line.Vertex(CurPoint);
168         if (PF.IsInternal() && CurPoint != 1)
169           VF = VL;
170         else
171           VF = MakeVertex(PF,tol,DS);
172         const Standard_Real parF = PF.ParameterOnLine();
173
174         if (CurPoint < NbPoints) {
175           const Contap_Point PL = Line.Vertex(CurPoint+1);
176           VL = MakeVertex(PL,tol,DS);
177           const Standard_Real parL = PL.ParameterOnLine();
178
179           if( (parL-parF) > Precision::PConfusion() ) {
180
181             Handle(Geom_Curve) C;
182             Handle(Geom2d_Curve) C2d;
183             Standard_Real first = parF;
184             Standard_Real last  = parL;
185             Standard_Boolean InsuffisantNumberOfPoints=Standard_False;
186
187             switch (Line.TypeContour()) {
188               
189               case Contap_Lin :
190               {
191                 C = new Geom_Line(Line.Line());
192                 if (withPCurve) {
193                   Handle(Geom_Surface) S = BRep_Tool::Surface(F);
194                   Standard_Real Tol = 1e-7;
195                   C2d = GeomProjLib::Curve2d(C,first,last,S,Tol); 
196                 }
197               }
198               break;
199               
200               case Contap_Circle :
201               {
202                 C = new Geom_Circle(Line.Circle());
203                 if (withPCurve) {
204                   TopLoc_Location Loc;
205                   Handle(Geom_Surface) S = BRep_Tool::Surface(F,Loc);
206                   if (!Loc.IsIdentity()) {
207                     S = Handle(Geom_Surface)::DownCast(S->Transformed(Loc.Transformation()));
208                   }
209                   Standard_Real Tol = 1e-7;
210                   C2d = GeomProjLib::Curve2d(C,first,last,S,Tol); 
211                 }
212               }
213               break;
214               
215               case Contap_Walking :
216               {
217                 // copy the points
218                 Standard_Integer ipF = Standard_Integer(parF);
219                 Standard_Integer ipL = Standard_Integer(parL);
220                 
221                 if(ipL-ipF < 1) { 
222                   InsuffisantNumberOfPoints=Standard_True;
223                   //std::cout<<"\n !! Pb ds HLRTopoBRep_DSFiller.cxx (Contour App Nbp <3)"<<std::endl;
224                 }
225 /*
226                 else if(ipL-ipF < 6) { 
227                   // compute the tangents
228                   Contap_SurfFunction& SFunc =
229                     FO.SurfaceFunction();
230                   
231                   Standard_Boolean isTg1,isTg2;
232                   gp_Vec tg1,tg2;
233                   gp_Vec2d uv1,uv2;
234                   math_Vector UV(1,2),F(1,1);
235                   
236                   Line.Point(ipF).ParametersOnS2(UV(1),UV(2));
237                   SFunc.Value(UV,F);
238                   isTg1 = SFunc.IsTangent();
239                   if (!isTg1) {
240                     tg1 = SFunc.Direction3d();
241                     if (withPCurve) uv1 = SFunc.Direction2d();
242                   }
243                   
244                   Line.Point(ipL).ParametersOnS2(UV(1),UV(2));
245                   SFunc.Value(UV,F);
246                   isTg2 = SFunc.IsTangent();
247                   if (!isTg2) {
248                     tg2 = SFunc.Direction3d();
249                     if (withPCurve) uv2 = SFunc.Direction2d();
250                   }
251                   // interpolate
252                   Standard_Integer nbp = ipL - ipF + 1;
253                   AppDef_MultiLine MLine(nbp);
254                   Standard_Integer nb2d = 0;
255                   if (withPCurve)  nb2d = 1;
256                   
257                   for (Standard_Integer i = 1; i <= nbp; i++) {
258                     AppDef_MultiPointConstraint MP(1, nb2d);
259                     MP.SetPoint(1,Line.Point(i + ipF - 1).Value());
260                     if (withPCurve) {
261                       Line.Point(i + ipF - 1).ParametersOnS2(UV(1),UV(2));
262                       MP.SetPoint2d(2,gp_Pnt2d(UV(1),UV(2)));
263                     }
264                     
265                     if (i == 1   && !isTg1) {
266                       MP.SetTang  (1,tg1);
267                       if (withPCurve) MP.SetTang2d(2,uv1);
268                     }
269                     if (i == nbp && !isTg2) {
270                       MP.SetTang  (1,tg2);
271                       if (withPCurve) MP.SetTang2d(2,uv2);
272                     }
273                     MLine.SetValue(i,MP);
274                   }
275                   AppDef_BSplineCompute interp;
276                   interp.Interpol(MLine);
277                   AppParCurves_MultiBSpCurve TheCurve = interp.Value();
278                   Standard_Integer Degree = TheCurve.Degree();
279                   TColgp_Array1OfPnt   Poles(1,TheCurve.NbPoles());
280                   TheCurve.Curve(1,Poles);
281                   C   = new Geom_BSplineCurve(Poles, 
282                                               TheCurve.Knots(),
283                                               TheCurve.Multiplicities(),
284                                               Degree);
285                   if (withPCurve) {
286                     TColgp_Array1OfPnt2d Pol2d(1,TheCurve.NbPoles());
287                     TheCurve.Curve(2,Pol2d);
288                     C2d = new Geom2d_BSplineCurve(Pol2d, 
289                                                   TheCurve.Knots(),
290                                                   TheCurve.Multiplicities(),
291                                                   Degree);
292                   }
293                   first = 0;
294                   last = 1;
295                 }
296 */
297                 else if(ipL-ipF < 5) { 
298                   const Standard_Integer nbp = ipL - ipF + 1;
299                   TColStd_Array1OfReal knots(1,nbp);
300                   TColStd_Array1OfInteger mults(1,nbp);
301                   TColgp_Array1OfPnt Points(1,nbp);
302
303                   for(Standard_Integer i=1;i<=nbp;i++) {
304                     knots.SetValue(i,(Standard_Real)i);
305                     mults.SetValue(i,1);
306                     Points.SetValue(i,Line.Point(i+ipF-1).Value());
307                   }
308                   mults(1)=mults(nbp)=2;
309                   C = new Geom_BSplineCurve(Points,knots,mults,1);
310                   
311                   if(withPCurve) { 
312                     TColgp_Array1OfPnt2d Points2d(1,nbp);
313                     for(Standard_Integer i=1;i<=nbp;i++) {
314                       Standard_Real u,v;
315                       Line.Point(i+ipF-1).ParametersOnS2(u,v);
316                       Points2d.SetValue(i,gp_Pnt2d(u,v));
317                     }
318                     C2d = new Geom2d_BSplineCurve(Points2d,knots,mults,1);
319                   }
320                   first = 1;
321                   last = nbp;
322                 }
323                 else { 
324                   const Standard_Integer nbp = ipL - ipF + 1;
325                   TColStd_Array1OfReal knots(1,nbp);
326                   TColStd_Array1OfInteger mults(1,nbp);
327                   TColgp_Array1OfPnt Points(1,nbp);
328
329                   Standard_Real Maxx,Maxy,Maxz,Maxu,Maxv;
330                   Standard_Real Minx,Miny,Minz,Minu,Minv;
331                   Maxx=Maxy=Maxz=Maxu=Maxv=-RealLast();
332                   Minx=Miny=Minz=Minu=Minv=RealLast();
333                   
334                   for(Standard_Integer i=1;i<=nbp;i++) {
335                     knots.SetValue(i,(Standard_Real)i);
336                     mults.SetValue(i,1);
337                     const gp_Pnt& P= Line.Point(i+ipF-1).Value();
338                     if(P.X()<Minx) Minx=P.X();
339                     if(P.Y()<Miny) Miny=P.Y();
340                     if(P.Z()<Minz) Minz=P.Z();
341                     if(P.X()>Maxx) Maxx=P.X();
342                     if(P.Y()>Maxy) Maxy=P.Y();
343                     if(P.Z()>Maxz) Maxz=P.Z();              
344                     Points.SetValue(i,P);
345                   }
346                   mults(1)=mults(nbp)=2;
347                   Handle(Geom_BSplineCurve)   AppC;
348                   Handle(Geom2d_BSplineCurve) AppC2d;
349                   AppC = new Geom_BSplineCurve(Points,knots,mults,1);
350
351                   if(withPCurve) {
352                     TColgp_Array1OfPnt2d Points2d(1,nbp);
353                     for(Standard_Integer i=1;i<=nbp;i++) {
354                       Standard_Real u,v;
355                       Line.Point(i+ipF-1).ParametersOnS2(u,v);
356                       if(u<Minu) Minu=u;
357                       if(v<Minv) Minv=v;
358                       if(u>Maxu) Maxu=u;
359                       if(v>Maxv) Maxv=v;
360                       Points2d.SetValue(i,gp_Pnt2d(u,v));
361                     }
362                     AppC2d = new Geom2d_BSplineCurve(Points2d,knots,mults,1);
363                   }
364                   first = 1;
365                   last = nbp;
366                   
367                   Handle(BRepApprox_ApproxLine) AppLine;
368                   Handle(Geom2d_BSplineCurve) CNull;
369                   AppLine = new BRepApprox_ApproxLine(AppC,AppC2d,CNull);
370                   
371                   Standard_Integer dmin=4,dmax=8,niter=0;
372                   Standard_Boolean tg= Standard_False;
373                   BRepApprox_Approx Approx;
374                   Standard_Real TOL3d,TOL2d,TOL=0.0001;
375
376                   Maxx-=Minx; Maxy-=Miny; Maxz-=Minz;
377                   Maxu-=Minu; Maxv-=Minv;
378                   if(Maxy>Maxx) Maxx=Maxy;
379                   if(Maxz>Maxx) Maxx=Maxy;
380                   if(Maxv>Maxu) Maxu=Maxv;
381
382                   TOL3d=TOL*Maxx; if(TOL3d<1e-12) TOL3d=1e-12; else if(TOL3d>0.1) TOL3d=0.1;
383                   TOL2d=TOL*Maxu; if(TOL2d<1e-12) TOL2d=1e-12; else if(TOL2d>0.1) TOL2d=0.1;
384                   
385                   //-- std::cout<<"\nHLRTopoBRep_DSFiller : nbp="<<nbp<<"  Tol3d="<<TOL3d<<"   Tol2d="<<TOL2d<<std::endl;
386
387                   Approx.SetParameters(TOL3d, TOL2d, dmin, dmax, niter, 30, tg);
388                   Approx.Perform(AppLine,Standard_True,Standard_True,Standard_False,1,nbp);
389                   if (!Approx.IsDone()) {
390                     C = AppC;
391                     C2d=AppC2d; 
392                     first = 1;
393                     last = nbp;
394                   }
395                   else { 
396                     const AppParCurves_MultiBSpCurve& AppVal = Approx.Value(1); 
397                     TColgp_Array1OfPnt poles3d(1,AppVal.NbPoles());
398                     AppVal.Curve(1,poles3d);
399                     C = new Geom_BSplineCurve(poles3d,AppVal.Knots(),AppVal.Multiplicities(),AppVal.Degree());
400                     
401                     const AppParCurves_MultiBSpCurve& AppVal2 = Approx.Value(2);
402                     TColgp_Array1OfPnt2d poles2d(1,AppVal2.NbPoles());
403                     AppVal2.Curve(2,poles2d);
404                     C2d = new Geom2d_BSplineCurve(poles2d,AppVal2.Knots(),AppVal2.Multiplicities(),AppVal2.Degree());
405                     first = C2d->FirstParameter();
406                     last  = C2d->LastParameter();
407                   }
408                 }
409               }
410               break;
411               
412               case Contap_Restriction :
413               {
414                 throw Standard_ProgramError("HLRTopoBRep_DSFiller::InsertFace : Restriction");
415               }
416               break;
417             }
418             
419             // compute the PCurve
420             // make the edge
421             if (!InsuffisantNumberOfPoints) {
422               TopoDS_Edge E;
423               BRep_Builder B;
424               B.MakeEdge(E,C,tol);
425               VF.Orientation(TopAbs_FORWARD);
426               VL.Orientation(TopAbs_REVERSED);
427               B.Add(E,VF);
428               B.Add(E,VL);
429               B.Range(E,first,last);
430
431               if (!C2d.IsNull()) {
432                 B.UpdateEdge(E,C2d,F,BRep_Tool::Tolerance(F));
433               }
434               
435               // add the edge in the DS
436               if (!E.IsNull())
437                 IntL.Append(E);
438             }
439           }
440         }
441       }
442     }
443   }
444
445   //Correction of internal outlines: unite coinciding vertices
446   const Standard_Real SqTol = tol*tol;
447   TopTools_ListIteratorOfListOfShape itl1(IntL);
448   for (; itl1.More(); itl1.Next())
449   {
450     TopoDS_Edge anIntLine = TopoDS::Edge(itl1.Value());
451     anIntLine.Orientation(TopAbs_FORWARD);
452     TopoDS_Vertex aVer [2];
453     TopExp::Vertices(anIntLine, aVer[0], aVer[1]);
454     TopTools_ListIteratorOfListOfShape itl2 = itl1;
455     for (; itl2.More(); itl2.Next())
456     {
457       TopoDS_Edge anIntLine2 = TopoDS::Edge(itl2.Value());
458       anIntLine2.Orientation(TopAbs_FORWARD);
459       if (anIntLine2.IsSame(anIntLine))
460         continue;
461       TopoDS_Vertex aVer2 [2];
462       TopExp::Vertices(anIntLine2, aVer2[0], aVer2[1]);
463       for (Standard_Integer i = 0; i < 2; i++)
464       {
465         if (i == 1 && aVer[0].IsSame(aVer[1]))
466           continue;
467         gp_Pnt Pnt1 = BRep_Tool::Pnt(aVer[i]);
468         for (Standard_Integer j = 0; j < 2; j++)
469         {
470           if (aVer[i].IsSame(aVer2[j]))
471             continue;
472           gp_Pnt Pnt2 = BRep_Tool::Pnt(aVer2[j]);
473           if (Pnt1.SquareDistance(Pnt2) <= SqTol)
474           {
475             BRep_Builder aBB;
476             aBB.Remove(anIntLine2, aVer2[j]);
477             aVer[i].Orientation((j==0)? TopAbs_FORWARD : TopAbs_REVERSED);
478             aBB.Add(anIntLine2, aVer[i]);
479           }
480         }
481       }
482     }
483   }
484 }
485
486 //=======================================================================
487 //function : MakeVertex
488 //purpose  : private, make a vertex from an intersection point
489 //=======================================================================
490
491 TopoDS_Vertex
492 HLRTopoBRep_DSFiller::MakeVertex (const Contap_Point& P,
493                                   const Standard_Real tol,
494                                   HLRTopoBRep_Data& DS)
495 {
496   BRep_Builder B;
497   TopoDS_Vertex V;
498   if (P.IsVertex()) {
499     V = Handle(BRepTopAdaptor_HVertex)::DownCast(P.Vertex())->Vertex();
500     DS.AddOutV(V);
501   }
502   else {
503     // if on arc, insert in the DS
504     if (P.IsOnArc()) {
505       const TopoDS_Edge& E = (*(BRepAdaptor_Curve2d*)(P.Arc().get())).Edge();
506       Standard_Real Par = P.ParameterOnArc();
507       const gp_Pnt& P3d = P.Value();
508
509       for (DS.InitVertex(E); DS.MoreVertex(); DS.NextVertex()) {
510         TopoDS_Vertex curV = DS.Vertex();
511         Standard_Real curP = DS.Parameter();
512         const gp_Pnt& PPP=BRep_Tool::Pnt(curV);
513         Standard_Real TTT=BRep_Tool::Tolerance(curV);
514         if (P3d.IsEqual(PPP,TTT)) { 
515           V = curV;
516           break;
517         }
518         else if (Par < curP) {
519           B.MakeVertex(V,P.Value(),tol);
520           DS.InsertBefore(V,Par);
521           break;
522         }
523       }
524       if (!DS.MoreVertex()) {
525         B.MakeVertex(V,P.Value(),tol);
526         DS.Append(V,Par);
527       } 
528       DS.AddOutV(V);
529     }
530     // if internal create a vertex and insert in the DS
531     else {
532       B.MakeVertex(V,P.Value(),tol);
533       if (P.IsInternal())
534         DS.AddIntV(V);
535       else
536         DS.AddOutV(V);
537     }
538   }
539   return V;
540 }
541
542 //=======================================================================
543 //function : InsertVertex
544 //purpose  : private, insert a vertex from an internal intersection point
545 //           on resctriction
546 //=======================================================================
547
548 void
549 HLRTopoBRep_DSFiller::InsertVertex (const Contap_Point& P,
550                                     const Standard_Real tol,
551                                     const TopoDS_Edge& E,
552                                     HLRTopoBRep_Data& DS)
553 {
554   BRep_Builder B;
555   TopoDS_Vertex V;
556
557   if (P.IsVertex()) {
558     V = Handle(BRepTopAdaptor_HVertex)::DownCast(P.Vertex())->Vertex();
559   }
560   else {
561     Standard_Real Par = P.ParameterOnLine();
562     
563     for (DS.InitVertex(E); DS.MoreVertex(); DS.NextVertex()) {
564       TopoDS_Vertex curV = DS.Vertex();
565       Standard_Real curP = DS.Parameter();
566       if (P.Value().IsEqual(BRep_Tool::Pnt(curV),
567                             BRep_Tool::Tolerance(curV))) {
568         V = curV;
569         break;
570       }
571       else if (Par < curP) {
572         B.MakeVertex(V,P.Value(),tol);
573         DS.InsertBefore(V,Par);
574         break;
575       }
576     }
577     if (!DS.MoreVertex()) {
578       B.MakeVertex(V,P.Value(),tol);
579       DS.Append(V,Par);
580     }   
581   }
582   DS.AddIntV(V);
583 }
584
585 //=======================================================================
586 //function : ProcessEdges
587 //purpose  : private, split edges with outline vertices
588 //=======================================================================
589
590 void  HLRTopoBRep_DSFiller::ProcessEdges (HLRTopoBRep_Data& DS)
591 {
592   BRep_Builder B;
593   TopoDS_Edge newE;
594   TopoDS_Vertex VF,VL,VI;
595   Standard_Real PF,PL,PI;
596
597   for (DS.InitEdge(); DS.MoreEdge(); DS.NextEdge()) {
598     TopoDS_Edge E = DS.Edge();
599     TopTools_ListOfShape& SplE = DS.AddSplE(E);
600     VF = TopExp::FirstVertex(E);
601     VL = TopExp::LastVertex(E);
602     BRep_Tool::Range(E,PF,PL);
603     VF.Orientation(TopAbs_FORWARD);
604     VL.Orientation(TopAbs_REVERSED);
605
606     for (DS.InitVertex(E); DS.MoreVertex(); DS.NextVertex()) {
607       VI = DS.Vertex();
608       PI = DS.Parameter();
609       VI.Orientation(TopAbs_REVERSED);
610       newE = E;
611       newE.EmptyCopy();
612       newE.Orientation(TopAbs_FORWARD);
613       B.Add(newE,VF);
614       B.UpdateVertex(VF,PF,newE,BRep_Tool::Tolerance(VF));
615       B.Add(newE,VI);
616       B.UpdateVertex(VI,PI,newE,BRep_Tool::Tolerance(VI));
617       newE.Orientation(E.Orientation());
618       SplE.Append(newE);
619       VF = VI;
620       PF = PI;
621       VF.Orientation(TopAbs_FORWARD);
622     }
623     newE = E;
624     newE.EmptyCopy();
625     newE.Orientation(TopAbs_FORWARD);
626     B.Add(newE,VF);
627     B.UpdateVertex(VF,PF,newE,BRep_Tool::Tolerance(VF));
628     B.Add(newE,VL);
629     B.UpdateVertex(VL,PL,newE,BRep_Tool::Tolerance(VL));
630     newE.Orientation(E.Orientation());
631     SplE.Append(newE);
632   }
633 }
634