Points: apply clang-formatting
This commit is contained in:
@@ -22,7 +22,7 @@
|
||||
|
||||
#include "PreCompiled.h"
|
||||
#ifndef _PreComp_
|
||||
# include <boost/math/special_functions/fpclassify.hpp>
|
||||
#include <boost/math/special_functions/fpclassify.hpp>
|
||||
#endif
|
||||
|
||||
#include <Base/Builder3D.h>
|
||||
@@ -32,8 +32,10 @@
|
||||
|
||||
#include "Points.h"
|
||||
// inclusion of the generated files (generated out of PointsPy.xml)
|
||||
// clang-format off
|
||||
#include "PointsPy.h"
|
||||
#include "PointsPy.cpp"
|
||||
// clang-format on
|
||||
|
||||
|
||||
using namespace Points;
|
||||
@@ -44,7 +46,7 @@ std::string PointsPy::representation() const
|
||||
return {"<PointKernel object>"};
|
||||
}
|
||||
|
||||
PyObject *PointsPy::PyMake(struct _typeobject *, PyObject *, PyObject *) // Python wrapper
|
||||
PyObject* PointsPy::PyMake(struct _typeobject*, PyObject*, PyObject*)
|
||||
{
|
||||
// create a new instance of PointsPy and the Twin object
|
||||
return new PointsPy(new PointKernel);
|
||||
@@ -53,23 +55,27 @@ PyObject *PointsPy::PyMake(struct _typeobject *, PyObject *, PyObject *) // Pyt
|
||||
// constructor method
|
||||
int PointsPy::PyInit(PyObject* args, PyObject* /*kwd*/)
|
||||
{
|
||||
PyObject *pcObj=nullptr;
|
||||
if (!PyArg_ParseTuple(args, "|O", &pcObj))
|
||||
PyObject* pcObj = nullptr;
|
||||
if (!PyArg_ParseTuple(args, "|O", &pcObj)) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
// if no mesh is given
|
||||
if (!pcObj)
|
||||
if (!pcObj) {
|
||||
return 0;
|
||||
}
|
||||
if (PyObject_TypeCheck(pcObj, &(PointsPy::Type))) {
|
||||
*getPointKernelPtr() = *(static_cast<PointsPy*>(pcObj)->getPointKernelPtr());
|
||||
}
|
||||
else if (PyList_Check(pcObj)) {
|
||||
if (!addPoints(args))
|
||||
if (!addPoints(args)) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
else if (PyTuple_Check(pcObj)) {
|
||||
if (!addPoints(args))
|
||||
if (!addPoints(args)) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
else if (PyUnicode_Check(pcObj)) {
|
||||
getPointKernelPtr()->load(PyUnicode_AsUTF8(pcObj));
|
||||
@@ -82,10 +88,11 @@ int PointsPy::PyInit(PyObject* args, PyObject* /*kwd*/)
|
||||
return 0;
|
||||
}
|
||||
|
||||
PyObject* PointsPy::copy(PyObject *args)
|
||||
PyObject* PointsPy::copy(PyObject* args)
|
||||
{
|
||||
if (!PyArg_ParseTuple(args, ""))
|
||||
if (!PyArg_ParseTuple(args, "")) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
PointKernel* kernel = new PointKernel();
|
||||
// assign data
|
||||
@@ -93,36 +100,43 @@ PyObject* PointsPy::copy(PyObject *args)
|
||||
return new PointsPy(kernel);
|
||||
}
|
||||
|
||||
PyObject* PointsPy::read(PyObject * args)
|
||||
PyObject* PointsPy::read(PyObject* args)
|
||||
{
|
||||
const char* Name;
|
||||
if (!PyArg_ParseTuple(args, "s",&Name))
|
||||
if (!PyArg_ParseTuple(args, "s", &Name)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
PY_TRY {
|
||||
PY_TRY
|
||||
{
|
||||
getPointKernelPtr()->load(Name);
|
||||
} PY_CATCH;
|
||||
}
|
||||
PY_CATCH;
|
||||
|
||||
Py_Return;
|
||||
}
|
||||
|
||||
PyObject* PointsPy::write(PyObject * args)
|
||||
PyObject* PointsPy::write(PyObject* args)
|
||||
{
|
||||
const char* Name;
|
||||
if (!PyArg_ParseTuple(args, "s",&Name))
|
||||
if (!PyArg_ParseTuple(args, "s", &Name)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
PY_TRY {
|
||||
PY_TRY
|
||||
{
|
||||
getPointKernelPtr()->save(Name);
|
||||
} PY_CATCH;
|
||||
}
|
||||
PY_CATCH;
|
||||
|
||||
Py_Return;
|
||||
}
|
||||
|
||||
PyObject* PointsPy::writeInventor(PyObject * args)
|
||||
PyObject* PointsPy::writeInventor(PyObject* args)
|
||||
{
|
||||
if (!PyArg_ParseTuple(args, ""))
|
||||
if (!PyArg_ParseTuple(args, "")) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
std::stringstream result;
|
||||
Base::InventorBuilder builder(result);
|
||||
@@ -130,21 +144,22 @@ PyObject* PointsPy::writeInventor(PyObject * args)
|
||||
std::vector<Base::Vector3f> points;
|
||||
PointKernel* kernel = getPointKernelPtr();
|
||||
points.reserve(kernel->size());
|
||||
for (const auto & it : *kernel) {
|
||||
for (const auto& it : *kernel) {
|
||||
points.push_back(Base::convertTo<Base::Vector3f>(it));
|
||||
}
|
||||
builder.addNode(Base::Coordinate3Item{points});
|
||||
builder.addNode(Base::PointSetItem{});
|
||||
builder.addNode(Base::Coordinate3Item {points});
|
||||
builder.addNode(Base::PointSetItem {});
|
||||
builder.endSeparator();
|
||||
|
||||
return Py::new_reference_to(Py::String(result.str()));
|
||||
}
|
||||
|
||||
PyObject* PointsPy::addPoints(PyObject * args)
|
||||
PyObject* PointsPy::addPoints(PyObject* args)
|
||||
{
|
||||
PyObject *obj;
|
||||
if (!PyArg_ParseTuple(args, "O", &obj))
|
||||
PyObject* obj;
|
||||
if (!PyArg_ParseTuple(args, "O", &obj)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
try {
|
||||
Py::Sequence list(obj);
|
||||
@@ -166,20 +181,22 @@ PyObject* PointsPy::addPoints(PyObject * args)
|
||||
}
|
||||
}
|
||||
catch (const Py::Exception&) {
|
||||
PyErr_SetString(PyExc_TypeError, "either expect\n"
|
||||
"-- [Vector,...] \n"
|
||||
"-- [(x,y,z),...]");
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"either expect\n"
|
||||
"-- [Vector,...] \n"
|
||||
"-- [(x,y,z),...]");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Py_Return;
|
||||
}
|
||||
|
||||
PyObject* PointsPy::fromSegment(PyObject * args)
|
||||
PyObject* PointsPy::fromSegment(PyObject* args)
|
||||
{
|
||||
PyObject *obj;
|
||||
if (!PyArg_ParseTuple(args, "O", &obj))
|
||||
PyObject* obj;
|
||||
if (!PyArg_ParseTuple(args, "O", &obj)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
try {
|
||||
const PointKernel* points = getPointKernelPtr();
|
||||
@@ -189,8 +206,9 @@ PyObject* PointsPy::fromSegment(PyObject * args)
|
||||
int numPoints = static_cast<int>(points->size());
|
||||
for (Py::Sequence::iterator it = list.begin(); it != list.end(); ++it) {
|
||||
long index = static_cast<long>(Py::Long(*it));
|
||||
if (index >= 0 && index < numPoints)
|
||||
if (index >= 0 && index < numPoints) {
|
||||
pts->push_back(points->getPoint(index));
|
||||
}
|
||||
}
|
||||
|
||||
return new PointsPy(pts.release());
|
||||
@@ -201,18 +219,21 @@ PyObject* PointsPy::fromSegment(PyObject * args)
|
||||
}
|
||||
}
|
||||
|
||||
PyObject* PointsPy::fromValid(PyObject * args)
|
||||
PyObject* PointsPy::fromValid(PyObject* args)
|
||||
{
|
||||
if (!PyArg_ParseTuple(args, ""))
|
||||
if (!PyArg_ParseTuple(args, "")) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
try {
|
||||
const PointKernel* points = getPointKernelPtr();
|
||||
std::unique_ptr<PointKernel> pts(new PointKernel());
|
||||
pts->reserve(points->size());
|
||||
for (const auto & point : *points) {
|
||||
if (!boost::math::isnan(point.x) && !boost::math::isnan(point.y) && !boost::math::isnan(point.z))
|
||||
for (const auto& point : *points) {
|
||||
if (!boost::math::isnan(point.x) && !boost::math::isnan(point.y)
|
||||
&& !boost::math::isnan(point.z)) {
|
||||
pts->push_back(point);
|
||||
}
|
||||
}
|
||||
|
||||
return new PointsPy(pts.release());
|
||||
@@ -232,13 +253,13 @@ Py::List PointsPy::getPoints() const
|
||||
{
|
||||
Py::List PointList;
|
||||
const PointKernel* points = getPointKernelPtr();
|
||||
for (const auto & point : *points) {
|
||||
for (const auto& point : *points) {
|
||||
PointList.append(Py::asObject(new Base::VectorPy(point)));
|
||||
}
|
||||
return PointList;
|
||||
}
|
||||
|
||||
PyObject *PointsPy::getCustomAttributes(const char* /*attr*/) const
|
||||
PyObject* PointsPy::getCustomAttributes(const char* /*attr*/) const
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
@@ -247,5 +268,3 @@ int PointsPy::setCustomAttributes(const char* /*attr*/, PyObject* /*obj*/)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user