1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright held by original author
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 the
13 Free Software Foundation; either version 2 of the License, or (at your
14 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, write to the Free Software Foundation,
23 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
27 \*---------------------------------------------------------------------------*/
29 #include "vtkPV3Foam.H"
34 #include "vtkPV3FoamPoints.H"
37 #include "vtkPoints.h"
38 #include "vtkPolyData.h"
39 #include "vtkCellArray.h"
41 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
43 vtkPolyData* Foam::vtkPV3Foam::faceSetVTKMesh
49 vtkPolyData* vtkmesh = vtkPolyData::New();
53 Info<< "<beg> Foam::vtkPV3Foam::faceSetVTKMesh" << endl;
57 // Construct primitivePatch of faces in fSet.
59 const faceList& meshFaces = mesh.faces();
60 faceList patchFaces(fSet.size());
62 forAllConstIter(faceSet, fSet, iter)
64 patchFaces[faceI++] = meshFaces[iter.key()];
66 primitiveFacePatch p(patchFaces, mesh.points());
69 // The balance of this routine should be identical to patchVTKMesh
71 // Convert Foam mesh vertices to VTK
72 const pointField& points = p.localPoints();
74 vtkPoints *vtkpoints = vtkPoints::New();
75 vtkpoints->Allocate( points.size() );
78 vtkPV3FoamInsertNextPoint(vtkpoints, points[i]);
80 vtkmesh->SetPoints(vtkpoints);
83 // Add faces as polygons
84 const faceList& faces = p.localFaces();
86 vtkCellArray* vtkcells = vtkCellArray::New();
87 vtkcells->Allocate( faces.size() );
91 const face& f = faces[faceI];
92 vtkIdType nodeIds[f.size()];
98 vtkcells->InsertNextCell(f.size(), nodeIds);
101 vtkmesh->SetPolys(vtkcells);
106 Info<< "<end> Foam::vtkPV3Foam::faceSetVTKMesh" << endl;
114 vtkPolyData* Foam::vtkPV3Foam::pointSetVTKMesh
120 vtkPolyData* vtkmesh = vtkPolyData::New();
124 Info<< "<beg> Foam::vtkPV3Foam::pointSetVTKMesh" << endl;
128 const pointField& meshPoints = mesh.points();
130 vtkPoints *vtkpoints = vtkPoints::New();
131 vtkpoints->Allocate( pSet.size() );
133 forAllConstIter(pointSet, pSet, iter)
135 vtkPV3FoamInsertNextPoint(vtkpoints, meshPoints[iter.key()]);
138 vtkmesh->SetPoints(vtkpoints);
143 Info<< "<end> Foam::vtkPV3Foam::pointSetVTKMesh" << endl;
151 // ************************************************************************* //