initial commit for version 1.5.x patch release
[OpenFOAM-1.5.x.git] / applications / utilities / postProcessing / graphics / PV3FoamReader / vtkPV3Foam / vtkPV3FoamAddZoneMesh.C
blob9c52624f0f9ad7019d92e70a3fceb1718e3de5cc
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 1991-2008 OpenCFD Ltd.
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 "vtkPV3FoamInsertNextPoint.H"
34 // VTK includes
35 #include "vtkPoints.h"
36 #include "vtkPolyData.h"
37 #include "vtkCellArray.h"
39 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
42 void Foam::vtkPV3Foam::addFaceZoneMesh
44     const fvMesh& mesh,
45     const labelList& faceLabels,
46     vtkPolyData* vtkmesh
49     if (debug)
50     {
51         Info<< "<beg> Foam::vtkPV3Foam::addFaceZoneMesh" << endl;
52         printMemory();
53     }
55     // Construct primitivePatch of faces in fSet.
57     const faceList& meshFaces = mesh.faces();
58     faceList patchFaces(faceLabels.size());
59     forAll(faceLabels, faceI)
60     {
61         patchFaces[faceI] = meshFaces[faceLabels[faceI]];
62     }
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());
73     forAll(points, i)
74     {
75         vtkPV3FoamInsertNextPoint(vtkpoints, points[i]);
76     }
77     vtkmesh->SetPoints(vtkpoints);
78     vtkpoints->Delete();
80     // Add faces as polygons
81     const faceList& faces = p.localFaces();
83     vtkCellArray* vtkcells = vtkCellArray::New();
84     vtkcells->Allocate(points.size());
85     forAll(faces, faceI)
86     {
87         const face& f = faces[faceI];
88         vtkIdType nodeIds[f.size()];
90         forAll (f, fp)
91         {
92             nodeIds[fp] = f[fp];
93         }
94         vtkcells->InsertNextCell(f.size(), nodeIds);
95     }
97     vtkmesh->SetPolys(vtkcells);
98     vtkcells->Delete();
100     if (debug)
101     {
102         Info<< "<end> Foam::vtkPV3Foam::addFaceZoneMesh" << endl;
103         printMemory();
104     }
109 void Foam::vtkPV3Foam::addPointZoneMesh
111     const fvMesh& mesh,
112     const labelList& pointLabels,
113     vtkPolyData* vtkmesh
116     if (debug)
117     {
118         Info<< "<beg> Foam::vtkPV3Foam::addPointZoneMesh" << endl;
119         printMemory();
120     }
122     const pointField& meshPoints = mesh.points();
124     vtkPoints *vtkpoints = vtkPoints::New();
125     vtkpoints->Allocate(pointLabels.size());
127     forAll(pointLabels, pointI)
128     {
129         vtkPV3FoamInsertNextPoint(vtkpoints, meshPoints[pointLabels[pointI]]);
130     }
132     vtkmesh->SetPoints(vtkpoints);
133     vtkpoints->Delete();
135     if (debug)
136     {
137         Info<< "<beg> Foam::vtkPV3Foam::addPointZoneMesh" << endl;
138         printMemory();
139     }
142 // ************************************************************************* //