0028643: Coding rules - eliminate GCC compiler warnings -Wmisleading-indentation
[occt.git] / src / BRepOffsetAPI / BRepOffsetAPI_DraftAngle.cxx
index 1416ff3..67bf880 100644 (file)
@@ -311,7 +311,7 @@ void BRepOffsetAPI_DraftAngle::Build()
 
 //=======================================================================
 //function : CorrectWires
-//purpose  : 
+//purpose  :
 //=======================================================================
 
 void BRepOffsetAPI_DraftAngle::CorrectWires()
@@ -479,8 +479,11 @@ void BRepOffsetAPI_DraftAngle::CorrectWires()
 
   //Sorting
   for (i = 1; i <= NonSeam.Length(); i++)
+  {
     for (j = 1; j < ParsNonSeam(i).Length(); j++)
+    {
       for (k = j+1; k <= ParsNonSeam(i).Length(); k++)
+      {
         if (ParsNonSeam(i)(k) < ParsNonSeam(i)(j))
         {
           Standard_Real temp = ParsNonSeam(i)(j);
@@ -493,416 +496,435 @@ void BRepOffsetAPI_DraftAngle::CorrectWires()
           ParsSeam(i)(j) = ParsSeam(i)(k);
           ParsSeam(i)(k) = temp;
         }
-        BRepFill_DataMapIteratorOfDataMapOfShapeSequenceOfReal iter( Emap );
-        for (; iter.More(); iter.Next())
+      }
+    }
+  }
+  BRepFill_DataMapIteratorOfDataMapOfShapeSequenceOfReal iter (Emap);
+  for (; iter.More (); iter.Next ())
+  {
+    TColStd_SequenceOfReal Seq = iter.Value ();
+    for (i = 1; i < Seq.Length (); i++)
+    {
+      for (j = i + 1; j <= Seq.Length (); j++)
+      {
+        if (Seq (j) < Seq (i))
         {
-          TColStd_SequenceOfReal Seq;
-          Seq = iter.Value();
-          for (i = 1; i < Seq.Length(); i++)
-            for (j = i+1; j <= Seq.Length(); j++)
-              if (Seq(j) < Seq(i))
-              {
-                Standard_Real temp = Seq(i);
-                Seq(i) = Seq(j);
-                Seq(j) = temp;
-              }
-              Emap( iter.Key() ) = Seq;
+          Standard_Real temp = Seq (i);
+          Seq (i) = Seq (j);
+          Seq (j) = temp;
         }
-        BRepFill_DataMapOfShapeSequenceOfReal EPmap;
-        TopTools_DataMapOfShapeSequenceOfShape EVmap; //Seam
-        TopTools_DataMapOfShapeSequenceOfShape EWmap; //Seam and wires intersecting it
-        iter.Initialize( Emap );
-        for (; iter.More(); iter.Next())
+      }
+    }
+    Emap (iter.Key ()) = Seq;
+  }
+  BRepFill_DataMapOfShapeSequenceOfReal EPmap;
+  TopTools_DataMapOfShapeSequenceOfShape EVmap; //Seam
+  TopTools_DataMapOfShapeSequenceOfShape EWmap; //Seam and wires intersecting it
+  iter.Initialize (Emap);
+  for (; iter.More (); iter.Next ())
+  {
+    TColStd_SequenceOfReal parseq;
+    EPmap.Bind (iter.Key (), parseq);
+    TopTools_SequenceOfShape shapeseq;
+    EVmap.Bind (iter.Key (), shapeseq);
+    TopTools_SequenceOfShape shapeseq2;
+    EWmap.Bind (iter.Key (), shapeseq2);
+  }
+
+  //Reconstruction of non-seam edges
+  BRepTools_Substitution aSub;
+  BRep_Builder BB;
+  for (i = 1; i <= NonSeam.Length (); i++)
+  {
+    TopoDS_Edge anEdge = TopoDS::Edge (NonSeam (i));
+    TopTools_ListOfShape NewEdges;
+    TopoDS_Edge NewE;
+    TopoDS_Vertex Vfirst, Vlast;
+    TopExp::Vertices (anEdge, Vfirst, Vlast);
+    Standard_Real par, FirstPar, LastPar;
+    BRep_Tool::Range (anEdge, FirstPar, LastPar);
+    Standard_Integer firstind = 1;
+    par = ParsNonSeam (i)(1);
+    TopoDS_Edge SeamEdge = TopoDS::Edge (Seam (i)(1));
+    //Find the face
+    for (j = 1; j <= Eseq.Length (); j++)
+      if (SeamEdge.IsSame (Eseq (j)))
+        break;
+    TopoDS_Face theFace = TopoDS::Face (Fseq (j));
+    TopLoc_Location L;
+    Handle (Geom_Surface) theSurf = BRep_Tool::Surface (theFace, L);
+    if (Abs (par - FirstPar) <= Precision::Confusion ())
+    {
+      BB.UpdateVertex (Vfirst, ParsSeam (i)(1), SeamEdge, BRep_Tool::Tolerance (Vfirst));
+      EPmap (SeamEdge).Append (ParsSeam (i)(1));
+      EVmap (SeamEdge).Append (Vfirst);
+      EWmap (SeamEdge).Append (NonSeamWires (i));
+      firstind = 2;
+    }
+    Standard_Real prevpar = FirstPar;
+    TopoDS_Vertex PrevV = Vfirst;
+    for (j = firstind; j <= ParsNonSeam (i).Length (); j++)
+    {
+      TopoDS_Shape aLocalShape = anEdge.EmptyCopied ();
+      NewE = TopoDS::Edge (aLocalShape);
+      //NewE = TopoDS::Edge( anEdge.EmptyCopied() );
+      TopoDS_Vertex NewV;
+      par = ParsNonSeam (i)(j);
+      BB.Range (NewE, prevpar, par);
+      SeamEdge = TopoDS::Edge (Seam (i)(j));
+      if (j == ParsNonSeam (i).Length () && Abs (par - LastPar) <= Precision::Confusion ())
+      {
+        NewV = Vlast;
+        if (firstind == 2 && j == 2)
         {
-          TColStd_SequenceOfReal parseq;
-          EPmap.Bind( iter.Key(), parseq );
-          TopTools_SequenceOfShape shapeseq;
-          EVmap.Bind( iter.Key(), shapeseq );
-          TopTools_SequenceOfShape shapeseq2;
-          EWmap.Bind( iter.Key(), shapeseq2 );
+          BB.UpdateVertex (Vlast, ParsSeam (i)(j), SeamEdge, BRep_Tool::Tolerance (Vlast));
+          EPmap (SeamEdge).Append (ParsSeam (i)(j));
+          EVmap (SeamEdge).Append (Vlast);
+          EWmap (SeamEdge).Append (NonSeamWires (i));
+          break;
         }
+      }
+      else
+      {
+        BRepAdaptor_Curve bcur (NewE);
+        gp_Pnt Point = bcur.Value (par);
+        NewV = BRepLib_MakeVertex (Point);
+        BB.UpdateVertex (NewV, par, NewE, 10.*Precision::Confusion ());
+      }
+      BB.UpdateVertex (NewV, ParsSeam (i)(j), SeamEdge, 10.*Precision::Confusion ());
+      NewE.Orientation (TopAbs_FORWARD);
+      BB.Add (NewE, PrevV.Oriented (TopAbs_FORWARD));
+      BB.Add (NewE, NewV.Oriented (TopAbs_REVERSED));
+
+      NewEdges.Append (NewE);
+      EPmap (SeamEdge).Append (ParsSeam (i)(j));
+      EVmap (SeamEdge).Append (NewV);
+      EWmap (SeamEdge).Append (NonSeamWires (i));
+
+      prevpar = par;
+      PrevV = NewV;
+    }
+    //The last edge
+    TopoDS_Shape aLocalShape = anEdge.EmptyCopied ();
+    NewE = TopoDS::Edge (aLocalShape);
+    //NewE = TopoDS::Edge( anEdge.EmptyCopied() );
+    par = LastPar;
+    if (Abs (prevpar - par) > Precision::Confusion ())
+    {
+      BB.Range (NewE, prevpar, par);
+      NewE.Orientation (TopAbs_FORWARD);
+      BB.Add (NewE, PrevV.Oriented (TopAbs_FORWARD));
+      BB.Add (NewE, Vlast.Oriented (TopAbs_REVERSED));
+      NewEdges.Append (NewE);
+    }
 
-        //Reconstruction of non-seam edges
-        BRepTools_Substitution aSub;
-        BRep_Builder BB;
-        for (i = 1; i <= NonSeam.Length(); i++)
-        {
-          TopoDS_Edge anEdge = TopoDS::Edge( NonSeam(i) );
-          TopTools_ListOfShape NewEdges;
-          TopoDS_Edge NewE;
-          TopoDS_Vertex Vfirst, Vlast;
-          TopExp::Vertices( anEdge, Vfirst, Vlast );
-          Standard_Real par, FirstPar, LastPar;
-          BRep_Tool::Range( anEdge, FirstPar, LastPar );
-          Standard_Integer firstind = 1;
-          par = ParsNonSeam(i)(1);
-          TopoDS_Edge SeamEdge = TopoDS::Edge( Seam(i)(1) );
-          //Find the face
-          for (j = 1; j <= Eseq.Length(); j++)
-            if (SeamEdge.IsSame( Eseq(j) ))
-              break;
-          TopoDS_Face theFace = TopoDS::Face( Fseq(j) );
-          TopLoc_Location L;
-          Handle( Geom_Surface ) theSurf = BRep_Tool::Surface( theFace, L );
-          if (Abs(par-FirstPar) <= Precision::Confusion())
-          {
-            BB.UpdateVertex( Vfirst, ParsSeam(i)(1), SeamEdge, BRep_Tool::Tolerance(Vfirst) );
-            EPmap( SeamEdge ).Append( ParsSeam(i)(1) );
-            EVmap( SeamEdge ).Append( Vfirst );
-            EWmap( SeamEdge ).Append( NonSeamWires(i) );
-            firstind = 2;
-          }
-          Standard_Real prevpar = FirstPar;
-          TopoDS_Vertex PrevV = Vfirst;
-          for (j = firstind; j <= ParsNonSeam(i).Length(); j++)
-          {
-            TopoDS_Shape aLocalShape = anEdge.EmptyCopied();
-            NewE = TopoDS::Edge( aLocalShape );
-            //NewE = TopoDS::Edge( anEdge.EmptyCopied() );
-            TopoDS_Vertex NewV;
-            par = ParsNonSeam(i)(j);
-            BB.Range( NewE, prevpar, par );
-            SeamEdge = TopoDS::Edge( Seam(i)(j) );
-            if (j == ParsNonSeam(i).Length() && Abs(par-LastPar) <= Precision::Confusion())
-            {
-              NewV = Vlast;
-              if (firstind == 2 && j == 2)
-              {
-                BB.UpdateVertex( Vlast, ParsSeam(i)(j), SeamEdge, BRep_Tool::Tolerance(Vlast) );
-                EPmap( SeamEdge ).Append( ParsSeam(i)(j) );
-                EVmap( SeamEdge ).Append( Vlast );
-                EWmap( SeamEdge ).Append( NonSeamWires(i) );
-                break;
-              }
-            }
-            else
-            {
-              BRepAdaptor_Curve bcur( NewE );
-              gp_Pnt Point = bcur.Value( par );
-              NewV = BRepLib_MakeVertex( Point );
-              BB.UpdateVertex( NewV, par, NewE, 10.*Precision::Confusion() );
-            }
-            BB.UpdateVertex( NewV, ParsSeam(i)(j), SeamEdge, 10.*Precision::Confusion() );
-            NewE.Orientation( TopAbs_FORWARD );
-            BB.Add( NewE, PrevV.Oriented(TopAbs_FORWARD) );
-            BB.Add( NewE, NewV.Oriented(TopAbs_REVERSED) );
-
-            NewEdges.Append( NewE );
-            EPmap( SeamEdge ).Append( ParsSeam(i)(j) );
-            EVmap( SeamEdge ).Append( NewV );
-            EWmap( SeamEdge ).Append( NonSeamWires(i) );
-
-            prevpar = par;
-            PrevV = NewV;
-          }
-          //The last edge
-          TopoDS_Shape aLocalShape = anEdge.EmptyCopied();
-          NewE = TopoDS::Edge( aLocalShape );
-          //NewE = TopoDS::Edge( anEdge.EmptyCopied() );
-          par = LastPar;
-          if (Abs(prevpar-par) > Precision::Confusion())
-          {
-            BB.Range( NewE, prevpar, par );
-            NewE.Orientation( TopAbs_FORWARD );
-            BB.Add( NewE, PrevV.Oriented(TopAbs_FORWARD) );
-            BB.Add( NewE, Vlast.Oriented(TopAbs_REVERSED) );
-            NewEdges.Append( NewE );
-          }
+    //Substitute anEdge by NewEdges
+    aSub.Substitute (anEdge, NewEdges);
+  }
 
-          //Substitute anEdge by NewEdges
-          aSub.Substitute( anEdge, NewEdges );
+  //Sorting of EPmap and EVmap and removing repeating points from them
+  iter.Initialize (EPmap);
+  for (; iter.More (); iter.Next ())
+  {
+    TColStd_SequenceOfReal Seq;
+    Seq = iter.Value ();
+    TopTools_SequenceOfShape SeqShape;
+    SeqShape = EVmap (iter.Key ());
+    TopTools_SequenceOfShape SeqShape2;
+    SeqShape2 = EWmap (iter.Key ());
+    for (i = 1; i < Seq.Length (); i++)
+    {
+      for (j = i + 1; j <= Seq.Length (); j++)
+      {
+        if (Seq (j) < Seq (i))
+        {
+          Standard_Real temp = Seq (i);
+          Seq (i) = Seq (j);
+          Seq (j) = temp;
+          TopoDS_Shape tmp = SeqShape (i);
+          SeqShape (i) = SeqShape (j);
+          SeqShape (j) = tmp;
+          tmp = SeqShape2 (i);
+          SeqShape2 (i) = SeqShape2 (j);
+          SeqShape2 (j) = tmp;
         }
+      }
+    }
 
-        //Sorting of EPmap and EVmap and removing repeating points from them
-        iter.Initialize( EPmap );
-        for (; iter.More(); iter.Next())
+    EPmap (iter.Key ()) = Seq;
+    EVmap (iter.Key ()) = SeqShape;
+    EWmap (iter.Key ()) = SeqShape2;
+  }
+  iter.Initialize (EPmap);
+  for (; iter.More (); iter.Next ())
+  {
+    TColStd_SequenceOfReal Seq;
+    Seq = iter.Value ();
+    TopTools_SequenceOfShape SeqShape;
+    SeqShape = EVmap (iter.Key ());
+    TopTools_SequenceOfShape SeqShape2;
+    SeqShape2 = EWmap (iter.Key ());
+    Standard_Boolean remove = Standard_True;
+    while (remove)
+    {
+      remove = Standard_False;
+      for (i = 1; i < Seq.Length (); i++)
+      {
+        if (Abs (Seq (i) - Seq (i + 1)) <= Precision::Confusion ())
         {
-          TColStd_SequenceOfReal Seq;
-          Seq = iter.Value();
-          TopTools_SequenceOfShape SeqShape;
-          SeqShape = EVmap( iter.Key() );
-          TopTools_SequenceOfShape SeqShape2;
-          SeqShape2 = EWmap( iter.Key() );
-          for (i = 1; i < Seq.Length(); i++)
-            for (j = i+1; j <= Seq.Length(); j++)
-              if (Seq(j) < Seq(i))
-              {
-                Standard_Real temp = Seq(i);
-                Seq(i) = Seq(j);
-                Seq(j) = temp;
-                TopoDS_Shape tmp = SeqShape(i);
-                SeqShape(i) = SeqShape(j);
-                SeqShape(j) = tmp;
-                tmp = SeqShape2(i);
-                SeqShape2(i) = SeqShape2(j);
-                SeqShape2(j) = tmp;
-              }
-              EPmap( iter.Key() ) = Seq;
-              EVmap( iter.Key() ) = SeqShape;
-              EWmap( iter.Key() ) = SeqShape2;
+          Seq.Remove (i + 1);
+          SeqShape.Remove (i + 1);
+          SeqShape2.Remove (i + 1);
+          remove = Standard_True;
         }
-        iter.Initialize( EPmap );
-        for (; iter.More(); iter.Next())
+      }
+    }
+    EPmap (iter.Key ()) = Seq;
+    EVmap (iter.Key ()) = SeqShape;
+    EWmap (iter.Key ()) = SeqShape2;
+  }
+
+  //Reconstruction of seam edges
+  TopTools_DataMapOfShapeShape VEmap;
+  iter.Initialize (Emap);
+  for (; iter.More (); iter.Next ())
+  {
+    TopoDS_Edge anEdge = TopoDS::Edge (iter.Key ());
+    Standard_Boolean onepoint = Standard_False;
+    TopTools_ListOfShape NewEdges;
+    TColStd_SequenceOfReal Seq;
+    Seq = iter.Value ();
+    TColStd_SequenceOfReal Seq2;
+    Seq2 = EPmap (anEdge);
+    TopTools_SequenceOfShape SeqVer;
+    SeqVer = EVmap (anEdge);
+    TopTools_SequenceOfShape SeqWire;
+    SeqWire = EWmap (anEdge);
+    TopoDS_Vertex Vfirst, Vlast;
+    TopExp::Vertices (anEdge, Vfirst, Vlast);
+    Standard_Real fpar, lpar, FirstPar, LastPar;
+    BRep_Tool::Range (anEdge, FirstPar, LastPar);
+    fpar = FirstPar;
+    lpar = Seq (1);
+    TopoDS_Edge NewE;
+    Standard_Integer firstind = 1;
+    if (Abs (fpar - lpar) <= Precision::Confusion ())
+    {
+      firstind = 2;
+      fpar = Seq (1);
+      lpar = Seq (2);
+    }
+    else
+    {
+      if (Seq.Length () % 2 != 0)
+      {
+        VEmap.Bind (Vfirst, anEdge);
+        firstind = 2;
+        fpar = Seq (1);
+        if (Seq.Length () > 2)
+          lpar = Seq (2);
+        else
+          onepoint = Standard_True;
+      }
+    }
+    if (!onepoint)
+    {
+      TopoDS_Shape aLocalShape = anEdge.EmptyCopied ();
+      NewE = TopoDS::Edge (aLocalShape);
+      //NewE = TopoDS::Edge( anEdge.EmptyCopied() );
+      BB.Range (NewE, fpar, lpar);
+      NewE.Orientation (TopAbs_FORWARD);
+      if (firstind == 1)
+      {
+        BB.Add (NewE, Vfirst.Oriented (TopAbs_FORWARD));
+        aLocalShape = SeqVer (1).Oriented (TopAbs_REVERSED);
+        BB.Add (NewE, TopoDS::Vertex (aLocalShape));
+        //BB.Add( NewE, TopoDS::Vertex( SeqVer(1).Oriented(TopAbs_REVERSED) ) );
+      }
+      else
+      {
+        aLocalShape = SeqVer (1).Oriented (TopAbs_FORWARD);
+        BB.Add (NewE, TopoDS::Vertex (aLocalShape));
+        aLocalShape = SeqVer (2).Oriented (TopAbs_REVERSED);
+        BB.Add (NewE, TopoDS::Vertex (aLocalShape));
+        //BB.Add( NewE, TopoDS::Vertex( SeqVer(1).Oriented(TopAbs_FORWARD) ) );
+        //BB.Add( NewE, TopoDS::Vertex( SeqVer(2).Oriented(TopAbs_REVERSED) ) );
+      }
+      NewEdges.Append (NewE);
+
+      firstind++;
+      for (i = firstind; i < Seq.Length (); i += 2)
+      {
+        aLocalShape = anEdge.EmptyCopied ();
+        NewE = TopoDS::Edge (aLocalShape);
+        //NewE = TopoDS::Edge( anEdge.EmptyCopied() );
+        fpar = Seq (i);
+        lpar = Seq (i + 1);
+        BB.Range (NewE, fpar, lpar);
+        //Find vertices
+        for (j = 1; j <= Seq2.Length (); j++)
         {
-          TColStd_SequenceOfReal Seq;
-          Seq = iter.Value();
-          TopTools_SequenceOfShape SeqShape;
-          SeqShape = EVmap( iter.Key() );
-          TopTools_SequenceOfShape SeqShape2;
-          SeqShape2 = EWmap( iter.Key() );
-          Standard_Boolean remove = Standard_True;
-          while (remove)
+          if (Abs (fpar - Seq2 (j)) <= Precision::Confusion ())
           {
-            remove = Standard_False;
-            for (i = 1; i < Seq.Length(); i++)
-              if (Abs(Seq(i)-Seq(i+1)) <= Precision::Confusion())
-              {
-                Seq.Remove(i+1);
-                SeqShape.Remove(i+1);
-                SeqShape2.Remove(i+1);
-                remove = Standard_True;
-              }
+            break;
           }
-          EPmap( iter.Key() ) = Seq;
-          EVmap( iter.Key() ) = SeqShape;
-          EWmap( iter.Key() ) = SeqShape2;
         }
+        NewE.Orientation (TopAbs_FORWARD);
+        TopoDS_Shape aLocalShapeCur = SeqVer (j).Oriented (TopAbs_FORWARD);
+        BB.Add (NewE, TopoDS::Vertex (aLocalShapeCur));
+        aLocalShapeCur = SeqVer (j + 1).Oriented (TopAbs_REVERSED);
+        BB.Add (NewE, TopoDS::Vertex (aLocalShapeCur));
+        //BB.Add( NewE, TopoDS::Vertex( SeqVer(j).Oriented(TopAbs_FORWARD) ) );
+        //BB.Add( NewE, TopoDS::Vertex( SeqVer(j+1).Oriented(TopAbs_REVERSED) ) );
+        NewEdges.Append (NewE);
+      }
+    }
 
-        //Reconstruction of seam edges
-        TopTools_DataMapOfShapeShape VEmap;
-        iter.Initialize( Emap );
-        for (; iter.More(); iter.Next())
-        {
-          TopoDS_Edge anEdge = TopoDS::Edge( iter.Key() );
-          Standard_Boolean onepoint = Standard_False;
-          TopTools_ListOfShape NewEdges;
-          TColStd_SequenceOfReal Seq;
-          Seq = iter.Value();
-          TColStd_SequenceOfReal Seq2;
-          Seq2 = EPmap( anEdge );
-          TopTools_SequenceOfShape SeqVer;
-          SeqVer = EVmap( anEdge );
-          TopTools_SequenceOfShape SeqWire;
-          SeqWire = EWmap( anEdge );
-          TopoDS_Vertex Vfirst, Vlast;
-          TopExp::Vertices( anEdge, Vfirst, Vlast );
-          Standard_Real fpar, lpar, FirstPar, LastPar;
-          BRep_Tool::Range( anEdge, FirstPar, LastPar );
-          fpar = FirstPar;
-          lpar = Seq(1);
-          TopoDS_Edge NewE;
-          Standard_Integer firstind = 1;
-          if (Abs(fpar-lpar) <= Precision::Confusion())
-          {
-            firstind = 2;
-            fpar = Seq(1);
-            lpar = Seq(2);
-          }
-          else
-          {
-            if (Seq.Length()%2 != 0)
-            {
-              VEmap.Bind( Vfirst, anEdge );
-              firstind = 2;
-              fpar = Seq(1);
-              if (Seq.Length() > 2)
-                lpar = Seq(2);
-              else
-                onepoint = Standard_True;
-            }
-          }
-          if (!onepoint)
-          {
-            TopoDS_Shape aLocalShape = anEdge.EmptyCopied();
-            NewE = TopoDS::Edge( aLocalShape );
-            //NewE = TopoDS::Edge( anEdge.EmptyCopied() );
-            BB.Range( NewE, fpar, lpar );
-            NewE.Orientation( TopAbs_FORWARD );
-            if (firstind == 1)
-            {
-              BB.Add( NewE, Vfirst.Oriented(TopAbs_FORWARD) );
-              aLocalShape = SeqVer(1).Oriented(TopAbs_REVERSED);
-              BB.Add( NewE, TopoDS::Vertex( aLocalShape ) );
-              //BB.Add( NewE, TopoDS::Vertex( SeqVer(1).Oriented(TopAbs_REVERSED) ) );
-            }
-            else
-            {
-              aLocalShape = SeqVer(1).Oriented(TopAbs_FORWARD);
-              BB.Add( NewE, TopoDS::Vertex( aLocalShape ) );
-              aLocalShape = SeqVer(2).Oriented(TopAbs_REVERSED);
-              BB.Add( NewE, TopoDS::Vertex( aLocalShape ) );
-              //BB.Add( NewE, TopoDS::Vertex( SeqVer(1).Oriented(TopAbs_FORWARD) ) );
-              //BB.Add( NewE, TopoDS::Vertex( SeqVer(2).Oriented(TopAbs_REVERSED) ) );
-            }
-            NewEdges.Append( NewE );
+    i = Seq.Length ();
+    fpar = Seq (i);
+    lpar = LastPar;
+    if (Abs (fpar - lpar) <= Precision::Confusion ())
+      continue;
+    TopoDS_Shape aLocalShape = anEdge.EmptyCopied ();
+    NewE = TopoDS::Edge (aLocalShape);
+    //NewE = TopoDS::Edge( anEdge.EmptyCopied() );
+    BB.Range (NewE, fpar, lpar);
+    NewE.Orientation (TopAbs_FORWARD);
+    aLocalShape = SeqVer (SeqVer.Length ()).Oriented (TopAbs_FORWARD);
+    BB.Add (NewE, TopoDS::Vertex (aLocalShape));
+    //BB.Add( NewE, TopoDS::Vertex( SeqVer(SeqVer.Length()).Oriented(TopAbs_FORWARD) ) );
+    BB.Add (NewE, Vlast.Oriented (TopAbs_REVERSED));
+    NewEdges.Append (NewE);
+
+    //Substitute anEdge by NewEdges
+    aSub.Substitute (anEdge, NewEdges);
+  }
 
-            firstind++;
-            for (i = firstind; i < Seq.Length(); i += 2)
-            {
-              aLocalShape = anEdge.EmptyCopied();
-              NewE = TopoDS::Edge( aLocalShape );
-              //NewE = TopoDS::Edge( anEdge.EmptyCopied() );
-              fpar = Seq(i);
-              lpar = Seq(i+1);
-              BB.Range( NewE, fpar, lpar );
-              //Find vertices
-              for (j = 1; j <= Seq2.Length(); j++)
-                if (Abs(fpar-Seq2(j)) <= Precision::Confusion())
-                  break;
-              NewE.Orientation( TopAbs_FORWARD );
-              TopoDS_Shape aLocalShapeCur = SeqVer(j).Oriented(TopAbs_FORWARD);
-              BB.Add( NewE, TopoDS::Vertex( aLocalShapeCur) );
-              aLocalShapeCur = SeqVer(j+1).Oriented(TopAbs_REVERSED);
-              BB.Add( NewE, TopoDS::Vertex( aLocalShapeCur ) );
-              //BB.Add( NewE, TopoDS::Vertex( SeqVer(j).Oriented(TopAbs_FORWARD) ) );
-              //BB.Add( NewE, TopoDS::Vertex( SeqVer(j+1).Oriented(TopAbs_REVERSED) ) );
-              NewEdges.Append( NewE );
-            }
-          }
+  //Removing edges connected with missing extremities of seam edges
+  TopTools_DataMapIteratorOfDataMapOfShapeShape itve (VEmap);
+  for (; itve.More (); itve.Next ())
+  {
+    TopoDS_Shape V = itve.Key ();
+    TopoDS_Shape E = itve.Value ();
+    TopoDS_Shape W;
+    for (i = 1; i <= Eseq.Length (); i++)
+    {
+      if (E.IsSame (Eseq (i)))
+      {
+        W = Wseq (i);
+        break;
+      }
+    }
+    TopoDS_Shape Etoremove;
+    eit.Initialize (W);
+    for (; eit.More (); eit.Next ())
+    {
+      TopoDS_Edge CurE = TopoDS::Edge (eit.Value ());
+      if (CurE.IsSame (E))
+        continue;
+      TopoDS_Vertex Vfirst, Vlast;
+      TopExp::Vertices (CurE, Vfirst, Vlast);
+      if (Vfirst.IsSame (V) || Vlast.IsSame (V))
+      {
+        Etoremove = CurE;
+        break;
+      }
+    }
+    if (!Etoremove.IsNull ())
+    {
+      W.Free (Standard_True);
+      BB.Remove (W, Etoremove);
+    }
+  }
 
-          i = Seq.Length();
-          fpar = Seq(i);
-          lpar = LastPar;
-          if (Abs(fpar-lpar) <= Precision::Confusion())
-            continue;
-          TopoDS_Shape aLocalShape = anEdge.EmptyCopied();
-          NewE = TopoDS::Edge( aLocalShape );
-          //NewE = TopoDS::Edge( anEdge.EmptyCopied() );
-          BB.Range( NewE, fpar, lpar );
-          NewE.Orientation( TopAbs_FORWARD );
-          aLocalShape = SeqVer(SeqVer.Length()).Oriented(TopAbs_FORWARD);
-          BB.Add( NewE, TopoDS::Vertex( aLocalShape ) );
-          //BB.Add( NewE, TopoDS::Vertex( SeqVer(SeqVer.Length()).Oriented(TopAbs_FORWARD) ) );
-          BB.Add( NewE, Vlast.Oriented(TopAbs_REVERSED) );
-          NewEdges.Append( NewE );
-
-          //Substitute anEdge by NewEdges
-          aSub.Substitute( anEdge, NewEdges );
-        }
+  aSub.Build (myShape);
+  if (aSub.IsCopied (myShape))
+  {
+    const TopTools_ListOfShape& listSh = aSub.Copy (myShape);
+    if (!listSh.IsEmpty ())
+      myShape = listSh.First ();
+  }
 
-        //Removing edges connected with missing extremities of seam edges
-        TopTools_DataMapIteratorOfDataMapOfShapeShape itve( VEmap );
-        for (; itve.More(); itve.Next())
+  //Reconstruction of wires
+  TopTools_ListOfShape theCopy;
+  TopTools_DataMapIteratorOfDataMapOfShapeListOfShape itww (WWmap);
+  for (; itww.More (); itww.Next ())
+  {
+    CurWire = itww.Key ();
+    theCopy = aSub.Copy (CurWire);
+    CurWire = theCopy.First ();
+    CurWire.Free (Standard_True);
+    TopTools_ListIteratorOfListOfShape itl (itww.Value ());
+    for (; itl.More (); itl.Next ())
+    {
+      TopoDS_Shape aWire = itl.Value ();
+      CurFace = WFmap (aWire);
+      theCopy = aSub.Copy (aWire);
+      aWire = theCopy.First ();
+      //Adjusting period
+      TopLoc_Location L;
+      Handle (Geom_Surface) theSurf = BRep_Tool::Surface (TopoDS::Face (CurFace), L);
+      eit.Initialize (aWire);
+      for (; eit.More (); eit.Next ())
+      {
+        TopoDS_Edge anEdge = TopoDS::Edge (eit.Value ());
+        gp_Pnt2d Pfirst, Plast, Pmid;
+        BRep_Tool::UVPoints (anEdge, TopoDS::Face (CurFace), Pfirst, Plast);
+        BRepAdaptor_Curve2d bc2d (anEdge, TopoDS::Face (CurFace));
+        Pmid = bc2d.Value ((bc2d.FirstParameter () + bc2d.LastParameter ()) / 2.);
+        gp_Vec2d offset;
+        Standard_Boolean translate = Standard_False;
+        if (Pfirst.X () - 2.*M_PI > Precision::Confusion () ||
+          Plast.X () - 2.*M_PI > Precision::Confusion () ||
+          Pmid.X () - 2.*M_PI > Precision::Confusion ())
         {
-          TopoDS_Shape V = itve.Key();
-          TopoDS_Shape E = itve.Value();
-          TopoDS_Shape W;
-          for (i = 1; i <= Eseq.Length(); i++)
-            if (E.IsSame( Eseq(i) ))
-            {
-              W = Wseq(i);
-              break;
-            }
-            TopoDS_Shape Etoremove;
-            eit.Initialize( W );
-            for (; eit.More(); eit.Next())
-            {
-              TopoDS_Edge CurE = TopoDS::Edge( eit.Value() );
-              if (CurE.IsSame( E ))
-                continue;
-              TopoDS_Vertex Vfirst, Vlast;
-              TopExp::Vertices( CurE, Vfirst, Vlast );
-              if (Vfirst.IsSame( V ) || Vlast.IsSame( V ))
-              {
-                Etoremove = CurE;
-                break;
-              }
-            }
-            if (! Etoremove.IsNull())
-            {
-              W.Free( Standard_True );
-              BB.Remove( W, Etoremove );
-            }
+          offset.SetCoord (-2.*M_PI, 0);
+          translate = Standard_True;
         }
-
-        aSub.Build( myShape );
-        if (aSub.IsCopied( myShape ))
+        if (Pfirst.X () < -Precision::Confusion () ||
+          Plast.X () < -Precision::Confusion () ||
+          Pmid.X () < -Precision::Confusion ())
         {
-          const TopTools_ListOfShape& listSh = aSub.Copy( myShape );
-          if (! listSh.IsEmpty())
-            myShape = listSh.First();
+          offset.SetCoord (2.*M_PI, 0);
+          translate = Standard_True;
         }
-
-        //Reconstruction of wires
-        TopTools_ListOfShape theCopy;
-        TopTools_DataMapIteratorOfDataMapOfShapeListOfShape itww( WWmap );
-        for (; itww.More(); itww.Next())
+        if (translate)
         {
-          CurWire = itww.Key();
-          theCopy = aSub.Copy( CurWire );
-          CurWire = theCopy.First();
-          CurWire.Free( Standard_True );
-          TopTools_ListIteratorOfListOfShape itl( itww.Value() );
-          for (; itl.More(); itl.Next())
+          const Handle (BRep_TEdge)& TE = *((Handle (BRep_TEdge)*) &anEdge.TShape ());
+          BRep_ListIteratorOfListOfCurveRepresentation itcr (TE->ChangeCurves ());
+          Handle (BRep_GCurve) GC;
+
+          for (; itcr.More (); itcr.Next ())
           {
-            TopoDS_Shape aWire = itl.Value();
-            CurFace = WFmap( aWire );
-            theCopy = aSub.Copy( aWire );
-            aWire = theCopy.First();
-            //Adjusting period
-            TopLoc_Location L;
-            Handle( Geom_Surface ) theSurf = BRep_Tool::Surface( TopoDS::Face(CurFace), L );
-            eit.Initialize( aWire );
-            for (; eit.More(); eit.Next())
+            GC = Handle (BRep_GCurve)::DownCast (itcr.Value ());
+            if (!GC.IsNull () && GC->IsCurveOnSurface (theSurf, L))
             {
-              TopoDS_Edge anEdge = TopoDS::Edge( eit.Value() );
-              gp_Pnt2d Pfirst, Plast, Pmid;
-              BRep_Tool::UVPoints( anEdge, TopoDS::Face(CurFace), Pfirst, Plast );
-              BRepAdaptor_Curve2d bc2d( anEdge, TopoDS::Face(CurFace) );
-              Pmid = bc2d.Value( (bc2d.FirstParameter()+bc2d.LastParameter())/2. );
-              gp_Vec2d offset;
-              Standard_Boolean translate = Standard_False;
-              if (Pfirst.X()-2.*M_PI > Precision::Confusion() ||
-                Plast.X()-2.*M_PI > Precision::Confusion()  ||
-                Pmid.X()-2.*M_PI > Precision::Confusion())
-              {
-                offset.SetCoord( -2.*M_PI, 0 );
-                translate = Standard_True;
-              }
-              if (Pfirst.X() < -Precision::Confusion() ||
-                Plast.X() < -Precision::Confusion()  ||
-                Pmid.X() < -Precision::Confusion())
-              {
-                offset.SetCoord( 2.*M_PI, 0 );
-                translate = Standard_True;
-              }
-              if (translate)
-              {
-                const Handle(BRep_TEdge)& TE = *((Handle(BRep_TEdge)*) &anEdge.TShape());
-                BRep_ListIteratorOfListOfCurveRepresentation itcr( TE->ChangeCurves() );
-                Handle(BRep_GCurve) GC;
-
-                for (; itcr.More(); itcr.Next())
-                {
-                  GC = Handle(BRep_GCurve)::DownCast(itcr.Value());
-                  if (!GC.IsNull() && GC->IsCurveOnSurface( theSurf, L ))
-                  {
-                    Handle(Geom2d_Curve) PC = GC->PCurve();
-                    PC = Handle(Geom2d_Curve)::DownCast( PC->Translated( offset ) );
-                    GC->PCurve( PC );
-                    TE->ChangeCurves().Remove( itcr );
-                    TE->ChangeCurves().Append( GC );
-                    break;
-                  }
-                }
-              }
-            }
-            ///////////////////
-            eit.Initialize( aWire, Standard_False );
-            for (; eit.More(); eit.Next())
-            {
-              TopoDS_Shape anEdge = eit.Value();
-              BB.Add( CurWire, anEdge );
-            }
-            if (aSub.IsCopied( CurFace ))
-            {
-              theCopy = aSub.Copy( CurFace );
-              CurFace = theCopy.First();
+              Handle (Geom2d_Curve) PC = GC->PCurve ();
+              PC = Handle (Geom2d_Curve)::DownCast (PC->Translated (offset));
+              GC->PCurve (PC);
+              TE->ChangeCurves ().Remove (itcr);
+              TE->ChangeCurves ().Append (GC);
+              break;
             }
-            CurFace.Free( Standard_True );
-            BB.Remove( CurFace, aWire );
           }
         }
+      }
+      ///////////////////
+      eit.Initialize (aWire, Standard_False);
+      for (; eit.More (); eit.Next ())
+      {
+        TopoDS_Shape anEdge = eit.Value ();
+        BB.Add (CurWire, anEdge);
+      }
+      if (aSub.IsCopied (CurFace))
+      {
+        theCopy = aSub.Copy (CurFace);
+        CurFace = theCopy.First ();
+      }
+      CurFace.Free (Standard_True);
+      BB.Remove (CurFace, aWire);
+    }
+  }
 }
 //=======================================================================
 //function : CorrectVertexTol