1 // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
3 // + This file is part of enGrid. +
5 // + Copyright 2008-2014 enGits GmbH +
7 // + enGrid is free software: you can redistribute it and/or modify +
8 // + it under the terms of the GNU General Public License as published by +
9 // + the Free Software Foundation, either version 3 of the License, or +
10 // + (at your option) any later version. +
12 // + enGrid is distributed in the hope that it will be useful, +
13 // + but WITHOUT ANY WARRANTY; without even the implied warranty of +
14 // + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +
15 // + GNU General Public License for more details. +
17 // + You should have received a copy of the GNU General Public License +
18 // + along with enGrid. If not, see <http://www.gnu.org/licenses/>. +
20 // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
21 #include "polydatareader.h"
22 #include "vtkEgPolyDataToUnstructuredGridFilter.h"
24 #include <vtkXMLPolyDataReader.h>
26 #include "guimainwindow.h"
28 PolyDataReader::PolyDataReader()
30 setFormat("VTK poly data files(*.vtp)");
34 void PolyDataReader::operate()
37 QFileInfo
file_info(GuiMainWindow::pointer()->getFilename());
38 readInputFileName(file_info
.completeBaseName() + ".vtp");
40 EG_VTKSP(vtkXMLPolyDataReader
,vtp
);
41 EG_VTKSP(vtkEgPolyDataToUnstructuredGridFilter
,pd2ug
);
42 vtp
->SetFileName(qPrintable(getFileName()));
43 pd2ug
->SetInputConnection(vtp
->GetOutputPort());
45 m_Grid
->DeepCopy(pd2ug
->GetOutput());
46 createBasicFields(m_Grid
, m_Grid
->GetNumberOfCells(), m_Grid
->GetNumberOfPoints());
47 updateNodeIndex(m_Grid
);
48 updateCellIndex(m_Grid
);
49 EG_VTKDCC(vtkIntArray
, bc
, m_Grid
, "cell_code");
50 for (vtkIdType id_cell
= 0; id_cell
< m_Grid
->GetNumberOfPoints(); ++id_cell
) {
51 bc
->SetValue(id_cell
,99);