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
}
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");
}
// 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");
}
}
// 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");
// 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();
}
#include <TopoDS_Solid.hxx>
#include <TopoDS_Compound.hxx>
#include <TopoDS_Iterator.hxx>
+#include <TopExp.hxx>
#include <TopExp_Explorer.hxx>
#include <TopTools_MapOfShape.hxx>
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;