Salome HOME
Added a method to disable waiting cursor in the preview operation
[modules/geom.git] / src / GEOMImpl / GEOMImpl_ShapeDriver.cxx
index 334bfbc0963c9b006a8272c07a8bbba5e2ebdf5d..f538cd337d500e7cfe5e8786f733bd7a1f5c28a1 100644 (file)
@@ -1,28 +1,28 @@
-//  Copyright (C) 2007-2010  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2011  CEA/DEN, EDF R&D, OPEN CASCADE
 //
-//  Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-//  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+// Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
 //
-//  This library is free software; you can redistribute it and/or
-//  modify it under the terms of the GNU Lesser General Public
-//  License as published by the Free Software Foundation; either
-//  version 2.1 of the License.
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
 //
-//  This library is distributed in the hope that it will be useful,
-//  but WITHOUT ANY WARRANTY; without even the implied warranty of
-//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-//  Lesser General Public License for more details.
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
 //
-//  You should have received a copy of the GNU Lesser General Public
-//  License along with this library; if not, write to the Free Software
-//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
-//
-//  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
 //
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 
 #include <GEOMImpl_ShapeDriver.hxx>
 
 #include <GEOMImpl_IShapes.hxx>
+#include <GEOMImpl_IVector.hxx>
 #include <GEOMImpl_Types.hxx>
 #include <GEOMImpl_Block6Explorer.hxx>
 
 #include <ShapeFix_Edge.hxx>
 #include <ShapeFix_Shape.hxx>
 
-#include <BRep_Tool.hxx>
 #include <BRep_Builder.hxx>
+#include <BRep_Tool.hxx>
+#include <BRepAdaptor_Curve.hxx>
 #include <BRepAlgo_FaceRestrictor.hxx>
-#include <BRepBuilderAPI_Sewing.hxx>
 #include <BRepBuilderAPI_Copy.hxx>
+#include <BRepBuilderAPI_Sewing.hxx>
+#include <BRepBuilderAPI_MakeWire.hxx>
+#include <BRepBuilderAPI_MakeEdge.hxx>
 #include <BRepCheck.hxx>
 #include <BRepCheck_Analyzer.hxx>
 #include <BRepCheck_Shell.hxx>
 #include <BRepClass3d_SolidClassifier.hxx>
-#include <BRepBuilderAPI_MakeWire.hxx>
-#include <BRepBuilderAPI_Sewing.hxx>
 #include <BRepLib.hxx>
 #include <BRepLib_MakeEdge.hxx>
 #include <BRepTools_WireExplorer.hxx>
-#include <BRepAdaptor_Curve.hxx>
 
 #include <ShapeAnalysis_FreeBounds.hxx>
-#include <ElCLib.hxx>
 
 #include <TopAbs.hxx>
+#include <TopExp.hxx>
+#include <TopExp_Explorer.hxx>
 #include <TopoDS.hxx>
 #include <TopoDS_Shape.hxx>
 #include <TopoDS_Edge.hxx>
 #include <TopoDS_Solid.hxx>
 #include <TopoDS_Compound.hxx>
 #include <TopoDS_Iterator.hxx>
-#include <TopExp.hxx>
-#include <TopExp_Explorer.hxx>
 
 #include <TopTools_MapOfShape.hxx>
 #include <TopTools_HSequenceOfShape.hxx>
 
+#include <ElCLib.hxx>
+
+#include <GCPnts_AbscissaPoint.hxx>
+
+#include <Geom_TrimmedCurve.hxx>
+#include <GeomAbs_CurveType.hxx>
+#include <GeomConvert_CompCurveToBSplineCurve.hxx>
+#include <GeomConvert.hxx>
+#include <GeomLProp.hxx>
+
 #include <TColStd_SequenceOfReal.hxx>
 #include <TColStd_HSequenceOfTransient.hxx>
 #include <TColStd_Array1OfReal.hxx>
 #include <TColGeom_Array1OfBSplineCurve.hxx>
 #include <TColGeom_HArray1OfBSplineCurve.hxx>
 
