Salome HOME
0020598: EDF 1191 GEOM : Creation of hexa block from two faces
authordmv <dmv@opencascade.com>
Thu, 3 Dec 2009 14:07:48 +0000 (14:07 +0000)
committerdmv <dmv@opencascade.com>
Thu, 3 Dec 2009 14:07:48 +0000 (14:07 +0000)
src/GEOMImpl/GEOMImpl_Block6Explorer.cxx
src/GEOMImpl/GEOMImpl_BlockDriver.cxx
src/GEOMImpl/GEOMImpl_PolylineDriver.cxx
src/GEOMImpl/GEOMImpl_ShapeDriver.cxx

index 68e3983d911d4151f35fce2f7435814a6fac67cb..db47bb49a2bac596228c7bbc001e09e49590d198 100644 (file)
@@ -983,6 +983,19 @@ void GEOMImpl_Block6Explorer::InitByTwoFaces (const TopoDS_Shape& theFace1,
     myEdges(edge_id(2, i)) = anEdges2(nb);
   }
 
+  // check the wires closure
+  TopoDS_Wire wire1 = TopoDS::Wire(aWire1);
+  TopoDS_Wire wire2 = TopoDS::Wire(aWire2);
+  TopoDS_Vertex aV1, aV2;
+  
+  TopExp::Vertices(wire1, aV1, aV2);
+  if ( !aV1.IsNull() && !aV2.IsNull() && aV1.IsSame(aV2) )
+    aWire1.Closed( true );
+  
+  TopExp::Vertices(wire2, aV1, aV2);
+  if ( !aV1.IsNull() && !aV2.IsNull() && aV1.IsSame(aV2) )
+    aWire2.Closed( true );
+  
   // 4. Generate side surface
   if (!aWire1.Closed() || !aWire2.Closed()) {
     // BRepOffsetAPI_ThruSections is not applicable on not closed wires
index 880661f70c3b4b93f6da7792390354a8c29313a4..56cfb3607c6384a21cf0aade05412b7d89fbfdcf 100644 (file)
@@ -235,6 +235,13 @@ Standard_Integer GEOMImpl_BlockDriver::Execute(TFunction_Logbook& log) const
       }
       TopoDS_Wire aWire = *MW;
       delete MW; 
+
+      // check the wire closure
+      TopoDS_Vertex aV1, aV2;
+      TopExp::Vertices(aWire, aV1, aV2);
+      if ( !aV1.IsNull() && !aV2.IsNull() && aV1.IsSame(aV2) )
+        aWire.Closed( true );
+
       if (!aWire.Closed()) {
         Standard_ConstructionError::Raise
           ("Impossible to build a closed wire from the given edges");
@@ -293,13 +300,27 @@ Standard_Integer GEOMImpl_BlockDriver::Execute(TFunction_Logbook& log) const
       }
 
       // build a wire
-      BRepBuilderAPI_MakeWire MW (anEdge1, anEdge3, anEdge2, anEdge4);
-      if (!MW.IsDone()) {
+      BRepBuilderAPI_MakeWire* MW;
+      MW = new BRepBuilderAPI_MakeWire(anEdge1, anEdge3, anEdge2, anEdge4);
+      if (!MW->IsDone()) {
         Standard_ConstructionError::Raise("Wire construction failed");
       }
 
+      TopoDS_Wire aWire = *MW;
+      delete MW;
+
+      TopoDS_Vertex aV1, aV2;
+      TopExp::Vertices(aWire, aV1, aV2);
+      if ( !aV1.IsNull() && !aV2.IsNull() && aV1.IsSame(aV2) )
+        aWire.Closed( true );
+
+      if (!aWire.Closed()) {
+        Standard_ConstructionError::Raise
+          ("Impossible to build a closed wire from the given edges");
+      }
+
       // try to build face on the wire
-      GEOMImpl_Block6Explorer::MakeFace(MW, Standard_False, aShape);
+      GEOMImpl_Block6Explorer::MakeFace(aWire, Standard_False, aShape);
       if (aShape.IsNull()) {
         Standard_ConstructionError::Raise("Face construction failed");
       }
@@ -357,6 +378,7 @@ Standard_Integer GEOMImpl_BlockDriver::Execute(TFunction_Logbook& log) const
       }
 
       // try to build face on the wire
+      aMkPoly.Close();
       GEOMImpl_Block6Explorer::MakeFace(aMkPoly, Standard_False, aShape);
       if (aShape.IsNull()) {
         Standard_ConstructionError::Raise("Face construction failed");
index 5a295e43b63eddf899bdc23a921fff540c99de4d..f18427df9c1a607622e69a176b57d691ef107301 100644 (file)
@@ -84,7 +84,20 @@ Standard_Integer GEOMImpl_PolylineDriver::Execute(TFunction_Logbook& log) const
 //        if (!aMakePoly.Added()) return 0;
       }
     }
-    if (false) aMakePoly.Close();
+    // Compare first and last point coordinates and close polyline if it's the same.
+    if ( aLen > 2 ) {
+      Handle(GEOM_Function) aFPoint = aCI.GetPoint(1);
+      TopoDS_Shape aFirstPnt = aFPoint->GetValue();
+      TopoDS_Vertex aV1 = TopoDS::Vertex(aFirstPnt);
+
+      Handle(GEOM_Function) aLPoint = aCI.GetPoint(aLen);
+      TopoDS_Shape aLastPnt = aLPoint->GetValue();
+      TopoDS_Vertex aV2 = TopoDS::Vertex(aLastPnt);
+
+      if ( !aV1.IsNull() && !aV2.IsNull() && aV1.IsSame(aV2) )
+        aMakePoly.Close();
+    }
+
     if (aMakePoly.IsDone()) {
       aShape = aMakePoly.Wire();
     }
index ca0f348edef62f74fb985200661ad786f8ada1c9..f557dea20c988df6c6d9b1a0b1c8a3ba29c5e95c 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>
@@ -196,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;