1 // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
3 // + This file is part of enGrid. +
5 // + Copyright 2008-2014 enGits GmbH +
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. +
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. +
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/>. +
20 // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
22 #include "surfacemesher.h"
23 #include "guimainwindow.h"
24 #include "meshqualityfaceorientation.h"
26 #include "laplacesmoother.h"
28 SurfaceMesher::SurfaceMesher() : SurfaceAlgorithm()
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();
45 //computeMeshDensity(); //!!
47 if (m_BoundaryCodes
.size() == 0) {
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);
58 bool done
= (iter
>= m_NumMaxIter
);
63 cout
<< "surface mesher iteration " << iter
<< ":" << endl
;
66 num_inserted
= insertNodes();
67 cout
<< " inserted nodes : " << num_inserted
<< endl
;
70 //computeMeshDensity(); //!!
72 num_deleted
= deleteNodes();
73 cout
<< " deleted nodes : " << num_deleted
<< endl
;
74 //computeMeshDensity(); // !!
76 for (int i
= 0; i
< m_NumSmoothSteps
; ++i
) {
77 smooth(1, m_CorrectCurvature
);
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;
100 quality1.printCellInfo(2);
104 createIndices(m_Grid
);
106 //computeMeshDensity(); //!!