2010-05-12 13:27:55 +00:00
|
|
|
/*---------------------------------------------------------------------------*\
|
|
|
|
========= |
|
2013-12-11 16:09:41 +00:00
|
|
|
\\ / F ield | foam-extend: Open Source CFD
|
2018-05-29 07:35:20 +00:00
|
|
|
\\ / O peration | Version: 4.1
|
2015-05-17 13:32:07 +00:00
|
|
|
\\ / A nd | Web: http://www.foam-extend.org
|
|
|
|
\\/ M anipulation | For copyright notice see file Copyright
|
2010-05-12 13:27:55 +00:00
|
|
|
-------------------------------------------------------------------------------
|
|
|
|
License
|
2013-12-11 16:09:41 +00:00
|
|
|
This file is part of foam-extend.
|
2010-05-12 13:27:55 +00:00
|
|
|
|
2013-12-11 16:09:41 +00:00
|
|
|
foam-extend is free software: you can redistribute it and/or modify it
|
2010-05-12 13:27:55 +00:00
|
|
|
under the terms of the GNU General Public License as published by the
|
2013-12-11 16:09:41 +00:00
|
|
|
Free Software Foundation, either version 3 of the License, or (at your
|
2010-05-12 13:27:55 +00:00
|
|
|
option) any later version.
|
|
|
|
|
2013-12-11 16:09:41 +00:00
|
|
|
foam-extend is distributed in the hope that it will be useful, but
|
|
|
|
WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
General Public License for more details.
|
2010-05-12 13:27:55 +00:00
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
2013-12-11 16:09:41 +00:00
|
|
|
along with foam-extend. If not, see <http://www.gnu.org/licenses/>.
|
2010-05-12 13:27:55 +00:00
|
|
|
|
|
|
|
Description
|
|
|
|
|
|
|
|
\*---------------------------------------------------------------------------*/
|
|
|
|
|
2018-02-20 15:48:10 +00:00
|
|
|
#include "vtkPVFoam.H"
|
2010-05-12 13:27:55 +00:00
|
|
|
|
|
|
|
// Foam includes
|
2018-02-20 15:48:10 +00:00
|
|
|
#include "vtkPVFoamPoints.H"
|
2010-05-12 13:27:55 +00:00
|
|
|
|
|
|
|
// VTK includes
|
|
|
|
#include "vtkPoints.h"
|
|
|
|
#include "vtkPolyData.h"
|
|
|
|
#include "vtkCellArray.h"
|
|
|
|
|
|
|
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
|
|
|
|
2018-02-20 15:48:10 +00:00
|
|
|
vtkPolyData* Foam::vtkPVFoam::faceZoneVTKMesh
|
2010-05-12 13:27:55 +00:00
|
|
|
(
|
|
|
|
const fvMesh& mesh,
|
2010-08-26 14:22:03 +00:00
|
|
|
const labelList& faceLabels
|
2010-05-12 13:27:55 +00:00
|
|
|
)
|
|
|
|
{
|
2010-08-26 14:22:03 +00:00
|
|
|
vtkPolyData* vtkmesh = vtkPolyData::New();
|
|
|
|
|
2010-05-12 13:27:55 +00:00
|
|
|
if (debug)
|
|
|
|
{
|
2018-02-20 15:48:10 +00:00
|
|
|
Info<< "<beg> Foam::vtkPVFoam::faceZoneVTKMesh" << endl;
|
2010-08-26 14:22:03 +00:00
|
|
|
printMemory();
|
2010-05-12 13:27:55 +00:00
|
|
|
}
|
|
|
|
|
2010-08-26 14:22:03 +00:00
|
|
|
// Construct primitivePatch of faces in faceZone
|
2010-05-12 13:27:55 +00:00
|
|
|
|
2011-03-21 20:24:36 +00:00
|
|
|
const faceList& meshFaces = mesh.allFaces();
|
2010-05-12 13:27:55 +00:00
|
|
|
faceList patchFaces(faceLabels.size());
|
2011-03-21 20:24:36 +00:00
|
|
|
label npf = 0;
|
|
|
|
|
|
|
|
// Filter faces that are not in live mesh
|
|
|
|
// Bug fix. HJ, 21/Mar/2011
|
2010-05-12 13:27:55 +00:00
|
|
|
forAll(faceLabels, faceI)
|
|
|
|
{
|
2011-03-21 20:24:36 +00:00
|
|
|
if (faceLabels[faceI] < mesh.nFaces())
|
|
|
|
{
|
|
|
|
patchFaces[npf] = meshFaces[faceLabels[faceI]];
|
|
|
|
npf++;
|
|
|
|
}
|
2010-05-12 13:27:55 +00:00
|
|
|
}
|
2011-03-21 20:24:36 +00:00
|
|
|
patchFaces.setSize(npf);
|
|
|
|
|
2010-08-26 14:22:03 +00:00
|
|
|
primitiveFacePatch p(patchFaces, mesh.points());
|
2010-05-12 13:27:55 +00:00
|
|
|
|
|
|
|
|
2010-08-26 14:22:03 +00:00
|
|
|
// The balance of this routine should be identical to patchVTKMesh
|
2010-05-12 13:27:55 +00:00
|
|
|
|
|
|
|
// Convert Foam mesh vertices to VTK
|
|
|
|
const pointField& points = p.localPoints();
|
|
|
|
|
2010-08-26 14:22:03 +00:00
|
|
|
vtkPoints* vtkpoints = vtkPoints::New();
|
2011-03-21 20:24:36 +00:00
|
|
|
vtkpoints->Allocate(points.size());
|
2010-05-12 13:27:55 +00:00
|
|
|
forAll(points, i)
|
|
|
|
{
|
2018-02-20 15:48:10 +00:00
|
|
|
vtkPVFoamInsertNextPoint(vtkpoints, points[i]);
|
2010-05-12 13:27:55 +00:00
|
|
|
}
|
2010-08-26 14:22:03 +00:00
|
|
|
|
2010-05-12 13:27:55 +00:00
|
|
|
vtkmesh->SetPoints(vtkpoints);
|
|
|
|
vtkpoints->Delete();
|
|
|
|
|
2010-08-26 14:22:03 +00:00
|
|
|
|
2010-05-12 13:27:55 +00:00
|
|
|
// Add faces as polygons
|
|
|
|
const faceList& faces = p.localFaces();
|
|
|
|
|
|
|
|
vtkCellArray* vtkcells = vtkCellArray::New();
|
2010-08-26 14:22:03 +00:00
|
|
|
vtkcells->Allocate( faces.size() );
|
|
|
|
|
2010-05-12 13:27:55 +00:00
|
|
|
forAll(faces, faceI)
|
|
|
|
{
|
|
|
|
const face& f = faces[faceI];
|
|
|
|
vtkIdType nodeIds[f.size()];
|
|
|
|
|
2010-08-26 14:22:03 +00:00
|
|
|
forAll(f, fp)
|
2010-05-12 13:27:55 +00:00
|
|
|
{
|
|
|
|
nodeIds[fp] = f[fp];
|
|
|
|
}
|
|
|
|
vtkcells->InsertNextCell(f.size(), nodeIds);
|
|
|
|
}
|
|
|
|
|
|
|
|
vtkmesh->SetPolys(vtkcells);
|
|
|
|
vtkcells->Delete();
|
2010-08-26 14:22:03 +00:00
|
|
|
|
|
|
|
if (debug)
|
|
|
|
{
|
2018-02-20 15:48:10 +00:00
|
|
|
Info<< "<end> Foam::vtkPVFoam::faceZoneVTKMesh" << endl;
|
2010-08-26 14:22:03 +00:00
|
|
|
printMemory();
|
|
|
|
}
|
|
|
|
|
|
|
|
return vtkmesh;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-02-20 15:48:10 +00:00
|
|
|
vtkPolyData* Foam::vtkPVFoam::pointZoneVTKMesh
|
2010-08-26 14:22:03 +00:00
|
|
|
(
|
|
|
|
const fvMesh& mesh,
|
|
|
|
const labelList& pointLabels
|
|
|
|
)
|
|
|
|
{
|
|
|
|
vtkPolyData* vtkmesh = vtkPolyData::New();
|
|
|
|
|
|
|
|
if (debug)
|
|
|
|
{
|
2018-02-20 15:48:10 +00:00
|
|
|
Info<< "<beg> Foam::vtkPVFoam::pointZoneVTKMesh" << endl;
|
2010-08-26 14:22:03 +00:00
|
|
|
printMemory();
|
|
|
|
}
|
|
|
|
|
2011-03-21 20:24:36 +00:00
|
|
|
const pointField& meshPoints = mesh.allPoints();
|
|
|
|
|
|
|
|
// Filter point labels to include only live points
|
|
|
|
labelList pl(pointLabels.size());
|
|
|
|
label npl = 0;
|
|
|
|
|
|
|
|
forAll (pointLabels, pointI)
|
|
|
|
{
|
|
|
|
if (pointLabels[pointI] < mesh.nPoints())
|
|
|
|
{
|
|
|
|
pl[npl] = pointLabels[pointI];
|
|
|
|
npl++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
pl.setSize(npl);
|
2010-08-26 14:22:03 +00:00
|
|
|
|
|
|
|
vtkPoints *vtkpoints = vtkPoints::New();
|
2011-03-21 20:24:36 +00:00
|
|
|
vtkpoints->Allocate( pl.size());
|
2010-08-26 14:22:03 +00:00
|
|
|
|
|
|
|
forAll(pointLabels, pointI)
|
|
|
|
{
|
2018-02-20 15:48:10 +00:00
|
|
|
vtkPVFoamInsertNextPoint(vtkpoints, meshPoints[pl[pointI]]);
|
2010-08-26 14:22:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
vtkmesh->SetPoints(vtkpoints);
|
|
|
|
vtkpoints->Delete();
|
|
|
|
|
|
|
|
if (debug)
|
|
|
|
{
|
2018-02-20 15:48:10 +00:00
|
|
|
Info<< "<beg> Foam::vtkPVFoam::pointZoneVTKMesh" << endl;
|
2010-08-26 14:22:03 +00:00
|
|
|
printMemory();
|
|
|
|
}
|
|
|
|
|
|
|
|
return vtkmesh;
|
2010-05-12 13:27:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// ************************************************************************* //
|