38 #include <vtkPolyDataWriter.h> 39 #include <vtkPolyData.h> 40 #include <vtkPoints.h> 41 #include <vtkCellArray.h> 68 cout <<
"OutputVtk: Writing file..." << endl;
71 vtkPolyData *vtkMesh = vtkPolyData::New();
72 vtkPoints *vtkPoints = vtkPoints::New();
73 vtkCellArray *vtkPolys = vtkCellArray::New();
75 std::set<NodeSharedPtr> tmp(
m_mesh->m_vertexSet.begin(),
76 m_mesh->m_vertexSet.end());
80 vtkPoints->InsertPoint(n->m_id, n->m_x, n->m_y, n->m_z);
84 vector<ElementSharedPtr> &elmt =
m_mesh->m_element[
m_mesh->m_expDim];
85 for (
int i = 0; i < elmt.size(); ++i)
87 int vertexCount = elmt[i]->GetVertexCount();
88 for (
int j = 0; j < vertexCount; ++j)
90 p[j] = elmt[i]->GetVertex(j)->m_id;
92 vtkPolys->InsertNextCell(vertexCount, &p[0]);
95 vtkMesh->SetPoints(vtkPoints);
96 vtkMesh->SetPolys(vtkPolys);
99 vtkPolyDataWriter *vtkMeshWriter = vtkPolyDataWriter::New();
100 vtkMeshWriter->SetFileName(
m_config[
"outfile"].as<string>().c_str());
101 #if VTK_MAJOR_VERSION <= 5 102 vtkMeshWriter->SetInput(vtkMesh);
104 vtkMeshWriter->SetInputData(vtkMesh);
106 vtkMeshWriter->Update();
Abstract base class for output modules.
MeshSharedPtr m_mesh
Mesh object.
std::shared_ptr< Mesh > MeshSharedPtr
Shared pointer to a mesh.
std::pair< ModuleType, std::string > ModuleKey
virtual void Process()
Write mesh to output file.
std::map< std::string, ConfigOption > m_config
List of configuration values.
tKey RegisterCreatorFunction(tKey idKey, CreatorFunction classCreator, std::string pDesc="")
Register a class with the factory.
std::pair< ModuleType, std::string > ModuleKey
ModuleFactory & GetModuleFactory()