From afe8b139b090bcf9b7d7be49b4937906887837b4 Mon Sep 17 00:00:00 2001 From: dmv Date: Thu, 3 Dec 2009 14:07:48 +0000 Subject: [PATCH] 0020598: EDF 1191 GEOM : Creation of hexa block from two faces --- src/GEOMImpl/GEOMImpl_Block6Explorer.cxx | 13 +++++++++++ src/GEOMImpl/GEOMImpl_BlockDriver.cxx | 28 +++++++++++++++++++++--- src/GEOMImpl/GEOMImpl_PolylineDriver.cxx | 15 ++++++++++++- src/GEOMImpl/GEOMImpl_ShapeDriver.cxx | 9 ++++++++ 4 files changed, 61 insertions(+), 4 deletions(-) diff --git a/src/GEOMImpl/GEOMImpl_Block6Explorer.cxx b/src/GEOMImpl/GEOMImpl_Block6Explorer.cxx index 68e3983d9..db47bb49a 100644 --- a/src/GEOMImpl/GEOMImpl_Block6Explorer.cxx +++ b/src/GEOMImpl/GEOMImpl_Block6Explorer.cxx @@ -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 diff --git a/src/GEOMImpl/GEOMImpl_BlockDriver.cxx b/src/GEOMImpl/GEOMImpl_BlockDriver.cxx index 880661f70..56cfb3607 100644 --- a/src/GEOMImpl/GEOMImpl_BlockDriver.cxx +++ b/src/GEOMImpl/GEOMImpl_BlockDriver.cxx @@ -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"); diff --git a/src/GEOMImpl/GEOMImpl_PolylineDriver.cxx b/src/GEOMImpl/GEOMImpl_PolylineDriver.cxx index 5a295e43b..f18427df9 100644 --- a/src/GEOMImpl/GEOMImpl_PolylineDriver.cxx +++ b/src/GEOMImpl/GEOMImpl_PolylineDriver.cxx @@ -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(); } diff --git a/src/GEOMImpl/GEOMImpl_ShapeDriver.cxx b/src/GEOMImpl/GEOMImpl_ShapeDriver.cxx index ca0f348ed..f557dea20 100644 --- a/src/GEOMImpl/GEOMImpl_ShapeDriver.cxx +++ b/src/GEOMImpl/GEOMImpl_ShapeDriver.cxx @@ -54,6 +54,7 @@ #include #include #include +#include #include #include @@ -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; -- 2.39.2