BUGFIX: Uninitialised member variables
[foam-extend-3.2.git] / applications / utilities / postProcessing / graphics / PV3FoamReader / vtkPV3Foam / vtkPV3FoamMeshPatch.C
blob5a45ac96de2171abe07f7bf86bf7427e0b1a0887
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright held by original author
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
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
19     for more details.
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
25 Description
27 \*---------------------------------------------------------------------------*/
29 #include "vtkPV3Foam.H"
31 // Foam includes
32 #include "polyPatch.H"
33 #include "primitivePatch.H"
34 #include "vtkPV3FoamPoints.H"
36 // VTK includes
37 #include "vtkCellArray.h"
38 #include "vtkPoints.h"
39 #include "vtkPolyData.h"
41 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
43 vtkPolyData* Foam::vtkPV3Foam::patchVTKMesh
45     const polyPatch& p
48     vtkPolyData* vtkmesh = vtkPolyData::New();
50     if (debug)
51     {
52         Info<< "<beg> Foam::vtkPV3Foam::patchVTKMesh - " << p.name() << endl;
53         printMemory();
54     }
56     // Convert Foam mesh vertices to VTK
57     const Foam::pointField& points = p.localPoints();
59     vtkPoints *vtkpoints = vtkPoints::New();
60     vtkpoints->Allocate( points.size() );
61     forAll(points, i)
62     {
63         vtkPV3FoamInsertNextPoint(vtkpoints, points[i]);
64     }
66     vtkmesh->SetPoints(vtkpoints);
67     vtkpoints->Delete();
70     // Add faces as polygons
71     const faceList& faces = p.localFaces();
73     vtkCellArray* vtkcells = vtkCellArray::New();
74     vtkcells->Allocate( faces.size() );
75     forAll(faces, faceI)
76     {
77         const face& f = faces[faceI];
78         vtkIdType nodeIds[f.size()];
80         forAll(f, fp)
81         {
82             nodeIds[fp] = f[fp];
83         }
84         vtkcells->InsertNextCell(f.size(), nodeIds);
85     }
87     vtkmesh->SetPolys(vtkcells);
88     vtkcells->Delete();
90     if (debug)
91     {
92         Info<< "<end> Foam::vtkPV3Foam::patchVTKMesh - " << p.name() << endl;
93         printMemory();
94     }
96     return vtkmesh;
100 // ************************************************************************* //