vtk 5.2 -> 5.4 in setup_paths.sh
[engrid.git] / src / reducesurfacetriangulation.cpp
blob734db5d411076227b78a24fbcea40f9eef209c5f
1 //
2 // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
3 // + +
4 // + This file is part of enGrid. +
5 // + +
6 // + Copyright 2008,2009 Oliver Gloth +
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 // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
24 #include "reducesurfacetriangulation.h"
26 ReduceSurfaceTriangulation::ReduceSurfaceTriangulation()
28 EG_TYPENAME;
29 m_PerformGeometricTests = true;
30 m_UseProjectionForSmoothing = false;
31 m_UseNormalCorrectionForSmoothing = true;
32 m_AllowFeatureEdgeSwapping = true;
33 m_RespectFeatureEdgesForDeleteNodes = false;
34 m_FeatureAngleForDeleteNodes = m_FeatureAngle;
37 void ReduceSurfaceTriangulation::pass1()
39 cout << "\nFirst pass of surface reduction:\n(This is the expensive part...)" << endl;
40 int iter = 0;
41 bool done = false;
42 m_UseNormalCorrectionForSmoothing = true;
43 int num_initial_nodes = m_Grid->GetNumberOfPoints();
44 int num_del_max = 0;
45 while (!done) {
46 ++iter;
47 cout << "\npass-1 iteration-" << iter << ":" << endl;
48 computeMeshDensity();
49 int num_deleted = deleteNodes();
50 num_del_max = max(num_del_max, num_deleted);
51 cout << "deleted nodes : " << num_deleted << endl;
52 swap();
53 //smooth(1);
54 done = num_deleted <= num_del_max/100;
55 cout << "total nodes : " << m_Grid->GetNumberOfPoints() << endl;
56 cout << "total cells : " << m_Grid->GetNumberOfCells() << endl;
60 void ReduceSurfaceTriangulation::pass2()
62 cout << "\n\nSecond pass of surface reduction:\n(This should be quick...)" << endl;
63 m_UseNormalCorrectionForSmoothing = false;
64 smooth(2);
67 void ReduceSurfaceTriangulation::operate()
69 prepare();
70 //writeGrid(m_Grid, "take1");
71 updateNodeInfo(true);
72 //writeGrid(m_Grid, "take2");
73 pass1();
74 //pass2();
75 createIndices(m_Grid);
76 updateNodeInfo(false);
77 computeMeshDensity();