PartDesign: improved feature parameters checks and avoid duplicate code
This commit is contained in:
@@ -26,19 +26,18 @@
|
||||
# include <BRep_Builder.hxx>
|
||||
# include <BRepBndLib.hxx>
|
||||
# include <BRepPrimAPI_MakeRevol.hxx>
|
||||
# include <BRepBuilderAPI_Copy.hxx>
|
||||
# include <BRepBuilderAPI_MakeFace.hxx>
|
||||
# include <TopoDS.hxx>
|
||||
# include <TopoDS_Face.hxx>
|
||||
# include <TopoDS_Wire.hxx>
|
||||
# include <TopExp_Explorer.hxx>
|
||||
# include <BRepAlgoAPI_Fuse.hxx>
|
||||
# include <Precision.hxx>
|
||||
#endif
|
||||
|
||||
#include <Base/Axis.h>
|
||||
#include <Base/Placement.h>
|
||||
#include <Base/Tools.h>
|
||||
#include <Mod/Part/App/Part2DObject.h>
|
||||
|
||||
#include "FeatureRevolution.h"
|
||||
|
||||
@@ -71,35 +70,21 @@ short Revolution::mustExecute() const
|
||||
|
||||
App::DocumentObjectExecReturn *Revolution::execute(void)
|
||||
{
|
||||
App::DocumentObject* link = Sketch.getValue();
|
||||
if (!link)
|
||||
return new App::DocumentObjectExecReturn("No sketch linked");
|
||||
if (!link->getTypeId().isDerivedFrom(Part::Part2DObject::getClassTypeId()))
|
||||
return new App::DocumentObjectExecReturn("Linked object is not a Sketch or Part2DObject");
|
||||
|
||||
Part::Part2DObject* pcSketch=static_cast<Part::Part2DObject*>(link);
|
||||
|
||||
TopoDS_Shape shape = pcSketch->Shape.getShape()._Shape;
|
||||
if (shape.IsNull())
|
||||
return new App::DocumentObjectExecReturn("Linked shape object is empty");
|
||||
|
||||
// this is a workaround for an obscure OCC bug which leads to empty tessellations
|
||||
// for some faces. Making an explicit copy of the linked shape seems to fix it.
|
||||
// The error only happens when re-computing the shape.
|
||||
if (!this->Shape.getValue().IsNull()) {
|
||||
BRepBuilderAPI_Copy copy(shape);
|
||||
shape = copy.Shape();
|
||||
if (shape.IsNull())
|
||||
return new App::DocumentObjectExecReturn("Linked shape object is empty");
|
||||
}
|
||||
|
||||
TopExp_Explorer ex;
|
||||
// Validate parameters
|
||||
double a = Angle.getValue();
|
||||
if (a < Precision::Confusion())
|
||||
return new App::DocumentObjectExecReturn("Angle of groove too small");
|
||||
if (a > 360.0)
|
||||
return new App::DocumentObjectExecReturn("Angle of groove too large");
|
||||
|
||||
Part::Part2DObject* pcSketch = 0;
|
||||
std::vector<TopoDS_Wire> wires;
|
||||
for (ex.Init(shape, TopAbs_WIRE); ex.More(); ex.Next()) {
|
||||
wires.push_back(TopoDS::Wire(ex.Current()));
|
||||
try {
|
||||
pcSketch = getVerifiedSketch();
|
||||
wires = getSketchWires();
|
||||
} catch (const Base::Exception& e) {
|
||||
return new App::DocumentObjectExecReturn(e.what());
|
||||
}
|
||||
if (wires.empty()) // there can be several wires
|
||||
return new App::DocumentObjectExecReturn("Linked shape object is not a wire");
|
||||
|
||||
// get the Sketch plane
|
||||
Base::Placement SketchPlm = pcSketch->Placement.getValue();
|
||||
@@ -174,6 +159,9 @@ App::DocumentObjectExecReturn *Revolution::execute(void)
|
||||
|
||||
if (RevolMaker.IsDone()) {
|
||||
TopoDS_Shape result = RevolMaker.Shape();
|
||||
// set the additive shape property for later usage in e.g. pattern
|
||||
this->AddShape.setValue(result);
|
||||
|
||||
// if the sketch has a support fuse them to get one result object (PAD!)
|
||||
if (SupportObject) {
|
||||
const TopoDS_Shape& support = SupportObject->Shape.getValue();
|
||||
|
||||
Reference in New Issue
Block a user