diff options
author | Campbell Barton <ideasman42@gmail.com> | 2008-03-18 16:42:38 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2008-03-18 16:42:38 +0300 |
commit | b10726a2ad110e4ca710d047a3f737cfa18131ef (patch) | |
tree | 49300dd7efcb32a340585fb068fe1ddd7cfcc03e /source/blender/python | |
parent | 65b0e6245d106fe9ecc83075e809c1912072df2f (diff) |
patch from Paul Rotering (pryon)
[#7124] knot vector access for SurfNurb
Diffstat (limited to 'source/blender/python')
-rw-r--r-- | source/blender/python/api2_2x/SurfNurb.c | 65 | ||||
-rw-r--r-- | source/blender/python/api2_2x/doc/Curve.py | 4 |
2 files changed, 68 insertions, 1 deletions
diff --git a/source/blender/python/api2_2x/SurfNurb.c b/source/blender/python/api2_2x/SurfNurb.c index 1d2e74a26a8..f1c038fc33c 100644 --- a/source/blender/python/api2_2x/SurfNurb.c +++ b/source/blender/python/api2_2x/SurfNurb.c @@ -1,5 +1,5 @@ /* - * $Id: SurfNurb.c 11400 2007-07-28 09:26:53Z campbellbarton $ + * $Id$ * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or @@ -46,6 +46,8 @@ static int SurfNurb_setPoint( BPy_SurfNurb * self, int index, PyObject * ob ); static int SurfNurb_length( PyInstanceObject * inst ); static PyObject *SurfNurb_getIter( BPy_SurfNurb * self ); static PyObject *SurfNurb_iterNext( BPy_SurfNurb * self ); +static PyObject *SurfNurb_getKnotsU( BPy_SurfNurb * self ); +static PyObject *SurfNurb_getKnotsV( BPy_SurfNurb * self ); PyObject *SurfNurb_append( BPy_SurfNurb * self, PyObject * args ); char M_SurfNurb_doc[] = "SurfNurb"; @@ -487,6 +489,58 @@ static int SurfNurb_setCyclicV( BPy_SurfNurb * self, PyObject * value ) return 0; } +/* + * SurfNurb_getKnotsU + * + * Returns surface's knotsU in a tuple. Empty tuple is returned if + * surface isn't Nurbs or it doesn't have knots in U + */ + +static PyObject *SurfNurb_getKnotsU( BPy_SurfNurb * self ) +{ + if(self->nurb->knotsu) { + int len = KNOTSU(self->nurb); + int i; + PyObject *knotsu = PyTuple_New(len); + if( !knotsu ) + return EXPP_ReturnPyObjError( PyExc_RuntimeError, + "could not get SurfNurb.knotsU attribute" ); + + for(i = 0; i < len; ++i) + PyTuple_SetItem(knotsu, i, + PyFloat_FromDouble(self->nurb->knotsu[i])); + + return knotsu; + } + return PyTuple_New(0); +} + +/* + * SurfNurb_getKnotsV + * + * Returns surface's knotsV in a tuple. Empty tuple is returned if + * curve doesn't have knots in V + */ + +static PyObject *SurfNurb_getKnotsV( BPy_SurfNurb * self ) +{ + if(self->nurb->knotsv) { + int len = KNOTSV(self->nurb); + int i; + PyObject *knotsv = PyTuple_New(len); + if( !knotsv ) + return EXPP_ReturnPyObjError( PyExc_RuntimeError, + "could not get SurfNurb.knotsV index" ); + + for(i = 0; i < len; ++i) + PyTuple_SetItem(knotsv, i, + PyFloat_FromDouble(self->nurb->knotsv[i] )); + + return knotsv; + } + return PyTuple_New(0); +} + /* * SurfNurb_getIter @@ -723,6 +777,15 @@ static PyGetSetDef BPy_SurfNurb_getseters[] = { {"orderV", (getter)SurfNurb_getOrderV, (setter)SurfNurb_setOrderV, "order setting for V direction", NULL}, + {"knotsU", + (getter)SurfNurb_getKnotsU, (setter)NULL, + "The The knot vector in the U direction", + NULL}, + {"knotsV", + (getter)SurfNurb_getKnotsV, (setter)NULL, + "The The knot vector in the V direction", + NULL}, + {NULL,NULL,NULL,NULL,NULL} /* Sentinel */ }; diff --git a/source/blender/python/api2_2x/doc/Curve.py b/source/blender/python/api2_2x/doc/Curve.py index c3760bc2c1d..ba8d6d21970 100644 --- a/source/blender/python/api2_2x/doc/Curve.py +++ b/source/blender/python/api2_2x/doc/Curve.py @@ -694,6 +694,10 @@ class SurfNurb: @ivar orderV: The order setting for the V direction. Values are clamped to the range [2:6] and not greater than the V dimension. @type orderV: int + @ivar knotsU: The The knot vector in the U direction + @type knotsU: tuple + @ivar knotsV: The The knot vector in the V direction + @type knotsV: tuple """ def __setitem__( n, point ): |