[MOAB-dev] r2936 - MOAB/trunk/tools/iMesh/python

jvporter at wisc.edu jvporter at wisc.edu
Mon Jun 8 18:15:39 CDT 2009


Author: jvporter
Date: 2009-06-08 18:15:37 -0500 (Mon, 08 Jun 2009)
New Revision: 2936

Added:
   MOAB/trunk/tools/iMesh/python/iMesh_entSet.inl
   MOAB/trunk/tools/iMesh/python/iMesh_iter.inl
   MOAB/trunk/tools/iMesh/python/iMesh_tag.inl
Removed:
   MOAB/trunk/tools/iMesh/python/iMesh_entSet.c
   MOAB/trunk/tools/iMesh/python/iMesh_iter.c
   MOAB/trunk/tools/iMesh/python/iMesh_tag.c
Modified:
   MOAB/trunk/tools/iMesh/python/common.h
   MOAB/trunk/tools/iMesh/python/errors.h
   MOAB/trunk/tools/iMesh/python/iBase_Python.h
   MOAB/trunk/tools/iMesh/python/iMesh.c
   MOAB/trunk/tools/iMesh/python/iMesh_Python.h
   MOAB/trunk/tools/iMesh/python/setup.py
Log:
Move iMesh_*.c files to .inl files to put everything in one 
translation unit


Modified: MOAB/trunk/tools/iMesh/python/common.h
===================================================================
--- MOAB/trunk/tools/iMesh/python/common.h	2009-06-08 22:45:22 UTC (rev 2935)
+++ MOAB/trunk/tools/iMesh/python/common.h	2009-06-08 23:15:37 UTC (rev 2936)
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef PYTAPS_COMMON_H
+#define PYTAPS_COMMON_H
 
 #include <Python.h>
 
@@ -52,3 +53,5 @@
         PyModule_AddObject(m,py_name,                           \
                            (PyObject *)&name ## _Type);         \
     } while(0)
+
+#endif

Modified: MOAB/trunk/tools/iMesh/python/errors.h
===================================================================
--- MOAB/trunk/tools/iMesh/python/errors.h	2009-06-08 22:45:22 UTC (rev 2935)
+++ MOAB/trunk/tools/iMesh/python/errors.h	2009-06-08 23:15:37 UTC (rev 2936)
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef PYTAPS_ERRORS_H
+#define PYTAPS_ERRORS_H
 
 #define ERR_STORAGE_ORDER "storage order expected"
 #define ERR_ENT_OR_ENTARR "entity or entity array expected"
@@ -8,3 +9,5 @@
 #define ERR_ARR_DIMS      "1- or 2-dimensional array expected"
 #define ERR_TYPE_CODE     "invalid type code"
 #define ERR_ADJ_LIST      "unable to create adjacency list"
+
+#endif

Modified: MOAB/trunk/tools/iMesh/python/iBase_Python.h
===================================================================
--- MOAB/trunk/tools/iMesh/python/iBase_Python.h	2009-06-08 22:45:22 UTC (rev 2935)
+++ MOAB/trunk/tools/iMesh/python/iBase_Python.h	2009-06-08 23:15:37 UTC (rev 2936)
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef PYTAPS_IBASE_PYTHON_H
+#define PYTAPS_IBASE_PYTHON_H
 
 #include "common.h"
 
@@ -107,3 +108,5 @@
 #endif
 
 #endif
+
+#endif

Modified: MOAB/trunk/tools/iMesh/python/iMesh.c
===================================================================
--- MOAB/trunk/tools/iMesh/python/iMesh.c	2009-06-08 22:45:22 UTC (rev 2935)
+++ MOAB/trunk/tools/iMesh/python/iMesh.c	2009-06-08 23:15:37 UTC (rev 2936)
@@ -1083,10 +1083,10 @@
 }
 
 static PyArray_ArrFuncs iMeshEntSetArr_Funcs;
-int NPY_IMESHENTSET;
+static int NPY_IMESHENTSET;
 
 static PyArray_ArrFuncs iMeshTagArr_Funcs;
-int NPY_IMESHTAG;
+static int NPY_IMESHTAG;
 
 ENUM_TYPE(iMeshTopology,"iMesh.Topology","");
 
@@ -1224,3 +1224,8 @@
 
     NPY_IMESHTAG = PyArray_RegisterDataType(descr);
 }
+
+/* Include source files so that everything is in one translation unit */
+#include "iMesh_entSet.inl"
+#include "iMesh_iter.inl"
+#include "iMesh_tag.inl"

Modified: MOAB/trunk/tools/iMesh/python/iMesh_Python.h
===================================================================
--- MOAB/trunk/tools/iMesh/python/iMesh_Python.h	2009-06-08 22:45:22 UTC (rev 2935)
+++ MOAB/trunk/tools/iMesh/python/iMesh_Python.h	2009-06-08 23:15:37 UTC (rev 2936)
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef PYTAPS_IMESH_PYTHON_H
+#define PYTAPS_IMESH_PYTHON_H
 
 #include "common.h"
 
@@ -28,21 +29,21 @@
 #define PyArray_NewFromMallocStrided(nd,dims,strides,typenum,data) \
     PyArray_NewFromMallocBaseStrided(nd,dims,strides,typenum,data,0)
 
-PyObject *
+static PyObject *
 PyArray_NewFromMallocBaseStrided(int nd,npy_intp *dims,npy_intp *strides,
                                  int typenum,void *data,PyObject *base);
 
-PyObject *
+static PyObject *
 PyArray_TryFromObject(PyObject *obj,int typenum,int min_depth,int max_depth);
 
 
-int checkError(iMesh_Instance mesh,int err);
-enum iBase_TagValueType char_to_type(char c);
-char type_to_char(enum iBase_TagValueType t);
+static int checkError(iMesh_Instance mesh,int err);
+static enum iBase_TagValueType char_to_type(char c);
+static char type_to_char(enum iBase_TagValueType t);
 
-PyObject *
+static PyObject *
 AdjacencyList_New(PyObject *adj,PyObject *offsets);
-PyObject *
+static PyObject *
 IndexedAdjacencyList_New(PyObject *ents, PyObject *adj,PyObject *indices,
                          PyObject *offsets);
 
@@ -65,7 +66,7 @@
     };
 } iMeshIter_Object;
 
-extern PyTypeObject iMeshIter_Type;
+static PyTypeObject iMeshIter_Type;
 
 typedef struct
 {
@@ -73,10 +74,10 @@
     iMesh_Object *mesh;
 } iMeshEntitySet_Object;
 
-extern PyTypeObject iMeshEntitySet_Type;
-extern int NPY_IMESHENTSET;
+static PyTypeObject iMeshEntitySet_Type;
+static int NPY_IMESHENTSET;
 
-iMeshEntitySet_Object * iMeshEntitySet_New(iMesh_Object *mesh);
+static iMeshEntitySet_Object * iMeshEntitySet_New(iMesh_Object *mesh);
 
 #define iMeshEntitySet_NewRaw()                         \
     (iMeshEntitySet_Object*)PyObject_CallObject(        \
@@ -94,10 +95,10 @@
     iMesh_Object *mesh;
 } iMeshTag_Object;
 
-extern PyTypeObject iMeshTag_Type;
-extern int NPY_IMESHTAG;
+static PyTypeObject iMeshTag_Type;
+static int NPY_IMESHTAG;
 
