[MOAB-dev] r2917 - in MOAB/trunk/tools/iMesh/python: . doc perf test tools

jvporter at wisc.edu jvporter at wisc.edu
Thu May 28 15:45:59 CDT 2009


Author: jvporter
Date: 2009-05-28 15:45:59 -0500 (Thu, 28 May 2009)
New Revision: 2917

Modified:
   MOAB/trunk/tools/iMesh/python/doc/imesh.rst
   MOAB/trunk/tools/iMesh/python/iMesh.c
   MOAB/trunk/tools/iMesh/python/iMesh_entSet.c
   MOAB/trunk/tools/iMesh/python/perf/perf.py
   MOAB/trunk/tools/iMesh/python/test/adj.py
   MOAB/trunk/tools/iMesh/python/test/basic.py
   MOAB/trunk/tools/iMesh/python/tools/volume.py
Log:
* Add more documentation
* Change API slightly to be more consistent


Modified: MOAB/trunk/tools/iMesh/python/doc/imesh.rst
===================================================================
--- MOAB/trunk/tools/iMesh/python/doc/imesh.rst	2009-05-27 23:28:23 UTC (rev 2916)
+++ MOAB/trunk/tools/iMesh/python/doc/imesh.rst	2009-05-28 20:45:59 UTC (rev 2917)
@@ -29,40 +29,22 @@
       the relative cost of retrieving adjacencies between entities of dimension
       i to entities of dimension j.
 
-   .. method:: load(entSet, filename[, options])
+   .. method:: load(filename[, options])
 
-      Load a mesh from a file.
+      Load a mesh from a file. Equivalent to ``rootSet.load(filename,
+      options)``.
 
-      :param entSet: Set to which loaded mesh will be added, root set if not
-                      desired
       :param filename: File name from which the mesh is to be loaded
       :param options: Implementation-specific options string
 
-   .. method:: save(entSet, filename[, options])
+   .. method:: save(filename[, options])
 
-      Save the mesh to a file.
+      Save the mesh to a file. Equivalent to ``rootSet.load(filename,
+      options)``.
 
-      :param entSet: Save a mesh to a file. If entity set is specified, save
-                     only the mesh contained in that set.
       :param filename: File name to which the mesh is to be saved
       :param options: Implementation-specific options string
 
-   .. method:: getNumOfType(entSet, type)
-
-      Get the number of entities with the specified type in ``entSet``.
-
-      :param entSet: Entity set being queried
-      :param type: Type of entity requested
-      :return: The number of entities in ``entSet`` of the requested type
-
-   .. method:: getNumOfTopo(entSet, topo)
-
-      Get the number of entities with the specified topology in ``entSet``.
-
-      :param entSet: Entity set being queried
-      :param type: Topology of entity requested
-      :return: The number of entities in ``entSet`` of the requested topology
-
    .. method:: areEHValid(doReset)
 
       Return whether entity handles have changed since last reset or since
@@ -122,7 +104,7 @@
 
       If ``entities`` is an array of entities, returns a tuple type, with the
       first element being an array of offsets into the second element such that
-      ``ret[1][ ret[0][i]:ret[0][i+1] ]`` is a list of entities adjacent to
+      ``ret[0][ ret[1][i]:ret[1][i+1] ]`` is a list of entities adjacent to
       ``entities[i]``.
 
       :param entities: Entity or array of entities being queried
@@ -140,7 +122,7 @@
 
       If ``entities`` is an array of entities, returns a tuple type, with the
       first element being an array of offsets into the second element such that
-      ``ret[1][ ret[0][i]:ret[0][i+1] ]`` is a list of entities adjacent to
+      ``ret[0][ ret[1][i]:ret[1][i+1] ]`` is a list of entities adjacent to
       ``entities[i]``.
 
       :param entities: Entity or array of entities being queried
@@ -154,33 +136,140 @@
 
    .. method:: createEntSet(isList)
 
+      Create an entity set, either ordered (``isList == True``) or unordered 
+      (``isList == False``). Unordered entity sets can contain a given entity
+      or set only once.
+
+      :param isList: True if the list should be ordered, false otherwise
+      :return: The newly-created entity set
+
    .. method:: destroyEntSet(entSet)
 
+      Destroy an entity set.
+
+      :param entSet: Entity set to be destroyed
+
    .. method:: setVtxCoords(entities, coords[, storageOrder])
 
+      Set the coordinates for the specified vertex or array of vertices. If
+      ``entities`` is an array of vertices, ``storageOrder`` must be specified;
+      otherwise it is ignored.
+
+      :param entities: Vertex handle or array of vertex handles being set
+      :param coords: New coordinates to assign to vertices
+      :param storageOrder: Storage order of coordinates to be assigned
+
    .. method:: createVtx(coords[, storageOrder])
 
+      Create a vertex or array of vertices with the specified coordinates. If
+      creating multiple vertices, ``storageOrder`` must be specified; otherwise
+      it is ignored.
+
+      :param coords: Coordinates of new vertices to create
+      :param storageOrder: Storage order of coordinates
+
    .. method:: createEnt(topo, entities)
 
+      Create a new entity with the specified lower-order topology.
+
+      :param topo: Topology of the entity to be created
+      :param entities: Array of lower order entity handles used to construct
+                       new entity
+      :return: Tuple containing the created entity and its creation status
+
    .. method:: createEntArr(topo, entitites)
 
+      Create an array of new entities with the specified lower-oder topology.
+
+      :param topo: Topology of the entities to be created
+      :param entities: Array of lower order entity handles used to construct
+                       new entities
+      :return: Tuple containing the created entities and their creation statuses
+
    .. method:: deleteEnt(entities)
 
+      Delete the specified entity or array of entities.
+
+      :param entities: An entity or array of entities to delete
+
    .. method:: createTag(name, size, type)
 
+      Create a tag with specified ``name``, ``size``, and ``type``. The tag
+      size is the number of values of type ``type`` that can be held. ``type``
+      is one of the following:
+
+      +---+---------------+
+      | i | Integer       |
+      +---+---------------+
+      | d | Double        |
+      +---+---------------+
+      | E | Entity handle |
+      +---+---------------+
+      | b | Binary data   |
+      +---+---------------+
+
+      :param name: Tag name
+      :param size: Size of tag in number of values
+      :param type: Character representing the tag's type
+      :return: The created tag
+
    .. method:: destroyTag(tag, forced)
 
+      Destroy a tag. If ``forced`` is true and entities still have values set
+      for this tag, the tag is deleted anyway and those values disappear.
+      Otherwise the tag is not deleted if entities still have values set for it.
+
+      :param tag: Tag to delete
+      :param forced: True if the tag should be deleted even if there are values
+                     set for it
+
    .. method:: getTagHandle(name)
 
+      Get the handle of an existing tag with the specified ``name``.
+
+      :param name: The name of the tag to find
+      :return: The tag with the specified name
+
    .. method:: setData(entities, tag, data[, type])
 
+      Set value(s) for a tag on an entity, entity set, or array of entities.
+      If ``type`` is not specified, this function will retrieve the tag type
+      automatically.
+
+      :param entities: Entity, entity set, or array of entities on which tag is
+                       being set
+      :param tag: Tag being set
+      :param data: Data to set
+      :param type: Character representing the tag's type (as above)
+
    .. method:: getData(entities, tag[, type])
 
+      Get value(s) for a tag on an entity, entity set, or array of entities.
+      If ``type`` is not specified, this function will retrieve the tag type
+      automatically.
+
+      :param entities: Entity, entity set, or array of entities on which tag is
+                       being retrieved
+      :param tag: Tag being retrieved
+      :param type: Character representing the tag's type (as above)
+      :return: The retrieved data
+
    .. method:: getAllTags(entities)
 
+      Get all the tags associated with a specified entity or entity set.
+
+      :param entities: Entity or entity set being queried
+      :return: Array of tags associated with ``entities``
+
    .. method:: rmvTag(entities, tag)
 
+      Remove a tag value from an entity, entity set, or array of entities.
 
+      :param entities: Entity, entity set, or array of entities from which tag
+                       is being removed
+      :param tag: Tag to be removed
+
+
 .. class:: itaps.iMesh.topology
 
    An enumeration of mesh element topologies corresponding to
@@ -246,6 +335,37 @@
 
    .. attribute:: isList
 
