Part: replace PyObject_IsTrue with Base::asBoolean

This commit is contained in:
wmayer
2022-07-16 13:31:10 +02:00
parent 343aadf02b
commit 8ae3185e3b
38 changed files with 141 additions and 161 deletions

View File

@@ -116,7 +116,7 @@ PyObject* ShapeFix_EdgePy::fixAddPCurve(PyObject *args)
TopoDS_Shape f = static_cast<TopoShapePy*>(face)->getTopoShapePtr()->getShape();
bool ok = getShapeFix_EdgePtr()->FixAddPCurve(TopoDS::Edge(e), TopoDS::Face(f),
PyObject_IsTrue(seam) ? Standard_True : Standard_False,
Base::asBoolean(seam),
prec);
return Py::new_reference_to(Py::Boolean(ok));
}
@@ -133,7 +133,7 @@ PyObject* ShapeFix_EdgePy::fixAddPCurve(PyObject *args)
TopLoc_Location loc = Tools::fromPlacement(*pm);
bool ok = getShapeFix_EdgePtr()->FixAddPCurve(TopoDS::Edge(e), surf, loc,
PyObject_IsTrue(seam) ? Standard_True : Standard_False,
Base::asBoolean(seam),
prec);
return Py::new_reference_to(Py::Boolean(ok));
}

View File

@@ -67,7 +67,7 @@ int ShapeFix_FacePy::PyInit(PyObject* args, PyObject* /*kwds*/)
setHandle(new ShapeFix_Face());
if (face) {
Handle(Geom_Surface) surf = Handle(Geom_Surface)::DownCast(static_cast<GeometrySurfacePy*>(face)->getGeomSurfacePtr()->handle());
getShapeFix_FacePtr()->Init(surf, prec, PyObject_IsTrue(fwd) ? Standard_True : Standard_False);
getShapeFix_FacePtr()->Init(surf, prec, Base::asBoolean(fwd));
}
return 0;
@@ -96,7 +96,7 @@ PyObject* ShapeFix_FacePy::init(PyObject *args)
if (PyArg_ParseTuple(args, "O!d|O!", &GeometrySurfacePy::Type, &face, &prec, &PyBool_Type, &fwd)) {
if (face) {
Handle(Geom_Surface) surf = Handle(Geom_Surface)::DownCast(static_cast<GeometrySurfacePy*>(face)->getGeomSurfacePtr()->handle());
getShapeFix_FacePtr()->Init(surf, prec, PyObject_IsTrue(fwd) ? Standard_True : Standard_False);
getShapeFix_FacePtr()->Init(surf, prec, Base::asBoolean(fwd));
}
Py_Return;
@@ -174,7 +174,7 @@ PyObject* ShapeFix_FacePy::fixSmallAreaWire(PyObject *args)
if (!PyArg_ParseTuple(args, "O!", &PyBool_Type, &removeSmall))
return nullptr;
Standard_Boolean ok = getShapeFix_FacePtr()->FixSmallAreaWire(PyObject_IsTrue(removeSmall) ? Standard_True : Standard_False);
Standard_Boolean ok = getShapeFix_FacePtr()->FixSmallAreaWire(Base::asBoolean(removeSmall));
return Py::new_reference_to(Py::Boolean(ok));
}

View File

@@ -108,7 +108,7 @@ PyObject* ShapeFix_FixSmallFacePy::fixStripFace(PyObject *args)
if (!PyArg_ParseTuple(args, "|O!", &PyBool_Type, &wasdone))
return nullptr;
TopoShape sh = getShapeFix_FixSmallFacePtr()->FixStripFace(PyObject_IsTrue(wasdone) ? Standard_True : Standard_False);
TopoShape sh = getShapeFix_FixSmallFacePtr()->FixStripFace(Base::asBoolean(wasdone));
return sh.getPyObject();
}

View File

@@ -61,8 +61,8 @@ int ShapeFix_FreeBoundsPy::PyInit(PyObject* args, PyObject* /*kwds*/)
&PyBool_Type, &splitclosed, &PyBool_Type, &splitopen)) {
TopoDS_Shape sh = static_cast<TopoShapePy*>(shape)->getTopoShapePtr()->getShape();
setTwinPointer(new ShapeFix_FreeBounds(sh, sewtoler, closetoler,
PyObject_IsTrue(splitclosed) ? Standard_True : Standard_False,
PyObject_IsTrue(splitopen) ? Standard_True : Standard_False));
Base::asBoolean(splitclosed),
Base::asBoolean(splitopen)));
return 0;
}
@@ -71,8 +71,8 @@ int ShapeFix_FreeBoundsPy::PyInit(PyObject* args, PyObject* /*kwds*/)
&PyBool_Type, &splitclosed, &PyBool_Type, &splitopen)) {
TopoDS_Shape sh = static_cast<TopoShapePy*>(shape)->getTopoShapePtr()->getShape();
setTwinPointer(new ShapeFix_FreeBounds(sh, closetoler,
PyObject_IsTrue(splitclosed) ? Standard_True : Standard_False,
PyObject_IsTrue(splitopen) ? Standard_True : Standard_False));
Base::asBoolean(splitclosed),
Base::asBoolean(splitopen)));
return 0;
}

