replaced abort() with EG_BUG
[engrid.git] / src / setboundarycode.cpp
bloba624b8e1005850089e84eae868e19ab269573bce
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 || OnlyPickedCell || OnlyPickedCellAndNeighbours)) {
39 using namespace GeometryTools;
40 double fa = feature_angle*M_PI/180.0;
42 QSet <int> DBC;
43 GuiMainWindow::pointer()->getDisplayBoundaryCodes(DBC);
44 DBC.insert(boundary_code);
46 EG_VTKDCC(vtkIntArray, cell_code, grid, "cell_code");
48 for (int i = 0; i < pair.size(); ++i) {
49 int bc1 = cell_code->GetValue(pair[i].item1);
50 int bc2 = cell_code->GetValue(pair[i].item2);
51 if(ProcessAll){
52 vec3_t n1 = cellNormal(grid, pair[i].item1);
53 vec3_t n2 = cellNormal(grid, pair[i].item2);
54 double cosa = (n1*n2)/(n1.abs()*n2.abs());
55 if (fabs(acos(cosa)) > fa) {
56 pair[i].terminate = true;
57 } else {
58 pair[i].terminate = false;
60 } else {
61 if(DBC.contains(bc1) && DBC.contains(bc2)){
62 vec3_t n1 = cellNormal(grid, pair[i].item1);
63 vec3_t n2 = cellNormal(grid, pair[i].item2);
64 double cosa = (n1*n2)/(n1.abs()*n2.abs());
65 if (fabs(acos(cosa)) > fa) {
66 pair[i].terminate = true;
67 } else {
68 pair[i].terminate = false;
70 } else {
71 pair[i].terminate = true;
78 void SetBoundaryCode::pass2()
80 EG_VTKDCC(vtkIntArray, cell_code, grid, "cell_code");
81 vtkIdType cellId;
82 if(SelectAllVisible) {
83 QSet <int> DBC;
84 GuiMainWindow::pointer()->getDisplayBoundaryCodes(DBC);
85 DBC.insert(boundary_code);
86 foreach(cellId, cells) {
87 int bc = cell_code->GetValue(cellId);
88 if(DBC.contains(bc)){
89 cell_code->SetValue(cellId, boundary_code);
92 } else if (OnlyPickedCell) {
93 cout<<"this->getStart()="<<this->getStart()<<endl;
94 cell_code->SetValue(this->getStart(), boundary_code);
95 } else if (OnlyPickedCellAndNeighbours) {
96 cell_code->SetValue(this->getStart(), boundary_code);
97 foreach (cellId, c2c[this->getStart()]) {
98 cell_code->SetValue(cellId, boundary_code);
100 } else {
101 foreach (cellId, item) {
102 cell_code->SetValue(cellId, boundary_code);
105 grid->Modified();