improved performance for face search -- some debugging required
[engrid-github.git] / src / libengrid / seligairfoilreader.cpp
blobe74439aecf7a37b673c2e27155f1c7aa3486197f
1 //
2 // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
3 // + +
4 // + This file is part of enGrid. +
5 // + +
6 // + Copyright 2008-2013 enGits GmbH +
7 // + +
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. +
12 // + +
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. +
17 // + +
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/>. +
20 // + +
21 // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
22 //
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()
36 try {
37 readInputFileName("");
38 if (isValid()) {
39 QFile file(getFileName());
40 file.open(QIODevice::ReadOnly | QIODevice::Text);
41 QTextStream f(&file);
42 f.readLine();
43 EG_VTKSP(vtkPolyData, poly);
44 double read_value;
45 int num_upper, num_lower;
46 f >> read_value;
47 num_upper = int(read_value);
48 f >> 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];
55 double dummy;
56 f >> dummy;
57 f >> dummy;
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) {
69 vtkIdType pts[2];
70 pts[0] = id_node;
71 if (id_node < num_nodes-1) {
72 pts[1] = id_node + 1;
73 } else {
74 pts[1] = 0;
76 poly->InsertNextCell(VTK_LINE, 2, pts);
79 EG_VTKSP(vtkDelaunay2D, tri);
80 tri->SetInput(poly);
81 tri->SetSource(poly);
82 EG_VTKSP(vtkEgPolyDataToUnstructuredGridFilter, poly2ug);
83 poly2ug->SetInput(tri->GetOutput());
84 poly2ug->Update();
85 makeCopy(poly2ug->GetOutput(), m_Grid);
86 UpdateNodeIndex(m_Grid);
87 UpdateCellIndex(m_Grid);
89 } catch (Error err) {
90 err.display();