1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2009 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 "vtkPV3FoamPoints.H"
35 #include "vtkPoints.h"
36 #include "vtkPolyData.h"
37 #include "vtkCellArray.h"
39 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
41 vtkPolyData* Foam::vtkPV3Foam::faceZoneVTKMesh
44 const labelList& faceLabels
47 vtkPolyData* vtkmesh = vtkPolyData::New();
51 Info<< "<beg> Foam::vtkPV3Foam::faceZoneVTKMesh" << endl;
55 // Construct primitivePatch of faces in faceZone
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 patchVTKMesh
68 // Convert Foam mesh vertices to VTK
69 const pointField& points = p.localPoints();
71 vtkPoints* vtkpoints = vtkPoints::New();
72 vtkpoints->Allocate( points.size() );
75 vtkPV3FoamInsertNextPoint(vtkpoints, points[i]);
78 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::faceZoneVTKMesh" << endl;
113 vtkPolyData* Foam::vtkPV3Foam::pointZoneVTKMesh
116 const labelList& pointLabels
119 vtkPolyData* vtkmesh = vtkPolyData::New();
123 Info<< "<beg> Foam::vtkPV3Foam::pointZoneVTKMesh" << endl;
127 const pointField& meshPoints = mesh.points();
129 vtkPoints *vtkpoints = vtkPoints::New();
130 vtkpoints->Allocate( pointLabels.size() );
132 forAll(pointLabels, pointI)
134 vtkPV3FoamInsertNextPoint(vtkpoints, meshPoints[pointLabels[pointI]]);
137 vtkmesh->SetPoints(vtkpoints);
142 Info<< "<beg> Foam::vtkPV3Foam::pointZoneVTKMesh" << endl;
150 // ************************************************************************* //