VTKUnstructuredGrid< T > Class Template Reference

#include <VTKData.h>

Public Member Functions

 VTKUnstructuredGrid (std::string filename, const VTKPointDescriptor< T > *descr)
 
 operator bool () const
 
template<typename C >
void write (const C &container)
 

Private Attributes

const VTKPointDescriptor< T > * descriptor_
 
std::ofstream outFile_
 

Detailed Description

template<typename T>
class VTKUnstructuredGrid< T >

This function writes single output frames. this requires an filename and a descriptor. To actually write it, we need a collection.

Constructor & Destructor Documentation

◆ VTKUnstructuredGrid()

template<typename T >
VTKUnstructuredGrid< T >::VTKUnstructuredGrid ( std::string  filename,
const VTKPointDescriptor< T > *  descr 
)
inline

Create a new VTK Unstructured grid file.

Parameters
filenameThe name of the output file
descrThe typedescriptor for T
296  : descriptor_(descr), outFile_(filename)
297  {
298  }
const VTKPointDescriptor< T > * descriptor_
Definition: Tools/VTKData.h:288
std::ofstream outFile_
Definition: Tools/VTKData.h:289
string filename
Definition: MergeRestartFiles.py:39

Member Function Documentation

◆ operator bool()

template<typename T >
VTKUnstructuredGrid< T >::operator bool ( ) const
inline

Returns true if this VTK output file is valid and has no errorbits set

302  {
303  return outFile_.good();
304  }

References VTKUnstructuredGrid< T >::outFile_.

◆ write()

template<typename T >
template<typename C >
void VTKUnstructuredGrid< T >::write ( const C container)
inline

Writes out the container C containing T's, which all get written using the information in the descriptor. C should contain the forward iterable traits, as well as a method size() to give the number of elements stored in this container. All STL containers have this property. Yours should too.

313  {
314  outFile_ <<
315  "<?xml version=\"1.0\"?>\n"
316  "<VTKFile type=\"UnstructuredGrid\" version=\"0.1\" byte_order=\"LittleEndian\">\n"
317  " <UnstructuredGrid>\n"
318  " <Piece NumberOfPoints=\"" << container.size() << "\" NumberOfCells=\"0\">\n"
319  " <Cells>\n"
320  " <DataArray type=\"Int32\" name=\"connectivity\" format=\"ascii\">\n"
321  " 0\n"
322  " </DataArray>\n"
323  " <DataArray type=\"Float32\" name=\"offset\" format=\"ascii\">\n"
324  " 0\n"
325  " </DataArray>\n"
326  " <DataArray type=\"UInt8\" name=\"types\" format=\"ascii\">\n"
327  " 1\n"
328  " </DataArray>\n"
329  " </Cells>\n"
330  " <Points>\n";
331  Detail::VTKPointDescriptorEntry<T>* pDescr = descriptor_->positionEntry_;
332  outFile_ << "<DataArray type=\"" << pDescr->getTypeName() << "\" "
333  "NumberOfComponents=\"" << pDescr->getNumberOfComponents() << "\" "
334  "format=\"ascii\">\n";
335  for (const T& mem : container)
336  {
337  pDescr->emit(outFile_, mem);
338  }
339  outFile_ << "\n</DataArray>\n";
340 
341  outFile_ <<
342  " </Points>\n"
343  " <PointData>\n";
344 
345  for (Detail::VTKPointDescriptorEntry<T>* descr : descriptor_->entries_)
346  {
347  outFile_ << "<DataArray type=\"" << descr->getTypeName() << "\" "
348  "Name=\"" << descr->getName() << "\" "
349  "NumberOfComponents=\"" << descr->getNumberOfComponents() << "\" "
350  "format=\"ascii\">\n";
351  for (const T& mem : container)
352  {
353  descr->emit(outFile_, mem);
354  }
355  outFile_ << "\n</DataArray>\n";
356  }
357  outFile_ <<
358  " </PointData>\n"
359  " <CellData/>\n"
360  " </Piece>\n"
361  " </UnstructuredGrid>\n"
362  "</VTKFile>\n";
363  }
Definition: Tools/VTKData.h:25
std::string getName() const
Returns the name associated with this field.
Definition: Tools/VTKData.h:55
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.
virtual std::string getTypeName() const =0
Gives the VTKDataType for VTK.

References VTKUnstructuredGrid< T >::descriptor_, Detail::VTKPointDescriptorEntry< T >::emit(), Detail::VTKPointDescriptorEntry< T >::getName(), Detail::VTKPointDescriptorEntry< T >::getNumberOfComponents(), Detail::VTKPointDescriptorEntry< T >::getTypeName(), and VTKUnstructuredGrid< T >::outFile_.

Referenced by transformMercuryToVTK().

Member Data Documentation

◆ descriptor_

template<typename T >
const VTKPointDescriptor<T>* VTKUnstructuredGrid< T >::descriptor_
private

◆ outFile_

template<typename T >
std::ofstream VTKUnstructuredGrid< T >::outFile_
private

The documentation for this class was generated from the following file: