]> SALOME platform Git repositories - modules/geom.git/commitdiff
Salome HOME
Mantis issue 0021399: Cant' build an edge from a wire. A fix by JGV.
authorjfa <jfa@opencascade.com>
Fri, 11 Nov 2011 12:28:39 +0000 (12:28 +0000)
committerjfa <jfa@opencascade.com>
Fri, 11 Nov 2011 12:28:39 +0000 (12:28 +0000)
src/GEOMImpl/GEOMImpl_ShapeDriver.cxx

index 332d117690809fd8c11ff49dca06dc27bf01abe7..37f3937f05e0bbd4d25cba6634ac98986a40755a 100644 (file)
@@ -495,6 +495,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())
@@ -526,6 +527,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
       {
@@ -728,6 +731,11 @@ 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
@@ -795,20 +803,25 @@ Standard_Integer GEOMImpl_ShapeDriver::Execute(TFunction_Logbook& log) const
           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) {
@@ -873,7 +886,7 @@ Standard_Integer GEOMImpl_ShapeDriver::Execute(TFunction_Logbook& log) const
 
     // Get the point by length
     GeomAdaptor_Curve AdapCurve = GeomAdaptor_Curve(ReOrientedCurve);
-    GCPnts_AbscissaPoint anAbsPnt (AdapCurve, aLength, UFirst); 
+    GCPnts_AbscissaPoint anAbsPnt (AdapCurve, aLength, UFirst);
     Standard_Real aParam = anAbsPnt.Parameter();
 
     if (AdapCurve.IsClosed() && aLength < 0.0) {