40 #include <vtkPolyDataWriter.h>
41 #include <vtkPolyData.h>
42 #include <vtkPoints.h>
43 #include <vtkCellArray.h>
45 #include "../MeshElements.h"
55 "Writes a VTK file.");
71 cout <<
"OutputVtk: Writing file..." << endl;
74 vtkPolyData *vtkMesh = vtkPolyData::New();
75 vtkPoints *vtkPoints = vtkPoints::New();
76 vtkCellArray *vtkPolys = vtkCellArray::New();
80 std::set<NodeSharedPtr> tmp(
81 m_mesh->m_vertexSet.begin(),
82 m_mesh->m_vertexSet.end());
84 for (it = tmp.begin(); it != tmp.end(); ++it)
87 vtkPoints->InsertPoint(n->m_id, n->m_x, n->m_y, n->m_z);
91 vector<ElementSharedPtr> &elmt =
93 for(
int i = 0; i < elmt.size(); ++i)
95 int vertexCount = elmt[i]->GetVertexCount();
96 for (
int j = 0; j < vertexCount; ++j)
98 p[j] = elmt[i]->GetVertex(j)->m_id;
100 vtkPolys->InsertNextCell(vertexCount, &p[0]);
103 vtkMesh->SetPoints(vtkPoints);
104 vtkMesh->SetPolys(vtkPolys);
107 vtkPolyDataWriter *vtkMeshWriter = vtkPolyDataWriter::New();
108 vtkMeshWriter->SetFileName(
m_config[
"outfile"].as<string>().c_str());
109 #if VTK_MAJOR_VERSION <= 5
110 vtkMeshWriter->SetInput(vtkMesh);
112 vtkMeshWriter->SetInputData(vtkMesh);
114 vtkMeshWriter->Update();
pair< ModuleType, string > ModuleKey
Abstract base class for output modules.
map< string, ConfigOption > m_config
List of configuration values.
MeshSharedPtr m_mesh
Mesh object.
boost::shared_ptr< Node > NodeSharedPtr
Shared pointer to a Node.
virtual void Process()
Write mesh to output file.
boost::shared_ptr< Mesh > MeshSharedPtr
Shared pointer to a mesh.
StandardMatrixTag boost::call_traits< LhsDataType >::const_reference rhs typedef NekMatrix< LhsDataType, StandardMatrixTag >::iterator iterator
ModuleFactory & GetModuleFactory()
tKey RegisterCreatorFunction(tKey idKey, CreatorFunction classCreator, tDescription pDesc="")
Register a class with the factory.