OpenFOAM logo
The Open Source CFD Toolbox
  Source Guide OpenCFD Solutions Contact OpenFOAM

vtkPV3FoamMeshPatch.C

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*\
00002   =========                 |
00003   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
00004    \\    /   O peration     |
00005     \\  /    A nd           | Copyright (C) 1991-2009 OpenCFD Ltd.
00006      \\/     M anipulation  |
00007 -------------------------------------------------------------------------------
00008 License
00009     This file is part of OpenFOAM.
00010 
00011     OpenFOAM is free software; you can redistribute it and/or modify it
00012     under the terms of the GNU General Public License as published by the
00013     Free Software Foundation; either version 2 of the License, or (at your
00014     option) any later version.
00015 
00016     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
00017     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00018     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00019     for more details.
00020 
00021     You should have received a copy of the GNU General Public License
00022     along with OpenFOAM; if not, write to the Free Software Foundation,
00023     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
00024 
00025 Description
00026 
00027 \*---------------------------------------------------------------------------*/
00028 
00029 #include "vtkPV3Foam.H"
00030 
00031 // Foam includes
00032 #include "polyPatch.H"
00033 #include "primitivePatch.H"
00034 #include "vtkPV3FoamPoints.H"
00035 
00036 // VTK includes
00037 #include "vtkCellArray.h"
00038 #include "vtkPoints.h"
00039 #include "vtkPolyData.h"
00040 
00041 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00042 
00043 vtkPolyData* Foam::vtkPV3Foam::patchVTKMesh
00044 (
00045     const polyPatch& p
00046 )
00047 {
00048     vtkPolyData* vtkmesh = vtkPolyData::New();
00049 
00050     if (debug)
00051     {
00052         Info<< "<beg> Foam::vtkPV3Foam::patchVTKMesh - " << p.name() << endl;
00053         printMemory();
00054     }
00055 
00056     // Convert Foam mesh vertices to VTK
00057     const Foam::pointField& points = p.localPoints();
00058 
00059     vtkPoints *vtkpoints = vtkPoints::New();
00060     vtkpoints->Allocate( points.size() );
00061     forAll(points, i)
00062     {
00063         vtkPV3FoamInsertNextPoint(vtkpoints, points[i]);
00064     }
00065 
00066     vtkmesh->SetPoints(vtkpoints);
00067     vtkpoints->Delete();
00068 
00069 
00070     // Add faces as polygons
00071     const faceList& faces = p.localFaces();
00072 
00073     vtkCellArray* vtkcells = vtkCellArray::New();
00074     vtkcells->Allocate( faces.size() );
00075     forAll(faces, faceI)
00076     {
00077         const face& f = faces[faceI];
00078         vtkIdType nodeIds[f.size()];
00079 
00080         forAll(f, fp)
00081         {
00082             nodeIds[fp] = f[fp];
00083         }
00084         vtkcells->InsertNextCell(f.size(), nodeIds);
00085     }
00086 
00087     vtkmesh->SetPolys(vtkcells);
00088     vtkcells->Delete();
00089 
00090     if (debug)
00091     {
00092         Info<< "<end> Foam::vtkPV3Foam::patchVTKMesh - " << p.name() << endl;
00093         printMemory();
00094     }
00095 
00096     return vtkmesh;
00097 }
00098 
00099 
00100 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd