1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2008 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 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 "vtkPV3FoamInsertNextPoint.H"
37 #include "vtkPoints.h"
38 #include "vtkPolyData.h"
39 #include "vtkCellArray.h"
41 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
43 void Foam::vtkPV3Foam::addFaceSetMesh
52 Info<< "<beg> Foam::vtkPV3Foam::addFaceSetMesh" << 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 addPatchMesh
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(p.size());
89 const face& f = faces[faceI];
90 vtkIdType nodeIds[f.size()];
96 vtkcells->InsertNextCell(f.size(), nodeIds);
99 vtkmesh->SetPolys(vtkcells);
104 Info<< "<end> Foam::vtkPV3Foam::addFaceSetMesh" << endl;
110 void Foam::vtkPV3Foam::addPointSetMesh
113 const pointSet& pSet,
119 Info<< "<beg> Foam::vtkPV3Foam::addPointSetMesh" << endl;
123 const pointField& meshPoints = mesh.points();
125 vtkPoints *vtkpoints = vtkPoints::New();
126 vtkpoints->Allocate(pSet.size());
128 forAllConstIter(pointSet, pSet, iter)
130 vtkPV3FoamInsertNextPoint(vtkpoints, meshPoints[iter.key()]);
133 vtkmesh->SetPoints(vtkpoints);
138 Info<< "<end> Foam::vtkPV3Foam::addPointSetMesh" << endl;
143 // ************************************************************************* //