diff --git a/src/App/DocumentPyImp.cpp b/src/App/DocumentPyImp.cpp index 4b5d805d4..0f5de8170 100644 --- a/src/App/DocumentPyImp.cpp +++ b/src/App/DocumentPyImp.cpp @@ -187,7 +187,9 @@ PyObject* DocumentPy::copyObject(PyObject *args) return NULL; // NULL triggers exception DocumentObjectPy* docObj = static_cast(obj); - DocumentObject* copy = getDocumentPtr()->copyObject(docObj->getDocumentObjectPtr(), rec==Py_True, keep==Py_True); + DocumentObject* copy = getDocumentPtr()->copyObject(docObj->getDocumentObjectPtr(), + PyObject_IsTrue(rec) ? true : false, + PyObject_IsTrue(keep)? true : false); if (copy) { return copy->getPyObject(); } @@ -204,7 +206,7 @@ PyObject* DocumentPy::moveObject(PyObject *args) return NULL; // NULL triggers exception DocumentObjectPy* docObj = static_cast(obj); - DocumentObject* move = getDocumentPtr()->moveObject(docObj->getDocumentObjectPtr(), rec==Py_True); + DocumentObject* move = getDocumentPtr()->moveObject(docObj->getDocumentObjectPtr(), PyObject_IsTrue(rec) ? true : false); if (move) { return move->getPyObject(); } diff --git a/src/App/FeaturePythonPyImp.cpp b/src/App/FeaturePythonPyImp.cpp index 42d90cdd4..3a6fb3958 100644 --- a/src/App/FeaturePythonPyImp.cpp +++ b/src/App/FeaturePythonPyImp.cpp @@ -51,7 +51,8 @@ PyObject* FeaturePythonPy::addProperty(PyObject *args) return NULL; // NULL triggers exception Property* prop=0; - prop = getFeaturePythonPtr()->addDynamicProperty(sType,sName,sGroup,sDoc,attr,ro==Py_True,hd==Py_True); + prop = getFeaturePythonPtr()->addDynamicProperty(sType,sName,sGroup,sDoc,attr, + PyObject_IsTrue(ro) ? true : false, PyObject_IsTrue(hd) ? true : false); if (!prop) { std::stringstream str; diff --git a/src/App/PropertyStandard.cpp b/src/App/PropertyStandard.cpp index 59a407f70..3918d0c36 100644 --- a/src/App/PropertyStandard.cpp +++ b/src/App/PropertyStandard.cpp @@ -1347,7 +1347,7 @@ PyObject *PropertyBool::getPyObject(void) void PropertyBool::setPyObject(PyObject *value) { if (PyBool_Check(value)) - setValue(value == Py_True); + setValue(PyObject_IsTrue(value)!=0); else if(PyInt_Check(value)) setValue(PyInt_AsLong(value)!=0); else { diff --git a/src/Gui/View3DPy.cpp b/src/Gui/View3DPy.cpp index 1fd6e034e..d8dabd075 100644 --- a/src/Gui/View3DPy.cpp +++ b/src/Gui/View3DPy.cpp @@ -474,7 +474,7 @@ Py::Object View3DInventorPy::setCameraOrientation(const Py::Tuple& args) float q1 = (float)Py::Float(tuple[1]); float q2 = (float)Py::Float(tuple[2]); float q3 = (float)Py::Float(tuple[3]); - _view->getViewer()->setCameraOrientation(SbRotation(q0, q1, q2, q3), m==Py_True); + _view->getViewer()->setCameraOrientation(SbRotation(q0, q1, q2, q3), PyObject_IsTrue(m)); } catch (const Base::Exception& e) { throw Py::Exception(e.what()); diff --git a/src/Gui/ViewProviderPythonFeaturePyImp.cpp b/src/Gui/ViewProviderPythonFeaturePyImp.cpp index badd7a56f..ddd2816a4 100644 --- a/src/Gui/ViewProviderPythonFeaturePyImp.cpp +++ b/src/Gui/ViewProviderPythonFeaturePyImp.cpp @@ -73,7 +73,8 @@ PyObject* ViewProviderPythonFeaturePy::addProperty(PyObject *args) return NULL; // NULL triggers exception App::Property* prop=0; - prop = getViewProviderPythonFeaturePtr()->addDynamicProperty(sType,sName,sGroup,sDoc,attr,ro==Py_True,hd==Py_True); + prop = getViewProviderPythonFeaturePtr()->addDynamicProperty(sType,sName,sGroup,sDoc,attr, + PyObject_IsTrue(ro) ? true : false, PyObject_IsTrue(hd) ? true : false); if (!prop) { std::stringstream str; diff --git a/src/Mod/Mesh/App/FeaturePythonPyImp.cpp b/src/Mod/Mesh/App/FeaturePythonPyImp.cpp index 47c19e5c5..2e985e2bb 100644 --- a/src/Mod/Mesh/App/FeaturePythonPyImp.cpp +++ b/src/Mod/Mesh/App/FeaturePythonPyImp.cpp @@ -49,7 +49,8 @@ PyObject* FeaturePythonPy::addProperty(PyObject *args) return NULL; // NULL triggers exception App::Property* prop=0; - prop = getFeaturePtr()->addDynamicProperty(sType,sName,sGroup,sDoc,attr,ro==Py_True,hd==Py_True); + prop = getFeaturePtr()->addDynamicProperty(sType,sName,sGroup,sDoc,attr, + PyObject_IsTrue(ro) ? true : false, PyObject_IsTrue(hd) ? true : false); if (!prop) { std::stringstream str; diff --git a/src/Mod/Mesh/App/MeshPyImp.cpp b/src/Mod/Mesh/App/MeshPyImp.cpp index 6d7c542f4..dc4d69390 100644 --- a/src/Mod/Mesh/App/MeshPyImp.cpp +++ b/src/Mod/Mesh/App/MeshPyImp.cpp @@ -278,7 +278,7 @@ PyObject* MeshPy::crossSections(PyObject *args) } std::vector sections; - getMeshObjectPtr()->crossSections(csPlanes, sections, min_eps, (poly == Py_True)); + getMeshObjectPtr()->crossSections(csPlanes, sections, min_eps, PyObject_IsTrue(poly) ? true : false); // convert to Python objects Py::List crossSections; diff --git a/src/Mod/Part/App/AppPartPy.cpp b/src/Mod/Part/App/AppPartPy.cpp index 342c59069..f6ff0c934 100644 --- a/src/Mod/Part/App/AppPartPy.cpp +++ b/src/Mod/Part/App/AppPartPy.cpp @@ -1166,8 +1166,8 @@ static PyObject * makeLoft(PyObject *self, PyObject *args) } TopoShape myShape; - Standard_Boolean anIsSolid = (psolid == Py_True) ? Standard_True : Standard_False; - Standard_Boolean anIsRuled = (pruled == Py_True) ? Standard_True : Standard_False; + Standard_Boolean anIsSolid = PyObject_IsTrue(psolid) ? Standard_True : Standard_False; + Standard_Boolean anIsRuled = PyObject_IsTrue(pruled) ? Standard_True : Standard_False; TopoDS_Shape aResult = myShape.makeLoft(profiles, anIsSolid, anIsRuled); return new TopoShapePy(new TopoShape(aResult)); } diff --git a/src/Mod/Part/App/BRepOffsetAPI_MakePipeShellPyImp.cpp b/src/Mod/Part/App/BRepOffsetAPI_MakePipeShellPyImp.cpp index 2017e86d2..5b0caa771 100644 --- a/src/Mod/Part/App/BRepOffsetAPI_MakePipeShellPyImp.cpp +++ b/src/Mod/Part/App/BRepOffsetAPI_MakePipeShellPyImp.cpp @@ -73,7 +73,7 @@ PyObject* BRepOffsetAPI_MakePipeShellPy::setFrenetMode(PyObject *args) PyObject *obj; if (!PyArg_ParseTuple(args, "O!",&PyBool_Type,&obj)) return 0; - this->getBRepOffsetAPI_MakePipeShellPtr()->SetMode(obj==Py_True); + this->getBRepOffsetAPI_MakePipeShellPtr()->SetMode(PyObject_IsTrue(obj) ? Standard_True : Standard_False); Py_Return; } @@ -121,7 +121,7 @@ PyObject* BRepOffsetAPI_MakePipeShellPy::setAuxiliarySpine(PyObject *args) PyErr_SetString(PyExc_TypeError, "spine is not a wire"); return 0; } - this->getBRepOffsetAPI_MakePipeShellPtr()->SetMode(TopoDS::Wire(s), curv==Py_True, keep==Py_True); + this->getBRepOffsetAPI_MakePipeShellPtr()->SetMode(TopoDS::Wire(s), PyObject_IsTrue(curv), PyObject_IsTrue(keep)); Py_Return; } @@ -133,7 +133,7 @@ PyObject* BRepOffsetAPI_MakePipeShellPy::add(PyObject *args) ,&PyBool_Type,&keep)) return 0; const TopoDS_Shape& s = static_cast(prof)->getTopoShapePtr()->_Shape; - this->getBRepOffsetAPI_MakePipeShellPtr()->Add(s, curv==Py_True, keep==Py_True); + this->getBRepOffsetAPI_MakePipeShellPtr()->Add(s, PyObject_IsTrue(curv), PyObject_IsTrue(keep)); Py_Return; } diff --git a/src/Mod/Part/App/BSplineCurvePyImp.cpp b/src/Mod/Part/App/BSplineCurvePyImp.cpp index 7f608c902..b94b99213 100644 --- a/src/Mod/Part/App/BSplineCurvePyImp.cpp +++ b/src/Mod/Part/App/BSplineCurvePyImp.cpp @@ -183,7 +183,7 @@ PyObject* BSplineCurvePy::insertKnot(PyObject * args) try { Handle_Geom_BSplineCurve curve = Handle_Geom_BSplineCurve::DownCast (getGeometryPtr()->handle()); - curve->InsertKnot(U,M,tol,(add==Py_True)); + curve->InsertKnot(U,M,tol,PyObject_IsTrue(add)); } catch (Standard_Failure) { Handle_Standard_Failure e = Standard_Failure::Caught(); @@ -223,7 +223,7 @@ PyObject* BSplineCurvePy::insertKnots(PyObject * args) Handle_Geom_BSplineCurve curve = Handle_Geom_BSplineCurve::DownCast (getGeometryPtr()->handle()); - curve->InsertKnots(k,m,tol,(add==Py_True)); + curve->InsertKnots(k,m,tol,PyObject_IsTrue(add)); Py_Return; } catch (Standard_Failure) { @@ -755,7 +755,7 @@ PyObject* BSplineCurvePy::interpolate(PyObject *args) Standard_Failure::Raise("not enough points given"); } - GeomAPI_Interpolate aBSplineInterpolation(interpolationPoints, (closed == Py_True), tol3d); + GeomAPI_Interpolate aBSplineInterpolation(interpolationPoints, PyObject_IsTrue(closed), tol3d); if (t1 && t2) { Base::Vector3d v1 = Py::Vector(t1,false).toVector(); Base::Vector3d v2 = Py::Vector(t1,false).toVector(); @@ -811,7 +811,7 @@ PyObject* BSplineCurvePy::buildFromPoles(PyObject *args) mults.SetValue(1, degree+1); mults.SetValue(knots.Length(), degree+1); - Handle_Geom_BSplineCurve spline = new Geom_BSplineCurve(poles, knots, mults, degree, (closed == Py_True)); + Handle_Geom_BSplineCurve spline = new Geom_BSplineCurve(poles, knots, mults, degree, PyObject_IsTrue(closed)); if (!spline.IsNull()) { this->getGeomBSplineCurvePtr()->setHandle(spline); Py_Return; diff --git a/src/Mod/Part/App/BSplineSurfacePyImp.cpp b/src/Mod/Part/App/BSplineSurfacePyImp.cpp index 5fd9c9773..b299e4ac5 100644 --- a/src/Mod/Part/App/BSplineSurfacePyImp.cpp +++ b/src/Mod/Part/App/BSplineSurfacePyImp.cpp @@ -293,7 +293,7 @@ PyObject* BSplineSurfacePy::insertUKnot(PyObject *args) try { Handle_Geom_BSplineSurface surf = Handle_Geom_BSplineSurface::DownCast (getGeometryPtr()->handle()); - surf->InsertUKnot(U,M,tol,(add==Py_True)); + surf->InsertUKnot(U,M,tol,PyObject_IsTrue(add)); } catch (Standard_Failure) { Handle_Standard_Failure e = Standard_Failure::Caught(); @@ -333,7 +333,7 @@ PyObject* BSplineSurfacePy::insertUKnots(PyObject *args) Handle_Geom_BSplineSurface surf = Handle_Geom_BSplineSurface::DownCast (getGeometryPtr()->handle()); - surf->InsertUKnots(k,m,tol,(add==Py_True)); + surf->InsertUKnots(k,m,tol,PyObject_IsTrue(add)); Py_Return; } catch (Standard_Failure) { @@ -356,7 +356,7 @@ PyObject* BSplineSurfacePy::insertVKnot(PyObject *args) try { Handle_Geom_BSplineSurface surf = Handle_Geom_BSplineSurface::DownCast (getGeometryPtr()->handle()); - surf->InsertVKnot(V,M,tol,(add==Py_True)); + surf->InsertVKnot(V,M,tol,PyObject_IsTrue(add)); } catch (Standard_Failure) { Handle_Standard_Failure e = Standard_Failure::Caught(); @@ -396,7 +396,7 @@ PyObject* BSplineSurfacePy::insertVKnots(PyObject *args) Handle_Geom_BSplineSurface surf = Handle_Geom_BSplineSurface::DownCast (getGeometryPtr()->handle()); - surf->InsertVKnots(k,m,tol,(add==Py_True)); + surf->InsertVKnots(k,m,tol,PyObject_IsTrue(add)); Py_Return; } catch (Standard_Failure) { diff --git a/src/Mod/Part/App/FeaturePythonPyImp.cpp b/src/Mod/Part/App/FeaturePythonPyImp.cpp index 6f2c8a255..2a2f76cd6 100644 --- a/src/Mod/Part/App/FeaturePythonPyImp.cpp +++ b/src/Mod/Part/App/FeaturePythonPyImp.cpp @@ -47,7 +47,8 @@ PyObject* FeaturePythonPy::addProperty(PyObject *args) return NULL; // NULL triggers exception App::Property* prop=0; - prop = getFeaturePythonPtr()->addDynamicProperty(sType,sName,sGroup,sDoc,attr,ro==Py_True,hd==Py_True); + prop = getFeaturePythonPtr()->addDynamicProperty(sType,sName,sGroup,sDoc,attr, + PyObject_IsTrue(ro) ? true : false, PyObject_IsTrue(hd) ? true : false); if (!prop) { std::stringstream str; diff --git a/src/Mod/Part/App/RectangularTrimmedSurfacePyImp.cpp b/src/Mod/Part/App/RectangularTrimmedSurfacePyImp.cpp index 456223283..40ebc5276 100644 --- a/src/Mod/Part/App/RectangularTrimmedSurfacePyImp.cpp +++ b/src/Mod/Part/App/RectangularTrimmedSurfacePyImp.cpp @@ -59,7 +59,7 @@ int RectangularTrimmedSurfacePy::PyInit(PyObject* args, PyObject* /*kwd*/) getGeomTrimmedSurfacePtr()->setHandle(new Geom_RectangularTrimmedSurface( Handle_Geom_Surface::DownCast(static_cast(surf)-> getGeomSurfacePtr()->handle()), - u1, u2, v1, v2, (usense==Py_True), (vsense==Py_True) + u1, u2, v1, v2, PyObject_IsTrue(usense), PyObject_IsTrue(vsense) )); return 0; } @@ -69,8 +69,8 @@ int RectangularTrimmedSurfacePy::PyInit(PyObject* args, PyObject* /*kwd*/) PyObject *utrim=0, *sense=Py_True; if (PyArg_ParseTuple(args, "O!ddO!|O!",&(Part::GeometrySurfacePy::Type),&surf, ¶m1,¶m2,&PyBool_Type,&utrim,&PyBool_Type,&sense)) { - Standard_Boolean UTrim = (utrim==Py_True); - Standard_Boolean Sense = (sense==Py_True); + Standard_Boolean UTrim = PyObject_IsTrue(utrim); + Standard_Boolean Sense = PyObject_IsTrue(sense); getGeomTrimmedSurfacePtr()->setHandle(new Geom_RectangularTrimmedSurface( Handle_Geom_Surface::DownCast(static_cast(surf)-> getGeomSurfacePtr()->handle()), diff --git a/src/Mod/Part/App/TopoShapeCompoundPyImp.cpp b/src/Mod/Part/App/TopoShapeCompoundPyImp.cpp index 3b84d7b97..50391d564 100644 --- a/src/Mod/Part/App/TopoShapeCompoundPyImp.cpp +++ b/src/Mod/Part/App/TopoShapeCompoundPyImp.cpp @@ -122,7 +122,7 @@ PyObject* TopoShapeCompoundPy::connectEdgesToWires(PyObject *args) for (TopExp_Explorer xp(s, TopAbs_EDGE); xp.More(); xp.Next()) hEdges->Append(xp.Current()); - ShapeAnalysis_FreeBounds::ConnectEdgesToWires(hEdges, tol, (shared==Py_True), hWires); + ShapeAnalysis_FreeBounds::ConnectEdgesToWires(hEdges, tol, PyObject_IsTrue(shared), hWires); TopoDS_Compound comp; BRep_Builder builder; diff --git a/src/Mod/Part/App/TopoShapePyImp.cpp b/src/Mod/Part/App/TopoShapePyImp.cpp index bc74344dd..24f26d832 100644 --- a/src/Mod/Part/App/TopoShapePyImp.cpp +++ b/src/Mod/Part/App/TopoShapePyImp.cpp @@ -1046,7 +1046,7 @@ PyObject* TopoShapePy::makeThickness(PyObject *args) } TopoDS_Shape shape = this->getTopoShapePtr()->makeThickSolid(facesToRemove, offset, tolerance, - (inter == Py_True), (self_inter == Py_True), offsetMode, join); + PyObject_IsTrue(inter) ? true : false, PyObject_IsTrue(self_inter) ? true : false, offsetMode, join); return new TopoShapeSolidPy(new TopoShape(shape)); } catch (Standard_Failure) { @@ -1073,7 +1073,9 @@ PyObject* TopoShapePy::makeOffsetShape(PyObject *args) try { TopoDS_Shape shape = this->getTopoShapePtr()->makeOffsetShape(offset, tolerance, - (inter == Py_True), (self_inter == Py_True), offsetMode, join, (fill == Py_True)); + PyObject_IsTrue(inter) ? true : false, + PyObject_IsTrue(self_inter) ? true : false, offsetMode, join, + PyObject_IsTrue(fill) ? true : false); return new TopoShapePy(new TopoShape(shape)); } catch (Standard_Failure) { @@ -1324,7 +1326,7 @@ PyObject* TopoShapePy::isInside(PyObject *args) gp_Pnt vertex = gp_Pnt(pnt.x,pnt.y,pnt.z); solidClassifier.Perform(vertex, tolerance); Standard_Boolean test = (solidClassifier.State() == stateIn); - if ( (checkFace == Py_True) && (solidClassifier.IsOnAFace()) ) + if (PyObject_IsTrue(checkFace) && (solidClassifier.IsOnAFace())) test = Standard_True; return Py_BuildValue("O", (test ? Py_True : Py_False)); }