-iMeshTag_Object * iMeshTag_New(iMesh_Object *mesh);
+static iMeshTag_Object * iMeshTag_New(iMesh_Object *mesh);
 
 #define iMeshTag_NewRaw()                               \
     (iMeshTag_Object*)PyObject_CallObject(              \
@@ -108,3 +109,5 @@
 
 #define iMeshTag_GetMesh(o)                             \
     ((iMeshTag_Object*)(o))->mesh
+
+#endif

Deleted: MOAB/trunk/tools/iMesh/python/iMesh_entSet.c
===================================================================
--- MOAB/trunk/tools/iMesh/python/iMesh_entSet.c	2009-06-08 22:45:22 UTC (rev 2935)
+++ MOAB/trunk/tools/iMesh/python/iMesh_entSet.c	2009-06-08 23:15:37 UTC (rev 2936)
@@ -1,708 +0,0 @@
-#define NO_IMPORT_ARRAY
-#define NO_IMPORT_IBASE
-
-#include "errors.h"
-#include "iMesh_Python.h"
-#include "iBase_Python.h"
-#include "structmember.h"
-
-static void
-iMeshEntSetObj_dealloc(iMeshEntitySet_Object *self)
-{
-    Py_XDECREF(self->mesh);
-    ((PyObject*)self)->ob_type->tp_free((PyObject*)self);
-}
-
-static PyObject *
-iMeshEntSetObj_load(iMeshEntitySet_Object *self,PyObject *args)
-{
-    const char *name = 0;
-    const char *options = "";
-    if(!PyArg_ParseTuple(args,"s|s",&name,&options))
-        return NULL;
-
-    int err;
-    iMesh_load(self->mesh->mesh,self->set.handle,name,options,&err,strlen(name),
-               strlen(options));
-    if(checkError(self->mesh->mesh,err))
-        return NULL;
-
-    Py_RETURN_NONE;
-}
-
-static PyObject *
-iMeshEntSetObj_save(iMeshEntitySet_Object *self,PyObject *args)
-{
-    const char *name = 0;
-    const char *options = "";
-    if(!PyArg_ParseTuple(args,"s|s",&name,&options))
-        return NULL;
-
-    int err;
-    iMesh_save(self->mesh->mesh,self->set.handle,name,options,&err,strlen(name),
-               strlen(options));
-    if(checkError(self->mesh->mesh,err))
-        return NULL;
-
-    Py_RETURN_NONE;
-}
-
-static PyObject *
-iMeshEntSetObj_getNumOfType(iMeshEntitySet_Object *self,PyObject *args)
-{
-    enum iBase_EntityType type;
-    int num,err;
-    if(!PyArg_ParseTuple(args,"i",&type))
-        return NULL;
-
-    iMesh_getNumOfType(self->mesh->mesh,self->set.handle,type,&num,&err);
-    if(checkError(self->mesh->mesh,err))
-        return NULL;
-
-    return Py_BuildValue("i",num);
-}
-
-static PyObject *
-iMeshEntSetObj_getNumOfTopo(iMeshEntitySet_Object *self,PyObject *args)
-{
-    enum iMesh_EntityTopology topo;
-    int num,err;
-    if(!PyArg_ParseTuple(args,"i",&topo))
-        return NULL;
-
-    iMesh_getNumOfTopo(self->mesh->mesh,self->set.handle,topo,&num,&err);
-    if(checkError(self->mesh->mesh,err))
-        return NULL;
-
-    return Py_BuildValue("i",num);
-}
-
-static PyObject *
-iMeshEntSetObj_getEntities(iMeshEntitySet_Object *self,PyObject *args)
-{
-    enum iBase_EntityType type;
-    enum iMesh_EntityTopology topo;
-    iBase_EntityHandle *entities=0;
-    int alloc=0,size,err;
-
-    if(!PyArg_ParseTuple(args,"ii",&type,&topo))
-        return NULL;
-
-    iMesh_getEntities(self->mesh->mesh,self->set.handle,type,topo,&entities,
-                      &alloc,&size,&err);
-    if(checkError(self->mesh->mesh,err))
-        return NULL;
-
-    npy_intp dims[] = {size};
-    return PyArray_NewFromMalloc(1,dims,NPY_IBASEENT,entities);
-}
-
-static PyObject *
-iMeshEntSetObj_getAdjEntIndices(iMeshEntitySet_Object *self,PyObject *args)
-{
-    int type_requestor,topo_requestor,type_requested;
-    int err;
-
-    if(!PyArg_ParseTuple(args,"iii",&type_requestor,&topo_requestor,
-                         &type_requested))
-        return NULL;
-
-    iBase_EntityHandle *entities=0;
-    int ent_alloc=0,ent_size;
-    iBase_EntityHandle *adj_ents=0;
-    int adj_alloc=0,adj_size;
-    int *indices=0;
-    int ind_alloc=0,ind_size;
-    int *offsets=0;
-    int off_alloc=0,off_size;
-
-    iMesh_getAdjEntIndices(self->mesh->mesh,self->set.handle,type_requestor,
-                           topo_requestor,type_requested,
-                           &entities,&ent_alloc,&ent_size,
-                           &adj_ents,&adj_alloc,&adj_size,
-                           &indices, &ind_alloc,&ind_size,
-                           &offsets, &off_alloc,&off_size,
-                           &err);
-    if(checkError(self->mesh->mesh,err))
-        return NULL;
-
-    npy_intp ent_dims[] = {ent_size};
-    npy_intp adj_dims[] = {adj_size};
-    npy_intp ind_dims[] = {ind_size};
-    npy_intp off_dims[] = {off_size};
-
-    return IndexedAdjacencyList_New(
-        PyArray_NewFromMalloc(1,ent_dims,NPY_IBASEENT,entities),
-        PyArray_NewFromMalloc(1,adj_dims,NPY_IBASEENT,adj_ents),
-        PyArray_NewFromMalloc(1,ind_dims,NPY_INT,indices),
-        PyArray_NewFromMalloc(1,off_dims,NPY_INT,offsets) );
-}
-
-static PyObject *
-iMeshEntSetObj_isList(iMeshEntitySet_Object *self,void *closure)
-{
-    int is_list,err;
-    iMesh_isList(self->mesh->mesh,self->set.handle,&is_list,&err);
-    if(checkError(self->mesh->mesh,err))
-        return NULL;
-
-    return PyBool_FromLong(is_list);
-}
-
-static PyObject *
-iMeshEntSetObj_getNumEntSets(iMeshEntitySet_Object *self,PyObject *args)
-{
-    int num_hops,num_sets,err;
-
-    if(!PyArg_ParseTuple(args,"i",&num_hops))
-        return NULL;
-
-    iMesh_getNumEntSets(self->mesh->mesh,self->set.handle,num_hops,&num_sets,
-                        &err);
-    if(checkError(self->mesh->mesh,err))
-        return NULL;
-
-    return Py_BuildValue("i",num_sets);
-}
-
-static PyObject *
-iMeshEntSetObj_getEntSets(iMeshEntitySet_Object *self,PyObject *args)
-{
-    int num_hops,sets_alloc=0,sets_size,err;
-    iBase_EntitySetHandle *sets;
-  
-    if(!PyArg_ParseTuple(args,"i",&num_hops))
-        return NULL;
-
-    iMesh_getEntSets(self->mesh->mesh,self->set.handle,num_hops,&sets,
-                     &sets_alloc,&sets_size,&err);
-    if(checkError(self->mesh->mesh,err))
-        return NULL;
-
-    npy_intp dims[] = {sets_size};
-    return PyArray_NewFromMallocBase(1,dims,NPY_IMESHENTSET,sets,
-                                     (PyObject*)self->mesh);
-}
-
-static PyObject *
-iMeshEntSetObj_add(iMeshEntitySet_Object *self,PyObject *args)
-{
-    int err;
-    PyObject *obj;
-
-    if(!PyArg_ParseTuple(args,"O",&obj))
-        return NULL;
-
-    PyObject *ents = PyArray_TryFromObject(obj,NPY_IBASEENT,1,1);
-    if(ents)
-    {
-        int size = PyArray_SIZE(ents);
-        iBase_EntityHandle *data = PyArray_DATA(ents);
-        iMesh_addEntArrToSet(self->mesh->mesh,data,size,self->set.handle,&err);
-        Py_DECREF(ents);
-    }
-    else if(iBaseEntitySet_Check(obj))
-    {
-        iBaseEntitySet_Object *set = (iBaseEntitySet_Object*)obj;
-        iMesh_addEntSet(self->mesh->mesh,set->handle,self->set.handle,&err);
-    }
-    else if(iBaseEntity_Check(obj))
-    {
-        iBaseEntity_Object *ent = (iBaseEntity_Object*)obj;
-        iMesh_addEntToSet(self->mesh->mesh,ent->handle,self->set.handle,&err);
-    }
-    else
-    {
-        PyErr_SetString(PyExc_ValueError,ERR_ANY_ENT);
-        return NULL;
-    }
-
-    if(checkError(self->mesh->mesh,err))
-        return NULL;
-    Py_RETURN_NONE;
-}
-
-static PyObject *
-iMeshEntSetObj_remove(iMeshEntitySet_Object *self,PyObject *args)
-{
-    int err;
-    PyObject *obj;
-
-    if(!PyArg_ParseTuple(args,"O",&obj))
-        return NULL;
-
-    PyObject *ents = PyArray_TryFromObject(obj,NPY_IBASEENT,1,1);
-    if(ents)
-    {
-        int size = PyArray_SIZE(ents);
-        iBase_EntityHandle *data = PyArray_DATA(ents);
-        iMesh_rmvEntArrFromSet(self->mesh->mesh,data,size,self->set.handle,
-                               &err);
-        Py_DECREF(ents);
-    }
-    else if(iBaseEntitySet_Check(obj))
-    {
-        iBaseEntitySet_Object *set = (iBaseEntitySet_Object*)obj;
-        iMesh_rmvEntSet(self->mesh->mesh,set->handle,self->set.handle,&err);
-    }
-    else if(iBaseEntity_Check(obj))
-    {
-        iBaseEntity_Object *ent = (iBaseEntity_Object*)obj;
-        iMesh_rmvEntFromSet(self->mesh->mesh,ent->handle,self->set.handle,
-                            &err);
-    }
-    else
-    {
-        PyErr_SetString(PyExc_ValueError,ERR_ANY_ENT);
-        return NULL;
-    }
-
-    if(checkError(self->mesh->mesh,err))
-        return NULL;
-    Py_RETURN_NONE;
-}
-
-static PyObject *
-iMeshEntSetObj_contains(iMeshEntitySet_Object *self,PyObject *args)
-{
-    int err;
-    PyObject *obj;
-
-    if(!PyArg_ParseTuple(args,"O",&obj))
-        return NULL;
-
-    PyObject *ents = PyArray_TryFromObject(obj,NPY_IBASEENT,1,1);
-    if(ents)
-    {
-        int *contains=0;
-        int contains_alloc=0,contains_size;
-
-        int size = PyArray_SIZE(ents);
-        iBase_EntityHandle *data = PyArray_DATA(ents);
-        iMesh_isEntArrContained(self->mesh->mesh,self->set.handle,data,size,
-                                &contains,&contains_alloc,&contains_size,&err);
-        Py_DECREF(ents);
-        if(checkError(self->mesh->mesh,err))
-            return NULL;
-
-        npy_intp dims[] = {contains_size};
-        npy_intp strides[] = {sizeof(int)/sizeof(npy_bool)};
-        return PyArray_NewFromMallocStrided(1,dims,strides,NPY_BOOL,contains);
-    }
-    else if(iBaseEntitySet_Check(obj))
-    {
-        int contains;
-        iBaseEntitySet_Object *set = (iBaseEntitySet_Object*)obj;
-        iMesh_isEntSetContained(self->mesh->mesh,self->set.handle,set->handle,
-                                &contains,&err);
-        if(checkError(self->mesh->mesh,err))
-            return NULL;
-
-        return PyBool_FromLong(contains);
-    }
-    else if(iBaseEntity_Check(obj))
-    {
-        int contains;
-        iBaseEntity_Object *ent = (iBaseEntity_Object*)obj;
-        iMesh_isEntContained(self->mesh->mesh,self->set.handle,ent->handle,
-                             &contains,&err);
-        if(checkError(self->mesh->mesh,err))
-            return NULL;
-
-        return PyBool_FromLong(contains);
-    }
-    else
-    {
-        PyErr_SetString(PyExc_ValueError,ERR_ANY_ENT);
-        return NULL;
-    }
-}
-
-/* TODO: add/removeParent? */
-
-static PyObject *
-iMeshEntSetObj_addChild(iMeshEntitySet_Object *self,PyObject *args)
-{
-    int err;
-    iBaseEntitySet_Object *set;
-
-    if(!PyArg_ParseTuple(args,"O!",&iBaseEntitySet_Type,&set))
-        return NULL;
-
-    iMesh_addPrntChld(self->mesh->mesh,self->set.handle,set->handle,&err);
-    if(checkError(self->mesh->mesh,err))
-        return NULL;
-
-    Py_RETURN_NONE;
-}
-
-static PyObject *
-iMeshEntSetObj_removeChild(iMeshEntitySet_Object *self,PyObject *args)
-{
-    int err;
-    iBaseEntitySet_Object *set;
-
-    if(!PyArg_ParseTuple(args,"O!",&iBaseEntitySet_Type,&set))
-        return NULL;
-
-    iMesh_rmvPrntChld(self->mesh->mesh,self->set.handle,set->handle,&err);
-    if(checkError(self->mesh->mesh,err))
-        return NULL;
-
-    Py_RETURN_NONE;
-}
-
-static PyObject *
-iMeshEntSetObj_isChild(iMeshEntitySet_Object *self,PyObject *args)
-{
-    int is_child,err;
-    iBaseEntitySet_Object *set;
-
-    if(!PyArg_ParseTuple(args,"O!",&iBaseEntitySet_Type,&set))
-        return NULL;
-
-    iMesh_isChildOf(self->mesh->mesh,self->set.handle,set->handle,&is_child,
-                    &err);
-    if(checkError(self->mesh->mesh,err))
-        return NULL;
-
-    return PyBool_FromLong(is_child);
-}
-
-static PyObject *
-iMeshEntSetObj_getNumChildren(iMeshEntitySet_Object *self,PyObject *args)
-{
-    int num_hops,num_children,err;
-
-    if(!PyArg_ParseTuple(args,"i",&num_hops))
-        return NULL;
-
-    iMesh_getNumChld(self->mesh->mesh,self->set.handle,num_hops,&num_children,
-                     &err);
-    if(checkError(self->mesh->mesh,err))
-        return NULL;
-
-    return Py_BuildValue("i",num_children);
-}
-
-static PyObject *
-iMeshEntSetObj_getNumParents(iMeshEntitySet_Object *self,PyObject *args)
-{
-    int num_hops,num_parents,err;
-
-    if(!PyArg_ParseTuple(args,"i",&num_hops))
-        return NULL;
-
-    iMesh_getNumPrnt(self->mesh->mesh,self->set.handle,num_hops,&num_parents,
-                     &err);
-    if(checkError(self->mesh->mesh,err))
-        return NULL;
-
-    return Py_BuildValue("i",num_parents);
-}
-
-static PyObject *
-iMeshEntSetObj_getChildren(iMeshEntitySet_Object *self,PyObject *args)
-{
-    int num_hops,sets_alloc=0,sets_size,err;
-    iBase_EntitySetHandle *sets;
-
-    if(!PyArg_ParseTuple(args,"i",&num_hops))
-        return NULL;
-
-    iMesh_getChldn(self->mesh->mesh,self->set.handle,num_hops,&sets,
-                   &sets_alloc,&sets_size,&err);
-    if(checkError(self->mesh->mesh,err))
-        return NULL;
-
-    npy_intp dims[] = {sets_size};
-    return PyArray_NewFromMallocBase(1,dims,NPY_IMESHENTSET,sets,
-                                     (PyObject*)self->mesh);
-}
-
-static PyObject *
-iMeshEntSetObj_getParents(iMeshEntitySet_Object *self,PyObject *args)
-{
-    int num_hops,sets_alloc=0,sets_size,err;
-    iBase_EntitySetHandle *sets;
-
-    if(!PyArg_ParseTuple(args,"i",&num_hops))
-        return NULL;
-
-    iMesh_getPrnts(self->mesh->mesh,self->set.handle,num_hops,&sets,
-                   &sets_alloc,&sets_size,&err);
-    if(checkError(self->mesh->mesh,err))
-        return NULL;
-
-    npy_intp dims[] = {sets_size};
-    return PyArray_NewFromMallocBase(1,dims,NPY_IMESHENTSET,sets,
-                                     (PyObject*)self->mesh);
-}
-
-static PyObject *
-iMeshEntSetObj_iterate(iMeshEntitySet_Object *self,PyObject *args)
-{
-    Py_ssize_t size = PyTuple_Size(args);
-    PyObject *type,*topo,*count,*tuple,*ret;
-
-    if(!PyArg_UnpackTuple(args,"iterate",2,3,&type,&topo,&count))
-        return NULL;
-    tuple = PyTuple_Pack(size+1,self,type,topo,count);
-
-    ret = PyObject_CallObject((PyObject*)&iMeshIter_Type,tuple);
-    Py_DECREF(tuple);
-    return ret;
-}
-
-
-static PyObject *
-iMeshEntSetObj_sub(iMeshEntitySet_Object *lhs,iMeshEntitySet_Object *rhs)
-{
-    int err;
-    iMeshEntitySet_Object *result;
-
-    if(lhs->mesh->mesh != rhs->mesh->mesh)
-        return NULL;
-
-    result = iMeshEntitySet_New(lhs->mesh);
-
-    iMesh_subtract(lhs->mesh->mesh,lhs->set.handle,rhs->set.handle,
-                   &result->set.handle,&err);
-    if(checkError(lhs->mesh->mesh,err))
-    {
-        Py_DECREF((PyObject*)result);
-        return NULL;
-    }
-
-    return (PyObject*)result;
-}
-
-static PyObject *
-iMeshEntSetObj_bitand(iMeshEntitySet_Object *lhs,iMeshEntitySet_Object *rhs)
-{
-    int err;
-    iMeshEntitySet_Object *result;
-
-    if(lhs->mesh->mesh != rhs->mesh->mesh)
-        return NULL;
-
-    result = iMeshEntitySet_New(lhs->mesh);
-
-    iMesh_intersect(lhs->mesh->mesh,lhs->set.handle,rhs->set.handle,
-                    &result->set.handle,&err);
-    if(checkError(lhs->mesh->mesh,err))
-    {
-        Py_DECREF((PyObject*)result);
-        return NULL;
-    }
-
-    return (PyObject*)result;
-}
-
-static PyObject *
-iMeshEntSetObj_bitor(iMeshEntitySet_Object *lhs,iMeshEntitySet_Object *rhs)
-{
-    int err;
-    iMeshEntitySet_Object *result;
-
-    if(lhs->mesh->mesh != rhs->mesh->mesh)
-        return NULL;
-
-    result = iMeshEntitySet_New(lhs->mesh);
-
-    iMesh_unite(lhs->mesh->mesh,lhs->set.handle,rhs->set.handle,
-                &result->set.handle,&err);
-    if(checkError(lhs->mesh->mesh,err))
-    {
-        Py_DECREF((PyObject*)result);
-        return NULL;
-    }
-
-    return (PyObject*)result;
-}
-
-
-static PyObject *
-iMeshEntSetObj_difference(iMeshEntitySet_Object *self,PyObject *args)
-{
-    iMeshEntitySet_Object *rhs;
-    if(!PyArg_ParseTuple(args,"O!",&iMeshEntitySet_Type,&rhs))
-        return NULL;
-
-    return iMeshEntSetObj_sub(self,rhs);
-}
-
-static PyObject *
-iMeshEntSetObj_intersection(iMeshEntitySet_Object *self,PyObject *args)
-{
-    iMeshEntitySet_Object *rhs;
-    if(!PyArg_ParseTuple(args,"O!",&iMeshEntitySet_Type,&rhs))
-        return NULL;
-
-    return iMeshEntSetObj_bitand(self,rhs);
-}
-
-static PyObject *
-iMeshEntSetObj_union(iMeshEntitySet_Object *self,PyObject *args)
-{
-    iMeshEntitySet_Object *rhs;
-    if(!PyArg_ParseTuple(args,"O!",&iMeshEntitySet_Type,&rhs))
-        return NULL;
-
-    return iMeshEntSetObj_bitor(self,rhs);
-}
-
-
-static PyMethodDef iMeshEntSetObj_methods[] = {
-    { "load", (PyCFunction)iMeshEntSetObj_load, METH_VARARGS,
-      "Load a mesh from a file into this set"
-    },
-    { "save", (PyCFunction)iMeshEntSetObj_save, METH_VARARGS,
-      "Save this set of the mesh to a file"
-    },
-    { "getNumOfType", (PyCFunction)iMeshEntSetObj_getNumOfType, METH_VARARGS,
-      "Get the number of entities with the specified type in this set"
-    },
-    { "getNumOfTopo", (PyCFunction)iMeshEntSetObj_getNumOfTopo, METH_VARARGS,
-      "Get the number of entities with the specified topology in the set"
-    },
-    { "getEntities", (PyCFunction)iMeshEntSetObj_getEntities, METH_VARARGS,
-      "Get entities of specific type and/or topology in this set"
-    },
-    { "getAdjEntIndices", (PyCFunction)iMeshEntSetObj_getAdjEntIndices,
-      METH_VARARGS,
-      "Get indexed representation of this set"
-    },
-    { "getNumEntSets", (PyCFunction)iMeshEntSetObj_getNumEntSets, METH_VARARGS,
-      "Get the number of entity sets contained in this set"
-    },
-    { "getEntSets", (PyCFunction)iMeshEntSetObj_getEntSets, METH_VARARGS,
-      "Get the entity sets contained in this set"
-    },
-    { "add", (PyCFunction)iMeshEntSetObj_add, METH_VARARGS,
-      "Add an entity (or array of entities or entity set) to this set"
-    },
-    { "remove", (PyCFunction)iMeshEntSetObj_remove, METH_VARARGS,
-      "Remove an entity (or array of entities or entity set) from this set"
-    },
-    { "contains", (PyCFunction)iMeshEntSetObj_contains, METH_VARARGS,
-      "Return whether an entity (or array of entities or entity set) are "
-      "contained in this set"
-    },
-    { "addChild", (PyCFunction)iMeshEntSetObj_addChild, METH_VARARGS,
-      "Add parent/child links between two sets"
-    },
-    { "removeChild", (PyCFunction)iMeshEntSetObj_removeChild, METH_VARARGS,
-      "Remove parent/child links between two sets"
-    },
-    { "isChild", (PyCFunction)iMeshEntSetObj_isChild, METH_VARARGS,
-      "Return whether a set is a child of this set"
-    },
-    { "getNumChildren", (PyCFunction)iMeshEntSetObj_getNumChildren,
-      METH_VARARGS,
-      "Get the number of child sets linked from this set"
-    },
-    { "getNumParents", (PyCFunction)iMeshEntSetObj_getNumParents, METH_VARARGS,
-      "Get the number of parent sets linked from this set"
-    },
-    { "getChildren", (PyCFunction)iMeshEntSetObj_getChildren, METH_VARARGS,
-      "Get the child sets linked from this set"
-    },
-    { "getParents", (PyCFunction)iMeshEntSetObj_getParents, METH_VARARGS,
-      "Get the parent sets linked from this set"
-    },
-    { "iterate", (PyCFunction)iMeshEntSetObj_iterate, METH_VARARGS,
-      "Initialize an iterator over specified entity type, topology, and size"
-    },
-    { "difference", (PyCFunction)iMeshEntSetObj_difference, METH_VARARGS,
-      "Get the difference of the two sets"
-    },
-    { "intersection", (PyCFunction)iMeshEntSetObj_intersection, METH_VARARGS,
-      "Get the intersection of the two sets"
-    },
-    { "union", (PyCFunction)iMeshEntSetObj_union, METH_VARARGS,
-      "Get the union of the two sets"
-    },
-    {0}
-};
-
-static PyMemberDef iMeshEntSetObj_members[] = {
-    {"instance", T_OBJECT_EX, offsetof(iMeshEntitySet_Object, mesh), READONLY,
-     "base iMesh instance"},
-    {0}
-};
-
-static PyGetSetDef iMeshEntSetObj_getset[] = {
-    { "isList", (getter)iMeshEntSetObj_isList, 0,
-      "Return whether a specified set is ordered or unordered", 0 },
-    {0}
-};
-
-static PyNumberMethods iMeshEntSetObj_num = {
-    0,                                   /* nb_add */
-    (binaryfunc)iMeshEntSetObj_sub,      /* nb_subtract */
-    0,                                   /* nb_multiply */
-    0,                                   /* nb_divide */
-    0,                                   /* nb_remainder */
-    0,                                   /* nb_divmod */
-    0,                                   /* nb_power */
-    0,                                   /* nb_negative */
-    0,                                   /* nb_positive */
-    0,                                   /* nb_absolute */
-    0,                                   /* nb_nonzero */
-    0,                                   /* nb_invert */
-    0,                                   /* nb_lshift */
-    0,                                   /* nb_rshift */
-    (binaryfunc)iMeshEntSetObj_bitand,   /* nb_and */
-    0,                                   /* nb_xor */
-    (binaryfunc)iMeshEntSetObj_bitor,    /* nb_or */
-    0,                                   /* nb_coerce */
-    0,                                   /* nb_int */
-    0,                                   /* nb_long */
-    0,                                   /* nb_float */
-    0,                                   /* nb_oct */
-    0,                                   /* nb_hex */
-};
-
-PyTypeObject iMeshEntitySet_Type = {
-    PyObject_HEAD_INIT(NULL)
-    0,                                   /* ob_size */
-    "itaps.iMesh.EntitySet",             /* tp_name */
-    sizeof(iMeshEntitySet_Object),       /* tp_basicsize */
-    0,                                   /* tp_itemsize */
-    (destructor)iMeshEntSetObj_dealloc,  /* tp_dealloc */
-    0,                                   /* tp_print */
-    0,                                   /* tp_getattr */
-    0,                                   /* tp_setattr */
-    0,                                   /* tp_compare */
-    0,                                   /* tp_repr */
-    &iMeshEntSetObj_num,                 /* tp_as_number */
-    0,                                   /* tp_as_sequence */
-    0,                                   /* tp_as_mapping */
-    0,                                   /* tp_hash */
-    0,                                   /* tp_call */
-    0,                                   /* tp_str */
-    0,                                   /* tp_getattro */
-    0,                                   /* tp_setattro */
-    0,                                   /* tp_as_buffer */
-    Py_TPFLAGS_DEFAULT |
-    Py_TPFLAGS_BASETYPE,                 /* tp_flags */
-    "iMesh entity set object",           /* tp_doc */
-    0,                                   /* tp_traverse */
-    0,                                   /* tp_clear */
-    0,                                   /* tp_richcompare */
-    0,                                   /* tp_weaklistoffset */
-    0,                                   /* tp_iter */
-    0,                                   /* tp_iternext */
-    iMeshEntSetObj_methods,              /* tp_methods */
-    iMeshEntSetObj_members,              /* tp_members */
-    iMeshEntSetObj_getset,               /* 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 */
-};

Copied: MOAB/trunk/tools/iMesh/python/iMesh_entSet.inl (from rev 2930, MOAB/trunk/tools/iMesh/python/iMesh_entSet.c)
===================================================================
--- MOAB/trunk/tools/iMesh/python/iMesh_entSet.inl	                        (rev 0)
+++ MOAB/trunk/tools/iMesh/python/iMesh_entSet.inl	2009-06-08 23:15:37 UTC (rev 2936)
@@ -0,0 +1,708 @@
+#define NO_IMPORT_ARRAY
+#define NO_IMPORT_IBASE
+
+#include "errors.h"
+#include "iMesh_Python.h"
+#include "iBase_Python.h"
+#include "structmember.h"
+
+static void
+iMeshEntSetObj_dealloc(iMeshEntitySet_Object *self)
+{
+    Py_XDECREF(self->mesh);
+    ((PyObject*)self)->ob_type->tp_free((PyObject*)self);
+}
+
+static PyObject *
+iMeshEntSetObj_load(iMeshEntitySet_Object *self,PyObject *args)
+{
+    const char *name = 0;
+    const char *options = "";
+    if(!PyArg_ParseTuple(args,"s|s",&name,&options))
+        return NULL;
+
+    int err;
+    iMesh_load(self->mesh->mesh,self->set.handle,name,options,&err,strlen(name),
+               strlen(options));
+    if(checkError(self->mesh->mesh,err))
+        return NULL;
+
+    Py_RETURN_NONE;
+}
+
+static PyObject *
+iMeshEntSetObj_save(iMeshEntitySet_Object *self,PyObject *args)
+{
+    const char *name = 0;
+    const char *options = "";
+    if(!PyArg_ParseTuple(args,"s|s",&name,&options))
+        return NULL;
+
+    int err;
+    iMesh_save(self->mesh->mesh,self->set.handle,name,options,&err,strlen(name),
+               strlen(options));
+    if(checkError(self->mesh->mesh,err))
+        return NULL;
+
+    Py_RETURN_NONE;
+}
+
+static PyObject *
+iMeshEntSetObj_getNumOfType(iMeshEntitySet_Object *self,PyObject *args)
+{
+    enum iBase_EntityType type;
+    int num,err;
+    if(!PyArg_ParseTuple(args,"i",&type))
+        return NULL;
+
+    iMesh_getNumOfType(self->mesh->mesh,self->set.handle,type,&num,&err);
+    if(checkError(self->mesh->mesh,err))
+        return NULL;
+
+    return Py_BuildValue("i",num);
+}
+
+static PyObject *
+iMeshEntSetObj_getNumOfTopo(iMeshEntitySet_Object *self,PyObject *args)
+{
+    enum iMesh_EntityTopology topo;
+    int num,err;
+    if(!PyArg_ParseTuple(args,"i",&topo))
+        return NULL;
+
+    iMesh_getNumOfTopo(self->mesh->mesh,self->set.handle,topo,&num,&err);
+    if(checkError(self->mesh->mesh,err))
+        return NULL;
+
+    return Py_BuildValue("i",num);
+}
+
+static PyObject *
+iMeshEntSetObj_getEntities(iMeshEntitySet_Object *self,PyObject *args)
+{
+    enum iBase_EntityType type;
+    enum iMesh_EntityTopology topo;
+    iBase_EntityHandle *entities=0;
+    int alloc=0,size,err;
+
+    if(!PyArg_ParseTuple(args,"ii",&type,&topo))
+        return NULL;
+
+    iMesh_getEntities(self->mesh->mesh,self->set.handle,type,topo,&entities,
+                      &alloc,&size,&err);
+    if(checkError(self->mesh->mesh,err))
+        return NULL;
+
+    npy_intp dims[] = {size};
+    return PyArray_NewFromMalloc(1,dims,NPY_IBASEENT,entities);
+}
+
+static PyObject *
+iMeshEntSetObj_getAdjEntIndices(iMeshEntitySet_Object *self,PyObject *args)
+{
+    int type_requestor,topo_requestor,type_requested;
+    int err;
+
+    if(!PyArg_ParseTuple(args,"iii",&type_requestor,&topo_requestor,
+                         &type_requested))
+        return NULL;
+
+    iBase_EntityHandle *entities=0;
+    int ent_alloc=0,ent_size;
+    iBase_EntityHandle *adj_ents=0;
+    int adj_alloc=0,adj_size;
+    int *indices=0;
+    int ind_alloc=0,ind_size;
+    int *offsets=0;
+    int off_alloc=0,off_size;
+
+    iMesh_getAdjEntIndices(self->mesh->mesh,self->set.handle,type_requestor,
+                           topo_requestor,type_requested,
+                           &entities,&ent_alloc,&ent_size,
+                           &adj_ents,&adj_alloc,&adj_size,
+                           &indices, &ind_alloc,&ind_size,
+                           &offsets, &off_alloc,&off_size,
+                           &err);
+    if(checkError(self->mesh->mesh,err))
+        return NULL;
+
+    npy_intp ent_dims[] = {ent_size};
+    npy_intp adj_dims[] = {adj_size};
+    npy_intp ind_dims[] = {ind_size};
+    npy_intp off_dims[] = {off_size};
+
+    return IndexedAdjacencyList_New(
+        PyArray_NewFromMalloc(1,ent_dims,NPY_IBASEENT,entities),
+        PyArray_NewFromMalloc(1,adj_dims,NPY_IBASEENT,adj_ents),
+        PyArray_NewFromMalloc(1,ind_dims,NPY_INT,indices),
+        PyArray_NewFromMalloc(1,off_dims,NPY_INT,offsets) );
+}
+
+static PyObject *
+iMeshEntSetObj_isList(iMeshEntitySet_Object *self,void *closure)
+{
+    int is_list,err;
+    iMesh_isList(self->mesh->mesh,self->set.handle,&is_list,&err);
+    if(checkError(self->mesh->mesh,err))
+        return NULL;
+
+    return PyBool_FromLong(is_list);
+}
+
+static PyObject *
+iMeshEntSetObj_getNumEntSets(iMeshEntitySet_Object *self,PyObject *args)
+{
+    int num_hops,num_sets,err;
+
+    if(!PyArg_ParseTuple(args,"i",&num_hops))
+        return NULL;
+
+    iMesh_getNumEntSets(self->mesh->mesh,self->set.handle,num_hops,&num_sets,
+                        &err);
+    if(checkError(self->mesh->mesh,err))
+        return NULL;
+
+    return Py_BuildValue("i",num_sets);
+}
+
+static PyObject *
+iMeshEntSetObj_getEntSets(iMeshEntitySet_Object *self,PyObject *args)
+{
+    int num_hops,sets_alloc=0,sets_size,err;
+    iBase_EntitySetHandle *sets;
+  
+    if(!PyArg_ParseTuple(args,"i",&num_hops))
+        return NULL;
+
+    iMesh_getEntSets(self->mesh->mesh,self->set.handle,num_hops,&sets,
+                     &sets_alloc,&sets_size,&err);
+    if(checkError(self->mesh->mesh,err))
+        return NULL;
+
+    npy_intp dims[] = {sets_size};
+    return PyArray_NewFromMallocBase(1,dims,NPY_IMESHENTSET,sets,
+                                     (PyObject*)self->mesh);
+}
+
+static PyObject *
+iMeshEntSetObj_add(iMeshEntitySet_Object *self,PyObject *args)
+{
+    int err;
+    PyObject *obj;
+
+    if(!PyArg_ParseTuple(args,"O",&obj))
+        return NULL;
+
+    PyObject *ents = PyArray_TryFromObject(obj,NPY_IBASEENT,1,1);
+    if(ents)
+    {
+        int size = PyArray_SIZE(ents);
+        iBase_EntityHandle *data = PyArray_DATA(ents);
+        iMesh_addEntArrToSet(self->mesh->mesh,data,size,self->set.handle,&err);
+        Py_DECREF(ents);
+    }
+    else if(iBaseEntitySet_Check(obj))
+    {
+        iBaseEntitySet_Object *set = (iBaseEntitySet_Object*)obj;
+        iMesh_addEntSet(self->mesh->mesh,set->handle,self->set.handle,&err);
+    }
+    else if(iBaseEntity_Check(obj))
+    {
+        iBaseEntity_Object *ent = (iBaseEntity_Object*)obj;
+        iMesh_addEntToSet(self->mesh->mesh,ent->handle,self->set.handle,&err);
+    }
+    else
+    {
+        PyErr_SetString(PyExc_ValueError,ERR_ANY_ENT);
+        return NULL;
+    }
+
+    if(checkError(self->mesh->mesh,err))
+        return NULL;
+    Py_RETURN_NONE;
+}
+
+static PyObject *
+iMeshEntSetObj_remove(iMeshEntitySet_Object *self,PyObject *args)
+{
+    int err;
+    PyObject *obj;
+
+    if(!PyArg_ParseTuple(args,"O",&obj))
+        return NULL;
+
+    PyObject *ents = PyArray_TryFromObject(obj,NPY_IBASEENT,1,1);
+    if(ents)
+    {
+        int size = PyArray_SIZE(ents);
+        iBase_EntityHandle *data = PyArray_DATA(ents);
+        iMesh_rmvEntArrFromSet(self->mesh->mesh,data,size,self->set.handle,
+                               &err);
+        Py_DECREF(ents);
+    }
+    else if(iBaseEntitySet_Check(obj))
+    {
+        iBaseEntitySet_Object *set = (iBaseEntitySet_Object*)obj;
+        iMesh_rmvEntSet(self->mesh->mesh,set->handle,self->set.handle,&err);
+    }
+    else if(iBaseEntity_Check(obj))
+    {
+        iBaseEntity_Object *ent = (iBaseEntity_Object*)obj;
+        iMesh_rmvEntFromSet(self->mesh->mesh,ent->handle,self->set.handle,
+                            &err);
+    }
+    else
+    {
+        PyErr_SetString(PyExc_ValueError,ERR_ANY_ENT);
+        return NULL;
+    }
+
+    if(checkError(self->mesh->mesh,err))
+        return NULL;
+    Py_RETURN_NONE;
+}
+
+static PyObject *
+iMeshEntSetObj_contains(iMeshEntitySet_Object *self,PyObject *args)
+{
+    int err;
+    PyObject *obj;
+
+    if(!PyArg_ParseTuple(args,"O",&obj))
+        return NULL;
+
+    PyObject *ents = PyArray_TryFromObject(obj,NPY_IBASEENT,1,1);
+    if(ents)
+    {
+        int *contains=0;
+        int contains_alloc=0,contains_size;
+
+        int size = PyArray_SIZE(ents);
+        iBase_EntityHandle *data = PyArray_DATA(ents);
+        iMesh_isEntArrContained(self->mesh->mesh,self->set.handle,data,size,
+                                &contains,&contains_alloc,&contains_size,&err);
+        Py_DECREF(ents);
+        if(checkError(self->mesh->mesh,err))
+            return NULL;
+
+        npy_intp dims[] = {contains_size};
+        npy_intp strides[] = {sizeof(int)/sizeof(npy_bool)};
+        return PyArray_NewFromMallocStrided(1,dims,strides,NPY_BOOL,contains);
+    }
+    else if(iBaseEntitySet_Check(obj))
+    {
+        int contains;
+        iBaseEntitySet_Object *set = (iBaseEntitySet_Object*)obj;
+        iMesh_isEntSetContained(self->mesh->mesh,self->set.handle,set->handle,
+                                &contains,&err);
+        if(checkError(self->mesh->mesh,err))
+            return NULL;
+
+        return PyBool_FromLong(contains);
+    }
+    else if(iBaseEntity_Check(obj))
+    {
+        int contains;
+        iBaseEntity_Object *ent = (iBaseEntity_Object*)obj;
+        iMesh_isEntContained(self->mesh->mesh,self->set.handle,ent->handle,
+                             &contains,&err);
+        if(checkError(self->mesh->mesh,err))
+            return NULL;
+
+        return PyBool_FromLong(contains);
+    }
+    else
+    {
+        PyErr_SetString(PyExc_ValueError,ERR_ANY_ENT);
+        return NULL;
+    }
+}
+
+/* TODO: add/removeParent? */
+
+static PyObject *
+iMeshEntSetObj_addChild(iMeshEntitySet_Object *self,PyObject *args)
+{
+    int err;
+    iBaseEntitySet_Object *set;
+
+    if(!PyArg_ParseTuple(args,"O!",&iBaseEntitySet_Type,&set))
+        return NULL;
+
+    iMesh_addPrntChld(self->mesh->mesh,self->set.handle,set->handle,&err);
+    if(checkError(self->mesh->mesh,err))
+        return NULL;
+
+    Py_RETURN_NONE;
+}
+
+static PyObject *
+iMeshEntSetObj_removeChild(iMeshEntitySet_Object *self,PyObject *args)
+{
+    int err;
+    iBaseEntitySet_Object *set;
+
+    if(!PyArg_ParseTuple(args,"O!",&iBaseEntitySet_Type,&set))
+        return NULL;
+
+    iMesh_rmvPrntChld(self->mesh->mesh,self->set.handle,set->handle,&err);
+    if(checkError(self->mesh->mesh,err))
+        return NULL;
+
+    Py_RETURN_NONE;
+}
+
+static PyObject *
+iMeshEntSetObj_isChild(iMeshEntitySet_Object *self,PyObject *args)
+{
+    int is_child,err;
+    iBaseEntitySet_Object *set;
+
+    if(!PyArg_ParseTuple(args,"O!",&iBaseEntitySet_Type,&set))
+        return NULL;
+
+    iMesh_isChildOf(self->mesh->mesh,self->set.handle,set->handle,&is_child,
+                    &err);
+    if(checkError(self->mesh->mesh,err))
+        return NULL;
+
+    return PyBool_FromLong(is_child);
+}
+
+static PyObject *
+iMeshEntSetObj_getNumChildren(iMeshEntitySet_Object *self,PyObject *args)
+{
+    int num_hops,num_children,err;
+
+    if(!PyArg_ParseTuple(args,"i",&num_hops))
+        return NULL;
+
+    iMesh_getNumChld(self->mesh->mesh,self->set.handle,num_hops,&num_children,
+                     &err);
+    if(checkError(self->mesh->mesh,err))
+        return NULL;
+
+    return Py_BuildValue("i",num_children);
+}
+
+static PyObject *
+iMeshEntSetObj_getNumParents(iMeshEntitySet_Object *self,PyObject *args)
+{
+    int num_hops,num_parents,err;
+
+    if(!PyArg_ParseTuple(args,"i",&num_hops))
+        return NULL;
+
+    iMesh_getNumPrnt(self->mesh->mesh,self->set.handle,num_hops,&num_parents,
+                     &err);
+    if(checkError(self->mesh->mesh,err))
+        return NULL;
+
+    return Py_BuildValue("i",num_parents);
+}
+
+static PyObject *
+iMeshEntSetObj_getChildren(iMeshEntitySet_Object *self,PyObject *args)
+{
+    int num_hops,sets_alloc=0,sets_size,err;
+    iBase_EntitySetHandle *sets;
+
+    if(!PyArg_ParseTuple(args,"i",&num_hops))
+        return NULL;
+
+    iMesh_getChldn(self->mesh->mesh,self->set.handle,num_hops,&sets,
+                   &sets_alloc,&sets_size,&err);
+    if(checkError(self->mesh->mesh,err))
+        return NULL;
+
+    npy_intp dims[] = {sets_size};
+    return PyArray_NewFromMallocBase(1,dims,NPY_IMESHENTSET,sets,
+                                     (PyObject*)self->mesh);
+}
+
+static PyObject *
+iMeshEntSetObj_getParents(iMeshEntitySet_Object *self,PyObject *args)
+{
+    int num_hops,sets_alloc=0,sets_size,err;
+    iBase_EntitySetHandle *sets;
+
+    if(!PyArg_ParseTuple(args,"i",&num_hops))
+        return NULL;
+
+    iMesh_getPrnts(self->mesh->mesh,self->set.handle,num_hops,&sets,
+                   &sets_alloc,&sets_size,&err);
+    if(checkError(self->mesh->mesh,err))
+        return NULL;
+
+    npy_intp dims[] = {sets_size};
+    return PyArray_NewFromMallocBase(1,dims,NPY_IMESHENTSET,sets,
+                                     (PyObject*)self->mesh);
+}
+
+static PyObject *
+iMeshEntSetObj_iterate(iMeshEntitySet_Object *self,PyObject *args)
+{
+    Py_ssize_t size = PyTuple_Size(args);
+    PyObject *type,*topo,*count,*tuple,*ret;
+
+    if(!PyArg_UnpackTuple(args,"iterate",2,3,&type,&topo,&count))
+        return NULL;
+    tuple = PyTuple_Pack(size+1,self,type,topo,count);
+
+    ret = PyObject_CallObject((PyObject*)&iMeshIter_Type,tuple);
+    Py_DECREF(tuple);
+    return ret;
+}
+
+
+static PyObject *
+iMeshEntSetObj_sub(iMeshEntitySet_Object *lhs,iMeshEntitySet_Object *rhs)
+{
+    int err;
+    iMeshEntitySet_Object *result;
+
+    if(lhs->mesh->mesh != rhs->mesh->mesh)
+        return NULL;
+
+    result = iMeshEntitySet_New(lhs->mesh);
+
+    iMesh_subtract(lhs->mesh->mesh,lhs->set.handle,rhs->set.handle,
+                   &result->set.handle,&err);
+    if(checkError(lhs->mesh->mesh,err))
+    {
+        Py_DECREF((PyObject*)result);
+        return NULL;
+    }
+
+    return (PyObject*)result;
+}
+
+static PyObject *
+iMeshEntSetObj_bitand(iMeshEntitySet_Object *lhs,iMeshEntitySet_Object *rhs)
+{
+    int err;
+    iMeshEntitySet_Object *result;
+
+    if(lhs->mesh->mesh != rhs->mesh->mesh)
+        return NULL;
+
+    result = iMeshEntitySet_New(lhs->mesh);
+
+    iMesh_intersect(lhs->mesh->mesh,lhs->set.handle,rhs->set.handle,
+                    &result->set.handle,&err);
+    if(checkError(lhs->mesh->mesh,err))
+    {
+        Py_DECREF((PyObject*)result);
+        return NULL;
+    }
+
+    return (PyObject*)result;
+}
+
+static PyObject *
+iMeshEntSetObj_bitor(iMeshEntitySet_Object *lhs,iMeshEntitySet_Object *rhs)
+{
+    int err;
+    iMeshEntitySet_Object *result;
+
+    if(lhs->mesh->mesh != rhs->mesh->mesh)
+        return NULL;
+
+    result = iMeshEntitySet_New(lhs->mesh);
+
+    iMesh_unite(lhs->mesh->mesh,lhs->set.handle,rhs->set.handle,
+                &result->set.handle,&err);
+    if(checkError(lhs->mesh->mesh,err))
+    {
+        Py_DECREF((PyObject*)result);
+        return NULL;
+    }
+
+    return (PyObject*)result;
+}
+
+
+static PyObject *
+iMeshEntSetObj_difference(iMeshEntitySet_Object *self,PyObject *args)
+{
+    iMeshEntitySet_Object *rhs;
+    if(!PyArg_ParseTuple(args,"O!",&iMeshEntitySet_Type,&rhs))
+        return NULL;
+
+    return iMeshEntSetObj_sub(self,rhs);
+}
+
+static PyObject *
+iMeshEntSetObj_intersection(iMeshEntitySet_Object *self,PyObject *args)
+{
+    iMeshEntitySet_Object *rhs;
+    if(!PyArg_ParseTuple(args,"O!",&iMeshEntitySet_Type,&rhs))
+        return NULL;
+
+    return iMeshEntSetObj_bitand(self,rhs);
+}
+
+static PyObject *
+iMeshEntSetObj_union(iMeshEntitySet_Object *self,PyObject *args)
+{
+    iMeshEntitySet_Object *rhs;
+    if(!PyArg_ParseTuple(args,"O!",&iMeshEntitySet_Type,&rhs))
+        return NULL;
+
+    return iMeshEntSetObj_bitor(self,rhs);
+}
+
+
+static PyMethodDef iMeshEntSetObj_methods[] = {
+    { "load", (PyCFunction)iMeshEntSetObj_load, METH_VARARGS,
+      "Load a mesh from a file into this set"
+    },
+    { "save", (PyCFunction)iMeshEntSetObj_save, METH_VARARGS,
+      "Save this set of the mesh to a file"
+    },
+    { "getNumOfType", (PyCFunction)iMeshEntSetObj_getNumOfType, METH_VARARGS,
+      "Get the number of entities with the specified type in this set"
+    },
+    { "getNumOfTopo", (PyCFunction)iMeshEntSetObj_getNumOfTopo, METH_VARARGS,
+      "Get the number of entities with the specified topology in the set"
+    },
+    { "getEntities", (PyCFunction)iMeshEntSetObj_getEntities, METH_VARARGS,
+      "Get entities of specific type and/or topology in this set"
+    },
+    { "getAdjEntIndices", (PyCFunction)iMeshEntSetObj_getAdjEntIndices,
+      METH_VARARGS,
+      "Get indexed representation of this set"
+    },
+    { "getNumEntSets", (PyCFunction)iMeshEntSetObj_getNumEntSets, METH_VARARGS,
+      "Get the number of entity sets contained in this set"
+    },
+    { "getEntSets", (PyCFunction)iMeshEntSetObj_getEntSets, METH_VARARGS,
+      "Get the entity sets contained in this set"
+    },
+    { "add", (PyCFunction)iMeshEntSetObj_add, METH_VARARGS,
+      "Add an entity (or array of entities or entity set) to this set"
+    },
+    { "remove", (PyCFunction)iMeshEntSetObj_remove, METH_VARARGS,
+      "Remove an entity (or array of entities or entity set) from this set"
+    },
+    { "contains", (PyCFunction)iMeshEntSetObj_contains, METH_VARARGS,
+      "Return whether an entity (or array of entities or entity set) are "
+      "contained in this set"
+    },
+    { "addChild", (PyCFunction)iMeshEntSetObj_addChild, METH_VARARGS,
+      "Add parent/child links between two sets"
+    },
+    { "removeChild", (PyCFunction)iMeshEntSetObj_removeChild, METH_VARARGS,
+      "Remove parent/child links between two sets"
+    },
+    { "isChild", (PyCFunction)iMeshEntSetObj_isChild, METH_VARARGS,
+      "Return whether a set is a child of this set"
+    },
+    { "getNumChildren", (PyCFunction)iMeshEntSetObj_getNumChildren,
+      METH_VARARGS,
+      "Get the number of child sets linked from this set"
+    },
+    { "getNumParents", (PyCFunction)iMeshEntSetObj_getNumParents, METH_VARARGS,
+      "Get the number of parent sets linked from this set"
+    },
+    { "getChildren", (PyCFunction)iMeshEntSetObj_getChildren, METH_VARARGS,
+      "Get the child sets linked from this set"
+    },
+    { "getParents", (PyCFunction)iMeshEntSetObj_getParents, METH_VARARGS,
+      "Get the parent sets linked from this set"
+    },
+    { "iterate", (PyCFunction)iMeshEntSetObj_iterate, METH_VARARGS,
+      "Initialize an iterator over specified entity type, topology, and size"
+    },
+    { "difference", (PyCFunction)iMeshEntSetObj_difference, METH_VARARGS,
+      "Get the difference of the two sets"
+    },
+    { "intersection", (PyCFunction)iMeshEntSetObj_intersection, METH_VARARGS,
+      "Get the intersection of the two sets"
+    },
+    { "union", (PyCFunction)iMeshEntSetObj_union, METH_VARARGS,
+      "Get the union of the two sets"
+    },
+    {0}
+};
+
+static PyMemberDef iMeshEntSetObj_members[] = {
+    {"instance", T_OBJECT_EX, offsetof(iMeshEntitySet_Object, mesh), READONLY,
+     "base iMesh instance"},
+    {0}
+};
+
+static PyGetSetDef iMeshEntSetObj_getset[] = {
+    { "isList", (getter)iMeshEntSetObj_isList, 0,
+      "Return whether a specified set is ordered or unordered", 0 },
+    {0}
+};
+
+static PyNumberMethods iMeshEntSetObj_num = {
+    0,                                   /* nb_add */
+    (binaryfunc)iMeshEntSetObj_sub,      /* nb_subtract */
+    0,                                   /* nb_multiply */
+    0,                                   /* nb_divide */
+    0,                                   /* nb_remainder */
+    0,                                   /* nb_divmod */
+    0,                                   /* nb_power */
+    0,                                   /* nb_negative */
+    0,                                   /* nb_positive */
+    0,                                   /* nb_absolute */
+    0,                                   /* nb_nonzero */
+    0,                                   /* nb_invert */
+    0,                                   /* nb_lshift */
+    0,                                   /* nb_rshift */
+    (binaryfunc)iMeshEntSetObj_bitand,   /* nb_and */
+    0,                                   /* nb_xor */
+    (binaryfunc)iMeshEntSetObj_bitor,    /* nb_or */
+    0,                                   /* nb_coerce */
+    0,                                   /* nb_int */
+    0,                                   /* nb_long */
+    0,                                   /* nb_float */
+    0,                                   /* nb_oct */
+    0,                                   /* nb_hex */
+};
+
+static PyTypeObject iMeshEntitySet_Type = {
+    PyObject_HEAD_INIT(NULL)
+    0,                                   /* ob_size */
+    "itaps.iMesh.EntitySet",             /* tp_name */
+    sizeof(iMeshEntitySet_Object),       /* tp_basicsize */
+    0,                                   /* tp_itemsize */
+    (destructor)iMeshEntSetObj_dealloc,  /* tp_dealloc */
+    0,                                   /* tp_print */
+    0,                                   /* tp_getattr */
+    0,                                   /* tp_setattr */
+    0,                                   /* tp_compare */
+    0,                                   /* tp_repr */
+    &iMeshEntSetObj_num,                 /* tp_as_number */
+    0,                                   /* tp_as_sequence */
+    0,                                   /* tp_as_mapping */
+    0,                                   /* tp_hash */
+    0,                                   /* tp_call */
+    0,                                   /* tp_str */
+    0,                                   /* tp_getattro */
+    0,                                   /* tp_setattro */
+    0,                                   /* tp_as_buffer */
+    Py_TPFLAGS_DEFAULT |
+    Py_TPFLAGS_BASETYPE,                 /* tp_flags */
+    "iMesh entity set object",           /* tp_doc */
+    0,                                   /* tp_traverse */
+    0,                                   /* tp_clear */
+    0,                                   /* tp_richcompare */
+    0,                                   /* tp_weaklistoffset */
+    0,                                   /* tp_iter */
+    0,                                   /* tp_iternext */
+    iMeshEntSetObj_methods,              /* tp_methods */
+    iMeshEntSetObj_members,              /* tp_members */
+    iMeshEntSetObj_getset,               /* 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 */
+};


Property changes on: MOAB/trunk/tools/iMesh/python/iMesh_entSet.inl
___________________________________________________________________
Name: svn:mergeinfo
   + 

Deleted: MOAB/trunk/tools/iMesh/python/iMesh_iter.c
===================================================================
--- MOAB/trunk/tools/iMesh/python/iMesh_iter.c	2009-06-08 22:45:22 UTC (rev 2935)
+++ MOAB/trunk/tools/iMesh/python/iMesh_iter.c	2009-06-08 23:15:37 UTC (rev 2936)
@@ -1,162 +0,0 @@
-#define NO_IMPORT_ARRAY
-#define NO_IMPORT_ITER
-
-#include "iMesh_Python.h"
-#include "iBase_Python.h"
-#include "structmember.h"
-
-static int
-iMeshIterObj_init(iMeshIter_Object *self,PyObject *args,PyObject *kwds)
-{
-    static char *kwlist[] = {"set","type","topology","size",0};
-    iMeshEntitySet_Object *set;
-    int type,topo,array_size=1,err;
-
-    if( !PyArg_ParseTupleAndKeywords(args,kwds,"O!ii|i",kwlist,
-                                     &iMeshEntitySet_Type,&set,&type,&topo,
-                                     &array_size) )
-        return -1;
-
-    self->mesh = set->mesh;
-    Py_INCREF(self->mesh);
-
-    if(array_size == 1)
-    {
-        self->is_arr = 0;
-        iMesh_initEntIter(self->mesh->mesh,set->set.handle,type,topo,
-                          &self->iter,&err);
-    }
-    else
-    {
-        self->is_arr = 1;
-        iMesh_initEntArrIter(self->mesh->mesh,set->set.handle,type,topo,
-                             array_size,&self->arr_iter,&err);
-    }
-    if(checkError(self->mesh->mesh,err))
-        return -1;
-
-    return 0;
-}
-
-static void
-iMeshIterObj_dealloc(iMeshIter_Object *self)
-{
-    if(self->mesh && self->iter)
-    {
-        int err;
-        if(self->is_arr)
-            iMesh_endEntArrIter(self->mesh->mesh,self->arr_iter,&err);
-        else
-            iMesh_endEntIter(self->mesh->mesh,self->iter,&err);
-    }
-
-    Py_XDECREF(self->mesh);
-    self->ob_type->tp_free((PyObject*)self);
-}
-
-static PyObject *
-iMeshIterObj_reset(iMeshIter_Object *self,PyObject *args)
-{
-    int err;
-    if(self->is_arr)
-        iMesh_resetEntArrIter(self->mesh->mesh,self->arr_iter,&err);
-    else
-        iMesh_resetEntIter(self->mesh->mesh,self->iter,&err);
-
-    if(checkError(self->mesh->mesh,err))
-        return NULL;
-    Py_RETURN_NONE;
-}
-
-static PyObject *
-iMeshIterObj_iternext(iMeshIter_Object *self)
-{
-    int has_data,err;
-
-    if(self->is_arr)
-    {
-        iBase_EntityHandle *entities=0;
-        int alloc=0,size;
-
-        iMesh_getNextEntArrIter(self->mesh->mesh,self->arr_iter,&entities,
-                                &alloc,&size,&has_data,&err);
-        if(checkError(self->mesh->mesh,err))
-            return NULL;
-        if(!has_data)
-            return NULL;
-
-        npy_intp dims[] = {size};
-        return PyArray_NewFromMalloc(1,dims,NPY_IBASEENT,entities);
-    }
-    else
-    {
-        iBase_EntityHandle entity;
-        iMesh_getNextEntIter(self->mesh->mesh,self->iter,&entity,&has_data,
-                             &err);
-        if(checkError(self->mesh->mesh,err))
-            return NULL;
-        if(!has_data)
-            return NULL;
-
-        iBaseEntity_Object *o = iBaseEntity_New();
-        o->handle = entity;
-        return (PyObject*)o;
-    }
-}
-
-static PyMethodDef iMeshIterObj_methods[] = {
-    { "reset", (PyCFunction)iMeshIterObj_reset, METH_NOARGS,
-      "Reset the iterator"
-    },
-    {0}
-};
-
-static PyMemberDef iMeshIterObj_members[] = {
-    {"instance", T_OBJECT_EX, offsetof(iMeshIter_Object, mesh), READONLY,
-     "base iMesh instance"},
-    {0}
-};
-
-PyTypeObject iMeshIter_Type = {
-    PyObject_HEAD_INIT(NULL)
-    0,                                   /* ob_size */
-    "itaps.iMesh.Iterator",              /* tp_name */
-    sizeof(iMeshIter_Object),            /* tp_basicsize */
-    0,                                   /* tp_itemsize */
-    (destructor)iMeshIterObj_dealloc,    /* tp_dealloc */
-    0,                                   /* tp_print */
-    0,                                   /* tp_getattr */
-    0,                                   /* tp_setattr */
-    0,                                   /* tp_compare */
-    0,                                   /* tp_repr */
-    0,                                   /* tp_as_number */
-    0,                                   /* tp_as_sequence */
-    0,                                   /* tp_as_mapping */
-    0,                                   /* tp_hash */
-    0,                                   /* tp_call */
-    0,                                   /* tp_str */
-    0,                                   /* tp_getattro */
-    0,                                   /* tp_setattro */
-    0,                                   /* tp_as_buffer */
-    Py_TPFLAGS_DEFAULT |
-    Py_TPFLAGS_HAVE_ITER |
-    Py_TPFLAGS_BASETYPE,                 /* tp_flags */
-    "iMesh iterator object",             /* tp_doc */
-    0,                                   /* tp_traverse */
-    0,                                   /* tp_clear */
-    0,                                   /* tp_richcompare */
-    0,                                   /* tp_weaklistoffset */
-    PyObject_SelfIter,                   /* tp_iter */
-    (iternextfunc)iMeshIterObj_iternext, /* tp_iternext */
-    iMeshIterObj_methods,                /* tp_methods */
-    iMeshIterObj_members,                /* tp_members */
-    0,                                   /* tp_getset */
-    0,                                   /* tp_base */
-    0,                                   /* tp_dict */
-    0,                                   /* tp_descr_get */
-    0,                                   /* tp_descr_set */
-    0,                                   /* tp_dictoffset */
-    (initproc)iMeshIterObj_init,         /* tp_init */
-    0,                                   /* tp_alloc */
-    0,                                   /* tp_new */
-};

Copied: MOAB/trunk/tools/iMesh/python/iMesh_iter.inl (from rev 2930, MOAB/trunk/tools/iMesh/python/iMesh_iter.c)
===================================================================
--- MOAB/trunk/tools/iMesh/python/iMesh_iter.inl	                        (rev 0)
+++ MOAB/trunk/tools/iMesh/python/iMesh_iter.inl	2009-06-08 23:15:37 UTC (rev 2936)
@@ -0,0 +1,162 @@
+#define NO_IMPORT_ARRAY
+#define NO_IMPORT_ITER
+
+#include "iMesh_Python.h"
+#include "iBase_Python.h"
+#include "structmember.h"
+
+static int
+iMeshIterObj_init(iMeshIter_Object *self,PyObject *args,PyObject *kwds)
+{
+    static char *kwlist[] = {"set","type","topology","size",0};
+    iMeshEntitySet_Object *set;
+    int type,topo,array_size=1,err;
+
+    if( !PyArg_ParseTupleAndKeywords(args,kwds,"O!ii|i",kwlist,
+                                     &iMeshEntitySet_Type,&set,&type,&topo,
+                                     &array_size) )
+        return -1;
+
+    self->mesh = set->mesh;
+    Py_INCREF(self->mesh);
+
+    if(array_size == 1)
+    {
+        self->is_arr = 0;
+        iMesh_initEntIter(self->mesh->mesh,set->set.handle,type,topo,
+                          &self->iter,&err);
+    }
+    else
+    {
+        self->is_arr = 1;
+        iMesh_initEntArrIter(self->mesh->mesh,set->set.handle,type,topo,
+                             array_size,&self->arr_iter,&err);
+    }
+    if(checkError(self->mesh->mesh,err))
+        return -1;
+
+    return 0;
+}
+
+static void
+iMeshIterObj_dealloc(iMeshIter_Object *self)
+{
+    if(self->mesh && self->iter)
+    {
+        int err;
+        if(self->is_arr)
+            iMesh_endEntArrIter(self->mesh->mesh,self->arr_iter,&err);
+        else
+            iMesh_endEntIter(self->mesh->mesh,self->iter,&err);
+    }
+
+    Py_XDECREF(self->mesh);
+    self->ob_type->tp_free((PyObject*)self);
+}
+
+static PyObject *
+iMeshIterObj_reset(iMeshIter_Object *self,PyObject *args)
+{
+    int err;
+    if(self->is_arr)
+        iMesh_resetEntArrIter(self->mesh->mesh,self->arr_iter,&err);
+    else
+        iMesh_resetEntIter(self->mesh->mesh,self->iter,&err);
+
+    if(checkError(self->mesh->mesh,err))
+        return NULL;
+    Py_RETURN_NONE;
+}
+
+static PyObject *
+iMeshIterObj_iternext(iMeshIter_Object *self)
+{
+    int has_data,err;
+
+    if(self->is_arr)
+    {
+        iBase_EntityHandle *entities=0;
+        int alloc=0,size;
+
+        iMesh_getNextEntArrIter(self->mesh->mesh,self->arr_iter,&entities,
+                                &alloc,&size,&has_data,&err);
+        if(checkError(self->mesh->mesh,err))
+            return NULL;
+        if(!has_data)
+            return NULL;
+
+        npy_intp dims[] = {size};
+        return PyArray_NewFromMalloc(1,dims,NPY_IBASEENT,entities);
+    }
+    else
+    {
+        iBase_EntityHandle entity;
+        iMesh_getNextEntIter(self->mesh->mesh,self->iter,&entity,&has_data,
+                             &err);
+        if(checkError(self->mesh->mesh,err))
+            return NULL;
+        if(!has_data)
+            return NULL;
+
+        iBaseEntity_Object *o = iBaseEntity_New();
+        o->handle = entity;
+        return (PyObject*)o;
+    }
+}
+
+static PyMethodDef iMeshIterObj_methods[] = {
+    { "reset", (PyCFunction)iMeshIterObj_reset, METH_NOARGS,
+      "Reset the iterator"
+    },
+    {0}
+};
+
+static PyMemberDef iMeshIterObj_members[] = {
+    {"instance", T_OBJECT_EX, offsetof(iMeshIter_Object, mesh), READONLY,
+     "base iMesh instance"},
+    {0}
+};
+
+static PyTypeObject iMeshIter_Type = {
+    PyObject_HEAD_INIT(NULL)
+    0,                                   /* ob_size */
+    "itaps.iMesh.Iterator",              /* tp_name */
+    sizeof(iMeshIter_Object),            /* tp_basicsize */
+    0,                                   /* tp_itemsize */
+    (destructor)iMeshIterObj_dealloc,    /* tp_dealloc */
+    0,                                   /* tp_print */
+    0,                                   /* tp_getattr */
+    0,                                   /* tp_setattr */
+    0,                                   /* tp_compare */
+    0,                                   /* tp_repr */
+    0,                                   /* tp_as_number */
+    0,                                   /* tp_as_sequence */
+    0,                                   /* tp_as_mapping */
+    0,                                   /* tp_hash */
+    0,                                   /* tp_call */
+    0,                                   /* tp_str */
+    0,                                   /* tp_getattro */
+    0,                                   /* tp_setattro */
+    0,                                   /* tp_as_buffer */
+    Py_TPFLAGS_DEFAULT |
+    Py_TPFLAGS_HAVE_ITER |
+    Py_TPFLAGS_BASETYPE,                 /* tp_flags */
+    "iMesh iterator object",             /* tp_doc */
+    0,                                   /* tp_traverse */
+    0,                                   /* tp_clear */
+    0,                                   /* tp_richcompare */
+    0,                                   /* tp_weaklistoffset */
+    PyObject_SelfIter,                   /* tp_iter */
+    (iternextfunc)iMeshIterObj_iternext, /* tp_iternext */
+    iMeshIterObj_methods,                /* tp_methods */
+    iMeshIterObj_members,                /* tp_members */
+    0,                                   /* tp_getset */
+    0,                                   /* tp_base */
+    0,                                   /* tp_dict */
+    0,                                   /* tp_descr_get */
+    0,                                   /* tp_descr_set */
+    0,                                   /* tp_dictoffset */
+    (initproc)iMeshIterObj_init,         /* tp_init */
+    0,                                   /* tp_alloc */
+    0,                                   /* tp_new */
+};


Property changes on: MOAB/trunk/tools/iMesh/python/iMesh_iter.inl
___________________________________________________________________
Name: svn:mergeinfo
   + 

Deleted: MOAB/trunk/tools/iMesh/python/iMesh_tag.c
===================================================================
--- MOAB/trunk/tools/iMesh/python/iMesh_tag.c	2009-06-08 22:45:22 UTC (rev 2935)
+++ MOAB/trunk/tools/iMesh/python/iMesh_tag.c	2009-06-08 23:15:37 UTC (rev 2936)
@@ -1,577 +0,0 @@
-#define NO_IMPORT_ARRAY
-#define NO_IMPORT_IBASE
-
-#include "iMesh_Python.h"
-#include "iBase_Python.h"
-#include "errors.h"
-#include "structmember.h"
-
-static char typechars[] = {'i','d','E','b'};
-
-enum iBase_TagValueType
-char_to_type(char c)
-{
-    int i;
-    for(i=0; i<sizeof(typechars); i++)
-    {
-        if(typechars[i] == c)
-            return i;
-    }
-    return -1;
-}
-
-char
-type_to_char(enum iBase_TagValueType t)
-{
-    return typechars[t];
-}
-
-
-static void
-iMeshTagObj_dealloc(iMeshTag_Object *self)
-{
-    Py_XDECREF(self->mesh);
-    ((PyObject*)self)->ob_type->tp_free((PyObject*)self);
-}
-
-static PyObject *
-iMeshTagObj_getName(iMeshTag_Object *self,void *closure)
-{
-    char name[512];
-    int err;
-    iMesh_getTagName(self->mesh->mesh,self->tag.handle,name,&err,sizeof(name));
-    if(checkError(self->mesh->mesh,err))
-        return NULL;
-
-    return Py_BuildValue("s",name);
-}
-
-static PyObject *
-iMeshTagObj_getSizeValues(iMeshTag_Object *self,void *closure)
-{
-    int size,err;
-    iMesh_getTagSizeValues(self->mesh->mesh,self->tag.handle,&size,&err);
-    if(checkError(self->mesh->mesh,err))
-        return NULL;
-
-    return Py_BuildValue("i",size);
-}
-
-static PyObject *
-iMeshTagObj_getSizeBytes(iMeshTag_Object *self,void *closure)
-{
-    int size,err;
-    iMesh_getTagSizeBytes(self->mesh->mesh,self->tag.handle,&size,&err);
-    if(checkError(self->mesh->mesh,err))
-        return NULL;
-
-    return Py_BuildValue("i",size);
-}
-
-static PyObject *
-iMeshTagObj_getType(iMeshTag_Object *self,void *closure)
-{
-    int type,err;
-    iMesh_getTagType(self->mesh->mesh,self->tag.handle,&type,&err);
-    if(checkError(self->mesh->mesh,err))
-        return NULL;
-
-    return Py_BuildValue("c",type_to_char(type));
-}
-
-static PyObject *
-iMeshTagObj_setData(iMeshTag_Object *self,PyObject *args)
-{
-    PyObject *obj;
-    PyObject *data_obj;
-    char typechar=0;
-    int type;
-    int err;
-
-    if(!PyArg_ParseTuple(args,"OO|c",&obj,&data_obj,&typechar))
-        return NULL;
-
-    if(typechar == 0)
-    {
-        /* infer the type of the data */
-        iMesh_getTagType(self->mesh->mesh,self->tag.handle,&type,&err);
-        if(checkError(self->mesh->mesh,err))
-            return NULL;
-    }
-    else
-    {
-        type = char_to_type(typechar);
-        if(type == -1)
-        {
-            PyErr_SetString(PyExc_ValueError,ERR_TYPE_CODE);
-            return NULL;
-        }
-    }
- 
-    PyObject *ents = PyArray_TryFromObject(obj,NPY_IBASEENT,1,1);
-    if(ents)
-    {
-        int ent_size;
-        iBase_EntityHandle *entities;
-        int data_size;
-        PyObject *data_arr=0;
-
-        ent_size = PyArray_SIZE(ents);
-        entities = PyArray_DATA(ents);
-
-        if(type == iBase_INTEGER)
-        {
-            data_arr = PyArray_FROMANY(data_obj,NPY_INT,1,1,NPY_C_CONTIGUOUS);
-            if(data_arr == NULL)
-                return NULL;
-
-            data_size = PyArray_SIZE(data_arr);
-            int *data = PyArray_DATA(data_arr);
-            iMesh_setIntArrData(self->mesh->mesh,entities,ent_size,
-                                self->tag.handle,data,data_size,&err);
-        }
-        else if(type == iBase_DOUBLE)
-        {
-            data_arr = PyArray_FROMANY(data_obj,NPY_DOUBLE,1,1,
-                                       NPY_C_CONTIGUOUS);
-            if(data_arr == NULL)
-                return NULL;
-
-            data_size = PyArray_SIZE(data_arr);
-            double *data = PyArray_DATA(data_arr);
-            iMesh_setDblArrData(self->mesh->mesh,entities,ent_size,
-                                self->tag.handle,data,data_size,&err);
-        }
-        else if(type == iBase_ENTITY_HANDLE)
-        {
-            data_arr = PyArray_FROMANY(data_obj,NPY_IBASEENT,1,1,
-                                       NPY_C_CONTIGUOUS);
-            if(data_arr == NULL)
-                return NULL;
-
-            data_size = PyArray_SIZE(data_arr);
-            iBase_EntityHandle *data = PyArray_DATA(data_arr);
-            iMesh_setEHArrData(self->mesh->mesh,entities,ent_size,
-                               self->tag.handle,data,data_size,&err);
-        }
-        else /* iBase_BYTES */
-        {
-            data_arr = PyArray_FROMANY(data_obj,NPY_BYTE,1,1,NPY_C_CONTIGUOUS);
-            if(data_arr == NULL)
-                return NULL;
-
-            data_size = PyArray_SIZE(data_arr);
-            char *data = PyArray_DATA(data_arr);
-            iMesh_setArrData(self->mesh->mesh,entities,ent_size,
-                             self->tag.handle,data,data_size,&err);
-        }
-
-        Py_DECREF(ents);
-        Py_XDECREF(data_arr);
-    }
-    else if(iBaseEntitySet_Check(obj))
-    {
-        iBase_EntitySetHandle set = iBaseEntitySet_GetHandle(obj);
-
-        if(type == iBase_INTEGER)
-        {
-            PyObject *o = PyNumber_Int(data_obj);
-            if(o == NULL)
-                return NULL;
-            iMesh_setEntSetIntData(self->mesh->mesh,set,self->tag.handle,
-                                   PyInt_AsLong(o),&err);
-            Py_DECREF(o);
-        }
-        else if(type == iBase_DOUBLE)
-        {
-            PyObject *o = PyNumber_Float(data_obj);
-            if(o == NULL)
-                return NULL;
-            iMesh_setEntSetDblData(self->mesh->mesh,set,self->tag.handle,
-                                   PyFloat_AsDouble(o),&err);
-            Py_DECREF(o);
-        }
-        else if(type == iBase_ENTITY_HANDLE)
-        {
-            if(!iBaseEntity_Check(data_obj))
-                return NULL;
-            iMesh_setEntSetEHData(self->mesh->mesh,set,self->tag.handle,
-                                  iBaseEntity_GetHandle(data_obj),&err);
-        }
-        else /* iBase_BYTES */
-        {
-            PyObject *data_arr = PyArray_FROMANY(data_obj,NPY_BYTE,1,1,
-                                                 NPY_C_CONTIGUOUS);
-            if(data_arr == NULL)
-                return NULL;
-
-            char *data = PyArray_DATA(data_arr);
-            int data_size = PyArray_SIZE(data_arr);
-            iMesh_setEntSetData(self->mesh->mesh,set,self->tag.handle,data,
-                                data_size,&err);
-            Py_DECREF(data_arr);
-        }
-    }
-    else if(iBaseEntity_Check(obj))
-    {
-        iBase_EntityHandle entity = iBaseEntity_GetHandle(obj);
-
-        if(type == iBase_INTEGER)
-        {
-            PyObject *o = PyNumber_Int(data_obj);
-            if(o == NULL)
-                return NULL;
-            iMesh_setIntData(self->mesh->mesh,entity,self->tag.handle,
-                             PyInt_AsLong(o),&err);
-            Py_DECREF(o);
-        }
-        else if(type == iBase_DOUBLE)
-        {
-            PyObject *o = PyNumber_Float(data_obj);
-            if(o == NULL)
-                return NULL;
-            iMesh_setDblData(self->mesh->mesh,entity,self->tag.handle,
-                             PyFloat_AsDouble(o),&err);
-            Py_DECREF(o);
-        }
-        else if(type == iBase_ENTITY_HANDLE)
-        {
-            if(!iBaseEntity_Check(data_obj))
-                return NULL;
-            iMesh_setEHData(self->mesh->mesh,entity,self->tag.handle,
-                            iBaseEntity_GetHandle(data_obj),&err);
-        }
-        else /* iBase_BYTES */
-        {
-            PyObject *data_arr = PyArray_FROMANY(data_obj,NPY_BYTE,1,1,
-                                                 NPY_C_CONTIGUOUS);
-            if(data_arr == NULL)
-                return NULL;
-
-            char *data = PyArray_DATA(data_arr);
-            int data_size = PyArray_SIZE(data_arr);
-            iMesh_setData(self->mesh->mesh,entity,self->tag.handle,data,
-                          data_size,&err);
-            Py_DECREF(data_arr);
-        }
-    }
-    else
-    {
-        PyErr_SetString(PyExc_ValueError,ERR_ANY_ENT);
-        return NULL;
-    }
-
-    if(checkError(self->mesh->mesh,err))
-        return NULL;
-    Py_RETURN_NONE;
-}
-
-static PyObject *
-iMeshTagObj_getData(iMeshTag_Object *self,PyObject *args)
-{
-    PyObject *obj;
-    char typechar=0;
-    int type;
-    int err;
-
-    if(!PyArg_ParseTuple(args,"O|c",&obj,&typechar))
-        return NULL;
-
-    if(typechar == 0)
-    {
-        /* infer the type of the data */
-        iMesh_getTagType(self->mesh->mesh,self->tag.handle,&type,&err);
-        if(checkError(self->mesh->mesh,err))
-            return NULL;
-    }
-    else
-    {
-        type = char_to_type(typechar);
-        if(type == -1)
-        {
-            PyErr_SetString(PyExc_ValueError,"invalid type code");
-            return NULL;
-        }
-    }
-
-    PyObject *ents = PyArray_TryFromObject(obj,NPY_IBASEENT,1,1);
-    if(ents)
-    {
-        int ent_size = PyArray_SIZE(ents);
-        iBase_EntityHandle *entities = PyArray_DATA(ents);
-        PyObject *ret = 0;
-
-        if(type == iBase_INTEGER)
-        {
-            int *data=0;
-            int alloc=0,size;
-
-            iMesh_getIntArrData(self->mesh->mesh,entities,ent_size,
-                                self->tag.handle,&data,&alloc,&size,&err);
-            if(!checkError(self->mesh->mesh,err))
-            {
-                npy_intp dims[] = {size};
-                ret = PyArray_NewFromMalloc(1,dims,NPY_INT,data);
-            }
-        }
-        else if(type == iBase_DOUBLE)
-        {
-            double *data=0;
-            int alloc=0,size;
-
-            iMesh_getDblArrData(self->mesh->mesh,entities,ent_size,
-                                self->tag.handle,&data,&alloc,&size,&err);
-            if(!checkError(self->mesh->mesh,err))
-            {
-                npy_intp dims[] = {size};
-                ret = PyArray_NewFromMalloc(1,dims,NPY_DOUBLE,data);
-            }
-        }
-        else if(type == iBase_ENTITY_HANDLE)
-        {
-            iBase_EntityHandle *data=0;
-            int alloc=0,size;
-
-            iMesh_getEHArrData(self->mesh->mesh,entities,ent_size,
-                               self->tag.handle,&data,&alloc,&size,&err);
-            if(!checkError(self->mesh->mesh,err))
-            {
-                npy_intp dims[] = {size};
-                ret = PyArray_NewFromMalloc(1,dims,NPY_IBASEENT,data);
-            }
-        }
-        else /* iBase_BYTES */
-        {
-            char *data=0;
-            int alloc=0,size;
-
-            iMesh_getArrData(self->mesh->mesh,entities,ent_size,
-                             self->tag.handle,&data,&alloc,&size,&err);
-            if(!checkError(self->mesh->mesh,err))
-            {
-                npy_intp dims[] = {size};
-                ret = PyArray_NewFromMalloc(1,dims,NPY_BYTE,data);
-            }
-        }
-
-        Py_DECREF(ents);
-        return ret;
-    }
-    else if(iBaseEntitySet_Check(obj))
-    {
-        iBase_EntitySetHandle set = iBaseEntitySet_GetHandle(obj);
-
-        if(type == iBase_INTEGER)
-        {
-            int data;
-            iMesh_getEntSetIntData(self->mesh->mesh,set,self->tag.handle,&data,
-                                   &err);
-            if(checkError(self->mesh->mesh,err))
-                return NULL;
-            return Py_BuildValue("i",data);
-        }
-        else if(type == iBase_DOUBLE)
-        {
-            double data;
-            iMesh_getEntSetDblData(self->mesh->mesh,set,self->tag.handle,&data,
-                                   &err);
-            if(checkError(self->mesh->mesh,err))
-                return NULL;
-            return Py_BuildValue("d",data);
-        }
-        else if(type == iBase_ENTITY_HANDLE)
-        {
-            iBaseEntity_Object *data = iBaseEntity_New();
-            iMesh_getEntSetEHData(self->mesh->mesh,set,self->tag.handle,
-                                  &data->handle,&err);
-            if(checkError(self->mesh->mesh,err))
-            {
-                Py_DECREF(data);
-                return NULL;
-            }
-            return (PyObject*)data;
-        }
-        else /* iBase_BYTES */
-        {
-            char *data=0;
-            int alloc=0,size;
-            iMesh_getEntSetData(self->mesh->mesh,set,self->tag.handle,&data,
-                                &alloc,&size,&err);
-            if(checkError(self->mesh->mesh,err))
-                return NULL;
-            npy_intp dims[] = {size};
-            return PyArray_NewFromMalloc(1,dims,NPY_BYTE,data);
-        }
-    }
-    else if(iBaseEntity_Check(obj))
-    {
-        iBase_EntityHandle entity = iBaseEntity_GetHandle(obj);
-
-        if(type == iBase_INTEGER)
-        {
-            int data;
-            iMesh_getIntData(self->mesh->mesh,entity,self->tag.handle,&data,
-                             &err);
-            if(checkError(self->mesh->mesh,err))
-                return NULL;
-            return Py_BuildValue("i",data);
-        }
-        else if(type == iBase_DOUBLE)
-        {
-            double data;
-            iMesh_getDblData(self->mesh->mesh,entity,self->tag.handle,&data,
-                             &err);
-            if(checkError(self->mesh->mesh,err))
-                return NULL;
-            return Py_BuildValue("d",data);
-        }
-        else if(type == iBase_ENTITY_HANDLE)
-        {
-            iBaseEntity_Object *data = iBaseEntity_New();
-            iMesh_getEHData(self->mesh->mesh,entity,self->tag.handle,
-                            &data->handle,&err);
-            if(checkError(self->mesh->mesh,err))
-            {
-                Py_DECREF(data);
-                return NULL;
-            }
-            return (PyObject*)data;
-        }
-        else /* iBase_BYTES */
-        {
-            char *data=0;
-            int alloc=0,size;
-            iMesh_getData(self->mesh->mesh,entity,self->tag.handle,&data,
-                          &alloc,&size,&err);
-            if(checkError(self->mesh->mesh,err))
-                return NULL;
-            npy_intp dims[] = {size};
-            return PyArray_NewFromMalloc(1,dims,NPY_BYTE,data);
-        }
-    }
-    else
-    {
-        PyErr_SetString(PyExc_ValueError,ERR_ANY_ENT);
-        return NULL;
-    }
-}
-
-static PyObject *
-iMeshTagObj_remove(iMeshTag_Object *self,PyObject *args)
-{
-    PyObject *obj;
-    int err;
-
-    if(!PyArg_ParseTuple(args,"O",&obj))
-        return NULL;
-
-    PyObject *ents = PyArray_TryFromObject(obj,NPY_IBASEENT,1,1);
-    if(ents)
-    {
-        int ent_size = PyArray_SIZE(ents);
-        iBase_EntityHandle *entities = PyArray_DATA(ents);
-        iMesh_rmvArrTag(self->mesh->mesh,entities,ent_size,self->tag.handle,
-                        &err);
-        Py_DECREF(ents);
-    }
-    else if(iBaseEntitySet_Check(obj))
-    {
-        iBase_EntitySetHandle set = iBaseEntitySet_GetHandle(obj);
-        iMesh_rmvEntSetTag(self->mesh->mesh,set,self->tag.handle,&err);
-    }
-    else if(iBaseEntity_Check(obj))
-    {
-        iBase_EntityHandle entity = iBaseEntity_GetHandle(obj);
-        iMesh_rmvTag(self->mesh->mesh,entity,self->tag.handle,&err);
-    }
-    else
-    {
-        PyErr_SetString(PyExc_ValueError,ERR_ANY_ENT);
-        return NULL;
-    }
-
-    if(checkError(self->mesh->mesh,err))
-        return NULL;
-    Py_RETURN_NONE;
-}
-
-
-static PyMethodDef iMeshTagObj_methods[] = {
-    { "setData", (PyCFunction)iMeshTagObj_setData, METH_VARARGS,
-      "Set tag values on an entity (or array/set of entities)"
-    },
-    { "getData", (PyCFunction)iMeshTagObj_getData, METH_VARARGS,
-      "Get tag values on an entity (or array/set of entities)"
-    },
-    { "remove", (PyCFunction)iMeshTagObj_remove, METH_VARARGS,
-      "Remove a tag value from an entity (or array/set of entities)"
-    },
-    {0}
-};
-
-static PyMemberDef iMeshTagObj_members[] = {
-    {"instance", T_OBJECT_EX, offsetof(iMeshTag_Object, mesh), READONLY,
-     "base iMesh instance"},
-    {0}
-};
-
-static PyGetSetDef iMeshTagObj_getset[] = {
-    { "name", (getter)iMeshTagObj_getName, 0,
-      "Get the name for a given tag handle", 0
-    },
-    { "sizeValues", (getter)iMeshTagObj_getSizeValues, 0,
-      "Get size of a tag in units of numbers of tag data type", 0
-    },
-    { "sizeBytes", (getter)iMeshTagObj_getSizeBytes, 0,
-      "Get size of a tag in units of bytes", 0
-    },
-    { "type", (getter)iMeshTagObj_getType, 0,
-      "Get the data type of the specified tag handle", 0
-    },
-    {0}
-};
-
-
-PyTypeObject iMeshTag_Type = {
-    PyObject_HEAD_INIT(NULL)
-    0,                                   /* ob_size */
-    "itaps.iMesh.Tag",                   /* tp_name */
-    sizeof(iMeshTag_Object),             /* tp_basicsize */
-    0,                                   /* tp_itemsize */
-    (destructor)iMeshTagObj_dealloc,     /* tp_dealloc */
-    0,                                   /* tp_print */
-    0,                                   /* tp_getattr */
-    0,                                   /* tp_setattr */
-    0,                                   /* tp_compare */
-    0,                                   /* tp_repr */
-    0,                                   /* tp_as_number */
-    0,                                   /* tp_as_sequence */
-    0,                                   /* tp_as_mapping */
-    0,                                   /* tp_hash */
-    0,                                   /* tp_call */
-    0,                                   /* tp_str */
-    0,                                   /* tp_getattro */
-    0,                                   /* tp_setattro */
-    0,                                   /* tp_as_buffer */
-    Py_TPFLAGS_DEFAULT |
-    Py_TPFLAGS_BASETYPE,                 /* tp_flags */
-    "iMesh tag object",                  /* tp_doc */
-    0,                                   /* tp_traverse */
-    0,                                   /* tp_clear */
-    0,                                   /* tp_richcompare */
-    0,                                   /* tp_weaklistoffset */
-    0,                                   /* tp_iter */
-    0,                                   /* tp_iternext */
-    iMeshTagObj_methods,                 /* tp_methods */
-    iMeshTagObj_members,                 /* tp_members */
-    iMeshTagObj_getset,                  /* 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 */
-};
-

Copied: MOAB/trunk/tools/iMesh/python/iMesh_tag.inl (from rev 2930, MOAB/trunk/tools/iMesh/python/iMesh_tag.c)
===================================================================
--- MOAB/trunk/tools/iMesh/python/iMesh_tag.inl	                        (rev 0)
+++ MOAB/trunk/tools/iMesh/python/iMesh_tag.inl	2009-06-08 23:15:37 UTC (rev 2936)
@@ -0,0 +1,577 @@
+#define NO_IMPORT_ARRAY
+#define NO_IMPORT_IBASE
+
+#include "iMesh_Python.h"
+#include "iBase_Python.h"
+#include "errors.h"
+#include "structmember.h"
+
+static char typechars[] = {'i','d','E','b'};
+
+static enum iBase_TagValueType
+char_to_type(char c)
+{
+    int i;
+    for(i=0; i<sizeof(typechars); i++)
+    {
+        if(typechars[i] == c)
+            return i;
+    }
+    return -1;
+}
+
+static char
+type_to_char(enum iBase_TagValueType t)
+{
+    return typechars[t];
+}
+
+
+static void
+iMeshTagObj_dealloc(iMeshTag_Object *self)
+{
+    Py_XDECREF(self->mesh);
+    ((PyObject*)self)->ob_type->tp_free((PyObject*)self);
+}
+
+static PyObject *
+iMeshTagObj_getName(iMeshTag_Object *self,void *closure)
+{
+    char name[512];
+    int err;
+    iMesh_getTagName(self->mesh->mesh,self->tag.handle,name,&err,sizeof(name));
+    if(checkError(self->mesh->mesh,err))
+        return NULL;
+
+    return Py_BuildValue("s",name);
+}
+
+static PyObject *
+iMeshTagObj_getSizeValues(iMeshTag_Object *self,void *closure)
+{
+    int size,err;
+    iMesh_getTagSizeValues(self->mesh->mesh,self->tag.handle,&size,&err);
+    if(checkError(self->mesh->mesh,err))
+        return NULL;
+
+    return Py_BuildValue("i",size);
+}
+
+static PyObject *
+iMeshTagObj_getSizeBytes(iMeshTag_Object *self,void *closure)
+{
+    int size,err;
+    iMesh_getTagSizeBytes(self->mesh->mesh,self->tag.handle,&size,&err);
+    if(checkError(self->mesh->mesh,err))
+        return NULL;
+
+    return Py_BuildValue("i",size);
+}
+
+static PyObject *
+iMeshTagObj_getType(iMeshTag_Object *self,void *closure)
+{
+    int type,err;
+    iMesh_getTagType(self->mesh->mesh,self->tag.handle,&type,&err);
+    if(checkError(self->mesh->mesh,err))
+        return NULL;
+
+    return Py_BuildValue("c",type_to_char(type));
+}
+
+static PyObject *
+iMeshTagObj_setData(iMeshTag_Object *self,PyObject *args)
+{
+    PyObject *obj;
+    PyObject *data_obj;
+    char typechar=0;
+    int type;
+    int err;
+
+    if(!PyArg_ParseTuple(args,"OO|c",&obj,&data_obj,&typechar))
+        return NULL;
+
+    if(typechar == 0)
+    {
+        /* infer the type of the data */
+        iMesh_getTagType(self->mesh->mesh,self->tag.handle,&type,&err);
+        if(checkError(self->mesh->mesh,err))
+            return NULL;
+    }
+    else
+    {
+        type = char_to_type(typechar);
+        if(type == -1)
+        {
+            PyErr_SetString(PyExc_ValueError,ERR_TYPE_CODE);
+            return NULL;
+        }
+    }
+ 
+    PyObject *ents = PyArray_TryFromObject(obj,NPY_IBASEENT,1,1);
+    if(ents)
+    {
+        int ent_size;
+        iBase_EntityHandle *entities;
+        int data_size;
+        PyObject *data_arr=0;
+
+        ent_size = PyArray_SIZE(ents);
+        entities = PyArray_DATA(ents);
+
+        if(type == iBase_INTEGER)
+        {
+            data_arr = PyArray_FROMANY(data_obj,NPY_INT,1,1,NPY_C_CONTIGUOUS);
+            if(data_arr == NULL)
+                return NULL;
+
+            data_size = PyArray_SIZE(data_arr);
+            int *data = PyArray_DATA(data_arr);
+            iMesh_setIntArrData(self->mesh->mesh,entities,ent_size,
+                                self->tag.handle,data,data_size,&err);
+        }
+        else if(type == iBase_DOUBLE)
+        {
+            data_arr = PyArray_FROMANY(data_obj,NPY_DOUBLE,1,1,
+                                       NPY_C_CONTIGUOUS);
+            if(data_arr == NULL)
+                return NULL;
+
+            data_size = PyArray_SIZE(data_arr);
+            double *data = PyArray_DATA(data_arr);
+            iMesh_setDblArrData(self->mesh->mesh,entities,ent_size,
+                                self->tag.handle,data,data_size,&err);
+        }
+        else if(type == iBase_ENTITY_HANDLE)
+        {
+            data_arr = PyArray_FROMANY(data_obj,NPY_IBASEENT,1,1,
+                                       NPY_C_CONTIGUOUS);
+            if(data_arr == NULL)
+                return NULL;
+
+            data_size = PyArray_SIZE(data_arr);
+            iBase_EntityHandle *data = PyArray_DATA(data_arr);
+            iMesh_setEHArrData(self->mesh->mesh,entities,ent_size,
+                               self->tag.handle,data,data_size,&err);
+        }
+        else /* iBase_BYTES */
+        {
+            data_arr = PyArray_FROMANY(data_obj,NPY_BYTE,1,1,NPY_C_CONTIGUOUS);
+            if(data_arr == NULL)
+                return NULL;
+
+            data_size = PyArray_SIZE(data_arr);
+            char *data = PyArray_DATA(data_arr);
+            iMesh_setArrData(self->mesh->mesh,entities,ent_size,
+                             self->tag.handle,data,data_size,&err);
+        }
+
+        Py_DECREF(ents);
+        Py_XDECREF(data_arr);
+    }
+    else if(iBaseEntitySet_Check(obj))
+    {
+        iBase_EntitySetHandle set = iBaseEntitySet_GetHandle(obj);
+
+        if(type == iBase_INTEGER)
+        {
+            PyObject *o = PyNumber_Int(data_obj);
+            if(o == NULL)
+                return NULL;
+            iMesh_setEntSetIntData(self->mesh->mesh,set,self->tag.handle,
+                                   PyInt_AsLong(o),&err);
+            Py_DECREF(o);
+        }
+        else if(type == iBase_DOUBLE)
+        {
+            PyObject *o = PyNumber_Float(data_obj);
+            if(o == NULL)
+                return NULL;
+            iMesh_setEntSetDblData(self->mesh->mesh,set,self->tag.handle,
+                                   PyFloat_AsDouble(o),&err);
+            Py_DECREF(o);
+        }
+        else if(type == iBase_ENTITY_HANDLE)
+        {
+            if(!iBaseEntity_Check(data_obj))
+                return NULL;
+            iMesh_setEntSetEHData(self->mesh->mesh,set,self->tag.handle,
+                                  iBaseEntity_GetHandle(data_obj),&err);
+        }
+        else /* iBase_BYTES */
+        {
+            PyObject *data_arr = PyArray_FROMANY(data_obj,NPY_BYTE,1,1,
+                                                 NPY_C_CONTIGUOUS);
+            if(data_arr == NULL)
+                return NULL;
+
+            char *data = PyArray_DATA(data_arr);
+            int data_size = PyArray_SIZE(data_arr);
+            iMesh_setEntSetData(self->mesh->mesh,set,self->tag.handle,data,
+                                data_size,&err);
+            Py_DECREF(data_arr);
+        }
+    }
+    else if(iBaseEntity_Check(obj))
+    {
+        iBase_EntityHandle entity = iBaseEntity_GetHandle(obj);
+
+        if(type == iBase_INTEGER)
+        {
+            PyObject *o = PyNumber_Int(data_obj);
+            if(o == NULL)
+                return NULL;
+            iMesh_setIntData(self->mesh->mesh,entity,self->tag.handle,
+                             PyInt_AsLong(o),&err);
+            Py_DECREF(o);
+        }
+        else if(type == iBase_DOUBLE)
+        {
+            PyObject *o = PyNumber_Float(data_obj);
+            if(o == NULL)
+                return NULL;
+            iMesh_setDblData(self->mesh->mesh,entity,self->tag.handle,
+                             PyFloat_AsDouble(o),&err);
+            Py_DECREF(o);
+        }
+        else if(type == iBase_ENTITY_HANDLE)
+        {
+            if(!iBaseEntity_Check(data_obj))
+                return NULL;
+            iMesh_setEHData(self->mesh->mesh,entity,self->tag.handle,
+                            iBaseEntity_GetHandle(data_obj),&err);
+        }
+        else /* iBase_BYTES */
+        {
+            PyObject *data_arr = PyArray_FROMANY(data_obj,NPY_BYTE,1,1,
+                                                 NPY_C_CONTIGUOUS);
+            if(data_arr == NULL)
+                return NULL;
+
+            char *data = PyArray_DATA(data_arr);
+            int data_size = PyArray_SIZE(data_arr);
+            iMesh_setData(self->mesh->mesh,entity,self->tag.handle,data,
+                          data_size,&err);
+            Py_DECREF(data_arr);
+        }
+    }
+    else
+    {
+        PyErr_SetString(PyExc_ValueError,ERR_ANY_ENT);
+        return NULL;
+    }
+
+    if(checkError(self->mesh->mesh,err))
+        return NULL;
+    Py_RETURN_NONE;
+}
+
+static PyObject *
+iMeshTagObj_getData(iMeshTag_Object *self,PyObject *args)
+{
+    PyObject *obj;
+    char typechar=0;
+    int type;
+    int err;
+
+    if(!PyArg_ParseTuple(args,"O|c",&obj,&typechar))
+        return NULL;
+
+    if(typechar == 0)
+    {
+        /* infer the type of the data */
+        iMesh_getTagType(self->mesh->mesh,self->tag.handle,&type,&err);
+        if(checkError(self->mesh->mesh,err))
+            return NULL;
+    }
+    else
+    {
+        type = char_to_type(typechar);
+        if(type == -1)
+        {
+            PyErr_SetString(PyExc_ValueError,"invalid type code");
+            return NULL;
+        }
+    }
+
+    PyObject *ents = PyArray_TryFromObject(obj,NPY_IBASEENT,1,1);
+    if(ents)
+    {
+        int ent_size = PyArray_SIZE(ents);
+        iBase_EntityHandle *entities = PyArray_DATA(ents);
+        PyObject *ret = 0;
+
+        if(type == iBase_INTEGER)
+        {
+            int *data=0;
+            int alloc=0,size;
+
+            iMesh_getIntArrData(self->mesh->mesh,entities,ent_size,
+                                self->tag.handle,&data,&alloc,&size,&err);
+            if(!checkError(self->mesh->mesh,err))
+            {
+                npy_intp dims[] = {size};
+                ret = PyArray_NewFromMalloc(1,dims,NPY_INT,data);
+            }
+        }
+        else if(type == iBase_DOUBLE)
+        {
+            double *data=0;
+            int alloc=0,size;
+
+            iMesh_getDblArrData(self->mesh->mesh,entities,ent_size,
+                                self->tag.handle,&data,&alloc,&size,&err);
+            if(!checkError(self->mesh->mesh,err))
+            {
+                npy_intp dims[] = {size};
+                ret = PyArray_NewFromMalloc(1,dims,NPY_DOUBLE,data);
+            }
+        }
+        else if(type == iBase_ENTITY_HANDLE)
+        {
+            iBase_EntityHandle *data=0;
+            int alloc=0,size;
+
+            iMesh_getEHArrData(self->mesh->mesh,entities,ent_size,
+                               self->tag.handle,&data,&alloc,&size,&err);
+            if(!checkError(self->mesh->mesh,err))
+            {
+                npy_intp dims[] = {size};
+                ret = PyArray_NewFromMalloc(1,dims,NPY_IBASEENT,data);
+            }
+        }
+        else /* iBase_BYTES */
+        {
+            char *data=0;
+            int alloc=0,size;
+
+            iMesh_getArrData(self->mesh->mesh,entities,ent_size,
+                             self->tag.handle,&data,&alloc,&size,&err);
+            if(!checkError(self->mesh->mesh,err))
+            {
+                npy_intp dims[] = {size};
+                ret = PyArray_NewFromMalloc(1,dims,NPY_BYTE,data);
+            }
+        }
+
+        Py_DECREF(ents);
+        return ret;
+    }
+    else if(iBaseEntitySet_Check(obj))
+    {
+        iBase_EntitySetHandle set = iBaseEntitySet_GetHandle(obj);
+
+        if(type == iBase_INTEGER)
+        {
+            int data;
+            iMesh_getEntSetIntData(self->mesh->mesh,set,self->tag.handle,&data,
+                                   &err);
+            if(checkError(self->mesh->mesh,err))
+                return NULL;
+            return Py_BuildValue("i",data);
+        }
+        else if(type == iBase_DOUBLE)
+        {
+            double data;
+            iMesh_getEntSetDblData(self->mesh->mesh,set,self->tag.handle,&data,
+                                   &err);
+            if(checkError(self->mesh->mesh,err))
+                return NULL;
+            return Py_BuildValue("d",data);
+        }
+        else if(type == iBase_ENTITY_HANDLE)
+        {
+            iBaseEntity_Object *data = iBaseEntity_New();
+            iMesh_getEntSetEHData(self->mesh->mesh,set,self->tag.handle,
+                                  &data->handle,&err);
+            if(checkError(self->mesh->mesh,err))
+            {
+                Py_DECREF(data);
+                return NULL;
+            }
+            return (PyObject*)data;
+        }
+        else /* iBase_BYTES */
+        {
+            char *data=0;
+            int alloc=0,size;
+            iMesh_getEntSetData(self->mesh->mesh,set,self->tag.handle,&data,
+                                &alloc,&size,&err);
+            if(checkError(self->mesh->mesh,err))
+                return NULL;
+            npy_intp dims[] = {size};
+            return PyArray_NewFromMalloc(1,dims,NPY_BYTE,data);
+        }
+    }
+    else if(iBaseEntity_Check(obj))
+    {
+        iBase_EntityHandle entity = iBaseEntity_GetHandle(obj);
+
+        if(type == iBase_INTEGER)
+        {
+            int data;
+            iMesh_getIntData(self->mesh->mesh,entity,self->tag.handle,&data,
+                             &err);
+            if(checkError(self->mesh->mesh,err))
+                return NULL;
+            return Py_BuildValue("i",data);
+        }
+        else if(type == iBase_DOUBLE)
+        {
+            double data;
+            iMesh_getDblData(self->mesh->mesh,entity,self->tag.handle,&data,
+                             &err);
+            if(checkError(self->mesh->mesh,err))
+                return NULL;
+            return Py_BuildValue("d",data);
+        }
+        else if(type == iBase_ENTITY_HANDLE)
+        {
+            iBaseEntity_Object *data = iBaseEntity_New();
+            iMesh_getEHData(self->mesh->mesh,entity,self->tag.handle,
+                            &data->handle,&err);
+            if(checkError(self->mesh->mesh,err))
+            {
+                Py_DECREF(data);
+                return NULL;
+            }
+            return (PyObject*)data;
+        }
+        else /* iBase_BYTES */
+        {
+            char *data=0;
+            int alloc=0,size;
+            iMesh_getData(self->mesh->mesh,entity,self->tag.handle,&data,
+                          &alloc,&size,&err);
+            if(checkError(self->mesh->mesh,err))
+                return NULL;
+            npy_intp dims[] = {size};
+            return PyArray_NewFromMalloc(1,dims,NPY_BYTE,data);
+        }
+    }
+    else
+    {
+        PyErr_SetString(PyExc_ValueError,ERR_ANY_ENT);
+        return NULL;
+    }
+}
+
+static PyObject *
+iMeshTagObj_remove(iMeshTag_Object *self,PyObject *args)
+{
+    PyObject *obj;
+    int err;
+
+    if(!PyArg_ParseTuple(args,"O",&obj))
+        return NULL;
+
+    PyObject *ents = PyArray_TryFromObject(obj,NPY_IBASEENT,1,1);
+    if(ents)
+    {
+        int ent_size = PyArray_SIZE(ents);
+        iBase_EntityHandle *entities = PyArray_DATA(ents);
+        iMesh_rmvArrTag(self->mesh->mesh,entities,ent_size,self->tag.handle,
+                        &err);
+        Py_DECREF(ents);
+    }
+    else if(iBaseEntitySet_Check(obj))
+    {
+        iBase_EntitySetHandle set = iBaseEntitySet_GetHandle(obj);
+        iMesh_rmvEntSetTag(self->mesh->mesh,set,self->tag.handle,&err);
+    }
+    else if(iBaseEntity_Check(obj))
+    {
+        iBase_EntityHandle entity = iBaseEntity_GetHandle(obj);
+        iMesh_rmvTag(self->mesh->mesh,entity,self->tag.handle,&err);
+    }
+    else
+    {
+        PyErr_SetString(PyExc_ValueError,ERR_ANY_ENT);
+        return NULL;
+    }
+
+    if(checkError(self->mesh->mesh,err))
+        return NULL;
+    Py_RETURN_NONE;
+}
+
+
+static PyMethodDef iMeshTagObj_methods[] = {
+    { "setData", (PyCFunction)iMeshTagObj_setData, METH_VARARGS,
+      "Set tag values on an entity (or array/set of entities)"
+    },
+    { "getData", (PyCFunction)iMeshTagObj_getData, METH_VARARGS,
+      "Get tag values on an entity (or array/set of entities)"
+    },
+    { "remove", (PyCFunction)iMeshTagObj_remove, METH_VARARGS,
+      "Remove a tag value from an entity (or array/set of entities)"
+    },
+    {0}
+};
+
+static PyMemberDef iMeshTagObj_members[] = {
+    {"instance", T_OBJECT_EX, offsetof(iMeshTag_Object, mesh), READONLY,
+     "base iMesh instance"},
+    {0}
+};
+
+static PyGetSetDef iMeshTagObj_getset[] = {
+    { "name", (getter)iMeshTagObj_getName, 0,
+      "Get the name for a given tag handle", 0
+    },
+    { "sizeValues", (getter)iMeshTagObj_getSizeValues, 0,
+      "Get size of a tag in units of numbers of tag data type", 0
+    },
+    { "sizeBytes", (getter)iMeshTagObj_getSizeBytes, 0,
+      "Get size of a tag in units of bytes", 0
+    },
+    { "type", (getter)iMeshTagObj_getType, 0,
+      "Get the data type of the specified tag handle", 0
+    },
+    {0}
+};
+
+
+static PyTypeObject iMeshTag_Type = {
+    PyObject_HEAD_INIT(NULL)
+    0,                                   /* ob_size */
+    "itaps.iMesh.Tag",                   /* tp_name */
+    sizeof(iMeshTag_Object),             /* tp_basicsize */
+    0,                                   /* tp_itemsize */
+    (destructor)iMeshTagObj_dealloc,     /* tp_dealloc */
+    0,                                   /* tp_print */
+    0,                                   /* tp_getattr */
+    0,                                   /* tp_setattr */
+    0,                                   /* tp_compare */
+    0,                                   /* tp_repr */
+    0,                                   /* tp_as_number */
+    0,                                   /* tp_as_sequence */
+    0,                                   /* tp_as_mapping */
+    0,                                   /* tp_hash */
+    0,                                   /* tp_call */
+    0,                                   /* tp_str */
+    0,                                   /* tp_getattro */
+    0,                                   /* tp_setattro */
+    0,                                   /* tp_as_buffer */
+    Py_TPFLAGS_DEFAULT |
+    Py_TPFLAGS_BASETYPE,                 /* tp_flags */
+    "iMesh tag object",                  /* tp_doc */
+    0,                                   /* tp_traverse */
+    0,                                   /* tp_clear */
+    0,                                   /* tp_richcompare */
+    0,                                   /* tp_weaklistoffset */
+    0,                                   /* tp_iter */
+    0,                                   /* tp_iternext */
+    iMeshTagObj_methods,                 /* tp_methods */
+    iMeshTagObj_members,                 /* tp_members */
+    iMeshTagObj_getset,                  /* 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 */
+};
+


Property changes on: MOAB/trunk/tools/iMesh/python/iMesh_tag.inl
___________________________________________________________________
Name: svn:mergeinfo
   + 

Modified: MOAB/trunk/tools/iMesh/python/setup.py
===================================================================
--- MOAB/trunk/tools/iMesh/python/setup.py	2009-06-08 22:45:22 UTC (rev 2935)
+++ MOAB/trunk/tools/iMesh/python/setup.py	2009-06-08 23:15:37 UTC (rev 2936)
@@ -11,7 +11,6 @@
 iMesh_libs = []
 iMesh_libdirs = []
 iMesh_incs = []
-compileargs = ''
 
 if 'IMESHPATH' in os.environ:
     defs = parse_makefile( os.path.join(os.environ['IMESHPATH'],
@@ -38,10 +37,10 @@
                   include_dirs = iMesh_incs,
                   libraries    = iMesh_libs,
                   library_dirs = iMesh_libdirs,
-                  depends      = ['common.h', 'iMesh_Python.h',
-                                  'iBase_Python.h', 'errors.h'],
-                  sources      = ['iMesh.c', 'iMesh_iter.c', 'iMesh_entSet.c',
-                                  'iMesh_tag.c']
+                  depends      = ['common.h', 'errors.h', 'iMesh_Python.h',
+                                  'iBase_Python.h', 'iMesh_entSet.inl',
+                                  'iMesh_iter.inl', 'iMesh_tag.inl'],
+                  sources      = ['iMesh.c']
                   )
 
 class TestCommand(Command):



More information about the moab-dev mailing list