0020598: EDF 1191 GEOM : Creation of hexa block from two faces

This commit is contained in:
dmv 2009-12-03 14:07:48 +00:00
parent 2b5e9d2459
commit afe8b139b0
4 changed files with 61 additions and 4 deletions

View 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

View 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");

View 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();
}

View 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;