PyObject* BezierSurfacePy::getWeights(PyObject *args) { if (!PyArg_ParseTuple(args, "")) return 0; try { Handle_Geom_BezierSurface surf = Handle_Geom_BezierSurface::DownCast (getGeometryPtr()->handle()); TColStd_Array2OfReal w(1,surf->NbUPoles(),1,surf->NbVPoles()); surf->Weights(w); Py::List weights; for (Standard_Integer i=w.LowerRow(); i<=w.UpperRow(); i++) { Py::List row; for (Standard_Integer j=w.LowerCol(); j<=w.UpperCol(); j++) { row.append(Py::Float(w(i,j))); } weights.append(row); } return Py::new_reference_to(weights); } catch (Standard_Failure) { Handle_Standard_Failure e = Standard_Failure::Caught(); PyErr_SetString(PartExceptionOCCError, e->GetMessageString()); return 0; } }
PyObject* BezierSurfacePy::getPoles(PyObject *args) { if (!PyArg_ParseTuple(args, "")) return 0; try { Handle_Geom_BezierSurface surf = Handle_Geom_BezierSurface::DownCast (getGeometryPtr()->handle()); TColgp_Array2OfPnt p(1,surf->NbUPoles(),1,surf->NbVPoles()); surf->Poles(p); 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); row.append(Py::Object(new Base::VectorPy( Base::Vector3d(pole.X(),pole.Y(),pole.Z())))); } 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* BezierSurfacePy::getWeight(PyObject *args) { int uindex,vindex; if (!PyArg_ParseTuple(args, "ii",&uindex,&vindex)) return 0; try { Handle_Geom_BezierSurface surf = Handle_Geom_BezierSurface::DownCast (getGeometryPtr()->handle()); Standard_OutOfRange_Raise_if (uindex < 1 || uindex > surf->NbUPoles() || vindex < 1 || vindex > surf->NbVPoles(), "Weight index out of range"); double w = surf->Weight(uindex,vindex); return Py_BuildValue("d", w); } catch (Standard_Failure) { Handle_Standard_Failure e = Standard_Failure::Caught(); PyErr_SetString(PartExceptionOCCError, e->GetMessageString()); return 0; } }
PyObject* BezierSurfacePy::getPole(PyObject *args) { int uindex,vindex; if (!PyArg_ParseTuple(args, "ii",&uindex,&vindex)) return 0; try { Handle_Geom_BezierSurface surf = Handle_Geom_BezierSurface::DownCast (getGeometryPtr()->handle()); Standard_OutOfRange_Raise_if (uindex < 1 || uindex > surf->NbUPoles() || vindex < 1 || vindex > surf->NbVPoles(), "Pole index out of range"); gp_Pnt p = surf->Pole(uindex,vindex); return new Base::VectorPy(Base::Vector3d(p.X(),p.Y(),p.Z())); } catch (Standard_Failure) { Handle_Standard_Failure e = Standard_Failure::Caught(); PyErr_SetString(PartExceptionOCCError, e->GetMessageString()); return 0; } }
Py::Int BezierSurfacePy::getNbUPoles(void) const { Handle_Geom_BezierSurface surf = Handle_Geom_BezierSurface::DownCast (getGeometryPtr()->handle()); return Py::Int(surf->NbUPoles()); }