Revision: 14162
          
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=14162
Author:   campbellbarton
Date:     2008-03-18 14:42:38 +0100 (Tue, 18 Mar 2008)

Log Message:
-----------
patch from Paul Rotering (pryon)
[#7124] knot vector access for SurfNurb

Modified Paths:
--------------
    trunk/blender/source/blender/python/api2_2x/SurfNurb.c
    trunk/blender/source/blender/python/api2_2x/doc/Curve.py

Modified: trunk/blender/source/blender/python/api2_2x/SurfNurb.c
===================================================================
--- trunk/blender/source/blender/python/api2_2x/SurfNurb.c      2008-03-18 
10:55:07 UTC (rev 14161)
+++ trunk/blender/source/blender/python/api2_2x/SurfNurb.c      2008-03-18 
13:42:38 UTC (rev 14162)
@@ -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_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,8 +489,60 @@
        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
  *
  * create an iterator for our SurfNurb.
@@ -723,6 +777,15 @@
        {"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 */
 };
 

Modified: trunk/blender/source/blender/python/api2_2x/doc/Curve.py
===================================================================
--- trunk/blender/source/blender/python/api2_2x/doc/Curve.py    2008-03-18 
10:55:07 UTC (rev 14161)
+++ trunk/blender/source/blender/python/api2_2x/doc/Curve.py    2008-03-18 
13:42:38 UTC (rev 14162)
@@ -694,6 +694,10 @@
        @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 ):


_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to