[MOAB-dev] r2930 - in MOAB/trunk/tools/iMesh/python: . doc tools
jvporter at wisc.edu
jvporter at wisc.edu
Thu Jun 4 22:13:59 CDT 2009
Author: jvporter
Date: 2009-06-04 22:13:56 -0500 (Thu, 04 Jun 2009)
New Revision: 2930
Modified:
MOAB/trunk/tools/iMesh/python/doc/build.rst
MOAB/trunk/tools/iMesh/python/doc/helpers.rst
MOAB/trunk/tools/iMesh/python/iBase.c
MOAB/trunk/tools/iMesh/python/setup.py
MOAB/trunk/tools/iMesh/python/tools/volume.py
Log:
* Add support for auto-detection of dependencies for Python via
iMesh-Defs.inc
* Minor fixes to Numpy arrays for iBase types
* Add more documentation
Modified: MOAB/trunk/tools/iMesh/python/doc/build.rst
===================================================================
--- MOAB/trunk/tools/iMesh/python/doc/build.rst 2009-06-04 05:46:41 UTC (rev 2929)
+++ MOAB/trunk/tools/iMesh/python/doc/build.rst 2009-06-05 03:13:56 UTC (rev 2930)
@@ -7,6 +7,15 @@
directory for PyTAPS. However, certain iMesh interfaces may require some
additional setup.
+The PyTAPS setup script supports importing definitions from the
+`iMesh-Defs.inc` file. In order to make use of this, specify the root
+location of your iMesh installation in the environment variable ``IMESHPATH``.
+For example, if your `iMesh-Defs.inc` is located in
+`/usr/local/iMesh/lib/iMesh-Defs.inc`, then ``IMESHPATH`` should be
+`/usr/local/iMesh`. If the `iMesh-Defs.inc` file was not installed, or you
+don't wish to use it, you can manually specify the build options as described
+below in `Non-standard Library Locations`_.
+
Requirements
============
Modified: MOAB/trunk/tools/iMesh/python/doc/helpers.rst
===================================================================
--- MOAB/trunk/tools/iMesh/python/doc/helpers.rst 2009-06-04 05:46:41 UTC (rev 2929)
+++ MOAB/trunk/tools/iMesh/python/doc/helpers.rst 2009-06-05 03:13:56 UTC (rev 2930)
@@ -20,24 +20,30 @@
.. method:: __getitem__(i[, j])
- Return the entities adjacent to the ``i``\ th entity. If ``j`` is
- specified, returns only the ``j``\ th entity of the preceding array.
+ Return the entities adjacent to the `i`\ th entity. If `j` is specified,
+ returns only the `j`\ th entity of the preceding array. As you would
+ expect, this is generally called as ``list[i, j]``.
+ .. note::
+ This method is equivalent to ``adj[ offsets[i]:offsets[i+1] ]`` when
+ only `i` is specified, and is equivalent to ``adj[ offsets[i]+j ]``
+ when both `i` and `j` are specified.
+
:param i: Index of the entity to query for adjacencies
- :param j: Index into the ``i``\ th entity's adjacency array
- :return: If ``j`` is specified, a single entity. Otherwise, an array of
+ :param j: Index into the `i`\ th entity's adjacency array
+ :return: If `j` is specified, a single entity. Otherwise, an array of
entities.
.. method:: length([i])
Return the number of entities whose adjacencies are stored in this object.
- If ``i`` is specified, return the number of adjacencies for the ``i``\ th
+ If `i` is specified, return the number of adjacencies for the `i`\ th
entity.
:param i: Index of the entity to query
- :return: If ``i`` is ``None``, the number of entities whose adjacencies
+ :return: If `i` is ``None``, the number of entities whose adjacencies
are stored. Otherwise, the number of adjacencies for the
- ``i``\ th entity.
+ `i`\ th entity.
IndexedAdjacencyList
@@ -52,11 +58,11 @@
.. attribute:: adj
A one-dimensional array of all entities adjacent to the elements of
- ``entities``
+ :attr:`entities`
.. attribute:: indices
- An index buffer into ``adj``
+ An index buffer into :attr:`adj`
.. attribute:: offsets
@@ -64,32 +70,41 @@
.. method:: __getitem__(i[, j])
- Return the entities adjacent to the ``i`` th entity. If ``j``
- is specified, returns only the ``j`` th entity of the preceding array.
+ Return the entities adjacent to the `i` th entity. If `j` is specified,
+ returns only the `j`\ th entity of the preceding array. As you would
+ expect, this is generally called as ``list[i, j]``.
+ .. note::
+ This method is equivalent to ``adj[ index(i, j) ]``, and relies on the
+ special indexing features of Numpy arrays.
+
:param i: Index of the entity to query for adjacencies
- :param j: Index into the ``i`` th entity's adjacency array
- :return: If ``j`` is specified, a single entity. Otherwise, an array of
+ :param j: Index into the `i` th entity's adjacency array
+ :return: If `j` is specified, a single entity. Otherwise, an array of
entities.
.. method:: index(i[, j])
- Return the indices of the entities adjacent to the ``i``\ th entity. If
- ``j`` is specified, returns only the ``j``\ th index of the preceding
- array.
+ Return the indices of the entities adjacent to the `i`\ th entity. If `j`
+ is specified, returns only the `j`\ th index of the preceding array.
:param i: Index of the entity to query for adjacencies
- :param j: Index into the ``i``\ th entity's adjacency array
- :return: If ``j`` is specified, a single index. Otherwise, an array of
+ :param j: Index into the `i`\ th entity's adjacency array
+ :return: If `j` is specified, a single index. Otherwise, an array of
indices.
+ .. note::
+ This method is equivalent to ``indices[ offsets[i]:offsets[i+1] ]``
+ when only `i` is specified, and is equivalent to
+ ``indices[ offsets[i]+j ]`` when both `i` and `j` are specified.
+
.. method:: length([i])
Return the number of entities whose adjacencies are stored in this object.
- If ``i`` is specified, return the number of adjacencies for the ``i``\ th
+ If `i` is specified, return the number of adjacencies for the `i`\ th
entity.
:param i: Index of the entity to query
- :return: If ``i`` is ``None``, the number of entities whose adjacencies
+ :return: If `i` is ``None``, the number of entities whose adjacencies
are stored. Otherwise, the number of adjacencies for the
- ``i``\ th entity.
+ `i`\ th entity.
Modified: MOAB/trunk/tools/iMesh/python/iBase.c
===================================================================
--- MOAB/trunk/tools/iMesh/python/iBase.c 2009-06-04 05:46:41 UTC (rev 2929)
+++ MOAB/trunk/tools/iMesh/python/iBase.c 2009-06-05 03:13:56 UTC (rev 2930)
@@ -123,6 +123,9 @@
static int
iBaseEntSetArr_setitem(PyObject *item,void *data,void *arr)
{
+ if(!iBaseEntitySet_Check(item))
+ return -1;
+ *(iBase_EntitySetHandle*)data = iBaseEntitySet_GetHandle(item);
return 0;
}
@@ -192,6 +195,9 @@
static int
iBaseTagArr_setitem(PyObject *item,void *data,void *arr)
{
+ if(!iBaseTag_Check(item))
+ return -1;
+ *(iBase_TagHandle*)data = iBaseTag_GetHandle(item);
return 0;
}
Modified: MOAB/trunk/tools/iMesh/python/setup.py
===================================================================
--- MOAB/trunk/tools/iMesh/python/setup.py 2009-06-04 05:46:41 UTC (rev 2929)
+++ MOAB/trunk/tools/iMesh/python/setup.py 2009-06-05 03:13:56 UTC (rev 2930)
@@ -1,13 +1,37 @@
from distutils.core import setup, Extension
+from distutils.sysconfig import parse_makefile
+import re
+import os
+# this is an enormous hack because distutils won't let me specify libraries in
+# 'extra_link_args' for unknown reasons
+iMesh_libs = []
+iMesh_libdirs = []
+compileargs = ''
+
+if 'IMESHPATH' in os.environ:
+ defs = parse_makefile( os.path.join(os.environ['IMESHPATH'],
+ 'lib/iMesh-Defs.inc') )
+
+ compileargs = defs['IMESH_INCLUDES']
+
+ lib_match = re.compile(r'(?:(?<=\s)|^)-([lL])\s*(\S*)')
+ for match in lib_match.finditer( defs['IMESH_LIBS'] ):
+ if match.group(1) == 'l':
+ iMesh_libs.append( match.group(2) )
+ elif match.group(1) == 'L':
+ iMesh_libdirs.append( match.group(2) )
+
iBase = Extension('itaps.iBase',
+ extra_compile_args = [ compileargs ],
depends = ['common.h', 'iBase_Python.h'],
sources = ['iBase.c']
)
iMesh = Extension('itaps.iMesh',
- libraries = ['iMesh', 'm', 'gcc_s', 'c', 'MOAB',
- 'netcdf_c++', 'netcdf', 'hdf5', 'stdc++'],
+ extra_compile_args = [ compileargs ],
+ 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',
Modified: MOAB/trunk/tools/iMesh/python/tools/volume.py
===================================================================
--- MOAB/trunk/tools/iMesh/python/tools/volume.py 2009-06-04 05:46:41 UTC (rev 2929)
+++ MOAB/trunk/tools/iMesh/python/tools/volume.py 2009-06-05 03:13:56 UTC (rev 2930)
@@ -43,13 +43,13 @@
x+=1
return volume
-parser = OptionParser()
+parser = OptionParser('Usage: %prog [options] file1 file2')
parser.add_option('-r', '--raw', action='store_true', dest='raw')
(options, args) = parser.parse_args()
if len(args) != 2:
- print 'Usage: python volume.py [opts] file1 file2'
+ print 'Usage: volume.py [options] file1 file2'
exit(1)
mesh_pre = iMesh.Mesh()
More information about the moab-dev
mailing list