4#ifndef DUNE_GRID_IO_FILE_VTK_VTUWRITER_HH
5#define DUNE_GRID_IO_FILE_VTK_VTUWRITER_HH
99 enum Phase { main, appended } phase;
105 std::string fileType;
106 std::string cellName;
122 : stream(stream_), factory(outputType, stream)
126 fileType =
"PolyData";
130 fileType =
"UnstructuredGrid";
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);
Default exception class for I/O errors.
Definition: exceptions.hh:257
Utility class for handling nested indentation in output.
Definition: indent.hh:51
a factory for DataArrayWriters
Definition: dataarraywriter.hh:326
bool beginAppended()
signal start of the appeneded section
Definition: dataarraywriter.hh:361
const std::string & appendedEncoding() const
query encoding string for appended data
Definition: dataarraywriter.hh:374
DataArrayWriter< T > * make(const std::string &name, unsigned ncomps, unsigned nitems, const Indent &indent)
create a DataArrayWriter
Definition: dataarraywriter.hh:405
base class for data array writers
Definition: dataarraywriter.hh:53
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
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)
aquire a DataArrayWriter
Definition: vtuwriter.hh:379
void endPointData()
finish PointData section
Definition: vtuwriter.hh:180
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
Common stuff for the VTKWriter.
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
Data array writers for the VTKWriter.
A few common exception classes.
#define DUNE_THROW(E, m)
Definition: exceptions.hh:244
Utility class for handling nested indentation in output.
Dune namespace.
Definition: alignment.hh:14