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;
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";
361 stream << indent <<
"</AppendedData>\n";
380 unsigned ncomps,
unsigned nitems) {
381 return factory.
make<T>(name, ncomps, nitems, indent);
Common stuff for the VTKWriter.
Data array writers for the VTKWriter.
Include standard header files.
Definition agrid.hh:60
OutputType
How the bulk data should be stored in the file.
Definition common.hh:40
FileType
which type of VTK file to write
Definition common.hh:290
@ polyData
for .vtp files (PolyData)
Definition common.hh:292
@ unstructuredGrid
for .vtu files (UnstructuredGrid)
Definition common.hh:294
std::string getEndiannessString()
determine endianness of this C++ implementation
Definition common.hh:270
base class for data array writers
Definition dataarraywriter.hh:54
a factory for DataArrayWriters
Definition dataarraywriter.hh:327
bool beginAppended()
signal start of the appended section
Definition dataarraywriter.hh:362
const std::string & appendedEncoding() const
query encoding string for appended data
Definition dataarraywriter.hh:375
DataArrayWriter< T > * make(const std::string &name, unsigned ncomps, unsigned nitems, const Indent &indent)
create a DataArrayWriter
Definition dataarraywriter.hh:406
Dump a .vtu/.vtp files contents to a stream.
Definition vtuwriter.hh:96
bool beginAppended()
start the appended data section
Definition vtuwriter.hh:343
void endAppended()
finish the appended data section
Definition vtuwriter.hh:357
VTUWriter(std::ostream &stream_, OutputType outputType, FileType fileType_)
create a VTUWriter object
Definition vtuwriter.hh:120
std::ostream & stream
Definition vtuwriter.hh:98
void endCellData()
finish CellData section
Definition vtuwriter.hh:218
void beginMain(unsigned ncells, unsigned npoints)
start the main PolyData/UnstructuredGrid section
Definition vtuwriter.hh:308
void beginCells()
start section for the grid cells/PolyData lines
Definition vtuwriter.hh:272
DataArrayWriter< T > * makeArrayWriter(const std::string &name, unsigned ncomps, unsigned nitems)
acquire a DataArrayWriter
Definition vtuwriter.hh:379
void endPointData()
finish PointData section
Definition vtuwriter.hh:180
Phase
Definition vtuwriter.hh:99
@ appended
Definition vtuwriter.hh:99
@ main
Definition vtuwriter.hh:99
void beginCellData(const std::string &scalars="", const std::string &vectors="")
start CellData section
Definition vtuwriter.hh:203
void beginPointData(const std::string &scalars="", const std::string &vectors="")
start PointData section
Definition vtuwriter.hh:165
void endPoints()
finish section for the point coordinates
Definition vtuwriter.hh:247
~VTUWriter()
write footer
Definition vtuwriter.hh:147
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 endMain()
finish the main PolyData/UnstructuredGrid section
Definition vtuwriter.hh:318
enum Dune::VTK::VTUWriter::Phase phase