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

@@ -331,7 +331,7 @@ private:
throw Py::Exception();
TopoDS_Shape sh = static_cast<TopoShapePy*>(shape)->getTopoShapePtr()->getShape();
bool ok = ShapeFix::SameParameter(sh, PyObject_IsTrue(enforce) ? Standard_True : Standard_False, prec);
bool ok = ShapeFix::SameParameter(sh, Base::asBoolean(enforce), prec);
return Py::Boolean(ok);
}
Py::Object encodeRegularity(const Py::Tuple& args)
@@ -1346,7 +1346,7 @@ private:
Standard_Failure::Raise("Cannot create polygon because less than two vertices are given");
// if the polygon should be closed
if (PyObject_IsTrue(pclosed) ? true : false) {
if (Base::asBoolean(pclosed)) {
if (!mkPoly.FirstVertex().IsSame(mkPoly.LastVertex())) {
mkPoly.Add(mkPoly.FirstVertex());
}
@@ -1527,8 +1527,8 @@ private:
try {
TopoShape helix;
Standard_Boolean anIsLeft = PyObject_IsTrue(pleft) ? Standard_True : Standard_False;
Standard_Boolean anIsVertHeight = PyObject_IsTrue(pvertHeight) ? Standard_True : Standard_False;
Standard_Boolean anIsLeft = Base::asBoolean(pleft);
Standard_Boolean anIsVertHeight = Base::asBoolean(pvertHeight);
TopoDS_Shape wire = helix.makeHelix(pitch, height, radius, angle,
anIsLeft, anIsVertHeight);
return Py::asObject(new TopoShapeWirePy(new TopoShape(wire)));
@@ -1548,7 +1548,7 @@ private:
try {
TopoShape helix;
Standard_Boolean anIsLeft = PyObject_IsTrue(pleft) ? Standard_True : Standard_False;
Standard_Boolean anIsLeft = Base::asBoolean(pleft);
TopoDS_Shape wire = helix.makeLongHelix(pitch, height, radius, angle, anIsLeft);
return Py::asObject(new TopoShapeWirePy(new TopoShape(wire)));
}
@@ -1865,9 +1865,9 @@ private:
}
TopoShape myShape;
Standard_Boolean anIsSolid = PyObject_IsTrue(psolid) ? Standard_True : Standard_False;
Standard_Boolean anIsRuled = PyObject_IsTrue(pruled) ? Standard_True : Standard_False;
Standard_Boolean anIsClosed = PyObject_IsTrue(pclosed) ? Standard_True : Standard_False;
Standard_Boolean anIsSolid = Base::asBoolean(psolid);
Standard_Boolean anIsRuled = Base::asBoolean(pruled);
Standard_Boolean anIsClosed = Base::asBoolean(pclosed);
TopoDS_Shape aResult = myShape.makeLoft(profiles, anIsSolid, anIsRuled, anIsClosed, degMax);
return Py::asObject(new TopoShapePy(new TopoShape(aResult)));
#endif
@@ -1885,7 +1885,7 @@ private:
TopoDS_Shape initShape = static_cast<TopoShapePy*>
(shape)->getTopoShapePtr()->getShape();
BRepFeat_SplitShape splitShape(initShape);
splitShape.SetCheckInterior(PyObject_IsTrue(checkInterior) ? Standard_True : Standard_False);
splitShape.SetCheckInterior(Base::asBoolean(checkInterior));
Py::Sequence seq(list);
for (Py::Sequence::iterator it = seq.begin(); it != seq.end(); ++it) {
@@ -2283,10 +2283,10 @@ private:
Base::Matrix4D mat;
if(pyMat)
mat = *static_cast<Base::MatrixPy*>(pyMat)->getMatrixPtr();
auto shape = Feature::getTopoShape(obj,subname,PyObject_IsTrue(needSubElement) ? true : false,
&mat,&subObj,retType==2,PyObject_IsTrue(transform) ? true : false,
PyObject_IsTrue(noElementMap) ? true : false);
if (PyObject_IsTrue(refine) ? true : false) {
auto shape = Feature::getTopoShape(obj,subname,Base::asBoolean(needSubElement),
&mat,&subObj,retType==2,Base::asBoolean(transform),
Base::asBoolean(noElementMap));
if (Base::asBoolean(refine)) {
// shape = TopoShape(0,shape.Hasher).makERefine(shape);
BRepBuilderAPI_RefineModel mkRefine(shape.getShape());
shape.setShape(mkRefine.Shape());

View File

@@ -80,7 +80,7 @@ int ArcOfCirclePy::PyInit(PyObject* args, PyObject* /*kwds*/)
try {
Handle(Geom_Circle) circle = Handle(Geom_Circle)::DownCast
(static_cast<CirclePy*>(o)->getGeomCirclePtr()->handle());
GC_MakeArcOfCircle arc(circle->Circ(), u1, u2, PyObject_IsTrue(sense) ? Standard_True : Standard_False);
GC_MakeArcOfCircle arc(circle->Circ(), u1, u2, Base::asBoolean(sense));
if (!arc.IsDone()) {
PyErr_SetString(PartExceptionOCCError, gce_ErrorStatusText(arc.Status()));
return -1;

View File

@@ -89,7 +89,7 @@ int ArcOfEllipsePy::PyInit(PyObject* args, PyObject* /*kwds*/)
try {
Handle(Geom_Ellipse) ellipse = Handle(Geom_Ellipse)::DownCast
(static_cast<EllipsePy*>(o)->getGeomEllipsePtr()->handle());
GC_MakeArcOfEllipse arc(ellipse->Elips(), u1, u2, PyObject_IsTrue(sense) ? Standard_True : Standard_False);
GC_MakeArcOfEllipse arc(ellipse->Elips(), u1, u2, Base::asBoolean(sense));
if (!arc.IsDone()) {
PyErr_SetString(PartExceptionOCCError, gce_ErrorStatusText(arc.Status()));
return -1;

View File

@@ -89,7 +89,7 @@ int ArcOfHyperbolaPy::PyInit(PyObject* args, PyObject* /*kwds*/)
try {
Handle(Geom_Hyperbola) hyperbola = Handle(Geom_Hyperbola)::DownCast
(static_cast<HyperbolaPy*>(o)->getGeomHyperbolaPtr()->handle());
GC_MakeArcOfHyperbola arc(hyperbola->Hypr(), u1, u2, PyObject_IsTrue(sense) ? Standard_True : Standard_False);
GC_MakeArcOfHyperbola arc(hyperbola->Hypr(), u1, u2, Base::asBoolean(sense));
if (!arc.IsDone()) {
PyErr_SetString(PartExceptionOCCError, gce_ErrorStatusText(arc.Status()));
return -1;

View File

@@ -87,7 +87,7 @@ int ArcOfParabolaPy::PyInit(PyObject* args, PyObject* /*kwds*/)
try {
Handle(Geom_Parabola) parabola = Handle(Geom_Parabola)::DownCast
(static_cast<ParabolaPy*>(o)->getGeomParabolaPtr()->handle());
GC_MakeArcOfParabola arc(parabola->Parab(), u1, u2, PyObject_IsTrue(sense) ? Standard_True : Standard_False);
GC_MakeArcOfParabola arc(parabola->Parab(), u1, u2, Base::asBoolean(sense));
if (!arc.IsDone()) {
PyErr_SetString(PartExceptionOCCError, gce_ErrorStatusText(arc.Status()));
return -1;

View File

@@ -69,7 +69,7 @@ int ArcPy::PyInit(PyObject* args, PyObject* /*kwd*/)
try {
Handle(Geom_Circle) circle = Handle(Geom_Circle)::DownCast
(static_cast<CirclePy*>(o)->getGeomCirclePtr()->handle());
GC_MakeArcOfCircle arc(circle->Circ(), u1, u2, PyObject_IsTrue(sense) ? Standard_True : Standard_False);
GC_MakeArcOfCircle arc(circle->Circ(), u1, u2, Base::asBoolean(sense));
if (!arc.IsDone()) {
PyErr_SetString(PartExceptionOCCError, gce_ErrorStatusText(arc.Status()));
return -1;
@@ -114,7 +114,7 @@ int ArcPy::PyInit(PyObject* args, PyObject* /*kwd*/)
try {
Handle(Geom_Ellipse) ellipse = Handle(Geom_Ellipse)::DownCast
(static_cast<EllipsePy*>(o)->getGeomEllipsePtr()->handle());
GC_MakeArcOfEllipse arc(ellipse->Elips(), u1, u2, PyObject_IsTrue(sense) ? Standard_True : Standard_False);
GC_MakeArcOfEllipse arc(ellipse->Elips(), u1, u2, Base::asBoolean(sense));
if (!arc.IsDone()) {
PyErr_SetString(PartExceptionOCCError, gce_ErrorStatusText(arc.Status()));
return -1;
@@ -139,7 +139,7 @@ int ArcPy::PyInit(PyObject* args, PyObject* /*kwd*/)
try {
Handle(Geom_Parabola) parabola = Handle(Geom_Parabola)::DownCast
(static_cast<ParabolaPy*>(o)->getGeomParabolaPtr()->handle());
GC_MakeArcOfParabola arc(parabola->Parab(), u1, u2, PyObject_IsTrue(sense) ? Standard_True : Standard_False);
GC_MakeArcOfParabola arc(parabola->Parab(), u1, u2, Base::asBoolean(sense));
if (!arc.IsDone()) {
PyErr_SetString(PartExceptionOCCError, gce_ErrorStatusText(arc.Status()));
return -1;
@@ -164,7 +164,7 @@ int ArcPy::PyInit(PyObject* args, PyObject* /*kwd*/)
try {
Handle(Geom_Hyperbola) hyperbola = Handle(Geom_Hyperbola)::DownCast
(static_cast<HyperbolaPy*>(o)->getGeomHyperbolaPtr()->handle());
GC_MakeArcOfHyperbola arc(hyperbola->Hypr(), u1, u2, PyObject_IsTrue(sense) ? Standard_True : Standard_False);
GC_MakeArcOfHyperbola arc(hyperbola->Hypr(), u1, u2, Base::asBoolean(sense));
if (!arc.IsDone()) {
PyErr_SetString(PartExceptionOCCError, gce_ErrorStatusText(arc.Status()));
return -1;

View File

@@ -66,7 +66,7 @@ int MakePrismPy::PyInit(PyObject* args, PyObject* kwds)
TopoDS_Face skface = TopoDS::Face(static_cast<TopoShapePy*>(Skface)->getTopoShapePtr()->getShape());
Base::Vector3d dir = static_cast<Base::VectorPy*>(Direction)->value();
std::unique_ptr<BRepFeat_MakePrism> ptr(new BRepFeat_MakePrism(sbase, pbase, skface, gp_Dir(dir.x, dir.y, dir.z), Fuse,
PyObject_IsTrue(Modify) ? Standard_True : Standard_False));
Base::asBoolean(Modify)));
setTwinPointer(ptr.release());
return 0;
@@ -126,7 +126,7 @@ PyObject* MakePrismPy::init(PyObject *args, PyObject* kwds)
TopoDS_Face skface = TopoDS::Face(static_cast<TopoShapePy*>(Skface)->getTopoShapePtr()->getShape());
Base::Vector3d dir = static_cast<Base::VectorPy*>(Direction)->value();
getBRepFeat_MakePrismPtr()->Init(sbase, pbase, skface, gp_Dir(dir.x, dir.y, dir.z), Fuse,
PyObject_IsTrue(Modify) ? Standard_True : Standard_False);
Base::asBoolean(Modify));
Py_Return;
}

View File

@@ -100,7 +100,7 @@ int BRepOffsetAPI_MakeFillingPy::PyInit(PyObject* args, PyObject* kwds)
try {
std::unique_ptr<BRepOffsetAPI_MakeFilling> ptr(new BRepOffsetAPI_MakeFilling(degree, nbPtsOnCur, nbIter,
PyObject_IsTrue(anisotropy) ? Standard_True : Standard_False,
Base::asBoolean(anisotropy),
tol2d, tol3d, tolAng, tolCurv, maxDeg, maxSegments));
@@ -155,7 +155,7 @@ PyObject* BRepOffsetAPI_MakeFillingPy::setResolParam(PyObject *args, PyObject *k
try {
getBRepOffsetAPI_MakeFillingPtr()->SetResolParam(degree, nbPtsOnCur, nbIter,
PyObject_IsTrue(anisotropy) ? Standard_True : Standard_False);
Base::asBoolean(anisotropy));
Py_Return;
}
catch (const Standard_Failure& e) {
@@ -273,7 +273,7 @@ PyObject* BRepOffsetAPI_MakeFillingPy::add(PyObject *args, PyObject *kwds)
}
getBRepOffsetAPI_MakeFillingPtr()->Add(edge, static_cast<GeomAbs_Shape>(order),
PyObject_IsTrue(isbound) ? Standard_True : Standard_False);
Base::asBoolean(isbound));
Py_Return;
}
catch (const Standard_Failure& e) {
@@ -307,7 +307,7 @@ PyObject* BRepOffsetAPI_MakeFillingPy::add(PyObject *args, PyObject *kwds)
}
getBRepOffsetAPI_MakeFillingPtr()->Add(edge, face, static_cast<GeomAbs_Shape>(order),
PyObject_IsTrue(isbound) ? Standard_True : Standard_False);
Base::asBoolean(isbound));
Py_Return;
}
catch (const Standard_Failure& e) {

View File

@@ -78,7 +78,7 @@ PyObject* BRepOffsetAPI_MakePipeShellPy::setFrenetMode(PyObject *args)
return nullptr;
try {
this->getBRepOffsetAPI_MakePipeShellPtr()->SetMode(PyObject_IsTrue(obj) ? Standard_True : Standard_False);
this->getBRepOffsetAPI_MakePipeShellPtr()->SetMode(Base::asBoolean(obj));
Py_Return;
}
catch (Standard_Failure& e) {
@@ -169,7 +169,7 @@ PyObject* BRepOffsetAPI_MakePipeShellPy::setAuxiliarySpine(PyObject *args)
}
this->getBRepOffsetAPI_MakePipeShellPtr()->SetMode(
TopoDS::Wire(s),
PyObject_IsTrue(curv) ? Standard_True : Standard_False,
Base::asBoolean(curv),
typeOfCantact);
Py_Return;
}
@@ -189,9 +189,7 @@ PyObject* BRepOffsetAPI_MakePipeShellPy::add(PyObject *args, PyObject *kwds)
,&PyBool_Type,&keep)) {
try {
const TopoDS_Shape& s = static_cast<Part::TopoShapePy*>(prof)->getTopoShapePtr()->getShape();
this->getBRepOffsetAPI_MakePipeShellPtr()->Add(s,
PyObject_IsTrue(curv) ? Standard_True : Standard_False,
PyObject_IsTrue(keep) ? Standard_True : Standard_False);
this->getBRepOffsetAPI_MakePipeShellPtr()->Add(s, Base::asBoolean(curv), Base::asBoolean(keep));
Py_Return;
}
catch (Standard_Failure& e) {
@@ -211,9 +209,7 @@ PyObject* BRepOffsetAPI_MakePipeShellPy::add(PyObject *args, PyObject *kwds)
try {
const TopoDS_Shape& s = static_cast<Part::TopoShapePy*>(prof)->getTopoShapePtr()->getShape();
const TopoDS_Vertex& v = TopoDS::Vertex(static_cast<Part::TopoShapePy*>(loc)->getTopoShapePtr()->getShape());
this->getBRepOffsetAPI_MakePipeShellPtr()->Add(s, v,
PyObject_IsTrue(curv) ? Standard_True : Standard_False,
PyObject_IsTrue(keep) ? Standard_True : Standard_False);
this->getBRepOffsetAPI_MakePipeShellPtr()->Add(s, v, Base::asBoolean(curv), Base::asBoolean(keep));
Py_Return;
}
catch (Standard_Failure& e) {
@@ -446,7 +442,7 @@ PyObject* BRepOffsetAPI_MakePipeShellPy::setForceApproxC1(PyObject *args)
return nullptr;
try {
this->getBRepOffsetAPI_MakePipeShellPtr()->SetForceApproxC1(PyObject_IsTrue(obj) ? Standard_True : Standard_False);
this->getBRepOffsetAPI_MakePipeShellPtr()->SetForceApproxC1(Base::asBoolean(obj));
Py_Return;
}
catch (Standard_Failure& e) {

View File

@@ -213,7 +213,7 @@ PyObject* BSplineCurvePy::insertKnot(PyObject * args)
try {
Handle(Geom_BSplineCurve) curve = Handle(Geom_BSplineCurve)::DownCast
(getGeometryPtr()->handle());
curve->InsertKnot(U,M,tol,PyObject_IsTrue(add) ? Standard_True : Standard_False);
curve->InsertKnot(U, M, tol, Base::asBoolean(add));
}
catch (Standard_Failure& e) {
PyErr_SetString(PartExceptionOCCError, e.GetMessageString());
@@ -252,7 +252,7 @@ PyObject* BSplineCurvePy::insertKnots(PyObject * args)
Handle(Geom_BSplineCurve) curve = Handle(Geom_BSplineCurve)::DownCast
(getGeometryPtr()->handle());
curve->InsertKnots(k,m,tol,PyObject_IsTrue(add) ? Standard_True : Standard_False);
curve->InsertKnots(k, m, tol, Base::asBoolean(add));
Py_Return;
}
catch (Standard_Failure& e) {
@@ -1044,19 +1044,18 @@ PyObject* BSplineCurvePy::interpolate(PyObject *args, PyObject *kwds)
std::unique_ptr<GeomAPI_Interpolate> aBSplineInterpolation;
if (parameters.IsNull()) {
aBSplineInterpolation.reset(new GeomAPI_Interpolate(interpolationPoints,
PyObject_IsTrue(periodic) ? Standard_True : Standard_False, tol3d));
Base::asBoolean(periodic), tol3d));
}
else {
aBSplineInterpolation.reset(new GeomAPI_Interpolate(interpolationPoints, parameters,
PyObject_IsTrue(periodic) ? Standard_True : Standard_False, tol3d));
Base::asBoolean(periodic), tol3d));
}
if (t1 && t2) {
Base::Vector3d v1 = Py::Vector(t1,false).toVector();
Base::Vector3d v2 = Py::Vector(t2,false).toVector();
gp_Vec initTangent(v1.x,v1.y,v1.z), finalTangent(v2.x,v2.y,v2.z);
aBSplineInterpolation->Load(initTangent, finalTangent, PyObject_IsTrue(scale)
? Standard_True : Standard_False);
aBSplineInterpolation->Load(initTangent, finalTangent, Base::asBoolean(scale));
}
else if (ts && fl) {
Py::Sequence tlist(ts);
@@ -1076,8 +1075,7 @@ PyObject* BSplineCurvePy::interpolate(PyObject *args, PyObject *kwds)
tangentFlags->SetValue(findex++, static_cast<bool>(flag) ? Standard_True : Standard_False);
}
aBSplineInterpolation->Load(tangents, tangentFlags, PyObject_IsTrue(scale)
? Standard_True : Standard_False);
aBSplineInterpolation->Load(tangents, tangentFlags, Base::asBoolean(scale));
}
aBSplineInterpolation->Perform();
@@ -1120,10 +1118,10 @@ PyObject* BSplineCurvePy::buildFromPoles(PyObject *args)
if (poles.Length() <= degree)
degree = poles.Length()-1;
if (PyObject_IsTrue(periodic) ? true : false) {
if (Base::asBoolean(periodic)) {
int mult;
int len;
if (PyObject_IsTrue(interpolate) ? true : false) {
if (Base::asBoolean(interpolate)) {
mult = degree;
len = poles.Length() - mult + 2;
}
@@ -1227,7 +1225,7 @@ PyObject* BSplineCurvePy::buildFromPolesMultsKnots(PyObject *args, PyObject *key
else {
if (knots != Py_None) { number_of_knots = PyObject_Length(knots); }
else { //guess number of knots
if (PyObject_IsTrue(periodic) ? true : false) {
if (Base::asBoolean(periodic)) {
if (number_of_poles < degree) {degree = number_of_poles+1;}
number_of_knots = number_of_poles+1;
}
@@ -1302,15 +1300,14 @@ PyObject* BSplineCurvePy::buildFromPolesMultsKnots(PyObject *args, PyObject *key
}
}
// check if the number of poles matches the sum of mults
if (((PyObject_IsTrue(periodic) ? true : false) && sum_of_mults != number_of_poles) ||
if ((Base::asBoolean(periodic) && sum_of_mults != number_of_poles) ||
((PyObject_Not(periodic) ? true : false) && sum_of_mults - degree -1 != number_of_poles)) {
Standard_Failure::Raise("number of poles and sum of mults mismatch");
return(nullptr);
}
Handle(Geom_BSplineCurve) spline = new Geom_BSplineCurve(occpoles,occweights,occknots,occmults,degree,
PyObject_IsTrue(periodic) ? Standard_True : Standard_False,
PyObject_IsTrue(CheckRational) ? Standard_True : Standard_False);
Base::asBoolean(periodic), Base::asBoolean(CheckRational));
if (!spline.IsNull()) {
this->getGeomBSplineCurvePtr()->setHandle(spline);
Py_Return;

View File

@@ -247,7 +247,7 @@ PyObject* BSplineSurfacePy::insertUKnot(PyObject *args)
try {
Handle(Geom_BSplineSurface) surf = Handle(Geom_BSplineSurface)::DownCast
(getGeometryPtr()->handle());
surf->InsertUKnot(U,M,tol,PyObject_IsTrue(add) ? Standard_True : Standard_False);
surf->InsertUKnot(U, M, tol, Base::asBoolean(add));
}
catch (Standard_Failure& e) {
PyErr_SetString(PartExceptionOCCError, e.GetMessageString());
@@ -286,7 +286,7 @@ PyObject* BSplineSurfacePy::insertUKnots(PyObject *args)
Handle(Geom_BSplineSurface) surf = Handle(Geom_BSplineSurface)::DownCast
(getGeometryPtr()->handle());
surf->InsertUKnots(k,m,tol,PyObject_IsTrue(add) ? Standard_True : Standard_False);
surf->InsertUKnots(k, m, tol, Base::asBoolean(add));
Py_Return;
}
catch (Standard_Failure& e) {
@@ -308,7 +308,7 @@ PyObject* BSplineSurfacePy::insertVKnot(PyObject *args)
try {
Handle(Geom_BSplineSurface) surf = Handle(Geom_BSplineSurface)::DownCast
(getGeometryPtr()->handle());
surf->InsertVKnot(V,M,tol,PyObject_IsTrue(add) ? Standard_True : Standard_False);
surf->InsertVKnot(V, M, tol, Base::asBoolean(add));
}
catch (Standard_Failure& e) {
PyErr_SetString(PartExceptionOCCError, e.GetMessageString());
@@ -347,7 +347,7 @@ PyObject* BSplineSurfacePy::insertVKnots(PyObject *args)
Handle(Geom_BSplineSurface) surf = Handle(Geom_BSplineSurface)::DownCast
(getGeometryPtr()->handle());
surf->InsertVKnots(k,m,tol,PyObject_IsTrue(add) ? Standard_True : Standard_False);
surf->InsertVKnots(k, m, tol, Base::asBoolean(add));
Py_Return;
}
catch (Standard_Failure& e) {
@@ -1453,9 +1453,9 @@ PyObject* BSplineSurfacePy::buildFromPolesMultsKnots(PyObject *args, PyObject *k
occvknots.SetValue(i,(double)(i-1)/(occvknots.Length()-1));
}
}
if (((PyObject_IsTrue(uperiodic) ? true : false) && sum_of_umults != lu) ||
if ((Base::asBoolean(uperiodic) && sum_of_umults != lu) ||
((PyObject_Not(uperiodic) ? true : false) && sum_of_umults - udegree -1 != lu) ||
((PyObject_IsTrue(vperiodic) ? true : false) && sum_of_vmults != lv) ||
(Base::asBoolean(vperiodic) && sum_of_vmults != lv) ||
((PyObject_Not(vperiodic) ? true : false) && sum_of_vmults - vdegree -1 != lv)) {
Standard_Failure::Raise("number of poles and sum of mults mismatch");
}
@@ -1473,8 +1473,8 @@ PyObject* BSplineSurfacePy::buildFromPolesMultsKnots(PyObject *args, PyObject *k
Handle(Geom_BSplineSurface) spline = new Geom_BSplineSurface(occpoles,occweights,
occuknots,occvknots,occumults,occvmults,udegree,vdegree,
PyObject_IsTrue(uperiodic) ? Standard_True : Standard_False,
PyObject_IsTrue(vperiodic) ? Standard_True : Standard_False);
Base::asBoolean(uperiodic),
Base::asBoolean(vperiodic));
if (!spline.IsNull()) {
this->getGeomBSplineSurfacePtr()->setHandle(spline);
Py_Return;
@@ -1534,7 +1534,7 @@ PyObject* BSplineSurfacePy::buildFromNSections(PyObject *args)
}
GeomFill_NSections fillOp(curveSeq);
if (PyObject_IsTrue(refSurf) ? true : false) {
if (Base::asBoolean(refSurf)) {
Handle(Geom_BSplineSurface) ref = Handle(Geom_BSplineSurface)::DownCast
(getGeometryPtr()->handle());
fillOp.SetSurface(ref);

View File

@@ -62,7 +62,7 @@ int ArcOfCircle2dPy::PyInit(PyObject* args, PyObject* /*kwds*/)
try {
Handle(Geom2d_Circle) circle = Handle(Geom2d_Circle)::DownCast
(static_cast<Circle2dPy*>(o)->getGeom2dCirclePtr()->handle());
GCE2d_MakeArcOfCircle arc(circle->Circ2d(), u1, u2, PyObject_IsTrue(sense) ? Standard_True : Standard_False);
GCE2d_MakeArcOfCircle arc(circle->Circ2d(), u1, u2, Base::asBoolean(sense));
if (!arc.IsDone()) {
PyErr_SetString(PartExceptionOCCError, gce_ErrorStatusText(arc.Status()));
return -1;

View File

@@ -60,7 +60,7 @@ int ArcOfEllipse2dPy::PyInit(PyObject* args, PyObject* /*kwds*/)
try {
Handle(Geom2d_Ellipse) ellipse = Handle(Geom2d_Ellipse)::DownCast
(static_cast<Ellipse2dPy*>(o)->getGeom2dEllipsePtr()->handle());
GCE2d_MakeArcOfEllipse arc(ellipse->Elips2d(), u1, u2, PyObject_IsTrue(sense) ? Standard_True : Standard_False);
GCE2d_MakeArcOfEllipse arc(ellipse->Elips2d(), u1, u2, Base::asBoolean(sense));
if (!arc.IsDone()) {
PyErr_SetString(PartExceptionOCCError, gce_ErrorStatusText(arc.Status()));
return -1;

View File

@@ -60,7 +60,7 @@ int ArcOfHyperbola2dPy::PyInit(PyObject* args, PyObject* /*kwds*/)
try {
Handle(Geom2d_Hyperbola) hyperbola = Handle(Geom2d_Hyperbola)::DownCast
(static_cast<Hyperbola2dPy*>(o)->getGeom2dHyperbolaPtr()->handle());
GCE2d_MakeArcOfHyperbola arc(hyperbola->Hypr2d(), u1, u2, PyObject_IsTrue(sense) ? Standard_True : Standard_False);
GCE2d_MakeArcOfHyperbola arc(hyperbola->Hypr2d(), u1, u2, Base::asBoolean(sense));
if (!arc.IsDone()) {
PyErr_SetString(PartExceptionOCCError, gce_ErrorStatusText(arc.Status()));
return -1;

View File

@@ -60,7 +60,7 @@ int ArcOfParabola2dPy::PyInit(PyObject* args, PyObject* /*kwds*/)
try {
Handle(Geom2d_Parabola) parabola = Handle(Geom2d_Parabola)::DownCast
(static_cast<Parabola2dPy*>(o)->getGeom2dParabolaPtr()->handle());
GCE2d_MakeArcOfParabola arc(parabola->Parab2d(), u1, u2, PyObject_IsTrue(sense) ? Standard_True : Standard_False);
GCE2d_MakeArcOfParabola arc(parabola->Parab2d(), u1, u2, Base::asBoolean(sense));
if (!arc.IsDone()) {
PyErr_SetString(PartExceptionOCCError, gce_ErrorStatusText(arc.Status()));
return -1;

View File

@@ -212,7 +212,7 @@ PyObject* BSplineCurve2dPy::insertKnots(PyObject * args)
Handle(Geom2d_BSplineCurve) curve = Handle(Geom2d_BSplineCurve)::DownCast
(getGeometry2dPtr()->handle());
curve->InsertKnots(k,m,tol,PyObject_IsTrue(add) ? Standard_True : Standard_False);
curve->InsertKnots(k, m, tol, Base::asBoolean(add));
Py_Return;
}
catch (Standard_Failure& e) {
@@ -950,11 +950,11 @@ PyObject* BSplineCurve2dPy::interpolate(PyObject *args, PyObject *kwds)
std::unique_ptr<Geom2dAPI_Interpolate> aBSplineInterpolation;
if (parameters.IsNull()) {
aBSplineInterpolation.reset(new Geom2dAPI_Interpolate(interpolationPoints,
PyObject_IsTrue(periodic) ? Standard_True : Standard_False, tol3d));
Base::asBoolean(periodic), tol3d));
}
else {
aBSplineInterpolation.reset(new Geom2dAPI_Interpolate(interpolationPoints, parameters,
PyObject_IsTrue(periodic) ? Standard_True : Standard_False, tol3d));
Base::asBoolean(periodic), tol3d));
}
if (t1 && t2) {
@@ -1022,10 +1022,10 @@ PyObject* BSplineCurve2dPy::buildFromPoles(PyObject *args)
if (poles.Length() <= degree)
degree = poles.Length()-1;
if (PyObject_IsTrue(periodic) ? true : false) {
if (Base::asBoolean(periodic)) {
int mult;
int len;
if (PyObject_IsTrue(interpolate) ? true : false) {
if (Base::asBoolean(interpolate)) {
mult = degree;
len = poles.Length() - mult + 2;
}
@@ -1126,7 +1126,7 @@ PyObject* BSplineCurve2dPy::buildFromPolesMultsKnots(PyObject *args, PyObject *k
else {
if (knots != Py_None) { number_of_knots = PyObject_Length(knots); }
else { //guess number of knots
if (PyObject_IsTrue(periodic) ? true : false) {
if (Base::asBoolean(periodic)) {
if (number_of_poles < degree) {degree = number_of_poles+1;}
number_of_knots = number_of_poles+1;
}
@@ -1193,14 +1193,14 @@ PyObject* BSplineCurve2dPy::buildFromPolesMultsKnots(PyObject *args, PyObject *k
}
}
// check if the number of poles matches the sum of mults
if (((PyObject_IsTrue(periodic) ? true : false) && sum_of_mults != number_of_poles) ||
if (((Base::asBoolean(periodic)) && sum_of_mults != number_of_poles) ||
((PyObject_Not(periodic) ? true : false) && sum_of_mults - degree -1 != number_of_poles)) {
Standard_Failure::Raise("number of poles and sum of mults mismatch");
return(nullptr);
}
Handle(Geom2d_BSplineCurve) spline = new Geom2d_BSplineCurve(occpoles,occweights,occknots,occmults,degree,
PyObject_IsTrue(periodic) ? Standard_True : Standard_False);
Handle(Geom2d_BSplineCurve) spline = new Geom2d_BSplineCurve(occpoles, occweights, occknots,
occmults, degree, Base::asBoolean(periodic));
if (!spline.IsNull()) {
this->getGeom2dBSplineCurvePtr()->setHandle(spline);
Py_Return;

View File

@@ -103,7 +103,7 @@ int BuildPlateSurfacePy::PyInit(PyObject* args, PyObject* kwds)
try {
std::unique_ptr<GeomPlate_BuildPlateSurface> ptr(new GeomPlate_BuildPlateSurface
(degree, nbPtsOnCur, nbIter, tol2d, tol3d, tolAng, tolCurv,
PyObject_IsTrue(anisotropy) ? Standard_True : Standard_False));
Base::asBoolean(anisotropy)));
if (surf) {
GeomSurface* surface = static_cast<GeometrySurfacePy*>(surf)->getGeomSurfacePtr();

View File

@@ -1688,8 +1688,8 @@ void GeomBSplineCurve::Restore(Base::XMLReader& reader)
// Handle(Geom_BSplineCurve) spline = new
// Geom_BSplineCurve(occpoles,occweights,occknots,occmults,degree,
// PyObject_IsTrue(periodic) ? Standard_True : Standard_False,
// PyObject_IsTrue(CheckRational) ? Standard_True : Standard_False);
// Base::asBoolean(periodic),
// Base::asBoolean(CheckRational));
TColgp_Array1OfPnt p(1,polescount);
TColStd_Array1OfReal w(1,polescount);

View File

@@ -62,14 +62,14 @@ int GeometryBoolExtensionPy::PyInit(PyObject* args, PyObject* /*kwd*/)
PyErr_Clear();
PyObject* val;
if (PyArg_ParseTuple(args, "O!", &PyBool_Type, &val)) {
this->getGeometryBoolExtensionPtr()->setValue(PyObject_IsTrue(val) ? true : false);
this->getGeometryBoolExtensionPtr()->setValue(Base::asBoolean(val));
return 0;
}
PyErr_Clear();
char * pystr;
if (PyArg_ParseTuple(args, "O!s", &PyBool_Type, &val, &pystr)) {
this->getGeometryBoolExtensionPtr()->setValue(PyObject_IsTrue(val) ? true : false);
this->getGeometryBoolExtensionPtr()->setValue(Base::asBoolean(val));
this->getGeometryBoolExtensionPtr()->setName(pystr);
return 0;
}

View File

@@ -925,8 +925,8 @@ PyObject* GeometryCurvePy::continuityWith(PyObject *args)
if (u2 < 0.0)
u2 = c2->FirstParameter();
Standard_Boolean r1 = PyObject_IsTrue(rev1) ? Standard_True : Standard_False;
Standard_Boolean r2 = PyObject_IsTrue(rev2) ? Standard_True : Standard_False;
Standard_Boolean r1 = Base::asBoolean(rev1);
Standard_Boolean r2 = Base::asBoolean(rev2);
try {
if (!c1.IsNull() && !c2.IsNull()) {

View File

@@ -143,7 +143,7 @@ PyObject* GeometrySurfacePy::toShell(PyObject *args, PyObject* kwds)
try {
if (!s.IsNull()) {
if (segm) {
Standard_Boolean segment = PyObject_IsTrue(segm) ? Standard_True : Standard_False;
Standard_Boolean segment = Base::asBoolean(segm);
BRepBuilderAPI_MakeShell mkBuilder(s, segment);
TopoDS_Shape sh = mkBuilder.Shape();
return new TopoShapeShellPy(new TopoShape(sh));

View File

@@ -252,14 +252,12 @@ PyObject* HLRToShapePy::compoundOfEdges(PyObject *args, PyObject *kwds)
if (shape) {
TopoDS_Shape input = static_cast<TopoShapePy*>(shape)->getTopoShapePtr()->getShape();
TopoDS_Shape result = getHLRBRep_HLRToShapePtr()->CompoundOfEdges(input, static_cast<HLRBRep_TypeOfResultingEdge>(type),
PyObject_IsTrue(visible) ? Standard_True : Standard_False,
PyObject_IsTrue(in3d) ? Standard_True : Standard_False);
Base::asBoolean(visible), Base::asBoolean(in3d));
return new TopoShapePy(new TopoShape(result));
}
else {
TopoDS_Shape result = getHLRBRep_HLRToShapePtr()->CompoundOfEdges(static_cast<HLRBRep_TypeOfResultingEdge>(type),
PyObject_IsTrue(visible) ? Standard_True : Standard_False,
PyObject_IsTrue(in3d) ? Standard_True : Standard_False);
Base::asBoolean(visible), Base::asBoolean(in3d));
return new TopoShapePy(new TopoShape(result));
}
}

View File

@@ -94,7 +94,7 @@ int PlateSurfacePy::PyInit(PyObject* args, PyObject* kwds)
try {
GeomPlate_BuildPlateSurface buildPlate(Degree, NbPtsOnCur, NbIter, Tol2d, Tol3d, TolAng, TolCurv,
PyObject_IsTrue(Anisotropie) ? Standard_True : Standard_False);
Base::asBoolean(Anisotropie));
if (!surf.IsNull()) {
buildPlate.LoadInitSurface(surf);

View File

@@ -59,8 +59,8 @@ int RectangularTrimmedSurfacePy::PyInit(PyObject* args, PyObject* /*kwd*/)
Handle(Geom_Surface)::DownCast(static_cast<GeometrySurfacePy*>(surf)->
getGeomSurfacePtr()->handle()),
u1, u2, v1, v2,
PyObject_IsTrue(usense) ? Standard_True : Standard_False,
PyObject_IsTrue(vsense) ? Standard_True : Standard_False
Base::asBoolean(usense),
Base::asBoolean(vsense)
));
return 0;
}
@@ -70,8 +70,8 @@ int RectangularTrimmedSurfacePy::PyInit(PyObject* args, PyObject* /*kwd*/)
PyObject *utrim=Py_False, *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 = PyObject_IsTrue(utrim) ? Standard_True : Standard_False;
Standard_Boolean Sense = PyObject_IsTrue(sense) ? Standard_True : Standard_False;
Standard_Boolean UTrim = Base::asBoolean(utrim);
Standard_Boolean Sense = Base::asBoolean(sense);
getGeomTrimmedSurfacePtr()->setHandle(new Geom_RectangularTrimmedSurface(
Handle(Geom_Surface)::DownCast(static_cast<GeometrySurfacePy*>(surf)->
getGeomSurfacePtr()->handle()),

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) {

View File

@@ -62,9 +62,9 @@ int UnifySameDomainPy::PyInit(PyObject* args, PyObject* kwds)
try {
TopoDS_Shape shp = static_cast<TopoShapePy*>(shape)->getTopoShapePtr()->getShape();
std::unique_ptr<ShapeUpgrade_UnifySameDomain> ptr(new ShapeUpgrade_UnifySameDomain(shp,
PyObject_IsTrue(unifyEdges) ? Standard_True : Standard_False,
PyObject_IsTrue(unifyFaces) ? Standard_True : Standard_False,
PyObject_IsTrue(concatBSpl) ? Standard_True : Standard_False));
Base::asBoolean(unifyEdges),
Base::asBoolean(unifyFaces),
Base::asBoolean(concatBSpl)));
setTwinPointer(ptr.release());
return 0;
@@ -93,9 +93,9 @@ PyObject* UnifySameDomainPy::initialize(PyObject *args, PyObject* kwds)
try {
TopoDS_Shape shp = static_cast<TopoShapePy*>(shape)->getTopoShapePtr()->getShape();
getShapeUpgrade_UnifySameDomainPtr()->Initialize(shp,
PyObject_IsTrue(unifyEdges) ? Standard_True : Standard_False,
PyObject_IsTrue(unifyFaces) ? Standard_True : Standard_False,
PyObject_IsTrue(concatBSpl) ? Standard_True : Standard_False);
Base::asBoolean(unifyEdges),
Base::asBoolean(unifyFaces),
Base::asBoolean(concatBSpl));
Py_Return;
}
@@ -118,7 +118,7 @@ PyObject* UnifySameDomainPy::allowInternalEdges(PyObject *args)
return nullptr;
try {
getShapeUpgrade_UnifySameDomainPtr()->AllowInternalEdges(PyObject_IsTrue(allow) ? Standard_True : Standard_False);
getShapeUpgrade_UnifySameDomainPtr()->AllowInternalEdges(Base::asBoolean(allow));
Py_Return;
}
catch (const Standard_Failure& e) {
@@ -174,7 +174,7 @@ PyObject* UnifySameDomainPy::setSafeInputMode(PyObject *args)
return nullptr;
try {
getShapeUpgrade_UnifySameDomainPtr()->SetSafeInputMode(PyObject_IsTrue(mode) ? Standard_True : Standard_False);
getShapeUpgrade_UnifySameDomainPtr()->SetSafeInputMode(Base::asBoolean(mode));
Py_Return;
}
catch (const Standard_Failure& e) {

View File

@@ -135,7 +135,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, PyObject_IsTrue(shared) ? Standard_True : Standard_False, hWires);
ShapeAnalysis_FreeBounds::ConnectEdgesToWires(hEdges, tol, Base::asBoolean(shared), hWires);
TopoDS_Compound comp;
BRep_Builder builder;

View File

@@ -722,7 +722,7 @@ PyObject* TopoShapeEdgePy::firstVertex(PyObject *args)
if (!PyArg_ParseTuple(args, "|O!", &PyBool_Type, &orient))
return nullptr;
const TopoDS_Edge& e = TopoDS::Edge(getTopoShapePtr()->getShape());
TopoDS_Vertex v = TopExp::FirstVertex(e, PyObject_IsTrue(orient) ? Standard_True : Standard_False);
TopoDS_Vertex v = TopExp::FirstVertex(e, Base::asBoolean(orient));
return new TopoShapeVertexPy(new TopoShape(v));
}
@@ -732,7 +732,7 @@ PyObject* TopoShapeEdgePy::lastVertex(PyObject *args)
if (!PyArg_ParseTuple(args, "|O!", &PyBool_Type, &orient))
return nullptr;
const TopoDS_Edge& e = TopoDS::Edge(getTopoShapePtr()->getShape());
TopoDS_Vertex v = TopExp::LastVertex(e, PyObject_IsTrue(orient) ? Standard_True : Standard_False);
TopoDS_Vertex v = TopExp::LastVertex(e, Base::asBoolean(orient));
return new TopoShapeVertexPy(new TopoShape(v));
}

View File

@@ -473,9 +473,9 @@ PyObject* TopoShapeFacePy::makeEvolved(PyObject *args, PyObject *kwds)
try {
BRepOffsetAPI_MakeEvolved evolved(spine, profile, joinType,
PyObject_IsTrue(AxeProf) ? Standard_True : Standard_False,
PyObject_IsTrue(Solid) ? Standard_True : Standard_False,
PyObject_IsTrue(ProfOnSpine) ? Standard_True : Standard_False,
Base::asBoolean(AxeProf),
Base::asBoolean(Solid),
Base::asBoolean(ProfOnSpine),
Tolerance);
TopoDS_Shape shape = evolved.Shape();
return Py::new_reference_to(shape2pyshape(shape));

View File

@@ -176,9 +176,7 @@ PyObject* TopoShapePy::copy(PyObject *args)
}
if (!shape.IsNull()) {
BRepBuilderAPI_Copy c(shape,
PyObject_IsTrue(copyGeom) ? Standard_True : Standard_False,
PyObject_IsTrue(copyMesh) ? Standard_True : Standard_False);
BRepBuilderAPI_Copy c(shape, Base::asBoolean(copyGeom), Base::asBoolean(copyMesh));
static_cast<TopoShapePy*>(cpy)->getTopoShapePtr()->setShape(c.Shape());
}
return cpy;
@@ -713,7 +711,7 @@ PyObject* TopoShapePy::check(PyObject *args)
if (!getTopoShapePtr()->getShape().IsNull()) {
std::stringstream str;
if (!getTopoShapePtr()->analyze(PyObject_IsTrue(runBopCheck) ? true : false, str)) {
if (!getTopoShapePtr()->analyze(Base::asBoolean(runBopCheck), str)) {
PyErr_SetString(PyExc_ValueError, str.str().c_str());
return nullptr;
}
@@ -929,7 +927,7 @@ PyObject* TopoShapePy::section(PyObject *args)
TopoDS_Shape shape = static_cast<TopoShapePy*>(pcObj)->getTopoShapePtr()->getShape();
try {
// Let's call algorithm computing a section operation:
TopoDS_Shape secShape = this->getTopoShapePtr()->section(shape,PyObject_IsTrue(approx) ? true : false);
TopoDS_Shape secShape = this->getTopoShapePtr()->section(shape, Base::asBoolean(approx));
return new TopoShapePy(new TopoShape(secShape));
}
catch (Standard_Failure& e) {
@@ -948,7 +946,7 @@ PyObject* TopoShapePy::section(PyObject *args)
std::vector<TopoDS_Shape> shapeVec;
shapeVec.push_back(static_cast<TopoShapePy*>(pcObj)->getTopoShapePtr()->getShape());
try {
TopoDS_Shape sectionShape = this->getTopoShapePtr()->section(shapeVec,tolerance,PyObject_IsTrue(approx) ? true : false);
TopoDS_Shape sectionShape = this->getTopoShapePtr()->section(shapeVec, tolerance, Base::asBoolean(approx));
return new TopoShapePy(new TopoShape(sectionShape));
}
catch (Standard_Failure& e) {
@@ -976,7 +974,7 @@ PyObject* TopoShapePy::section(PyObject *args)
}
}
try {
TopoDS_Shape multiSectionShape = this->getTopoShapePtr()->section(shapeVec,tolerance,PyObject_IsTrue(approx) ? true : false);
TopoDS_Shape multiSectionShape = this->getTopoShapePtr()->section(shapeVec, tolerance, Base::asBoolean(approx));
return new TopoShapePy(new TopoShape(multiSectionShape));
}
catch (Standard_Failure& e) {
@@ -1193,9 +1191,7 @@ PyObject* TopoShapePy::childShapes(PyObject *args)
PyErr_SetString(PyExc_ValueError, "Shape is null");
return nullptr;
}
TopoDS_Iterator it(shape,
PyObject_IsTrue(cumOri) ? Standard_True : Standard_False,
PyObject_IsTrue(cumLoc) ? Standard_True : Standard_False);
TopoDS_Iterator it(shape, Base::asBoolean(cumOri), Base::asBoolean(cumLoc));
Py::List list;
for (; it.More(); it.Next()) {
const TopoDS_Shape& aChild = it.Value();
@@ -1369,7 +1365,7 @@ PyObject* TopoShapePy::transformGeometry(PyObject *args)
try {
Base::Matrix4D mat = static_cast<Base::MatrixPy*>(obj)->value();
TopoDS_Shape shape = this->getTopoShapePtr()->transformGShape(mat, PyObject_IsTrue(cpy) ? true : false);
TopoDS_Shape shape = this->getTopoShapePtr()->transformGShape(mat, Base::asBoolean(cpy));
return new TopoShapePy(new TopoShape(shape));
}
catch (Standard_Failure& e) {
@@ -1388,8 +1384,7 @@ PyObject* TopoShapePy::transformShape(PyObject *args)
Base::Matrix4D mat = static_cast<Base::MatrixPy*>(obj)->value();
PY_TRY {
this->getTopoShapePtr()->transformShape(mat, PyObject_IsTrue(copy) ? true : false,
PyObject_IsTrue(checkScale) ? true : false);
this->getTopoShapePtr()->transformShape(mat, Base::asBoolean(copy), Base::asBoolean(checkScale));
return IncRef();
}
PY_CATCH_OCC
@@ -1410,7 +1405,7 @@ PyObject* TopoShapePy::transformed(PyObject *args, PyObject *keywds)
(void)op;
PY_TRY {
TopoShape s(*getTopoShapePtr());
s.transformShape(mat,PyObject_IsTrue(copy) ? true : false,PyObject_IsTrue(checkScale) ? true : false);
s.transformShape(mat,Base::asBoolean(copy), Base::asBoolean(checkScale));
return Py::new_reference_to(shape2pyshape(s));
}
PY_CATCH_OCC
@@ -1679,7 +1674,7 @@ PyObject* TopoShapePy::makeThickness(PyObject *args)
}
TopoDS_Shape shape = this->getTopoShapePtr()->makeThickSolid(facesToRemove, offset, tolerance,
PyObject_IsTrue(inter) ? true : false, PyObject_IsTrue(self_inter) ? true : false, offsetMode, join);
Base::asBoolean(inter), Base::asBoolean(self_inter), offsetMode, join);
return new TopoShapeSolidPy(new TopoShape(shape));
}
catch (Standard_Failure& e) {
@@ -1702,9 +1697,9 @@ PyObject* TopoShapePy::makeOffsetShape(PyObject *args, PyObject *keywds)
try {
TopoDS_Shape shape = this->getTopoShapePtr()->makeOffsetShape(offset, tolerance,
PyObject_IsTrue(inter) ? true : false,
PyObject_IsTrue(self_inter) ? true : false, offsetMode, join,
PyObject_IsTrue(fill) ? true : false);
Base::asBoolean(inter),
Base::asBoolean(self_inter), offsetMode, join,
Base::asBoolean(fill));
return new TopoShapePy(new TopoShape(shape));
}
catch (Standard_Failure& e) {
@@ -1727,9 +1722,7 @@ PyObject* TopoShapePy::makeOffset2D(PyObject *args, PyObject *keywds)
try {
TopoDS_Shape resultShape = this->getTopoShapePtr()->makeOffset2D(offset, join,
PyObject_IsTrue(fill) ? true : false,
PyObject_IsTrue(openResult) ? true : false,
PyObject_IsTrue(inter) ? true : false);
Base::asBoolean(fill), Base::asBoolean(openResult), Base::asBoolean(inter));
return new_reference_to(shape2pyshape(resultShape));
}
PY_CATCH_OCC;
@@ -1943,7 +1936,7 @@ PyObject* TopoShapePy::tessellate(PyObject *args)
try {
std::vector<Base::Vector3d> Points;
std::vector<Data::ComplexGeoData::Facet> Facets;
if (PyObject_IsTrue(ok) ? true : false)
if (Base::asBoolean(ok))
BRepTools::Clean(getTopoShapePtr()->getShape());
getTopoShapePtr()->getFaces(Points, Facets,tolerance);
Py::Tuple tuple(2);
@@ -2098,8 +2091,7 @@ PyObject* TopoShapePy::reflectLines(PyObject *args, PyObject *kwds)
HLRAppli_ReflectLines reflect(shape);
reflect.SetAxes(v.x, v.y, v.z, p.x, p.y, p.z, u.x, u.y, u.z);
reflect.Perform();
TopoDS_Shape lines = reflect.GetCompoundOf3dEdges(t, PyObject_IsTrue(vis) ? Standard_True : Standard_False,
PyObject_IsTrue(in3d) ? Standard_True : Standard_False);
TopoDS_Shape lines = reflect.GetCompoundOf3dEdges(t, Base::asBoolean(vis), Base::asBoolean(in3d));
return new TopoShapePy(new TopoShape(lines));
}
catch (Standard_Failure& e) {
@@ -2137,7 +2129,7 @@ PyObject* TopoShapePy::makeShapeFromMesh(PyObject *args)
}
getTopoShapePtr()->setFaces(Points, Facets, tolerance);
if (PyObject_IsTrue(sewShape) ? true : false)
if (Base::asBoolean(sewShape))
getTopoShapePtr()->sewShape(tolerance);
Py_Return;
@@ -2210,7 +2202,7 @@ PyObject* TopoShapePy::isInside(PyObject *args)
solidClassifier.Perform(vertex, tolerance);
Standard_Boolean test = (solidClassifier.State() == stateIn);
if ((PyObject_IsTrue(checkFace) ? true : false) && (solidClassifier.IsOnAFace()))
if (Base::asBoolean(checkFace) && solidClassifier.IsOnAFace())
test = Standard_True;
return Py_BuildValue("O", (test ? Py_True : Py_False));
}
@@ -2719,8 +2711,8 @@ PyObject* TopoShapePy::optimalBoundingBox(PyObject *args)
TopoDS_Shape shape = this->getTopoShapePtr()->getShape();
Bnd_Box bounds;
BRepBndLib::AddOptimal(shape, bounds,
PyObject_IsTrue(useT) ? Standard_True : Standard_False,
PyObject_IsTrue(useS) ? Standard_True : Standard_False);
Base::asBoolean(useT),
Base::asBoolean(useS));
bounds.SetGap(0.0);
Standard_Real xMin, yMin, zMin, xMax, yMax, zMax;
bounds.Get(xMin, yMin, zMin, xMax, yMax, zMax);

View File

@@ -287,9 +287,7 @@ PyObject* TopoShapeWirePy::makePipeShell(PyObject *args)
}
}
TopoDS_Shape shape = this->getTopoShapePtr()->makePipeShell(sections,
PyObject_IsTrue(make_solid) ? Standard_True : Standard_False,
PyObject_IsTrue(is_Frenet) ? Standard_True : Standard_False,
transition);
Base::asBoolean(make_solid), Base::asBoolean(is_Frenet), transition);
return new TopoShapePy(new TopoShape(shape));
}
catch (Standard_Failure& e) {
@@ -349,9 +347,9 @@ PyObject* TopoShapeWirePy::makeEvolved(PyObject *args, PyObject *kwds)
try {
BRepOffsetAPI_MakeEvolved evolved(spine, profile, joinType,
PyObject_IsTrue(AxeProf) ? Standard_True : Standard_False,
PyObject_IsTrue(Solid) ? Standard_True : Standard_False,
PyObject_IsTrue(ProfOnSpine) ? Standard_True : Standard_False,
Base::asBoolean(AxeProf),
Base::asBoolean(Solid),
Base::asBoolean(ProfOnSpine),
Tolerance);
TopoDS_Shape shape = evolved.Shape();
return Py::new_reference_to(shape2pyshape(shape));

View File

@@ -71,7 +71,7 @@ PyObject* BodyPy::insertObject(PyObject *args)
return nullptr;
}
bool after = PyObject_IsTrue(afterPy) ? true : false;
bool after = Base::asBoolean(afterPy);
Body* body = this->getBodyPtr();
try {

View File

@@ -52,10 +52,10 @@ PyObject* ViewProviderPy::setBodyMode(PyObject* args)
PyObject* b_mode;
if (!PyArg_ParseTuple(args, "O!", &PyBool_Type, &b_mode)) {
return nullptr;
};
}
PartDesignGui::ViewProvider* base = getViewProviderPtr();
base->setBodyMode(PyObject_IsTrue(b_mode) ? true : false);
base->setBodyMode(Base::asBoolean(b_mode));
return Py::new_reference_to(Py::None());
}
@@ -65,10 +65,10 @@ PyObject* ViewProviderPy::makeTemporaryVisible(PyObject* args)
PyObject* b_vis;
if (!PyArg_ParseTuple(args, "O!", &PyBool_Type, &b_vis)) {
return nullptr;
};
}
PartDesignGui::ViewProvider* base = getViewProviderPtr();
base->makeTemporaryVisible(PyObject_IsTrue(b_vis) ? true : false);
base->makeTemporaryVisible(Base::asBoolean(b_vis));
return Py::new_reference_to(Py::None());
}