Salome HOME
Merge from V5_1_3_BR branch (07/12/09)
[modules/geom.git] / src / GEOMImpl / GEOMImpl_ShapeDriver.cxx
index 1165007ea9f0bab0746bb005447220d30d6f6688..17d810da96250b99874c30613db28ba784d39fcf 100644 (file)
@@ -54,6 +54,7 @@
 #include <TopoDS_Solid.hxx>
 #include <TopoDS_Compound.hxx>
 #include <TopoDS_Iterator.hxx>
+#include <TopExp.hxx>
 #include <TopExp_Explorer.hxx>
 
 #include <TopTools_MapOfShape.hxx>
@@ -168,20 +169,22 @@ Standard_Integer GEOMImpl_ShapeDriver::Execute(TFunction_Logbook& log) const
       if (aFW->StatusConnected(ShapeExtend_FAIL)) {
         Standard_ConstructionError::Raise("Wire construction failed: cannot build connected wire");
       }
-
       // IMP 0019766
-      aFW->FixGapsByRangesMode() = Standard_True;
-      if (aFW->FixGaps3d()) {
-        Handle(ShapeExtend_WireData) sbwd = aFW->WireData();
-        Handle(ShapeFix_Edge) aFe = new ShapeFix_Edge;
-        for (Standard_Integer iedge = 1; iedge <= sbwd->NbEdges(); iedge++) {
-          TopoDS_Edge aEdge = TopoDS::Edge(sbwd->Edge(iedge));
-          aFe->FixVertexTolerance(aEdge);
-          aFe->FixSameParameter(aEdge);
+      if (aFW->StatusConnected(ShapeExtend_DONE3)) {
+        // Confused with <prec> but not Analyzer.Precision(), set the same
+        aFW->FixGapsByRangesMode() = Standard_True;
+        if (aFW->FixGaps3d()) {
+          Handle(ShapeExtend_WireData) sbwd = aFW->WireData();
+          Handle(ShapeFix_Edge) aFe = new ShapeFix_Edge;
+          for (Standard_Integer iedge = 1; iedge <= sbwd->NbEdges(); iedge++) {
+            TopoDS_Edge aEdge = TopoDS::Edge(sbwd->Edge(iedge));
+            aFe->FixVertexTolerance(aEdge);
+            aFe->FixSameParameter(aEdge);
+          }
+        }
+        else if (aFW->StatusGaps3d(ShapeExtend_FAIL)) {
+          Standard_ConstructionError::Raise("Wire construction failed: cannot fix 3d gaps");
         }
-      }
-      else if (aFW->StatusGaps3d(ShapeExtend_FAIL)) {
-        Standard_ConstructionError::Raise("Wire construction failed: cannot fix 3d gaps");
       }
 
       aShape = aFW->WireAPIMake();
@@ -194,6 +197,14 @@ Standard_Integer GEOMImpl_ShapeDriver::Execute(TFunction_Logbook& log) const
     TopoDS_Wire W;
     if (aShapeBase.ShapeType() == TopAbs_WIRE) {
       W = TopoDS::Wire(aShapeBase);
+      // check the wire is closed
+      TopoDS_Vertex aV1, aV2;
+      TopExp::Vertices(W, aV1, aV2);
+      if ( !aV1.IsNull() && !aV2.IsNull() && aV1.IsSame(aV2) )
+        aShapeBase.Closed(true);
+      else
+        Standard_NullObject::Raise
+          ("Shape for face construction is not closed");
     }
     else if (aShapeBase.ShapeType() == TopAbs_EDGE && aShapeBase.Closed()) {
       BRepBuilderAPI_MakeWire MW;
@@ -410,15 +421,10 @@ Standard_Integer GEOMImpl_ShapeDriver::Execute(TFunction_Logbook& log) const
     if ( ish == 0 ) return 0;
     BRepClass3d_SolidClassifier SC (Sol);
     SC.PerformInfinitePoint(Precision::Confusion());
-    switch (SC.State()) {
-    case TopAbs_IN:
-      aShape = Sol.Reversed(); break;
-    case TopAbs_OUT:
-      aShape = Sol; break;
-    default: // not closed shell?
-      return 0;
-    }
-
+    if (SC.State() == TopAbs_IN)
+      aShape = Sol.Reversed();
+    else
+      aShape = Sol;
   }
   else if (aType == COMPOUND_SHAPES) {
     Handle(TColStd_HSequenceOfTransient) aShapes = aCI.GetShapes();