41 #include <vtkPolyDataReader.h>
42 #include <vtkPolyData.h>
43 #include <vtkPoints.h>
44 #include <vtkCellArray.h>
46 #include "../MeshElements.h"
83 cout <<
"InputVtk: Start reading file..." << endl;
86 vtkPolyDataReader *vtkMeshReader = vtkPolyDataReader::New();
87 vtkMeshReader->SetFileName(
m_config[
"infile"].as<string>().c_str());
88 vtkMeshReader->Update();
89 vtkPolyData *vtkMesh = vtkMeshReader->GetOutput();
91 vtkPoints *vtkPoints = vtkMesh->GetPoints();
93 const int numCellTypes = 3;
94 vtkCellArray* vtkCells[numCellTypes];
96 int vtkNumPoints[numCellTypes];
97 vtkCells[0] = vtkMesh->GetPolys();
98 vtkCells[1] = vtkMesh->GetStrips();
99 vtkCells[2] = vtkMesh->GetLines();
111 for (
int i = 0; i < vtkPoints->GetNumberOfPoints(); ++i)
113 vtkPoints->GetPoint(i, p);
115 if ((p[0] * p[0]) > 0.000001 &&
m_mesh->m_spaceDim < 1)
119 if ((p[1] * p[1]) > 0.000001 &&
m_mesh->m_spaceDim < 2)
123 if ((p[2] * p[2]) > 0.000001 &&
m_mesh->m_spaceDim < 3)
128 m_mesh->m_node.push_back(boost::shared_ptr<Node>(
new Node(i, p[0], p[1], p[2])));
131 for (
int c = 0; c < numCellTypes; ++c)
133 vtkCells[c]->InitTraversal();
134 for (
int i = 0; vtkCells[c]->GetNextCell(npts, pts); ++i)
136 for (
int j = 0; j < npts - vtkNumPoints[c] + 1; ++j)
141 tags.push_back(vtkCellTypes[c]);
144 vector<NodeSharedPtr> nodeList;
145 for (
int k = j; k < j + vtkNumPoints[c]; ++k)
147 nodeList.push_back(
m_mesh->m_node[pts[k]]);
151 ElmtConfig conf(vtkCellTypes[c],1,
false,
false);
153 CreateInstance(vtkCellTypes[c],
157 if (E->GetDim() >
m_mesh->m_expDim) {
158 m_mesh->m_expDim = E->GetDim();
160 m_mesh->m_element[E->GetDim()].push_back(E);
pair< ModuleType, string > ModuleKey
map< string, ConfigOption > m_config
List of configuration values.
MeshSharedPtr m_mesh
Mesh object.
virtual void ProcessEdges(bool ReprocessEdges=true)
Extract element edges.
boost::shared_ptr< Element > ElementSharedPtr
Shared pointer to an element.
virtual void ProcessVertices()
Extract element vertices.
virtual void ProcessElements()
Generate element IDs.
boost::shared_ptr< Mesh > MeshSharedPtr
Shared pointer to a mesh.
Basic information about an element.
virtual void ProcessComposites()
Generate composites.
Represents a point in the domain.
virtual void ProcessFaces(bool ReprocessFaces=true)
Extract element faces.
ElementFactory & GetElementFactory()
ModuleFactory & GetModuleFactory()
tKey RegisterCreatorFunction(tKey idKey, CreatorFunction classCreator, tDescription pDesc="")
Register a class with the factory.