Added check to Revolution and Groove for sketch axis intersecting the sketch face
This commit is contained in:
@@ -33,6 +33,7 @@
|
||||
# include <TopExp_Explorer.hxx>
|
||||
# include <BRepAlgoAPI_Cut.hxx>
|
||||
# include <Precision.hxx>
|
||||
# include <gp_Lin.hxx>
|
||||
#endif
|
||||
|
||||
#include <Base/Axis.h>
|
||||
@@ -76,12 +77,12 @@ App::DocumentObjectExecReturn *Groove::execute(void)
|
||||
return new App::DocumentObjectExecReturn("Angle of groove too small");
|
||||
if (angle > 360.0)
|
||||
return new App::DocumentObjectExecReturn("Angle of groove too large");
|
||||
|
||||
|
||||
angle = Base::toRadians<double>(angle);
|
||||
// Reverse angle if selected
|
||||
if (Reversed.getValue() && !Midplane.getValue())
|
||||
angle *= (-1.0);
|
||||
|
||||
|
||||
Part::Part2DObject* sketch = 0;
|
||||
std::vector<TopoDS_Wire> wires;
|
||||
TopoDS_Shape support;
|
||||
@@ -152,6 +153,10 @@ App::DocumentObjectExecReturn *Groove::execute(void)
|
||||
support.Move(invObjLoc);
|
||||
sketchshape.Move(invObjLoc);
|
||||
|
||||
// Check distance between sketchshape and axis - to avoid failures and crashes
|
||||
if (checkLineCrossesFace(gp_Lin(pnt, dir), TopoDS::Face(sketchshape)))
|
||||
return new App::DocumentObjectExecReturn("Revolve axis intersects the sketch");
|
||||
|
||||
// revolve the face to a solid
|
||||
BRepPrimAPI_MakeRevol RevolMaker(sketchshape, gp_Ax1(pnt, dir), angle);
|
||||
|
||||
@@ -159,7 +164,7 @@ App::DocumentObjectExecReturn *Groove::execute(void)
|
||||
TopoDS_Shape result = RevolMaker.Shape();
|
||||
// set the subtractive shape property for later usage in e.g. pattern
|
||||
this->SubShape.setValue(result);
|
||||
|
||||
|
||||
// cut out groove to get one result object
|
||||
BRepAlgoAPI_Cut mkCut(support, result);
|
||||
// Let's check if the fusion has been successful
|
||||
@@ -181,7 +186,7 @@ App::DocumentObjectExecReturn *Groove::execute(void)
|
||||
catch (Standard_Failure) {
|
||||
Handle_Standard_Failure e = Standard_Failure::Caught();
|
||||
if (std::string(e->GetMessageString()) == "TopoDS::Face")
|
||||
return new App::DocumentObjectExecReturn("Could not create face from sketch.\n"
|
||||
return new App::DocumentObjectExecReturn("Could not create face from sketch.\n"
|
||||
"Intersecting sketch entities or multiple faces in a sketch are not allowed.");
|
||||
else
|
||||
return new App::DocumentObjectExecReturn(e->GetMessageString());
|
||||
|
||||
Reference in New Issue
Block a user