38 #include <vtkPolyDataReader.h>
39 #include <vtkPolyData.h>
40 #include <vtkPoints.h>
41 #include <vtkCellArray.h>
78 cout <<
"InputVtk: Start reading file..." << endl;
81 vtkPolyDataReader *vtkMeshReader = vtkPolyDataReader::New();
82 vtkMeshReader->SetFileName(
m_config[
"infile"].as<string>().c_str());
83 vtkMeshReader->Update();
84 vtkPolyData *vtkMesh = vtkMeshReader->GetOutput();
86 vtkPoints *vtkPoints = vtkMesh->GetPoints();
88 const int numCellTypes = 3;
89 vtkCellArray *vtkCells[numCellTypes];
91 int vtkNumPoints[numCellTypes];
92 vtkCells[0] = vtkMesh->GetPolys();
93 vtkCells[1] = vtkMesh->GetStrips();
94 vtkCells[2] = vtkMesh->GetLines();
106 for (
int i = 0; i < vtkPoints->GetNumberOfPoints(); ++i)
108 vtkPoints->GetPoint(i, p);
110 if ((p[0] * p[0]) > 0.000001 &&
m_mesh->m_spaceDim < 1)
114 if ((p[1] * p[1]) > 0.000001 &&
m_mesh->m_spaceDim < 2)
118 if ((p[2] * p[2]) > 0.000001 &&
m_mesh->m_spaceDim < 3)
124 boost::shared_ptr<Node>(
new Node(i, p[0], p[1], p[2])));
127 for (
int c = 0; c < numCellTypes; ++c)
129 vtkCells[c]->InitTraversal();
130 for (
int i = 0; vtkCells[c]->GetNextCell(npts, pts); ++i)
132 for (
int j = 0; j < npts - vtkNumPoints[c] + 1; ++j)
137 tags.push_back(vtkCellTypes[c]);
140 vector<NodeSharedPtr> nodeList;
141 for (
int k = j; k < j + vtkNumPoints[c]; ++k)
143 nodeList.push_back(
m_mesh->m_node[pts[k]]);
147 ElmtConfig conf(vtkCellTypes[c], 1,
false,
false);
149 vtkCellTypes[c], conf, nodeList, tags);
152 if (E->GetDim() >
m_mesh->m_expDim)
154 m_mesh->m_expDim = E->GetDim();
156 m_mesh->m_element[E->GetDim()].push_back(E);
Basic information about an element.
pair< ModuleType, string > ModuleKey
tBaseSharedPtr CreateInstance(tKey idKey BOOST_PP_COMMA_IF(MAX_PARAM) BOOST_PP_ENUM_BINARY_PARAMS(MAX_PARAM, tParam, x))
Create an instance of the class referred to by idKey.
map< string, ConfigOption > m_config
List of configuration values.
MeshSharedPtr m_mesh
Mesh object.
ElementFactory & GetElementFactory()
Represents a point in the domain.
virtual void ProcessEdges(bool ReprocessEdges=true)
Extract element edges.
virtual void ProcessVertices()
Extract element vertices.
virtual void ProcessElements()
Generate element IDs.
virtual void ProcessComposites()
Generate composites.
boost::shared_ptr< Mesh > MeshSharedPtr
Shared pointer to a mesh.
virtual void ProcessFaces(bool ReprocessFaces=true)
Extract element faces.
boost::shared_ptr< Element > ElementSharedPtr
ModuleFactory & GetModuleFactory()
tKey RegisterCreatorFunction(tKey idKey, CreatorFunction classCreator, tDescription pDesc="")
Register a class with the factory.