Part: Geometry Python interface to get/set an extension
This commit is contained in:
@@ -51,6 +51,7 @@ generate_from_xml(ArcOfHyperbolaPy)
|
||||
generate_from_xml(ParabolaPy)
|
||||
generate_from_xml(OffsetCurvePy)
|
||||
generate_from_xml(GeometryPy)
|
||||
generate_from_xml(GeometryExtensionPy)
|
||||
generate_from_xml(GeometryCurvePy)
|
||||
generate_from_xml(BoundedCurvePy)
|
||||
generate_from_xml(TrimmedCurvePy)
|
||||
@@ -211,6 +212,8 @@ SET(Python_SRCS
|
||||
OffsetCurvePyImp.cpp
|
||||
GeometryPy.xml
|
||||
GeometryPyImp.cpp
|
||||
GeometryExtensionPy.xml
|
||||
GeometryExtensionPyImp.cpp
|
||||
GeometryCurvePy.xml
|
||||
GeometryCurvePyImp.cpp
|
||||
BoundedCurvePy.xml
|
||||
|
||||
@@ -53,6 +53,16 @@ It describes the common behavior of these objects when:
|
||||
<UserDocu>Create a clone of this geometry with the same Tag</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Methode Name="getExtension" Const="true">
|
||||
<Documentation>
|
||||
<UserDocu>Gets a geometry extension of the indicated type.</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Methode Name="setExtension" Const="false">
|
||||
<Documentation>
|
||||
<UserDocu>Sets a geometry extension of the indicated type.</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Attribute Name="Construction" ReadOnly="false">
|
||||
<Documentation>
|
||||
<UserDocu>Defines this geometry as a construction one which
|
||||
|
||||
@@ -51,6 +51,7 @@
|
||||
#include "GeometryPy.h"
|
||||
#include "GeometryPy.cpp"
|
||||
|
||||
#include "GeometryExtensionPy.h"
|
||||
#include "TopoShape.h"
|
||||
#include "TopoShapePy.h"
|
||||
|
||||
@@ -239,6 +240,57 @@ PyObject* GeometryPy::clone(PyObject *args)
|
||||
return cpy;
|
||||
}
|
||||
|
||||
PyObject* GeometryPy::setExtension(PyObject *args)
|
||||
{
|
||||
PyObject* o;
|
||||
if (PyArg_ParseTuple(args, "O!", &(GeometryExtensionPy::Type),&o)) {
|
||||
Part::GeometryExtension * ext;
|
||||
ext = static_cast<GeometryExtensionPy *>(o)->getGeometryExtensionPtr();
|
||||
|
||||
std::unique_ptr<GeometryExtension> cpy = ext->copy(); // allocate new extension in memory
|
||||
|
||||
this->getGeometryPtr()->setExtension(std::move(cpy));
|
||||
Py_Return;
|
||||
}
|
||||
|
||||
PyErr_SetString(PartExceptionOCCError, "A geometry extension object was expected");
|
||||
return 0;
|
||||
}
|
||||
|
||||
PyObject* GeometryPy::getExtension(PyObject *args)
|
||||
{
|
||||
char* o;
|
||||
if (PyArg_ParseTuple(args, "s", &o)) {
|
||||
|
||||
Base::Type type = Base::Type::fromName(o);
|
||||
|
||||
if(type != Base::Type::badType()) {
|
||||
try {
|
||||
const std::weak_ptr<GeometryExtension> ext = this->getGeometryPtr()->getExtension(type);
|
||||
|
||||
std::unique_ptr<GeometryExtension> cext = ext.lock()->copy();
|
||||
|
||||
GeometryExtension * pcext = cext.release();
|
||||
|
||||
return pcext->getPyObject();
|
||||
}
|
||||
catch(Base::ValueError e) {
|
||||
PyErr_SetString(PartExceptionOCCError, e.what());
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
PyErr_SetString(PartExceptionOCCError, "Exception type does not exist");
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
PyErr_SetString(PartExceptionOCCError, "A string with the name of the geometry extension type was expected");
|
||||
return 0;
|
||||
}
|
||||
|
||||
Py::Boolean GeometryPy::getConstruction(void) const
|
||||
{
|
||||
return Py::Boolean(getGeometryPtr()->Construction);
|
||||
|
||||
Reference in New Issue
Block a user