38 #include <vtkXMLUnstructuredGridWriter.h>
39 #include <vtkUnstructuredGridWriter.h>
40 #include <vtkUnstructuredGrid.h>
41 #include <vtkPoints.h>
42 #include <vtkCellType.h>
73 else if (pType ==
"T")
77 else if (pType ==
"Q")
81 else if (pType ==
"A")
85 else if (pType ==
"P")
89 else if (pType ==
"R")
93 else if (pType ==
"H")
95 return VTK_HEXAHEDRON;
99 ASSERTL0(
false,
"Element type not supported.");
108 cout <<
"OutputVtk: Writing file..." << endl;
111 vtkUnstructuredGrid *vtkMesh = vtkUnstructuredGrid::New();
112 vtkPoints *vtkPoints = vtkPoints::New();
114 std::set<NodeSharedPtr> tmp(
m_mesh->m_vertexSet.begin(),
115 m_mesh->m_vertexSet.end());
119 vtkPoints->InsertPoint(n->m_id, n->m_x, n->m_y, n->m_z);
123 vector<ElementSharedPtr> &elmt =
m_mesh->m_element[
m_mesh->m_expDim];
124 for (
int i = 0; i < elmt.size(); ++i)
126 int vertexCount = elmt[i]->GetVertexCount();
127 for (
int j = 0; j < vertexCount; ++j)
129 p[j] = elmt[i]->GetVertex(j)->m_id;
132 if (elmt[i]->GetTag() ==
"R")
134 std::swap(
p[2],
p[4]);
140 vtkMesh->SetPoints(vtkPoints);
145 vtkUnstructuredGridWriter *vtkMeshWriter = vtkUnstructuredGridWriter::New();
146 vtkMeshWriter->SetFileName(
m_config[
"outfile"].as<string>().c_str());
148 #if VTK_MAJOR_VERSION <= 5
149 vtkMeshWriter->SetInput(vtkMesh);
151 vtkMeshWriter->SetInputData(vtkMesh);
153 vtkMeshWriter->Update();
157 vtkXMLUnstructuredGridWriter *vtkMeshWriter = vtkXMLUnstructuredGridWriter::New();
158 vtkMeshWriter->SetFileName(
m_config[
"outfile"].as<string>().c_str());
160 #if VTK_MAJOR_VERSION <= 5
161 vtkMeshWriter->SetInput(vtkMesh);
163 vtkMeshWriter->SetInputData(vtkMesh);
167 vtkMeshWriter->SetDataModeToAscii();
169 vtkMeshWriter->Update();
#define ASSERTL0(condition, msg)
tKey RegisterCreatorFunction(tKey idKey, CreatorFunction classCreator, std::string pDesc="")
Register a class with the factory.
MeshSharedPtr m_mesh
Mesh object.
std::map< std::string, ConfigOption > m_config
List of configuration values.
Abstract base class for output modules.
int GetVtkCellType(std::string pType)
virtual void Process()
Write mesh to output file.
std::pair< ModuleType, std::string > ModuleKey
ModuleFactory & GetModuleFactory()
std::pair< ModuleType, std::string > ModuleKey
std::shared_ptr< Mesh > MeshSharedPtr
Shared pointer to a mesh.
Represents a command-line configuration option.