Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2008-03-18 16:42:38 +0300
committerCampbell Barton <ideasman42@gmail.com>2008-03-18 16:42:38 +0300
commitb10726a2ad110e4ca710d047a3f737cfa18131ef (patch)
tree49300dd7efcb32a340585fb068fe1ddd7cfcc03e /source/blender/python/api2_2x/SurfNurb.c
parent65b0e6245d106fe9ecc83075e809c1912072df2f (diff)
patch from Paul Rotering (pryon)
[#7124] knot vector access for SurfNurb
Diffstat (limited to 'source/blender/python/api2_2x/SurfNurb.c')
-rw-r--r--source/blender/python/api2_2x/SurfNurb.c65
1 files changed, 64 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 */
};