-#include <GeomAbs_CurveType.hxx>
-#include <Geom_TrimmedCurve.hxx>
-#include <GeomConvert_CompCurveToBSplineCurve.hxx>
-#include <GeomConvert.hxx>
-#include <GeomLProp.hxx>
-
 #include <Precision.hxx>
+
 #include <Standard_NullObject.hxx>
 #include <Standard_TypeMismatch.hxx>
 #include <Standard_ConstructionError.hxx>
 
+//modified by NIZNHY-PKV Wed Dec 28 13:48:20 2011f
+//static
+//  void KeepEdgesOrder(const Handle(TopTools_HSequenceOfShape)& aEdges,
+//                   const Handle(TopTools_HSequenceOfShape)& aWires);
+//modified by NIZNHY-PKV Wed Dec 28 13:48:23 2011t
+
 //=======================================================================
 //function : GetID
 //purpose  :
@@ -117,6 +127,8 @@ Standard_Integer GEOMImpl_ShapeDriver::Execute(TFunction_Logbook& log) const
   Standard_Integer aType = aFunction->GetType();
 
   TopoDS_Shape aShape;
+  TCollection_AsciiString aWarning;
+
   BRep_Builder B;
 
   if (aType == WIRE_EDGES) {
@@ -145,7 +157,7 @@ Standard_Integer GEOMImpl_ShapeDriver::Execute(TFunction_Logbook& log) const
     Handle(ShapeFix_Wire) aFW = new ShapeFix_Wire;
     aFW->Load(aWire);
     aFW->FixReorder();
-    
+
     if (aFW->StatusReorder(ShapeExtend_FAIL1)) {
       Standard_ConstructionError::Raise("Wire construction failed: several loops detected");
     } else if (aFW->StatusReorder(ShapeExtend_FAIL)) {
@@ -157,7 +169,7 @@ Standard_Integer GEOMImpl_ShapeDriver::Execute(TFunction_Logbook& log) const
     Standard_Real aTolerance = aCI.GetTolerance();
     if (aTolerance < Precision::Confusion())
       aTolerance = Precision::Confusion();
-    
+
     aFW->ClosedWireMode() = Standard_False;
     aFW->FixConnected(aTolerance);
     if (aFW->StatusConnected(ShapeExtend_FAIL)) {
@@ -204,13 +216,13 @@ Standard_Integer GEOMImpl_ShapeDriver::Execute(TFunction_Logbook& log) const
       if (!MW.IsDone()) {
         Standard_ConstructionError::Raise("Wire construction failed");
       }
-          W = MW;
+      W = MW;
     }
     else {
       Standard_NullObject::Raise
         ("Shape for face construction is neither a wire nor a closed edge");
     }
-    GEOMImpl_Block6Explorer::MakeFace(W, aCI.GetIsPlanar(), aShape);
+    aWarning = GEOMImpl_Block6Explorer::MakeFace(W, aCI.GetIsPlanar(), aShape);
     if (aShape.IsNull()) {
       Standard_ConstructionError::Raise("Face construction failed");
     }
@@ -245,6 +257,9 @@ Standard_Integer GEOMImpl_ShapeDriver::Execute(TFunction_Logbook& log) const
     Handle(TopTools_HSequenceOfShape) aSeqWiresOut;
     ShapeAnalysis_FreeBounds::ConnectEdgesToWires(aSeqEdgesIn, Precision::Confusion(),
                                                   /*shared*/Standard_False, aSeqWiresOut);
+    //modified by NIZNHY-PKV Wed Dec 28 13:46:55 2011f
+    //KeepEdgesOrder(aSeqEdgesIn, aSeqWiresOut);
+    //modified by NIZNHY-PKV Wed Dec 28 13:46:59 2011t
 
     // 3. Separate closed wires
     Handle(TopTools_HSequenceOfShape) aSeqClosedWires = new TopTools_HSequenceOfShape;
@@ -266,7 +281,7 @@ Standard_Integer GEOMImpl_ShapeDriver::Execute(TFunction_Logbook& log) const
     // 4.a. Basic face
     TopoDS_Shape aFFace;
     TopoDS_Wire aW1 = TopoDS::Wire(aSeqClosedWires->Value(1));
-    GEOMImpl_Block6Explorer::MakeFace(aW1, aCI.GetIsPlanar(), aFFace);
+    aWarning = GEOMImpl_Block6Explorer::MakeFace(aW1, aCI.GetIsPlanar(), aFFace);
     if (aFFace.IsNull()) {
       Standard_ConstructionError::Raise("Face construction failed");
     }
@@ -370,12 +385,16 @@ Standard_Integer GEOMImpl_ShapeDriver::Execute(TFunction_Logbook& log) const
   else if (aType == SOLID_SHELL) {
     Handle(GEOM_Function) aRefShell = aCI.GetBase();
     TopoDS_Shape aShapeShell = aRefShell->GetValue();
+    if (!aShapeShell.IsNull() && aShapeShell.ShapeType() == TopAbs_COMPOUND) {
+      TopoDS_Iterator It (aShapeShell, Standard_True, Standard_True);
+      if (It.More()) aShapeShell = It.Value();
+    }
     if (aShapeShell.IsNull() || aShapeShell.ShapeType() != TopAbs_SHELL) {
       Standard_NullObject::Raise("Shape for solid construction is null or not a shell");
     }
 
     BRepCheck_Shell chkShell(TopoDS::Shell(aShapeShell));
-    if(chkShell.Closed() == BRepCheck_NotClosed) return 0;
+    if (chkShell.Closed() == BRepCheck_NotClosed) return 0;
 
     TopoDS_Solid Sol;
     B.MakeSolid(Sol);
@@ -404,12 +423,16 @@ Standard_Integer GEOMImpl_ShapeDriver::Execute(TFunction_Logbook& log) const
       if (aShapeShell.IsNull()) {
         Standard_NullObject::Raise("Shell for solid construction is null");
       }
+      if (aShapeShell.ShapeType() == TopAbs_COMPOUND) {
+        TopoDS_Iterator It (aShapeShell, Standard_True, Standard_True);
+        if (It.More()) aShapeShell = It.Value();
+      }
       if (aShapeShell.ShapeType() == TopAbs_SHELL) {
         B.Add(Sol, aShapeShell);
         ish++;
       }
     }
-    if ( ish == 0 ) return 0;
+    if (ish == 0) return 0;
     BRepClass3d_SolidClassifier SC (Sol);
     SC.PerformInfinitePoint(Precision::Confusion());
     if (SC.State() == TopAbs_IN)
@@ -436,6 +459,7 @@ Standard_Integer GEOMImpl_ShapeDriver::Execute(TFunction_Logbook& log) const
     aShape = C;
 
   }
+  /*
   else if (aType == REVERSE_ORIENTATION) {
     Handle(GEOM_Function) aRefShape = aCI.GetBase();
     TopoDS_Shape aShape_i = aRefShape->GetValue();
@@ -458,6 +482,7 @@ Standard_Integer GEOMImpl_ShapeDriver::Execute(TFunction_Logbook& log) const
       aShape = tds;
     }
   }
+  */
   else if (aType == EDGE_WIRE) {
     Handle(GEOM_Function) aRefBase = aCI.GetBase();
     TopoDS_Shape aWire = aRefBase->GetValue();
@@ -481,6 +506,7 @@ Standard_Integer GEOMImpl_ShapeDriver::Execute(TFunction_Logbook& log) const
     TColStd_SequenceOfReal TolSeq;
     GeomAbs_CurveType CurType;
     TopoDS_Vertex FirstVertex, LastVertex;
+    Standard_Boolean FinalReverse = Standard_False;
 
     BRepTools_WireExplorer wexp(theWire) ;
     for (; wexp.More(); wexp.Next())
@@ -512,6 +538,8 @@ Standard_Integer GEOMImpl_ShapeDriver::Execute(TFunction_Logbook& log) const
         LparSeq.Append(lpar);
         CurType = aType;
         FirstVertex = wexp.CurrentVertex();
+        if (anEdge.Orientation() == TopAbs_REVERSED)
+          FinalReverse = Standard_True;
       }
       else
       {
@@ -550,7 +578,7 @@ Standard_Integer GEOMImpl_ShapeDriver::Execute(TFunction_Logbook& log) const
           case GeomAbs_Line:
             {
               gp_Lin aLine    = BAcurve.Line();
-              gp_Lin PrevLine = GAprevcurve.Line(); 
+              gp_Lin PrevLine = GAprevcurve.Line();
               if (aLine.Contains(PrevLine.Location(), LinTol) &&
                   aLine.Direction().IsParallel(PrevLine.Direction(), AngTol))
               {
@@ -589,14 +617,14 @@ Standard_Integer GEOMImpl_ShapeDriver::Execute(TFunction_Logbook& log) const
                 NewFpar = ElCLib::Parameter(PrevCircle, P1);
                 NewLpar = ElCLib::Parameter(PrevCircle, P2);
                 if (NewLpar < NewFpar)
-                  NewLpar += 2.*PI;
+                  NewLpar += 2.*M_PI;
                 //Standard_Real MemNewFpar = NewFpar, MemNewLpar =  NewLpar;
                 if (ConnectByOrigin == TopAbs_FORWARD)
                   ElCLib::AdjustPeriodic(FparSeq.Last(),
-                                         FparSeq.Last() + 2.*PI,
+                                         FparSeq.Last() + 2.*M_PI,
                                          Precision::PConfusion(), NewFpar, NewLpar);
                 else
-                  ElCLib::AdjustPeriodic(FparSeq.Last() - 2.*PI,
+                  ElCLib::AdjustPeriodic(FparSeq.Last() - 2.*M_PI,
                                          FparSeq.Last(),
                                          Precision::PConfusion(), NewFpar, NewLpar);
                 Done = Standard_True;
@@ -625,13 +653,13 @@ Standard_Integer GEOMImpl_ShapeDriver::Execute(TFunction_Logbook& log) const
                 NewFpar = ElCLib::Parameter(PrevEllipse, P1);
                 NewLpar = ElCLib::Parameter(PrevEllipse, P2);
                 if (NewLpar < NewFpar)
-                  NewLpar += 2.*PI;
+                  NewLpar += 2.*M_PI;
                 if (ConnectByOrigin == TopAbs_FORWARD)
                   ElCLib::AdjustPeriodic(FparSeq.Last(),
-                                         FparSeq.Last() + 2.*PI,
+                                         FparSeq.Last() + 2.*M_PI,
                                          Precision::PConfusion(), NewFpar, NewLpar);
                 else
-                  ElCLib::AdjustPeriodic(FparSeq.Last() - 2.*PI,
+                  ElCLib::AdjustPeriodic(FparSeq.Last() - 2.*M_PI,
                                          FparSeq.Last(),
                                          Precision::PConfusion(), NewFpar, NewLpar);
                 Done = Standard_True;
@@ -714,38 +742,43 @@ Standard_Integer GEOMImpl_ShapeDriver::Execute(TFunction_Logbook& log) const
     LastVertex = wexp.CurrentVertex();
     TolSeq.Append(BRep_Tool::Tolerance(LastVertex));
 
+    TopoDS_Vertex FirstVtx_final = (FinalReverse)? LastVertex : FirstVertex;
+    FirstVtx_final.Orientation(TopAbs_FORWARD);
+    TopoDS_Vertex LastVtx_final = (FinalReverse)? FirstVertex : LastVertex;
+    LastVtx_final.Orientation(TopAbs_REVERSED);
+
     if (!CurveSeq.IsEmpty())
     {
       Standard_Integer nb_curve = CurveSeq.Length();   //number of curves
       TColGeom_Array1OfBSplineCurve tab(0,nb_curve-1);                    //array of the curves
       TColStd_Array1OfReal tabtolvertex(0,nb_curve-1); //(0,nb_curve-2);  //array of the tolerances
-      
+
       Standard_Integer i;
-      
+
       if (nb_curve > 1)
       {
         for (i = 1; i <= nb_curve; i++)
         {
           if (CurveSeq(i)->IsInstance(STANDARD_TYPE(Geom_TrimmedCurve)))
             CurveSeq(i) = (*((Handle(Geom_TrimmedCurve)*)&(CurveSeq(i))))->BasisCurve();
-          
+
           Handle(Geom_TrimmedCurve) aTrCurve = new Geom_TrimmedCurve(CurveSeq(i), FparSeq(i), LparSeq(i));
           tab(i-1) = GeomConvert::CurveToBSplineCurve(aTrCurve);
           tab(i-1)->Transform(LocSeq(i).Location().Transformation());
           GeomConvert::C0BSplineToC1BSplineCurve(tab(i-1), Precision::Confusion());
           if (LocSeq(i).Orientation() == TopAbs_REVERSED)
             tab(i-1)->Reverse();
-          
+
           //Temporary
           //char* name = new char[100];
           //sprintf(name, "c%d", i);
           //DrawTrSurf::Set(name, tab(i-1));
-          
+
           if (i > 1)
             tabtolvertex(i-2) = TolSeq(i-1);
         } // end for (i = 1; i <= nb_curve; i++)
         tabtolvertex(nb_curve-1) = TolSeq(TolSeq.Length());
-        
+
         Standard_Boolean closed_flag = Standard_False;
         Standard_Real closed_tolerance = 0.;
         if (FirstVertex.IsSame(LastVertex) &&
@@ -757,7 +790,7 @@ Standard_Integer GEOMImpl_ShapeDriver::Execute(TFunction_Logbook& log) const
           closed_flag = Standard_True ;
           closed_tolerance = BRep_Tool::Tolerance(FirstVertex);
         }
-        
+
         Handle(TColGeom_HArray1OfBSplineCurve)  concatcurve;     //array of the concatenated curves
         Handle(TColStd_HArray1OfInteger)        ArrayOfIndices;  //array of the remining Vertex
         GeomConvert::ConcatC1(tab,
@@ -766,34 +799,119 @@ Standard_Integer GEOMImpl_ShapeDriver::Execute(TFunction_Logbook& log) const
                               concatcurve,
                               closed_flag,
                               closed_tolerance);   //C1 concatenation
-        
+
         if (concatcurve->Length() > 1)
         {
           GeomConvert_CompCurveToBSplineCurve Concat(concatcurve->Value(concatcurve->Lower()));
-          
+
           for (i = concatcurve->Lower()+1; i <= concatcurve->Upper(); i++)
             Concat.Add( concatcurve->Value(i), LinTol, Standard_True );
-          
+
           concatcurve->SetValue(concatcurve->Lower(), Concat.BSplineCurve());
         }
-        
+        // rnc : prevents the driver from building an edge without C1 continuity
+        if (concatcurve->Value(concatcurve->Lower())->Continuity()==GeomAbs_C0){
+          Standard_ConstructionError::Raise("Construction aborted : The given Wire has sharp bends between some Edges, no valid Edge can be built");
+        }
         ResEdge = BRepLib_MakeEdge(concatcurve->Value(concatcurve->Lower()),
-                                   FirstVertex, LastVertex);
+                                   FirstVtx_final, LastVtx_final,
+                                   concatcurve->Value(concatcurve->Lower())->FirstParameter(),
+                                   concatcurve->Value(concatcurve->Lower())->LastParameter());
       }
       else
       {
         if (CurveSeq(1)->IsInstance(STANDARD_TYPE(Geom_TrimmedCurve)))
-          CurveSeq(1) = (*((Handle(Geom_TrimmedCurve)*)&(CurveSeq(i))))->BasisCurve();
-        
+          CurveSeq(1) = (*((Handle(Geom_TrimmedCurve)*)&(CurveSeq(1))))->BasisCurve();
+
         CurveSeq(1)->Transform(LocSeq(1).Location().Transformation());
         ResEdge = BRepLib_MakeEdge(CurveSeq(1),
-                                   FirstVertex, LastVertex,
+                                   FirstVtx_final, LastVtx_final,
                                    FparSeq(1), LparSeq(1));
       }
     }
-      
+
+    if (FinalReverse)
+      ResEdge.Reverse();
+
     aShape = ResEdge;
   }
+  else if (aType == EDGE_CURVE_LENGTH) {
+    GEOMImpl_IVector aVI (aFunction);
+
+    // RefCurve
+    Handle(GEOM_Function) aRefCurve = aVI.GetPoint1();
+    if (aRefCurve.IsNull()) Standard_NullObject::Raise("Argument Curve is null");
+    TopoDS_Shape aRefShape1 = aRefCurve->GetValue();
+    if (aRefShape1.ShapeType() != TopAbs_EDGE) {
+      Standard_TypeMismatch::Raise
+        ("Edge On Curve creation aborted : curve shape is not an edge");
+    }
+    TopoDS_Edge aRefEdge = TopoDS::Edge(aRefShape1);
+    TopoDS_Vertex V1, V2;
+    TopExp::Vertices(aRefEdge, V1, V2, Standard_True);
+
+    // RefPoint
+    TopoDS_Vertex aRefVertex;
+    Handle(GEOM_Function) aRefPoint = aVI.GetPoint2();
+    if (aRefPoint.IsNull()) {
+      aRefVertex = V1;
+    }
+    else {
+      TopoDS_Shape aRefShape2 = aRefPoint->GetValue();
+      if (aRefShape2.ShapeType() != TopAbs_VERTEX) {
+        Standard_TypeMismatch::Raise
+          ("Edge On Curve creation aborted : start point shape is not a vertex");
+      }
+      aRefVertex = TopoDS::Vertex(aRefShape2);
+    }
+    gp_Pnt aRefPnt = BRep_Tool::Pnt(aRefVertex);
+
+    // Length
+    Standard_Real aLength = aVI.GetParameter();
+    //Standard_Real aCurveLength = IntTools::Length(aRefEdge);
+    //if (aLength > aCurveLength) {
+    //  Standard_ConstructionError::Raise
+    //    ("Edge On Curve creation aborted : given length is greater than edges length");
+    //}
+    if (fabs(aLength) < Precision::Confusion()) {
+      Standard_ConstructionError::Raise
+        ("Edge On Curve creation aborted : given length is smaller than Precision::Confusion()");
+    }
+
+    // Check orientation
+    Standard_Real UFirst, ULast;
+    Handle(Geom_Curve) EdgeCurve = BRep_Tool::Curve(aRefEdge, UFirst, ULast);
+    Handle(Geom_Curve) ReOrientedCurve = EdgeCurve;
+
+    Standard_Real dU = ULast - UFirst;
+    Standard_Real par1 = UFirst + 0.1 * dU;
+    Standard_Real par2 = ULast  - 0.1 * dU;
+
+    gp_Pnt P1 = EdgeCurve->Value(par1);
+    gp_Pnt P2 = EdgeCurve->Value(par2);
+
+    if (aRefPnt.SquareDistance(P2) < aRefPnt.SquareDistance(P1)) {
+      ReOrientedCurve = EdgeCurve->Reversed();
+      UFirst = EdgeCurve->ReversedParameter(ULast);
+    }
+
+    // Get the point by length
+    GeomAdaptor_Curve AdapCurve = GeomAdaptor_Curve(ReOrientedCurve);
+    GCPnts_AbscissaPoint anAbsPnt (AdapCurve, aLength, UFirst);
+    Standard_Real aParam = anAbsPnt.Parameter();
+
+    if (AdapCurve.IsClosed() && aLength < 0.0) {
+      Standard_Real aTmp = aParam;
+      aParam = UFirst;
+      UFirst = aTmp;
+    }
+
+    BRepBuilderAPI_MakeEdge aME (ReOrientedCurve, UFirst, aParam);
+    if (aME.IsDone())
+      aShape = aME.Shape();
+  }
+  else {
+  }
 
   if (aShape.IsNull()) return 0;
 
@@ -807,6 +925,9 @@ Standard_Integer GEOMImpl_ShapeDriver::Execute(TFunction_Logbook& log) const
 
   log.SetTouched(Label());
 
+  if (!aWarning.IsEmpty())
+    Standard_Failure::Raise(aWarning.ToCString());
+
   return 1;
 }
 
@@ -852,3 +973,72 @@ const Handle(GEOMImpl_ShapeDriver) Handle(GEOMImpl_ShapeDriver)::DownCast(const
 
   return _anOtherObject;
 }
+
+//modified by NIZNHY-PKV Wed Dec 28 13:48:31 2011f
+#include <TopoDS_Iterator.hxx>
+#include <TopTools_HSequenceOfShape.hxx>
+#include <ShapeAnalysis_FreeBounds.hxx>
+#include <TopTools_MapOfShape.hxx>
+#include <TopTools_MapOfOrientedShape.hxx>
+#include <BRep_Builder.hxx>
+#include <TopoDS_Wire.hxx>
+
+//=======================================================================
+//function : KeepEdgesOrder
+//purpose  : 
+//=======================================================================
+/*
+void KeepEdgesOrder(const Handle(TopTools_HSequenceOfShape)& aEdges,
+                   const Handle(TopTools_HSequenceOfShape)& aWires)
+{
+  Standard_Integer aNbWires, aNbEdges;
+  // 
+  if (aEdges.IsNull()) {
+    return;
+  }
+  //
+  if (aWires.IsNull()) {
+    return;
+  }
+  //
+  aNbEdges=aEdges->Length();
+  aNbWires=aWires->Length();
+  if (!aNbEdges || !aNbWires) {
+    return;
+  }
+  //-----
+  Standard_Boolean bClosed;
+  Standard_Integer i, j;
+  TopoDS_Wire aWy;
+  TopoDS_Iterator aIt;
+  BRep_Builder aBB;
+  TopTools_MapOfOrientedShape aMEx;
+  //
+  for (i=1; i<=aNbWires; ++i) {
+    const TopoDS_Shape& aWx=aWires->Value(i);
+    //
+    aMEx.Clear();
+    aIt.Initialize (aWx);
+    for (; aIt.More(); aIt.Next()) {
+      const TopoDS_Shape& aEx=aIt.Value();
+      aMEx.Add(aEx);
+    }
+    // aWy
+    aBB.MakeWire (aWy);
+    for (j=1; j<=aNbEdges; ++j) {
+      const TopoDS_Shape& aE=aEdges->Value(j);
+      if (aMEx.Contains(aE)) {
+       aBB.Add(aWy, aE);
+      }
+    }
+    //
+    bClosed=aWx.Closed();
+    aWy.Closed(bClosed);
+    //
+    aWires->Append(aWy);
+  }// for (i=1; i<=aNbWires; ++i) {
+  //
+  aWires->Remove(1, aNbWires);
+}
+*/
+//modified by NIZNHY-PKV Wed Dec 28 13:48:34 2011t