1 // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
3 // + This file is part of enGrid. +
5 // + Copyright 2008-2014 enGits GmbH +
7 // + enGrid is free software: you can redistribute it and/or modify +
8 // + it under the terms of the GNU General Public License as published by +
9 // + the Free Software Foundation, either version 3 of the License, or +
10 // + (at your option) any later version. +
12 // + enGrid is distributed in the hope that it will be useful, +
13 // + but WITHOUT ANY WARRANTY; without even the implied warranty of +
14 // + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +
15 // + GNU General Public License for more details. +
17 // + You should have received a copy of the GNU General Public License +
18 // + along with enGrid. If not, see <http://www.gnu.org/licenses/>. +
20 // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
21 #include "neutralwriter.h"
24 #include "guimainwindow.h"
26 NeutralWriter::NeutralWriter()
28 setFormat("Neutral mesh files(*.mesh)");
31 void NeutralWriter::operate()
34 QFileInfo
file_info(GuiMainWindow::pointer()->getFilename());
35 readOutputFileName(file_info
.completeBaseName() + ".mesh");
37 QFile
file(getFileName());
38 file
.open(QIODevice::WriteOnly
| QIODevice::Text
);
40 f
<< m_Grid
->GetNumberOfPoints() << "\n";
41 for (vtkIdType pointId
= 0; pointId
< m_Grid
->GetNumberOfPoints(); ++pointId
) {
43 m_Grid
->GetPoints()->GetPoint(pointId
, x
.data());
44 f
<< x
[0] << " " << x
[1] << " " << x
[2] << "\n";
48 for (vtkIdType cellId
= 0; cellId
< m_Grid
->GetNumberOfCells(); ++cellId
) {
49 vtkIdType cellType
= m_Grid
->GetCellType(cellId
);
50 if ((cellType
!= VTK_TRIANGLE
) && (cellType
!= VTK_TETRA
)) {
51 EG_ERR_RETURN("only simplex elements are allowed for the NEUTRAL format");
53 if (isSurface(cellId
, m_Grid
)) {
60 for (vtkIdType cellId
= 0; cellId
< m_Grid
->GetNumberOfCells(); ++cellId
) {
61 if (!isSurface(cellId
, m_Grid
)) {
62 EG_GET_CELL(cellId
, m_Grid
);
63 f
<< "1 " << pts
[0]+1 << " " << pts
[1]+1 << " " << pts
[3]+1 << " " << pts
[2]+1 << "\n";
67 EG_VTKDCC(vtkIntArray
, cell_code
, m_Grid
, "cell_code");
68 for (vtkIdType cellId
= 0; cellId
< m_Grid
->GetNumberOfCells(); ++cellId
) {
69 if (isSurface(cellId
, m_Grid
)) {
70 EG_GET_CELL(cellId
, m_Grid
);
71 f
<< 1;//cell_code->GetValue(cellId);
72 f
<< " " << pts
[2]+1 << " " << pts
[1]+1 << " " << pts
[0]+1 << "\n";