1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd.
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
11 OpenFOAM is free software: you can redistribute it and/or modify it
12 under the terms of the GNU General Public License as published by
13 the Free Software Foundation, either version 3 of the License, or
14 (at your option) any later version.
16 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 You should have received a copy of the GNU General Public License
22 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
24 \*---------------------------------------------------------------------------*/
26 #include "vtkPV3Foam.H"
31 #include "vtkOpenFOAMPoints.H"
34 #include "vtkPoints.h"
35 #include "vtkPolyData.h"
36 #include "vtkCellArray.h"
38 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
40 vtkPolyData* Foam::vtkPV3Foam::faceSetVTKMesh
46 vtkPolyData* vtkmesh = vtkPolyData::New();
50 Info<< "<beg> Foam::vtkPV3Foam::faceSetVTKMesh" << endl;
54 // Construct primitivePatch of faces in fSet.
56 const faceList& meshFaces = mesh.faces();
57 faceList patchFaces(fSet.size());
59 forAllConstIter(faceSet, fSet, iter)
61 patchFaces[faceI++] = meshFaces[iter.key()];
63 primitiveFacePatch p(patchFaces, mesh.points());
66 // The balance of this routine should be identical to patchVTKMesh
68 // Convert OpenFOAM mesh vertices to VTK
69 const pointField& points = p.localPoints();
71 vtkPoints* vtkpoints = vtkPoints::New();
72 vtkpoints->Allocate(points.size());
75 vtkInsertNextOpenFOAMPoint(vtkpoints, points[i]);
77 vtkmesh->SetPoints(vtkpoints);
80 // Add faces as polygons
81 const faceList& faces = p.localFaces();
83 vtkCellArray* vtkcells = vtkCellArray::New();
84 vtkcells->Allocate(faces.size());
88 const face& f = faces[faceI];
89 vtkIdType nodeIds[f.size()];
95 vtkcells->InsertNextCell(f.size(), nodeIds);
98 vtkmesh->SetPolys(vtkcells);
103 Info<< "<end> Foam::vtkPV3Foam::faceSetVTKMesh" << endl;
111 vtkPolyData* Foam::vtkPV3Foam::pointSetVTKMesh
117 vtkPolyData* vtkmesh = vtkPolyData::New();
121 Info<< "<beg> Foam::vtkPV3Foam::pointSetVTKMesh" << endl;
125 const pointField& meshPoints = mesh.points();
127 vtkPoints* vtkpoints = vtkPoints::New();
128 vtkpoints->Allocate(pSet.size());
130 forAllConstIter(pointSet, pSet, iter)
132 vtkInsertNextOpenFOAMPoint(vtkpoints, meshPoints[iter.key()]);
135 vtkmesh->SetPoints(vtkpoints);
140 Info<< "<end> Foam::vtkPV3Foam::pointSetVTKMesh" << endl;
148 // ************************************************************************* //