From a7429605d88f25e9d59206b1dfe7eef0ddfae34e Mon Sep 17 00:00:00 2001 From: jfa Date: Mon, 28 Nov 2005 10:37:46 +0000 Subject: [PATCH] Fix for bug 10627. Now you can pass edges for wire construction in any order. --- src/GEOMImpl/GEOMImpl_ShapeDriver.cxx | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/src/GEOMImpl/GEOMImpl_ShapeDriver.cxx b/src/GEOMImpl/GEOMImpl_ShapeDriver.cxx index dce557fc9..227b76d4f 100644 --- a/src/GEOMImpl/GEOMImpl_ShapeDriver.cxx +++ b/src/GEOMImpl/GEOMImpl_ShapeDriver.cxx @@ -9,6 +9,9 @@ #include +// OCCT Includes +#include + #include #include #include @@ -77,8 +80,10 @@ Standard_Integer GEOMImpl_ShapeDriver::Execute(TFunction_Logbook& log) const Handle(TColStd_HSequenceOfTransient) aShapes = aCI.GetShapes(); unsigned int ind, nbshapes = aShapes->Length(); + TopoDS_Wire aWire; + B.MakeWire(aWire); + // add edges - BRepBuilderAPI_MakeWire MW; for (ind = 1; ind <= nbshapes; ind++) { Handle(GEOM_Function) aRefShape = Handle(GEOM_Function)::DownCast(aShapes->Value(ind)); TopoDS_Shape aShape_i = aRefShape->GetValue(); @@ -86,18 +91,28 @@ Standard_Integer GEOMImpl_ShapeDriver::Execute(TFunction_Logbook& log) const Standard_NullObject::Raise("Shape for wire construction is null"); } if (aShape_i.ShapeType() == TopAbs_EDGE) - MW.Add(TopoDS::Edge(aShape_i)); + B.Add(aWire, TopoDS::Edge(aShape_i)); else if (aShape_i.ShapeType() == TopAbs_WIRE) - MW.Add(TopoDS::Wire(aShape_i)); + B.Add(aWire, TopoDS::Wire(aShape_i)); else Standard_TypeMismatch::Raise ("Shape for wire construction is neither an edge nor a wire"); } - if (!MW.IsDone()) { + // fix edges order + Handle(ShapeFix_Wire) aFW = new ShapeFix_Wire; + aFW->Load(aWire); + aFW->FixReorder(); + + if (aFW->StatusReorder(ShapeExtend_FAIL1)) { + Standard_ConstructionError::Raise("Wire construction failed: several loops detected"); + } else if (aFW->StatusReorder(ShapeExtend_FAIL)) { Standard_ConstructionError::Raise("Wire construction failed"); + } else if (aFW->StatusReorder(ShapeExtend_DONE2)) { + Standard_ConstructionError::Raise("Wire construction failed: some gaps detected"); + } else { } - aShape = MW; + aShape = aFW->Wire(); } else if (aType == FACE_WIRE) { Handle(GEOM_Function) aRefBase = aCI.GetBase();