1 #ifndef __MESHWITHDATA_H 2 #define __MESHWITHDATA_H 13 template <
class MeshType>
30 if ( data.size() !=
static_cast<unsigned>(
_mesh.
getNumVertices () ) )
throw std::invalid_argument(
aol::strprintf (
"Wrong size. In File %s at line %d.", __FILE__, __LINE__ ).c_str() );
35 if ( data.size() !=
static_cast<unsigned>(
_mesh.
getNumTriangs () ) )
throw std::invalid_argument(
aol::strprintf (
"Wrong size. In File %s at line %d.", __FILE__, __LINE__ ).c_str() );
40 throw std::invalid_argument(
aol::strprintf (
"Unknown DataSupp. In File %s at line %d.", __FILE__, __LINE__ ).c_str() );
47 VectorData entry = { dataDescr, vSpec, &data, numComponents };
57 throw std::invalid_argument(
aol::strprintf (
"Unknown DataSupp. In File %s at line %d.", __FILE__, __LINE__ ).c_str() );
65 void save (
string filename )
const {
68 std::ofstream out ( filename.c_str() );
70 out <<
"# vtk DataFile Version 2.0" << endl
71 <<
"written by method MeshWithData::saveAsLegacyVTK" << endl
73 <<
"DATASET POLYDATA" << endl
74 <<
"POINTS " << numVertices <<
" float" << endl;
79 for (
short i = 0; i < 3; ++i )
80 out << ( i == 0 ?
"" :
" " ) << coords[i];
88 for (
short i = 0; i < 3; ++i )
94 out <<
"POINT_DATA " << numVertices << endl;
98 out <<
"LOOKUP_TABLE default" << endl;
108 out <<
"LOOKUP_TABLE default" << endl;
119 for (
int vx = 0; vx < numVertices; ++vx ) {
121 out << ( comp == 0 ?
"" :
" " ) << (*
_vectorVertexData[i]._data)(vx + comp * numVertices);
MeshType::RealType RealType
LegacyVtkWriter & addVectorData(const VectorType &data, const int numComponents, string dataDescr, DataSupp supp, VectorSpec vSpec=VECTORS)
const Point3DType & getVertex(const int num) const
MeshType::Indices3DType Indices3DType
void setPrecisionTo(int prec)
set precision in saving methods
int getNumVertices() const
DataTypeContainer::RealType RealType
int getNumTriangs() const
VectorSpec
vector-valued data can be saved (in VTK legacy format) as 3-vectors, normals or texture coordinates (...
DataTypeContainer::VectorType VectorType
std::vector< VectorData > _vectorVertexData
std::vector< ScalarData > _scalarFaceData
std::vector< VectorData > _vectorFaceData
int getTriangNodeIdx(const int num, const int localNode) const
LegacyVtkWriter(const MeshType &mesh, int precision)
MeshType::VectorType VectorType
string strprintf(const char *format,...)
Give back formatted string, analogously to sprintf, but save the long way 'round with char arrays...
DataSupp
data can either belong to vertices or to faces
void save(string filename) const
LegacyVtkWriter & addScalarData(const VectorType &data, string dataDescr, DataSupp supp)
DataTypeContainer::Point3DType Point3DType
DataTypeContainer::Indices3DType Indices3DType
LegacyVtkWriter(const MeshType &mesh)
std::vector< ScalarData > _scalarVertexData
MeshType::Point3DType Point3DType