+      Returns whether the entity set is ordered.
+
+   .. method:: load(entSet, filename[, options])
+
+      Load a mesh from a file, adding it to the entity set.
+
+      :param filename: File name from which the mesh is to be loaded
+      :param options: Implementation-specific options string
+
+   .. method:: save(filename[, options])
+
+      Save the subset of the mesh contained in the entity set to a file.
+
+      :param filename: File name to which the mesh is to be saved
+      :param options: Implementation-specific options string
+
+   .. method:: getNumOfType(type)
+
+      Get the number of entities with the specified type in the entity set.
+
+      :param type: Type of entity requested
+      :return: The number of entities in entity set of the requested type
+
+   .. method:: getNumOfTopo(topo)
+
+      Get the number of entities with the specified topology in the entity set.
+
+      :param type: Topology of entity requested
+      :return: The number of entities in the entity set of the requested
+               topology
+
    .. method:: getNumEntSets(numHops)
 
    .. method:: getEntSets(numHops)

Modified: MOAB/trunk/tools/iMesh/python/iMesh.c
===================================================================
--- MOAB/trunk/tools/iMesh/python/iMesh.c	2009-05-27 23:28:23 UTC (rev 2916)
+++ MOAB/trunk/tools/iMesh/python/iMesh.c	2009-05-28 20:45:59 UTC (rev 2917)
@@ -58,36 +58,44 @@
 static PyObject *
 iMeshObj_load(iMeshObject *self,PyObject *args)
 {
-    iBaseEntitySet_Object *set;
     const char *name = 0;
     const char *options = "";
-    if(!PyArg_ParseTuple(args,"O!s|s",&iBaseEntitySet_Type,&set,&name,&options))
+    iBase_EntitySetHandle root;
+    int err;
+
+    if(!PyArg_ParseTuple(args,"s|s",&name,&options))
         return NULL;
 
-    int err;
-    iMesh_load(self->mesh,set->handle,name,options,&err,strlen(name),
-               strlen(options));
+    iMesh_getRootSet(self->mesh,&root,&err);
     if(checkError(self->mesh,err))
         return NULL;
 
+    iMesh_load(self->mesh,root,name,options,&err,strlen(name),strlen(options));
+    if(checkError(self->mesh,err))
+        return NULL;
+
     Py_RETURN_NONE;
 }
 
 static PyObject *
 iMeshObj_save(iMeshObject *self,PyObject *args)
 {
-    iBaseEntitySet_Object *set;
     const char *name = 0;
     const char *options = "";
-    if(!PyArg_ParseTuple(args,"O!s|s",&iBaseEntitySet_Type,&set,&name,&options))
+    iBase_EntitySetHandle root;
+    int err;
+
+    if(!PyArg_ParseTuple(args,"s|s",&name,&options))
         return NULL;
 
-    int err;
-    iMesh_save(self->mesh,set->handle,name,options,&err,strlen(name),
-               strlen(options));
+    iMesh_getRootSet(self->mesh,&root,&err);
     if(checkError(self->mesh,err))
         return NULL;
 
+    iMesh_save(self->mesh,root,name,options,&err,strlen(name),strlen(options));
+    if(checkError(self->mesh,err))
+        return NULL;
+
     Py_RETURN_NONE;
 }
 
@@ -166,38 +174,6 @@
 }
 
 static PyObject *
