2 // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
4 // + This file is part of enGrid. +
6 // + Copyright 2008-2013 enGits GmbH +
8 // + enGrid is free software: you can redistribute it and/or modify +
9 // + it under the terms of the GNU General Public License as published by +
10 // + the Free Software Foundation, either version 3 of the License, or +
11 // + (at your option) any later version. +
13 // + enGrid is distributed in the hope that it will be useful, +
14 // + but WITHOUT ANY WARRANTY; without even the implied warranty of +
15 // + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +
16 // + GNU General Public License for more details. +
18 // + You should have received a copy of the GNU General Public License +
19 // + along with enGrid. If not, see <http://www.gnu.org/licenses/>. +
21 // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
24 #include "seligairfoilreader.h"
25 #include "vtkEgPolyDataToUnstructuredGridFilter.h"
27 #include <vtkDelaunay2D.h>
29 SeligAirfoilReader::SeligAirfoilReader()
31 setFormat("Selig airfoil data file (*.dat *.DAT)");
34 void SeligAirfoilReader::operate()
37 readInputFileName("");
39 QFile
file(getFileName());
40 file
.open(QIODevice::ReadOnly
| QIODevice::Text
);
43 EG_VTKSP(vtkPolyData
, poly
);
45 int num_upper
, num_lower
;
47 num_upper
= int(read_value
);
49 num_lower
= int(read_value
);
50 int num_nodes
= num_lower
+ num_upper
- 1;
51 QVector
<vec3_t
> coord(num_nodes
, vec3_t(0,0,0));
52 for (int i
= 0; i
< num_upper
; ++i
) {
53 f
>> coord
[i
][0] >> coord
[i
][1];
58 for (int i
= num_nodes
- 1; i
>= num_upper
; --i
) {
59 f
>> coord
[i
][0] >> coord
[i
][1];
61 EG_VTKSP(vtkPoints
, points
);
62 points
->SetNumberOfPoints(num_nodes
);
63 poly
->SetPoints(points
);
64 poly
->Allocate(num_nodes
);
65 for (vtkIdType id_node
= 0; id_node
< num_nodes
; ++id_node
) {
66 poly
->GetPoints()->SetPoint(id_node
, coord
[id_node
].data());
68 for (vtkIdType id_node
= 0; id_node
< num_nodes
; ++id_node
) {
71 if (id_node
< num_nodes
-1) {
76 poly
->InsertNextCell(VTK_LINE
, 2, pts
);
79 EG_VTKSP(vtkDelaunay2D
, tri
);
82 EG_VTKSP(vtkEgPolyDataToUnstructuredGridFilter
, poly2ug
);
83 poly2ug
->SetInput(tri
->GetOutput());
85 makeCopy(poly2ug
->GetOutput(), m_Grid
);
86 UpdateNodeIndex(m_Grid
);
87 UpdateCellIndex(m_Grid
);