Skip to content

Commit

Permalink
Part.BSplineSurface.buildFromPolesMultsKnots(): Fix 'Truth value of a…
Browse files Browse the repository at this point in the history
…n array ... use a.any() or a.all()' when explicit knots or weights provided

Calls to BSplineSurface.buildFromPolesMultsKnots() with explicit knots or weights fail in recent versions of FreeCAD (tested on 0.18.3 with python3) with the message 'The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()'. 

This trivial change follows the pattern used later in the function of explicit comparisons with Py_None, replacing PyObject_Not() and PyObject_IsTrue()  when they are used to determine whether explicit weights or knots have been provided.
  • Loading branch information
sdh4 authored and wwmayer committed Aug 27, 2019
1 parent efba264 commit 57ef3df
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/Mod/Part/App/BSplineSurfacePyImp.cpp
Expand Up @@ -1405,7 +1405,7 @@ PyObject* BSplineSurfacePy::buildFromPolesMultsKnots(PyObject *args, PyObject *k
Standard_Integer lv = col.size();
TColgp_Array2OfPnt occpoles(1, lu, 1, lv);
TColStd_Array2OfReal occweights(1, lu, 1, lv);
Standard_Boolean genweights = PyObject_Not(weights) ? Standard_True : Standard_False; //cache
Standard_Boolean genweights = (weights==Py_None) ? Standard_True : Standard_False; //cache
Standard_Integer index1 = 0;
Standard_Integer index2 = 0;
for (Py::Sequence::iterator it1 = list.begin(); it1 != list.end(); ++it1) {
Expand Down Expand Up @@ -1445,8 +1445,8 @@ PyObject* BSplineSurfacePy::buildFromPolesMultsKnots(PyObject *args, PyObject *k
}
number_of_uknots = PyObject_Length(umults);
number_of_vknots = PyObject_Length(vmults);
if ((PyObject_IsTrue(uknots) && PyObject_Length(uknots) != number_of_uknots) ||
(PyObject_IsTrue(vknots) && PyObject_Length(vknots) != number_of_vknots)){
if (((uknots != Py_None) && PyObject_Length(uknots) != number_of_uknots) ||
((vknots != Py_None) && PyObject_Length(vknots) != number_of_vknots)){
Standard_Failure::Raise("number of knots and mults mismatch");
return 0;
}
Expand Down

0 comments on commit 57ef3df

Please sign in to comment.