+ add method getPolesAndWeights() to NURBS surfaces and curves
This commit is contained in:
parent
814c144ecb
commit
fbdfeef2a3
|
@ -201,6 +201,11 @@ to the pole of index Index in the poles table.</UserDocu>
|
|||
<UserDocu>Get all weights of the B-Spline curve.</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Methode Name="getPolesAndWeights">
|
||||
<Documentation>
|
||||
<UserDocu>Returns the table of poles and weights in homogenous ccordinates.</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Methode Name="getResolution" Const="true">
|
||||
<Documentation>
|
||||
<UserDocu>Computes for this B-Spline curve the parametric tolerance (UTolerance)
|
||||
|
|
|
@ -435,6 +435,38 @@ PyObject* BSplineCurvePy::getPoles(PyObject * args)
|
|||
}
|
||||
}
|
||||
|
||||
PyObject* BSplineCurvePy::getPolesAndWeights(PyObject * args)
|
||||
{
|
||||
if (!PyArg_ParseTuple(args, ""))
|
||||
return 0;
|
||||
try {
|
||||
Handle_Geom_BSplineCurve curve = Handle_Geom_BSplineCurve::DownCast
|
||||
(getGeometryPtr()->handle());
|
||||
TColgp_Array1OfPnt p(1,curve->NbPoles());
|
||||
curve->Poles(p);
|
||||
TColStd_Array1OfReal w(1,curve->NbPoles());
|
||||
curve->Weights(w);
|
||||
|
||||
Py::List poles;
|
||||
for (Standard_Integer i=p.Lower(); i<=p.Upper(); i++) {
|
||||
gp_Pnt pnt = p(i);
|
||||
double weight = w(i);
|
||||
Py::Tuple t(4);
|
||||
t.setItem(0, Py::Float(pnt.X()));
|
||||
t.setItem(1, Py::Float(pnt.Y()));
|
||||
t.setItem(2, Py::Float(pnt.Z()));
|
||||
t.setItem(3, Py::Float(weight));
|
||||
poles.append(t);
|
||||
}
|
||||
return Py::new_reference_to(poles);
|
||||
}
|
||||
catch (Standard_Failure) {
|
||||
Handle_Standard_Failure e = Standard_Failure::Caught();
|
||||
PyErr_SetString(PartExceptionOCCError, e->GetMessageString());
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
PyObject* BSplineCurvePy::setWeight(PyObject * args)
|
||||
{
|
||||
int index;
|
||||
|
|
|
@ -491,6 +491,11 @@
|
|||
<UserDocu>Returns the table of weights of the poles for this B-Spline surface.</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Methode Name="getPolesAndWeights">
|
||||
<Documentation>
|
||||
<UserDocu>Returns the table of poles and weights in homogenous ccordinates.</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Methode Name="getResolution" Const="true">
|
||||
<Documentation>
|
||||
<UserDocu>
|
||||
|
|
|
@ -917,6 +917,42 @@ PyObject* BSplineSurfacePy::getWeights(PyObject *args)
|
|||
}
|
||||
}
|
||||
|
||||
PyObject* BSplineSurfacePy::getPolesAndWeights(PyObject *args)
|
||||
{
|
||||
if (!PyArg_ParseTuple(args, ""))
|
||||
return 0;
|
||||
try {
|
||||
Handle_Geom_BSplineSurface surf = Handle_Geom_BSplineSurface::DownCast
|
||||
(getGeometryPtr()->handle());
|
||||
TColgp_Array2OfPnt p(1,surf->NbUPoles(),1,surf->NbVPoles());
|
||||
surf->Poles(p);
|
||||
TColStd_Array2OfReal w(1,surf->NbUPoles(),1,surf->NbVPoles());
|
||||
surf->Weights(w);
|
||||
|
||||
Py::List poles;
|
||||
for (Standard_Integer i=p.LowerRow(); i<=p.UpperRow(); i++) {
|
||||
Py::List row;
|
||||
for (Standard_Integer j=p.LowerCol(); j<=p.UpperCol(); j++) {
|
||||
const gp_Pnt& pole = p(i,j);
|
||||
double weight = w(i,j);
|
||||
Py::Tuple t(4);
|
||||
t.setItem(0, Py::Float(pole.X()));
|
||||
t.setItem(1, Py::Float(pole.Y()));
|
||||
t.setItem(2, Py::Float(pole.Z()));
|
||||
t.setItem(3, Py::Float(weight));
|
||||
row.append(t);
|
||||
}
|
||||
poles.append(row);
|
||||
}
|
||||
return Py::new_reference_to(poles);
|
||||
}
|
||||
catch (Standard_Failure) {
|
||||
Handle_Standard_Failure e = Standard_Failure::Caught();
|
||||
PyErr_SetString(PartExceptionOCCError, e->GetMessageString());
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
PyObject* BSplineSurfacePy::getResolution(PyObject *args)
|
||||
{
|
||||
double tol;
|
||||
|
|
Loading…
Reference in New Issue
Block a user