created common base clase for surface projection implementations
[engrid.git] / src / libengrid / booleangeometryoperation.h
blob55a50bbdcf0cff856f52d87fd71b9df3441f250b
1 //
2 // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
3 // + +
4 // + This file is part of enGrid. +
5 // + +
6 // + Copyright 2008-2012 enGits GmbH +
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 #ifndef BOOLEANGEOMETRYOPERATION_H
24 #define BOOLEANGEOMETRYOPERATION_H
26 class BooleanGeometryOperation;
28 #include "surfacealgorithm.h"
29 #include "trisurfaceprojection.h"
31 class BooleanGeometryOperation : public SurfaceAlgorithm
34 protected: // data types
36 struct edge_t
38 vtkIdType id1, id2;
39 //vtkIdType id_face;
40 //int i_tri;
41 int bc;
44 struct tri_t
46 vtkIdType id1, id2, id3;
47 int bc;
50 private: // attributes
52 edge_t m_CurrentEdge;
53 QList<tri_t> m_Triangles;
54 tri_t m_CurrentTriangle;
55 QVector<int> m_OpenNode;
56 QVector<bool> m_SplitNode;
57 QVector<QSet<vtkIdType> > m_Node2Cell;
58 QVector<QSet<vtkIdType> > m_Node2Node;
60 protected: // attributes
62 vtkUnstructuredGrid *m_ShapeGrid1;
63 vtkUnstructuredGrid *m_ShapeGrid2;
64 TriSurfaceProjection m_Proj1;
65 TriSurfaceProjection m_Proj2;
66 MeshPartition m_Part1;
67 MeshPartition m_Part2;
68 int m_Side1;
69 int m_Side2;
70 QList<int> m_BCs1;
71 QList<int> m_BCs2;
72 int m_NumCutLayers;
74 private: // methods
76 bool fillGap_prepare();
77 void fillGap_updateOpenNode(vtkIdType id_node);
78 bool fillGap_onDifferentSides(vtkIdType id1, vtkIdType id2, vtkIdType id3);
79 bool fillGap_step();
80 void fillGap_createTriangles();
82 void smoothJunction_triangulate();
83 void smoothJunction_updateBCs();
84 double smoothJunction_mesher();
86 protected: // methods;
88 void deleteNodes();
89 void checkOrientation();
90 void fillGap();
91 void smoothJunction();
93 public: // methods
95 template <class C> BooleanGeometryOperation(vtkUnstructuredGrid *grid, const C &bcs1, const C &bcs2, int side1, int side2);
97 virtual void operate();
99 void setNumCutLayers(int N) { m_NumCutLayers = N; }
103 template <class C>
104 BooleanGeometryOperation::BooleanGeometryOperation(vtkUnstructuredGrid *grid, const C &bcs1, const C &bcs2, int side1, int side2)
106 setGrid(grid);
107 m_Part1.setGrid(m_Grid);
108 m_Part2.setGrid(m_Grid);
109 m_Part1.setBCs(bcs1);
110 m_Part2.setBCs(bcs2);
111 m_ShapeGrid1 = vtkUnstructuredGrid::New();
112 m_ShapeGrid2 = vtkUnstructuredGrid::New();
113 m_Part1.extractToVtkGrid(m_ShapeGrid1);
114 m_Part2.extractToVtkGrid(m_ShapeGrid2);
115 QVector<vtkIdType> cells1;
116 getAllCells(cells1, m_ShapeGrid1);
117 QVector<vtkIdType> cells2;
118 getAllCells(cells2, m_ShapeGrid2);
119 m_Proj1.setBackgroundGrid(m_ShapeGrid1, cells1);
120 m_Proj2.setBackgroundGrid(m_ShapeGrid2, cells2);
121 m_Side1 = side1;
122 m_Side2 = side2;
123 m_BCs1.clear();
124 m_BCs2.clear();
125 foreach (int bc, bcs1) {
126 m_BCs1.append(bc);
128 foreach (int bc, bcs2) {
129 m_BCs2.append(bc);
131 m_NumCutLayers = 1;
137 #endif // BOOLEANGEOMETRYOPERATION_H