Base: remove explicit namespace-name qualifier from *PyImp.cpp

Explicit Base namespace-name is used randomly across PyImp sources.
Remove it.
This commit is contained in:
Ladislav Michl
2025-04-26 20:40:36 +02:00
committed by Benjamin Nauck
parent 24d55dc616
commit 47c1565edf
12 changed files with 302 additions and 317 deletions

View File

@@ -92,19 +92,14 @@ int BoundBoxPy::PyInit(PyObject* args, PyObject* /*kwd*/)
}
}
PyErr_Clear(); // set by PyArg_ParseTuple()
if (PyArg_ParseTuple(args,
"O!O!",
&(Base::VectorPy::Type),
&object1,
&(Base::VectorPy::Type),
&object2)) {
ptr->Add(*(static_cast<Base::VectorPy*>(object1)->getVectorPtr()));
ptr->Add(*(static_cast<Base::VectorPy*>(object2)->getVectorPtr()));
if (PyArg_ParseTuple(args, "O!O!", &(VectorPy::Type), &object1, &(VectorPy::Type), &object2)) {
ptr->Add(*(static_cast<VectorPy*>(object1)->getVectorPtr()));
ptr->Add(*(static_cast<VectorPy*>(object2)->getVectorPtr()));
return 0;
}
PyErr_Clear(); // set by PyArg_ParseTuple()
if (PyArg_ParseTuple(args, "O!", &(Base::BoundBoxPy::Type), &object1)) {
*ptr = *(static_cast<Base::BoundBoxPy*>(object1)->getBoundBoxPtr());
if (PyArg_ParseTuple(args, "O!", &(BoundBoxPy::Type), &object1)) {
*ptr = *(static_cast<BoundBoxPy*>(object1)->getBoundBoxPtr());
return 0;
}
@@ -151,17 +146,17 @@ PyObject* BoundBoxPy::add(PyObject* args)
}
PyErr_Clear();
if (PyArg_ParseTuple(args, "O!", &(Base::VectorPy::Type), &object)) {
getBoundBoxPtr()->Add(*(static_cast<Base::VectorPy*>(object)->getVectorPtr()));
if (PyArg_ParseTuple(args, "O!", &(VectorPy::Type), &object)) {
getBoundBoxPtr()->Add(*(static_cast<VectorPy*>(object)->getVectorPtr()));
Py_Return;
}
PyErr_Clear();
if (PyArg_ParseTuple(args,
"O!;Need a Vector, BoundBox or three floats as argument",
&(Base::BoundBoxPy::Type),
&(BoundBoxPy::Type),
&object)) {
getBoundBoxPtr()->Add(*(static_cast<Base::BoundBoxPy*>(object)->getBoundBoxPtr()));
getBoundBoxPtr()->Add(*(static_cast<BoundBoxPy*>(object)->getBoundBoxPtr()));
Py_Return;
}
@@ -182,8 +177,7 @@ PyObject* BoundBoxPy::getPoint(PyObject* args) const
return nullptr;
}
Base::Vector3d pnt = getBoundBoxPtr()->CalcPoint(index);
return new Base::VectorPy(new Base::Vector3d(pnt));
return new VectorPy(new Vector3d(getBoundBoxPtr()->CalcPoint(index)));
}
PyObject* BoundBoxPy::getEdge(PyObject* args) const
@@ -198,8 +192,8 @@ PyObject* BoundBoxPy::getEdge(PyObject* args) const
return nullptr;
}
Base::Vector3d pnt1;
Base::Vector3d pnt2;
Vector3d pnt1;
Vector3d pnt2;
getBoundBoxPtr()->CalcEdge(index, pnt1, pnt2);
Py::Tuple tuple(2);
tuple.setItem(0, Py::Vector(pnt1));
@@ -214,7 +208,7 @@ PyObject* BoundBoxPy::closestPoint(PyObject* args) const
double z {};
PyObject* object {};
Base::Vector3d vec;
Vector3d vec;
do {
if (PyArg_ParseTuple(args, "ddd", &x, &y, &z)) {
@@ -229,8 +223,8 @@ PyObject* BoundBoxPy::closestPoint(PyObject* args) const
}
PyErr_Clear();
if (PyArg_ParseTuple(args, "O!", &(Base::VectorPy::Type), &object)) {
vec = *(static_cast<Base::VectorPy*>(object)->getVectorPtr());
if (PyArg_ParseTuple(args, "O!", &(VectorPy::Type), &object)) {
vec = *(static_cast<VectorPy*>(object)->getVectorPtr());
break;
}
@@ -238,8 +232,8 @@ PyObject* BoundBoxPy::closestPoint(PyObject* args) const
return nullptr;
} while (false);
Base::Vector3d point = getBoundBoxPtr()->ClosestPoint(vec);
return new Base::VectorPy(new Base::Vector3d(point));
Vector3d point = getBoundBoxPtr()->ClosestPoint(vec);
return new VectorPy(new Vector3d(point));
}
PyObject* BoundBoxPy::intersect(PyObject* args)
@@ -256,24 +250,24 @@ PyObject* BoundBoxPy::intersect(PyObject* args)
do {
if (PyArg_ParseTuple(args,
"O!O!",
&(Base::VectorPy::Type),
&(VectorPy::Type),
&object1,
&(Base::VectorPy::Type),
&(VectorPy::Type),
&object2)) {
retVal = getBoundBoxPtr()->IsCutLine(
*(static_cast<Base::VectorPy*>(object1)->getVectorPtr()),
*(static_cast<Base::VectorPy*>(object2)->getVectorPtr()));
retVal =
getBoundBoxPtr()->IsCutLine(*(static_cast<VectorPy*>(object1)->getVectorPtr()),
*(static_cast<VectorPy*>(object2)->getVectorPtr()));
break;
}
PyErr_Clear();
if (PyArg_ParseTuple(args, "O!", &(Base::BoundBoxPy::Type), &object1)) {
if (!static_cast<Base::BoundBoxPy*>(object1)->getBoundBoxPtr()->IsValid()) {
if (PyArg_ParseTuple(args, "O!", &(BoundBoxPy::Type), &object1)) {
if (!static_cast<BoundBoxPy*>(object1)->getBoundBoxPtr()->IsValid()) {
PyErr_SetString(PyExc_FloatingPointError, "Invalid bounding box argument");
return nullptr;
}
retVal = getBoundBoxPtr()->Intersect(
*(static_cast<Base::BoundBoxPy*>(object1)->getBoundBoxPtr()));
retVal =
getBoundBoxPtr()->Intersect(*(static_cast<BoundBoxPy*>(object1)->getBoundBoxPtr()));
break;
}
@@ -292,17 +286,17 @@ PyObject* BoundBoxPy::intersected(PyObject* args)
}
PyObject* object {};
if (!PyArg_ParseTuple(args, "O!", &(Base::BoundBoxPy::Type), &object)) {
if (!PyArg_ParseTuple(args, "O!", &(BoundBoxPy::Type), &object)) {
return nullptr;
}
if (!static_cast<Base::BoundBoxPy*>(object)->getBoundBoxPtr()->IsValid()) {
if (!static_cast<BoundBoxPy*>(object)->getBoundBoxPtr()->IsValid()) {
PyErr_SetString(PyExc_FloatingPointError, "Invalid bounding box argument");
return nullptr;
}
Base::BoundBox3d bbox =
getBoundBoxPtr()->Intersected(*static_cast<Base::BoundBoxPy*>(object)->getBoundBoxPtr());
return new Base::BoundBoxPy(new Base::BoundBox3d(bbox));
BoundBox3d bbox =
getBoundBoxPtr()->Intersected(*static_cast<BoundBoxPy*>(object)->getBoundBoxPtr());
return new BoundBoxPy(new BoundBox3d(bbox));
}
PyObject* BoundBoxPy::united(PyObject* args)
@@ -313,17 +307,16 @@ PyObject* BoundBoxPy::united(PyObject* args)
}
PyObject* object {};
if (!PyArg_ParseTuple(args, "O!", &(Base::BoundBoxPy::Type), &object)) {
if (!PyArg_ParseTuple(args, "O!", &(BoundBoxPy::Type), &object)) {
return nullptr;
}
if (!static_cast<Base::BoundBoxPy*>(object)->getBoundBoxPtr()->IsValid()) {
if (!static_cast<BoundBoxPy*>(object)->getBoundBoxPtr()->IsValid()) {
PyErr_SetString(PyExc_FloatingPointError, "Invalid bounding box argument");
return nullptr;
}
Base::BoundBox3d bbox =
getBoundBoxPtr()->United(*static_cast<Base::BoundBoxPy*>(object)->getBoundBoxPtr());
return new Base::BoundBoxPy(new Base::BoundBox3d(bbox));
BoundBox3d bbox = getBoundBoxPtr()->United(*static_cast<BoundBoxPy*>(object)->getBoundBoxPtr());
return new BoundBoxPy(new BoundBox3d(bbox));
}
PyObject* BoundBoxPy::enlarge(PyObject* args)
@@ -343,25 +336,25 @@ PyObject* BoundBoxPy::getIntersectionPoint(PyObject* args)
double epsilon = 0.0001;
if (!PyArg_ParseTuple(args,
"O!O!|d;Need base and direction vector",
&(Base::VectorPy::Type),
&(VectorPy::Type),
&object1,
&(Base::VectorPy::Type),
&(VectorPy::Type),
&object2,
&epsilon)) {
return nullptr;
}
Base::Vector3d point;
bool ok = getBoundBoxPtr()->IntersectionPoint(
*(static_cast<Base::VectorPy*>(object1)->getVectorPtr()),
*(static_cast<Base::VectorPy*>(object2)->getVectorPtr()),
point,
epsilon);
Vector3d point;
bool ok =
getBoundBoxPtr()->IntersectionPoint(*(static_cast<VectorPy*>(object1)->getVectorPtr()),
*(static_cast<VectorPy*>(object2)->getVectorPtr()),
point,
epsilon);
if (ok) {
return new VectorPy(point);
}
PyErr_SetString(Base::PyExc_FC_GeneralError, "No intersection");
PyErr_SetString(PyExc_FC_GeneralError, "No intersection");
return nullptr;
}
@@ -372,7 +365,7 @@ PyObject* BoundBoxPy::move(PyObject* args)
double z {};
PyObject* object {};
Base::Vector3d vec;
Vector3d vec;
do {
if (PyArg_ParseTuple(args, "ddd", &x, &y, &z)) {
@@ -387,8 +380,8 @@ PyObject* BoundBoxPy::move(PyObject* args)
}
PyErr_Clear();
if (PyArg_ParseTuple(args, "O!", &(Base::VectorPy::Type), &object)) {
vec = *(static_cast<Base::VectorPy*>(object)->getVectorPtr());
if (PyArg_ParseTuple(args, "O!", &(VectorPy::Type), &object)) {
vec = *(static_cast<VectorPy*>(object)->getVectorPtr());
break;
}
@@ -410,7 +403,7 @@ PyObject* BoundBoxPy::scale(PyObject* args)
double z {};
PyObject* object {};
Base::Vector3d vec;
Vector3d vec;
do {
if (PyArg_ParseTuple(args, "ddd", &x, &y, &z)) {
@@ -425,8 +418,8 @@ PyObject* BoundBoxPy::scale(PyObject* args)
}
PyErr_Clear();
if (PyArg_ParseTuple(args, "O!", &(Base::VectorPy::Type), &object)) {
vec = *(static_cast<Base::VectorPy*>(object)->getVectorPtr());
if (PyArg_ParseTuple(args, "O!", &(VectorPy::Type), &object)) {
vec = *(static_cast<VectorPy*>(object)->getVectorPtr());
break;
}
@@ -445,16 +438,15 @@ PyObject* BoundBoxPy::transformed(PyObject* args)
{
PyObject* mat {};
if (!PyArg_ParseTuple(args, "O!", &(Base::MatrixPy::Type), &mat)) {
if (!PyArg_ParseTuple(args, "O!", &(MatrixPy::Type), &mat)) {
return nullptr;
}
if (!getBoundBoxPtr()->IsValid()) {
throw Py::FloatingPointError("Cannot transform invalid bounding box");
}
Base::BoundBox3d bbox =
getBoundBoxPtr()->Transformed(*static_cast<Base::MatrixPy*>(mat)->getMatrixPtr());
return new Base::BoundBoxPy(new Base::BoundBox3d(bbox));
BoundBox3d bbox = getBoundBoxPtr()->Transformed(*static_cast<MatrixPy*>(mat)->getMatrixPtr());
return new BoundBoxPy(new BoundBox3d(bbox));
}
PyObject* BoundBoxPy::isCutPlane(PyObject* args)
@@ -470,15 +462,15 @@ PyObject* BoundBoxPy::isCutPlane(PyObject* args)
if (!PyArg_ParseTuple(args,
"O!O!;Need base and normal vector of a plane",
&(Base::VectorPy::Type),
&(VectorPy::Type),
&object,
&(Base::VectorPy::Type),
&(VectorPy::Type),
&object2)) {
return nullptr;
}
retVal = getBoundBoxPtr()->IsCutPlane(*(static_cast<Base::VectorPy*>(object)->getVectorPtr()),
*(static_cast<Base::VectorPy*>(object2)->getVectorPtr()));
retVal = getBoundBoxPtr()->IsCutPlane(*(static_cast<VectorPy*>(object)->getVectorPtr()),
*(static_cast<VectorPy*>(object2)->getVectorPtr()));
return Py::new_reference_to(retVal);
}
@@ -509,20 +501,19 @@ PyObject* BoundBoxPy::isInside(PyObject* args)
}
PyErr_Clear();
if (PyArg_ParseTuple(args, "O!", &(Base::VectorPy::Type), &object)) {
retVal =
getBoundBoxPtr()->IsInBox(*(static_cast<Base::VectorPy*>(object)->getVectorPtr()));
if (PyArg_ParseTuple(args, "O!", &(VectorPy::Type), &object)) {
retVal = getBoundBoxPtr()->IsInBox(*(static_cast<VectorPy*>(object)->getVectorPtr()));
break;
}
PyErr_Clear();
if (PyArg_ParseTuple(args, "O!", &(Base::BoundBoxPy::Type), &object)) {
if (!static_cast<Base::BoundBoxPy*>(object)->getBoundBoxPtr()->IsValid()) {
if (PyArg_ParseTuple(args, "O!", &(BoundBoxPy::Type), &object)) {
if (!static_cast<BoundBoxPy*>(object)->getBoundBoxPtr()->IsValid()) {
PyErr_SetString(PyExc_FloatingPointError, "Invalid bounding box argument");
return nullptr;
}
retVal = getBoundBoxPtr()->IsInBox(
*(static_cast<Base::BoundBoxPy*>(object)->getBoundBoxPtr()));
retVal =
getBoundBoxPtr()->IsInBox(*(static_cast<BoundBoxPy*>(object)->getBoundBoxPtr()));
break;
}