MOAB: Mesh Oriented datABase  (version 5.2.1)
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 # define MOAB_ENTITY_TYPE_NAME EntityType
00059 # else /* __cplusplus */
00060 # define MOAB_ENTITY_TYPE_NAME MBEntityType
00061 #endif /* __cplusplus */
00062 
00063 /*! Entity types defined in MOAB and MBCN
00064  *  The ordering here must ensure that all element types are 
00065  *  grouped together and all elements of similar dimension are
00066  *  grouped together.
00067  */
00068 enum MOAB_ENTITY_TYPE_NAME
00069 {
00070   MBVERTEX = 0, /**< Mesh Vertex AKA node */
00071   MBEDGE,       /**< Mesh Edge */
00072   MBTRI,        /**< Triangular element (including shells) */
00073   MBQUAD,       /**< Quadrilateral element (including shells) */
00074   MBPOLYGON,    /**< Polygon */
00075   MBTET,        /**< Tetrahedral element */
00076   MBPYRAMID,    /**< Pyramid element (where are the face ids for this defined?) */
00077   MBPRISM,      /**< Wedge element (Exodus has one, Cubit doesn't. Does Mesh need it?) */
00078   MBKNIFE,      /**< Knife element */
00079   MBHEX,        /**< Hexahedral element */
00080   MBPOLYHEDRON, /**< Polyhedron */
00081   MBENTITYSET,    /**< MeshSet */
00082   MBMAXTYPE  /**< Just a place keeper - must be the # of entities, for array */
00083     /**< dimensioning purposes  */
00084 };
00085 
00086 #ifdef __cplusplus
00087 /** prefix increment operator for MBEntityType */
00088 inline MOAB_ENTITY_TYPE_NAME & operator++(MOAB_ENTITY_TYPE_NAME &type)
00089 {
00090   return type = static_cast<MOAB_ENTITY_TYPE_NAME>(type+1);
00091 }
00092 
00093 /** postfix increment operator for MBEntityType */
00094 inline MOAB_ENTITY_TYPE_NAME operator++(MOAB_ENTITY_TYPE_NAME &type, int)
00095 {
00096   MOAB_ENTITY_TYPE_NAME oldval = type;
00097   ++type;
00098   return oldval;
00099 }
00100 
00101 /** prefix increment operator for MBEntityType */
00102 inline MOAB_ENTITY_TYPE_NAME & operator--(MOAB_ENTITY_TYPE_NAME &type)
00103 {
00104   return type = static_cast<MOAB_ENTITY_TYPE_NAME>(type-1);
00105 }
00106 
00107 /** postfix increment operator for MBEntityType */
00108 inline MOAB_ENTITY_TYPE_NAME operator--(MOAB_ENTITY_TYPE_NAME &type, int)
00109 {
00110   MOAB_ENTITY_TYPE_NAME oldval = type;
00111   --type;
00112   return oldval;
00113 }
00114 
00115 } /* namespace moab*/
00116 #endif /* __cplusplus */
00117 
00118 #undef MOAB_ENTITY_TYPE_NAME
00119 #endif /* MB_ENTITY_TYPE_H */
00120 
00121 #ifdef __cplusplus
00122 #  ifndef MOAB_ENTITY_TYPE_NS_ONLY
00123 #    define MOAB_ENTITY_TYPE_NS_ONLY
00124      typedef moab::EntityType MBEntityType;
00125      using moab::MBVERTEX;
00126      using moab::MBEDGE;
00127      using moab::MBTRI;
00128      using moab::MBQUAD;
00129      using moab::MBPOLYGON;
00130      using moab::MBTET;
00131      using moab::MBPYRAMID;
00132      using moab::MBPRISM;
00133      using moab::MBKNIFE;
00134      using moab::MBHEX;
00135      using moab::MBPOLYHEDRON;
00136      using moab::MBENTITYSET;
00137      using moab::MBMAXTYPE;
00138 #  endif /* MOAB_ENTITY_TYPE_NS_ONLY */
00139 #else /* __cplusplus */
00140 #  ifndef MOAB_ENTITY_TYPE_C
00141 #    define MOAB_ENTITY_TYPE_C
00142      typedef enum MBEntityType MBEntityType;
00143 #  endif /* MOAB_ENTITY_TYPE_C */
00144 #endif /* __cplusplus */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines