1 /*****************************************************************************/
2 /*                                    XDMF                                   */
3 /*                       eXtensible Data Model and Format                    */
4 /*                                                                           */
5 /*  Id : XdmfGeometryType.hpp                                                */
6 /*                                                                           */
7 /*  Author:                                                                  */
8 /*     Kenneth Leiter                                                        */
9 /*     kenneth.leiter@arl.army.mil                                           */
10 /*     US Army Research Laboratory                                           */
11 /*     Aberdeen Proving Ground, MD                                           */
12 /*                                                                           */
13 /*     Copyright @ 2011 US Army Research Laboratory                          */
14 /*     All Rights Reserved                                                   */
15 /*     See Copyright.txt for details                                         */
16 /*                                                                           */
17 /*     This software is distributed WITHOUT ANY WARRANTY; without            */
18 /*     even the implied warranty of MERCHANTABILITY or FITNESS               */
19 /*     FOR A PARTICULAR PURPOSE.  See the above copyright notice             */
20 /*     for more information.                                                 */
21 /*                                                                           */
22 /*****************************************************************************/
23 
24 #ifndef XDMFGEOMETRYTYPE_HPP_
25 #define XDMFGEOMETRYTYPE_HPP_
26 
27 // C Compatible Includes
28 #include "Xdmf.hpp"
29 
30 #ifdef __cplusplus
31 
32 // Includes
33 #include "XdmfItemProperty.hpp"
34 #include <map>
35 
36 /**
37  * @brief Property describing the types of coordinate values stored in
38  * an XdmfGeometry.
39  *
40  * XdmfGeometryType is a property used by XdmfGeometry to specify the
41  * type of coordinate values stored in the XdmfGeometry. A specific
42  * XdmfGeometryType can be created by calling one of the static
43  * methods in the class, i.e.  XdmfAttributeType::XYZ().
44  *
45  * Example of use:
46  *
47  * C++
48  *
49  * @dontinclude ExampleXdmfGeometryType.cpp
50  * @skipline //#initialization
51  * @until //#initialization
52  * @skipline //#getType
53  * @until //#getType
54  *
55  * Python
56  *
57  * @dontinclude XdmfExampleGeometryType.py
58  * @skipline #//getType
59  * @until #//getType
60  *
61  * Xdmf supports the following geometry types:
62  *   NoGeometryType
63  *   XYZ
64  *   XY
65  *   Polar
66  *   Spherical
67  *
68  * The Polar and Spherical types consist of a series of coordinates.
69  * These coordinates are in order of: radius, polar, azimuthal.
70  * In accordance with the ISO standard.
71  *
72  */
73 class XDMF_EXPORT XdmfGeometryType : public XdmfItemProperty {
74 
75 public:
76 
77   virtual ~XdmfGeometryType();
78 
79   friend class XdmfGeometry;
80 
81   // Supported Xdmf Geometry Types
82   static shared_ptr<const XdmfGeometryType> NoGeometryType();
83   static shared_ptr<const XdmfGeometryType> XYZ();
84   static shared_ptr<const XdmfGeometryType> XY();
85   static shared_ptr<const XdmfGeometryType> Polar();
86   static shared_ptr<const XdmfGeometryType> Spherical();
87 
88   /**
89    * Get the dimensions of this geometry type - i.e. XYZ = 3.
90    *
91    * Example of use:
92    *
93    * C++
94    *
95    * @dontinclude ExampleXdmfGeometryType.cpp
96    * @skipline //#getDimensions
97    * @until //#getDimensions
98    *
99    * Python
100    *
101    * @dontinclude XdmfExampleGeometryType.py
102    * @skipline #//getDimensions
103    * @until #//getDimensions
104    *
105    * @return    An int containing number of dimensions.
106    */
107   virtual unsigned int getDimensions() const;
108 
109   /**
110    * Get the name of this geometry type.
111    *
112    * Example of use:
113    *
114    * C++
115    *
116    * @dontinclude ExampleXdmfGeometryType.cpp
117    * @skipline //#getName
118    * @until //#getName
119    *
120    * Python
121    *
122    * @dontinclude XdmfExampleGeometryType.py
123    * @skipline #//getName
124    * @until #//getName
125    *
126    * @return    The name of this geometry type.
127    */
128   std::string getName() const;
129 
130   virtual void
131   getProperties(std::map<std::string, std::string> & collectedProperties) const;
132 
133 protected:
134 
135   /**
136    * Protected constructor for XdmfGeometryType.  The constructor is
137    * protected because all geometry types supported by Xdmf should be
138    * accessed through more specific static methods that construct
139    * XdmfGeometryTypes - i.e.  XdmfGeometryType::XYZ().
140    *
141    * @param name a std::string containing the name of the geometry type..
142    * @param dimensions an int containing the dimensions of the geometry type.
143    */
144   XdmfGeometryType(const std::string & name, const int & dimensions);
145 
146   static std::map<std::string, shared_ptr<const XdmfGeometryType>(*)()> mGeometryDefinitions;
147 
148   static void InitTypes();
149 
150 private:
151 
152   XdmfGeometryType(const XdmfGeometryType &); // Not implemented.
153   void operator=(const XdmfGeometryType &); // Not implemented.
154 
155   static shared_ptr<const XdmfGeometryType>
156   New(const std::map<std::string, std::string> & itemProperties);
157 
158   unsigned int mDimensions;
159   std::string mName;
160 };
161 
162 #endif
163 
164 #ifdef __cplusplus
165 extern "C" {
166 #endif
167 
168 // C wrappers go here
169 
170 #define XDMF_GEOMETRY_TYPE_NO_GEOMETRY_TYPE 300
171 #define XDMF_GEOMETRY_TYPE_XYZ              301
172 #define XDMF_GEOMETRY_TYPE_XY               302
173 #define XDMF_GEOMETRY_TYPE_POLAR            303
174 #define XDMF_GEOMETRY_TYPE_SPHERICAL        304
175 
176 XDMF_EXPORT int XdmfGeometryTypeNoGeometryType();
177 XDMF_EXPORT int XdmfGeometryTypeXYZ();
178 XDMF_EXPORT int XdmfGeometryTypeXY();
179 XDMF_EXPORT int XdmfGeometryTypePolar();
180 XDMF_EXPORT int XdmfGeometryTypeSpherical();
181 
182 XDMF_EXPORT unsigned int XdmfGeometryTypeGetDimensions(int type, int * status);
183 
184 XDMF_EXPORT char * XdmfGeometryTypeGetName(int type);
185 
186 #ifdef __cplusplus
187 }
188 #endif
189 
190 #endif /* XDMFGEOMETRYTYPE_HPP_ */
191