limited volume meshing to boundary layer only
[engrid-github.git] / src / libengrid / seligairfoilreader.cpp
blob23b9b3c78b3de25d29f88591cac15686b9d2fc1c
1 // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 // + +
3 // + This file is part of enGrid. +
4 // + +
5 // + Copyright 2008-2014 enGits GmbH +
6 // + +
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. +
11 // + +
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. +
16 // + +
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/>. +
19 // + +
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()
34 try {
35 readInputFileName("");
36 if (isValid()) {
37 QFile file(getFileName());
38 file.open(QIODevice::ReadOnly | QIODevice::Text);
39 QTextStream f(&file);
40 f.readLine();
41 EG_VTKSP(vtkPolyData, poly);
42 double read_value;
43 int num_upper, num_lower;
44 f >> read_value;
45 num_upper = int(read_value);
46 f >> 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];
53 double dummy;
54 f >> dummy;
55 f >> dummy;
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) {
67 vtkIdType pts[2];
68 pts[0] = id_node;
69 if (id_node < num_nodes-1) {
70 pts[1] = id_node + 1;
71 } else {
72 pts[1] = 0;
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());
82 poly2ug->Update();
83 makeCopy(poly2ug->GetOutput(), m_Grid);
84 updateNodeIndex(m_Grid);
85 updateCellIndex(m_Grid);
87 } catch (Error err) {
88 err.display();