Sketcher: App - Clang-format
This commit is contained in:
committed by
abdullahtahiriyo
parent
c33cdcd68a
commit
987b4bda2a
@@ -27,11 +27,12 @@
|
||||
#include <Base/PlacementPy.h>
|
||||
#include <Base/Vector3D.h>
|
||||
#include <Base/VectorPy.h>
|
||||
#include <Mod/Part/App/GeometryPy.h>
|
||||
#include <Mod/Part/App/GeometryExtensionPy.h>
|
||||
#include <Mod/Part/App/GeometryPy.h>
|
||||
#include <Mod/Part/App/OCCError.h>
|
||||
|
||||
#include "ExternalGeometryFacadePy.h"
|
||||
|
||||
#include "ExternalGeometryFacadePy.cpp"
|
||||
|
||||
|
||||
@@ -47,7 +48,8 @@ std::string ExternalGeometryFacadePy::representation() const
|
||||
return str.str();
|
||||
}
|
||||
|
||||
PyObject *ExternalGeometryFacadePy::PyMake(struct _typeobject *, PyObject *, PyObject *) // Python wrapper
|
||||
PyObject* ExternalGeometryFacadePy::PyMake(struct _typeobject*, PyObject*,
|
||||
PyObject*)// Python wrapper
|
||||
{
|
||||
// create a new instance of PointPy and the Twin object
|
||||
return new ExternalGeometryFacadePy(new ExternalGeometryFacade());
|
||||
@@ -56,60 +58,61 @@ PyObject *ExternalGeometryFacadePy::PyMake(struct _typeobject *, PyObject *, PyO
|
||||
// constructor method
|
||||
int ExternalGeometryFacadePy::PyInit(PyObject* args, PyObject* /*kwd*/)
|
||||
{
|
||||
PyObject *object;
|
||||
if (PyArg_ParseTuple(args,"O!",&(Part::GeometryPy::Type), &object)) {
|
||||
Part::Geometry * geo = static_cast<Part::GeometryPy *>(object)->getGeometryPtr();
|
||||
PyObject* object;
|
||||
if (PyArg_ParseTuple(args, "O!", &(Part::GeometryPy::Type), &object)) {
|
||||
Part::Geometry* geo = static_cast<Part::GeometryPy*>(object)->getGeometryPtr();
|
||||
|
||||
getExternalGeometryFacadePtr()->setGeometry(geo->clone());
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
PyErr_SetString(PyExc_TypeError, "Sketcher::ExternalGeometryFacade constructor accepts:\n"
|
||||
"-- Part.Geometry\n"
|
||||
);
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"Sketcher::ExternalGeometryFacade constructor accepts:\n"
|
||||
"-- Part.Geometry\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
PyObject* ExternalGeometryFacadePy::testFlag(PyObject *args)
|
||||
PyObject* ExternalGeometryFacadePy::testFlag(PyObject* args)
|
||||
{
|
||||
char* flag;
|
||||
if (PyArg_ParseTuple(args, "s",&flag)) {
|
||||
if (PyArg_ParseTuple(args, "s", &flag)) {
|
||||
|
||||
auto pos = std::find_if(ExternalGeometryExtension::flag2str.begin(),
|
||||
ExternalGeometryExtension::flag2str.end(),
|
||||
[flag](const char * val) { return strcmp(val,flag) == 0;});
|
||||
ExternalGeometryExtension::flag2str.end(),
|
||||
[flag](const char* val) {
|
||||
return strcmp(val, flag) == 0;
|
||||
});
|
||||
|
||||
if( pos != ExternalGeometryExtension::flag2str.end()) {
|
||||
int index = std::distance( ExternalGeometryExtension::flag2str.begin(), pos );
|
||||
if (pos != ExternalGeometryExtension::flag2str.end()) {
|
||||
int index = std::distance(ExternalGeometryExtension::flag2str.begin(), pos);
|
||||
|
||||
return new_reference_to(Py::Boolean(this->getExternalGeometryFacadePtr()->testFlag(index)));
|
||||
return new_reference_to(
|
||||
Py::Boolean(this->getExternalGeometryFacadePtr()->testFlag(index)));
|
||||
}
|
||||
|
||||
PyErr_SetString(PyExc_TypeError, "Flag string does not exist.");
|
||||
return nullptr;
|
||||
|
||||
}
|
||||
|
||||
PyErr_SetString(PyExc_TypeError, "No flag string provided.");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
PyObject* ExternalGeometryFacadePy::setFlag(PyObject *args)
|
||||
PyObject* ExternalGeometryFacadePy::setFlag(PyObject* args)
|
||||
{
|
||||
char * flag;
|
||||
PyObject * bflag = Py_True;
|
||||
char* flag;
|
||||
PyObject* bflag = Py_True;
|
||||
if (PyArg_ParseTuple(args, "s|O!", &flag, &PyBool_Type, &bflag)) {
|
||||
|
||||
auto pos = std::find_if(ExternalGeometryExtension::flag2str.begin(),
|
||||
ExternalGeometryExtension::flag2str.end(),
|
||||
[flag](const char * val) {
|
||||
return strcmp(val,flag)==0;
|
||||
}
|
||||
);
|
||||
[flag](const char* val) {
|
||||
return strcmp(val, flag) == 0;
|
||||
});
|
||||
|
||||
if( pos != ExternalGeometryExtension::flag2str.end()) {
|
||||
int index = std::distance( ExternalGeometryExtension::flag2str.begin(), pos );
|
||||
if (pos != ExternalGeometryExtension::flag2str.end()) {
|
||||
int index = std::distance(ExternalGeometryExtension::flag2str.begin(), pos);
|
||||
|
||||
this->getExternalGeometryFacadePtr()->setFlag(index, Base::asBoolean(bflag));
|
||||
Py_Return;
|
||||
@@ -147,12 +150,12 @@ Py::String ExternalGeometryFacadePy::getInternalType() const
|
||||
{
|
||||
int internaltypeindex = (int)this->getExternalGeometryFacadePtr()->getInternalType();
|
||||
|
||||
if(internaltypeindex >= InternalType::NumInternalGeometryType)
|
||||
if (internaltypeindex >= InternalType::NumInternalGeometryType)
|
||||
throw Py::NotImplementedError("String name of enum not implemented");
|
||||
|
||||
std::string typestr = SketchGeometryExtension::internaltype2str[internaltypeindex];
|
||||
|
||||
return Py::String(typestr);
|
||||
return Py::String(typestr);
|
||||
}
|
||||
|
||||
void ExternalGeometryFacadePy::setInternalType(Py::String arg)
|
||||
@@ -160,7 +163,7 @@ void ExternalGeometryFacadePy::setInternalType(Py::String arg)
|
||||
std::string argstr = arg;
|
||||
InternalType::InternalType type;
|
||||
|
||||
if(SketchGeometryExtension::getInternalTypeFromName(argstr, type)) {
|
||||
if (SketchGeometryExtension::getInternalTypeFromName(argstr, type)) {
|
||||
this->getExternalGeometryFacadePtr()->setInternalType(type);
|
||||
return;
|
||||
}
|
||||
@@ -178,10 +181,10 @@ void ExternalGeometryFacadePy::setBlocked(Py::Boolean arg)
|
||||
getExternalGeometryFacadePtr()->setBlocked(arg);
|
||||
}
|
||||
|
||||
PyObject* ExternalGeometryFacadePy::mirror(PyObject *args)
|
||||
PyObject* ExternalGeometryFacadePy::mirror(PyObject* args)
|
||||
{
|
||||
PyObject* o;
|
||||
if (PyArg_ParseTuple(args, "O!", &(Base::VectorPy::Type),&o)) {
|
||||
if (PyArg_ParseTuple(args, "O!", &(Base::VectorPy::Type), &o)) {
|
||||
Base::Vector3d vec = static_cast<Base::VectorPy*>(o)->value();
|
||||
getExternalGeometryFacadePtr()->mirror(vec);
|
||||
Py_Return;
|
||||
@@ -189,22 +192,23 @@ PyObject* ExternalGeometryFacadePy::mirror(PyObject *args)
|
||||
|
||||
PyErr_Clear();
|
||||
PyObject* axis;
|
||||
if (PyArg_ParseTuple(args, "O!O!", &(Base::VectorPy::Type),&o,
|
||||
&(Base::VectorPy::Type),&axis)) {
|
||||
if (PyArg_ParseTuple(
|
||||
args, "O!O!", &(Base::VectorPy::Type), &o, &(Base::VectorPy::Type), &axis)) {
|
||||
Base::Vector3d pnt = static_cast<Base::VectorPy*>(o)->value();
|
||||
Base::Vector3d dir = static_cast<Base::VectorPy*>(axis)->value();
|
||||
getExternalGeometryFacadePtr()->mirror(pnt, dir);
|
||||
Py_Return;
|
||||
}
|
||||
|
||||
PyErr_SetString(Part::PartExceptionOCCError, "either a point (vector) or axis (vector, vector) must be given");
|
||||
PyErr_SetString(Part::PartExceptionOCCError,
|
||||
"either a point (vector) or axis (vector, vector) must be given");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
PyObject* ExternalGeometryFacadePy::rotate(PyObject *args)
|
||||
PyObject* ExternalGeometryFacadePy::rotate(PyObject* args)
|
||||
{
|
||||
PyObject* o;
|
||||
if (!PyArg_ParseTuple(args, "O!", &(Base::PlacementPy::Type),&o))
|
||||
if (!PyArg_ParseTuple(args, "O!", &(Base::PlacementPy::Type), &o))
|
||||
return nullptr;
|
||||
|
||||
Base::Placement* plm = static_cast<Base::PlacementPy*>(o)->getPlacementPtr();
|
||||
@@ -212,19 +216,19 @@ PyObject* ExternalGeometryFacadePy::rotate(PyObject *args)
|
||||
Py_Return;
|
||||
}
|
||||
|
||||
PyObject* ExternalGeometryFacadePy::scale(PyObject *args)
|
||||
PyObject* ExternalGeometryFacadePy::scale(PyObject* args)
|
||||
{
|
||||
PyObject* o;
|
||||
double scale;
|
||||
Base::Vector3d vec;
|
||||
if (PyArg_ParseTuple(args, "O!d", &(Base::VectorPy::Type),&o, &scale)) {
|
||||
if (PyArg_ParseTuple(args, "O!d", &(Base::VectorPy::Type), &o, &scale)) {
|
||||
vec = static_cast<Base::VectorPy*>(o)->value();
|
||||
getExternalGeometryFacadePtr()->scale(vec, scale);
|
||||
Py_Return;
|
||||
}
|
||||
|
||||
PyErr_Clear();
|
||||
if (PyArg_ParseTuple(args, "O!d", &PyTuple_Type,&o, &scale)) {
|
||||
if (PyArg_ParseTuple(args, "O!d", &PyTuple_Type, &o, &scale)) {
|
||||
vec = Base::getVectorFromTuple<double>(o);
|
||||
getExternalGeometryFacadePtr()->scale(vec, scale);
|
||||
Py_Return;
|
||||
@@ -234,28 +238,28 @@ PyObject* ExternalGeometryFacadePy::scale(PyObject *args)
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
PyObject* ExternalGeometryFacadePy::transform(PyObject *args)
|
||||
PyObject* ExternalGeometryFacadePy::transform(PyObject* args)
|
||||
{
|
||||
PyObject* o;
|
||||
if (!PyArg_ParseTuple(args, "O!", &(Base::MatrixPy::Type),&o))
|
||||
if (!PyArg_ParseTuple(args, "O!", &(Base::MatrixPy::Type), &o))
|
||||
return nullptr;
|
||||
Base::Matrix4D mat = static_cast<Base::MatrixPy*>(o)->value();
|
||||
getExternalGeometryFacadePtr()->transform(mat);
|
||||
Py_Return;
|
||||
}
|
||||
|
||||
PyObject* ExternalGeometryFacadePy::translate(PyObject *args)
|
||||
PyObject* ExternalGeometryFacadePy::translate(PyObject* args)
|
||||
{
|
||||
PyObject* o;
|
||||
Base::Vector3d vec;
|
||||
if (PyArg_ParseTuple(args, "O!", &(Base::VectorPy::Type),&o)) {
|
||||
if (PyArg_ParseTuple(args, "O!", &(Base::VectorPy::Type), &o)) {
|
||||
vec = static_cast<Base::VectorPy*>(o)->value();
|
||||
getExternalGeometryFacadePtr()->translate(vec);
|
||||
Py_Return;
|
||||
}
|
||||
|
||||
PyErr_Clear();
|
||||
if (PyArg_ParseTuple(args, "O!", &PyTuple_Type,&o)) {
|
||||
if (PyArg_ParseTuple(args, "O!", &PyTuple_Type, &o)) {
|
||||
vec = Base::getVectorFromTuple<double>(o);
|
||||
getExternalGeometryFacadePtr()->translate(vec);
|
||||
Py_Return;
|
||||
@@ -265,12 +269,12 @@ PyObject* ExternalGeometryFacadePy::translate(PyObject *args)
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
PyObject* ExternalGeometryFacadePy::setExtension(PyObject *args)
|
||||
PyObject* ExternalGeometryFacadePy::setExtension(PyObject* args)
|
||||
{
|
||||
PyObject* o;
|
||||
if (PyArg_ParseTuple(args, "O!", &(Part::GeometryExtensionPy::Type),&o)) {
|
||||
Part::GeometryExtension * ext;
|
||||
ext = static_cast<Part::GeometryExtensionPy *>(o)->getGeometryExtensionPtr();
|
||||
if (PyArg_ParseTuple(args, "O!", &(Part::GeometryExtensionPy::Type), &o)) {
|
||||
Part::GeometryExtension* ext;
|
||||
ext = static_cast<Part::GeometryExtensionPy*>(o)->getGeometryExtensionPtr();
|
||||
|
||||
// make copy of Python managed memory and wrap it in smart pointer
|
||||
auto cpy = ext->copy();
|
||||
@@ -283,154 +287,159 @@ PyObject* ExternalGeometryFacadePy::setExtension(PyObject *args)
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
PyObject* ExternalGeometryFacadePy::getExtensionOfType(PyObject *args)
|
||||
PyObject* ExternalGeometryFacadePy::getExtensionOfType(PyObject* args)
|
||||
{
|
||||
char* o;
|
||||
if (PyArg_ParseTuple(args, "s", &o)) {
|
||||
|
||||
Base::Type type = Base::Type::fromName(o);
|
||||
|
||||
if(type != Base::Type::badType()) {
|
||||
if (type != Base::Type::badType()) {
|
||||
try {
|
||||
std::shared_ptr<const Part::GeometryExtension> ext(this->getExternalGeometryFacadePtr()->getExtension(type));
|
||||
std::shared_ptr<const Part::GeometryExtension> ext(
|
||||
this->getExternalGeometryFacadePtr()->getExtension(type));
|
||||
|
||||
// we create a copy and transfer this copy's memory management responsibility to Python
|
||||
// we create a copy and transfer this copy's memory management responsibility to
|
||||
// Python
|
||||
PyObject* cpy = ext->copyPyObject();
|
||||
return cpy;
|
||||
}
|
||||
catch(const Base::ValueError& e) {
|
||||
catch (const Base::ValueError& e) {
|
||||
PyErr_SetString(Part::PartExceptionOCCError, e.what());
|
||||
return nullptr;
|
||||
}
|
||||
catch(const std::bad_weak_ptr&) {
|
||||
PyErr_SetString(Part::PartExceptionOCCError, "Geometry extension does not exist anymore.");
|
||||
catch (const std::bad_weak_ptr&) {
|
||||
PyErr_SetString(Part::PartExceptionOCCError,
|
||||
"Geometry extension does not exist anymore.");
|
||||
return nullptr;
|
||||
}
|
||||
catch(Base::NotImplementedError&) {
|
||||
PyErr_SetString(Part::PartExceptionOCCError, "Geometry extension does not implement a Python counterpart.");
|
||||
catch (Base::NotImplementedError&) {
|
||||
PyErr_SetString(Part::PartExceptionOCCError,
|
||||
"Geometry extension does not implement a Python counterpart.");
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
PyErr_SetString(Part::PartExceptionOCCError, "Exception type does not exist");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
PyErr_SetString(Part::PartExceptionOCCError, "A string with the name of the geometry extension type was expected");
|
||||
PyErr_SetString(Part::PartExceptionOCCError,
|
||||
"A string with the name of the geometry extension type was expected");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
PyObject* ExternalGeometryFacadePy::getExtensionOfName(PyObject *args)
|
||||
PyObject* ExternalGeometryFacadePy::getExtensionOfName(PyObject* args)
|
||||
{
|
||||
char* o;
|
||||
if (PyArg_ParseTuple(args, "s", &o)) {
|
||||
|
||||
try {
|
||||
std::shared_ptr<const Part::GeometryExtension> ext(this->getExternalGeometryFacadePtr()->getExtension(std::string(o)));
|
||||
std::shared_ptr<const Part::GeometryExtension> ext(
|
||||
this->getExternalGeometryFacadePtr()->getExtension(std::string(o)));
|
||||
|
||||
// we create a copy and transfer this copy's memory management responsibility to Python
|
||||
PyObject* cpy = ext->copyPyObject();
|
||||
return cpy;
|
||||
}
|
||||
catch(const Base::ValueError& e) {
|
||||
catch (const Base::ValueError& e) {
|
||||
PyErr_SetString(Part::PartExceptionOCCError, e.what());
|
||||
return nullptr;
|
||||
}
|
||||
catch(const std::bad_weak_ptr&) {
|
||||
PyErr_SetString(Part::PartExceptionOCCError, "Geometry extension does not exist anymore.");
|
||||
catch (const std::bad_weak_ptr&) {
|
||||
PyErr_SetString(Part::PartExceptionOCCError,
|
||||
"Geometry extension does not exist anymore.");
|
||||
return nullptr;
|
||||
}
|
||||
catch(Base::NotImplementedError&) {
|
||||
PyErr_SetString(Part::PartExceptionOCCError, "Geometry extension does not implement a Python counterpart.");
|
||||
catch (Base::NotImplementedError&) {
|
||||
PyErr_SetString(Part::PartExceptionOCCError,
|
||||
"Geometry extension does not implement a Python counterpart.");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
PyErr_SetString(Part::PartExceptionOCCError, "A string with the name of the geometry extension was expected");
|
||||
PyErr_SetString(Part::PartExceptionOCCError,
|
||||
"A string with the name of the geometry extension was expected");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
PyObject* ExternalGeometryFacadePy::hasExtensionOfType(PyObject *args)
|
||||
PyObject* ExternalGeometryFacadePy::hasExtensionOfType(PyObject* args)
|
||||
{
|
||||
char* o;
|
||||
if (PyArg_ParseTuple(args, "s", &o)) {
|
||||
|
||||
Base::Type type = Base::Type::fromName(o);
|
||||
|
||||
if(type != Base::Type::badType()) {
|
||||
if (type != Base::Type::badType()) {
|
||||
try {
|
||||
return Py::new_reference_to(Py::Boolean(this->getExternalGeometryFacadePtr()->hasExtension(type)));
|
||||
return Py::new_reference_to(
|
||||
Py::Boolean(this->getExternalGeometryFacadePtr()->hasExtension(type)));
|
||||
}
|
||||
catch(const Base::ValueError& e) {
|
||||
catch (const Base::ValueError& e) {
|
||||
PyErr_SetString(Part::PartExceptionOCCError, e.what());
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
PyErr_SetString(Part::PartExceptionOCCError, "Exception type does not exist");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
PyErr_SetString(Part::PartExceptionOCCError, "A string with the type of the geometry extension was expected");
|
||||
PyErr_SetString(Part::PartExceptionOCCError,
|
||||
"A string with the type of the geometry extension was expected");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
PyObject* ExternalGeometryFacadePy::hasExtensionOfName(PyObject *args)
|
||||
PyObject* ExternalGeometryFacadePy::hasExtensionOfName(PyObject* args)
|
||||
{
|
||||
char* o;
|
||||
if (PyArg_ParseTuple(args, "s", &o)) {
|
||||
|
||||
try {
|
||||
return Py::new_reference_to(Py::Boolean(this->getExternalGeometryFacadePtr()->hasExtension(std::string(o))));
|
||||
return Py::new_reference_to(
|
||||
Py::Boolean(this->getExternalGeometryFacadePtr()->hasExtension(std::string(o))));
|
||||
}
|
||||
catch(const Base::ValueError& e) {
|
||||
catch (const Base::ValueError& e) {
|
||||
PyErr_SetString(Part::PartExceptionOCCError, e.what());
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
PyErr_SetString(Part::PartExceptionOCCError, "A string with the type of the geometry extension was expected");
|
||||
PyErr_SetString(Part::PartExceptionOCCError,
|
||||
"A string with the type of the geometry extension was expected");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
PyObject* ExternalGeometryFacadePy::deleteExtensionOfType(PyObject *args)
|
||||
PyObject* ExternalGeometryFacadePy::deleteExtensionOfType(PyObject* args)
|
||||
{
|
||||
char* o;
|
||||
if (PyArg_ParseTuple(args, "s", &o)) {
|
||||
|
||||
Base::Type type = Base::Type::fromName(o);
|
||||
|
||||
if(type != Base::Type::badType()) {
|
||||
if (type != Base::Type::badType()) {
|
||||
try {
|
||||
this->getExternalGeometryFacadePtr()->deleteExtension(type);
|
||||
Py_Return;
|
||||
}
|
||||
catch(const Base::ValueError& e) {
|
||||
catch (const Base::ValueError& e) {
|
||||
PyErr_SetString(Part::PartExceptionOCCError, e.what());
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
PyErr_SetString(Part::PartExceptionOCCError, "Type does not exist");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
PyErr_SetString(Part::PartExceptionOCCError, "A string with a type object was expected");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
PyObject* ExternalGeometryFacadePy::deleteExtensionOfName(PyObject *args)
|
||||
PyObject* ExternalGeometryFacadePy::deleteExtensionOfName(PyObject* args)
|
||||
{
|
||||
char* o;
|
||||
if (PyArg_ParseTuple(args, "s", &o)) {
|
||||
@@ -439,38 +448,40 @@ PyObject* ExternalGeometryFacadePy::deleteExtensionOfName(PyObject *args)
|
||||
this->getExternalGeometryFacadePtr()->deleteExtension(std::string(o));
|
||||
Py_Return;
|
||||
}
|
||||
catch(const Base::ValueError& e) {
|
||||
catch (const Base::ValueError& e) {
|
||||
PyErr_SetString(Part::PartExceptionOCCError, e.what());
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
PyErr_SetString(Part::PartExceptionOCCError, "A string with the name of the extension was expected");
|
||||
PyErr_SetString(Part::PartExceptionOCCError,
|
||||
"A string with the name of the extension was expected");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
PyObject* ExternalGeometryFacadePy::getExtensions(PyObject *args)
|
||||
PyObject* ExternalGeometryFacadePy::getExtensions(PyObject* args)
|
||||
{
|
||||
if (!PyArg_ParseTuple(args, "")){
|
||||
if (!PyArg_ParseTuple(args, "")) {
|
||||
PyErr_SetString(Part::PartExceptionOCCError, "No arguments were expected");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
try {
|
||||
const std::vector<std::weak_ptr<const Part::GeometryExtension>> ext = this->getExternalGeometryFacadePtr()->getExtensions();
|
||||
const std::vector<std::weak_ptr<const Part::GeometryExtension>> ext =
|
||||
this->getExternalGeometryFacadePtr()->getExtensions();
|
||||
|
||||
Py::List list;
|
||||
|
||||
for (std::size_t i=0; i<ext.size(); ++i) {
|
||||
for (std::size_t i = 0; i < ext.size(); ++i) {
|
||||
|
||||
std::shared_ptr<const Part::GeometryExtension> p = ext[i].lock();
|
||||
|
||||
if(p) {
|
||||
if (p) {
|
||||
// we create a python copy and add it to the list
|
||||
try {
|
||||
list.append(Py::asObject(p->copyPyObject()));
|
||||
}
|
||||
catch(Base::NotImplementedError&) {
|
||||
catch (Base::NotImplementedError&) {
|
||||
// silently ignoring extensions not having a Python object
|
||||
}
|
||||
}
|
||||
@@ -478,11 +489,10 @@ PyObject* ExternalGeometryFacadePy::getExtensions(PyObject *args)
|
||||
|
||||
return Py::new_reference_to(list);
|
||||
}
|
||||
catch(const Base::ValueError& e) {
|
||||
catch (const Base::ValueError& e) {
|
||||
PyErr_SetString(Part::PartExceptionOCCError, e.what());
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Py::Boolean ExternalGeometryFacadePy::getConstruction() const
|
||||
@@ -490,7 +500,7 @@ Py::Boolean ExternalGeometryFacadePy::getConstruction() const
|
||||
return Py::Boolean(getExternalGeometryFacadePtr()->getConstruction());
|
||||
}
|
||||
|
||||
void ExternalGeometryFacadePy::setConstruction(Py::Boolean arg)
|
||||
void ExternalGeometryFacadePy::setConstruction(Py::Boolean arg)
|
||||
{
|
||||
if (getExternalGeometryFacadePtr()->getTypeId() != Part::GeomPoint::getClassTypeId())
|
||||
getExternalGeometryFacadePtr()->setConstruction(arg);
|
||||
@@ -519,17 +529,17 @@ Py::Object ExternalGeometryFacadePy::getGeometry() const
|
||||
return Py::Object(geo->getPyObject(), true);
|
||||
}
|
||||
|
||||
void ExternalGeometryFacadePy::setGeometry(Py::Object arg)
|
||||
void ExternalGeometryFacadePy::setGeometry(Py::Object arg)
|
||||
{
|
||||
if (PyObject_TypeCheck(arg.ptr(), &(Part::GeometryPy::Type))) {
|
||||
Part::GeometryPy * gp = static_cast<Part::GeometryPy *>(arg.ptr());
|
||||
Part::GeometryPy* gp = static_cast<Part::GeometryPy*>(arg.ptr());
|
||||
|
||||
getExternalGeometryFacadePtr()->setGeometry(gp->getGeometryPtr()->clone());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
PyObject *ExternalGeometryFacadePy::getCustomAttributes(const char* /*attr*/) const
|
||||
PyObject* ExternalGeometryFacadePy::getCustomAttributes(const char* /*attr*/) const
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user