26 #ifndef TOOLS_VTKDATA_H
27 #define TOOLS_VTKDATA_H
36 #include <type_traits>
66 virtual void emit(std::ostream& out,
const T& t)
const = 0;
87 typename std::enable_if<std::is_floating_point<V>::value, std::string>::type
94 typename std::enable_if<std::is_integral<V>::value && std::is_unsigned<V>::value, std::string>::type
101 typename std::enable_if<std::is_integral<V>::value && std::is_signed<V>::value, std::string>::type
108 typename std::enable_if<std::is_array<V>::value, std::string>::type
111 return toVTKDataType< typename std::remove_extent<V>::type >();
115 template<
typename T,
typename V>
116 typename std::enable_if<std::is_array<V>::value || std::is_pointer<V>::value,
void>::type
117 emitProxy(std::ostream& out,
const T& t, std::size_t nComponents, V T::*member)
119 for (std::size_t i = 0; i < nComponents; i++)
121 out << (t.*member)[i] <<
" ";
125 template<
typename T,
typename V>
126 typename std::enable_if<!(std::is_array<V>::value || std::is_pointer<V>::value),
void>::type
127 emitProxy(std::ostream& out,
const T& t, std::size_t nComponents, V T::*member)
129 out << t.*member <<
" ";
135 template<
typename T,
typename V>
147 return toVTKDataType<V>();
150 void emit(std::ostream& out,
const T& t)
const override
173 std::vector< Detail::VTKPointDescriptorEntry<T>* >
entries_;
186 template<
typename DATATYPE>
188 addProperty(std::string name, DATATYPE T::*m,
bool isPrimary =
false)
199 template<
typename DATATYPE>
201 addProperty(std::string name, DATATYPE T::*m,
bool isPrimary =
false)
212 template<
typename DATATYPE>
225 template<
typename VT>
244 "<?xml version=\"1.0\"?>\n"
245 "<VTKFile type=\"Collection\" version=\"0.1\" byte_order=\"LittleEndian\">\n"
271 operator bool()
const
283 "<DataSet group=\"\" part=\"0\" timestep=\"" <<
recordID_ <<
"\" file=\"" << filename <<
"\" />\n";
309 operator bool()
const
323 "<?xml version=\"1.0\"?>\n"
324 "<VTKFile type=\"UnstructuredGrid\" version=\"0.1\" byte_order=\"LittleEndian\">\n"
325 " <UnstructuredGrid>\n"
326 " <Piece NumberOfPoints=\"" << container.size() <<
"\" NumberOfCells=\"0\">\n"
328 " <DataArray type=\"Int32\" name=\"connectivity\" format=\"ascii\">\n"
331 " <DataArray type=\"Float32\" name=\"offset\" format=\"ascii\">\n"
334 " <DataArray type=\"UInt8\" name=\"types\" format=\"ascii\">\n"
342 "format=\"ascii\">\n";
343 for (
const T& mem : container)
356 "Name=\"" << descr->
getName() <<
"\" "
358 "format=\"ascii\">\n";
359 for (
const T& mem : container)
369 " </UnstructuredGrid>\n"
std::string getTypeName() const override
Gives the VTKDataType for VTK.
const VTKPointDescriptor< T > * descriptor_
std::size_t getNumberOfComponents() const override
Returns the number of components in this type.
virtual void emit(std::ostream &out, const T &t) const =0
writes this VTKData to the given output stream for a single T
virtual std::size_t getNumberOfComponents() const =0
Returns the number of components in this type.
void write(const C &container)
virtual ~VTKPointDescriptorEntry()
std::enable_if<!std::is_array< DATATYPE >::value, VTKPointDescriptor & >::type addProperty(std::string name, DATATYPE T::*m, bool isPrimary=false)
Detail::VTKPointDescriptorEntry< T > * positionEntry_
void emit(std::ostream &out, const T &t) const override
writes this VTKData to the given output stream for a single T
std::enable_if< std::is_floating_point< V >::value, std::string >::type toVTKDataType()
const std::size_t nComponents_
VTKPointDescriptor & addProperty(std::string name, DATATYPE T::*m, std::size_t nComponents, bool isPrimary=false)
std::enable_if< std::is_array< V >::value||std::is_pointer< V >::value, void >::type emitProxy(std::ostream &out, const T &t, std::size_t nComponents, V T::*member)
This function actually writes the correct datatype to ostream.
VTKPointDescriptorEntry(std::string fieldName)
initialises this data member with given name.
void append(std::string filename)
std::string getName() const
Returns the name associated with this field.
std::vector< Detail::VTKPointDescriptorEntry< T > * > entries_
VTKUnstructuredGrid(std::string filename, const VTKPointDescriptor< T > *descr)
std::enable_if< std::is_array< DATATYPE >::value, VTKPointDescriptor & >::type addProperty(std::string name, DATATYPE T::*m, bool isPrimary=false)
VTKPointDescriptorEntryImpl(std::string name, V T::*member, std::size_t nComponents)
VTKCollection(std::string fileName)
virtual std::string getTypeName() const =0
Gives the VTKDataType for VTK.