Go to the documentation of this file.
4 #ifndef DUNE_GRID_IO_FILE_VTK_COMMON_HH
5 #define DUNE_GRID_IO_FILE_VTK_COMMON_HH
12 #include <dune/common/deprecated.hh>
13 #include <dune/common/exceptions.hh>
14 #include <dune/geometry/type.hh>
15 #include <dune/common/typetraits.hh>
111 typedef std::conditional<std::numeric_limits<char>::is_signed,
127 static std::string getString() {
128 static const unsigned int_sizes[] = { 8, 16, 32, 64, 0 };
129 static const unsigned float_sizes[] = { 32, 64, 0 };
130 const unsigned* sizes;
132 std::ostringstream s;
133 if(std::numeric_limits<T>::is_integer) {
134 if(std::numeric_limits<T>::is_signed)
146 static const unsigned size = 8*
sizeof(T);
147 while(*sizes != 0 && *sizes <= size) ++sizes;
159 const std::string& operator()()
const {
160 static const std::string s = getString();
201 if (t.isVertex())
return vertex;
202 if (t.isLine())
return line;
203 if (t.isTriangle())
return triangle;
206 if (t.isPyramid())
return pyramid;
207 if (t.isPrism())
return prism;
212 if( t.dim() == 2 )
return polygon;
216 DUNE_THROW(IOError,
"VTKWriter: unsupported GeometryType " << t);
236 static const int quadRenumbering[4] = {0,1,3,2};
237 static const int cubeRenumbering[8] = {0,1,3,2,4,5,7,6};
238 static const int prismRenumbering[6] = {0,2,1,3,5,4};
239 static const int pyramidRenumbering[5] = {0,1,3,2,4};
241 if (t.isQuadrilateral())
return quadRenumbering[i];
242 if (t.isPyramid())
return pyramidRenumbering[i];
243 if (t.isPrism())
return prismRenumbering[i];
244 if (t.isHexahedron())
return cubeRenumbering[i];
283 if (
reinterpret_cast<char*
>(&i)[1] == 1)
286 return "LittleEndian";
343 DUNE_THROW(Dune::NotImplemented,
"Unknown precision type");
353 return sizeof(float);
355 return sizeof(double);
357 return sizeof(std::uint32_t);
361 return sizeof(std::int32_t);
363 DUNE_THROW(Dune::NotImplemented,
"Unknown precision type");
439 #endif // DUNE_GRID_IO_FILE_VTK_COMMON_HH
@ appendedraw
Output is to the file is appended raw binary.
Definition: common.hh:48
FileType
which type of VTK file to write
Definition: common.hh:300
std::conditional< std::numeric_limits< char >::is_signed, int, unsigned >::type Type
Definition: common.hh:113
unsigned char uint8_t
Definition: yaspgrid.hh:16
@ line
Definition: common.hh:182
@ conforming
Output conforming data.
Definition: common.hh:72
@ vector
vector-valued field (always 3D, will be padded if necessary)
@ quadrilateral
Definition: common.hh:185
std::string name() const
The name of the data field.
Definition: common.hh:400
unsigned Type
Definition: common.hh:101
@ pyramid
Definition: common.hh:189
@ triangle
Definition: common.hh:183
@ nonconforming
Output non-conforming data.
Definition: common.hh:80
@ polyData
for .vtp files (PolyData)
Definition: common.hh:302
T Type
type to convert T to before putting it into a stream with <<
Definition: common.hh:96
std::size_t size() const
The number of components in the data field.
Definition: common.hh:412
@ ascii
Output to the file is in ascii.
Definition: common.hh:44
Precision precision() const
The precision used for the output of the data field.
Definition: common.hh:418
OutputType
How the bulk data should be stored in the file.
Definition: common.hh:42
@ polygon
Definition: common.hh:184
@ polyhedron
Definition: common.hh:190
GeometryType geometryType(const Dune::GeometryType &t)
mapping from GeometryType to VTKGeometryType
Definition: common.hh:199
@ tetrahedron
Definition: common.hh:186
Type type() const
The type of the data field.
Definition: common.hh:406
std::size_t typeSize(Precision p)
map precision to byte size
Definition: common.hh:348
@ hexahedron
Definition: common.hh:187
std::string getEndiannessString()
determine endianness of this C++ implementation
Definition: common.hh:280
@ appendedbase64
Output is to the file is appended base64 binary.
Definition: common.hh:50
@ unstructuredGrid
for .vtu files (UnstructuredGrid)
Definition: common.hh:304
@ vertex
Definition: common.hh:181
determine a type to safely put another type into a stream
Definition: common.hh:94
int Type
Definition: common.hh:106
@ tensor
tensor field (always 3x3)
std::string toString(Precision p)
map precision to VTK type name
Definition: common.hh:328
Precision
which precision to use when writing out data to vtk files
Definition: common.hh:319
int renumber(const Dune::GeometryType &t, int i)
renumber VTK <-> Dune
Definition: common.hh:234
DataMode
Whether to produce conforming or non-conforming output.
Definition: common.hh:66
Descriptor struct for VTK fields.
Definition: common.hh:375
FieldInfo(std::string name, Type type, std::size_t size, Precision prec=Precision::float32)
Create a FieldInfo instance with the given name, type and size.
Definition: common.hh:392
Include standard header files.
Definition: agrid.hh:58
@ base64
Output to the file is inline base64 binary.
Definition: common.hh:46
@ prism
Definition: common.hh:188
GeometryType
Type representing VTK's entity geometry types.
Definition: common.hh:180
class DUNE_DEPRECATED_MSG("TypeName will be removed after Dune 2.7. Look at VTK::toString and VTK::Precision for substitution.") TypeName
map type to its VTK name in data array
Definition: common.hh:126
Type
VTK data type.
Definition: common.hh:381