XdmfGridCollection.cpp 3.7 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 25
#include "XdmfGeometry.hpp"
#include "XdmfTopology.hpp"
26
#include "XdmfGridCollection.hpp"
27
#include "XdmfGridCollectionType.hpp"
28

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

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

XdmfGridCollection::~XdmfGridCollection()
{
}

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

std::map<std::string, std::string> XdmfGridCollection::getItemProperties() const
{
50
	std::map<std::string, std::string> collectionProperties = XdmfGrid::getItemProperties();
51
	collectionProperties["GridType"] = "Collection";
52
	mType->getProperties(collectionProperties);
53 54 55
	return collectionProperties;
}

56
std::string XdmfGridCollection::getItemTag() const
57
{
58
	return ItemTag;
59 60
}

61 62
boost::shared_ptr<const XdmfGridCollectionType> XdmfGridCollection::getType() const
{
63 64 65 66 67 68
	return mType;
}

void XdmfGridCollection::insert(const boost::shared_ptr<XdmfInformation> information)
{
	XdmfItem::insert(information);
69 70
}

71
void XdmfGridCollection::populateItem(const std::map<std::string, std::string> & itemProperties, std::vector<boost::shared_ptr<XdmfItem> > & childItems, const XdmfCoreReader * const reader)
72
{
73
	mType = XdmfGridCollectionType::New(itemProperties);
74
	XdmfDomain::populateItem(itemProperties, childItems, reader);
75
	mInformations.clear();
76
	XdmfGrid::populateItem(itemProperties, childItems, reader);
77 78
}

79
void XdmfGridCollection::setType(const boost::shared_ptr<const XdmfGridCollectionType> type)
80
{
81
	mType = type;
82 83
}

84
void XdmfGridCollection::traverse(const boost::shared_ptr<XdmfBaseVisitor> visitor)
85
{
86
	XdmfGrid::traverse(visitor);
87 88 89 90

	// Only write XdmfInformations once (deal with diamond inheritance)
	std::vector<boost::shared_ptr<XdmfInformation> > informations;
	informations.swap(mInformations);
91
	XdmfDomain::traverse(visitor);
92
	informations.swap(mInformations);
93
}