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"
32 #include "vtkPV3FoamInsertNextPoint.H"
35 #include "vtkPoints.h"
36 #include "vtkPolyData.h"
37 #include "vtkCellArray.h"
39 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
42 void Foam::vtkPV3Foam::addFaceZoneMesh
45 const labelList& faceLabels,
51 Info<< "<beg> Foam::vtkPV3Foam::addFaceZoneMesh" << endl;
55 // Construct primitivePatch of faces in fSet.
57 const faceList& meshFaces = mesh.faces();
58 faceList patchFaces(faceLabels.size());
59 forAll(faceLabels, faceI)
61 patchFaces[faceI] = meshFaces[faceLabels[faceI]];
63 primitiveFacePatch p(patchFaces, mesh.points());
66 // The balance of this routine should be identical to addPatchMesh
68 // Convert Foam mesh vertices to VTK
69 const pointField& points = p.localPoints();
71 vtkPoints *vtkpoints = vtkPoints::New();
72 vtkpoints->Allocate(p.size());
75 vtkPV3FoamInsertNextPoint(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(points.size());
87 const face& f = faces[faceI];
88 vtkIdType nodeIds[f.size()];
94 vtkcells->InsertNextCell(f.size(), nodeIds);
97 vtkmesh->SetPolys(vtkcells);
102 Info<< "<end> Foam::vtkPV3Foam::addFaceZoneMesh" << endl;
109 void Foam::vtkPV3Foam::addPointZoneMesh
112 const labelList& pointLabels,
118 Info<< "<beg> Foam::vtkPV3Foam::addPointZoneMesh" << endl;
122 const pointField& meshPoints = mesh.points();
124 vtkPoints *vtkpoints = vtkPoints::New();
125 vtkpoints->Allocate(pointLabels.size());
127 forAll(pointLabels, pointI)
129 vtkPV3FoamInsertNextPoint(vtkpoints, meshPoints[pointLabels[pointI]]);
132 vtkmesh->SetPoints(vtkpoints);
137 Info<< "<beg> Foam::vtkPV3Foam::addPointZoneMesh" << endl;
142 // ************************************************************************* //