Improved setboundarycode function/dialog:
[engrid.git] / src / setboundarycode.cpp
blob526a57c753984cc47f77db8a483c8b37e327807a
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 // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
23 #include "setboundarycode.h"
24 #include <vtkIntArray.h>
25 #include <vtkCellData.h>
26 #include "guimainwindow.h"
28 SetBoundaryCode::SetBoundaryCode()
30 feature_angle = 180.0;
31 boundary_code = 1;
32 setSurfaceIteration();
33 setQuickSave(true);
36 void SetBoundaryCode::pass1()
38 if(!SelectAllVisible)
40 using namespace GeometryTools;
41 double fa = feature_angle*M_PI/180.0;
42 cout<<"fa="<<fa<<endl;
44 QSet <int> DBC;
45 GuiMainWindow::pointer()->getDisplayBoundaryCodes(DBC);
46 DBC.insert(boundary_code);
48 EG_VTKDCC(vtkIntArray, cell_code, grid, "cell_code");
50 for (int i = 0; i < pair.size(); ++i) {
52 int bc1 = cell_code->GetValue(pair[i].item1);
53 int bc2 = cell_code->GetValue(pair[i].item2);
54 cout<<"bc1="<<bc1<<" bc2="<<bc2<<" DBC="<<DBC<<endl;
56 if(ProcessAll){
57 vec3_t n1 = cellNormal(grid, pair[i].item1);
58 vec3_t n2 = cellNormal(grid, pair[i].item2);
59 double cosa = (n1*n2)/(n1.abs()*n2.abs());
60 if (fabs(acos(cosa)) > fa) {
61 pair[i].terminate = true;
62 } else {
63 pair[i].terminate = false;
66 else{
67 if(DBC.contains(bc1) && DBC.contains(bc2)){
68 vec3_t n1 = cellNormal(grid, pair[i].item1);
69 vec3_t n2 = cellNormal(grid, pair[i].item2);
70 double cosa = (n1*n2)/(n1.abs()*n2.abs());
71 if (fabs(acos(cosa)) > fa) {
72 pair[i].terminate = true;
73 } else {
74 pair[i].terminate = false;
77 else{
78 pair[i].terminate = true;
81 /* if(DBC.contains(bc1) && DBC.contains(bc2)){
82 vec3_t n1 = cellNormal(grid, pair[i].item1);
83 vec3_t n2 = cellNormal(grid, pair[i].item2);
84 double cosa = (n1*n2)/(n1.abs()*n2.abs());
85 if (fabs(acos(cosa)) > fa) {
86 pair[i].terminate = true;
87 } else {
88 pair[i].terminate = false;
91 else{
92 pair[i].terminate = true;
93 }*/
95 };//end of for loop
99 void SetBoundaryCode::pass2()
101 EG_VTKDCC(vtkIntArray, cell_code, grid, "cell_code");
102 vtkIdType cellId;
103 if(!SelectAllVisible){
104 foreach(cellId, item) {
105 cell_code->SetValue(cellId, boundary_code);
108 else{
109 QSet <int> DBC;
110 GuiMainWindow::pointer()->getDisplayBoundaryCodes(DBC);
111 DBC.insert(boundary_code);
112 foreach(cellId, cells) {
113 int bc = cell_code->GetValue(cellId);
114 if(DBC.contains(bc)){
115 cell_code->SetValue(cellId, boundary_code);