XdmfDomain.cpp 5.85 KB
Newer Older
Kenneth Leiter's avatar
Kenneth Leiter committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
/*****************************************************************************/
/*                                    XDMF                                   */
/*                       eXtensible Data Model and Format                    */
/*                                                                           */
/*  Id : XdmfDomain.cpp                                                      */
/*                                                                           */
/*  Author:                                                                  */
/*     Kenneth Leiter                                                        */
/*     kenneth.leiter@arl.army.mil                                           */
/*     US Army Research Laboratory                                           */
/*     Aberdeen Proving Ground, MD                                           */
/*                                                                           */
/*     Copyright @ 2011 US Army Research Laboratory                          */
/*     All Rights Reserved                                                   */
/*     See Copyright.txt for details                                         */
/*                                                                           */
/*     This software is distributed WITHOUT ANY WARRANTY; without            */
/*     even the implied warranty of MERCHANTABILITY or FITNESS               */
/*     FOR A PARTICULAR PURPOSE.  See the above copyright notice             */
/*     for more information.                                                 */
/*                                                                           */
/*****************************************************************************/
Kenneth Leiter's avatar
Kenneth Leiter committed
23 24

#include "XdmfDomain.hpp"
25
#include "XdmfCurvilinearGrid.hpp"
26
#include "XdmfGraph.hpp"
27
#include "XdmfGridCollection.hpp"
28 29 30
#include "XdmfRectilinearGrid.hpp"
#include "XdmfRegularGrid.hpp"
#include "XdmfUnstructuredGrid.hpp"
Kenneth Leiter's avatar
Kenneth Leiter committed
31

32 33 34 35 36 37 38 39
XDMF_CHILDREN_IMPLEMENTATION(XdmfDomain,
                             XdmfGridCollection,
                             GridCollection,
                             Name)
XDMF_CHILDREN_IMPLEMENTATION(XdmfDomain,
                             XdmfCurvilinearGrid,
                             CurvilinearGrid,
                             Name)
40 41 42 43
XDMF_CHILDREN_IMPLEMENTATION(XdmfDomain,
                             XdmfGraph,
                             Graph,
                             Name)
44 45 46 47 48 49 50 51 52 53 54 55
XDMF_CHILDREN_IMPLEMENTATION(XdmfDomain,
                             XdmfRectilinearGrid,
                             RectilinearGrid,
                             Name)
XDMF_CHILDREN_IMPLEMENTATION(XdmfDomain,
                             XdmfRegularGrid,
                             RegularGrid,
                             Name)
XDMF_CHILDREN_IMPLEMENTATION(XdmfDomain,
                             XdmfUnstructuredGrid,
                             UnstructuredGrid,
                             Name)
56

57
shared_ptr<XdmfDomain>
58
XdmfDomain::New()
59
{
60
  shared_ptr<XdmfDomain> p(new XdmfDomain());
61
  return p;
62 63
}

Kenneth Leiter's avatar
Kenneth Leiter committed
64 65 66 67 68 69 70 71
XdmfDomain::XdmfDomain()
{
}

XdmfDomain::~XdmfDomain()
{
}

72
const std::string XdmfDomain::ItemTag = "Domain";
73

74 75
std::map<std::string, std::string>
XdmfDomain::getItemProperties() const
76
{
77 78
  std::map<std::string, std::string> domainProperties;
  return domainProperties;
79 80
}

81 82
std::string
XdmfDomain::getItemTag() const
83
{
84
  return ItemTag;
85 86
}

87 88
void
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 95 96
        childItems.begin();
      iter != childItems.end();
      ++iter) {
97 98
    if(shared_ptr<XdmfGridCollection> gridCollection =
       shared_dynamic_cast<XdmfGridCollection>(*iter)) {
99 100
      this->insert(gridCollection);
    }
101 102
    else if(shared_ptr<XdmfCurvilinearGrid> grid =
            shared_dynamic_cast<XdmfCurvilinearGrid>(*iter)) {
103 104
      this->insert(grid);
    }
105 106 107 108
    else if(shared_ptr<XdmfGraph> graph =
            shared_dynamic_cast<XdmfGraph>(*iter)) {
      this->insert(graph);
    }
109 110
    else if(shared_ptr<XdmfRectilinearGrid> grid =
            shared_dynamic_cast<XdmfRectilinearGrid>(*iter)) {
111 112
      this->insert(grid);
    }
113 114
    else if(shared_ptr<XdmfRegularGrid> grid =
            shared_dynamic_cast<XdmfRegularGrid>(*iter)) {
115 116
      this->insert(grid);
    }
117 118
    else if(shared_ptr<XdmfUnstructuredGrid> grid =
            shared_dynamic_cast<XdmfUnstructuredGrid>(*iter)) {
119 120 121
      this->insert(grid);
    }
  }
122 123
}

124
void
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 131 132 133
      iter != mGridCollections.end();
      ++iter) {
    (*iter)->accept(visitor);
  }
134
  for(std::vector<shared_ptr<XdmfCurvilinearGrid> >::const_iterator iter =
135
        mCurvilinearGrids.begin();
136 137 138 139
      iter != mCurvilinearGrids.end();
      ++iter) {
    (*iter)->accept(visitor);
  }
140 141 142 143 144 145 146
  for(std::vector<shared_ptr<XdmfGraph> >::const_iterator iter =
        mGraphs.begin();
      iter != mGraphs.end();
      ++iter) {
    (*iter)->accept(visitor);
  }
  for(std::vector<shared_ptr<XdmfRectilinearGrid> >::const_iterator iter =
147
        mRectilinearGrids.begin();
148 149 150 151
      iter != mRectilinearGrids.end();
      ++iter) {
    (*iter)->accept(visitor);
  }
152
  for(std::vector<shared_ptr<XdmfRegularGrid> >::const_iterator iter =
153
        mRegularGrids.begin();
154 155 156 157
      iter != mRegularGrids.end();
      ++iter) {
    (*iter)->accept(visitor);
  }
158
  for(std::vector<shared_ptr<XdmfUnstructuredGrid> >::const_iterator iter =
159
        mUnstructuredGrids.begin();
160 161 162 163
      iter != mUnstructuredGrids.end();
      ++iter) {
    (*iter)->accept(visitor);
  }
164
}