Part.BSplineSurface.buildFromPolesMultsKnots(): Fix 'Truth value of an 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.
This commit is contained in:
@@ -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) {
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user