diff --git a/src/Mod/Path/App/Area.cpp b/src/Mod/Path/App/Area.cpp
index d7343a44ba..58516bab98 100644
--- a/src/Mod/Path/App/Area.cpp
+++ b/src/Mod/Path/App/Area.cpp
@@ -110,6 +110,27 @@ Area::Area(const AreaParams *params)
setParams(*params);
}
+Area::Area(const Area &other, bool deep_copy)
+:Base::BaseClass(other)
+,myShapes(other.myShapes)
+,myTrsf(other.myTrsf)
+,myParams(other.myParams)
+,myWorkPlane(other.myWorkPlane)
+,myHaveFace(other.myHaveFace)
+,myHaveSolid(other.myHaveSolid)
+,myShapeDone(false)
+{
+ if(!deep_copy) return;
+ if(other.myArea)
+ myArea.reset(new CArea(*other.myArea));
+ myShapePlane = other.myShapePlane;
+ myShape = other.myShape;
+ myShapeDone = other.myShapeDone;
+ mySections.reserve(other.mySections.size());
+ for(shared_ptr area:mySections)
+ mySections.push_back(make_shared(*area,true));
+}
+
Area::~Area() {
clean();
}
diff --git a/src/Mod/Path/App/Area.h b/src/Mod/Path/App/Area.h
index b261ddb471..ca2866149d 100644
--- a/src/Mod/Path/App/Area.h
+++ b/src/Mod/Path/App/Area.h
@@ -146,6 +146,7 @@ public:
PARAM_ENUM_DECLARE(AREA_PARAMS_ALL)
Area(const AreaParams *params = NULL);
+ Area(const Area &other, bool deep_copy=true);
virtual ~Area();
/** Set a working plane
diff --git a/src/Mod/Path/App/CMakeLists.txt b/src/Mod/Path/App/CMakeLists.txt
index 14531ff4d8..0816c7d077 100644
--- a/src/Mod/Path/App/CMakeLists.txt
+++ b/src/Mod/Path/App/CMakeLists.txt
@@ -32,6 +32,7 @@ generate_from_xml(ToolPy)
generate_from_xml(TooltablePy)
generate_from_xml(FeaturePathCompoundPy)
generate_from_xml(AreaPy)
+generate_from_xml(FeatureAreaPy)
SET(Python_SRCS
CommandPy.xml
@@ -45,6 +46,8 @@ SET(Python_SRCS
FeaturePathCompoundPyImp.cpp
AreaPy.xml
AreaPyImp.cpp
+ FeatureAreaPy.xml
+ FeatureAreaPyImp.cpp
)
SET(Mod_SRCS
diff --git a/src/Mod/Path/App/FeatureArea.cpp b/src/Mod/Path/App/FeatureArea.cpp
index b02d23441e..a8193f5ef4 100644
--- a/src/Mod/Path/App/FeatureArea.cpp
+++ b/src/Mod/Path/App/FeatureArea.cpp
@@ -29,6 +29,7 @@
#include
#include "FeatureArea.h"
+#include "FeatureAreaPy.h"
#include
#include
#include
@@ -81,18 +82,18 @@ App::DocumentObjectExecReturn *FeatureArea::execute(void)
params.PARAM_FNAME(_param) = PARAM_FNAME(_param).getValue();
PARAM_FOREACH(AREA_PROP_GET,AREA_PARAMS_CONF)
- Area area(¶ms);
+ myArea.clean(true);
+ myArea.setParams(params);
TopoDS_Shape workPlane = WorkPlane.getShape().getShape();
- if(!workPlane.IsNull())
- area.setPlane(workPlane);
+ myArea.setPlane(workPlane);
for (std::vector::iterator it = links.begin(); it != links.end(); ++it) {
- area.add(static_cast(*it)->Shape.getShape().getShape(),
+ myArea.add(static_cast(*it)->Shape.getShape().getShape(),
PARAM_PROP_ARGS(AREA_PARAMS_OPCODE));
}
- this->Shape.setValue(area.getShape(-1));
+ this->Shape.setValue(myArea.getShape(-1));
return Part::Feature::execute();
}
@@ -108,6 +109,16 @@ short FeatureArea::mustExecute(void) const
return Part::Feature::mustExecute();
}
+PyObject *FeatureArea::getPyObject()
+{
+ if (PythonObject.is(Py::_None())){
+ // ref counter is set to 1
+ PythonObject = Py::Object(new FeatureAreaPy(this),true);
+ }
+ return Py::new_reference_to(PythonObject);
+}
+
+
// Python Area feature ---------------------------------------------------------
namespace App {
diff --git a/src/Mod/Path/App/FeatureArea.h b/src/Mod/Path/App/FeatureArea.h
index d5e10c2def..5a084f3b18 100644
--- a/src/Mod/Path/App/FeatureArea.h
+++ b/src/Mod/Path/App/FeatureArea.h
@@ -40,6 +40,8 @@ class PathExport FeatureArea : public Part::Feature
PROPERTY_HEADER(Path::FeatureArea);
public:
+ Area myArea;
+
/// Constructor
FeatureArea(void);
virtual ~FeatureArea();
@@ -50,6 +52,7 @@ public:
}
virtual App::DocumentObjectExecReturn *execute(void);
virtual short mustExecute(void) const;
+ virtual PyObject *getPyObject(void);
App::PropertyLinkList Sources;
Part::PropertyPartShape WorkPlane;
diff --git a/src/Mod/Path/App/FeatureAreaPy.xml b/src/Mod/Path/App/FeatureAreaPy.xml
new file mode 100644
index 0000000000..e62d94ed16
--- /dev/null
+++ b/src/Mod/Path/App/FeatureAreaPy.xml
@@ -0,0 +1,30 @@
+
+
+
+
+
+ This class handles Path Area features
+
+
+
+ Return a copy of the encapsulated Python Area object.
+
+
+
+
+ setParams(key=value...): Convenient function to configure this feature.\n
+Same usage as Path.Area.setParams(). This function stores the parameters in the properties.
+
+
+
+
+
+
diff --git a/src/Mod/Path/App/FeatureAreaPyImp.cpp b/src/Mod/Path/App/FeatureAreaPyImp.cpp
new file mode 100644
index 0000000000..1e76840e2b
--- /dev/null
+++ b/src/Mod/Path/App/FeatureAreaPyImp.cpp
@@ -0,0 +1,93 @@
+/****************************************************************************
+ * Copyright (c) 2017 Zheng, Lei (realthunder) *
+ * *
+ * This file is part of the FreeCAD CAx development system. *
+ * *
+ * This library is free software; you can redistribute it and/or *
+ * modify it under the terms of the GNU Library General Public *
+ * License as published by the Free Software Foundation; either *
+ * version 2 of the License, or (at your option) any later version. *
+ * *
+ * This library is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU Library General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Library General Public *
+ * License along with this library; see the file COPYING.LIB. If not, *
+ * write to the Free Software Foundation, Inc., 59 Temple Place, *
+ * Suite 330, Boston, MA 02111-1307, USA *
+ * *
+ ****************************************************************************/
+
+#include "PreCompiled.h"
+
+#include
+#include "FeatureArea.h"
+
+// inclusion of the generated files (generated out of FeatureAreaPy.xml)
+#include "FeatureAreaPy.h"
+#include "FeatureAreaPy.cpp"
+
+#include "AreaPy.h"
+
+using namespace Path;
+
+
+// returns a string which represent the object e.g. when printed in python
+std::string FeatureAreaPy::representation(void) const
+{
+ return std::string("");
+}
+
+
+PyObject* FeatureAreaPy::getArea(PyObject *args)
+{
+ if (!PyArg_ParseTuple(args, ""))
+ return NULL;
+
+ return new AreaPy(new Area(getFeatureAreaPtr()->myArea));
+}
+
+PyObject* FeatureAreaPy::setParams(PyObject *args, PyObject *keywds)
+{
+ static char *kwlist[] = {PARAM_FIELD_STRINGS(NAME,AREA_PARAMS_CONF),NULL};
+
+ //Declare variables defined in the NAME field of the CONF parameter list
+ PARAM_PY_DECLARE(PARAM_FNAME,AREA_PARAMS_CONF);
+
+ FeatureArea *feature = getFeatureAreaPtr();
+
+#define AREA_SET(_param) \
+ PARAM_FNAME(_param) = \
+ PARAM_TYPED(PARAM_PY_CAST_,_param)(feature->PARAM_FNAME(_param).getValue());
+ //populate the CONF variables with values in properties
+ PARAM_FOREACH(AREA_SET,AREA_PARAMS_CONF)
+
+ //Parse arguments to overwrite CONF variables
+ if (!PyArg_ParseTupleAndKeywords(args, keywds,
+ "|" PARAM_PY_KWDS(AREA_PARAMS_CONF), kwlist,
+ PARAM_REF(PARAM_FNAME,AREA_PARAMS_CONF)))
+ Py_Error(Base::BaseExceptionFreeCADError,
+ "Wrong parameters, call getParamsDesc() to get supported params");
+
+#define AREA_GET(_param) \
+ feature->PARAM_FNAME(_param).setValue(\
+ PARAM_TYPED(PARAM_CAST_PY_,_param)(PARAM_FNAME(_param)));
+ //populate properties with the CONF variables
+ PARAM_FOREACH(AREA_GET,AREA_PARAMS_CONF)
+
+ return Py_None;
+}
+
+PyObject *FeatureAreaPy::getCustomAttributes(const char* /*attr*/) const
+{
+ return 0;
+}
+
+
+int FeatureAreaPy::setCustomAttributes(const char* /*attr*/, PyObject* /*obj*/)
+{
+ return 0;
+}
+