2 // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
4 // + This file is part of enGrid. +
6 // + Copyright 2008-2013 enGits GmbH +
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"
26 #include "guimainwindow.h"
28 NeutralWriter::NeutralWriter()
30 setFormat("Neutral mesh files(*.mesh)");
33 void NeutralWriter::operate()
36 QFileInfo
file_info(GuiMainWindow::pointer()->getFilename());
37 readOutputFileName(file_info
.completeBaseName() + ".mesh");
39 QFile
file(getFileName());
40 file
.open(QIODevice::WriteOnly
| QIODevice::Text
);
42 f
<< m_Grid
->GetNumberOfPoints() << "\n";
43 for (vtkIdType pointId
= 0; pointId
< m_Grid
->GetNumberOfPoints(); ++pointId
) {
45 m_Grid
->GetPoints()->GetPoint(pointId
, x
.data());
46 f
<< x
[0] << " " << x
[1] << " " << x
[2] << "\n";
50 for (vtkIdType cellId
= 0; cellId
< m_Grid
->GetNumberOfCells(); ++cellId
) {
51 vtkIdType cellType
= m_Grid
->GetCellType(cellId
);
52 if ((cellType
!= VTK_TRIANGLE
) && (cellType
!= VTK_TETRA
)) {
53 EG_ERR_RETURN("only simplex elements are allowed for the NEUTRAL format");
55 if (isSurface(cellId
, m_Grid
)) {
62 for (vtkIdType cellId
= 0; cellId
< m_Grid
->GetNumberOfCells(); ++cellId
) {
63 if (!isSurface(cellId
, m_Grid
)) {
65 m_Grid
->GetCellPoints(cellId
, Npts
, pts
);
66 f
<< "1 " << pts
[0]+1 << " " << pts
[1]+1 << " " << pts
[3]+1 << " " << pts
[2]+1 << "\n";
70 EG_VTKDCC(vtkIntArray
, cell_code
, m_Grid
, "cell_code");
71 for (vtkIdType cellId
= 0; cellId
< m_Grid
->GetNumberOfCells(); ++cellId
) {
72 if (isSurface(cellId
, m_Grid
)) {
74 m_Grid
->GetCellPoints(cellId
, Npts
, pts
);
75 f
<< 1;//cell_code->GetValue(cellId);
76 f
<< " " << pts
[2]+1 << " " << pts
[1]+1 << " " << pts
[0]+1 << "\n";