View File

@@ -137,8 +137,7 @@ PyObject* ShapeFix_ShellPy::fixFaceOrientation(PyObject *args)
return nullptr;
bool ok = getShapeFix_ShellPtr()->FixFaceOrientation(TopoDS::Shell(static_cast<TopoShapePy*>(shell)->getTopoShapePtr()->getShape()),
PyObject_IsTrue(multiConex) ? Standard_True : Standard_False,
PyObject_IsTrue(nonManifold) ? Standard_True : Standard_False);
Base::asBoolean(multiConex), Base::asBoolean(nonManifold));
return Py::new_reference_to(Py::Boolean(ok));
}
@@ -148,7 +147,7 @@ PyObject* ShapeFix_ShellPy::setNonManifoldFlag(PyObject *args)
if (!PyArg_ParseTuple(args, "O!", &PyBool_Type, &nonManifold))
return nullptr;
getShapeFix_ShellPtr()->SetNonManifoldFlag(PyObject_IsTrue(nonManifold) ? Standard_True : Standard_False);
getShapeFix_ShellPtr()->SetNonManifoldFlag(Base::asBoolean(nonManifold));
Py_Return;
}

View File

@@ -265,7 +265,7 @@ PyObject* ShapeFix_WirePy::fixSmall(PyObject *args)
double prec = 0.0;
if (PyArg_ParseTuple(args, "O!|d", &PyBool_Type, &lock, &prec)) {
try {
int num = getShapeFix_WirePtr()->FixSmall(PyObject_IsTrue(lock) ? Standard_True : Standard_False, prec);
int num = getShapeFix_WirePtr()->FixSmall(Base::asBoolean(lock), prec);
return Py::new_reference_to(Py::Long(num));
}
catch (const Standard_Failure& e) {
@@ -278,7 +278,7 @@ PyObject* ShapeFix_WirePy::fixSmall(PyObject *args)
int num;
if (PyArg_ParseTuple(args, "iO!d", &num, &PyBool_Type, &lock, &prec)) {
try {
bool ok = getShapeFix_WirePtr()->FixSmall(num, PyObject_IsTrue(lock) ? Standard_True : Standard_False, prec);
bool ok = getShapeFix_WirePtr()->FixSmall(num, Base::asBoolean(lock), prec);
return Py::new_reference_to(Py::Boolean(ok));
}
catch (const Standard_Failure& e) {
@@ -366,7 +366,7 @@ PyObject* ShapeFix_WirePy::fixLacking(PyObject *args)
PyObject* force = Py_False;
if (PyArg_ParseTuple(args, "|O!", &PyBool_Type, &force)) {
try {
Standard_Boolean ok = getShapeFix_WirePtr()->FixLacking(PyObject_IsTrue(force) ? Standard_True : Standard_False);
Standard_Boolean ok = getShapeFix_WirePtr()->FixLacking(Base::asBoolean(force));
return Py::new_reference_to(Py::Boolean(ok));
}
catch (const Standard_Failure& e) {
@@ -380,7 +380,7 @@ PyObject* ShapeFix_WirePy::fixLacking(PyObject *args)
force = Py_False;
if (PyArg_ParseTuple(args, "i|O!", &num, &PyBool_Type, &force)) {
try {
Standard_Boolean ok = getShapeFix_WirePtr()->FixLacking(num, PyObject_IsTrue(force) ? Standard_True : Standard_False);
Standard_Boolean ok = getShapeFix_WirePtr()->FixLacking(num, Base::asBoolean(force));
return Py::new_reference_to(Py::Boolean(ok));
}
catch (const Standard_Failure& e) {
@@ -431,7 +431,7 @@ PyObject* ShapeFix_WirePy::fixGap3d(PyObject *args)
return nullptr;
try {
Standard_Boolean ok = getShapeFix_WirePtr()->FixGap3d(num, PyObject_IsTrue(convert) ? Standard_True : Standard_False);
Standard_Boolean ok = getShapeFix_WirePtr()->FixGap3d(num, Base::asBoolean(convert));
return Py::new_reference_to(Py::Boolean(ok));
}
catch (const Standard_Failure& e) {
@@ -448,7 +448,7 @@ PyObject* ShapeFix_WirePy::fixGap2d(PyObject *args)
return nullptr;
try {
Standard_Boolean ok = getShapeFix_WirePtr()->FixGap2d(num, PyObject_IsTrue(convert) ? Standard_True : Standard_False);
Standard_Boolean ok = getShapeFix_WirePtr()->FixGap2d(num, Base::asBoolean(convert));
return Py::new_reference_to(Py::Boolean(ok));
}
catch (const Standard_Failure& e) {