fixed edge display for volume cells
[engrid-github.git] / src / libengrid / surfacemesher.cpp
blob2e4e59ef5f350bb052236da86b7ff5ffd0413a6c
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 "surfacemesher.h"
23 #include "guimainwindow.h"
24 #include "meshqualityfaceorientation.h"
26 #include "laplacesmoother.h"
28 SurfaceMesher::SurfaceMesher() : SurfaceAlgorithm()
30 EG_TYPENAME;
31 m_PerformGeometricTests = true;
32 getSet("surface meshing", "use surface projection for smoothing", true, m_UseProjectionForSmoothing);
33 getSet("surface meshing", "use normal correction for smoothing", false, m_UseNormalCorrectionForSmoothing);
34 getSet("surface meshing", "allow feature edge swapping", false, m_AllowFeatureEdgeSwapping);
35 getSet("surface meshing", "correct curvature", false, m_CorrectCurvature);
36 //m_EdgeAngle = m_FeatureAngle;
39 void SurfaceMesher::operate()
41 if (!GuiMainWindow::pointer()->checkCadInterfaces()) {
42 GuiMainWindow::pointer()->storeCadInterfaces();
44 prepare();
45 //computeMeshDensity(); //!!
46 //prepare(); //!!
47 if (m_BoundaryCodes.size() == 0) {
48 return;
50 EG_VTKDCN(vtkDoubleArray, characteristic_length_desired, m_Grid, "node_meshdensity_desired");
51 for (vtkIdType id_node = 0; id_node < m_Grid->GetNumberOfPoints(); ++id_node) {
52 characteristic_length_desired->SetValue(id_node, 1e-6);
54 updateNodeInfo();
55 int num_inserted = 0;
56 int num_deleted = 0;
57 int iter = 0;
58 bool done = (iter >= m_NumMaxIter);
59 //int Nfull = 0;
60 //int Nhalf = 0;
61 while (!done) {
62 ++iter;
63 cout << "surface mesher iteration " << iter << ":" << endl;
64 computeMeshDensity();
65 //return;
66 num_inserted = insertNodes();
67 cout << " inserted nodes : " << num_inserted << endl;
68 updateNodeInfo();
69 swap();
70 //computeMeshDensity(); //!!
71 updateNodeInfo();
72 num_deleted = deleteNodes();
73 cout << " deleted nodes : " << num_deleted << endl;
74 //computeMeshDensity(); // !!
75 updateNodeInfo();
76 for (int i = 0; i < m_NumSmoothSteps; ++i) {
77 smooth(1, m_CorrectCurvature);
78 swap();
80 //int N_crit = m_Grid->GetNumberOfPoints()/100;
81 done = (iter >= m_NumMaxIter);
82 cout << " total nodes : " << m_Grid->GetNumberOfPoints() << endl;
83 cout << " total cells : " << m_Grid->GetNumberOfCells() << endl;
84 double change_ratio = 0;
85 double fluctuation_ratio = 0;
87 double N_new = m_Grid->GetNumberOfPoints();
88 double N_chg = num_inserted - num_deleted;
89 double N_max = max(num_inserted, num_deleted);
90 double N_old = N_new - N_chg;
91 change_ratio = 0.1*int(1000*N_chg/N_old);
92 fluctuation_ratio = 0.1*int(1000*N_max/N_old);
94 cout << " change ratio : " << change_ratio << "%" << endl;
95 cout << " fluctuation ratio : " << fluctuation_ratio << "%" << endl;
97 if (!m_BCodeFeatureDefinition) {
98 MeshQualityFaceOrientation quality1;
99 quality1();
100 quality1.printCellInfo(2);
104 createIndices(m_Grid);
105 updateNodeInfo();
106 //computeMeshDensity(); //!!