4 #ifndef DUNE_GRID_IO_FILE_VTK_VTUWRITER_HH
5 #define DUNE_GRID_IO_FILE_VTK_VTUWRITER_HH
10 #include <dune/common/exceptions.hh>
11 #include <dune/common/indent.hh>
105 std::string fileType;
106 std::string cellName;
122 : stream(stream_), factory(outputType, stream)
126 fileType =
"PolyData";
130 fileType =
"UnstructuredGrid";
134 DUNE_THROW(IOError,
"VTUWriter: Unknown fileType: " << fileType_);
138 stream << indent <<
"<?xml version=\"1.0\"?>\n";
139 stream << indent <<
"<VTKFile"
140 <<
" type=\"" << fileType <<
"\""
141 <<
" version=\"0.1\""
142 <<
" byte_order=\"" << byteOrder <<
"\">\n";
149 stream << indent <<
"</VTKFile>\n"
166 const std::string& vectors =
"") {
169 stream << indent <<
"<PointData";
170 if(scalars !=
"") stream <<
" Scalars=\"" << scalars <<
"\"";
171 if(vectors !=
"") stream <<
" Vectors=\"" << vectors <<
"\"";
184 stream << indent <<
"</PointData>\n";
204 const std::string& vectors =
"") {
207 stream << indent <<
"<CellData";
208 if(scalars !=
"") stream <<
" Scalars=\"" << scalars <<
"\"";
209 if(vectors !=
"") stream <<
" Vectors=\"" << vectors <<
"\"";
222 stream << indent <<
"</CellData>\n";
239 stream << indent <<
"<Points>\n";
251 stream << indent <<
"</Points>\n";
275 stream << indent <<
"<" << cellName <<
">\n";
287 stream << indent <<
"</" << cellName <<
">\n";
308 inline void beginMain(
unsigned ncells,
unsigned npoints) {
309 stream << indent <<
"<" << fileType <<
">\n";
311 stream << indent <<
"<Piece"
312 <<
" NumberOf" << cellName <<
"=\"" << ncells <<
"\""
313 <<
" NumberOfPoints=\"" << npoints <<
"\">\n";
320 stream << indent <<
"</Piece>\n";
322 stream << indent <<
"</" << fileType <<
">\n";
347 stream << indent <<
"<AppendedData"
348 <<
" encoding=\"" << encoding <<
"\">\n";
351 stream << indent <<
"_";
361 stream << indent <<
"</AppendedData>\n";
380 unsigned ncomps,
unsigned nitems) {
381 return factory.
make<T>(name, ncomps, nitems, indent);
391 #endif // DUNE_GRID_IO_FILE_VTK_VTUWRITER_HH
for .vtu files (UnstructuredGrid)
Definition: common.hh:294
for .vtp files (PolyData)
Definition: common.hh:292
OutputType
How the bulk data should be stored in the file.
Definition: common.hh:40
void beginCells()
start section for the grid cells/PolyData lines
Definition: vtuwriter.hh:272
FileType
which type of VTK file to write
Definition: common.hh:290
Include standard header files.
Definition: agrid.hh:59
base class for data array writers
Definition: dataarraywriter.hh:53
DataArrayWriter< T > * makeArrayWriter(const std::string &name, unsigned ncomps, unsigned nitems)
aquire a DataArrayWriter
Definition: vtuwriter.hh:379
~VTUWriter()
write footer
Definition: vtuwriter.hh:147
enum Dune::VTK::VTUWriter::Phase phase
void endAppended()
finish the appended data section
Definition: vtuwriter.hh:357
Phase
Definition: vtuwriter.hh:99
std::string getEndiannessString()
determine endianness of this C++ implementation
Definition: common.hh:270
const std::string & appendedEncoding() const
query encoding string for appended data
Definition: dataarraywriter.hh:375
Common stuff for the VTKWriter.
Data array writers for the VTKWriter.
VTUWriter(std::ostream &stream_, OutputType outputType, FileType fileType_)
create a VTUWriter object
Definition: vtuwriter.hh:120
bool beginAppended()
signal start of the appended section
Definition: dataarraywriter.hh:362
void endMain()
finish the main PolyData/UnstructuredGrid section
Definition: vtuwriter.hh:318
Definition: vtuwriter.hh:99
void endPointData()
finish PointData section
Definition: vtuwriter.hh:180
void endCells()
start section for the grid cells/PolyData lines
Definition: vtuwriter.hh:283
void beginPoints()
start section for the point coordinates
Definition: vtuwriter.hh:236
void beginPointData(const std::string &scalars="", const std::string &vectors="")
start PointData section
Definition: vtuwriter.hh:165
DataArrayWriter< T > * make(const std::string &name, unsigned ncomps, unsigned nitems, const Indent &indent)
create a DataArrayWriter
Definition: dataarraywriter.hh:406
void beginCellData(const std::string &scalars="", const std::string &vectors="")
start CellData section
Definition: vtuwriter.hh:203
Dump a .vtu/.vtp files contents to a stream.
Definition: vtuwriter.hh:96
Definition: vtuwriter.hh:99
a factory for DataArrayWriters
Definition: dataarraywriter.hh:327
void beginMain(unsigned ncells, unsigned npoints)
start the main PolyData/UnstructuredGrid section
Definition: vtuwriter.hh:308
bool beginAppended()
start the appended data section
Definition: vtuwriter.hh:343
std::ostream & stream
Definition: vtuwriter.hh:98
void endPoints()
finish section for the point coordinates
Definition: vtuwriter.hh:247
void endCellData()
finish CellData section
Definition: vtuwriter.hh:218