2 // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
4 // + This file is part of enGrid. +
6 // + Copyright 2008,2009 Oliver Gloth +
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. +
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. +
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/>. +
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;
32 setSurfaceIteration();
36 void SetBoundaryCode::pass1()
40 using namespace GeometryTools
;
41 double fa
= feature_angle
*M_PI
/180.0;
42 cout
<<"fa="<<fa
<<endl
;
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
;
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;
63 pair
[i
].terminate
= false;
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;
74 pair
[i
].terminate
= false;
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;
88 pair[i].terminate = false;
92 pair[i].terminate = true;
99 void SetBoundaryCode::pass2()
101 EG_VTKDCC(vtkIntArray
, cell_code
, grid
, "cell_code");
103 if(!SelectAllVisible
){
104 foreach(cellId
, item
) {
105 cell_code
->SetValue(cellId
, boundary_code
);
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
);