MOAB: Mesh Oriented datABase  (version 5.5.0)
iBase.h
Go to the documentation of this file.
1 #ifndef _ITAPS_iBase
2 #define _ITAPS_iBase
3 
4 /***************************************************************************/ /**
5  * \ingroup
6  *VersionNumbers
7  * \brief Compile time
8  *version number
9  *digits
10  *
11  * iBase maintains a
12  *major, minor and
13  *patch digit in its
14  *version number.
15  * Technically
16  *speaking, there is
17  *not much practical
18  *value in patch digit
19  * for an interface
20  *specification. A
21  *patch release is
22  *typically only used
23  * for bug fix
24  *releases. Although
25  *it is rare,
26  *sometimes a bug fix
27  * necessitates an API
28  *change. So, we
29  *define a patch digit
30  *for iBase.
31  *
32  * Although each
33  *interface in ITAPS
34  *has been designed to
35  *support its own
36  * unique version
37  *numbers, apart from
38  *other ITAPS
39  *interfaces, as
40  *currently used, we
41  *require all ITAPS
42  *interfaces to use
43  *the same ITAPS-wide
44  *version number
45  *derived from the
46  *version number
47  *defined by these
48  *three digits.
49  ******************************************************************************/
50 #define IBASE_VERSION_MAJOR 1
51 #define IBASE_VERSION_MINOR 4
52 #define IBASE_VERSION_PATCH 1
53 
54 /***************************************************************************/ /**
55  * \ingroup
56  *VersionNumbers
57  * \brief Version
58  *Comparison
59  *
60  * Evaluates to true
61  *at CPP time if the
62  *version of iBase
63  *currently being
64  * compiled is greater
65  *than or equal to the
66  *version specified.
67  ******************************************************************************/
68 #define IBASE_VERSION_GE( Maj, Min, Pat ) \
69  ( ( ( IBASE_VERSION_MAJOR == ( Maj ) ) && ( IBASE_VERSION_MINOR == ( Min ) ) && \
70  ( IBASE_VERSION_PATCH >= ( Pat ) ) ) || \
71  ( ( IBASE_VERSION_MAJOR == ( Maj ) ) && ( IBASE_VERSION_MINOR > ( Min ) ) ) || \
72  ( IBASE_VERSION_MAJOR > ( Maj ) ) )
73 
74 /***************************************************************************/ /**
75  * \ingroup
76  *VersionNumbers
77  * \brief Compose
78  *compile-time string
79  *represention of the
80  *version number
81  ******************************************************************************/
82 #define IBASE_VERSION_STRING___( I, X, Y, Z ) #I "_Version_" #X "." #Y "." #Z
83 #define IBASE_VERSION_STRING__( I, X, Y, Z ) IBASE_VERSION_STRING___( I, X, Y, Z )
84 #define IBASE_VERSION_STRING_( I ) \
85  IBASE_VERSION_STRING__( I, IBASE_VERSION_MAJOR, IBASE_VERSION_MINOR, IBASE_VERSION_PATCH )
86 #define IBASE_VERSION_STRING IBASE_VERSION_STRING_( iBase )
87 
88 /***************************************************************************/ /**
89  * \ingroup
90  *VersionNumbers
91  * \brief Compose
92  *compile-time symbol
93  *name derived from
94  *the version number.
95  ******************************************************************************/
96 #define IBASE_VERSION_TAG__( I, X, Y, Z ) I##_Version_##X##_##Y##_##Z
97 #define IBASE_VERSION_TAG_( I, X, Y, Z ) IBASE_VERSION_TAG__( I, X, Y, Z )
98 #define IBASE_VERSION_TAG( I ) IBASE_VERSION_TAG_( I, IBASE_VERSION_MAJOR, IBASE_VERSION_MINOR, IBASE_VERSION_PATCH )
99 
100 /***************************************************************************/ /**
101  * \ingroup
102  *VersionNumbers
103  * \brief ITAPS-wide
104  *(across all ITAPS
105  *APIs) version
106  *handling
107  ******************************************************************************/
108 #define ITAPS_VERSION_MAJOR IBASE_VERSION_MAJOR
109 #define ITAPS_VERSION_MINOR IBASE_VERSION_MINOR
110 #define ITAPS_VERSION_PATCH IBASE_VERSION_PATCH
111 #define ITAPS_VERSION_GE( Maj, Min, Pat ) IBASE_VERSION_GE( Maj, Min, Pat )
112 #define ITAPS_VERSION_STRING_( I ) IBASE_VERSION_STRING_( I )
113 #define ITAPS_VERSION_STRING ITAPS_VERSION_STRING_( ITAPS )
114 #define ITAPS_VERSION_TAG_( I ) IBASE_VERSION_TAG( I )
115 #define ITAPS_VERSION_TAG ITAPS_VERSION_TAG_( I )
116 
117 /***************************************************************************/ /**
118  * \defgroup
119  *EnumIterators
120  *Enum-Iterators
121  * \ingroup iBase
122  * \brief Convenience
123  *macros for iterating
124  *over all possible
125  *values in an enum
126  *
127  * These convenience
128  *macros are provided
129  *to facilitate
130  *iterating over all
131  * possible values in
132  *an enumerated type.
133  *To use these macros,
134  *for example... \code
135  * for
136  *(iBase_EntityType i
137  *=
138  *IBASE_MINENUM(iBase_EntityType);
139  * i
140  *<=
141  *IBASE_MAXENUM(iBase_EntityType);
142  * IBASE_INCENUM(i,iBase_EntityType))
143  * {
144  * }
145  * \endcode
146  * Be aware that some
147  *enumerated types
148  *include a <em>wild
149  *card</em> often used
150  * in queries to
151  *represent all
152  *possible values and
153  *you may or may not
154  *want to include such
155  *a value in your
156  *iteration.
157  ******************************************************************************/
158 
159 /***************************************************************************/ /**
160  * \ingroup
161  *EnumIterators
162  * @{
163  ******************************************************************************/
164 #define IBASE_MINENUM( enumName ) enumName##_MIN
165 #define IBASE_MAXENUM( enumName ) enumName##_MAX
166 #define IBASE_NUMENUM( enumName ) ( (int)IBASE_MAXENUM( enumName ) - (int)IBASE_MINENUM( enumName ) + 1 )
167 #define IBASE_INCENUM( enumName, I ) ( ( I ) = ( enum( enumName ) )( (int)( I ) + 1 ) )
168 /** @} */
169 
170 #ifdef __cplusplus
171 extern "C" {
172 #endif
173 
174 typedef void* iBase_Instance;
175 typedef struct iBase_EntityHandle_Private* iBase_EntityHandle;
176 typedef struct iBase_EntitySetHandle_Private* iBase_EntitySetHandle;
177 typedef struct iBase_TagHandle_Private* iBase_TagHandle;
178 typedef struct iBase_EntityIterator_Private* iBase_EntityIterator;
180 
182 {
184  /**< facilitates iteration over all values */
186  /**< A topological dimension 0 entity */
187  iBase_EDGE,
188  /**< A topological dimension 1 entity */
189  iBase_FACE,
190  /**< A topological dimension 2 entity */
191  iBase_REGION,
192  /**< A topological dimension 3 entity */
194  /**< used only in queries to request information about all types */
196  /**< facilitates iteration over all values */
197 };
198 
200 {
202  /**< facilitates iteration over all values */
204  /**< Adjacency information not supported */
206  /**< No more than local mesh traversal required (i!=j) */
208  /**< Global tree search (i!=j) */
210  /**< Global exhaustive search (i!=j) */
212  /**< Only some adjacency info, local (i!=j) */
214  /**< Only some adjacency info, tree (i!=j) */
216  /**< Only some adjacency info, exhaustive (i!=j) */
218  /**< ALL (intermediate) entities available. (i==j) */
220  /**< facilitates iteration over all values */
221 };
222 
224 {
226  /**< facilitates iteration over all values */
228  /**< The entity was newly created */
230  /**< The entity already existed and the handle for that
231  already existing handle was returned */
233  /**< The entity already existed but a new, duplicate entity was
234  nevertheless created */
236  /**< Creation of the entity did not succeed */
238  /**< facilitates iteration over all values */
239 };
240 
242 {
244  /**< facilitates iteration over all values */
269  /**< facilitates iteration over all values */
270 };
271 
272 /***************************************************************************/ /**
273  * \details
274  * Many of the
275  *functions in iMesh
276  *can return arrays of
277  *tuples; that is,
278  *arrays of
279  *multi-valued type.
280  *For example, the
281  *function
282  *iMesh_getVtxArrCoords,
283  * returns an array of
284  *xyz coordinate
285  *3-tuples (or,
286  *perhaps for
287  *geometrically 2D
288  *meshes, xy
289  *2-tuples). In these
290  *situations, there
291  *are multiple ways
292  *the data can be
293  *organized in memory.
294  *For example, it
295  *could be stored
296  *xyz,xyz,xyz or
297  *xxx...,yyy...,zzz....
298  *These two different
299  *storage orders are
300  *referred to as
301  *INTERLEAVED and
302  *BLOCKED,
303  *respectively. For
304  *some functions in
305  *iMesh, the storage
306  *order is explicitly
307  *specified as an
308  *argument to the
309  *function. For other
310  *functions, the
311  *storage order is not
312  *explicitly
313  *specified. And, in
314  *these cases, it
315  *shall always be
316  *implicitly assumed
317  *to be INTERLEAVED.
318  * This fact will be
319  *mentioned in the
320  *documentation for
321  *each specific
322  *function where it
323  *applies. For
324  *example, in case of
325  *iMesh_getEntArrAdj,
326  *the returned array
327  *of adjacent entities
328  *is multi-valued in
329  *that it stores for
330  *each entity queried,
331  *all its adjacent
332  *entities. Such an
333  *array will be stored
334  * INTERLEAVED with
335  *all adjacent
336  *entities for the
337  *first entity in the
338  *query followed by
339  *all adjacent
340  *entities for the
341  *second entity in the
342  *query and so forth.
343  ******************************************************************************/
345 {
347  /**< facilitates iteration over all values */
349  /**< xxx...yyy...zzz... */
351  /**< xyzxyzxyz... */
353  /**< facilitates iteration over all values */
354 };
355 
357 {
359  /**< facilitates iteration over all values */
361  /**< An opaque sequence of bytes, size always measured in bytes */
363  /**< A value of type \c int */
364  iBase_DOUBLE,
365  /**< A value of type \c double */
367  /**< A value of type \c iBase_EntityHandle */
369  /**< A value of type \c iBase_EntitySetHandle */
371  /**< facilitates iteration over all values */
372 };
373 
374 /***************************************************************************/ /**
375  * \page ibase iBase:
376  *ITAPS Base Interface
377  ******************************************************************************/
378 
379 /***************************************************************************/ /**
380  * \defgroup iBase
381  *iBase
382  ******************************************************************************/
383 
384 /***************************************************************************/ /**
385  * \defgroup
386  *VersionNumbers
387  *Version Numbers
388  * \ingroup iBase
389  ******************************************************************************/
390 
391 /***************************************************************************/ /**
392  * \defgroup
393  *ErrorHandling Error
394  *Handling \ingroup
395  *iBase
396  ******************************************************************************/
397 
398 /***************************************************************************/ /**
399  * \defgroup Datatypes
400  *Datatypes \ingroup
401  *iBase
402  ******************************************************************************/
403 
404 /***************************************************************************/ /**
405  * \page The ITAPS Interfaces
406  *
407  * \subpage ibase
408  *
409  * \subpage imesh
410  *
411  * \subpage imeshp
412  *
413  * \subpage error
414  *
415  * \subpage trio
416  *
417  * \subpage strlen
418  *
419  * \subpage options
420  *
421  * \subpage numhops
422  *
423  * \subpage resilient
424  *
425  * \page error Error Handling
426  *
427  * With few exceptions, every iMesh function includes an output argument,
428  * 'int *err', which returns an error code indicating if the function call
429  * may have failed. If the value returned for the 'err' argument is NOT
430  * iBase_SUCCESS, the caller should NOT attempt to interpret (read the
431  * values in) any of the other return arguments of the call. While some
432  * implementations may actually return valid/useful results in other
433  * return arguments of a call that has failed, there is no guarentee that
434  * ALL implementations will do similarly and so depending on such behavior
435  * is neither portable nor safe. This is true even if the returned values
436  * are different from the values of the arguments before the call was
437  * made.
438  *
439  * \page trio Array pointer, allocated and occupied sizes argument trio
440  *
441  * Many of the functions in iMesh have arguments corresponding to lists of
442  * objects. In-type arguments for lists consist of a pointer to an array and
443  * a list size. Lists returned from functions are passed in three arguments,
444  * a pointer to the array representing the list, and pointers to the
445  * allocated and occupied lengths of the array. These three arguments are
446  * inout-type arguments, because they can be allocated by the application and
447  * passed into the interface to hold the results of the function. Lists
448  * which are pre-allocated must be large enough to hold the results of the
449  * function; if this is not the case, an error is generated. Otherwise, the
450  * occupied size is changed to the size output from the function. If a list
451  * argument is unallocated (the list pointer points to a NULL value) or if
452  * the incoming value of the allocated size is zero, the list storage will be
453  * allocated by the implementation.
454  *
455  * IN ALL CASES, MEMORY ALLOCATED BY ITAPS INTERFACE IMPLEMENTATIONS IS DONE
456  * USING THE C MALLOC FUNCTION, AND MUST BE DE-ALLOCATED USING THE C FREE
457  * FUNCTION.
458  *
459  * \page strlen String Length Arguments
460  *
461  * Many of the functions in iMesh involve passing a string and also the length
462  * of that string. How is the null character is handled?
463  * For users of the iMesh interface calling iMesh functions, it is optional
464  * as to whether or not to include the null character in computing the length
465  * of the string. So, for example, calling iMesh from a C program, users could
466  * pass strlen(my_string) or strlen(my_string)+1 as the length of the string.
467  *
468  * <em>Note to implementors</em>: However, it should be noted that the situation
469  * is different for implementers of the iMesh interface. In implementing an
470  * iMesh interface function, there can be no assumption that the string is
471  * indeed null terminated. The length argument the caller passes in may or may
472  * NOT include the null character and implementations must be coded to
473  * accommodate this. This requirement is primarily due to differences in how
474  * Fortran and C/C++ handle passing of strings as function arguments.
475  * Furthermore, because of the way Fortran clients pass strings (Fortran always
476  * passes the length of the string as declared in the source code), there
477  * may be trailing spaces in the string that need to be truncated.
478  *
479  * \page numhops Indirection in Set-Inclusion and Parent-Child structures
480  *
481  * Various functions to query entities, entity sets and parent or child sets
482  * as well as the numbers of these involve a num_hops argument. If the set
483  * upon which the query is originated is the root set, the num_hops argument
484  * is irrelevant and is ignored by the implementation. Otherwise, the num_hops
485  * argument represents the maximum number of levels of indirection employed in
486  * satisfying the query not including the originating set. For example, using
487  * value for num_hops of 0 (zero) in iMesh_getEntSets will return all the
488  * entity sets that are immediately contained in a given set. Likewise, a
489  * value for num_hops of 1 (one) will return all entity sets that are
490  * immediately contained in the given set plus all entity sets that
491  * are contained in those immediately contained sets (e.g. one level of
492  * indirection). Using a value of -1 for num_hops will return results for
493  * all possible levels of indirection. In other words, using a value of
494  * -1 for num_hops is equivalent to setting the maximum number of levels
495  * of indirection to infinity.
496  *
497  * \page options Option Strings
498  *
499  * A few of the functions in iMesh support arbitrary options passed as a
500  * character string, called an 'Option String'. The format of and handling
501  * of an Option String is as follows...
502  *
503  * 1. Option Strings are INsensitive to case.
504  *
505  * 2. Each option in an Option String is pre-pended with the implementation
506  * name followed by a special character called the separator character.
507  *
508  * 3. The separator is a colon, ':'.
509  *
510  * 4. Multiple options existing in a single Option String are separated by a
511  * special character called the delimiter character.
512  *
513  * 5. The delimiter character is a space, ' '.
514  *
515  * 6. The effect of multiple options in a single Option String is
516  * INsensitive to order of occurrence in the string.
517  *
518  * 7. By default, implementations silently ignore any options that
519  * do not match on the implementation name part (everything before
520  * the separator character). This way, a caller may included options
521  * in a single string intended for multiple different implementations.
522  *
523  * 8. Implementations may (or may not) warn or error for option strings
524  * that match on implementation name part but are found to be in error
525  * for other reasons the implementation decides.
526  *
527  * 9. Whenever either the separator character, ':', or delimiter character,
528  * ' ', need to appear in an option, they must be escaped with the
529  * backslash character, '\'.
530  *
531  * For example, consider the Options String
532  *
533  * "grummp:silant FMDB:TwoPhaseIO moab:mpiio_hints\ foo\:bar"
534  *
535  * In the above example, the space serves as the delimiter character
536  * between multiple options in the string. The colon serves as the
537  * implementation-name/option separator character. Because options are
538  * required to be insensitive to case, the caller is free to use case as a
539  * word separator as in 'TwoPhaseIO' and even in the implementation name,
540  * as in 'FMDB:', although 'fmdb:twophaseio' and 'fmdb:TWOPHASEIO' would
541  * all have the same effect. In the moab option, both the separator
542  * character and delimiter character appear in the option and so are
543  * pre-pended (e.g. escaped) with the backslash character.
544 
545  * GRUMMP will silently ignore the FMDB: and moab: options because they do
546  * NOT match on the implementation name part. However, GRUMMP may
547  * optionally error out, or warn or silently ignore 'grummp:silant' (it was
548  * supposed to be spelled 'silent') as an invalid option.
549  *
550  * Note that iMesh itself currently does not define any options. In order
551  * to discover options a given implementation defines, users are directed
552  * to the developers of the respective implementations.
553  *
554  * \page resilient Resilient and Non-Resilient Iterators
555  *
556  * A resilient iterator is one that can deal with modifications to the container
557  * it is iterating over.
558  *
559  * A common concern about an iterator is how it behaves when the container
560  * over which it is iterating is modified. For example, in STL, iterators
561  * for std::set<> and std::map<> and std::list<> containers are guaranteed
562  * to <em>work</em> in the presence of modifications to the associated
563  * containers with one exception; they don't handle the case when the
564  * container member the iterator is currently pointed at is deleted. However,
565  * iterators for std::vector<> are not guaranteed to work under any kinds of
566  * modification.
567  *
568  * In the ITAPS interfaces, a <em>resilient</em> iterator is one that makes
569  * certain guarantees (described below) about how it behaves when the
570  * container being iterated is modified. On the other hand, a
571  * <em>non-resilient</em> is one that does not make such guarantees.
572  *
573  * In all cases, the <em>container</em> associated with an iterator in the
574  * ITAPS interfaces is an entity set of some sort. This is the only container
575  * type for which iterators are defined.
576  *
577  * Here, we characterize the behavior of iterators in the presence of
578  * container modifications. There are a number of (subtle) aspects to
579  * keep in mind.
580  *
581  * 1. There are set-type (<em>duplicate preventing</em>) sets and list-type
582  * (<em>order preserving</em>) sets and iterators behave differently for each.
583  *
584  * 2. Sets can have <em>set</em> members and <em>entity</em> members. However,
585  * iterators are currently defined to iterate over <em>only</em> the entity
586  * members. That said, the question arises as to whether modifications that
587  * involve only set members nonetheless <em>effect</em> iterator behavior.
588  *
589  * 3. There are array-type iterators that upon each step in the iteration
590  * return a whole array of entity member handles and single entity iterators
591  * that upon each step return just a single entity member handle.
592  *
593  * 4. The iterators support type/topology <em>filtering</em>. Iterators do not
594  * (always) strictly iterate over <em>all</em> entities in a set; just
595  * <em>all</em> entities matching the type/topology criteria. When
596  * type/topology specifies either all types or all topologies, then indeed
597  * the iterator will iterate over all entities.
598  *
599  * 5. There are add/remove operations that add/remove <em>entity members</em> or
600  * <em>set members</em> to a set.
601  *
602  * 6. There are create/delete operations that create and delete
603  * <em>entities</em> from the whole iMesh_Instance.
604  *
605  * 7. There are create/destroy operations that create and destroy
606  * <em>sets</em> from the whole interface instance.
607  *
608  * 8. There is the <em>root set</em> which is special and may have different
609  * iterator behavior than all other sets. By definition, the root set is a set-type
610  * (<em>duplicate prevent</em>) set.
611  *
612  * Modification means addition/removal and/or create/destroy and/or create/delete
613  * <em>after</em> iterator initialization. When we talk about
614  * <em>container modification</em> here, we are talking about any of the
615  * following operations.
616  *
617  * A. addition and removal of entity members
618  * \code
619  * void iMesh_rmvEntFromSet(iMesh_Instance instance,
620  * void iMesh_rmvEntArrFromSet(iMesh_Instance instance,
621  * void iMesh_addEntToSet(iMesh_Instance instance,
622  * void iMesh_addEntArrToSet(iMesh_Instance instance,
623  * \endcode
624  * B. addition and removal of set members
625  * \code
626  * void iMesh_rmvEntSet(iMesh_Instance instance,
627  * void iMesh_addEntSet(iMesh_Instance instance,
628  * \endcode
629  * C. deletion of entities from whole iMesh_Instance
630  * \code
631  * void iMesh_deleteEntArr(iMesh_Instance instance,
632  * void iMesh_deleteEnt(iMesh_Instance instance,
633  * \endcode
634  * D. creation of entities (effects root set)
635  * \code
636  * void iMesh_createEntSet(iMesh_Instance instance,
637  * void iMesh_createVtxArr(iMesh_Instance instance,
638  * void iMesh_createEntArr(iMesh_Instance instance,
639  * void iMesh_createVtx(iMesh_Instance instance,
640  * void iMesh_createEnt(iMesh_Instance instance,
641  * \endcode
642  * E. destruction of entity sets
643  * \code
644  * void iMesh_destroyEntSet(iMesh_Instance instance,
645  * \endcode
646 
647  * By container modification, we mean that of the above operations occur on
648  * the container between iterator initialization and reset.
649  *
650  * For purposes of this discussion, there is no distinction between any of
651  * these <em>kinds of</em> modifications. What is true for any is true for
652  * all. Below, the words <em>add</em> and <em>remove</em> are used to
653  * represent any of the modifications that add members or remove members
654  * regardless of the <em>kind of operation</em> above.
655  *
656  * Resilient iterators are not effected by modifications involving set members:
657  *
658  * Iterators are currently defined to iterate over *only* the entity members
659  * of a container. In particular, if the container is modified by
660  * adding/removing sets from the container, this will have no impact on
661  * the iterator. This is true for set-type sets and list-type sets.
662  *
663  * Resilient iterator's <em>current position</em> not effected by modification:
664  *
665  * If the container is modified, the iterator will continue to properly
666  * <em>keep track of</em> the member it was currently pointing at. If a
667  * modification occurs that removes the member it was currently pointing at,
668  * the iterator will be advanced to the <em>next</em> (not already deleted)
669  * member it would have proceeded to. In this way, the iterator is guaranteed
670  * to always point at a valid member or to the end of the set, in the case
671  * that the member being removed is the last one.
672  *
673  * A resilient iterator must skip over removed members:
674  *
675  * If the container is modified by removing members, the iterator will guarantee
676  * not to <em>land on</em> (e.g. return) those members as iteration proceeds.
677  * This is true of set-type sets and list-type sets.
678  *
679  * A resilient iterator on set-type sets <em>may</em> fail to return added members:
680  *
681  * If the container is a set-type (<em>duplicate preventing</em>) container and
682  * it is modified by adding members, the iterator <em>may</em> skip over (e.g.
683  * fail to return) members that have been added. In other words, there is no
684  * guarantee in this circumstance that an iterator will return added members.
685  *
686  * A resilient iterator on list-type sets <em>must</em> return added members.
687  * If it is a list-type (<em>order preserving</em>) container, then the iterator
688  * <em>must</em> guarantee to return the added members.
689  *
690  * A non-resilient iterator may or may not behave like a resilient iterator in
691  * some or all of the circumstances described above. There are no guarantees
692  * about how a non-resilient iterator will behave. The behavior of a non-resilient
693  * iterator in the presence of container modifications is left entirely up
694  * to the implementation.
695  *
696  * If upon initializing an iterator, an application requests it be resilient and
697  * the implementation is unable to support that, the iterator initialization
698  * request shall fail and return error iBase_NOT_SUPPORTED.
699  ******************************************************************************/
700 
701 #ifdef __cplusplus
702 }
703 #endif
704 
705 #endif /* #ifndef _ITAPS_iBase */