compiles on openSUSE 15.4 part 2
[engrid-github.git] / src / libengrid / reducesurfacetriangulation.cpp
blobc88de6b13f5daef07b69e774e677cb70d9d750e4
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 // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
21 #include "reducesurfacetriangulation.h"
22 #include "geometrytools.h"
24 ReduceSurfaceTriangulation::ReduceSurfaceTriangulation()
26 EG_TYPENAME;
27 m_PerformGeometricTests = true;
28 m_UseProjectionForSmoothing = false;
29 m_UseNormalCorrectionForSmoothing = true;
30 m_AllowFeatureEdgeSwapping = true;
31 m_RespectFeatureEdgesForDeleteNodes = true;
32 m_FeatureAngleForDeleteNodes = GeometryTools::deg2rad(20);
34 m_NumDelaunaySweeps = 10;
35 m_NumSmoothSteps = 1;
38 void ReduceSurfaceTriangulation::pass1()
40 cout << "\nFirst pass of surface reduction:\n(This is the expensive part...)" << endl;
41 int iter = 0;
42 bool done = false;
43 m_UseNormalCorrectionForSmoothing = true;
44 int num_initial_nodes = m_Grid->GetNumberOfPoints();
45 int num_del_max = 0;
46 while (!done) {
47 ++iter;
48 cout << "\npass-1 iteration-" << iter << ":" << endl;
49 computeMeshDensity();
50 int num_deleted = deleteNodes();
51 num_del_max = max(num_del_max, num_deleted);
52 cout << "deleted nodes : " << num_deleted << endl;
53 for (int i = 0; i < m_NumSmoothSteps; ++i) {
54 cout << " smoothing : " << i+1 << "/" << m_NumSmoothSteps << endl;
55 smooth(1);
56 swap();
58 done = num_deleted <= max(num_initial_nodes/100, num_del_max/100);
59 cout << "total nodes : " << m_Grid->GetNumberOfPoints() << endl;
60 cout << "total cells : " << m_Grid->GetNumberOfCells() << endl;
61 //done = true;
65 void ReduceSurfaceTriangulation::pass2()
67 cout << "\n\nSecond pass of surface reduction:\n(This should be quick...)" << endl;
68 m_UseNormalCorrectionForSmoothing = false;
69 smooth(2);
72 void ReduceSurfaceTriangulation::operate()
74 setStretchingFactor(1.0);
75 prepare();
76 //writeGrid(m_Grid, "take1");
77 updateNodeInfo();
78 //writeGrid(m_Grid, "take2");
79 pass1();
80 //pass2();
81 createIndices(m_Grid);
82 updateNodeInfo();
83 computeMeshDensity();