2 // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
4 // + This file is part of enGrid. +
6 // + Copyright 2008 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 "vtkEgExtractVolumeCells.h"
25 vtkStandardNewMacro(vtkEgExtractVolumeCells
)
27 vtkEgExtractVolumeCells::vtkEgExtractVolumeCells()
33 m_ExtrPyramids
= true;
38 void vtkEgExtractVolumeCells::SetX(vec3_t x
)
44 void vtkEgExtractVolumeCells::SetN(vec3_t n
)
50 void vtkEgExtractVolumeCells::SetClippingOn()
58 void vtkEgExtractVolumeCells::SetClippingOff()
67 void vtkEgExtractVolumeCells::SetAllOn()
75 void vtkEgExtractVolumeCells::SetAllOff()
83 void vtkEgExtractVolumeCells::SetTetrasOn()
91 void vtkEgExtractVolumeCells::SetTetrasOff()
99 void vtkEgExtractVolumeCells::SetPyramidsOn()
101 if (!m_ExtrPyramids
) {
102 m_ExtrPyramids
= true;
107 void vtkEgExtractVolumeCells::SetPyramidsOff()
109 if (m_ExtrPyramids
) {
110 m_ExtrPyramids
= false;
115 void vtkEgExtractVolumeCells::SetWedgesOn()
123 void vtkEgExtractVolumeCells::SetWedgesOff()
126 m_ExtrWedges
= false;
131 void vtkEgExtractVolumeCells::SetHexesOn()
139 void vtkEgExtractVolumeCells::SetHexesOff()
147 void vtkEgExtractVolumeCells::Setx(double x
)
153 void vtkEgExtractVolumeCells::Sety(double y
)
159 void vtkEgExtractVolumeCells::Setz(double z
)
165 void vtkEgExtractVolumeCells::Setnx(double nx
)
171 void vtkEgExtractVolumeCells::Setny(double ny
)
177 void vtkEgExtractVolumeCells::Setnz(double nz
)
184 void vtkEgExtractVolumeCells::ExecuteEg()
186 QSet
<vtkIdType
> ex_cells
;
187 for (vtkIdType id_cell
= 0; id_cell
< m_Input
->GetNumberOfCells(); ++id_cell
) {
188 if (isVolume(id_cell
, m_Input
)) {
190 vtkIdType type_cell
= m_Input
->GetCellType(id_cell
);
191 if (!m_ExtrTetras
&& type_cell
== VTK_TETRA
) {
194 if (!m_ExtrPyramids
&& type_cell
== VTK_PYRAMID
) {
197 if (!m_ExtrWedges
&& type_cell
== VTK_WEDGE
) {
200 if (!m_ExtrHexes
&& type_cell
== VTK_HEXAHEDRON
) {
203 if (m_Clip
&& select
) {
206 m_Input
->GetCellPoints(id_cell
, N_pts
, pts
);
207 for (int i_pts
= 0; i_pts
< N_pts
; ++i_pts
) {
209 m_Input
->GetPoints()->GetPoint(pts
[i_pts
],x
.data());
210 if ((x
- m_X
)*m_N
< 0) {
217 ex_cells
.insert(id_cell
);
221 QVector
<vtkIdType
> cells(ex_cells
.size());
222 qCopy(ex_cells
.begin(), ex_cells
.end(), cells
.begin());
223 QVector
<vtkIdType
> nodes
;
225 getNodesFromCells(cells
, nodes
, m_Input
);
226 createNodeMapping(nodes
, _nodes
, m_Input
);
227 allocateGrid(m_Output
, cells
.size(), nodes
.size());
228 foreach(vtkIdType id_node
, nodes
) {
230 m_Input
->GetPoints()->GetPoint(id_node
, x
.data());
231 m_Output
->GetPoints()->SetPoint(_nodes
[id_node
], x
.data());
233 foreach(vtkIdType id_cell
, cells
) {
236 m_Input
->GetCellPoints(id_cell
, Npts
, pts
);
237 vtkIdType
*new_pts
= new vtkIdType
[Npts
];
238 for (int i
= 0; i
< Npts
; ++i
) {
239 new_pts
[i
] = _nodes
[pts
[i
]];
241 vtkIdType id_new_cell
= m_Output
->InsertNextCell(m_Input
->GetCellType(id_cell
), Npts
, new_pts
);
242 copyCellData(m_Input
, id_cell
, m_Output
, id_new_cell
);