1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157
|
/////////////////////////////////////////////////////////////
// //
// Copyright (c) 2003-2014 by The University of Queensland //
// Centre for Geoscience Computing //
// http://earth.uq.edu.au/centre-geoscience-computing //
// //
// Primary Business: Brisbane, Queensland, Australia //
// Licensed under the Open Software License version 3.0 //
// http://www.apache.org/licenses/LICENSE-2.0 //
// //
/////////////////////////////////////////////////////////////
#ifndef ESYS_LSM_VTKSTRUCTUREDGRID_H
#define ESYS_LSM_VTKSTRUCTUREDGRID_H
#include <vector>
#include <map>
#include <iostream>
#include <sstream>
#include "Foundation/vec3.h"
#include "Geometry/Vec3L.h"
#include "Tools/StressCalculator/VtkPiece.h"
namespace esys
{
namespace lsm
{
namespace vtk
{
template <typename TmplPointType, typename TmplPointDataTypeTuple>
class StructuredPiece : public Piece<TmplPointType, TmplPointDataTypeTuple>
{
public:
typedef Piece<TmplPointType, TmplPointDataTypeTuple> Inherited;
typedef typename Inherited::PointType PointType;
typedef typename Inherited::PointValue PointValue;
typedef typename Inherited::PointDataTypeTuple PointDataTypeTuple;
typedef typename Inherited::PointData PointData;
StructuredPiece(const PointType &pointType, const PointDataTypeTuple &pointDataType)
: Inherited(pointType, pointDataType),
m_minExtent(),
m_maxExtent()
{
}
virtual ~StructuredPiece()
{
}
void setExtent(const Vec3L &minIndex, const Vec3L &maxIndex)
{
m_minExtent = minIndex;
m_maxExtent = maxIndex;
}
virtual void writeXml(std::ostream &oStream)
{
oStream
<< "<Piece Extent=\""
<< getMinExtent()[0] << " "
<< getMaxExtent()[0] << " "
<< getMinExtent()[1] << " "
<< getMaxExtent()[1] << " "
<< getMinExtent()[2] << " "
<< getMaxExtent()[2] << "\">"
<< std::endl;
this->writePointsXml(oStream);
this->writePointDataXml(oStream);
this->writeCellDataXml(oStream);
oStream << "</Piece>";
}
const Vec3L &getMinExtent() const
{
return m_minExtent;
}
const Vec3L &getMaxExtent() const
{
return m_maxExtent;
}
protected:
private:
Vec3L m_minExtent;
Vec3L m_maxExtent;
};
class StructuredGrid
{
private:
typedef std::vector<XmlPiece *> PiecePtrVector;
public:
StructuredGrid()
: m_pieceVector(),
m_minExtent(),
m_maxExtent()
{
}
virtual ~StructuredGrid()
{
}
void setExtent(const Vec3L &minIndex, const Vec3L &maxIndex)
{
m_minExtent = minIndex;
m_maxExtent = maxIndex;
}
template <typename TmplStructuredPiece>
void addPiece(TmplStructuredPiece &piece)
{
XmlPiece &xmlPiece = dynamic_cast<XmlPiece &>(piece);
m_pieceVector.push_back(&xmlPiece);
}
virtual void writeXml(std::ostream &oStream)
{
oStream
<< "<VTKFile type=\"StructuredGrid\" version=\"0.1\">\n"
<< "<StructuredGrid WholeExtent=\""
<< m_minExtent.X() << " "
<< m_maxExtent.X() << " "
<< m_minExtent.Y() << " "
<< m_maxExtent.Y() << " "
<< m_minExtent.Z() << " "
<< m_maxExtent.Z() << "\">"
<< std::endl;
for (
PiecePtrVector::const_iterator it = m_pieceVector.begin();
it != m_pieceVector.end();
it++
)
{
(*it)->writeXml(oStream);
oStream << "\n";
}
oStream << "</StructuredGrid>\n";
oStream << "</VTKFile>";
}
private:
PiecePtrVector m_pieceVector;
Vec3L m_minExtent;
Vec3L m_maxExtent;
};
}
}
}
#endif
|