-iMeshObj_getNumOfType(iMeshObject *self,PyObject *args)
-{
-    iBaseEntitySet_Object *set;
-    enum iBase_EntityType type;
-    int num,err;
-    if(!PyArg_ParseTuple(args,"O!i",&iBaseEntitySet_Type,&set,&type))
-        return NULL;
-
-    iMesh_getNumOfType(self->mesh,set->handle,type,&num,&err);
-    if(checkError(self->mesh,err))
-        return NULL;
-
-    return Py_BuildValue("i",num);
-}
-
-static PyObject *
-iMeshObj_getNumOfTopo(iMeshObject *self,PyObject *args)
-{
-    iBaseEntitySet_Object *set;
-    enum iMesh_EntityTopology topo;
-    int num,err;
-    if(!PyArg_ParseTuple(args,"O!i",&iBaseEntitySet_Type,&set,&topo))
-        return NULL;
-
-    iMesh_getNumOfTopo(self->mesh,set->handle,topo,&num,&err);
-    if(checkError(self->mesh,err))
-        return NULL;
-
-    return Py_BuildValue("i",num);
-}
-
-static PyObject *
 iMeshObj_areEHValid(iMeshObject *self,PyObject *args)
 {
     int doReset,areInv,err;
@@ -761,7 +737,6 @@
     int lower_size = PyArray_SIZE(ents);
     iBase_EntityHandle *lower = PyArray_DATA(ents);
 
-    PyObject *pair = PyTuple_New(2);
     iBaseEntity_Object *entity = iBaseEntity_New();
 
     iMesh_createEnt(self->mesh,topo,lower,lower_size,&entity->handle,&status,
@@ -769,11 +744,11 @@
     Py_DECREF(ents);
     if(checkError(self->mesh,err))
     {
-        Py_DECREF(pair);
         Py_DECREF((PyObject*)entity);
         return NULL;
     }
 
+    PyObject *pair = PyTuple_New(2);
     PyTuple_SET_ITEM(pair,0,(PyObject*)entity);
     PyTuple_SET_ITEM(pair,1,Py_BuildValue("i",status));
     return pair;
@@ -1007,7 +982,7 @@
             iBase_EntityHandle *data = PyArray_DATA(data_arr);
             iMesh_setEHArrData(self->mesh,entities,ent_size,tag->handle,data,
                                data_size,&err);
-    }
+        }
         else /* iBase_BYTES */
         {
             data_arr = PyArray_FROMANY(data_obj,NPY_BYTE,1,1,NPY_C_CONTIGUOUS);
@@ -1385,19 +1360,11 @@
 
 static PyMethodDef iMesh_methods[] = {
     { "load", (PyCFunction)iMeshObj_load, METH_VARARGS,
-      "Load a mesh"
+      "Load a mesh from a file"
     },
     { "save", (PyCFunction)iMeshObj_save, METH_VARARGS,
-      "Save the mesh"
+      "Save the mesh to a file"
     },
-    { "getNumOfType", (PyCFunction)iMeshObj_getNumOfType, METH_VARARGS,
-      "Get the number of entities with the specified type in the instance or "
-      "set"
-    },
-    { "getNumOfTopo", (PyCFunction)iMeshObj_getNumOfTopo, METH_VARARGS,
-      "Get the number of entities with the specified topology in the instance "
-      "or set"
-    },
     { "areEHValid", (PyCFunction)iMeshObj_areEHValid, METH_VARARGS,
       "Return whether entity handles have changed since last reset or since "
       "instance construction"

Modified: MOAB/trunk/tools/iMesh/python/iMesh_entSet.c
===================================================================
--- MOAB/trunk/tools/iMesh/python/iMesh_entSet.c	2009-05-27 23:28:23 UTC (rev 2916)
+++ MOAB/trunk/tools/iMesh/python/iMesh_entSet.c	2009-05-28 20:45:59 UTC (rev 2917)
@@ -6,6 +6,70 @@
 #include "iBase_Python.h"
 
 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,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,err))
+        return NULL;
+
+    return Py_BuildValue("i",num);
+}
+
+static PyObject *
 iMeshEntSetObj_isList(iMeshEntitySet_Object *self,void *closure)
 {
     int is_list,err;
@@ -421,11 +485,23 @@
 
 
 static PyMethodDef iMeshEntSetObj_methods[] = {
+    { "load", (PyCFunction)iMeshEntSetObj_load, METH_VARARGS,
+      "Load a mesh from a file"
+    },
+    { "save", (PyCFunction)iMeshEntSetObj_save, METH_VARARGS,
+      "Save the mesh to a file"
+    },
+    { "getNumOfType", (PyCFunction)iMeshEntSetObj_getNumOfType, METH_VARARGS,
+      "Get the number of entities with the specified type in the set"
+    },
+    { "getNumOfTopo", (PyCFunction)iMeshEntSetObj_getNumOfTopo, METH_VARARGS,
+      "Get the number of entities with the specified topology in the set"
+    },
     { "getNumEntSets", (PyCFunction)iMeshEntSetObj_getNumEntSets, METH_VARARGS,
-      "Get the number of entity sets contained in the set or interface"
+      "Get the number of entity sets contained in the set"
     },
     { "getEntSets", (PyCFunction)iMeshEntSetObj_getEntSets, METH_VARARGS,
-      "Get the entity sets contained in the set or interface"
+      "Get the entity sets contained in the set"
     },
     { "add", (PyCFunction)iMeshEntSetObj_add, METH_VARARGS,
       "Add an entity (or array of entities or entity set) to the set"

Modified: MOAB/trunk/tools/iMesh/python/perf/perf.py
===================================================================
--- MOAB/trunk/tools/iMesh/python/perf/perf.py	2009-05-27 23:28:23 UTC (rev 2916)
+++ MOAB/trunk/tools/iMesh/python/perf/perf.py	2009-05-28 20:45:59 UTC (rev 2917)
@@ -64,11 +64,7 @@
     timer.reset()
     for x in range(count):
         m = iMesh()
-        try:
-            m.load(m.rootSet, file)
-        except:
-            print file
-            exit(0)
+        m.load(file)
         m = None
     py_stats[file].append( timer.delta()/count )
     list_stats[file].append(0)
@@ -76,7 +72,7 @@
     ##### Intermission #####
     mesh = iMesh()
     root = mesh.rootSet
-    mesh.load(root, file)
+    mesh.load(file)
 
     ##### 2 #####
     timer.reset()
@@ -114,7 +110,8 @@
     list_stats[file].append( timer.delta()/count )
 
     mesh = None
-    arr = None
+    root = None
+    arr  = None
     list = None
 
 

Modified: MOAB/trunk/tools/iMesh/python/test/adj.py
===================================================================
--- MOAB/trunk/tools/iMesh/python/test/adj.py	2009-05-27 23:28:23 UTC (rev 2916)
+++ MOAB/trunk/tools/iMesh/python/test/adj.py	2009-05-28 20:45:59 UTC (rev 2917)
@@ -36,25 +36,25 @@
         quad = self.mesh.createEnt(topo.quadrilateral, self.lines)[0]
         root = self.mesh.rootSet
 
-        self.assertEqual(self.mesh.getNumOfType(root, iBase.type.vertex),  4)
-        self.assertEqual(self.mesh.getNumOfType(root, iBase.type.edge),    4)
-        self.assertEqual(self.mesh.getNumOfType(root, iBase.type.face),    1)
+        self.assertEqual(root.getNumOfType(iBase.type.vertex),  4)
+        self.assertEqual(root.getNumOfType(iBase.type.edge),    4)
+        self.assertEqual(root.getNumOfType(iBase.type.face),    1)
 
-        self.assertEqual(self.mesh.getNumOfTopo(root, topo.point),         4)
-        self.assertEqual(self.mesh.getNumOfTopo(root, topo.line_segment),  4)
-        self.assertEqual(self.mesh.getNumOfTopo(root, topo.quadrilateral), 1)
+        self.assertEqual(root.getNumOfTopo(topo.point),         4)
+        self.assertEqual(root.getNumOfTopo(topo.line_segment),  4)
+        self.assertEqual(root.getNumOfTopo(topo.quadrilateral), 1)
 
         self.mesh.deleteEnt(quad)
-        self.assertEqual(self.mesh.getNumOfType(root, iBase.type.face),    0)
-        self.assertEqual(self.mesh.getNumOfTopo(root, topo.quadrilateral), 0)
+        self.assertEqual(root.getNumOfType(iBase.type.face),    0)
+        self.assertEqual(root.getNumOfTopo(topo.quadrilateral), 0)
 
         self.mesh.deleteEnt(self.lines)
-        self.assertEqual(self.mesh.getNumOfType(root, iBase.type.edge),    0)
-        self.assertEqual(self.mesh.getNumOfTopo(root, topo.line_segment),  0)
+        self.assertEqual(root.getNumOfType(iBase.type.edge),    0)
+        self.assertEqual(root.getNumOfTopo(topo.line_segment),  0)
 
         self.mesh.deleteEnt(self.ents)
-        self.assertEqual(self.mesh.getNumOfType(root, iBase.type.vertex),  0)
-        self.assertEqual(self.mesh.getNumOfTopo(root, topo.point),         0)
+        self.assertEqual(root.getNumOfType(iBase.type.vertex),  0)
+        self.assertEqual(root.getNumOfTopo(topo.point),         0)
 
     def testAdj(self):
         adj = self.mesh.getEntAdj(self.ents[1], iBase.type.all)

Modified: MOAB/trunk/tools/iMesh/python/test/basic.py
===================================================================
--- MOAB/trunk/tools/iMesh/python/test/basic.py	2009-05-27 23:28:23 UTC (rev 2916)
+++ MOAB/trunk/tools/iMesh/python/test/basic.py	2009-05-28 20:45:59 UTC (rev 2917)
@@ -12,8 +12,8 @@
         mesh.dfltStorage
 
         self.assert_(mesh.areEHValid(True))
-        self.assertEqual(mesh.getNumOfType(root, iBase.type.all), 0)
-        self.assertEqual(mesh.getNumOfTopo(root, iMesh.topology.all), 0)
+        self.assertEqual(root.getNumOfType(iBase.type.all),     0)
+        self.assertEqual(root.getNumOfTopo(iMesh.topology.all), 0)
         self.assertEqual(mesh.adjTable.shape, (4,4))
 
     def testVertex(self):
@@ -21,8 +21,8 @@
         ent = mesh.createVtx([1,2,3])
         root = mesh.rootSet
 
-        self.assertEqual(mesh.getNumOfType(root, iBase.type.vertex), 1)
-        self.assertEqual(mesh.getNumOfTopo(root, iMesh.topology.point), 1)
+        self.assertEqual(root.getNumOfType(iBase.type.vertex),    1)
+        self.assertEqual(root.getNumOfTopo(iMesh.topology.point), 1)
 
         self.assert_( (mesh.getVtxCoords(ent) == [1,2,3]).all() )
         self.assert_( (mesh.getVtxCoords([ent], iBase.storageOrder.interleaved)
@@ -40,8 +40,8 @@
         ents = mesh.createVtx(verts, iBase.storageOrder.interleaved)
         root = mesh.rootSet
 
-        self.assertEqual(mesh.getNumOfType(root, iBase.type.vertex), 4)
-        self.assertEqual(mesh.getNumOfTopo(root, iMesh.topology.point), 4)
+        self.assertEqual(root.getNumOfType(iBase.type.vertex),    4)
+        self.assertEqual(root.getNumOfTopo(iMesh.topology.point), 4)
 
         coords = mesh.getVtxCoords(ents, iBase.storageOrder.interleaved)
         self.assert_( (coords == verts).all())
@@ -67,11 +67,11 @@
         topo = iMesh.topology
 
         lines = mesh.createEntArr(topo.line_segment,ents)[0]
-        self.assertEqual(mesh.getNumOfType(root, iBase.type.vertex),  4)
-        self.assertEqual(mesh.getNumOfType(root, iBase.type.edge),    2)
+        self.assertEqual(root.getNumOfType(iBase.type.vertex),  4)
+        self.assertEqual(root.getNumOfType(iBase.type.edge),    2)
 
-        self.assertEqual(mesh.getNumOfTopo(root, topo.point),         4)
-        self.assertEqual(mesh.getNumOfTopo(root, topo.line_segment),  2)
+        self.assertEqual(root.getNumOfTopo(topo.point),         4)
+        self.assertEqual(root.getNumOfTopo(topo.line_segment),  2)
 
     def testSave(self):
         file = tempfile.NamedTemporaryFile()
@@ -80,17 +80,17 @@
         verts = [1,2,3]
         mesh.createVtx(verts)
         
-        mesh.save(mesh.rootSet,file.name)
+        mesh.save(file.name)
         
         mesh = iMesh()
         root = mesh.rootSet
-        mesh.load(root,file.name)
-        ents = mesh.getEntities(root,iBase.type.all,iMesh.topology.all)
+        mesh.load(file.name)
+        ents = mesh.getEntities(root, iBase.type.all, iMesh.topology.all)
 
-        self.assertEqual(mesh.getNumOfType(root, iBase.type.vertex), 1)
-        self.assertEqual(mesh.getNumOfTopo(root, iMesh.topology.point), 1)
+        self.assertEqual(root.getNumOfType(iBase.type.vertex),    1)
+        self.assertEqual(root.getNumOfTopo(iMesh.topology.point), 1)
 
-        coords = mesh.getVtxCoords(ents,iBase.storageOrder.interleaved)
+        coords = mesh.getVtxCoords(ents, iBase.storageOrder.interleaved)
         self.assert_( (coords == [1,2,3]).all() )
 
 

Modified: MOAB/trunk/tools/iMesh/python/tools/volume.py
===================================================================
--- MOAB/trunk/tools/iMesh/python/tools/volume.py	2009-05-27 23:28:23 UTC (rev 2916)
+++ MOAB/trunk/tools/iMesh/python/tools/volume.py	2009-05-28 20:45:59 UTC (rev 2917)
@@ -28,9 +28,9 @@
 
 def calc_volume(filename):
     mesh = iMesh()
-    mesh.load(mesh.rootSet, filename)
+    mesh.load(filename)
 
-    volume = ndarray(mesh.getNumOfType(mesh.rootSet, iBase.type.region), float_)
+    volume = ndarray(mesh.rootSet.getNumOfType(iBase.type.region), float_)
     x=0
     for i in mesh.rootSet.iterate(iBase.type.region, iMesh.topology.all):
         topo = mesh.getEntTopo(i)



More information about the moab-dev mailing list