Part: make reverse function parametric
This commit is contained in:
@@ -487,12 +487,13 @@ PyMOD_INIT_FUNC(Part)
|
||||
Part::Offset2D ::init();
|
||||
Part::Thickness ::init();
|
||||
Part::Refine ::init();
|
||||
Part::Reverse ::init();
|
||||
|
||||
// Geometry types
|
||||
Part::GeometryExtension ::init();
|
||||
Part::GeometryIntExtension ::init();
|
||||
Part::GeometryExtension ::init();
|
||||
Part::GeometryIntExtension ::init();
|
||||
Part::GeometryStringExtension ::init();
|
||||
Part::GeometryBoolExtension ::init();
|
||||
Part::GeometryBoolExtension ::init();
|
||||
Part::GeometryDoubleExtension ::init();
|
||||
Part::Geometry ::init();
|
||||
Part::GeomPoint ::init();
|
||||
|
||||
@@ -694,3 +694,29 @@ App::DocumentObjectExecReturn *Refine::execute(void)
|
||||
return new App::DocumentObjectExecReturn(e.GetMessageString());
|
||||
}
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
PROPERTY_SOURCE(Part::Reverse, Part::Feature)
|
||||
|
||||
Reverse::Reverse()
|
||||
{
|
||||
ADD_PROPERTY_TYPE(Source, (0), "Reverse", App::Prop_None, "Source shape");
|
||||
}
|
||||
|
||||
App::DocumentObjectExecReturn* Reverse::execute(void)
|
||||
{
|
||||
Part::Feature* source = Source.getValue<Part::Feature*>();
|
||||
if (!source)
|
||||
return new App::DocumentObjectExecReturn("No part object linked.");
|
||||
|
||||
try {
|
||||
TopoDS_Shape myShape = source->Shape.getValue();
|
||||
if (!myShape.IsNull())
|
||||
this->Shape.setValue(myShape.Reversed());
|
||||
return App::DocumentObject::StdReturn;
|
||||
}
|
||||
catch (Standard_Failure & e) {
|
||||
return new App::DocumentObjectExecReturn(e.GetMessageString());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -173,6 +173,25 @@ public:
|
||||
//@}
|
||||
};
|
||||
|
||||
class Reverse : public Part::Feature
|
||||
{
|
||||
PROPERTY_HEADER(Part::Reverse);
|
||||
|
||||
public:
|
||||
Reverse();
|
||||
|
||||
App::PropertyLink Source;
|
||||
|
||||
/** @name methods override feature */
|
||||
//@{
|
||||
/// recalculate the feature
|
||||
App::DocumentObjectExecReturn* execute(void);
|
||||
const char* getViewProviderName(void) const {
|
||||
return "PartGui::ViewProviderReverse";
|
||||
}
|
||||
//@}
|
||||
};
|
||||
|
||||
} //namespace Part
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user