Path.Area: Changed FeatureArea WorkPlane behavior
FeatureArea will return the user defined workplane if there is one, or else it returns auto selected plane by its internal Area object
This commit is contained in:
@@ -146,6 +146,7 @@ Area::~Area() {
|
||||
}
|
||||
|
||||
void Area::setPlane(const TopoDS_Shape &shape) {
|
||||
clean();
|
||||
if(shape.IsNull()) {
|
||||
myWorkPlane.Nullify();
|
||||
return;
|
||||
@@ -156,7 +157,6 @@ void Area::setPlane(const TopoDS_Shape &shape) {
|
||||
throw Base::ValueError("shape is not planar");
|
||||
myWorkPlane = plane;
|
||||
myTrsf = trsf;
|
||||
clean();
|
||||
}
|
||||
|
||||
bool Area::isCoplanar(const TopoDS_Shape &s1, const TopoDS_Shape &s2) {
|
||||
|
||||
@@ -242,8 +242,6 @@ protected:
|
||||
|
||||
void explode(const TopoDS_Shape &shape);
|
||||
|
||||
bool isBuilt() const;
|
||||
|
||||
TopoDS_Shape findPlane(const TopoDS_Shape &shape, gp_Trsf &trsf);
|
||||
|
||||
public:
|
||||
@@ -254,6 +252,8 @@ public:
|
||||
Area(const Area &other, bool deep_copy=true);
|
||||
virtual ~Area();
|
||||
|
||||
bool isBuilt() const;
|
||||
|
||||
/** Set a working plane
|
||||
*
|
||||
* \arg \c shape: a shape defining a working plane.
|
||||
|
||||
@@ -98,7 +98,7 @@ same algorithm</UserDocu>
|
||||
</Documentation>
|
||||
<Parameter Name="Sections" Type="List"/>
|
||||
</Attribute>
|
||||
<Attribute Name="Workplane" ReadOnly="true">
|
||||
<Attribute Name="Workplane" ReadOnly="false">
|
||||
<Documentation>
|
||||
<UserDocu>The current workplane. If no plane is set, it is derived from the added shapes.</UserDocu>
|
||||
</Documentation>
|
||||
|
||||
@@ -178,10 +178,6 @@ struct AreaPyModifier {
|
||||
|
||||
static AreaPyModifier mod;
|
||||
|
||||
namespace Part {
|
||||
extern PartExport Py::Object shape2pyshape(const TopoDS_Shape &shape);
|
||||
}
|
||||
|
||||
using namespace Path;
|
||||
|
||||
// returns a string which represents the object e.g. when printed in python
|
||||
@@ -481,6 +477,15 @@ Py::Object AreaPy::getWorkplane(void) const {
|
||||
return Part::shape2pyshape(getAreaPtr()->getPlane());
|
||||
}
|
||||
|
||||
void AreaPy::setWorkplane(Py::Object obj) {
|
||||
PyObject* p = obj.ptr();
|
||||
if (!PyObject_TypeCheck(p, &(Part::TopoShapePy::Type))) {
|
||||
std::string error = std::string("type must be 'TopoShape', not ");
|
||||
error += p->ob_type->tp_name;
|
||||
throw Py::TypeError(error);
|
||||
}
|
||||
getAreaPtr()->setPlane(GET_TOPOSHAPE(p));
|
||||
}
|
||||
|
||||
// custom attributes get/set
|
||||
|
||||
|
||||
@@ -136,14 +136,7 @@ const std::vector<TopoDS_Shape> &FeatureArea::getShapes() {
|
||||
|
||||
short FeatureArea::mustExecute(void) const
|
||||
{
|
||||
if (Sources.isTouched())
|
||||
return 1;
|
||||
if (WorkPlane.isTouched())
|
||||
return 1;
|
||||
|
||||
PARAM_PROP_TOUCHED(AREA_PARAMS_ALL)
|
||||
|
||||
return Part::Feature::mustExecute();
|
||||
return !myArea.isBuilt() || Part::Feature::mustExecute();
|
||||
}
|
||||
|
||||
PyObject *FeatureArea::getPyObject()
|
||||
|
||||
@@ -60,6 +60,11 @@ public:
|
||||
|
||||
PARAM_PROP_DECLARE(AREA_PARAMS_ALL)
|
||||
|
||||
void setWorkPlane(const TopoDS_Shape &shape) {
|
||||
WorkPlane.setValue(shape);
|
||||
myArea.setPlane(shape);
|
||||
}
|
||||
|
||||
private:
|
||||
bool myBuild;
|
||||
Area myArea;
|
||||
|
||||
@@ -24,6 +24,12 @@
|
||||
Same usage as Path.Area.setParams(). This function stores the parameters in the properties.</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Attribute Name="WorkPlane" ReadOnly="false">
|
||||
<Documentation>
|
||||
<UserDocu>The current workplane. If no plane is set, it is derived from the added shapes.</UserDocu>
|
||||
</Documentation>
|
||||
<Parameter Name="WorkPlane" Type="Object"/>
|
||||
</Attribute>
|
||||
<CustomAttributes />
|
||||
</PythonExport>
|
||||
</GenerateModel>
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
#include "PreCompiled.h"
|
||||
|
||||
#include <CXX/Objects.hxx>
|
||||
#include <Mod/Part/App/TopoShapePy.h>
|
||||
#include "FeatureArea.h"
|
||||
|
||||
// inclusion of the generated files (generated out of FeatureAreaPy.xml)
|
||||
@@ -80,6 +81,21 @@ PyObject* FeatureAreaPy::setParams(PyObject *args, PyObject *keywds)
|
||||
return Py_None;
|
||||
}
|
||||
|
||||
Py::Object FeatureAreaPy::getWorkPlane(void) const {
|
||||
return Part::shape2pyshape(getFeatureAreaPtr()->getArea().getPlane());
|
||||
}
|
||||
|
||||
void FeatureAreaPy::setWorkPlane(Py::Object obj) {
|
||||
PyObject* p = obj.ptr();
|
||||
if (!PyObject_TypeCheck(p, &(Part::TopoShapePy::Type))) {
|
||||
std::string error = std::string("type must be 'TopoShape', not ");
|
||||
error += p->ob_type->tp_name;
|
||||
throw Py::TypeError(error);
|
||||
}
|
||||
getFeatureAreaPtr()->setWorkPlane(
|
||||
static_cast<Part::TopoShapePy*>(p)->getTopoShapePtr()->getShape());
|
||||
}
|
||||
|
||||
PyObject *FeatureAreaPy::getCustomAttributes(const char* /*attr*/) const
|
||||
{
|
||||
return 0;
|
||||
|
||||
Reference in New Issue
Block a user