Added check to Revolution and Groove for sketch axis intersecting the sketch face

This commit is contained in:
jrheinlaender
2012-11-30 17:29:07 +04:30
committed by wmayer
parent 8a1c9f0651
commit 8371982dfc
4 changed files with 85 additions and 9 deletions

View File

@@ -33,6 +33,7 @@
# include <TopExp_Explorer.hxx>
# include <BRepAlgoAPI_Fuse.hxx>
# include <Precision.hxx>
# include <gp_Lin.hxx>
#endif
#include <Base/Axis.h>
@@ -40,6 +41,7 @@
#include <Base/Tools.h>
#include "FeatureRevolution.h"
#include <Base/Console.h>
using namespace PartDesign;
@@ -76,12 +78,12 @@ App::DocumentObjectExecReturn *Revolution::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;
try {
@@ -90,7 +92,7 @@ App::DocumentObjectExecReturn *Revolution::execute(void)
} catch (const Base::Exception& e) {
return new App::DocumentObjectExecReturn(e.what());
}
TopoDS_Shape support;
try {
support = getSupportShape();
@@ -158,6 +160,10 @@ App::DocumentObjectExecReturn *Revolution::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);
@@ -186,7 +192,7 @@ App::DocumentObjectExecReturn *Revolution::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());