1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | foam-extend: Open Source CFD
4 \\ / O peration | Version: 3.2
5 \\ / A nd | Web: http://www.foam-extend.org
6 \\/ M anipulation | For copyright notice see file Copyright
7 -------------------------------------------------------------------------------
9 This file is part of foam-extend.
11 foam-extend is free software: you can redistribute it and/or modify it
12 under the terms of the GNU General Public License as published by the
13 Free Software Foundation, either version 3 of the License, or (at your
14 option) any later version.
16 foam-extend is distributed in the hope that it will be useful, but
17 WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 General Public License for more details.
21 You should have received a copy of the GNU General Public License
22 along with foam-extend. If not, see <http://www.gnu.org/licenses/>.
26 \*---------------------------------------------------------------------------*/
28 #include "vtkPV3Foam.H"
33 #include "vtkPV3FoamPoints.H"
36 #include "vtkPoints.h"
37 #include "vtkPolyData.h"
38 #include "vtkCellArray.h"
40 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
42 vtkPolyData* Foam::vtkPV3Foam::faceSetVTKMesh
48 vtkPolyData* vtkmesh = vtkPolyData::New();
52 Info<< "<beg> Foam::vtkPV3Foam::faceSetVTKMesh" << endl;
56 // Construct primitivePatch of faces in fSet.
58 const faceList& meshFaces = mesh.faces();
59 faceList patchFaces(fSet.size());
61 forAllConstIter(faceSet, fSet, iter)
63 patchFaces[faceI++] = meshFaces[iter.key()];
65 primitiveFacePatch p(patchFaces, mesh.points());
68 // The balance of this routine should be identical to patchVTKMesh
70 // Convert Foam mesh vertices to VTK
71 const pointField& points = p.localPoints();
73 vtkPoints *vtkpoints = vtkPoints::New();
74 vtkpoints->Allocate( points.size() );
77 vtkPV3FoamInsertNextPoint(vtkpoints, points[i]);
79 vtkmesh->SetPoints(vtkpoints);
82 // Add faces as polygons
83 const faceList& faces = p.localFaces();
85 vtkCellArray* vtkcells = vtkCellArray::New();
86 vtkcells->Allocate( faces.size() );
90 const face& f = faces[faceI];
91 vtkIdType nodeIds[f.size()];
97 vtkcells->InsertNextCell(f.size(), nodeIds);
100 vtkmesh->SetPolys(vtkcells);
105 Info<< "<end> Foam::vtkPV3Foam::faceSetVTKMesh" << endl;
113 vtkPolyData* Foam::vtkPV3Foam::pointSetVTKMesh
119 vtkPolyData* vtkmesh = vtkPolyData::New();
123 Info<< "<beg> Foam::vtkPV3Foam::pointSetVTKMesh" << endl;
127 const pointField& meshPoints = mesh.points();
129 vtkPoints *vtkpoints = vtkPoints::New();
130 vtkpoints->Allocate( pSet.size() );
132 forAllConstIter(pointSet, pSet, iter)
134 vtkPV3FoamInsertNextPoint(vtkpoints, meshPoints[iter.key()]);
137 vtkmesh->SetPoints(vtkpoints);
142 Info<< "<end> Foam::vtkPV3Foam::pointSetVTKMesh" << endl;
150 // ************************************************************************* //