Protect EdgeWalker against bad input

This commit is contained in:
WandererFan
2016-09-11 13:12:24 -04:00
parent d3afb32487
commit 6c937e1bbe
5 changed files with 216 additions and 45 deletions
+27 -16
View File
@@ -245,7 +245,9 @@ App::DocumentObjectExecReturn *DrawViewSection::execute(void)
inputCenter,
Direction.getValue(),
validXDir);
builder.Add(newFaces,pFace);
if (!pFace.IsNull()) {
builder.Add(newFaces,pFace);
}
}
sectionFaces = newFaces;
@@ -393,28 +395,37 @@ TopoDS_Face DrawViewSection::projectFace(const TopoDS_Shape &face,
// }
// }
TopoDS_Face projectedFace;
if (faceEdges.empty()) {
Base::Console().Log("LOG - DVS::projectFace - no faceEdges\n");
return projectedFace;
}
//recreate the wires for this single face
EdgeWalker ew;
ew.loadEdges(faceEdges);
ew.perform();
std::vector<TopoDS_Wire> fw = ew.getResultNoDups();
bool success = ew.perform();
if (success) {
std::vector<TopoDS_Wire> fw = ew.getResultNoDups();
TopoDS_Face projectedFace;
if (!fw.empty()) {
std::vector<TopoDS_Wire> sortedWires = ew.sortStrip(fw, true);
if (sortedWires.empty()) {
return projectedFace;
}
if (!fw.empty()) {
std::vector<TopoDS_Wire> sortedWires = ew.sortStrip(fw, true);
if (sortedWires.empty()) {
return projectedFace;
BRepBuilderAPI_MakeFace mkFace(sortedWires.front(),true); //true => only want planes?
std::vector<TopoDS_Wire>::iterator itWire = ++sortedWires.begin(); //starting with second face
for (; itWire != sortedWires.end(); itWire++) {
mkFace.Add(*itWire);
}
projectedFace = mkFace.Face();
}
BRepBuilderAPI_MakeFace mkFace(sortedWires.front(),true); //true => only want planes?
std::vector<TopoDS_Wire>::iterator itWire = ++sortedWires.begin(); //starting with second face
for (; itWire != sortedWires.end(); itWire++) {
mkFace.Add(*itWire);
}
projectedFace = mkFace.Face();
} else {
Base::Console().Warning("DVS::projectFace - input is not planar graph. No face detection\n");
}
return projectedFace;
}