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 "neutralwriter.h"
25 NeutralWriter::NeutralWriter()
27 setFormat("Neutral mesh files(*.mesh)");
30 void NeutralWriter::operate()
35 QFile
file(getFileName());
36 file
.open(QIODevice::WriteOnly
| QIODevice::Text
);
38 f
<< grid
->GetNumberOfPoints() << "\n";
39 for (vtkIdType pointId
= 0; pointId
< grid
->GetNumberOfPoints(); ++pointId
) {
41 grid
->GetPoints()->GetPoint(pointId
, x
.data());
42 f
<< x
[0] << " " << x
[1] << " " << x
[2] << "\n";
46 for (vtkIdType cellId
= 0; cellId
< grid
->GetNumberOfCells(); ++cellId
) {
47 vtkIdType cellType
= grid
->GetCellType(cellId
);
48 if ((cellType
!= VTK_TRIANGLE
) && (cellType
!= VTK_TETRA
)) {
49 EG_ERR_RETURN("only simplex elements are allowed for the NEUTRAL format");
51 if (isSurface(cellId
, grid
)) {
58 for (vtkIdType cellId
= 0; cellId
< grid
->GetNumberOfCells(); ++cellId
) {
59 if (!isSurface(cellId
, grid
)) {
61 grid
->GetCellPoints(cellId
, Npts
, pts
);
62 f
<< "1 " << pts
[0]+1 << " " << pts
[1]+1 << " " << pts
[3]+1 << " " << pts
[2]+1 << "\n";
66 EG_VTKDCC(vtkIntArray
, cell_code
, grid
, "cell_code");
67 for (vtkIdType cellId
= 0; cellId
< grid
->GetNumberOfCells(); ++cellId
) {
68 if (isSurface(cellId
, grid
)) {
70 grid
->GetCellPoints(cellId
, Npts
, pts
);
71 f
<< 1;//cell_code->GetValue(cellId);
72 f
<< " " << pts
[2]+1 << " " << pts
[1]+1 << " " << pts
[0]+1 << "\n";