limited volume meshing to boundary layer only
[engrid-github.git] / src / libengrid / setboundarycode.cpp
blobd23bdb797bb12e324c08c8c9d6c32636289d888c
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 "setboundarycode.h"
22 #include <vtkIntArray.h>
23 #include <vtkCellData.h>
24 #include "guimainwindow.h"
26 SetBoundaryCode::SetBoundaryCode()
28 m_FeatureAngle = 180.0;
29 m_NewBoundaryCode = 1;
30 m_OldBoundaryCode = -1;
31 setSurfaceIteration();
32 setQuickSave(true);
35 void SetBoundaryCode::pass1()
37 if(!(m_SelectAllVisible || m_OnlyPickedCell || m_OnlyPickedCellAndNeighbours)) {
38 using namespace GeometryTools;
39 double fa = m_FeatureAngle*M_PI/180.0;
41 QSet <int> DBC;
42 GuiMainWindow::pointer()->getDisplayBoundaryCodes(DBC);
43 DBC.insert(9999);
44 EG_VTKDCC(vtkIntArray, cell_code, m_Grid, "cell_code");
46 for (int i = 0; i < pair.size(); ++i) {
47 int bc2 = cell_code->GetValue(pair[i].item2);
48 if (m_ProcessAll) {
49 if (bc2 == m_OldBoundaryCode || m_OldBoundaryCode < 0) {
50 vec3_t n1 = cellNormal(m_Grid, pair[i].item1);
51 vec3_t n2 = cellNormal(m_Grid, pair[i].item2);
52 n1.normalise();
53 n2.normalise();
54 if (GeometryTools::angle(n1, n2) > fa) {
55 pair[i].terminate = true;
56 } else {
57 pair[i].terminate = false;
59 } else {
60 pair[i].terminate = true;
62 } else {
63 if (DBC.contains(bc2)) {
64 if (bc2 == m_OldBoundaryCode || m_OldBoundaryCode < 0) {
65 vec3_t n1 = cellNormal(m_Grid, pair[i].item1);
66 vec3_t n2 = cellNormal(m_Grid, pair[i].item2);
67 n1.normalise();
68 n2.normalise();
69 if (GeometryTools::angle(n1, n2) > fa) {
70 pair[i].terminate = true;
71 } else {
72 pair[i].terminate = false;
75 } else {
76 pair[i].terminate = true;
83 void SetBoundaryCode::pass2()
85 EG_VTKDCC(vtkIntArray, cell_code, m_Grid, "cell_code");
86 vtkIdType cellId;
87 if(m_SelectAllVisible) {
88 QSet <int> DBC;
89 GuiMainWindow::pointer()->getDisplayBoundaryCodes(DBC);
90 DBC.insert(m_NewBoundaryCode);
91 foreach(cellId, cells) {
92 int bc = cell_code->GetValue(cellId);
93 if(DBC.contains(bc)){
94 cell_code->SetValue(cellId, m_NewBoundaryCode);
97 } else if (m_OnlyPickedCell) {
98 cout<<"this->getStart()="<<this->getStart()<<endl;
99 cell_code->SetValue(this->getStart(), m_NewBoundaryCode);
100 } else if (m_OnlyPickedCellAndNeighbours) {
101 cell_code->SetValue(this->getStart(), m_NewBoundaryCode);
102 foreach (cellId, c2c[this->getStart()]) {
103 cell_code->SetValue(cellId, m_NewBoundaryCode);
105 } else {
106 foreach (cellId, item) {
107 cell_code->SetValue(cellId, m_NewBoundaryCode);
110 m_Grid->Modified();