DeleteSetOfPoints function working
[engrid.git] / neutralwriter.cpp
blob32a8a94a529385fc4ca1468b21ad1eb163ed94a1
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 "neutralwriter.h"
25 NeutralWriter::NeutralWriter()
27 setFormat("Neutral mesh files(*.mesh)");
30 void NeutralWriter::operate()
32 try {
33 readOutputFileName();
34 if (isValid()) {
35 QFile file(getFileName());
36 file.open(QIODevice::WriteOnly | QIODevice::Text);
37 QTextStream f(&file);
38 f << grid->GetNumberOfPoints() << "\n";
39 for (vtkIdType pointId = 0; pointId < grid->GetNumberOfPoints(); ++pointId) {
40 vec3_t x;
41 grid->GetPoints()->GetPoint(pointId, x.data());
42 f << x[0] << " " << x[1] << " " << x[2] << "\n";
44 vtkIdType Nvol = 0;
45 vtkIdType Nsurf = 0;
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)) {
52 ++Nsurf;
53 } else {
54 ++Nvol;
57 f << Nvol << "\n";
58 for (vtkIdType cellId = 0; cellId < grid->GetNumberOfCells(); ++cellId) {
59 if (!isSurface(cellId, grid)) {
60 vtkIdType Npts, *pts;
61 grid->GetCellPoints(cellId, Npts, pts);
62 f << "1 " << pts[0]+1 << " " << pts[1]+1 << " " << pts[3]+1 << " " << pts[2]+1 << "\n";
65 f << Nsurf << "\n";
66 EG_VTKDCC(vtkIntArray, cell_code, grid, "cell_code");
67 for (vtkIdType cellId = 0; cellId < grid->GetNumberOfCells(); ++cellId) {
68 if (isSurface(cellId, grid)) {
69 vtkIdType Npts, *pts;
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";
76 } catch (Error err) {
77 err.display();