[MOAB-dev] r2918 - in MOAB/trunk/tools/iMesh/python: . doc perf test
jvporter at wisc.edu
jvporter at wisc.edu
Thu May 28 18:14:04 CDT 2009
Author: jvporter
Date: 2009-05-28 18:14:04 -0500 (Thu, 28 May 2009)
New Revision: 2918
Modified:
MOAB/trunk/tools/iMesh/python/doc/ibase.rst
MOAB/trunk/tools/iMesh/python/doc/imesh.rst
MOAB/trunk/tools/iMesh/python/iBase.c
MOAB/trunk/tools/iMesh/python/iMesh.c
MOAB/trunk/tools/iMesh/python/iMesh_entSet.c
MOAB/trunk/tools/iMesh/python/iMesh_iter.c
MOAB/trunk/tools/iMesh/python/iMesh_tag.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/test/iter.py
MOAB/trunk/tools/iMesh/python/test/tags.py
Log:
* Add iBase.creationStatus enum
* More API changes (tag and entity set interfaces)
* Updated tests
* Finished API reference
Modified: MOAB/trunk/tools/iMesh/python/doc/ibase.rst
===================================================================
--- MOAB/trunk/tools/iMesh/python/doc/ibase.rst 2009-05-28 20:45:59 UTC (rev 2917)
+++ MOAB/trunk/tools/iMesh/python/doc/ibase.rst 2009-05-28 23:14:04 UTC (rev 2918)
@@ -6,36 +6,92 @@
.. class:: itaps.iBase.type
+ An enumeration of entity types corresponding to ``iBase_EntityType``.
+
.. data:: vertex
+ A zero-dimensional entity
+
.. data:: edge
+ A one-dimensional entity
+
.. data:: face
+ A two-dimensional entity
+
.. data:: region
+ A three-dimensional entity
+
.. data:: all
+ Allows the user to request information about all the types
+
.. class:: itaps.iBase.adjCost
+ An enumeration of entity types corresponding to ``iBase_AdjacencyCost``.
+
.. data:: unavailable
+ Adjacency information not supported
+
.. data:: all_order_1
+ No more than local mesh traversal required
+
.. data:: all_order_logn
+ Global tree search
+
.. data:: all_order_n
+ Global exhaustive search
+
.. data:: some_order_1
+ Only some adjacency info, local
+
.. data:: some_order_logn
+ Only some adjacency info, tree
+
.. data:: some_order_n
+ Only some adjacency info, exhaustive
+
.. class:: itaps.iBase.storageOrder
+ An enumeration of entity types corresponding to ``iBase_StorageOrder``.
+
.. data:: interleaved
- .. data:: blocked
\ No newline at end of file
+ Coordinates are interleaved, e.g. ``[ x0, y0, z0, x1, y1, z1, ... ]``.
+
+ .. data:: blocked
+
+ Coordinates are blocked, e.g. ``[ x0, x1, ..., y0, y1, ..., z0, z1,
+ ...]``.
+
+
+.. class:: itaps.iBase.creationStatus
+
+ An enumeration of entity types corresponding to ``iBase_CreationStatus``.
+
+ .. data:: new
+
+ New entity was created
+
+ .. data:: exists
+
+ Entity already exists
+
+ .. data:: duplicated
+
+ Duplicate entity created
+
+ .. data:: failed
+
+ Creation failed
\ No newline at end of file
Modified: MOAB/trunk/tools/iMesh/python/doc/imesh.rst
===================================================================
--- MOAB/trunk/tools/iMesh/python/doc/imesh.rst 2009-05-28 20:45:59 UTC (rev 2917)
+++ MOAB/trunk/tools/iMesh/python/doc/imesh.rst 2009-05-28 23:14:04 UTC (rev 2918)
@@ -4,8 +4,13 @@
.. module:: itaps
-.. class:: itaps.iMesh
+.. class:: itaps.iMesh([options])
+ Return a new ``iMesh`` object with any implementation-specific options
+ defined in ``options``.
+
+ :param options: Implementation-specific options string
+
.. attribute:: rootSet
Get the handle of the root set for this instance. The entire mesh in this
@@ -57,18 +62,6 @@
which handles are invariant.
:return: True iff entity handles have changed
- .. method:: getEntities(entSet, type, topo)
-
- Get entities of a specific type and/or topology in ``entSet``. All
- entities of a given type or topology are requested by specifying
- ``iBase.type.all`` or ``iMesh.topology.all``, respectively.
-
- :param entSet: Entity set being queried
- :param type: Type of entities being requested
- :param topo: Topology of entities being requested
- :return: Array of entity handles from ``entSet`` meeting the requirements
- of ``type`` and ``topo``.
-
.. method:: getVtxCoords(entities[, storageOrder])
Get coordinates of specified vertices. If ``entitites`` is an array of
@@ -132,8 +125,6 @@
entities. Otherwise, a tuple containing an array of offsets and
an array of adjacent entities.
- .. method:: getAdjEntIndices(entSet, typeRequestor, topoRequestor, typeRequested)
-
.. method:: createEntSet(isList)
Create an entity set, either ordered (``isList == True``) or unordered
@@ -198,15 +189,15 @@
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 |
- +---+---------------+
+ +-------+---------------+
+ | ``i`` | Integer |
+ +-------+---------------+
+ | ``d`` | Double |
+ +-------+---------------+
+ | ``E`` | Entity handle |
+ +-------+---------------+
+ | ``b`` | Binary data |
+ +-------+---------------+
:param name: Tag name
:param size: Size of tag in number of values
@@ -230,30 +221,6 @@
: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.
@@ -261,15 +228,7 @@
: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
@@ -326,85 +285,276 @@
Allows the user to request information about all the topology types
-.. class:: itaps.iMesh.iterator
+.. class:: itaps.iMesh.iterator(set, type, topology[, size=1])
+ Return a new iterator on the entity set ``set`` to iterate over entities of
+ the specified ``type`` and ``topology``. If ``size`` is greater than 1, each
+ step of the iteration will return an array of ``size`` entities. All
+ entities of a given type or topology are requested by specifying
+ ``iBase.type.all`` or `iMesh.topology.all``, respectively.
+
+ :param set: Entity set to iterate over
+ :param type: Type of entities being requested
+ :param topo: Topology of entities being requested
+ :param count: Number of entities to return on each step of iteration
+
.. method:: reset()
+ Resets the iterator to the beginning.
+
.. class:: itaps.iMesh.entitySet
.. attribute:: isList
- Returns whether the entity set is ordered.
+ Return whether this entity set is ordered.
.. method:: load(entSet, filename[, options])
- Load a mesh from a file, adding it to the entity set.
+ Load a mesh from a file, adding it to this 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.
+ Save the subset of the mesh contained in this 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.
+ Get the number of entities with the specified type in this 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.
+ Get the number of entities with the specified topology in this entity set.
:param type: Topology of entity requested
:return: The number of entities in the entity set of the requested
topology
+ .. method:: getEntities(type, topo)
+
+ Get entities of a specific type and/or topology in this entity set. All
+ entities of a given type or topology are requested by specifying
+ ``iBase.type.all`` or ``iMesh.topology.all``, respectively.
+
+ :param entSet: Entity set being queried
+ :param type: Type of entities being requested
+ :param topo: Topology of entities being requested
+ :return: Array of entity handles from ``entSet`` meeting the requirements
+ of ``type`` and ``topo``.
+
+ .. method:: getAdjEntIndices(type, topo, adjType)
+
+ Given an entity set and optionally a type or topology, return a tuple
+ containing the following:
+
+ * The entities in the set of the specified ``type`` and/or ``topology``
+ * The entities adjacent to those entities with the specified type
+ ``adjType``, as a list of unique handles
+ * An index buffer containing, for each entity in the first list,
+ the indices of the entities adjacent to it
+ * An array of offsets into the index buffer for each entity in the first
+ list
+
+ That is, given an entity located in ``ret[0][i]``, the list of entities to
+ which it is adjacent is::
+
+ ret[1][ ret[2][ ret[3][i]:ret[3][i+1] ] ]
+
+ :param type: Type of entities being requested
+ :param topo: Topology of entities being requested
+ :param adjType: Type of adjacent entities being requested
+ :return: 4-tuple containing the adjacency information
+
.. method:: getNumEntSets(numHops)
+ Get the number of sets contained in this entity set. If this entity set is
+ not the root set, ``numHops`` indicates the maximum number of contained
+ sets from ``self`` to one of the contained sets, inclusive of ``self``.
+
+ :param numHops: Maximum number of contained sets from ``self`` to a
+ contained set, including ``self``.
+ :return: Number of entity sets found
+
.. method:: getEntSets(numHops)
+ Get the sets contained in this entity set. If this entity set is not the
+ root set, ``numHops`` indicates the maximum number of contained sets from
+ ``self`` to one of the contained sets, inclusive of ``self``.
+
+ :param numHops: Maximum number of contained sets from ``self`` to a
+ contained set, including ``self``.
+ :return: Array of entity sets found
+
.. method:: add(entities)
+ Add an entity, entity set, or array of entities to this entity set.
+
+ :param entities: The entity, entity set, or array of entities to add
+
.. method:: remove(entities)
+ Remove an entity, entity set, or array of entities from this entity set.
+
+ :param entities: The entity, entity set, or array of entities to remove
+
.. method:: contains(entities)
+ Return whether an entity, entity set, or array of entities is contained
+ in this entity set.
+
+ :param entities: The entity, entity set, or array of entities to query
+ :return: If ``entities`` is an array of entities, an array of booleans
+ corresponding to each element of ``entities``. Otherwise, a
+ single boolean.
+
.. method:: addChild(entSet)
+ Add ``entSet`` as a child to this entity set.
+
+ :param entSet: The entity set to add
+
.. method:: removeChild(entSet)
+ Remove ``entSet`` as a child from this entity set.
+
+ :param entSet: The entity set to remove
+
.. method:: isChild(entSet)
+ Return whether an entity set is a child of this entity set.
+
+ :param entSet: The entity set to query:
+ :return: True if ``entSet`` is a child of this entity set, false otherwise
+
.. method:: getNumChildren(numHops)
+ Get the number of child sets linked from this entity set. If ``numHops``
+ is non-zero, this represents the maximum hops from this entity set to any
+ child in the count.
+
+ :param numHops: Maximum hops from this entity set to a child set,
+ inclusive of the child set
+ :return: Number of children
+
.. method:: getNumParents(numHops)
+ Get the number of parent sets linked from this entity set. If ``numHops``
+ is non-zero, this represents the maximum hops from this entity set to any
+ parents in the count.
+
+ :param numHops: Maximum hops from this entity set to a parent set,
+ inclusive of the parent set
+ :return: Number of parents
+
.. method:: getChildren(numHops)
+ Get the child sets linked from this entity set. If ``numHops`` is
+ non-zero, this represents the maximum hops from this entity set to any
+ child in the result.
+
+ :param numHops: Maximum hops from this entity set to a child set,
+ inclusive of the child set
+ :return: Array of children
+
.. method:: getParents(numHops)
+ Get the parents sets linked from this entity set. If ``numHops`` is
+ non-zero, this represents the maximum hops from this entity set to any
+ parent in the result.
+
+ :param numHops: Maximum hops from this entity set to a parent set,
+ inclusive of the parent set
+ :return: Array of parents
+
.. method:: iterate(type, topo[, count=1])
+ Initialize an iterator over the specified entity type and topology for
+ this entity set. If ``count`` is greater than 1, each step of the
+ iteration returns an array of ``count`` entities. Equivalent to::
+
+ itaps.iMesh.iterator(self, type, topo, count)
+
+ :param type: Type of entities being requested
+ :param topo: Topology of entities being requested
+ :param count: Number of entities to return on each step of iteration
+ :return: An ``itaps.iMesh.iterator`` instance
+
.. method:: difference(entSet)
+ Subtract contents of an entity set from this set. Equivalent to
+ ``self - entSet``.
+
+ :param entSet: Entity set to subtract
+ :return: Resulting entity set
+
.. method:: intersection(entSet)
+ Intersect contents of an entity set with this set. Equivalent to
+ ``self & entSet``.
+
+ :param entSet: Entity set to intersect
+ :return: Resulting entity set
+
.. method:: union(entSet)
+ Unite contents of an entity set with this set. Equivalent to
+ ``self | entSet``.
+ :param entSet: Entity set to unite
+ :return: Resulting entity set
+
+
.. class:: itaps.iMesh.tag
.. attribute:: name
+ Get the name for this tag.
+
.. attribute:: sizeValues
+ Get the size in number of values for this tag.
+
.. attribute:: sizeBytes
- .. attribute:: type
\ No newline at end of file
+ Get the size in bytes for this tag.
+
+ .. attribute:: type
+
+ Get the data type for this tag as a character code (see above).
+
+ .. method:: setData(entities, data[, type])
+
+ Set value(s) for the 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 data: Data to set
+ :param type: Character representing the tag's type (as above)
+
+ .. method:: getData(entities, [, type])
+
+ Get value(s) for the 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 type: Character representing the tag's type (as above)
+ :return: The retrieved data
+
+ .. method:: rmvTag(entities)
+
+ Remove the 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
Modified: MOAB/trunk/tools/iMesh/python/iBase.c
===================================================================
--- MOAB/trunk/tools/iMesh/python/iBase.c 2009-05-28 20:45:59 UTC (rev 2917)
+++ MOAB/trunk/tools/iMesh/python/iBase.c 2009-05-28 23:14:04 UTC (rev 2918)
@@ -35,9 +35,10 @@
}
static int NPY_IBASETAG;
-ENUM_TYPE(type, "iBase.type", "");
-ENUM_TYPE(adjCost, "iBase.adjCost", "");
-ENUM_TYPE(storageOrder, "iBase.storageOrder", "");
+ENUM_TYPE(type, "iBase.type", "");
+ENUM_TYPE(adjCost, "iBase.adjCost", "");
+ENUM_TYPE(storageOrder, "iBase.storageOrder", "");
+ENUM_TYPE(creationStatus, "iBase.creationStatus", "");
static PyMethodDef module_methods[] = {
{0}
@@ -85,6 +86,9 @@
static PyObject *
iBaseEntObj_richcompare(iBaseEntity_Object *lhs,iBaseEntity_Object *rhs,int op)
{
+ if(!iBaseEntity_Check(lhs) || !iBaseEntity_Check(rhs))
+ return Py_NotImplemented;
+
switch(op)
{
case Py_EQ:
@@ -150,6 +154,9 @@
iBaseEntSetObj_richcompare(iBaseEntitySet_Object *lhs,
iBaseEntitySet_Object *rhs,int op)
{
+ if(!iBaseEntitySet_Check(lhs) || !iBaseEntitySet_Check(rhs))
+ return Py_NotImplemented;
+
switch(op)
{
case Py_EQ:
@@ -270,6 +277,14 @@
ADD_ENUM(&storageOrder_Type,"blocked", iBase_BLOCKED);
ADD_ENUM(&storageOrder_Type,"interleaved",iBase_INTERLEAVED);
+ /***** initialize creation status enum *****/
+ REGISTER_SIMPLE(m,creationStatus);
+
+ ADD_ENUM(&creationStatus_Type,"new", iBase_NEW);
+ ADD_ENUM(&creationStatus_Type,"exists", iBase_ALREADY_EXISTED);
+ ADD_ENUM(&creationStatus_Type,"duplicated", iBase_CREATED_DUPLICATE);
+ ADD_ENUM(&creationStatus_Type,"failed", iBase_CREATION_FAILED);
+
/***** initialize iBaseEntity handle *****/
iBaseEntity_Type.tp_repr = (reprfunc)iBaseEntObj_repr;
iBaseEntity_Type.tp_richcompare = (richcmpfunc)iBaseEntObj_richcompare;
Modified: MOAB/trunk/tools/iMesh/python/iMesh.c
===================================================================
--- MOAB/trunk/tools/iMesh/python/iMesh.c 2009-05-28 20:45:59 UTC (rev 2917)
+++ MOAB/trunk/tools/iMesh/python/iMesh.c 2009-05-28 23:14:04 UTC (rev 2918)
@@ -188,27 +188,6 @@
}
static PyObject *
-iMeshObj_getEntities(iMeshObject *self,PyObject *args)
-{
- iBaseEntitySet_Object *set;
- enum iBase_EntityType type;
- enum iMesh_EntityTopology topo;
- iBase_EntityHandle *entities=0;
- int alloc=0,size,err;
-
- if(!PyArg_ParseTuple(args,"O!ii",&iBaseEntitySet_Type,&set,&type,&topo))
- return NULL;
-
- iMesh_getEntities(self->mesh,set->handle,type,topo,&entities,&alloc,&size,
- &err);
- if(checkError(self->mesh,err))
- return NULL;
-
- npy_intp dims[] = {size};
- return PyArray_NewFromMalloc(1,dims,NPY_IBASEENT,entities);
-}
-
-static PyObject *
iMeshObj_getVtxCoords(iMeshObject *self,PyObject *args)
{
PyObject *obj;
@@ -492,59 +471,6 @@
}
static PyObject *
-iMeshObj_getAdjEntIndices(iMeshObject *self,PyObject *args)
-{
- iBaseEntitySet_Object *set;
- int type_requestor,topo_requestor,type_requested;
- int err;
-
- if(!PyArg_ParseTuple(args,"O!iii",&iBaseEntitySet_Type,&set,
- &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,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,err))
- return NULL;
-
- /* TODO: this is clunky */
- PyObject *tup = PyTuple_New(4);
- npy_intp dims[1];
-
- dims[0] = ent_size;
- PyTuple_SET_ITEM(tup, 0,
- PyArray_NewFromMalloc(1,dims,NPY_IBASEENT,entities));
-
- dims[0] = adj_size;
- PyTuple_SET_ITEM(tup, 1,
- PyArray_NewFromMalloc(1,dims,NPY_IBASEENT,adj_ents));
-
- dims[0] = ind_size;
- PyTuple_SET_ITEM(tup, 2,
- PyArray_NewFromMalloc(1,dims,NPY_INT,indices));
-
- dims[0] = off_size;
- PyTuple_SET_ITEM(tup, 3,
- PyArray_NewFromMalloc(1,dims,NPY_INT,offsets));
-
- return tup;
-}
-
-static PyObject *
iMeshObj_createEntSet(iMeshObject *self,PyObject *args)
{
int isList,err;
@@ -907,380 +833,6 @@
}
static PyObject *
-iMeshObj_setData(iMeshObject *self,PyObject *args)
-{
- PyObject *obj;
- iBaseTag_Object *tag;
- PyObject *data_obj;
- char typechar=0;
- int type;
- int err;
-
- if(!PyArg_ParseTuple(args,"OO!O|c",&obj,&iBaseTag_Type,&tag,&data_obj,
- &typechar))
- return NULL;
-
- if(typechar == 0)
- {
- /* infer the type of the data */
- iMesh_getTagType(self->mesh,tag->handle,&type,&err);
- if(checkError(self->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,entities,ent_size,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,entities,ent_size,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,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);
- if(data_arr == NULL)
- return NULL;
-
- data_size = PyArray_SIZE(data_arr);
- char *data = PyArray_DATA(data_arr);
- iMesh_setArrData(self->mesh,entities,ent_size,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,set,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,set,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,set,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,set,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,entity,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,entity,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,entity,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,entity,tag->handle,data,data_size,&err);
- Py_DECREF(data_arr);
- }
- }
- else
- {
- PyErr_SetString(PyExc_ValueError,ERR_ANY_ENT);
- return NULL;
- }
-
- if(checkError(self->mesh,err))
- return NULL;
- Py_RETURN_NONE;
-}
-
-static PyObject *
-iMeshObj_getData(iMeshObject *self,PyObject *args)
-{
- PyObject *obj;
- iBaseTag_Object *tag;
- char typechar=0;
- int type;
- int err;
-
- if(!PyArg_ParseTuple(args,"OO!|c",&obj,&iBaseTag_Type,&tag,&typechar))
- return NULL;
-
- if(typechar == 0)
- {
- /* infer the type of the data */
- iMesh_getTagType(self->mesh,tag->handle,&type,&err);
- if(checkError(self->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,entities,ent_size,tag->handle,&data,
- &alloc,&size,&err);
- if(!checkError(self->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,entities,ent_size,tag->handle,&data,
- &alloc,&size,&err);
- if(!checkError(self->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,entities,ent_size,tag->handle,&data,
- &alloc,&size,&err);
- if(!checkError(self->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,entities,ent_size,tag->handle,&data,
- &alloc,&size,&err);
- if(!checkError(self->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,set,tag->handle,&data,&err);
- if(checkError(self->mesh,err))
- return NULL;
- return Py_BuildValue("i",data);
- }
- else if(type == iBase_DOUBLE)
- {
- double data;
- iMesh_getEntSetDblData(self->mesh,set,tag->handle,&data,&err);
- if(checkError(self->mesh,err))
- return NULL;
- return Py_BuildValue("d",data);
- }
- else if(type == iBase_ENTITY_HANDLE)
- {
- iBaseEntity_Object *data = iBaseEntity_New();
- iMesh_getEntSetEHData(self->mesh,set,tag->handle,&data->handle,
- &err);
- if(checkError(self->mesh,err))
- {
- Py_DECREF(data);
- return NULL;
- }
- return (PyObject*)data;
- }
- else /* iBase_BYTES */
- {
- char *data=0;
- int alloc=0,size;
- iMesh_getEntSetData(self->mesh,set,tag->handle,&data,&alloc,&size,
- &err);
- if(checkError(self->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,entity,tag->handle,&data,&err);
- if(checkError(self->mesh,err))
- return NULL;
- return Py_BuildValue("i",data);
- }
- else if(type == iBase_DOUBLE)
- {
- double data;
- iMesh_getDblData(self->mesh,entity,tag->handle,&data,&err);
- if(checkError(self->mesh,err))
- return NULL;
- return Py_BuildValue("d",data);
- }
- else if(type == iBase_ENTITY_HANDLE)
- {
- iBaseEntity_Object *data = iBaseEntity_New();
- iMesh_getEHData(self->mesh,entity,tag->handle,&data->handle,&err);
- if(checkError(self->mesh,err))
- {
- Py_DECREF(data);
- return NULL;
- }
- return (PyObject*)data;
- }
- else /* iBase_BYTES */
- {
- char *data=0;
- int alloc=0,size;
- iMesh_getData(self->mesh,entity,tag->handle,&data,&alloc,&size,
- &err);
- if(checkError(self->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 *
iMeshObj_getAllTags(iMeshObject *self,PyObject *args)
{
PyObject *ents;
@@ -1318,46 +870,7 @@
(PyObject*)self);
}
-static PyObject *
-iMeshObj_rmvTag(iMeshObject *self,PyObject *args)
-{
- PyObject *obj;
- iBaseTag_Object *tag;
- int err;
- if(!PyArg_ParseTuple(args,"OO!",&obj,&iBaseTag_Type,&tag))
- 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,entities,ent_size,tag->handle,&err);
- Py_DECREF(ents);
- }
- else if(iBaseEntitySet_Check(obj))
- {
- iBase_EntitySetHandle set = iBaseEntitySet_GetHandle(obj);
- iMesh_rmvEntSetTag(self->mesh,set,tag->handle,&err);
- }
- else if(iBaseEntity_Check(obj))
- {
- iBase_EntityHandle entity = iBaseEntity_GetHandle(obj);
- iMesh_rmvTag(self->mesh,entity,tag->handle,&err);
- }
- else
- {
- PyErr_SetString(PyExc_ValueError,ERR_ANY_ENT);
- return NULL;
- }
-
- if(checkError(self->mesh,err))
- return NULL;
- Py_RETURN_NONE;
-}
-
-
static PyMethodDef iMesh_methods[] = {
{ "load", (PyCFunction)iMeshObj_load, METH_VARARGS,
"Load a mesh from a file"
@@ -1369,9 +882,6 @@
"Return whether entity handles have changed since last reset or since "
"instance construction"
},
- { "getEntities", (PyCFunction)iMeshObj_getEntities, METH_VARARGS,
- "Get entities of specific type and/or topology in set or instance"
- },
{ "getVtxCoords", (PyCFunction)iMeshObj_getVtxCoords, METH_VARARGS,
"Get coordinates of specified vertex(ices)"
},
@@ -1387,9 +897,6 @@
{ "getEnt2ndAdj", (PyCFunction)iMeshObj_getEnt2ndAdj, METH_VARARGS,
"Get \"2nd order\" adjacencies to entity(ies)"
},
- { "getAdjEntIndices", (PyCFunction)iMeshObj_getAdjEntIndices, METH_VARARGS,
- "Get indexed representation of mesh or subset of mesh"
- },
{ "createEntSet", (PyCFunction)iMeshObj_createEntSet, METH_VARARGS,
"Create an entity set"
},
@@ -1420,19 +927,10 @@
{ "getTagHandle", (PyCFunction)iMeshObj_getTagHandle, METH_VARARGS,
"Get the handle of an existing tag with the specified name"
},
- { "setData", (PyCFunction)iMeshObj_setData, METH_VARARGS,
- "Set tag values on an entity (or array/set of entities)"
- },
- { "getData", (PyCFunction)iMeshObj_getData, METH_VARARGS,
- "Get tag values on an entity (or array/set of entities)"
- },
{ "getAllTags", (PyCFunction)iMeshObj_getAllTags, METH_VARARGS,
"Get all the tags associated with a specified entity handle (or "
"array/set of entities)"
},
- { "rmvTag", (PyCFunction)iMeshObj_rmvTag, METH_VARARGS,
- "Remove a tag value from an entity (or array/set of entities)"
- },
{0}
};
Modified: MOAB/trunk/tools/iMesh/python/iMesh_entSet.c
===================================================================
--- MOAB/trunk/tools/iMesh/python/iMesh_entSet.c 2009-05-28 20:45:59 UTC (rev 2917)
+++ MOAB/trunk/tools/iMesh/python/iMesh_entSet.c 2009-05-28 23:14:04 UTC (rev 2918)
@@ -48,7 +48,7 @@
return NULL;
iMesh_getNumOfType(self->mesh->mesh,self->set.handle,type,&num,&err);
- if(checkError(self->mesh,err))
+ if(checkError(self->mesh->mesh,err))
return NULL;
return Py_BuildValue("i",num);
@@ -63,13 +63,85 @@
return NULL;
iMesh_getNumOfTopo(self->mesh->mesh,self->set.handle,topo,&num,&err);
- if(checkError(self->mesh,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;
+
+ /* TODO: this is clunky */
+ PyObject *tup = PyTuple_New(4);
+ npy_intp dims[1];
+
+ dims[0] = ent_size;
+ PyTuple_SET_ITEM(tup, 0,
+ PyArray_NewFromMalloc(1,dims,NPY_IBASEENT,entities));
+
+ dims[0] = adj_size;
+ PyTuple_SET_ITEM(tup, 1,
+ PyArray_NewFromMalloc(1,dims,NPY_IBASEENT,adj_ents));
+
+ dims[0] = ind_size;
+ PyTuple_SET_ITEM(tup, 2,
+ PyArray_NewFromMalloc(1,dims,NPY_INT,indices));
+
+ dims[0] = off_size;
+ PyTuple_SET_ITEM(tup, 3,
+ PyArray_NewFromMalloc(1,dims,NPY_INT,offsets));
+
+ return tup;
+}
+
+static PyObject *
iMeshEntSetObj_isList(iMeshEntitySet_Object *self,void *closure)
{
int is_list,err;
@@ -378,7 +450,7 @@
if(!PyArg_UnpackTuple(args,"iterate",2,3,&type,&topo,&count))
return NULL;
- tuple = PyTuple_Pack(size+2,self->mesh,self,type,topo,count);
+ tuple = PyTuple_Pack(size+1,self,type,topo,count);
ret = PyObject_CallObject((PyObject*)&iMeshIter_Type,tuple);
Py_DECREF(tuple);
@@ -486,32 +558,39 @@
static PyMethodDef iMeshEntSetObj_methods[] = {
{ "load", (PyCFunction)iMeshEntSetObj_load, METH_VARARGS,
- "Load a mesh from a file"
+ "Load a mesh from a file into this set"
},
{ "save", (PyCFunction)iMeshEntSetObj_save, METH_VARARGS,
- "Save the mesh to a file"
+ "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 the set"
+ "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 the set"
+ "Get the number of entity sets contained in this set"
},
{ "getEntSets", (PyCFunction)iMeshEntSetObj_getEntSets, METH_VARARGS,
- "Get the entity sets contained in the set"
+ "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 the set"
+ "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 the set"
+ "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 the set"
+ "contained in this set"
},
{ "addChild", (PyCFunction)iMeshEntSetObj_addChild, METH_VARARGS,
"Add parent/child links between two sets"
Modified: MOAB/trunk/tools/iMesh/python/iMesh_iter.c
===================================================================
--- MOAB/trunk/tools/iMesh/python/iMesh_iter.c 2009-05-28 20:45:59 UTC (rev 2917)
+++ MOAB/trunk/tools/iMesh/python/iMesh_iter.c 2009-05-28 23:14:04 UTC (rev 2918)
@@ -7,26 +7,26 @@
static int
iMeshIterObj_init(iMeshIter_Object *self,PyObject *args,PyObject *kwds)
{
- static char *kwlist[] = {"mesh","entity_set","type","topology",
- "array_size",0};
- iMeshObject *mesh;
- iBaseEntitySet_Object *set;
+ static char *kwlist[] = {"set","type","topology","size",0};
+ iMeshEntitySet_Object *set;
int type,topo,array_size=1,err;
- if( !PyArg_ParseTupleAndKeywords(args,kwds,"OOii|i",kwlist,&mesh,&set,
- &type,&topo,&array_size) )
+ if( !PyArg_ParseTupleAndKeywords(args,kwds,"O!ii|i",kwlist,
+ &iMeshEntitySet_Type,&set,&type,&topo,
+ &array_size) )
return -1;
- self->mesh = mesh->mesh;
+ self->mesh = set->mesh->mesh;
if(array_size == 1)
{
self->is_arr = 0;
- iMesh_initEntIter(self->mesh,set->handle,type,topo,&self->iter,&err);
+ iMesh_initEntIter(self->mesh,set->set.handle,type,topo,&self->iter,
+ &err);
}
else
{
self->is_arr = 1;
- iMesh_initEntArrIter(self->mesh,set->handle,type,topo,array_size,
+ iMesh_initEntArrIter(self->mesh,set->set.handle,type,topo,array_size,
&self->arr_iter,&err);
}
if(checkError(self->mesh,err))
Modified: MOAB/trunk/tools/iMesh/python/iMesh_tag.c
===================================================================
--- MOAB/trunk/tools/iMesh/python/iMesh_tag.c 2009-05-28 20:45:59 UTC (rev 2917)
+++ MOAB/trunk/tools/iMesh/python/iMesh_tag.c 2009-05-28 23:14:04 UTC (rev 2918)
@@ -3,6 +3,7 @@
#include "iMesh_Python.h"
#include "iBase_Python.h"
+#include "errors.h"
static char typechars[] = {'i','d','E','b'};
@@ -70,8 +71,433 @@
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}
};
Modified: MOAB/trunk/tools/iMesh/python/perf/perf.py
===================================================================
--- MOAB/trunk/tools/iMesh/python/perf/perf.py 2009-05-28 20:45:59 UTC (rev 2917)
+++ MOAB/trunk/tools/iMesh/python/perf/perf.py 2009-05-28 23:14:04 UTC (rev 2918)
@@ -77,14 +77,14 @@
##### 2 #####
timer.reset()
for x in range(count):
- mesh.getAdjEntIndices(root, iBase.type.all,
- iMesh.topology.all, iBase.type.all)
+ root.getAdjEntIndices(iBase.type.all, iMesh.topology.all,
+ iBase.type.all)
py_stats[file].append( timer.delta()/count )
list_stats[file].append(0)
##### Intermission #####
- arr = mesh.getAdjEntIndices(root, iBase.type.all,
- iMesh.topology.all, iBase.type.all)
+ arr = root.getAdjEntIndices(iBase.type.all, iMesh.topology.all,
+ iBase.type.all)
list = map(lambda x: x.tolist(), arr)
##### 3 #####
Modified: MOAB/trunk/tools/iMesh/python/test/adj.py
===================================================================
--- MOAB/trunk/tools/iMesh/python/test/adj.py 2009-05-28 20:45:59 UTC (rev 2917)
+++ MOAB/trunk/tools/iMesh/python/test/adj.py 2009-05-28 23:14:04 UTC (rev 2918)
@@ -85,8 +85,8 @@
def testAdjIndices(self):
set = self.mesh.createEntSet(True)
set.add(self.ents)
- adj = self.mesh.getAdjEntIndices(set, iBase.type.all, topo.all,
- iBase.type.all)
+ adj = set.getAdjEntIndices(iBase.type.all, topo.all,
+ iBase.type.all)
self.assertEqual(adj[0].tolist(), self.ents.tolist())
self.assertEqual(adj[1].tolist(), self.lines)
Modified: MOAB/trunk/tools/iMesh/python/test/basic.py
===================================================================
--- MOAB/trunk/tools/iMesh/python/test/basic.py 2009-05-28 20:45:59 UTC (rev 2917)
+++ MOAB/trunk/tools/iMesh/python/test/basic.py 2009-05-28 23:14:04 UTC (rev 2918)
@@ -85,7 +85,7 @@
mesh = iMesh()
root = mesh.rootSet
mesh.load(file.name)
- ents = mesh.getEntities(root, iBase.type.all, iMesh.topology.all)
+ ents = root.getEntities(iBase.type.all, iMesh.topology.all)
self.assertEqual(root.getNumOfType(iBase.type.vertex), 1)
self.assertEqual(root.getNumOfTopo(iMesh.topology.point), 1)
@@ -93,6 +93,26 @@
coords = mesh.getVtxCoords(ents, iBase.storageOrder.interleaved)
self.assert_( (coords == [1,2,3]).all() )
+ def testAltSave(self):
+ file = tempfile.NamedTemporaryFile()
+ mesh = iMesh()
+ verts = [1,2,3]
+ mesh.createVtx(verts)
+
+ mesh.rootSet.save(file.name)
+
+ mesh = iMesh()
+ root = mesh.rootSet
+ root.load(file.name)
+ ents = root.getEntities(iBase.type.all, iMesh.topology.all)
+
+ self.assertEqual(root.getNumOfType(iBase.type.vertex), 1)
+ self.assertEqual(root.getNumOfTopo(iMesh.topology.point), 1)
+
+ coords = mesh.getVtxCoords(ents, iBase.storageOrder.interleaved)
+ self.assert_( (coords == [1,2,3]).all() )
+
+
suite = unittest.TestLoader().loadTestsFromTestCase(TestBasic)
unittest.TextTestRunner(verbosity=2).run(suite)
Modified: MOAB/trunk/tools/iMesh/python/test/iter.py
===================================================================
--- MOAB/trunk/tools/iMesh/python/test/iter.py 2009-05-28 20:45:59 UTC (rev 2917)
+++ MOAB/trunk/tools/iMesh/python/test/iter.py 2009-05-28 23:14:04 UTC (rev 2918)
@@ -34,8 +34,7 @@
def testAlternate(self):
count = 0
- iter = iMesh.iterator(self.mesh, self.set, iBase.type.all,
- iMesh.topology.all)
+ iter = iMesh.iterator(self.set, iBase.type.all, iMesh.topology.all)
for i in iter:
count += 1
self.assertEqual(i, self.ent)
Modified: MOAB/trunk/tools/iMesh/python/test/tags.py
===================================================================
--- MOAB/trunk/tools/iMesh/python/test/tags.py 2009-05-28 20:45:59 UTC (rev 2917)
+++ MOAB/trunk/tools/iMesh/python/test/tags.py 2009-05-28 23:14:04 UTC (rev 2918)
@@ -29,46 +29,41 @@
self.assertRaises(RuntimeError, self.mesh.getTagHandle, 'potato')
def testIntData(self):
- self.mesh.setData(self.ent, self.itag, 42)
- self.assertEqual(self.mesh.getData(self.ent, self.itag), 42)
- self.assertEqual(self.mesh.getData(self.ent, self.itag, 'i'), 42)
+ self.itag.setData(self.ent, 42)
+ self.assertEqual(self.itag.getData(self.ent), 42)
+ self.assertEqual(self.itag.getData(self.ent, 'i'), 42)
- self.mesh.rmvTag(self.ent, self.itag)
- self.assertRaises(RuntimeError, self.mesh.getData,
- self.ent,self.itag)
+ self.itag.remove(self.ent)
+ self.assertRaises(RuntimeError, self.itag.getData, self.ent)
def testDblData(self):
- self.mesh.setData(self.ent, self.dtag, 42.0)
- self.assertEqual(self.mesh.getData(self.ent, self.dtag), 42.0)
- self.assertEqual(self.mesh.getData(self.ent, self.dtag, 'd'), 42.0)
+ self.dtag.setData(self.ent, 42.0)
+ self.assertEqual(self.dtag.getData(self.ent), 42)
+ self.assertEqual(self.dtag.getData(self.ent, 'd'), 42)
- self.mesh.rmvTag(self.ent, self.dtag)
- self.assertRaises(RuntimeError, self.mesh.getData,
- self.ent,self.dtag)
+ self.dtag.remove(self.ent)
+ self.assertRaises(RuntimeError, self.dtag.getData, self.ent)
def testEHData(self):
- self.mesh.setData(self.ent, self.etag, self.ent)
- self.assertEqual(self.mesh.getData(self.ent, self.etag), self.ent)
- self.assertEqual(self.mesh.getData(self.ent, self.etag, 'E'), self.ent)
+ self.etag.setData(self.ent, self.ent)
+ self.assertEqual(self.etag.getData(self.ent), self.ent)
+ self.assertEqual(self.etag.getData(self.ent, 'E'), self.ent)
- self.mesh.rmvTag(self.ent, self.etag)
- self.assertRaises(RuntimeError, self.mesh.getData,
- self.ent,self.etag)
+ self.etag.remove(self.ent)
+ self.assertRaises(RuntimeError, self.etag.getData, self.ent)
def testRawData(self):
data = array([1,2,3], int8)
- self.mesh.setData(self.ent, self.btag, data)
- self.assert_( (self.mesh.getData(self.ent, self.btag) == data).all() )
- self.assert_( (self.mesh.getData(self.ent, self.btag, 'b') == data)
- .all() )
+ self.btag.setData(self.ent, data)
+ self.assert_( (self.btag.getData(self.ent) == data).all() )
+ self.assert_( (self.btag.getData(self.ent, 'b') == data).all() )
- self.mesh.rmvTag(self.ent, self.btag)
- self.assertRaises(RuntimeError, self.mesh.getData,
- self.ent,self.btag)
+ self.btag.remove(self.ent)
+ self.assertRaises(RuntimeError, self.btag.getData, self.ent)
def testGetAll(self):
- self.mesh.setData(self.ent, self.itag, 42)
- self.mesh.setData(self.ent, self.dtag, 42)
+ self.itag.setData(self.ent, 42)
+ self.dtag.setData(self.ent, 42)
tags = self.mesh.getAllTags(self.ent)
self.assertEqual(tags[0].name, self.itag.name) # TODO: ignore order?
@@ -76,96 +71,94 @@
def testIntArrData(self):
- self.mesh.setData(self.ents, self.itag, 3*[42])
+ self.itag.setData(self.ents, 3*[42])
- self.assert_((self.mesh.getData(self.ents, self.itag, 'i') ==
- 3*[42]).all())
- self.assertEqual(self.mesh.getData(self.ents[0], self.itag, 'i'), 42)
+ self.assert_((self.itag.getData(self.ents) == 3*[42]).all())
+ self.assert_((self.itag.getData(self.ents, 'i') == 3*[42]).all())
- self.mesh.rmvTag(self.ents, self.itag)
- self.assertRaises(RuntimeError, self.mesh.getData,
- self.ents,self.itag)
+ self.assertEqual(self.itag.getData(self.ents[0]), 42)
+ self.assertEqual(self.itag.getData(self.ents[0], 'i'), 42)
+ self.itag.remove(self.ents)
+ self.assertRaises(RuntimeError, self.itag.getData, self.ents)
+
def testDblArrData(self):
- self.mesh.setData(self.ents, self.dtag, 3*[42.0])
+ self.dtag.setData(self.ents, 3*[42])
- self.assert_((self.mesh.getData(self.ents, self.dtag, 'd') ==
- 3*[42.0]).all())
- self.assertEqual(self.mesh.getData(self.ents[0], self.dtag, 'd'), 42.0)
+ self.assert_((self.dtag.getData(self.ents) == 3*[42]).all())
+ self.assert_((self.dtag.getData(self.ents, 'd') == 3*[42]).all())
- self.mesh.rmvTag(self.ents, self.dtag)
- self.assertRaises(RuntimeError, self.mesh.getData,
- self.ents,self.dtag)
+ self.assertEqual(self.dtag.getData(self.ents[0]), 42)
+ self.assertEqual(self.dtag.getData(self.ents[0], 'd'), 42)
+ self.dtag.remove(self.ents)
+ self.assertRaises(RuntimeError, self.dtag.getData, self.ents)
+
def testEHArrData(self):
- self.mesh.setData(self.ents, self.etag, self.ents)
+ self.etag.setData(self.ents, self.ents)
- self.assertEqual(str(self.mesh.getData(self.ents, self.etag, 'E')),
- str(self.ents))
- self.assertEqual(self.mesh.getData(self.ents[0], self.etag, 'E'),
- self.ents[0])
+ self.assertEqual(self.etag.getData(self.ents).tolist(),
+ self.ents.tolist())
+ self.assertEqual(self.etag.getData(self.ents, 'E').tolist(),
+ self.ents.tolist())
- self.mesh.rmvTag(self.ents, self.etag)
- self.assertRaises(RuntimeError, self.mesh.getData,
- self.ents,self.etag)
+ self.assertEqual(self.etag.getData(self.ents[0]), self.ents[0])
+ self.assertEqual(self.etag.getData(self.ents[0], 'E'), self.ents[0])
+ self.etag.remove(self.ents)
+ self.assertRaises(RuntimeError, self.etag.getData, self.ents)
+
def testRawArrData(self):
data = array(3*[1,2,3], int8)
- self.mesh.setData(self.ents, self.btag, data)
+ self.btag.setData(self.ents, data)
- self.assert_((self.mesh.getData(self.ents, self.btag, 'b') ==
- data).all())
- self.assert_((self.mesh.getData(self.ents[0], self.btag, 'b') ==
- data[0:3]).all())
+ self.assert_((self.btag.getData(self.ents) == data).all())
+ self.assert_((self.btag.getData(self.ents, 'b') == data).all())
- self.mesh.rmvTag(self.ents, self.btag)
- self.assertRaises(RuntimeError, self.mesh.getData,
- self.ents,self.btag)
+ self.assert_((self.btag.getData(self.ents[0]) == data[0:3]).all())
+ self.assert_((self.btag.getData(self.ents[0], 'b') == data[0:3]).all())
+ self.btag.remove(self.ents)
+ self.assertRaises(RuntimeError, self.btag.getData, self.ents)
def testIntSetData(self):
- self.mesh.setData(self.set, self.itag, 42)
- self.assertEqual(self.mesh.getData(self.set, self.itag), 42)
- self.assertEqual(self.mesh.getData(self.set, self.itag, 'i'), 42)
+ self.itag.setData(self.set, 42)
+ self.assertEqual(self.itag.getData(self.set), 42)
+ self.assertEqual(self.itag.getData(self.set, 'i'), 42)
- self.mesh.rmvTag(self.set, self.itag)
- self.assertRaises(RuntimeError, self.mesh.getData,
- self.set,self.itag)
+ self.itag.remove(self.set)
+ self.assertRaises(RuntimeError, self.itag.getData, self.set)
def testDblSetData(self):
- self.mesh.setData(self.set, self.dtag, 42)
- self.assertEqual(self.mesh.getData(self.set, self.dtag), 42)
- self.assertEqual(self.mesh.getData(self.set, self.dtag, 'd'), 42)
+ self.dtag.setData(self.set, 42)
+ self.assertEqual(self.dtag.getData(self.set), 42)
+ self.assertEqual(self.dtag.getData(self.set, 'd'), 42)
- self.mesh.rmvTag(self.set, self.dtag)
- self.assertRaises(RuntimeError, self.mesh.getData,
- self.set,self.dtag)
+ self.dtag.remove(self.set)
+ self.assertRaises(RuntimeError, self.dtag.getData, self.set)
def testEHSetData(self):
- self.mesh.setData(self.set, self.etag, self.ent)
- self.assertEqual(self.mesh.getData(self.set, self.etag), self.ent)
- self.assertEqual(self.mesh.getData(self.set, self.etag, 'd'), self.ent)
+ self.etag.setData(self.set, self.ent)
+ self.assertEqual(self.etag.getData(self.set), self.ent)
+ self.assertEqual(self.etag.getData(self.set, 'E'), self.ent)
- self.mesh.rmvTag(self.set, self.etag)
- self.assertRaises(RuntimeError, self.mesh.getData,
- self.set,self.etag)
+ self.etag.remove(self.set)
+ self.assertRaises(RuntimeError, self.etag.getData, self.set)
def testRawSetData(self):
data = array([1,2,3], int8)
- self.mesh.setData(self.set, self.btag, data)
+ self.btag.setData(self.set, data)
- self.assert_((self.mesh.getData(self.set, self.btag) == data).all())
- self.assert_((self.mesh.getData(self.set, self.btag, 'b') == data)
- .all())
+ self.assert_((self.btag.getData(self.set) == data).all())
+ self.assert_((self.btag.getData(self.set, 'b') == data).all())
- self.mesh.rmvTag(self.set, self.btag)
- self.assertRaises(RuntimeError, self.mesh.getData,
- self.set,self.btag)
+ self.btag.remove(self.set)
+ self.assertRaises(RuntimeError, self.btag.getData, self.set)
def testGetAllSet(self):
- self.mesh.setData(self.set, self.itag, 42)
- self.mesh.setData(self.set, self.dtag, 42)
+ self.itag.setData(self.set, 42)
+ self.dtag.setData(self.set, 42)
tags = self.mesh.getAllTags(self.set)
self.assertEqual(tags[0].name, self.itag.name) # TODO: ignore order?
More information about the moab-dev
mailing list