0022998: Various exceptions in HLR algorithms
authorszv <szv@opencascade.com>
Tue, 6 Mar 2012 10:43:10 +0000 (14:43 +0400)
committerbugmaster <bugmaster@opencascade.com>
Tue, 6 Mar 2012 11:13:23 +0000 (15:13 +0400)
src/HLRBRep/HLRBRep.cxx
src/HLRBRep/HLRBRep_Curve.cxx
src/HLRBRep/HLRBRep_HLRToShape.cxx
src/HLRTopoBRep/HLRTopoBRep_DSFiller.cxx

index 44b9cdb..21e8dd1 100755 (executable)
 //=======================================================================
 
 TopoDS_Edge HLRBRep::MakeEdge (const HLRBRep_Curve& ec,
-                              const Standard_Real U1,
-                              const Standard_Real U2)
+                               const Standard_Real U1,
+                               const Standard_Real U2)
 {
   TopoDS_Edge Edg;
-  //gp_Pnt2d P,P1,P2;
-  Standard_Real sta3d = U1;
-  Standard_Real end3d = U2;
-  Standard_Real sta   = ec.Parameter2d(U1);
-  Standard_Real end   = ec.Parameter2d(U2);
-  
-  if (ec.GetType() == GeomAbs_Line) {
-    Edg = BRepLib_MakeEdge2d(ec.Line(),sta,end);
-  }
-  else if (ec.GetType() == GeomAbs_Circle) {
-    Edg = BRepLib_MakeEdge2d(ec.Circle(),sta,end);
-  }
-  else if (ec.GetType() == GeomAbs_Ellipse) {
-    Edg = BRepLib_MakeEdge2d(ec.Ellipse(),sta,end);
-  }
-  else if (ec.GetType() == GeomAbs_Hyperbola) {
-    Edg = BRepLib_MakeEdge2d(ec.Hyperbola(),sta,end);
-  }
-  else if (ec.GetType() == GeomAbs_Parabola) {
-    Edg = BRepLib_MakeEdge2d(ec.Parabola(),sta,end);
-  }
-  else if (ec.GetType() == GeomAbs_BezierCurve) {
-    TColgp_Array1OfPnt2d Poles(1,ec.NbPoles());
-    if (ec.IsRational()) {
-      TColStd_Array1OfReal Weights(1,ec.NbPoles());
-      ec.PolesAndWeights(Poles,Weights);
-      Edg = BRepLib_MakeEdge2d(new Geom2d_BezierCurve(Poles,Weights),sta,end);
-    }
-    else {
-      ec.Poles(Poles);
-      Edg = BRepLib_MakeEdge2d(new Geom2d_BezierCurve(Poles),sta,end);
-    }
-  }
-  else if (ec.GetType() == GeomAbs_BSplineCurve) {
-    TColgp_Array1OfPnt2d    Poles(1,ec.NbPoles());
-    TColStd_Array1OfReal    knots(1,ec.NbKnots());
-    TColStd_Array1OfInteger mults(1,ec.NbKnots());
-    //-- ec.KnotsAndMultiplicities(knots,mults);
-    ec.Knots(knots);
-    ec.Multiplicities(mults);
-    if (ec.IsRational()) {
-      TColStd_Array1OfReal Weights(1,ec.NbPoles());
-      ec.PolesAndWeights(Poles,Weights);
-      Edg = BRepLib_MakeEdge2d
-       (new Geom2d_BSplineCurve
-        (Poles,Weights,knots,mults,ec.Degree()),sta,end);
+  const Standard_Real sta = ec.Parameter2d(U1);
+  const Standard_Real end = ec.Parameter2d(U2);
+
+  switch (ec.GetType())
+  {
+    case GeomAbs_Line:
+      Edg = BRepLib_MakeEdge2d(ec.Line(),sta,end);
+      break;
+
+    case GeomAbs_Circle:
+      Edg = BRepLib_MakeEdge2d(ec.Circle(),sta,end);
+      break;
+
+       case GeomAbs_Ellipse:
+      Edg = BRepLib_MakeEdge2d(ec.Ellipse(),sta,end);
+      break;
+
+       case GeomAbs_Hyperbola:
+      Edg = BRepLib_MakeEdge2d(ec.Hyperbola(),sta,end);
+      break;
+
+       case GeomAbs_Parabola:
+      Edg = BRepLib_MakeEdge2d(ec.Parabola(),sta,end);
+      break;
+
+    case GeomAbs_BezierCurve: {
+      TColgp_Array1OfPnt2d Poles(1,ec.NbPoles());
+      Handle(Geom2d_BezierCurve) ec2d;
+      if (ec.IsRational()) {
+        TColStd_Array1OfReal Weights(1,ec.NbPoles());
+        ec.PolesAndWeights(Poles,Weights);
+        ec2d = new Geom2d_BezierCurve(Poles,Weights);
+      }
+      else {
+        ec.Poles(Poles);
+        ec2d = new Geom2d_BezierCurve(Poles);
+      }
+      BRepLib_MakeEdge2d mke2d(ec2d,sta,end);
+      if (mke2d.IsDone())
+        Edg = mke2d.Edge();
+      break;
     }
-    else {
-      ec.Poles(Poles);
-      Edg = BRepLib_MakeEdge2d
-       (new Geom2d_BSplineCurve(Poles,knots,mults,ec.Degree()),sta,end);
+
+       case GeomAbs_BSplineCurve: {
+      TColgp_Array1OfPnt2d    Poles(1,ec.NbPoles());
+      TColStd_Array1OfReal    knots(1,ec.NbKnots());
+      TColStd_Array1OfInteger mults(1,ec.NbKnots());
+      //-- ec.KnotsAndMultiplicities(knots,mults);
+      ec.Knots(knots);
+      ec.Multiplicities(mults);
+      Handle(Geom2d_BSplineCurve) ec2d;
+      if (ec.IsRational()) {
+        TColStd_Array1OfReal Weights(1,ec.NbPoles());
+        ec.PolesAndWeights(Poles,Weights);
+        ec2d = new Geom2d_BSplineCurve(Poles,Weights,knots,mults,ec.Degree());
+      }
+      else {
+        ec.Poles(Poles);
+        ec2d = new Geom2d_BSplineCurve(Poles,knots,mults,ec.Degree());
+      }
+      BRepLib_MakeEdge2d mke2d(ec2d,sta,end);
+      if (mke2d.IsDone())
+        Edg = mke2d.Edge();
+      break;
     }
-  }
-  else {
-    Standard_Integer nbPnt = 15;
-    TColgp_Array1OfPnt2d    Poles(1,nbPnt);
-    TColStd_Array1OfReal    knots(1,nbPnt);
-    TColStd_Array1OfInteger mults(1,nbPnt);
-    mults.Init(1);
-    mults(1    ) = 2;
-    mults(nbPnt) = 2;
-    Standard_Real step = (end3d-sta3d)/(nbPnt-1);
-    
-    for (Standard_Integer i = 1; i <= nbPnt; i++) {
-      Poles(i) = ec.Value(sta3d);
-      knots(i) = sta3d;
-      sta3d += step;
+
+       default: {
+      const Standard_Integer nbPnt = 15;
+      TColgp_Array1OfPnt2d    Poles(1,nbPnt);
+      TColStd_Array1OfReal    knots(1,nbPnt);
+      TColStd_Array1OfInteger mults(1,nbPnt);
+      mults.Init(1);
+      mults(1    ) = 2;
+      mults(nbPnt) = 2;
+      const Standard_Real step = (U2-U1)/(nbPnt-1);
+      Standard_Real par3d = U1;
+      for (Standard_Integer i = 1; i < nbPnt; i++) {
+        Poles(i) = ec.Value(par3d);
+        knots(i) = par3d;
+        par3d += step;
+      }
+      Poles(nbPnt) = ec.Value(U2);
+      knots(nbPnt) = U2;
+      
+      Handle(Geom2d_BSplineCurve) ec2d = new Geom2d_BSplineCurve(Poles,knots,mults,1);
+      BRepLib_MakeEdge2d mke2d(ec2d,sta,end);
+      if (mke2d.IsDone())
+        Edg = mke2d.Edge();
     }
-    Edg = BRepLib_MakeEdge2d
-      (new Geom2d_BSplineCurve(Poles,knots,mults,1),sta,end);
   }
   return Edg;
 }
index 169ded6..6adf29d 100755 (executable)
@@ -50,18 +50,18 @@ HLRBRep_Curve::Parameter2d (const Standard_Real P3d) const
   // Res -> --------------------------------------------
   //        (-myOF + myOZ) (-myOF + myOZ + P3d myVZ)
 
-  if (myType == GeomAbs_Line) {
-    if (((HLRAlgo_Projector*) myProj)->Perspective()) {
-      const Standard_Real FmOZ = myOF - myOZ;
-      return myOF * P3d * (myVX * FmOZ + myOX * myVZ) / (FmOZ * (FmOZ - P3d * myVZ));
-    }
-    return P3d * myVX;
-  }
+  switch (myType)
+  {
+    case GeomAbs_Line:
+      if (((HLRAlgo_Projector*) myProj)->Perspective()) {
+        const Standard_Real FmOZ = myOF - myOZ;
+        return myOF * P3d * (myVX * FmOZ + myOX * myVZ) / (FmOZ * (FmOZ - P3d * myVZ));
+      }
+      return P3d * myVX;
 
-  else if (myType == GeomAbs_Ellipse) {
-    return P3d + myOX;
+    case GeomAbs_Ellipse:
+      return P3d + myOX;
   }
-
   return P3d;
 }
 
index 553f091..f333558 100755 (executable)
@@ -180,34 +180,40 @@ HLRBRep_HLRToShape::DrawEdge (const Standard_Boolean visible,
                              TopoDS_Shape& Result,
                              Standard_Boolean& added) const
 {
-  Standard_Boolean todraw;
+  Standard_Boolean todraw = Standard_False;
   if      (inFace)   todraw = Standard_True;
   else if (typ == 3) todraw = ed.Rg1Line() && !ed.RgNLine();
   else if (typ == 4) todraw = ed.RgNLine();
   else               todraw =!ed.Rg1Line();
+
   if (todraw) {
     Standard_Real sta,end;
     Standard_ShortReal tolsta,tolend;
     BRep_Builder B;
+    TopoDS_Edge E;
     HLRAlgo_EdgeIterator It;
-    if (visible) {
-      
-      for (It.InitVisible(ed.Status());
-          It.MoreVisible();
-          It.NextVisible()) {
-       It.Visible(sta,tolsta,end,tolend);
-       B.Add(Result,HLRBRep::MakeEdge(ed.Geometry(),sta,end));
-       added = Standard_True;
+    if (visible)
+    {
+      for (It.InitVisible(ed.Status()); It.MoreVisible(); It.NextVisible()) {
+        It.Visible(sta,tolsta,end,tolend);
+        E = HLRBRep::MakeEdge(ed.Geometry(),sta,end);
+        if (!E.IsNull())
+        {
+          B.Add(Result,E);
+          added = Standard_True;
+        }
       }
     }
-    else {
-      
-      for (It.InitHidden(ed.Status());
-          It.MoreHidden();
-          It.NextHidden()) {
-       It.Hidden(sta,tolsta,end,tolend);
-       B.Add(Result,HLRBRep::MakeEdge(ed.Geometry(),sta,end));
-       added = Standard_True;
+    else
+    {
+      for (It.InitHidden(ed.Status()); It.MoreHidden(); It.NextHidden()) {
+        It.Hidden(sta,tolsta,end,tolend);
+        E = HLRBRep::MakeEdge(ed.Geometry(),sta,end);
+        if (!E.IsNull())
+        {
+          B.Add(Result,E);
+          added = Standard_True;
+        }
       }
     }
   }
index cb0eb63..3f691cc 100755 (executable)
@@ -104,15 +104,14 @@ void  HLRTopoBRep_DSFiller::InsertFace (const Standard_Integer FI,
 {
   // Insert the intersections of FO in DS
 
-
-  Standard_Real tol = BRep_Tool::Tolerance(F);
+  const Standard_Real tol = BRep_Tool::Tolerance(F);
   TopTools_ListOfShape& IntL = DS.AddIntL(F);
   TopTools_ListOfShape& OutL = DS.AddOutL(F);
-  TopTools_MapOfShape VM;
+
   TopoDS_Vertex VF,VL;
-  Standard_Real parF,parL;
+  /*
+  TopTools_MapOfShape VM;
   TopExp_Explorer ex(F,TopAbs_EDGE);
-
   while (ex.More()) {
     const TopoDS_Edge& E = TopoDS::Edge(ex.Current());
     if (BRep_Tool::IsClosed(E,F)) {
@@ -122,100 +121,97 @@ void  HLRTopoBRep_DSFiller::InsertFace (const Standard_Integer FI,
     }
     ex.Next();
   }
+  */
 
-  Standard_Integer CurLine;
-  Standard_Integer NbLines = FO.NbLines();
-
-  for (CurLine = 1; CurLine <= NbLines; CurLine++) {
+  const Standard_Integer NbLines = FO.NbLines();
+  Standard_Integer CurLine = 1;
+  for (; CurLine <= NbLines; CurLine++)
+  {
     const Contap_TheLineOfContour& Line = FO.Line(CurLine);
+    const Standard_Integer NbPoints = Line.NbVertex();
     Standard_Integer CurPoint;
-    Standard_Integer NbPoints = Line.NbVertex();
-    
-    if (Line.TypeContour() == Contap_Restriction) {
+    if (Line.TypeContour() == Contap_Restriction)
+    {
       // OutLine on restriction
-      TopoDS_Edge E =
-       (*(BRepAdaptor_Curve2d*)&(Line.Arc()->Curve2d())).Edge();
+      TopoDS_Edge E = (*(BRepAdaptor_Curve2d*)&(Line.Arc()->Curve2d())).Edge();
       OutL.Append(E);
       TopExp::Vertices(E,VF,VL);
       // insert the Internal points.
 
       for (CurPoint = 1; CurPoint <= NbPoints; CurPoint++) {
-       Contap_ThePointOfContour P = Line.Vertex(CurPoint);
-       if (P.IsInternal()) {
-         if (P.Value().IsEqual(BRep_Tool::Pnt(VF),BRep_Tool::Tolerance(VF))) {
-           if (P.Value().IsEqual(BRep_Tool::Pnt(VL),BRep_Tool::Tolerance(VL))) {
-             InsertVertex(P,tol,E,DS);
-           }
-         }
-       }
+        Contap_ThePointOfContour P = Line.Vertex(CurPoint);
+        if (P.IsInternal()) {
+          if (P.Value().IsEqual(BRep_Tool::Pnt(VF),BRep_Tool::Tolerance(VF))) {
+            if (P.Value().IsEqual(BRep_Tool::Pnt(VL),BRep_Tool::Tolerance(VL))) {
+              InsertVertex(P,tol,E,DS);
+            }
+          }
+        }
       }
     }
-    else {
+    else
+    {
       for (CurPoint = 1; CurPoint <= NbPoints; CurPoint++) {
-       Standard_Boolean InsuffisantNumberOfPoints=Standard_False;
-       Contap_ThePointOfContour PF = Line.Vertex(CurPoint);
-       if (PF.IsInternal())
-         VF = VL;
-       else 
-         VF = MakeVertex(PF,tol,DS);
-       parF = PF.ParameterOnLine();
-
-       if (CurPoint <= NbPoints) {
-         CurPoint++;
-         Contap_ThePointOfContour PF = Line.Vertex(CurPoint);
-         VL = MakeVertex(PF,tol,DS);
-         parL = PF.ParameterOnLine();
-         Handle(Geom_Curve)   C;
-         Handle(Geom2d_Curve) C2d;
-         Standard_Real first = parF;
-         Standard_Real last  = parL;
-         Standard_Real tol = BRep_Tool::Tolerance(F);
-         
-
-         if( (last-first) > Precision::PConfusion()) {  
-           
-           switch (Line.TypeContour()) {
+
+        const Contap_ThePointOfContour PF = Line.Vertex(CurPoint);
+        if (PF.IsInternal() && CurPoint != 1)
+          VF = VL;
+        else
+          VF = MakeVertex(PF,tol,DS);
+        const Standard_Real parF = PF.ParameterOnLine();
+
+        if (CurPoint < NbPoints) {
+          const Contap_ThePointOfContour PL = Line.Vertex(CurPoint+1);
+          VL = MakeVertex(PL,tol,DS);
+          const Standard_Real parL = PL.ParameterOnLine();
+
+          if( (parL-parF) > Precision::PConfusion() ) {
+
+            Handle(Geom_Curve) C;
+            Handle(Geom2d_Curve) C2d;
+            Standard_Real first = parF;
+            Standard_Real last  = parL;
+            Standard_Boolean InsuffisantNumberOfPoints=Standard_False;
+
+            switch (Line.TypeContour()) {
              
-           case Contap_Lin :
-             {
-               C = new Geom_Line(Line.Line());
-               if (withPCurve) {
-                 Handle(Geom_Surface) S = BRep_Tool::Surface(F);
-                 Standard_Real Tol = 1e-7;
-                 C2d = GeomProjLib::Curve2d(C,first,last,S,Tol); 
-               }
-             }
-             break;
+              case Contap_Lin :
+              {
+                C = new Geom_Line(Line.Line());
+                if (withPCurve) {
+                  Handle(Geom_Surface) S = BRep_Tool::Surface(F);
+                  Standard_Real Tol = 1e-7;
+                  C2d = GeomProjLib::Curve2d(C,first,last,S,Tol); 
+                }
+              }
+              break;
              
-           case Contap_Circle :
-             {
-               C = new Geom_Circle(Line.Circle());
-               if (withPCurve) {
-                 TopLoc_Location Loc;
-                 Handle(Geom_Surface) S =
-                   BRep_Tool::Surface(F,Loc);
-                 if (!Loc.IsIdentity()) {
-                   S = Handle(Geom_Surface)::DownCast
-                     (S->Transformed(Loc.Transformation()));
-                 }
-//               C2d = GeomProjLib::Curve2d(C,first,last,S,1e-7); 
-                 Standard_Real Tol = 1e-7;
-                 C2d = GeomProjLib::Curve2d(C,first,last,S,Tol); 
-               }
-             }
-             break;
+              case Contap_Circle :
+              {
+                C = new Geom_Circle(Line.Circle());
+                if (withPCurve) {
+                  TopLoc_Location Loc;
+                  Handle(Geom_Surface) S = BRep_Tool::Surface(F,Loc);
+                  if (!Loc.IsIdentity()) {
+                    S = Handle(Geom_Surface)::DownCast(S->Transformed(Loc.Transformation()));
+                  }
+                  Standard_Real Tol = 1e-7;
+                  C2d = GeomProjLib::Curve2d(C,first,last,S,Tol); 
+                }
+              }
+              break;
              
-           case Contap_Walking :
-             {
-               // copy the points
-               Standard_Integer ipF = Standard_Integer(parF);
-               Standard_Integer ipL = Standard_Integer(parL);
+              case Contap_Walking :
+              {
+                // copy the points
+                Standard_Integer ipF = Standard_Integer(parF);
+                Standard_Integer ipL = Standard_Integer(parL);
                
-               if(ipL-ipF < 1) { 
-                 InsuffisantNumberOfPoints=Standard_True;
-                 //cout<<"\n !! Pb ds HLRTopoBRep_DSFiller.cxx (Contour App Nbp <3)"<<endl;
-               }
-#if 0 
+                if(ipL-ipF < 1) { 
+                  InsuffisantNumberOfPoints=Standard_True;
+                  //cout<<"\n !! Pb ds HLRTopoBRep_DSFiller.cxx (Contour App Nbp <3)"<<endl;
+                }
+/*
                else if(ipL-ipF < 6) { 
                  // compute the tangents
                  Contap_TheSurfFunctionOfContour& SFunc =
@@ -286,164 +282,152 @@ void  HLRTopoBRep_DSFiller::InsertFace (const Standard_Integer FI,
                  first = 0;
                  last = 1;
                }
-#endif
-               else if(ipL-ipF < 5) { 
-                 Standard_Integer nbp = ipL - ipF + 1;
-                 TColStd_Array1OfReal knots(1,nbp);
-                 TColStd_Array1OfInteger mults(1,nbp);
-                 TColgp_Array1OfPnt Points(1,nbp);
-                 
-                 for(Standard_Integer i=1;i<=nbp;i++) {
-                   knots.SetValue(i,(Standard_Real)i);
-                   mults.SetValue(i,1);
-                   Points.SetValue(i,Line.Point(i+ipF-1).Value());
-                 }
-                 mults(1)=mults(nbp)=2;
-                 C = new Geom_BSplineCurve(Points,knots,mults,1);
-                 
-                 if(withPCurve) { 
-                   TColgp_Array1OfPnt2d Points2d(1,nbp);
-                   for(Standard_Integer i=1;i<=nbp;i++) {
-                     Standard_Real u,v;
-                     Line.Point(i+ipF-1).ParametersOnS2(u,v);
-                     gp_Pnt2d P2d(u,v);
-                     Points2d.SetValue(i,P2d);
-                   }
-                   C2d = new Geom2d_BSplineCurve(Points2d,knots,mults,1);
-                 }
-                 first = 1;
-                 last = nbp;
-               }
-               else { 
-                 Standard_Integer nbp = ipL - ipF + 1;
-                 TColStd_Array1OfReal knots(1,nbp);
-                 TColStd_Array1OfInteger mults(1,nbp);
-                 TColgp_Array1OfPnt Points(1,nbp);
-
-                 Standard_Real Maxx,Maxy,Maxz,Maxu,Maxv;
-                 Standard_Real Minx,Miny,Minz,Minu,Minv;
-                 Maxx=Maxy=Maxz=Maxu=Maxv=-RealLast();
-                 Minx=Miny=Minz=Minu=Minv=RealLast();
-                 
+*/
+                else if(ipL-ipF < 5) { 
+                  const Standard_Integer nbp = ipL - ipF + 1;
+                  TColStd_Array1OfReal knots(1,nbp);
+                  TColStd_Array1OfInteger mults(1,nbp);
+                  TColgp_Array1OfPnt Points(1,nbp);
+
+                  for(Standard_Integer i=1;i<=nbp;i++) {
+                    knots.SetValue(i,(Standard_Real)i);
+                    mults.SetValue(i,1);
+                    Points.SetValue(i,Line.Point(i+ipF-1).Value());
+                  }
+                  mults(1)=mults(nbp)=2;
+                  C = new Geom_BSplineCurve(Points,knots,mults,1);
                  
-                 for(Standard_Integer i=1;i<=nbp;i++) {
-                   knots.SetValue(i,(Standard_Real)i);
-                   mults.SetValue(i,1);
-                   const gp_Pnt& P= Line.Point(i+ipF-1).Value();
-                   if(P.X()<Minx) Minx=P.X();
-                   if(P.Y()<Miny) Miny=P.Y();
-                   if(P.Z()<Minz) Minz=P.Z();
-                   if(P.X()>Maxx) Maxx=P.X();
-                   if(P.Y()>Maxy) Maxy=P.Y();
-                   if(P.Z()>Maxz) Maxz=P.Z();              
-                   Points.SetValue(i,P);
-                 }
-                 mults(1)=mults(nbp)=2;
-                 Handle(Geom_BSplineCurve)   AppC;
-                 Handle(Geom2d_BSplineCurve) AppC2d;
-                 AppC = new Geom_BSplineCurve(Points,knots,mults,1);
+                  if(withPCurve) { 
+                    TColgp_Array1OfPnt2d Points2d(1,nbp);
+                    for(Standard_Integer i=1;i<=nbp;i++) {
+                      Standard_Real u,v;
+                      Line.Point(i+ipF-1).ParametersOnS2(u,v);
+                      Points2d.SetValue(i,gp_Pnt2d(u,v));
+                    }
+                    C2d = new Geom2d_BSplineCurve(Points2d,knots,mults,1);
+                  }
+                  first = 1;
+                  last = nbp;
+                }
+                else { 
+                  const Standard_Integer nbp = ipL - ipF + 1;
+                  TColStd_Array1OfReal knots(1,nbp);
+                  TColStd_Array1OfInteger mults(1,nbp);
+                  TColgp_Array1OfPnt Points(1,nbp);
+
+                  Standard_Real Maxx,Maxy,Maxz,Maxu,Maxv;
+                  Standard_Real Minx,Miny,Minz,Minu,Minv;
+                  Maxx=Maxy=Maxz=Maxu=Maxv=-RealLast();
+                  Minx=Miny=Minz=Minu=Minv=RealLast();
                  
-                 if(withPCurve) { 
-                   TColgp_Array1OfPnt2d Points2d(1,nbp);
-                   for(Standard_Integer i=1;i<=nbp;i++) {
-                     Standard_Real u,v;
-                     Line.Point(i+ipF-1).ParametersOnS2(u,v);
-                     gp_Pnt2d P2d(u,v);
-                     if(u<Minu) Minu=u;
-                     if(v<Minv) Minv=v;
-                     if(u>Maxu) Maxu=u;
-                     if(v>Maxv) Maxv=v;
-                     Points2d.SetValue(i,P2d);
-                   }
-                   AppC2d = new Geom2d_BSplineCurve(Points2d,knots,mults,1);
-                 }
-                 first = 1;
-                 last = nbp;
+                  for(Standard_Integer i=1;i<=nbp;i++) {
+                    knots.SetValue(i,(Standard_Real)i);
+                    mults.SetValue(i,1);
+                    const gp_Pnt& P= Line.Point(i+ipF-1).Value();
+                    if(P.X()<Minx) Minx=P.X();
+                    if(P.Y()<Miny) Miny=P.Y();
+                    if(P.Z()<Minz) Minz=P.Z();
+                    if(P.X()>Maxx) Maxx=P.X();
+                    if(P.Y()>Maxy) Maxy=P.Y();
+                    if(P.Z()>Maxz) Maxz=P.Z();             
+                    Points.SetValue(i,P);
+                  }
+                  mults(1)=mults(nbp)=2;
+                  Handle(Geom_BSplineCurve)   AppC;
+                  Handle(Geom2d_BSplineCurve) AppC2d;
+                  AppC = new Geom_BSplineCurve(Points,knots,mults,1);
+
+                  if(withPCurve) {
+                    TColgp_Array1OfPnt2d Points2d(1,nbp);
+                    for(Standard_Integer i=1;i<=nbp;i++) {
+                      Standard_Real u,v;
+                      Line.Point(i+ipF-1).ParametersOnS2(u,v);
+                      if(u<Minu) Minu=u;
+                      if(v<Minv) Minv=v;
+                      if(u>Maxu) Maxu=u;
+                      if(v>Maxv) Maxv=v;
+                      Points2d.SetValue(i,gp_Pnt2d(u,v));
+                    }
+                    AppC2d = new Geom2d_BSplineCurve(Points2d,knots,mults,1);
+                  }
+                  first = 1;
+                  last = nbp;
                  
-                 Handle(BRepApprox_ApproxLine) AppLine;
-                 Handle(Geom2d_BSplineCurve) CNull;
-                 AppLine = new BRepApprox_ApproxLine(AppC,AppC2d,CNull);
+                  Handle(BRepApprox_ApproxLine) AppLine;
+                  Handle(Geom2d_BSplineCurve) CNull;
+                  AppLine = new BRepApprox_ApproxLine(AppC,AppC2d,CNull);
                  
-                 Standard_Integer dmin=4,dmax=8,niter=0;
-                 Standard_Boolean tg= Standard_False;
-                 BRepApprox_Approx Approx;
-                 Standard_Real TOL3d,TOL2d,TOL=0.0001;
-
-                 Maxx-=Minx; Maxy-=Miny; Maxz-=Minz;
-                 Maxu-=Minu; Maxv-=Minv;
-                 if(Maxy>Maxx) Maxx=Maxy;
-                 if(Maxz>Maxx) Maxx=Maxy;
-                 if(Maxv>Maxu) Maxu=Maxv;
-
-                 TOL3d=TOL*Maxx; if(TOL3d<1e-12) TOL3d=1e-12; else if(TOL3d>0.1) TOL3d=0.1;
-                 TOL2d=TOL*Maxu; if(TOL2d<1e-12) TOL2d=1e-12; else if(TOL2d>0.1) TOL2d=0.1;
+                  Standard_Integer dmin=4,dmax=8,niter=0;
+                  Standard_Boolean tg= Standard_False;
+                  BRepApprox_Approx Approx;
+                  Standard_Real TOL3d,TOL2d,TOL=0.0001;
+
+                  Maxx-=Minx; Maxy-=Miny; Maxz-=Minz;
+                  Maxu-=Minu; Maxv-=Minv;
+                  if(Maxy>Maxx) Maxx=Maxy;
+                  if(Maxz>Maxx) Maxx=Maxy;
+                  if(Maxv>Maxu) Maxu=Maxv;
+
+                  TOL3d=TOL*Maxx; if(TOL3d<1e-12) TOL3d=1e-12; else if(TOL3d>0.1) TOL3d=0.1;
+                  TOL2d=TOL*Maxu; if(TOL2d<1e-12) TOL2d=1e-12; else if(TOL2d>0.1) TOL2d=0.1;
                  
-                 //-- cout<<"\nHLRTopoBRep_DSFiller : nbp="<<nbp<<"  Tol3d="<<TOL3d<<"   Tol2d="<<TOL2d<<endl;
-
-                 Approx.SetParameters(TOL3d,TOL2d,dmin,dmax,niter,tg);
-                 Approx.Perform(AppLine,Standard_True,Standard_True,Standard_False,1,nbp);
-                 if (Approx.IsDone()==Standard_False) { 
-                   C = AppC;
-                   C2d=AppC2d; 
-                   first = 1;
-                   last = nbp;
-                 }
-                 else { 
-                   const AppParCurves_MultiBSpCurve& AppVal = Approx.Value(1); 
-                   Standard_Integer np = AppVal.NbPoles();
-                   TColgp_Array1OfPnt poles3d(1,np);
-                   AppVal.Curve(1,poles3d);
-                   const TColStd_Array1OfReal& knots = AppVal.Knots();
-                   const TColStd_Array1OfInteger& mults = AppVal.Multiplicities();
-                   Standard_Integer degree = AppVal.Degree();
-                   C = new Geom_BSplineCurve(poles3d,knots,mults,degree);
+                  //-- cout<<"\nHLRTopoBRep_DSFiller : nbp="<<nbp<<"  Tol3d="<<TOL3d<<"   Tol2d="<<TOL2d<<endl;
+
+                  Approx.SetParameters(TOL3d,TOL2d,dmin,dmax,niter,tg);
+                  Approx.Perform(AppLine,Standard_True,Standard_True,Standard_False,1,nbp);
+                  if (!Approx.IsDone()) {
+                    C = AppC;
+                    C2d=AppC2d; 
+                    first = 1;
+                    last = nbp;
+                  }
+                  else { 
+                    const AppParCurves_MultiBSpCurve& AppVal = Approx.Value(1); 
+                    TColgp_Array1OfPnt poles3d(1,AppVal.NbPoles());
+                    AppVal.Curve(1,poles3d);
+                    C = new Geom_BSplineCurve(poles3d,AppVal.Knots(),AppVal.Multiplicities(),AppVal.Degree());
                    
-                   const AppParCurves_MultiBSpCurve& AppVal2 = Approx.Value(2);
-                   Standard_Integer np2 = AppVal2.NbPoles();
-                   TColgp_Array1OfPnt2d poles2d(1,np2);
-                   AppVal2.Curve(2,poles2d);
-                   const TColStd_Array1OfReal& knots2 = AppVal2.Knots();
-                   const TColStd_Array1OfInteger& mults2 = AppVal2.Multiplicities();
-                   degree = AppVal2.Degree();
-                   C2d = new Geom2d_BSplineCurve(poles2d,knots2,mults2,degree);
-                   first = C2d->FirstParameter();
-                   last  = C2d->LastParameter();
-                 }
-               }
-             }
-             break;
+                    const AppParCurves_MultiBSpCurve& AppVal2 = Approx.Value(2);
+                    TColgp_Array1OfPnt2d poles2d(1,AppVal2.NbPoles());
+                    AppVal2.Curve(2,poles2d);
+                    C2d = new Geom2d_BSplineCurve(poles2d,AppVal2.Knots(),AppVal2.Multiplicities(),AppVal2.Degree());
+                    first = C2d->FirstParameter();
+                    last  = C2d->LastParameter();
+                  }
+                }
+              }
+              break;
              
-           case Contap_Restriction :
-             {
-               Standard_ProgramError::Raise
-                 ("HLRTopoBRep_DSFiller::InsertFace : Restriction");
-             }
-             break;
-           }
+              case Contap_Restriction :
+              {
+                Standard_ProgramError::Raise("HLRTopoBRep_DSFiller::InsertFace : Restriction");
+              }
+              break;
+            }
            
-           // compute the PCurve
-           // make the edge
-           if(InsuffisantNumberOfPoints==Standard_False) { 
-             TopoDS_Edge E = TopoDS_Edge();
-             BRep_Builder B;
-             VF.Orientation(TopAbs_FORWARD);
-             VL.Orientation(TopAbs_REVERSED);
-             B.MakeEdge(E,C,tol);
-             B.Add(E,VF);
-             B.Add(E,VL);
-             B.Range(E,first,last);
-             
-             if (!C2d.IsNull()) {
-               BRep_Builder B;
-               B.UpdateEdge(E,C2d,F,BRep_Tool::Tolerance(F));
-             }
+            // compute the PCurve
+            // make the edge
+            if (!InsuffisantNumberOfPoints) {
+              TopoDS_Edge E;
+              BRep_Builder B;
+              B.MakeEdge(E,C,tol);
+              VF.Orientation(TopAbs_FORWARD);
+              VL.Orientation(TopAbs_REVERSED);
+              B.Add(E,VF);
+              B.Add(E,VL);
+              B.Range(E,first,last);
+
+              if (!C2d.IsNull()) {
+                BRep_Builder B;
+                B.UpdateEdge(E,C2d,F,BRep_Tool::Tolerance(F));
+              }
              
-             // add the edge in the DS
-             if (!E.IsNull())
-               IntL.Append(E);
-           }
-         }
-       }
+              // add the edge in the DS
+              if (!E.IsNull())
+                IntL.Append(E);
+            }
+          }
+        }
       }
     }
   }