1 /*****************************************************************************/
2 /* XDMF */
3 /* eXtensible Data Model and Format */
4 /* */
5 /* Id : XdmfDomain.cpp */
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 #include "XdmfDomain.hpp"
25 #include "XdmfCurvilinearGrid.hpp"
26 #include "XdmfGraph.hpp"
27 #include "XdmfGridCollection.hpp"
28 #include "XdmfRectilinearGrid.hpp"
29 #include "XdmfRegularGrid.hpp"
30 #include "XdmfUnstructuredGrid.hpp"
31
XDMF_CHILDREN_IMPLEMENTATION(XdmfDomain,XdmfGridCollection,GridCollection,Name)32 XDMF_CHILDREN_IMPLEMENTATION(XdmfDomain,
33 XdmfGridCollection,
34 GridCollection,
35 Name)
36 XDMF_CHILDREN_IMPLEMENTATION(XdmfDomain,
37 XdmfCurvilinearGrid,
38 CurvilinearGrid,
39 Name)
40 XDMF_CHILDREN_IMPLEMENTATION(XdmfDomain,
41 XdmfGraph,
42 Graph,
43 Name)
44 XDMF_CHILDREN_IMPLEMENTATION(XdmfDomain,
45 XdmfRectilinearGrid,
46 RectilinearGrid,
47 Name)
48 XDMF_CHILDREN_IMPLEMENTATION(XdmfDomain,
49 XdmfRegularGrid,
50 RegularGrid,
51 Name)
52 XDMF_CHILDREN_IMPLEMENTATION(XdmfDomain,
53 XdmfUnstructuredGrid,
54 UnstructuredGrid,
55 Name)
56
57 shared_ptr<XdmfDomain>
58 XdmfDomain::New()
59 {
60 shared_ptr<XdmfDomain> p(new XdmfDomain());
61 return p;
62 }
63
XdmfDomain()64 XdmfDomain::XdmfDomain()
65 {
66 }
67
~XdmfDomain()68 XdmfDomain::~XdmfDomain()
69 {
70 }
71
72 const std::string XdmfDomain::ItemTag = "Domain";
73
74 std::map<std::string, std::string>
getItemProperties() const75 XdmfDomain::getItemProperties() const
76 {
77 std::map<std::string, std::string> domainProperties;
78 return domainProperties;
79 }
80
81 std::string
getItemTag() const82 XdmfDomain::getItemTag() const
83 {
84 return ItemTag;
85 }
86
87 void
populateItem(const std::map<std::string,std::string> & itemProperties,const std::vector<shared_ptr<XdmfItem>> & childItems,const XdmfCoreReader * const reader)88 XdmfDomain::populateItem(const std::map<std::string, std::string> & itemProperties,
89 const std::vector<shared_ptr<XdmfItem> > & childItems,
90 const XdmfCoreReader * const reader)
91 {
92 XdmfItem::populateItem(itemProperties, childItems, reader);
93 for(std::vector<shared_ptr<XdmfItem> >::const_iterator iter =
94 childItems.begin();
95 iter != childItems.end();
96 ++iter) {
97 if(shared_ptr<XdmfGridCollection> gridCollection =
98 shared_dynamic_cast<XdmfGridCollection>(*iter)) {
99 this->insert(gridCollection);
100 }
101 else if(shared_ptr<XdmfCurvilinearGrid> grid =
102 shared_dynamic_cast<XdmfCurvilinearGrid>(*iter)) {
103 this->insert(grid);
104 }
105 else if(shared_ptr<XdmfGraph> graph =
106 shared_dynamic_cast<XdmfGraph>(*iter)) {
107 this->insert(graph);
108 }
109 else if(shared_ptr<XdmfRectilinearGrid> grid =
110 shared_dynamic_cast<XdmfRectilinearGrid>(*iter)) {
111 this->insert(grid);
112 }
113 else if(shared_ptr<XdmfRegularGrid> grid =
114 shared_dynamic_cast<XdmfRegularGrid>(*iter)) {
115 this->insert(grid);
116 }
117 else if(shared_ptr<XdmfUnstructuredGrid> grid =
118 shared_dynamic_cast<XdmfUnstructuredGrid>(*iter)) {
119 this->insert(grid);
120 }
121 }
122 }
123
124 void
traverse(const shared_ptr<XdmfBaseVisitor> visitor)125 XdmfDomain::traverse(const shared_ptr<XdmfBaseVisitor> visitor)
126 {
127 XdmfItem::traverse(visitor);
128 for(std::vector<shared_ptr<XdmfGridCollection> >::const_iterator iter =
129 mGridCollections.begin();
130 iter != mGridCollections.end();
131 ++iter) {
132 (*iter)->accept(visitor);
133 }
134 for(std::vector<shared_ptr<XdmfCurvilinearGrid> >::const_iterator iter =
135 mCurvilinearGrids.begin();
136 iter != mCurvilinearGrids.end();
137 ++iter) {
138 (*iter)->accept(visitor);
139 }
140 for(std::vector<shared_ptr<XdmfGraph> >::const_iterator iter =
141 mGraphs.begin();
142 iter != mGraphs.end();
143 ++iter) {
144 (*iter)->accept(visitor);
145 }
146 for(std::vector<shared_ptr<XdmfRectilinearGrid> >::const_iterator iter =
147 mRectilinearGrids.begin();
148 iter != mRectilinearGrids.end();
149 ++iter) {
150 (*iter)->accept(visitor);
151 }
152 for(std::vector<shared_ptr<XdmfRegularGrid> >::const_iterator iter =
153 mRegularGrids.begin();
154 iter != mRegularGrids.end();
155 ++iter) {
156 (*iter)->accept(visitor);
157 }
158 for(std::vector<shared_ptr<XdmfUnstructuredGrid> >::const_iterator iter =
159 mUnstructuredGrids.begin();
160 iter != mUnstructuredGrids.end();
161 ++iter) {
162 (*iter)->accept(visitor);
163 }
164 }
165