diff options
author | Stephen Swaney <sswaney@centurytel.net> | 2004-07-22 01:01:15 +0400 |
---|---|---|
committer | Stephen Swaney <sswaney@centurytel.net> | 2004-07-22 01:01:15 +0400 |
commit | bce2c02fdd6ebaf88ffc0950e87de96b0b65377f (patch) | |
tree | 708d01a564f56cb729d8e536c8de15c70f7349dd /source/blender/python/api2_2x | |
parent | 1c5302e68b47c03fd60ab5edefb4a16d6294b7a7 (diff) |
New Curve method Curve.appendPoint( numcurve, newpoint ) to add
points to a Curve.
New supporting module CurNurb to provide access to the curves in a Curve
and their associated points.
Curve module now supports Python iterator and sequence protocols.
This allows typical python programming idioms using 'for' statement
and the [] operator.
# example 1
for curve in a_curve:
for point in curve:
print point
#example 2
curnurb = a_curve[0]
curnurb.append( [1,1,1,1] )
Still under construction. Epydoc will follow.
Diffstat (limited to 'source/blender/python/api2_2x')
-rw-r--r-- | source/blender/python/api2_2x/Blender.c | 4 | ||||
-rw-r--r-- | source/blender/python/api2_2x/CurNurb.c | 686 | ||||
-rw-r--r-- | source/blender/python/api2_2x/CurNurb.h | 11 | ||||
-rw-r--r-- | source/blender/python/api2_2x/Curve.c | 1716 | ||||
-rw-r--r-- | source/blender/python/api2_2x/Types.c | 9 | ||||
-rw-r--r-- | source/blender/python/api2_2x/Types.h | 4 | ||||
-rw-r--r-- | source/blender/python/api2_2x/bpy_types.h | 31 | ||||
-rw-r--r-- | source/blender/python/api2_2x/modules.h | 6 |
8 files changed, 1721 insertions, 746 deletions
diff --git a/source/blender/python/api2_2x/Blender.c b/source/blender/python/api2_2x/Blender.c index 749f4255715..1414c37e489 100644 --- a/source/blender/python/api2_2x/Blender.c +++ b/source/blender/python/api2_2x/Blender.c @@ -1,5 +1,5 @@ /* - * + * $Id$ * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or @@ -512,6 +512,8 @@ void M_Blender_Init (void) PyDict_SetItemString (dict, "Mathutils",Mathutils_Init()); PyDict_SetItemString (dict, "Library", Library_Init()); + PyDict_SetItemString (dict, "CurNurb", CurNurb_Init()); + PyModule_AddIntConstant(module, "TRUE", 1); PyModule_AddIntConstant(module, "FALSE", 0); } diff --git a/source/blender/python/api2_2x/CurNurb.c b/source/blender/python/api2_2x/CurNurb.c new file mode 100644 index 00000000000..cb233c4e5ee --- /dev/null +++ b/source/blender/python/api2_2x/CurNurb.c @@ -0,0 +1,686 @@ +/* + * $Id$ + * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. The Blender + * Foundation also sells licenses for use in proprietary software under + * the Blender License. See http://www.blender.org/BL/ for information + * about this. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. + * All rights reserved. + * + * This is a new part of Blender. + * + * Contributor(s): + * + * ***** END GPL/BL DUAL LICENSE BLOCK ***** + */ + +#include "Python.h" +#include "DNA_curve_types.h" +#include "BKE_curve.h" +#include "MEM_guardedalloc.h" +#include "bpy_types.h" +#include "modules.h" +#include "gen_utils.h" +#include "CurNurb.h" + + +/*------------------------------------------------------------- + +stuff in this section should be placed in bpy_types.h + +-----------------------------------------------------------*/ + + +/* + * forward declarations go here + */ + + +extern PyMethodDef BPy_CurNurb_methods[]; +PyObject *CurNurb_CreatePyObject( Nurb * blen_nurb ); +static PyObject *CurNurb_setMatIndex( BPy_CurNurb * self, PyObject * args ); +static PyObject *CurNurb_getMatIndex( BPy_CurNurb * self ); +/* static PyObject* CurNurb_setXXX( BPy_CurNurb* self, PyObject* args ); */ +PyObject* CurNurb_getPoint( BPy_CurNurb* self, int index ); +static int CurNurb_length( PyInstanceObject *inst); +static PyObject *CurNurb_getIter (BPy_CurNurb * self); +static PyObject *CurNurb_iterNext (BPy_CurNurb * self); +PyObject* CurNurb_append( BPy_CurNurb* self, PyObject* args ); +PyObject* CurNurb_pointAtIndex( Nurb* nurb, int index ); +static PyObject *CurNurb_isNurb( BPy_CurNurb* self ); + +char M_CurNurb_doc[] = "CurNurb"; + + +/* + CurNurb_Type callback function prototypes: +*/ + +static void CurNurb_dealloc( BPy_CurNurb * self ); +static int CurNurb_compare( BPy_CurNurb * a, BPy_CurNurb * b ); +static PyObject *CurNurb_getAttr( BPy_CurNurb * self, char *name ); +static int CurNurb_setAttr( BPy_CurNurb * self, char *name, PyObject * v ); +static PyObject *CurNurb_repr( BPy_CurNurb * self ); + + + + +void CurNurb_dealloc( BPy_CurNurb * self ) +{ + PyObject_DEL( self ); +} + + + +static PyObject *CurNurb_getAttr( BPy_CurNurb * self, char *name ) +{ + PyObject *attr = Py_None; + + if( strcmp( name, "mat_index" ) == 0 ) + attr = PyInt_FromLong( self->nurb->mat_nr ); + + else if( strcmp( name, "points" ) == 0 ) + attr = PyInt_FromLong( self->nurb->pntsu ); + + if( !attr ) + return EXPP_ReturnPyObjError( PyExc_MemoryError, + "couldn't create PyObject" ); + + /* member attribute found, return it */ + if( attr != Py_None ) + return attr; + + /* not an attribute, search the methods table */ + return Py_FindMethod( BPy_CurNurb_methods, ( PyObject * ) self, name ); +} + + +/* + setattr +*/ + +static int CurNurb_setAttr( BPy_CurNurb * self, char *name, PyObject * value ) +{ + PyObject *valtuple; + PyObject *error = NULL; + + /* make a tuple to pass to our type methods */ + valtuple = Py_BuildValue( "(O)", value ); + + if( !valtuple ) + return EXPP_ReturnIntError( PyExc_MemoryError, + "CurNurb.setAttr: cannot create pytuple" ); + + if( strcmp( name, "mat_index" ) == 0 ) + error = CurNurb_setMatIndex( self, valtuple ); + + else { /* error - no match for name */ + Py_DECREF( valtuple ); + + if( ( strcmp( name, "ZZZZ" ) == 0 ) || /* user tried to change a */ + ( strcmp( name, "ZZZZ" ) == 0 ) ) /* constant dict type ... */ + return EXPP_ReturnIntError( PyExc_AttributeError, + "constant dictionary -- cannot be changed" ); + else + return EXPP_ReturnIntError( PyExc_KeyError, + "attribute not found" ); + } + + + Py_DECREF( valtuple ); /* since it is not being returned */ + if( error != Py_None ) + return -1; + + Py_DECREF( Py_None ); + return 0; /* normal exit */ +} + +/* + compare + in this case, we consider two CurNurbs equal, if they point to the same + blender data. +*/ + +static int CurNurb_compare( BPy_CurNurb * a, BPy_CurNurb * b ) +{ + Nurb *pa = a->nurb; + Nurb *pb = b->nurb; + + return ( pa == pb ) ? 0 : -1; +} + + +/* + factory method to create a BPy_CurNurb from a Blender Nurb +*/ + +PyObject *CurNurb_CreatePyObject( Nurb * blen_nurb ) +{ + BPy_CurNurb *pyNurb; + + pyNurb = ( BPy_CurNurb * ) PyObject_NEW( BPy_CurNurb, &CurNurb_Type ); + + if( !pyNurb ) + return EXPP_ReturnPyObjError( PyExc_MemoryError, + "could not create BPy_CurNurb PyObject" ); + + pyNurb->nurb = blen_nurb; + return ( PyObject * ) pyNurb; +} + + +/* + * CurNurb_repr + */ +static PyObject *CurNurb_repr( BPy_CurNurb * self ) +{ /* used by 'repr' */ + + return PyString_FromFormat( "[CurNurb \"%d\"]", self->nurb->type ); +} + + +static PyObject *M_CurNurb_New( PyObject * self, PyObject * args ) +{ + return ( PyObject * ) 0; + +} + + + +/* + * CurNurb_append( point ) + * append a new point to a nurb curve. + * arg is BezTriple or list of xyzw floats + */ + +PyObject* CurNurb_append( BPy_CurNurb* self, PyObject* args ) +{ + Nurb* nurb = self->nurb; + + return CurNurb_appendPointToNurb( nurb, args ); +} + + + +/* + * CurNurb_appendPointToNurb + * this is a non-bpy utility func to add a point to a given nurb + */ + +PyObject* CurNurb_appendPointToNurb( Nurb* nurb, PyObject* args ) +{ + + int i; + int size; + PyObject* pyOb; + int npoints; + + /* + do we have a list of four floats or a BezTriple? + */ + PyArg_ParseTuple( args, "O", &pyOb ); + + if( BezTriple_CheckPyObject( pyOb )){ + BezTriple* tmp; + npoints = nurb->pntsu; + +/* printf("\ndbg: got a BezTriple\n"); */ + tmp = nurb->bezt; /* save old points */ + nurb->bezt = (BezTriple*)MEM_mallocN ( + sizeof(BezTriple) * (npoints + 1), "CurNurb_append2"); + + if( ! nurb->bezt ) + return( EXPP_ReturnPyObjError + (PyExc_MemoryError, "allocation failed")); + + /* copy old points to new */ + memmove( nurb->bezt, tmp, sizeof( BezTriple) * npoints ); + MEM_freeN( tmp ); + nurb->pntsu++; + /* add new point to end of list */ + memcpy( nurb->bezt + npoints, + BezTriple_FromPyObject( pyOb), + sizeof( BezTriple)); + + } else if( PySequence_Check( pyOb )) { + size = PySequence_Size( pyOb ); +/* printf("\ndbg: got a sequence of size %d\n", size ); */ + if( size == 4 ) { + BPoint* tmp; + npoints = nurb->pntsu; + + tmp = nurb->bp; /* save old pts */ + + nurb->bp =(BPoint*)MEM_mallocN ( sizeof (BPoint) * (npoints + 1), + "CurNurb_append1"); + if( ! nurb->bp ) + return( EXPP_ReturnPyObjError + (PyExc_MemoryError, "allocation failed")); + + memmove( nurb->bp, tmp, sizeof(BPoint) * npoints ); + MEM_freeN( tmp ); + + ++nurb->pntsu; + /* initialize new BPoint from old */ + memcpy( nurb->bp + npoints, nurb->bp, sizeof (BPoint)); + + for( i=0; i < 4; ++i){ + float tmpx = + (float) PyFloat_AsDouble + ( PySequence_GetItem ( pyOb, i)); + nurb->bp[npoints].vec[i] = tmpx; + + } + + makeknots(nurb, 1, nurb->flagu >> 1); + + }else if( size == 3 ){ /* 3 xyz coords */ + printf("\nNot Yet Implemented!\n"); + + } + + } else { + /* bail with error */ + return ( EXPP_ReturnPyObjError + ( PyExc_AttributeError, + "expected better stuff" ) ); + + } + + return (EXPP_incr_ret( Py_None )); +} + + +/* + * CurNurb_setMatIndex + * + * set index into material list + */ + +static PyObject *CurNurb_setMatIndex( BPy_CurNurb * self, PyObject * args ) +{ + int index; + + if( !PyArg_ParseTuple( args, "i", &( index ) ) ) + return ( EXPP_ReturnPyObjError + ( PyExc_AttributeError, + "expected integer argument" ) ); + + /* fixme: some range checking would be nice! */ + self->nurb->mat_nr = index; + + Py_INCREF( Py_None ); + return Py_None; +} + +/* + * CurNurb_getMatIndex + * + * returns index into material list + */ + +static PyObject *CurNurb_getMatIndex( BPy_CurNurb * self ) +{ + PyObject *index = PyInt_FromLong( ( long ) self->nurb->mat_nr ); + + if( index ) + return index; + + return ( EXPP_ReturnPyObjError( PyExc_RuntimeError, + "could not get material index" ) ); +} + + +/* + * CurNurb_getIter + * + * create an iterator for our CurNurb. + * this iterator returns the points for this CurNurb. + */ + +static PyObject *CurNurb_getIter (BPy_CurNurb * self) +{ + self->bp = self->nurb->bp; + self->bezt = self->nurb->bezt; + self->atEnd = 0; + self->nextPoint = 0; + + /* set exhausted flag if both bp and bezt are zero */ + if( (!self->bp) && (!self->bezt)) + self->atEnd = 1; + + Py_INCREF( self ); + return (PyObject*) self; +} + + + +static PyObject *CurNurb_iterNext( BPy_CurNurb * self ) +{ + PyObject *po; /* return value */ + Nurb *pnurb = self->nurb; + int npoints = pnurb->pntsu; + + /* are we at end already? */ + if( self->atEnd ) + return ( EXPP_ReturnPyObjError( PyExc_StopIteration, + "iterator at end" ) ); + + if( self->nextPoint < npoints ){ + + po = CurNurb_pointAtIndex( self->nurb, self->nextPoint); + self->nextPoint++; + + return po; + + } + else{ + self->atEnd = 1; /* set flag true */ + } + + return( EXPP_ReturnPyObjError( PyExc_StopIteration, + "iterator at end" ) ); +} + + + +/* + * CurNurb_isNurb() + * test whether spline nurb or bezier + */ + +static PyObject *CurNurb_isNurb( BPy_CurNurb* self ) +{ + /* NOTE: a Nurb has bp and bezt pointers + * depending on type. + * It is possible both are NULL if no points exist. + * in that case, we return False + */ + + if( self->nurb->bp ){ + Py_INCREF( Py_True ); + return Py_True; + } + else{ + Py_INCREF( Py_False ); + return( Py_False ); + } +} + + +/* + table of module methods + these are the equivalent of class or static methods. + you do not need an object instance to call one. + +*/ + +static PyMethodDef M_CurNurb_methods[] = { +/* name, method, flags, doc_string */ + {"New", ( PyCFunction ) M_CurNurb_New, METH_VARARGS | METH_KEYWORDS, + " () - doc string"}, +/* {"Get", (PyCFunction) M_CurNurb_method, METH_NOARGS, " () - doc string"}, */ +/* {"method", (PyCFunction) M_CurNurb_method, METH_NOARGS, " () - doc string"}, */ + + {NULL, NULL, 0, NULL} +}; + + + +/* + * method table + * table of instance methods + * these methods are invoked on an instance of the type. +*/ + +static PyMethodDef BPy_CurNurb_methods[] = { +/* name, method, flags, doc */ +/* {"method", (PyCFunction) CurNurb_method, METH_NOARGS, " () - doc string"} */ + {"setMatIndex", ( PyCFunction ) CurNurb_setMatIndex, METH_VARARGS, + "( index ) - set index into materials list"}, + {"getMatIndex", ( PyCFunction ) CurNurb_getMatIndex, METH_NOARGS, + "( ) - get current material index"}, + {"append", ( PyCFunction ) CurNurb_append, METH_VARARGS, + "( point ) - add a new point. arg is BezTriple or list of x,y,z,w floats"}, + {"isNurb", ( PyCFunction ) CurNurb_isNurb, METH_NOARGS, + "( ) - boolean function tests if this spline is type nurb or bezier"}, + {NULL, NULL, 0, NULL} +}; + + +/* + * methods for CurNurb as sequece + */ + +static PySequenceMethods CurNurb_as_sequence = { + (inquiry)CurNurb_length, /* sq_length */ + (binaryfunc) 0, /* sq_concat */ + (intargfunc) 0, /* sq_repeat */ + (intargfunc) CurNurb_getPoint, /* sq_item */ + (intintargfunc) 0, /* sq_slice */ + 0, /* sq_ass_item */ + 0, /* sq_ass_slice */ + (objobjproc) 0, /* sq_contains */ + 0, + 0 +}; + + + +/* + Object Type definition + full blown 2.3 struct +*/ + +PyTypeObject CurNurb_Type = { + PyObject_HEAD_INIT( NULL ) /* required py macro */ 0, /* ob_size */ + /* For printing, in format "<module>.<name>" */ + "CurNurb", /* char *tp_name; */ + sizeof( CurNurb_Type ), /* int tp_basicsize, */ + 0, /* tp_itemsize; For allocation */ + + /* Methods to implement standard operations */ + + ( destructor ) CurNurb_dealloc, /* destructor tp_dealloc; */ + 0, /* printfunc tp_print; */ + ( getattrfunc ) CurNurb_getAttr, /* getattrfunc tp_getattr; */ + ( setattrfunc ) CurNurb_setAttr, /* setattrfunc tp_setattr; */ + ( cmpfunc ) CurNurb_compare, /* cmpfunc tp_compare; */ + ( reprfunc ) CurNurb_repr, /* reprfunc tp_repr; */ + + /* Method suites for standard classes */ + + 0, /* PyNumberMethods *tp_as_number; */ + &CurNurb_as_sequence, /* PySequenceMethods *tp_as_sequence; */ + 0, /* PyMappingMethods *tp_as_mapping; */ + + /* More standard operations (here for binary compatibility) */ + + 0, /* hashfunc tp_hash; */ + 0, /* ternaryfunc tp_call; */ + 0, /* reprfunc tp_str; */ + 0, /* getattrofunc tp_getattro; */ + 0, /* setattrofunc tp_setattro; */ + + /* Functions to access object as input/output buffer */ + 0, /* PyBufferProcs *tp_as_buffer; */ + + /*** Flags to define presence of optional/expanded features ***/ + Py_TPFLAGS_DEFAULT, /* long tp_flags; */ + + 0, /* char *tp_doc; Documentation string */ + /*** Assigned meaning in release 2.0 ***/ + /* call function for all accessible objects */ + 0, /* traverseproc tp_traverse; */ + + /* delete references to contained objects */ + 0, /* inquiry tp_clear; */ + + /*** Assigned meaning in release 2.1 ***/ + /*** rich comparisons ***/ + 0, /* richcmpfunc tp_richcompare; */ + + /*** weak reference enabler ***/ + 0, /* long tp_weaklistoffset; */ + + /*** Added in release 2.2 ***/ + /* Iterators */ + (getiterfunc) CurNurb_getIter, /* getiterfunc tp_iter; */ + (iternextfunc) CurNurb_iterNext, /* iternextfunc tp_iternext; */ + + /*** Attribute descriptor and subclassing stuff ***/ + BPy_CurNurb_methods, /* struct PyMethodDef *tp_methods; */ + 0, /* struct PyMemberDef *tp_members; */ + 0, /* struct PyGetSetDef *tp_getset; */ + 0, /* struct _typeobject *tp_base; */ + 0, /* PyObject *tp_dict; */ + 0, /* descrgetfunc tp_descr_get; */ + 0, /* descrsetfunc tp_descr_set; */ + 0, /* long tp_dictoffset; */ + 0, /* initproc tp_init; */ + 0, /* allocfunc tp_alloc; */ + 0, /* newfunc tp_new; */ + /* Low-level free-memory routine */ + 0, /* freefunc tp_free; */ + /* For PyObject_IS_GC */ + 0, /* inquiry tp_is_gc; */ + 0, /* PyObject *tp_bases; */ + /* method resolution order */ + 0, /* PyObject *tp_mro; */ + 0, /* PyObject *tp_cache; */ + 0, /* PyObject *tp_subclasses; */ + 0, /* PyObject *tp_weaklist; */ + 0 +}; + + +/* + * CurNurb_length + * returns the number of points in a Nurb + * this is a tp_as_sequence method, not a regular instance method. + */ + +static int CurNurb_length( PyInstanceObject *inst) +{ + Nurb* nurb; + int len; + + if( CurNurb_CheckPyObject( (PyObject*)inst ) ) { + nurb = ((BPy_CurNurb*) inst)->nurb; + len = nurb->pntsu; + return len; + } + + return EXPP_ReturnIntError( PyExc_RuntimeError, + "arg is not a BPy_CurNurb" ); + +} + + +/* + * CurNurb_getPoint + * returns the Nth point in a Nurb + * this is one of the tp_as_sequence methods, hence the int N argument. + * it is called via the [] operator, not as a usual instance method. + */ + +PyObject* CurNurb_getPoint( BPy_CurNurb* self, int index ) +{ + PyObject *pyo; + Nurb* myNurb; + + int npoints; + + /* for convenince */ + myNurb = self->nurb; + npoints = myNurb->pntsu; + + /* DELETED: bail if index < 0 */ + /* actually, this check is not needed since python treats */ + /* negative indices as starting from the right end of a sequence */ + + /* bail if no Nurbs in Curve */ + if( npoints == 0) + return( EXPP_ReturnPyObjError( PyExc_IndexError, + "no points in this CurNurb")); + + if( index >= npoints ) /* out of range! */ + return( EXPP_ReturnPyObjError( PyExc_IndexError, + "index out of range")); + + pyo = CurNurb_pointAtIndex( myNurb, index ); + + // handle bezt case AND bp case + + + + + return (PyObject*) pyo; + +} + + +/* + * this is an internal routine. not callable directly from python + */ + +PyObject* CurNurb_pointAtIndex( Nurb* nurb, int index ) +{ + PyObject* pyo; + + if( nurb->bp ){ /* we have a nurb curve */ + int i; + pyo = PyList_New( 4 ); + + for( i = 0; i < 4; i++ ){ + PyList_SetItem( pyo, i, + PyFloat_FromDouble( nurb->bp[index].vec[i] )); + + } + + }else if( nurb->bezt ) { /* we have a bezier */ + /* if an error occurs, we just pass it on */ + pyo = BezTriple_CreatePyObject( &( nurb->bezt[index] ) ); + + } + else /* something is horribly wrong */ + /* neither bp or bezt is set && pntsu != 0 */ + return( EXPP_ReturnPyObjError( PyExc_SystemError, + "inconsistant structure found")); + + + return( pyo ); +} + + +int CurNurb_CheckPyObject( PyObject * py_obj ) +{ + return ( py_obj->ob_type == &CurNurb_Type ); +} + + +PyObject *CurNurb_Init (void) +{ + PyObject *submodule; + + Curve_Type.ob_type = &PyType_Type; + + submodule = + Py_InitModule3 ("Blender.CurNurb", M_CurNurb_methods, M_CurNurb_doc); + return (submodule); +} diff --git a/source/blender/python/api2_2x/CurNurb.h b/source/blender/python/api2_2x/CurNurb.h new file mode 100644 index 00000000000..2cc3e1e5786 --- /dev/null +++ b/source/blender/python/api2_2x/CurNurb.h @@ -0,0 +1,11 @@ + +#ifndef EXPP_NURB_H +#define EXPP_NURB_H + + +PyObject* CurNurb_getPoint( BPy_CurNurb* self, int index ); +PyObject* CurNurb_pointAtIndex( Nurb* nurb, int index ); + +PyObject* CurNurb_appendPointToNurb( Nurb* nurb, PyObject* args ); + +#endif /* EXPP_NURB_H */ diff --git a/source/blender/python/api2_2x/Curve.c b/source/blender/python/api2_2x/Curve.c index d1fb62669ab..de40a5ac9dd 100644 --- a/source/blender/python/api2_2x/Curve.c +++ b/source/blender/python/api2_2x/Curve.c @@ -1,5 +1,5 @@ /* - * + * $Id$ * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or @@ -40,8 +40,11 @@ #include <BKE_object.h> #include <BKE_library.h> #include <BKE_curve.h> - +#include <BKE_utildefines.h> +#include <MEM_guardedalloc.h> /* because we wil be mallocing memory */ +#include "CurNurb.h" #include "gen_utils.h" +#include "modules.h" /*****************************************************************************/ /* The following string definitions are used for documentation strings. */ @@ -103,14 +106,29 @@ static PyObject *Curve_isNurb (BPy_Curve * self, PyObject * args); static PyObject *Curve_getNumPoints (BPy_Curve * self, PyObject * args); static PyObject *Curve_getNumPoints (BPy_Curve * self, PyObject * args); +static PyObject *Curve_appendPoint (BPy_Curve * self, PyObject * args); + +static PyObject *Curve_getMaterials (BPy_Curve * self); + +static PyObject *Curve_getIter (BPy_Curve * self); +static PyObject *Curve_iterNext (BPy_Curve * self); +static PyObject *Curve_update (BPy_Curve * self); +PyObject *Curve_getNurb (BPy_Curve * self, int n); +static int Curve_length (PyInstanceObject * inst); +void update_displists( void* data ); + +void makeDispList(Object *ob); +struct chartrans *text_to_curve(Object *ob, int mode); + + /*****************************************************************************/ /* Python method definitions for Blender.Curve module: */ /*****************************************************************************/ struct PyMethodDef M_Curve_methods[] = { - {"New", (PyCFunction) M_Curve_New, METH_VARARGS, M_Curve_New_doc}, - {"Get", M_Curve_Get, METH_VARARGS, M_Curve_Get_doc}, - {"get", M_Curve_Get, METH_VARARGS, M_Curve_Get_doc}, - {NULL, NULL, 0, NULL} + {"New", (PyCFunction) M_Curve_New, METH_VARARGS, M_Curve_New_doc}, + {"Get", M_Curve_Get, METH_VARARGS, M_Curve_Get_doc}, + {"get", M_Curve_Get, METH_VARARGS, M_Curve_Get_doc}, + {NULL, NULL, 0, NULL} }; @@ -118,73 +136,87 @@ struct PyMethodDef M_Curve_methods[] = { /* Python BPy_Curve instance methods table: */ /*****************************************************************************/ static PyMethodDef BPy_Curve_methods[] = { - {"getName", (PyCFunction) Curve_getName, - METH_NOARGS, "() - Return Curve Data name"}, - {"setName", (PyCFunction) Curve_setName, - METH_VARARGS, "() - Sets Curve Data name"}, - {"getPathLen", (PyCFunction) Curve_getPathLen, - METH_NOARGS, "() - Return Curve path length"}, - {"setPathLen", (PyCFunction) Curve_setPathLen, - METH_VARARGS, "(int) - Sets Curve path length"}, - {"getTotcol", (PyCFunction) Curve_getTotcol, - METH_NOARGS, "() - Return the number of materials of the curve"}, - {"setTotcol", (PyCFunction) Curve_setTotcol, - METH_VARARGS, "(int) - Sets the number of materials of the curve"}, - {"getFlag", (PyCFunction) Curve_getMode, - METH_NOARGS, "() - Return flag (see the doc for semantic)"}, - {"setFlag", (PyCFunction) Curve_setMode, - METH_VARARGS, "(int) - Sets flag (see the doc for semantic)"}, - {"getBevresol", (PyCFunction) Curve_getBevresol, - METH_NOARGS, "() - Return bevel resolution"}, - {"setBevresol", (PyCFunction) Curve_setBevresol, - METH_VARARGS, "(int) - Sets bevel resolution"}, - {"getResolu", (PyCFunction) Curve_getResolu, - METH_NOARGS, "() - Return U resolution"}, - {"setResolu", (PyCFunction) Curve_setResolu, - METH_VARARGS, "(int) - Sets U resolution"}, - {"getResolv", (PyCFunction) Curve_getResolv, - METH_NOARGS, "() - Return V resolution"}, - {"setResolv", (PyCFunction) Curve_setResolv, - METH_VARARGS, "(int) - Sets V resolution"}, - {"getWidth", (PyCFunction) Curve_getWidth, - METH_NOARGS, "() - Return curve width"}, - {"setWidth", (PyCFunction) Curve_setWidth, - METH_VARARGS, "(int) - Sets curve width"}, - {"getExt1", (PyCFunction) Curve_getExt1, - METH_NOARGS, "() - Returns extent 1 of the bevel"}, - {"setExt1", (PyCFunction) Curve_setExt1, - METH_VARARGS, "(int) - Sets extent 1 of the bevel"}, - {"getExt2", (PyCFunction) Curve_getExt2, - METH_NOARGS, "() - Return extent 2 of the bevel "}, - {"setExt2", (PyCFunction) Curve_setExt2, - METH_VARARGS, "(int) - Sets extent 2 of the bevel "}, - {"getControlPoint", (PyCFunction) Curve_getControlPoint, - METH_VARARGS, "(int numcurve,int numpoint) -\ + {"getName", (PyCFunction) Curve_getName, + METH_NOARGS, "() - Return Curve Data name"}, + {"setName", (PyCFunction) Curve_setName, + METH_VARARGS, "() - Sets Curve Data name"}, + {"getPathLen", (PyCFunction) Curve_getPathLen, + METH_NOARGS, "() - Return Curve path length"}, + {"setPathLen", (PyCFunction) Curve_setPathLen, + METH_VARARGS, "(int) - Sets Curve path length"}, + {"getTotcol", (PyCFunction) Curve_getTotcol, + METH_NOARGS, "() - Return the number of materials of the curve"}, + {"setTotcol", (PyCFunction) Curve_setTotcol, + METH_VARARGS, "(int) - Sets the number of materials of the curve"}, + {"getFlag", (PyCFunction) Curve_getMode, + METH_NOARGS, "() - Return flag (see the doc for semantic)"}, + {"setFlag", (PyCFunction) Curve_setMode, + METH_VARARGS, "(int) - Sets flag (see the doc for semantic)"}, + {"getBevresol", (PyCFunction) Curve_getBevresol, + METH_NOARGS, "() - Return bevel resolution"}, + {"setBevresol", (PyCFunction) Curve_setBevresol, + METH_VARARGS, "(int) - Sets bevel resolution"}, + {"getResolu", (PyCFunction) Curve_getResolu, + METH_NOARGS, "() - Return U resolution"}, + {"setResolu", (PyCFunction) Curve_setResolu, + METH_VARARGS, "(int) - Sets U resolution"}, + {"getResolv", (PyCFunction) Curve_getResolv, + METH_NOARGS, "() - Return V resolution"}, + {"setResolv", (PyCFunction) Curve_setResolv, + METH_VARARGS, "(int) - Sets V resolution"}, + {"getWidth", (PyCFunction) Curve_getWidth, + METH_NOARGS, "() - Return curve width"}, + {"setWidth", (PyCFunction) Curve_setWidth, + METH_VARARGS, "(int) - Sets curve width"}, + {"getExt1", (PyCFunction) Curve_getExt1, + METH_NOARGS, "() - Returns extent 1 of the bevel"}, + {"setExt1", (PyCFunction) Curve_setExt1, + METH_VARARGS, "(int) - Sets extent 1 of the bevel"}, + {"getExt2", (PyCFunction) Curve_getExt2, + METH_NOARGS, "() - Return extent 2 of the bevel "}, + {"setExt2", (PyCFunction) Curve_setExt2, + METH_VARARGS, "(int) - Sets extent 2 of the bevel "}, + {"getControlPoint", (PyCFunction) Curve_getControlPoint, + METH_VARARGS, "(int numcurve,int numpoint) -\ Gets a control point.Depending upon the curve type, returne a list of 4 or 9 floats"}, - {"setControlPoint", (PyCFunction) Curve_setControlPoint, - METH_VARARGS, "(int numcurve,int numpoint,float x,float y,float z,\ + {"setControlPoint", (PyCFunction) Curve_setControlPoint, + METH_VARARGS, "(int numcurve,int numpoint,float x,float y,float z,\ float w)(nurbs) or (int numcurve,int numpoint,float x1,...,x9(bezier)\ Sets a control point "}, - {"getLoc", (PyCFunction) Curve_getLoc, - METH_NOARGS, "() - Gets Location of the curve (a 3-tuple) "}, - {"setLoc", (PyCFunction) Curve_setLoc, - METH_VARARGS, "(3-tuple) - Sets Location "}, - {"getRot", (PyCFunction) Curve_getRot, - METH_NOARGS, "() - Gets curve rotation"}, - {"setRot", (PyCFunction) Curve_setRot, - METH_VARARGS, "(3-tuple) - Sets curve rotation"}, - {"getSize", (PyCFunction) Curve_getSize, - METH_NOARGS, "() - Gets curve size"}, - {"setSize", (PyCFunction) Curve_setSize, - METH_VARARGS, "(3-tuple) - Sets curve size"}, - {"getNumCurves", ( PyCFunction ) Curve_getNumCurves, - METH_NOARGS, "() - Gets number of curves in Curve"}, - {"isNurb", ( PyCFunction ) Curve_isNurb, - METH_VARARGS, "(nothing or integer) - returns 1 if curve is type Nurb, O otherwise."}, - {"getNumPoints", (PyCFunction) Curve_getNumPoints, - METH_VARARGS, - "(nothing or integer) - returns the number of points of the specified curve"}, - {NULL, NULL, 0, NULL} + {"getLoc", (PyCFunction) Curve_getLoc, + METH_NOARGS, "() - Gets Location of the curve (a 3-tuple) "}, + {"setLoc", (PyCFunction) Curve_setLoc, + METH_VARARGS, "(3-tuple) - Sets Location "}, + {"getRot", (PyCFunction) Curve_getRot, + METH_NOARGS, "() - Gets curve rotation"}, + {"setRot", (PyCFunction) Curve_setRot, + METH_VARARGS, "(3-tuple) - Sets curve rotation"}, + {"getSize", (PyCFunction) Curve_getSize, + METH_NOARGS, "() - Gets curve size"}, + {"setSize", (PyCFunction) Curve_setSize, + METH_VARARGS, "(3-tuple) - Sets curve size"}, + {"getNumCurves", (PyCFunction) Curve_getNumCurves, + METH_NOARGS, "() - Gets number of curves in Curve"}, + {"isNurb", (PyCFunction) Curve_isNurb, + METH_VARARGS, + "(nothing or integer) - returns 1 if curve is type Nurb, O otherwise."}, + {"getNumPoints", (PyCFunction) Curve_getNumPoints, + METH_VARARGS, + "(nothing or integer) - returns the number of points of the specified curve"}, + {"appendPoint", (PyCFunction) Curve_appendPoint, METH_VARARGS, + "( int numcurve, list of coordinates) - adds a new point to end of curve"}, + {"update", (PyCFunction) Curve_update, METH_NOARGS, + "( ) - updates display lists after changes to Curve"}, + {"getMaterials", (PyCFunction) Curve_getMaterials, METH_NOARGS, + "() - returns list of materials assigned to this Curve"}, +#if 0 +// fixme + {"getIter", (PyCFunction) Curve_getIter, METH_NOARGS, + "() - returns an iterator for the curves that make up the Curve"}, + {"iterNext", (PyCFunction) Curve_iterNext, METH_NOARGS, + "() - returns the next curve or NULL if at end of list "}, +#endif + {NULL, NULL, 0, NULL} }; @@ -201,195 +233,204 @@ PyObject *Curve_CreatePyObject (struct Curve *curve); int Curve_CheckPyObject (PyObject * py_obj); struct Curve *Curve_FromPyObject (PyObject * py_obj); +static PySequenceMethods Curve_as_sequence = { + (inquiry) Curve_length, /* sq_length */ + (binaryfunc) 0, /* sq_concat */ + (intargfunc) 0, /* sq_repeat */ + (intargfunc) Curve_getNurb, /* sq_item */ + (intintargfunc) 0, /* sq_slice */ + 0, /* sq_ass_item */ + 0, /* sq_ass_slice */ + (objobjproc) 0, /* sq_contains */ + 0, + 0 +}; /*****************************************************************************/ /* Python Curve_Type structure definition: */ /*****************************************************************************/ PyTypeObject Curve_Type = { - PyObject_HEAD_INIT (NULL) /* required macro */ - 0, /* ob_size */ - "Curve", /* tp_name - for printing */ - sizeof (BPy_Curve), /* tp_basicsize - for allocation */ - 0, /* tp_itemsize - for allocation */ - /* methods for standard operations */ - (destructor) CurveDeAlloc, /* tp_dealloc */ - 0, /* tp_print */ - (getattrfunc) CurveGetAttr, /* tp_getattr */ - (setattrfunc) CurveSetAttr, /* tp_setattr */ - 0, /* tp_compare */ - (reprfunc) CurveRepr, /* tp_repr */ - /* methods for standard classes */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_as_hash */ - 0, /* tp_call */ - 0, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - /* Flags to define presence of optional/expaned features */ - 0, /* tp_flags */ - 0, /* tp_doc - documentation string */ - 0, /* tp_traverse */ - - /* delete references to contained objects */ - 0, /* tp_clear */ - - 0, /* tp_richcompare - rich comparisions */ - 0, /* tp_weaklistoffset - weak reference enabler */ - - /* new release 2.2 stuff - Iterators */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - - /* Attribute descriptor and subclassing stuff */ - BPy_Curve_methods, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset; */ - 0, /* tp_base; */ - 0, /* tp_dict; */ - 0, /* tp_descr_get; */ - 0, /* tp_descr_set; */ - 0, /* tp_dictoffset; */ - 0, /* tp_init; */ - 0, /* tp_alloc; */ - 0, /* tp_new; */ - 0, /* tp_free; Low-level free-memory routine */ - 0, /* tp_is_gc */ - 0, /* tp_bases; */ - 0, /* tp_mro; method resolution order */ - 0, /* tp_defined; */ - 0, /* tp_weakllst */ - 0, + PyObject_HEAD_INIT (NULL) /* required macro */ 0, /* ob_size */ + "Curve", /* tp_name - for printing */ + sizeof (BPy_Curve), /* tp_basicsize - for allocation */ + 0, /* tp_itemsize - for allocation */ + /* methods for standard operations */ + (destructor) CurveDeAlloc, /* tp_dealloc */ + 0, /* tp_print */ + (getattrfunc) CurveGetAttr, /* tp_getattr */ + (setattrfunc) CurveSetAttr, /* tp_setattr */ + 0, /* tp_compare */ + (reprfunc) CurveRepr, /* tp_repr */ + /* methods for standard classes */ + 0, /* tp_as_number */ + &Curve_as_sequence, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_as_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + /* Flags to define presence of optional/expaned features */ + Py_TPFLAGS_HAVE_ITER, /* tp_flags */ + 0, /* tp_doc - documentation string */ + 0, /* tp_traverse */ + + /* delete references to contained objects */ + 0, /* tp_clear */ + + 0, /* tp_richcompare - rich comparisions */ + 0, /* tp_weaklistoffset - weak reference enabler */ + + /* new release 2.2 stuff - Iterators */ + (getiterfunc) Curve_getIter, /* tp_iter */ + (iternextfunc) Curve_iterNext, /* tp_iternext *//* was Curve_iterNext */ + + /* Attribute descriptor and subclassing stuff */ + BPy_Curve_methods, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset; */ + 0, /* tp_base; */ + 0, /* tp_dict; */ + 0, /* tp_descr_get; */ + 0, /* tp_descr_set; */ + 0, /* tp_dictoffset; */ + 0, /* tp_init; */ + 0, /* tp_alloc; */ + 0, /* tp_new; */ + 0, /* tp_free; Low-level free-memory routine */ + 0, /* tp_is_gc */ + 0, /* tp_bases; */ + 0, /* tp_mro; method resolution order */ + 0, /* tp_defined; */ + 0, /* tp_weakllst */ + 0, + 0 }; /*****************************************************************************/ /* Function: M_Curve_New */ /* Python equivalent: Blender.Curve.New */ /*****************************************************************************/ -static PyObject * -M_Curve_New (PyObject * self, PyObject * args) +static PyObject *M_Curve_New (PyObject * self, PyObject * args) { - char buf[24]; - char *name = NULL; - BPy_Curve *pycurve; /* for Curve Data object wrapper in Python */ - Curve *blcurve = 0; /* for actual Curve Data we create in Blender */ - - if (!PyArg_ParseTuple (args, "|s", &name)) - return (EXPP_ReturnPyObjError (PyExc_AttributeError, - "expected string argument or no argument")); - - blcurve = add_curve (OB_CURVE); /* first create the Curve Data in Blender */ - - if (blcurve == NULL) /* bail out if add_curve() failed */ - return (EXPP_ReturnPyObjError (PyExc_RuntimeError, - "couldn't create Curve Data in Blender")); - - /* return user count to zero because add_curve() inc'd it */ - blcurve->id.us = 0; - /* create python wrapper obj */ - pycurve = (BPy_Curve *) PyObject_NEW (BPy_Curve, &Curve_Type); - - if (pycurve == NULL) - return (EXPP_ReturnPyObjError (PyExc_MemoryError, - "couldn't create Curve Data object")); - - pycurve->curve = blcurve; /* link Python curve wrapper to Blender Curve */ - if (name) - { - PyOS_snprintf (buf, sizeof (buf), "%s", name); - rename_id (&blcurve->id, buf); - } + char buf[24]; + char *name = NULL; + BPy_Curve *pycurve; /* for Curve Data object wrapper in Python */ + Curve *blcurve = 0; /* for actual Curve Data we create in Blender */ + + if(!PyArg_ParseTuple (args, "|s", &name)) + return (EXPP_ReturnPyObjError + (PyExc_AttributeError, + "expected string argument or no argument")); + + blcurve = add_curve (OB_CURVE); /* first create the Curve Data in Blender */ + + if(blcurve == NULL) /* bail out if add_curve() failed */ + return (EXPP_ReturnPyObjError + (PyExc_RuntimeError, + "couldn't create Curve Data in Blender")); + + /* return user count to zero because add_curve() inc'd it */ + blcurve->id.us = 0; + /* create python wrapper obj */ + pycurve = (BPy_Curve *) PyObject_NEW (BPy_Curve, &Curve_Type); + + if(pycurve == NULL) + return (EXPP_ReturnPyObjError + (PyExc_MemoryError, + "couldn't create Curve Data object")); + + pycurve->curve = blcurve; /* link Python curve wrapper to Blender Curve */ + if(name) { + PyOS_snprintf (buf, sizeof (buf), "%s", name); + rename_id (&blcurve->id, buf); + } - return (PyObject *) pycurve; + return (PyObject *) pycurve; } /*****************************************************************************/ /* Function: M_Curve_Get */ /* Python equivalent: Blender.Curve.Get */ /*****************************************************************************/ -static PyObject * -M_Curve_Get (PyObject * self, PyObject * args) +static PyObject *M_Curve_Get (PyObject * self, PyObject * args) { - char *name = NULL; - Curve *curv_iter; - BPy_Curve *wanted_curv; - - if (!PyArg_ParseTuple (args, "|s", &name)) /* expects nothing or a string */ - return (EXPP_ReturnPyObjError (PyExc_AttributeError, - "expected string argument")); - if (name) - { /*a name has been given */ - /* Use the name to search for the curve requested */ - wanted_curv = NULL; - curv_iter = G.main->curve.first; - - while ((curv_iter) && (wanted_curv == NULL)) - { - - if (strcmp (name, curv_iter->id.name + 2) == 0) - { - wanted_curv = - (BPy_Curve *) PyObject_NEW (BPy_Curve, &Curve_Type); - if (wanted_curv) - wanted_curv->curve = curv_iter; - } - - curv_iter = curv_iter->id.next; - } - - if (wanted_curv == NULL) - { /* Requested curve doesn't exist */ - char error_msg[64]; - PyOS_snprintf (error_msg, sizeof (error_msg), - "Curve \"%s\" not found", name); - return (EXPP_ReturnPyObjError (PyExc_NameError, error_msg)); - } - - - return (PyObject *) wanted_curv; - } /* end of if(name) */ - else - { - /* no name has been given; return a list of all curves by name. */ - PyObject *curvlist; - - curv_iter = G.main->curve.first; - curvlist = PyList_New (0); - - if (curvlist == NULL) - return (EXPP_ReturnPyObjError (PyExc_MemoryError, - "couldn't create PyList")); - - while (curv_iter) - { - BPy_Curve *found_cur = - (BPy_Curve *) PyObject_NEW (BPy_Curve, &Curve_Type); - found_cur->curve = curv_iter; - PyList_Append (curvlist, (PyObject *) found_cur); - - curv_iter = curv_iter->id.next; - } - - return (curvlist); - } /* end of else */ + char *name = NULL; + Curve *curv_iter; + BPy_Curve *wanted_curv; + + if(!PyArg_ParseTuple (args, "|s", &name)) /* expects nothing or a string */ + return (EXPP_ReturnPyObjError (PyExc_AttributeError, + "expected string argument")); + if(name) { /*a name has been given */ + /* Use the name to search for the curve requested */ + wanted_curv = NULL; + curv_iter = G.main->curve.first; + + while((curv_iter) && (wanted_curv == NULL)) { + + if(strcmp (name, curv_iter->id.name + 2) == 0) { + wanted_curv = + (BPy_Curve *) PyObject_NEW (BPy_Curve, + &Curve_Type); + if(wanted_curv) + wanted_curv->curve = curv_iter; + } + + curv_iter = curv_iter->id.next; + } + + if(wanted_curv == NULL) { /* Requested curve doesn't exist */ + char error_msg[64]; + PyOS_snprintf (error_msg, sizeof (error_msg), + "Curve \"%s\" not found", name); + return (EXPP_ReturnPyObjError + (PyExc_NameError, error_msg)); + } + + + return (PyObject *) wanted_curv; + } /* end of if(name) */ + else { + /* no name has been given; return a list of all curves by name. */ + PyObject *curvlist; + + curv_iter = G.main->curve.first; + curvlist = PyList_New (0); + + if(curvlist == NULL) + return (EXPP_ReturnPyObjError (PyExc_MemoryError, + "couldn't create PyList")); + + while(curv_iter) { + BPy_Curve *found_cur = + (BPy_Curve *) PyObject_NEW (BPy_Curve, + &Curve_Type); + found_cur->curve = curv_iter; + PyList_Append (curvlist, (PyObject *) found_cur); + + curv_iter = curv_iter->id.next; + } + + return (curvlist); + } /* end of else */ } /*****************************************************************************/ /* Function: Curve_Init */ /*****************************************************************************/ -PyObject * -Curve_Init (void) +PyObject *Curve_Init (void) { - PyObject *submodule; + PyObject *submodule; - Curve_Type.ob_type = &PyType_Type; + Curve_Type.ob_type = &PyType_Type; - submodule = Py_InitModule3 ("Blender.Curve", M_Curve_methods, M_Curve_doc); - return (submodule); + submodule = + Py_InitModule3 ("Blender.Curve", M_Curve_methods, M_Curve_doc); + return (submodule); } /*****************************************************************************/ @@ -402,268 +443,248 @@ Curve_Init (void) /*****************************************************************************/ -static PyObject * -Curve_getName (BPy_Curve * self) +static PyObject *Curve_getName (BPy_Curve * self) { - PyObject *attr = PyString_FromString (self->curve->id.name + 2); + PyObject *attr = PyString_FromString (self->curve->id.name + 2); - if (attr) - return attr; + if(attr) + return attr; - return (EXPP_ReturnPyObjError (PyExc_RuntimeError, - "couldn't get Curve.name attribute")); + return (EXPP_ReturnPyObjError (PyExc_RuntimeError, + "couldn't get Curve.name attribute")); } -static PyObject * -Curve_setName (BPy_Curve * self, PyObject * args) +static PyObject *Curve_setName (BPy_Curve * self, PyObject * args) { - char *name; - char buf[50]; + char *name; + char buf[50]; - if (!PyArg_ParseTuple (args, "s", &(name))) - return (EXPP_ReturnPyObjError (PyExc_AttributeError, - "expected string argument")); - PyOS_snprintf (buf, sizeof (buf), "%s", name); - rename_id (&self->curve->id, buf); /* proper way in Blender */ + if(!PyArg_ParseTuple (args, "s", &(name))) + return (EXPP_ReturnPyObjError (PyExc_AttributeError, + "expected string argument")); + PyOS_snprintf (buf, sizeof (buf), "%s", name); + rename_id (&self->curve->id, buf); /* proper way in Blender */ - Py_INCREF (Py_None); - return Py_None; + Py_INCREF (Py_None); + return Py_None; } -static PyObject * -Curve_getPathLen (BPy_Curve * self) +static PyObject *Curve_getPathLen (BPy_Curve * self) { - PyObject *attr = PyInt_FromLong ((long) self->curve->pathlen); + PyObject *attr = PyInt_FromLong ((long) self->curve->pathlen); - if (attr) - return attr; + if(attr) + return attr; - return (EXPP_ReturnPyObjError (PyExc_RuntimeError, - "couldn't get Curve.pathlen attribute")); + return (EXPP_ReturnPyObjError (PyExc_RuntimeError, + "couldn't get Curve.pathlen attribute")); } -static PyObject * -Curve_setPathLen (BPy_Curve * self, PyObject * args) +static PyObject *Curve_setPathLen (BPy_Curve * self, PyObject * args) { - if (!PyArg_ParseTuple (args, "i", &(self->curve->pathlen))) - return (EXPP_ReturnPyObjError (PyExc_AttributeError, - "expected int argument")); + if(!PyArg_ParseTuple (args, "i", &(self->curve->pathlen))) + return (EXPP_ReturnPyObjError (PyExc_AttributeError, + "expected int argument")); - Py_INCREF (Py_None); - return Py_None; + Py_INCREF (Py_None); + return Py_None; } -static PyObject * -Curve_getTotcol (BPy_Curve * self) +static PyObject *Curve_getTotcol (BPy_Curve * self) { - PyObject *attr = PyInt_FromLong ((long) self->curve->totcol); + PyObject *attr = PyInt_FromLong ((long) self->curve->totcol); - if (attr) - return attr; + if(attr) + return attr; - return (EXPP_ReturnPyObjError (PyExc_RuntimeError, - "couldn't get Curve.totcol attribute")); + return (EXPP_ReturnPyObjError (PyExc_RuntimeError, + "couldn't get Curve.totcol attribute")); } -static PyObject * -Curve_setTotcol (BPy_Curve * self, PyObject * args) +static PyObject *Curve_setTotcol (BPy_Curve * self, PyObject * args) { - if (!PyArg_ParseTuple (args, "i", &(self->curve->totcol))) - return (EXPP_ReturnPyObjError (PyExc_AttributeError, - "expected int argument")); + if(!PyArg_ParseTuple (args, "i", &(self->curve->totcol))) + return (EXPP_ReturnPyObjError (PyExc_AttributeError, + "expected int argument")); - Py_INCREF (Py_None); - return Py_None; + Py_INCREF (Py_None); + return Py_None; } -static PyObject * -Curve_getMode (BPy_Curve * self) +static PyObject *Curve_getMode (BPy_Curve * self) { - PyObject *attr = PyInt_FromLong ((long) self->curve->flag); + PyObject *attr = PyInt_FromLong ((long) self->curve->flag); - if (attr) - return attr; + if(attr) + return attr; - return (EXPP_ReturnPyObjError (PyExc_RuntimeError, - "couldn't get Curve.flag attribute")); + return (EXPP_ReturnPyObjError (PyExc_RuntimeError, + "couldn't get Curve.flag attribute")); } -static PyObject * -Curve_setMode (BPy_Curve * self, PyObject * args) +static PyObject *Curve_setMode (BPy_Curve * self, PyObject * args) { - if (!PyArg_ParseTuple (args, "i", &(self->curve->flag))) - return (EXPP_ReturnPyObjError (PyExc_AttributeError, - "expected int argument")); + if(!PyArg_ParseTuple (args, "i", &(self->curve->flag))) + return (EXPP_ReturnPyObjError (PyExc_AttributeError, + "expected int argument")); - Py_INCREF (Py_None); - return Py_None; + Py_INCREF (Py_None); + return Py_None; } -static PyObject * -Curve_getBevresol (BPy_Curve * self) +static PyObject *Curve_getBevresol (BPy_Curve * self) { - PyObject *attr = PyInt_FromLong ((long) self->curve->bevresol); + PyObject *attr = PyInt_FromLong ((long) self->curve->bevresol); - if (attr) - return attr; + if(attr) + return attr; - return (EXPP_ReturnPyObjError (PyExc_RuntimeError, - "couldn't get Curve.bevresol attribute")); + return (EXPP_ReturnPyObjError (PyExc_RuntimeError, + "couldn't get Curve.bevresol attribute")); } -static PyObject * -Curve_setBevresol (BPy_Curve * self, PyObject * args) +static PyObject *Curve_setBevresol (BPy_Curve * self, PyObject * args) { - if (!PyArg_ParseTuple (args, "i", &(self->curve->bevresol))) - return (EXPP_ReturnPyObjError (PyExc_AttributeError, - "expected int argument")); + if(!PyArg_ParseTuple (args, "i", &(self->curve->bevresol))) + return (EXPP_ReturnPyObjError (PyExc_AttributeError, + "expected int argument")); - Py_INCREF (Py_None); - return Py_None; + Py_INCREF (Py_None); + return Py_None; } -static PyObject * -Curve_getResolu (BPy_Curve * self) +static PyObject *Curve_getResolu (BPy_Curve * self) { - PyObject *attr = PyInt_FromLong ((long) self->curve->resolu); + PyObject *attr = PyInt_FromLong ((long) self->curve->resolu); - if (attr) - return attr; + if(attr) + return attr; - return (EXPP_ReturnPyObjError (PyExc_RuntimeError, - "couldn't get Curve.resolu attribute")); + return (EXPP_ReturnPyObjError (PyExc_RuntimeError, + "couldn't get Curve.resolu attribute")); } -static PyObject * -Curve_setResolu (BPy_Curve * self, PyObject * args) +static PyObject *Curve_setResolu (BPy_Curve * self, PyObject * args) { - if (!PyArg_ParseTuple (args, "i", &(self->curve->resolu))) - return (EXPP_ReturnPyObjError (PyExc_AttributeError, - "expected int argument")); + if(!PyArg_ParseTuple (args, "i", &(self->curve->resolu))) + return (EXPP_ReturnPyObjError (PyExc_AttributeError, + "expected int argument")); - Py_INCREF (Py_None); - return Py_None; + Py_INCREF (Py_None); + return Py_None; } -static PyObject * -Curve_getResolv (BPy_Curve * self) +static PyObject *Curve_getResolv (BPy_Curve * self) { - PyObject *attr = PyInt_FromLong ((long) self->curve->resolv); + PyObject *attr = PyInt_FromLong ((long) self->curve->resolv); - if (attr) - return attr; + if(attr) + return attr; - return (EXPP_ReturnPyObjError (PyExc_RuntimeError, - "couldn't get Curve.resolv attribute")); + return (EXPP_ReturnPyObjError (PyExc_RuntimeError, + "couldn't get Curve.resolv attribute")); } -static PyObject * -Curve_setResolv (BPy_Curve * self, PyObject * args) +static PyObject *Curve_setResolv (BPy_Curve * self, PyObject * args) { - if (!PyArg_ParseTuple (args, "i", &(self->curve->resolv))) - return (EXPP_ReturnPyObjError (PyExc_AttributeError, - "expected int argument")); + if(!PyArg_ParseTuple (args, "i", &(self->curve->resolv))) + return (EXPP_ReturnPyObjError (PyExc_AttributeError, + "expected int argument")); - Py_INCREF (Py_None); - return Py_None; + Py_INCREF (Py_None); + return Py_None; } -static PyObject * -Curve_getWidth (BPy_Curve * self) +static PyObject *Curve_getWidth (BPy_Curve * self) { - PyObject *attr = PyFloat_FromDouble ((double) self->curve->width); + PyObject *attr = PyFloat_FromDouble ((double) self->curve->width); - if (attr) - return attr; + if(attr) + return attr; - return (EXPP_ReturnPyObjError (PyExc_RuntimeError, - "couldn't get Curve.width attribute")); + return (EXPP_ReturnPyObjError (PyExc_RuntimeError, + "couldn't get Curve.width attribute")); } -static PyObject * -Curve_setWidth (BPy_Curve * self, PyObject * args) +static PyObject *Curve_setWidth (BPy_Curve * self, PyObject * args) { - if (!PyArg_ParseTuple (args, "f", &(self->curve->width))) - return (EXPP_ReturnPyObjError (PyExc_AttributeError, - "expected float argument")); + if(!PyArg_ParseTuple (args, "f", &(self->curve->width))) + return (EXPP_ReturnPyObjError (PyExc_AttributeError, + "expected float argument")); - Py_INCREF (Py_None); - return Py_None; + Py_INCREF (Py_None); + return Py_None; } -static PyObject * -Curve_getExt1 (BPy_Curve * self) +static PyObject *Curve_getExt1 (BPy_Curve * self) { - PyObject *attr = PyFloat_FromDouble ((double) self->curve->ext1); + PyObject *attr = PyFloat_FromDouble ((double) self->curve->ext1); - if (attr) - return attr; + if(attr) + return attr; - return (EXPP_ReturnPyObjError (PyExc_RuntimeError, - "couldn't get Curve.ext1 attribute")); + return (EXPP_ReturnPyObjError (PyExc_RuntimeError, + "couldn't get Curve.ext1 attribute")); } -static PyObject * -Curve_setExt1 (BPy_Curve * self, PyObject * args) +static PyObject *Curve_setExt1 (BPy_Curve * self, PyObject * args) { - if (!PyArg_ParseTuple (args, "f", &(self->curve->ext1))) - return (EXPP_ReturnPyObjError (PyExc_AttributeError, - "expected float argument")); + if(!PyArg_ParseTuple (args, "f", &(self->curve->ext1))) + return (EXPP_ReturnPyObjError (PyExc_AttributeError, + "expected float argument")); - Py_INCREF (Py_None); - return Py_None; + Py_INCREF (Py_None); + return Py_None; } -static PyObject * -Curve_getExt2 (BPy_Curve * self) +static PyObject *Curve_getExt2 (BPy_Curve * self) { - PyObject *attr = PyFloat_FromDouble ((double) self->curve->ext2); + PyObject *attr = PyFloat_FromDouble ((double) self->curve->ext2); - if (attr) - return attr; + if(attr) + return attr; - return (EXPP_ReturnPyObjError (PyExc_RuntimeError, - "couldn't get Curve.ext2 attribute")); + return (EXPP_ReturnPyObjError (PyExc_RuntimeError, + "couldn't get Curve.ext2 attribute")); } -static PyObject * -Curve_setExt2 (BPy_Curve * self, PyObject * args) +static PyObject *Curve_setExt2 (BPy_Curve * self, PyObject * args) { - if (!PyArg_ParseTuple (args, "f", &(self->curve->ext2))) - return (EXPP_ReturnPyObjError (PyExc_AttributeError, - "expected float argument")); + if(!PyArg_ParseTuple (args, "f", &(self->curve->ext2))) + return (EXPP_ReturnPyObjError (PyExc_AttributeError, + "expected float argument")); - Py_INCREF (Py_None); - return Py_None; + Py_INCREF (Py_None); + return Py_None; } @@ -709,191 +730,200 @@ static PyObject *Curve_setControlPoint(BPy_Curve *self, PyObject *args) */ -static PyObject * -Curve_setControlPoint (BPy_Curve * self, PyObject * args) -{ - PyObject *listargs = 0; - Nurb *ptrnurb = self->curve->nurb.first; - int numcourbe, numpoint, i, j; - - if (!ptrnurb) - { - Py_INCREF (Py_None); - return Py_None; - } - - if (ptrnurb->bp) - if (!PyArg_ParseTuple (args, "iiO", &numcourbe, &numpoint, &listargs)) - return (EXPP_ReturnPyObjError (PyExc_AttributeError, - "expected int int list arguments")); - if (ptrnurb->bezt) - if (!PyArg_ParseTuple (args, "iiO", &numcourbe, &numpoint, &listargs)) - return (EXPP_ReturnPyObjError (PyExc_AttributeError, - "expected int int list arguments")); - - for (i = 0; i < numcourbe; i++) - ptrnurb = ptrnurb->next; +/* + * Curve_setControlPoint + * this function sets an EXISTING control point. + * it does NOT add a new one. + */ - if (ptrnurb->bp) - for (i = 0; i < 4; i++) - ptrnurb->bp[numpoint].vec[i] = - PyFloat_AsDouble (PyList_GetItem (listargs, i)); +static PyObject *Curve_setControlPoint (BPy_Curve * self, PyObject * args) +{ + PyObject *listargs = 0; + Nurb *ptrnurb = self->curve->nurb.first; + int numcourbe, numpoint, i, j; - if (ptrnurb->bezt) - for (i = 0; i < 3; i++) - for (j = 0; j < 3; j++) - ptrnurb->bezt[numpoint].vec[i][j] = - PyFloat_AsDouble (PyList_GetItem (listargs, i * 3 + j)); + if(!ptrnurb) { + Py_INCREF (Py_None); + return Py_None; + } - Py_INCREF (Py_None); - return Py_None; + if(ptrnurb->bp) + if(!PyArg_ParseTuple + (args, "iiO", &numcourbe, &numpoint, &listargs)) + return (EXPP_ReturnPyObjError + (PyExc_AttributeError, + "expected int int list arguments")); + if(ptrnurb->bezt) + if(!PyArg_ParseTuple + (args, "iiO", &numcourbe, &numpoint, &listargs)) + return (EXPP_ReturnPyObjError + (PyExc_AttributeError, + "expected int int list arguments")); + + for(i = 0; i < numcourbe; i++) + ptrnurb = ptrnurb->next; + + /* fixme: case where ->bp && ->bezt are both NULL is not handled */ + if(ptrnurb->bp) + for(i = 0; i < 4; i++) + ptrnurb->bp[numpoint].vec[i] = + PyFloat_AsDouble (PyList_GetItem + (listargs, i)); + + if(ptrnurb->bezt) + for(i = 0; i < 3; i++) + for(j = 0; j < 3; j++) + ptrnurb->bezt[numpoint].vec[i][j] = + PyFloat_AsDouble (PyList_GetItem + (listargs, + i * 3 + j)); + + Py_INCREF (Py_None); + return Py_None; } -static PyObject * -Curve_getControlPoint (BPy_Curve * self, PyObject * args) +static PyObject *Curve_getControlPoint (BPy_Curve * self, PyObject * args) { - PyObject *liste = PyList_New (0); /* return values */ - - Nurb *ptrnurb; - int i, j; - /* input args: requested curve and point number on curve */ - int numcourbe, numpoint; - - if (!PyArg_ParseTuple (args, "ii", &numcourbe, &numpoint)) - return (EXPP_ReturnPyObjError (PyExc_AttributeError, - "expected int int arguments")); - if ((numcourbe < 0) || (numpoint < 0)) - return (EXPP_ReturnPyObjError (PyExc_AttributeError, - " arguments must be non-negative")); - - /* if no nurbs in this curve obj */ - if (!self->curve->nurb.first) - return liste; - - /* walk the list of nurbs to find requested numcourbe */ - ptrnurb = self->curve->nurb.first; - for (i = 0; i < numcourbe; i++) - { - ptrnurb = ptrnurb->next; - if (!ptrnurb) /* if zero, we ran just ran out of curves */ - return (EXPP_ReturnPyObjError (PyExc_AttributeError, - "curve index out of range")); - } - - /* check numpoint param against pntsu */ - if (numpoint >= ptrnurb->pntsu) - return (EXPP_ReturnPyObjError (PyExc_AttributeError, - "point index out of range")); + PyObject *liste = PyList_New (0); /* return values */ + + Nurb *ptrnurb; + int i, j; + /* input args: requested curve and point number on curve */ + int numcourbe, numpoint; + + if(!PyArg_ParseTuple (args, "ii", &numcourbe, &numpoint)) + return (EXPP_ReturnPyObjError (PyExc_AttributeError, + "expected int int arguments")); + if((numcourbe < 0) || (numpoint < 0)) + return (EXPP_ReturnPyObjError (PyExc_AttributeError, + " arguments must be non-negative")); + + /* if no nurbs in this curve obj */ + if(!self->curve->nurb.first) + return liste; + + /* walk the list of nurbs to find requested numcourbe */ + ptrnurb = self->curve->nurb.first; + for(i = 0; i < numcourbe; i++) { + ptrnurb = ptrnurb->next; + if(!ptrnurb) /* if zero, we ran just ran out of curves */ + return (EXPP_ReturnPyObjError (PyExc_AttributeError, + "curve index out of range")); + } - if (ptrnurb->bp) /* if we are a nurb curve, you get 4 values */ - { - for (i = 0; i < 4; i++) - PyList_Append (liste, - PyFloat_FromDouble (ptrnurb->bp[numpoint].vec[i])); - } + /* check numpoint param against pntsu */ + if(numpoint >= ptrnurb->pntsu) + return (EXPP_ReturnPyObjError (PyExc_AttributeError, + "point index out of range")); + + if(ptrnurb->bp) { /* if we are a nurb curve, you get 4 values */ + for(i = 0; i < 4; i++) + PyList_Append (liste, + PyFloat_FromDouble (ptrnurb-> + bp[numpoint]. + vec[i])); + } - if (ptrnurb->bezt) /* if we are a bezier, you get 9 values */ - { - for (i = 0; i < 3; i++) - for (j = 0; j < 3; j++) - PyList_Append (liste, - PyFloat_FromDouble (ptrnurb->bezt[numpoint]. - vec[i][j])); - } + if(ptrnurb->bezt) { /* if we are a bezier, you get 9 values */ + for(i = 0; i < 3; i++) + for(j = 0; j < 3; j++) + PyList_Append (liste, + PyFloat_FromDouble (ptrnurb-> + bezt + [numpoint]. + vec[i][j])); + } - return liste; + return liste; } -static PyObject * -Curve_getLoc (BPy_Curve * self) +static PyObject *Curve_getLoc (BPy_Curve * self) { - int i; - PyObject *liste = PyList_New (3); - for (i = 0; i < 3; i++) - PyList_SetItem (liste, i, PyFloat_FromDouble (self->curve->loc[i])); - return liste; + int i; + PyObject *liste = PyList_New (3); + for(i = 0; i < 3; i++) + PyList_SetItem (liste, i, + PyFloat_FromDouble (self->curve->loc[i])); + return liste; } -static PyObject * -Curve_setLoc (BPy_Curve * self, PyObject * args) +static PyObject *Curve_setLoc (BPy_Curve * self, PyObject * args) { - PyObject *listargs = 0; - int i; - if (!PyArg_ParseTuple (args, "O", &listargs)) - return EXPP_ReturnPyObjError (PyExc_AttributeError, - "expected list argument"); - if (!PyList_Check (listargs)) - return (EXPP_ReturnPyObjError (PyExc_TypeError, "expected a list")); - for (i = 0; i < 3; i++) - { - PyObject *xx = PyList_GetItem (listargs, i); - self->curve->loc[i] = PyFloat_AsDouble (xx); - } - Py_INCREF (Py_None); - return Py_None; + PyObject *listargs = 0; + int i; + if(!PyArg_ParseTuple (args, "O", &listargs)) + return EXPP_ReturnPyObjError (PyExc_AttributeError, + "expected list argument"); + if(!PyList_Check (listargs)) + return (EXPP_ReturnPyObjError + (PyExc_TypeError, "expected a list")); + for(i = 0; i < 3; i++) { + PyObject *xx = PyList_GetItem (listargs, i); + self->curve->loc[i] = PyFloat_AsDouble (xx); + } + Py_INCREF (Py_None); + return Py_None; } -static PyObject * -Curve_getRot (BPy_Curve * self) +static PyObject *Curve_getRot (BPy_Curve * self) { - int i; - PyObject *liste = PyList_New (3); - for (i = 0; i < 3; i++) - PyList_SetItem (liste, i, PyFloat_FromDouble (self->curve->rot[i])); - return liste; + int i; + PyObject *liste = PyList_New (3); + for(i = 0; i < 3; i++) + PyList_SetItem (liste, i, + PyFloat_FromDouble (self->curve->rot[i])); + return liste; } -static PyObject * -Curve_setRot (BPy_Curve * self, PyObject * args) +static PyObject *Curve_setRot (BPy_Curve * self, PyObject * args) { - PyObject *listargs = 0; - int i; - if (!PyArg_ParseTuple (args, "O", &listargs)) - return EXPP_ReturnPyObjError (PyExc_AttributeError, - "expected list argument"); - if (!PyList_Check (listargs)) - return (EXPP_ReturnPyObjError (PyExc_TypeError, "expected a list")); - for (i = 0; i < 3; i++) - { - PyObject *xx = PyList_GetItem (listargs, i); - self->curve->rot[i] = PyFloat_AsDouble (xx); - } - Py_INCREF (Py_None); - return Py_None; + PyObject *listargs = 0; + int i; + if(!PyArg_ParseTuple (args, "O", &listargs)) + return EXPP_ReturnPyObjError (PyExc_AttributeError, + "expected list argument"); + if(!PyList_Check (listargs)) + return (EXPP_ReturnPyObjError + (PyExc_TypeError, "expected a list")); + for(i = 0; i < 3; i++) { + PyObject *xx = PyList_GetItem (listargs, i); + self->curve->rot[i] = PyFloat_AsDouble (xx); + } + Py_INCREF (Py_None); + return Py_None; } -static PyObject * -Curve_getSize (BPy_Curve * self) +static PyObject *Curve_getSize (BPy_Curve * self) { - int i; - PyObject *liste = PyList_New (3); - for (i = 0; i < 3; i++) - PyList_SetItem (liste, i, PyFloat_FromDouble (self->curve->size[i])); - return liste; + int i; + PyObject *liste = PyList_New (3); + for(i = 0; i < 3; i++) + PyList_SetItem (liste, i, + PyFloat_FromDouble (self->curve->size[i])); + return liste; } -static PyObject * -Curve_setSize (BPy_Curve * self, PyObject * args) +static PyObject *Curve_setSize (BPy_Curve * self, PyObject * args) { - PyObject *listargs = 0; - int i; - if (!PyArg_ParseTuple (args, "O", &listargs)) - return EXPP_ReturnPyObjError (PyExc_AttributeError, - "expected list argument"); - if (!PyList_Check (listargs)) - return (EXPP_ReturnPyObjError (PyExc_TypeError, "expected a list")); - for (i = 0; i < 3; i++) - { - PyObject *xx = PyList_GetItem (listargs, i); - self->curve->size[i] = PyFloat_AsDouble (xx); - } - Py_INCREF (Py_None); - return Py_None; + PyObject *listargs = 0; + int i; + if(!PyArg_ParseTuple (args, "O", &listargs)) + return EXPP_ReturnPyObjError (PyExc_AttributeError, + "expected list argument"); + if(!PyList_Check (listargs)) + return (EXPP_ReturnPyObjError + (PyExc_TypeError, "expected a list")); + for(i = 0; i < 3; i++) { + PyObject *xx = PyList_GetItem (listargs, i); + self->curve->size[i] = PyFloat_AsDouble (xx); + } + Py_INCREF (Py_None); + return Py_None; } @@ -902,152 +932,313 @@ Curve_setSize (BPy_Curve * self, PyObject * args) * int getNumCurves() */ -static PyObject * -Curve_getNumCurves (BPy_Curve * self) +static PyObject *Curve_getNumCurves (BPy_Curve * self) { - Nurb *ptrnurb; - PyObject *ret_val; - int num_curves = 0; /* start with no splines */ - - /* get curve */ - ptrnurb = self->curve->nurb.first; - if (ptrnurb) /* we have some nurbs in this curve */ - { - while (1) - { - ++num_curves; - ptrnurb = ptrnurb->next; - if (!ptrnurb) /* no more curves */ - break; + Nurb *ptrnurb; + PyObject *ret_val; + int num_curves = 0; /* start with no splines */ + + /* get curve */ + ptrnurb = self->curve->nurb.first; + if(ptrnurb) { /* we have some nurbs in this curve */ + while(1) { + ++num_curves; + ptrnurb = ptrnurb->next; + if(!ptrnurb) /* no more curves */ + break; + } } - } - ret_val = PyInt_FromLong ((long) num_curves); + ret_val = PyInt_FromLong ((long) num_curves); - if (ret_val) - return ret_val; + if(ret_val) + return ret_val; - /* oops! */ - return (EXPP_ReturnPyObjError (PyExc_RuntimeError, - "couldn't get number of curves")); + /* oops! */ + return (EXPP_ReturnPyObjError (PyExc_RuntimeError, + "couldn't get number of curves")); } /* - * count the number of points in a give spline + * count the number of points in a given spline * int getNumPoints( curve_num=0 ) * */ -static PyObject * -Curve_getNumPoints (BPy_Curve * self, PyObject * args) +static PyObject *Curve_getNumPoints (BPy_Curve * self, PyObject * args) { - Nurb *ptrnurb; - PyObject *ret_val; - int curve_num = 0; /* default spline number */ - int i; + Nurb *ptrnurb; + PyObject *ret_val; + int curve_num = 0; /* default spline number */ + int i; + + /* parse input arg */ + if(!PyArg_ParseTuple (args, "|i", &curve_num)) + return (EXPP_ReturnPyObjError (PyExc_AttributeError, + "expected int argument")); + + /* check arg - must be non-negative */ + if(curve_num < 0) + return (EXPP_ReturnPyObjError (PyExc_AttributeError, + "argument must be non-negative")); + + + /* walk the list of curves looking for our curve */ + ptrnurb = self->curve->nurb.first; + if(!ptrnurb) { /* no splines in this Curve */ + return (EXPP_ReturnPyObjError (PyExc_AttributeError, + "no splines in this Curve")); + } + + for(i = 0; i < curve_num; i++) { + ptrnurb = ptrnurb->next; + if(!ptrnurb) /* if zero, we ran just ran out of curves */ + return (EXPP_ReturnPyObjError (PyExc_AttributeError, + "curve index out of range")); + } - /* parse input arg */ - if (!PyArg_ParseTuple (args, "|i", &curve_num)) - return (EXPP_ReturnPyObjError (PyExc_AttributeError, - "expected int argument")); + /* pntsu is the number of points in curve */ + ret_val = PyInt_FromLong ((long) ptrnurb->pntsu); - /* check arg - must be non-negative */ - if (curve_num < 0) - return (EXPP_ReturnPyObjError (PyExc_AttributeError, - "argument must be non-negative")); + if(ret_val) + return ret_val; + /* oops! */ + return (EXPP_ReturnPyObjError (PyExc_RuntimeError, + "couldn't get number of points for curve")); +} - /* walk the list of curves looking for our curve */ - ptrnurb = self->curve->nurb.first; - if (!ptrnurb) /* no splines in this Curve */ - { - return (EXPP_ReturnPyObjError (PyExc_AttributeError, - "no splines in this Curve")); - } +/* + * Test whether a given spline of a Curve is a nurb + * as opposed to a bezier + * int isNurb( curve_num=0 ) + */ - for (i = 0; i < curve_num; i++) - { - ptrnurb = ptrnurb->next; - if (!ptrnurb) /* if zero, we ran just ran out of curves */ - return (EXPP_ReturnPyObjError (PyExc_AttributeError, - "curve index out of range")); - } +static PyObject *Curve_isNurb (BPy_Curve * self, PyObject * args) +{ + int curve_num = 0; /* default value */ + int is_nurb; + Nurb *ptrnurb; + PyObject *ret_val; + int i; + + /* parse and check input args */ + if(!PyArg_ParseTuple (args, "|i", &curve_num)) { + return (EXPP_ReturnPyObjError (PyExc_AttributeError, + "expected int argument")); + } + if(curve_num < 0) { + return (EXPP_ReturnPyObjError (PyExc_AttributeError, + "curve number must be non-negative")); + } + + ptrnurb = self->curve->nurb.first; + + if(!ptrnurb) /* no splines in this curve */ + return (EXPP_ReturnPyObjError (PyExc_AttributeError, + "no splines in this Curve")); + + for(i = 0; i < curve_num; i++) { + ptrnurb = ptrnurb->next; + if(!ptrnurb) /* if zero, we ran just ran out of curves */ + return (EXPP_ReturnPyObjError (PyExc_AttributeError, + "curve index out of range")); + } - /* pntsu is the number of points in curve */ - ret_val = PyInt_FromLong ((long) ptrnurb->pntsu); + /* right now, there are only two curve types, nurb and bezier. */ + is_nurb = ptrnurb->bp ? 1 : 0; - if (ret_val) - return ret_val; + ret_val = PyInt_FromLong ((long) is_nurb); + if(ret_val) + return ret_val; - /* oops! */ - return (EXPP_ReturnPyObjError (PyExc_RuntimeError, - "couldn't get number of points for curve")); + /* oops */ + return (EXPP_ReturnPyObjError (PyExc_RuntimeError, + "couldn't get curve type")); } + /* - * Test whether a given spline of a Curve is a nurb - * as opposed to a bezier - * int isNurb( curve_num=0 ) + * Curve_appendPoint( numcurve, new_point ) + * append a new point to indicated spline */ -static PyObject * -Curve_isNurb (BPy_Curve * self, PyObject * args) +static PyObject *Curve_appendPoint (BPy_Curve * self, PyObject * args) { - int curve_num = 0; /* default value */ - int is_nurb; - Nurb *ptrnurb; - PyObject *ret_val; - int i; - - /* parse and check input args */ - if (!PyArg_ParseTuple (args, "|i", &curve_num)) - { - return (EXPP_ReturnPyObjError (PyExc_AttributeError, - "expected int argument")); - } - if (curve_num < 0) - { - return (EXPP_ReturnPyObjError (PyExc_AttributeError, - "curve number must be non-negative")); - } + int i; + int nurb_num; /* index of curve we append to */ + PyObject* coord_args; /* coords for new point */ + Nurb* nurb = self->curve->nurb.first; /* first nurb in Curve */ + +// fixme - need to malloc new Nurb + if( ! nurb ) + return( EXPP_ReturnPyObjError + ( PyExc_AttributeError, + "no nurbs in this Curve")); + + if( ! PyArg_ParseTuple( args,"iO", &nurb_num, &coord_args )) + return( EXPP_ReturnPyObjError + (PyExc_AttributeError, + "expected int, coords as arguments")); + + /* + chase down the list of Nurbs looking for our curve. + */ + for( i = 0; i < nurb_num; i++){ + nurb = nurb->next; + if( ! nurb ) /* we ran off end of list */ + return( EXPP_ReturnPyObjError + ( PyExc_AttributeError, + "curve index out of range")); + } - ptrnurb = self->curve->nurb.first; + return CurNurb_appendPointToNurb( nurb, coord_args ); - if (!ptrnurb) /* no splines in this curve */ - return (EXPP_ReturnPyObjError (PyExc_AttributeError, - "no splines in this Curve")); +} - for (i = 0; i < curve_num; i++) - { - ptrnurb = ptrnurb->next; - if (!ptrnurb) /* if zero, we ran just ran out of curves */ - return (EXPP_ReturnPyObjError (PyExc_AttributeError, - "curve index out of range")); - } - /* right now, there are only two curve types, nurb and bezier. */ - is_nurb = ptrnurb->bp ? 1 : 0; +/* + * Curve_update( ) + * method to update display list for a Curve. + * used. after messing with control points + */ + +static PyObject *Curve_update( BPy_Curve *self ) +{ + + update_displists( (void*) self->curve ); + + Py_INCREF (Py_None); + return Py_None; +} + +/* + * Curve_getMaterials + * + */ + +static PyObject *Curve_getMaterials (BPy_Curve * self) +{ + return (EXPP_PyList_fromMaterialList (self->curve->mat, + self->curve->totcol, + 1 ) ); + +} - ret_val = PyInt_FromLong ((long) is_nurb); - if (ret_val) - return ret_val; - /* oops */ - return (EXPP_ReturnPyObjError (PyExc_RuntimeError, - "couldn't get curve type")); + +/* + * Curve_getIter + * + * create an iterator for our Curve. + * this iterator returns the Nurbs for this Curve. + * the iter_pointer always points to the next available item or null + */ + +static PyObject *Curve_getIter (BPy_Curve * self) +{ + self->iter_pointer = self->curve->nurb.first; + + Py_INCREF( self ); + return (PyObject*) self; + } +/* + * Curve_iterNext + * get the next item. + * iter_pointer always points to the next available element + * or NULL if at the end of the list. + */ + +static PyObject *Curve_iterNext (BPy_Curve * self) +{ + PyObject *po; /* return value */ + Nurb *pnurb; + + if(self->iter_pointer) { + pnurb = self->iter_pointer; + self->iter_pointer = pnurb->next; /* advance iterator */ + po = CurNurb_CreatePyObject (pnurb); /* make a bpy_nurb */ + + return (PyObject *) po; + } + + /* if iter_pointer was null, we are at end */ + return (EXPP_ReturnPyObjError + (PyExc_StopIteration, "iterator at end")); +} + + + +/* tp_sequence methods */ + +/* + * Curve_length + * returns the number of curves in a Curve + * this is a tp_as_sequence method, not a regular instance method. + */ + +static int Curve_length (PyInstanceObject * inst) +{ + if(Curve_CheckPyObject ((PyObject *) inst)) + return( (int) PyInt_AsLong + (Curve_getNumCurves ((BPy_Curve *) inst))); + + return EXPP_ReturnIntError (PyExc_RuntimeError, + "arg is not a BPy_Curve"); + +} + + + +/* + * Curve_getNurb + * returns the Nth nurb in a Curve. + * this is one of the tp_as_sequence methods, hence the int N argument. + * it is called via the [] operator, not as a usual instance method. + */ + +PyObject *Curve_getNurb (BPy_Curve * self, int n) +{ + PyObject *pyo; + Nurb *pNurb; + int i; + + /* bail if index < 0 */ + if(n < 0) + return (EXPP_ReturnPyObjError (PyExc_IndexError, + "index less than 0")); + /* bail if no Nurbs in Curve */ + if(self->curve->nurb.first == 0) + return (EXPP_ReturnPyObjError (PyExc_IndexError, + "no Nurbs in this Curve")); + /* set pointer to nth Nurb */ + for(pNurb = self->curve->nurb.first, i = 0; + pNurb != 0 && i < n; pNurb = pNurb->next, ++i) + /**/; + + if(!pNurb) /* we came to the end of the list */ + return (EXPP_ReturnPyObjError (PyExc_IndexError, + "index out of range")); + + pyo = CurNurb_CreatePyObject (pNurb); /* make a bpy_curnurb */ + return (PyObject *) pyo; + +} + + + /*****************************************************************************/ /* Function: CurveDeAlloc */ /* Description: This is a callback function for the BPy_Curve type. It is */ /* the destructor function. */ /*****************************************************************************/ -static void -CurveDeAlloc (BPy_Curve * self) +static void CurveDeAlloc (BPy_Curve * self) { - PyObject_DEL (self); + PyObject_DEL (self); } /*****************************************************************************/ @@ -1056,52 +1247,51 @@ CurveDeAlloc (BPy_Curve * self) /* the function that accesses BPy_Curve "member variables" and */ /* methods. */ /*****************************************************************************/ -static PyObject * -CurveGetAttr (BPy_Curve * self, char *name) /* getattr */ -{ - PyObject *attr = Py_None; - - if (strcmp (name, "name") == 0) - attr = PyString_FromString (self->curve->id.name + 2); - if (strcmp (name, "pathlen") == 0) - attr = PyInt_FromLong (self->curve->pathlen); - if (strcmp (name, "totcol") == 0) - attr = PyInt_FromLong (self->curve->totcol); - if (strcmp (name, "flag") == 0) - attr = PyInt_FromLong (self->curve->flag); - if (strcmp (name, "bevresol") == 0) - attr = PyInt_FromLong (self->curve->bevresol); - if (strcmp (name, "resolu") == 0) - attr = PyInt_FromLong (self->curve->resolu); - if (strcmp (name, "resolv") == 0) - attr = PyInt_FromLong (self->curve->resolv); - if (strcmp (name, "width") == 0) - attr = PyFloat_FromDouble (self->curve->width); - if (strcmp (name, "ext1") == 0) - attr = PyFloat_FromDouble (self->curve->ext1); - if (strcmp (name, "ext2") == 0) - attr = PyFloat_FromDouble (self->curve->ext2); - if (strcmp (name, "loc") == 0) - return Curve_getLoc (self); - if (strcmp (name, "rot") == 0) - return Curve_getRot (self); - if (strcmp (name, "size") == 0) - return Curve_getSize (self); +static PyObject *CurveGetAttr (BPy_Curve * self, char *name) +{ /* getattr */ + PyObject *attr = Py_None; + + if(strcmp (name, "name") == 0) + attr = PyString_FromString (self->curve->id.name + 2); + if(strcmp (name, "pathlen") == 0) + attr = PyInt_FromLong (self->curve->pathlen); + if(strcmp (name, "totcol") == 0) + attr = PyInt_FromLong (self->curve->totcol); + if(strcmp (name, "flag") == 0) + attr = PyInt_FromLong (self->curve->flag); + if(strcmp (name, "bevresol") == 0) + attr = PyInt_FromLong (self->curve->bevresol); + if(strcmp (name, "resolu") == 0) + attr = PyInt_FromLong (self->curve->resolu); + if(strcmp (name, "resolv") == 0) + attr = PyInt_FromLong (self->curve->resolv); + if(strcmp (name, "width") == 0) + attr = PyFloat_FromDouble (self->curve->width); + if(strcmp (name, "ext1") == 0) + attr = PyFloat_FromDouble (self->curve->ext1); + if(strcmp (name, "ext2") == 0) + attr = PyFloat_FromDouble (self->curve->ext2); + if(strcmp (name, "loc") == 0) + return Curve_getLoc (self); + if(strcmp (name, "rot") == 0) + return Curve_getRot (self); + if(strcmp (name, "size") == 0) + return Curve_getSize (self); #if 0 - if (strcmp (name, "numpts") == 0) - return Curve_getNumPoints (self); + if(strcmp (name, "numpts") == 0) + return Curve_getNumPoints (self); #endif - if (!attr) - return (EXPP_ReturnPyObjError (PyExc_MemoryError, - "couldn't create PyObject")); + if(!attr) + return (EXPP_ReturnPyObjError (PyExc_MemoryError, + "couldn't create PyObject")); - if (attr != Py_None) - return attr; /* member attribute found, return it */ + if(attr != Py_None) + return attr; /* member attribute found, return it */ - /* not an attribute, search the methods table */ - return Py_FindMethod (BPy_Curve_methods, (PyObject *) self, name); + /* not an attribute, search the methods table */ + return Py_FindMethod (BPy_Curve_methods, (PyObject *) self, name); } /*****************************************************************************/ @@ -1109,56 +1299,57 @@ CurveGetAttr (BPy_Curve * self, char *name) /* getattr */ /* Description: This is a callback function for the BPy_Curve type. It is the */ /* function that sets Curve Data attributes (member variables). */ /*****************************************************************************/ -static int -CurveSetAttr (BPy_Curve * self, char *name, PyObject * value) +static int CurveSetAttr (BPy_Curve * self, char *name, PyObject * value) { - PyObject *valtuple; - PyObject *error = NULL; - valtuple = Py_BuildValue ("(O)", value); - /* resolu resolv width ext1 ext2 */ - if (!valtuple) - return EXPP_ReturnIntError (PyExc_MemoryError, - "CurveSetAttr: couldn't create PyTuple"); - - if (strcmp (name, "name") == 0) - error = Curve_setName (self, valtuple); - else if (strcmp (name, "pathlen") == 0) - error = Curve_setPathLen (self, valtuple); - else if (strcmp (name, "resolu") == 0) - error = Curve_setResolu (self, valtuple); - else if (strcmp (name, "resolv") == 0) - error = Curve_setResolv (self, valtuple); - else if (strcmp (name, "width") == 0) - error = Curve_setWidth (self, valtuple); - else if (strcmp (name, "ext1") == 0) - error = Curve_setExt1 (self, valtuple); - else if (strcmp (name, "ext2") == 0) - error = Curve_setExt2 (self, valtuple); - else if (strcmp (name, "loc") == 0) - error = Curve_setLoc (self, valtuple); - else if (strcmp (name, "rot") == 0) - error = Curve_setRot (self, valtuple); - else if (strcmp (name, "size") == 0) - error = Curve_setSize (self, valtuple); - - else - { /* Error */ - Py_DECREF (valtuple); - - if ((strcmp (name, "Types") == 0) || (strcmp (name, "Modes") == 0)) - return (EXPP_ReturnIntError (PyExc_AttributeError, - "constant dictionary -- cannot be changed")); - - else - return (EXPP_ReturnIntError (PyExc_KeyError, "attribute not found")); - } + PyObject *valtuple; + PyObject *error = NULL; + valtuple = Py_BuildValue ("(O)", value); + /* resolu resolv width ext1 ext2 */ + if(!valtuple) + return EXPP_ReturnIntError (PyExc_MemoryError, + "CurveSetAttr: couldn't create PyTuple"); + + if(strcmp (name, "name") == 0) + error = Curve_setName (self, valtuple); + else if(strcmp (name, "pathlen") == 0) + error = Curve_setPathLen (self, valtuple); + else if(strcmp (name, "resolu") == 0) + error = Curve_setResolu (self, valtuple); + else if(strcmp (name, "resolv") == 0) + error = Curve_setResolv (self, valtuple); + else if(strcmp (name, "width") == 0) + error = Curve_setWidth (self, valtuple); + else if(strcmp (name, "ext1") == 0) + error = Curve_setExt1 (self, valtuple); + else if(strcmp (name, "ext2") == 0) + error = Curve_setExt2 (self, valtuple); + else if(strcmp (name, "loc") == 0) + error = Curve_setLoc (self, valtuple); + else if(strcmp (name, "rot") == 0) + error = Curve_setRot (self, valtuple); + else if(strcmp (name, "size") == 0) + error = Curve_setSize (self, valtuple); + + else { /* Error */ + Py_DECREF (valtuple); + + if((strcmp (name, "Types") == 0) + || (strcmp (name, "Modes") == 0)) + return (EXPP_ReturnIntError + (PyExc_AttributeError, + "constant dictionary -- cannot be changed")); + + else + return (EXPP_ReturnIntError + (PyExc_KeyError, "attribute not found")); + } - Py_DECREF (valtuple); + Py_DECREF (valtuple); - if (error != Py_None) - return -1; - Py_DECREF (Py_None); - return 0; + if(error != Py_None) + return -1; + Py_DECREF (Py_None); + return 0; } @@ -1167,42 +1358,91 @@ CurveSetAttr (BPy_Curve * self, char *name, PyObject * value) /* Description: This is a callback function for the BPy_Curve type. It */ /* builds a meaninful string to represent curve objects. */ /*****************************************************************************/ -static PyObject * -CurveRepr (BPy_Curve * self) /* used by 'repr' */ -{ +static PyObject *CurveRepr (BPy_Curve * self) +{ /* used by 'repr' */ - return PyString_FromFormat ("[Curve \"%s\"]", self->curve->id.name + 2); + return PyString_FromFormat ("[Curve \"%s\"]", + self->curve->id.name + 2); } -PyObject * -Curve_CreatePyObject (struct Curve * curve) + +/* + * Curve_CreatePyObject + * constructor to build a py object from blender data + */ + +PyObject *Curve_CreatePyObject (struct Curve * curve) { - BPy_Curve *blen_object; + BPy_Curve *blen_object; - blen_object = (BPy_Curve *) PyObject_NEW (BPy_Curve, &Curve_Type); + blen_object = (BPy_Curve *) PyObject_NEW (BPy_Curve, &Curve_Type); - if (blen_object == NULL) - { - return (NULL); - } - blen_object->curve = curve; - return ((PyObject *) blen_object); + if(blen_object == NULL) { + return (NULL); + } + blen_object->curve = curve; + return ((PyObject *) blen_object); } -int -Curve_CheckPyObject (PyObject * py_obj) +int Curve_CheckPyObject (PyObject * py_obj) { - return (py_obj->ob_type == &Curve_Type); + return (py_obj->ob_type == &Curve_Type); } -struct Curve * -Curve_FromPyObject (PyObject * py_obj) +struct Curve *Curve_FromPyObject (PyObject * py_obj) { - BPy_Curve *blen_obj; + BPy_Curve *blen_obj; + + blen_obj = (BPy_Curve *) py_obj; + return (blen_obj->curve); + +} + - blen_obj = (BPy_Curve *) py_obj; - return (blen_obj->curve); +/* + * walk across all objects looking for curves + * so we can update their ob's disp list + */ + +void update_displists( void* data ) +{ + Base *base; + Object *ob; + unsigned int layer; + + /* background */ + layer = G.scene->lay; + + base = G.scene->base.first; + while(base) { + if(base->lay & layer) + { + ob = base->object; + + if ELEM(ob->type, OB_CURVE, OB_SURF) { + if(ob != G.obedit) { + if ( ob->data == data ){ + makeDispList( ob ); + } + } + } + else if(ob->type == OB_FONT) { + Curve *cu= ob->data; + if(cu->textoncurve) { + if( ((Curve *)cu->textoncurve->data)->key ) { + text_to_curve(ob, 0); + makeDispList(ob); + } + } + } + } + if( base->next == 0 && G.scene->set && base == G.scene->base.last) + base= G.scene->set->base.first; + else + base= base->next; + } } + diff --git a/source/blender/python/api2_2x/Types.c b/source/blender/python/api2_2x/Types.c index a2dc2b0f212..3aa425101fb 100644 --- a/source/blender/python/api2_2x/Types.c +++ b/source/blender/python/api2_2x/Types.c @@ -1,5 +1,5 @@ /* - * + * $Id$ * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or @@ -35,7 +35,7 @@ char M_Types_doc[] = "The Blender Types module\n\n\ This module is a dictionary of all Blender Python types"; -struct PyMethodDef Null_methods[] = {{NULL, NULL}}; +struct PyMethodDef Null_methods[] = {{NULL, NULL, 0, NULL}}; void types_InitAll(void) { @@ -52,6 +52,7 @@ void types_InitAll(void) Build_Type.ob_type = &PyType_Type; Button_Type.ob_type = &PyType_Type; Camera_Type.ob_type = &PyType_Type; + CurNurb_Type.ob_type = &PyType_Type; Curve_Type.ob_type = &PyType_Type; Effect_Type.ob_type = &PyType_Type; Image_Type.ob_type = &PyType_Type; @@ -112,7 +113,9 @@ PyObject *Types_Init (void) PyDict_SetItemString(dict, "ArmatureType", (PyObject *)&Armature_Type); PyDict_SetItemString(dict, "BoneType", (PyObject *)&Bone_Type); - PyDict_SetItemString(dict, "CurveType", (PyObject *)&Curve_Type); + PyDict_SetItemString(dict, "CurNurb_Type", (PyObject *)&CurNurb_Type); + PyDict_SetItemString(dict, "CurveType", (PyObject *)&Curve_Type); + PyDict_SetItemString(dict, "IpoType", (PyObject *)&Ipo_Type); PyDict_SetItemString(dict, "MetaballType", (PyObject *)&Metaball_Type); diff --git a/source/blender/python/api2_2x/Types.h b/source/blender/python/api2_2x/Types.h index 25476ef76a7..032bd05d215 100644 --- a/source/blender/python/api2_2x/Types.h +++ b/source/blender/python/api2_2x/Types.h @@ -36,7 +36,9 @@ extern PyTypeObject Action_Type, Armature_Type; extern PyTypeObject BezTriple_Type, Bone_Type, Build_Type, Button_Type; -extern PyTypeObject Camera_Type, Curve_Type; +extern PyTypeObject Camera_Type; +extern PyTypeObject CurNurb_Type; +extern PyTypeObject Curve_Type; extern PyTypeObject Effect_Type; extern PyTypeObject Image_Type, Ipo_Type, IpoCurve_Type; extern PyTypeObject Lamp_Type, Lattice_Type; diff --git a/source/blender/python/api2_2x/bpy_types.h b/source/blender/python/api2_2x/bpy_types.h index 7defd9fbc47..b7a084f2c3a 100644 --- a/source/blender/python/api2_2x/bpy_types.h +++ b/source/blender/python/api2_2x/bpy_types.h @@ -1,5 +1,5 @@ /* - * + * $Id$ * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or @@ -193,11 +193,36 @@ extern PyTypeObject Curve_Type; /* Python BPy_Curve structure definition */ typedef struct { - PyObject_HEAD /* required py macro */ - Curve * curve; + PyObject_HEAD /* required py macro */ + Curve * curve; + /* pointer for iterator: does not point to owned memory */ + Nurb *iter_pointer; } BPy_Curve; +/********** + CurNurb data +***********/ + +extern PyTypeObject CurNurb_Type; + +#define BPy_CurNurb_Check(v) ((v)->ob_type == &CurNurb_Type) /* for type checking */ + +/* Python BPy_CurNurb structure definition */ +typedef struct { + PyObject_HEAD /* required py macro */ + Nurb * nurb; /* pointer to Blender data */ + + /* iterator stuff */ + /* internal ptrs to point data. do not free */ + BPoint *bp; + BezTriple *bezt; + int atEnd; /* iter exhausted flag */ + int nextPoint; + +} BPy_CurNurb; + + /*****************************************************************************/ /* World Data */ /*****************************************************************************/ diff --git a/source/blender/python/api2_2x/modules.h b/source/blender/python/api2_2x/modules.h index f284184199f..89360e1cf0d 100644 --- a/source/blender/python/api2_2x/modules.h +++ b/source/blender/python/api2_2x/modules.h @@ -186,6 +186,12 @@ int Lattice_CheckPyObject (PyObject *pyobj); /* Noise */ PyObject * Noise_Init (void); +/* CurNurb */ +PyObject * CurNurb_Init (void); +PyObject * CurNurb_CreatePyObject (Nurb *bzt); +int CurNurb_CheckPyObject (PyObject *pyobj); +Nurb * CurNurb_FromPyObject (PyObject *pyobj); + /* Init functions for other modules */ PyObject * Window_Init (void); PyObject * Draw_Init (void); |