Commit 1b345c19 authored by wmayer's avatar wmayer
Browse files

Use PyObject_IsTrue to check argument

parent 0efd86fb
......@@ -187,7 +187,9 @@ PyObject* DocumentPy::copyObject(PyObject *args)
return NULL; // NULL triggers exception
DocumentObjectPy* docObj = static_cast<DocumentObjectPy*>(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<DocumentObjectPy*>(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();
}
......
......@@ -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;
......
......@@ -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 {
......
......@@ -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());
......
......@@ -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;
......
......@@ -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;
......
......@@ -278,7 +278,7 @@ PyObject* MeshPy::crossSections(PyObject *args)
}
std::vector<MeshObject::TPolylines> 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;
......
......@@ -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));
}
......
......@@ -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<Part::TopoShapePy*>(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;
}
......
......@@ -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;
......
......@@ -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) {
......
......@@ -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;
......
......@@ -59,7 +59,7 @@ int RectangularTrimmedSurfacePy::PyInit(PyObject* args, PyObject* /*kwd*/)
getGeomTrimmedSurfacePtr()->setHandle(new Geom_RectangularTrimmedSurface(
Handle_Geom_Surface::DownCast(static_cast<GeometrySurfacePy*>(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,
&param1,&param2,&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<GeometrySurfacePy*>(surf)->
getGeomSurfacePtr()->handle()),
......
......@@ -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;
......
......@@ -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));
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment