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 // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
22 #include "seligairfoilreader.h"
23 #include "vtkEgPolyDataToUnstructuredGridFilter.h"
25 #include <vtkDelaunay2D.h>
27 SeligAirfoilReader::SeligAirfoilReader()
29 setFormat("Selig airfoil data file (*.dat *.DAT)");
32 void SeligAirfoilReader::operate()
35 readInputFileName("");
37 QFile
file(getFileName());
38 file
.open(QIODevice::ReadOnly
| QIODevice::Text
);
41 EG_VTKSP(vtkPolyData
, poly
);
43 int num_upper
, num_lower
;
45 num_upper
= int(read_value
);
47 num_lower
= int(read_value
);
48 int num_nodes
= num_lower
+ num_upper
- 1;
49 QVector
<vec3_t
> coord(num_nodes
, vec3_t(0,0,0));
50 for (int i
= 0; i
< num_upper
; ++i
) {
51 f
>> coord
[i
][0] >> coord
[i
][1];
56 for (int i
= num_nodes
- 1; i
>= num_upper
; --i
) {
57 f
>> coord
[i
][0] >> coord
[i
][1];
59 EG_VTKSP(vtkPoints
, points
);
60 points
->SetNumberOfPoints(num_nodes
);
61 poly
->SetPoints(points
);
62 poly
->Allocate(num_nodes
);
63 for (vtkIdType id_node
= 0; id_node
< num_nodes
; ++id_node
) {
64 poly
->GetPoints()->SetPoint(id_node
, coord
[id_node
].data());
66 for (vtkIdType id_node
= 0; id_node
< num_nodes
; ++id_node
) {
69 if (id_node
< num_nodes
-1) {
74 poly
->InsertNextCell(VTK_LINE
, 2, pts
);
77 EG_VTKSP(vtkDelaunay2D
, tri
);
78 tri
->SetInputData(poly
);
79 tri
->SetSourceData(poly
);
80 EG_VTKSP(vtkEgPolyDataToUnstructuredGridFilter
, poly2ug
);
81 poly2ug
->SetInputConnection(tri
->GetOutputPort());
83 makeCopy(poly2ug
->GetOutput(), m_Grid
);
84 updateNodeIndex(m_Grid
);
85 updateCellIndex(m_Grid
);