23
#include "PreCompiled.h"
28
#include <Base/VectorPy.h>
33
#include "MeshPointPy.h"
34
#include "MeshPointPy.cpp"
41
std::string MeshPointPy::representation() const
43
MeshPointPy::PointerType ptr = getMeshPointPtr();
44
Base::Vector3d vec = *ptr;
46
std::stringstream str;
49
if (getMeshPointPtr()->Mesh->countPoints() <= getMeshPointPtr()->Index) {
50
str << vec.x << ", " << vec.y << ", " << vec.z << ", Idx=" << ptr->Index
54
vec = getMeshPointPtr()->Mesh->getPoint(getMeshPointPtr()->Index);
55
str << vec.x << ", " << vec.y << ", " << vec.z << ", Idx=" << ptr->Index;
59
str << vec.x << ", " << vec.y << ", " << vec.z;
66
PyObject* MeshPointPy::PyMake(struct _typeobject*, PyObject*, PyObject*)
69
return new MeshPointPy(new MeshPoint);
73
int MeshPointPy::PyInit(PyObject* args, PyObject* )
75
double x = 0.0, y = 0.0, z = 0.0;
76
if (!PyArg_ParseTuple(args, "|ddd", &x, &y, &z)) {
80
getMeshPointPtr()->Set(x, y, z);
84
PyObject* MeshPointPy::unbound(PyObject* args)
86
if (!PyArg_ParseTuple(args, "")) {
89
getMeshPointPtr()->Index = UINT_MAX;
90
getMeshPointPtr()->Mesh = nullptr;
94
Py::Long MeshPointPy::getIndex() const
96
return Py::Long((long)getMeshPointPtr()->Index);
99
Py::Boolean MeshPointPy::getBound() const
101
return {getMeshPointPtr()->Index != UINT_MAX};
104
Py::Object MeshPointPy::getNormal() const
106
if (!getMeshPointPtr()->isBound()) {
107
throw Py::RuntimeError(
108
"This object is not bound to a mesh, so no topological operation is possible!");
110
if (getMeshPointPtr()->Mesh->countPoints() <= getMeshPointPtr()->Index) {
111
throw Py::IndexError("Index out of range");
115
new Base::Vector3d(getMeshPointPtr()->Mesh->getPointNormal(getMeshPointPtr()->Index));
116
Base::VectorPy* normal = new Base::VectorPy(v);
118
return Py::Object(normal, true);
121
Py::Object MeshPointPy::getVector() const
123
MeshPointPy::PointerType ptr = static_cast<MeshPointPy::PointerType>(_pcTwinPointer);
125
Base::VectorPy* vec = new Base::VectorPy(*ptr);
127
return Py::Object(vec, true);
130
Py::Float MeshPointPy::getx() const
132
MeshPointPy::PointerType ptr = static_cast<MeshPointPy::PointerType>(_pcTwinPointer);
135
if (getMeshPointPtr()->isBound()) {
136
if (getMeshPointPtr()->Mesh->countPoints() > getMeshPointPtr()->Index) {
137
x = getMeshPointPtr()->Mesh->getPoint(getMeshPointPtr()->Index).x;
144
Py::Float MeshPointPy::gety() const
146
MeshPointPy::PointerType ptr = static_cast<MeshPointPy::PointerType>(_pcTwinPointer);
149
if (getMeshPointPtr()->isBound()) {
150
if (getMeshPointPtr()->Mesh->countPoints() > getMeshPointPtr()->Index) {
151
y = getMeshPointPtr()->Mesh->getPoint(getMeshPointPtr()->Index).y;
158
Py::Float MeshPointPy::getz() const
160
MeshPointPy::PointerType ptr = static_cast<MeshPointPy::PointerType>(_pcTwinPointer);
163
if (getMeshPointPtr()->isBound()) {
164
if (getMeshPointPtr()->Mesh->countPoints() > getMeshPointPtr()->Index) {
165
z = getMeshPointPtr()->Mesh->getPoint(getMeshPointPtr()->Index).z;
172
PyObject* MeshPointPy::getCustomAttributes(const char* ) const
177
int MeshPointPy::setCustomAttributes(const char* , PyObject* )