MOAB: Mesh Oriented datABase  (version 5.4.0)
MBEntityType.h
Go to the documentation of this file.
00001 /**
00002  * MOAB, a Mesh-Oriented datABase, is a software component for creating,
00003  * storing and accessing finite element mesh data.
00004  * 
00005  * Copyright 2004 Sandia Corporation.  Under the terms of Contract
00006  * DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government
00007  * retains certain rights in this software.
00008  * 
00009  * This library is free software; you can redistribute it and/or
00010  * modify it under the terms of the GNU Lesser General Public
00011  * License as published by the Free Software Foundation; either
00012  * version 2.1 of the License, or (at your option) any later version.
00013  * 
00014  */
00015 
00016 #ifndef MB_ENTITY_TYPE_H
00017 #define MB_ENTITY_TYPE_H
00018 
00019 /* This file can be used to define several different things.
00020  *
00021  * A) If included in C code (not C++), it defines:
00022  *    1) An enum named MBEntityType, guarded by the MB_ENTITY_TYPE_H
00023  *        include guards and 
00024  *    2) a typedef MBEntityType guarded by MOAB_ENTITY_TYPE_C include guards.
00025  *
00026  * B) If included in C++ code, it defines:
00027  *    1) An enum named EntiyType in the MOAB namespace, guarded
00028  *       by the MB_ENTITY_TYPE include guards
00029  *    2) Increment and decrement oeprators for the moab::EntityType enum,
00030  *       also guarded by the MB_ENTITY_TYPE include guards
00031  *    3) A typedef for moab::EntityType in the global namespace 
00032  *        named MBEntityType, guarded by the MOAB_ENTITY_TYPE_NS_ONLY
00033  *        include guards
00034  *
00035  * The C and C++ code should be entirely independent.  They are defined
00036  * in the same file only to avoid code duplication and inconsistent enum
00037  * values.  OTOH, the C++ definitions must be in the same file because
00038  * the compiler must treat both the namespaced and non-namespaced names
00039  * as the same type.
00040  *
00041  * The C++ code must be able to provide:
00042  *  a) An enum in the moab namespace
00043  *  b) An enum in the global namespace that is the *same type*
00044  *      as a) as far as the compiler is concerned.
00045  *  c) Nothing in the global namespace unless requested
00046  *  d) No breakage if both namespaced and non-namespaced headers
00047  *      are both included.
00048  * 
00049  * This is acheived with the somewhat complicated set of multiple
00050  * included guards described above, where moab/EntityType.hpp will
00051  * include this file with MOAB_ENTITY_TYPE_NS_OLNY temporarily defined
00052  * so as to pull in only the namespaced version at that time, without
00053  * prohibiting the non-namespaced version from being pulled in previously
00054  * or later.
00055  */
00056 #ifdef __cplusplus
00057 namespace moab
00058 {
00059 #define MOAB_ENTITY_TYPE_NAME EntityType
00060 #else /* __cplusplus */
00061 #define MOAB_ENTITY_TYPE_NAME MBEntityType
00062 #endif /* __cplusplus */
00063 
00064 /*! Entity types defined in MOAB and MBCN
00065  *  The ordering here must ensure that all element types are 
00066  *  grouped together and all elements of similar dimension are
00067  *  grouped together.
00068  */
00069 enum MOAB_ENTITY_TYPE_NAME
00070 {
00071     MBVERTEX = 0, /**< Mesh Vertex AKA node */
00072     MBEDGE,       /**< Mesh Edge */
00073     MBTRI,        /**< Triangular element (including shells) */
00074     MBQUAD,       /**< Quadrilateral element (including shells) */
00075     MBPOLYGON,    /**< Polygon */
00076     MBTET,        /**< Tetrahedral element */
00077     MBPYRAMID,    /**< Pyramid element (where are the face ids for this defined?) */
00078     MBPRISM,      /**< Wedge element (Exodus has one, Cubit doesn't. Does Mesh need it?) */
00079     MBKNIFE,      /**< Knife element */
00080     MBHEX,        /**< Hexahedral element */
00081     MBPOLYHEDRON, /**< Polyhedron */
00082     MBENTITYSET,  /**< MeshSet */
00083     MBMAXTYPE     /**< Just a place keeper - must be the # of entities, for array */
00084     /**< dimensioning purposes  */
00085 };
00086 
00087 #ifdef __cplusplus
00088 /** prefix increment operator for MBEntityType */
00089 inline MOAB_ENTITY_TYPE_NAME& operator++( MOAB_ENTITY_TYPE_NAME& type )
00090 {
00091     return type = static_cast< MOAB_ENTITY_TYPE_NAME >( type + 1 );
00092 }
00093 
00094 /** postfix increment operator for MBEntityType */
00095 inline MOAB_ENTITY_TYPE_NAME operator++( MOAB_ENTITY_TYPE_NAME& type, int )
00096 {
00097     MOAB_ENTITY_TYPE_NAME oldval = type;
00098     ++type;
00099     return oldval;
00100 }
00101 
00102 /** prefix increment operator for MBEntityType */
00103 inline MOAB_ENTITY_TYPE_NAME& operator--( MOAB_ENTITY_TYPE_NAME& type )
00104 {
00105     return type = static_cast< MOAB_ENTITY_TYPE_NAME >( type - 1 );
00106 }
00107 
00108 /** postfix increment operator for MBEntityType */
00109 inline MOAB_ENTITY_TYPE_NAME operator--( MOAB_ENTITY_TYPE_NAME& type, int )
00110 {
00111     MOAB_ENTITY_TYPE_NAME oldval = type;
00112     --type;
00113     return oldval;
00114 }
00115 
00116 } /* namespace moab*/
00117 #endif /* __cplusplus */
00118 
00119 #undef MOAB_ENTITY_TYPE_NAME
00120 #endif /* MB_ENTITY_TYPE_H */
00121 
00122 #ifdef __cplusplus
00123 #ifndef MOAB_ENTITY_TYPE_NS_ONLY
00124 #define MOAB_ENTITY_TYPE_NS_ONLY
00125 typedef moab::EntityType MBEntityType;
00126 using moab::MBEDGE;
00127 using moab::MBENTITYSET;
00128 using moab::MBHEX;
00129 using moab::MBKNIFE;
00130 using moab::MBMAXTYPE;
00131 using moab::MBPOLYGON;
00132 using moab::MBPOLYHEDRON;
00133 using moab::MBPRISM;
00134 using moab::MBPYRAMID;
00135 using moab::MBQUAD;
00136 using moab::MBTET;
00137 using moab::MBTRI;
00138 using moab::MBVERTEX;
00139 #endif /* MOAB_ENTITY_TYPE_NS_ONLY */
00140 #else  /* __cplusplus */
00141 #ifndef MOAB_ENTITY_TYPE_C
00142 #define MOAB_ENTITY_TYPE_C
00143 typedef enum MBEntityType MBEntityType;
00144 #endif /* MOAB_ENTITY_TYPE_C */
00145 #endif /* __cplusplus */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines