XdmfGridCollection.cpp 3.78 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 : XdmfGridCollection.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.                                                 */
/*                                                                           */
/*****************************************************************************/
23

24
#include <utility>
25 26
#include "XdmfGeometry.hpp"
#include "XdmfTopology.hpp"
27
#include "XdmfGridCollection.hpp"
28
#include "XdmfGridCollectionType.hpp"
29

30
shared_ptr<XdmfGridCollection>
31
XdmfGridCollection::New()
32
{
33
  shared_ptr<XdmfGridCollection> p(new XdmfGridCollection());
34
  return p;
35 36
};

37
XdmfGridCollection::XdmfGridCollection() :
38 39 40
  XdmfDomain(),
  XdmfGrid(XdmfGeometry::New(), XdmfTopology::New(), "Collection"),
  mType(XdmfGridCollectionType::NoCollectionType())
41 42 43 44 45 46 47
{
}

XdmfGridCollection::~XdmfGridCollection()
{
}

48
const std::string XdmfGridCollection::ItemTag = "Grid";
49

50 51
std::map<std::string, std::string>
XdmfGridCollection::getItemProperties() const
52
{
53 54
  std::map<std::string, std::string> collectionProperties =
    XdmfGrid::getItemProperties();
55
  collectionProperties.insert(std::make_pair("GridType", "Collection"));
56 57
  mType->getProperties(collectionProperties);
  return collectionProperties;
58 59
}

60 61
std::string
XdmfGridCollection::getItemTag() const
62
{
63
  return ItemTag;
64 65
}

66
shared_ptr<const XdmfGridCollectionType>
67
XdmfGridCollection::getType() const
68
{
69
  return mType;
70 71
}

72
void
73
XdmfGridCollection::insert(const shared_ptr<XdmfInformation> information)
74
{
75
  XdmfItem::insert(information);
76 77
}

78 79
void
XdmfGridCollection::populateItem(const std::map<std::string, std::string> & itemProperties,
80
                                 const std::vector<shared_ptr<XdmfItem> > & childItems,
81
                                 const XdmfCoreReader * const reader)
82
{
83 84 85 86
  mType = XdmfGridCollectionType::New(itemProperties);
  XdmfDomain::populateItem(itemProperties, childItems, reader);
  mInformations.clear();
  XdmfGrid::populateItem(itemProperties, childItems, reader);
87 88
}

89
void
90
XdmfGridCollection::setType(const shared_ptr<const XdmfGridCollectionType> type)
91
{
92
  mType = type;
93 94
}

95
void
96
XdmfGridCollection::traverse(const shared_ptr<XdmfBaseVisitor> visitor)
97
{
98
  XdmfGrid::traverse(visitor);
99

100
  // Only write XdmfInformations once (deal with diamond inheritance)
101
  std::vector<shared_ptr<XdmfInformation> > informations;
102 103 104
  informations.swap(mInformations);
  XdmfDomain::traverse(visitor);
  informations.swap(mInformations);
105
}