vtkPV3FoamMeshSet.C
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 #include "vtkPV3Foam.H"
00030
00031
00032 #include "faceSet.H"
00033 #include "pointSet.H"
00034 #include "vtkPV3FoamPoints.H"
00035
00036
00037 #include "vtkPoints.h"
00038 #include "vtkPolyData.h"
00039 #include "vtkCellArray.h"
00040
00041
00042
00043 vtkPolyData* Foam::vtkPV3Foam::faceSetVTKMesh
00044 (
00045 const fvMesh& mesh,
00046 const faceSet& fSet
00047 )
00048 {
00049 vtkPolyData* vtkmesh = vtkPolyData::New();
00050
00051 if (debug)
00052 {
00053 Info<< "<beg> Foam::vtkPV3Foam::faceSetVTKMesh" << endl;
00054 printMemory();
00055 }
00056
00057
00058
00059 const faceList& meshFaces = mesh.faces();
00060 faceList patchFaces(fSet.size());
00061 label faceI = 0;
00062 forAllConstIter(faceSet, fSet, iter)
00063 {
00064 patchFaces[faceI++] = meshFaces[iter.key()];
00065 }
00066 primitiveFacePatch p(patchFaces, mesh.points());
00067
00068
00069
00070
00071
00072 const pointField& points = p.localPoints();
00073
00074 vtkPoints *vtkpoints = vtkPoints::New();
00075 vtkpoints->Allocate( points.size() );
00076 forAll(points, i)
00077 {
00078 vtkPV3FoamInsertNextPoint(vtkpoints, points[i]);
00079 }
00080 vtkmesh->SetPoints(vtkpoints);
00081 vtkpoints->Delete();
00082
00083
00084 const faceList& faces = p.localFaces();
00085
00086 vtkCellArray* vtkcells = vtkCellArray::New();
00087 vtkcells->Allocate( faces.size() );
00088
00089 forAll(faces, faceI)
00090 {
00091 const face& f = faces[faceI];
00092 vtkIdType nodeIds[f.size()];
00093
00094 forAll(f, fp)
00095 {
00096 nodeIds[fp] = f[fp];
00097 }
00098 vtkcells->InsertNextCell(f.size(), nodeIds);
00099 }
00100
00101 vtkmesh->SetPolys(vtkcells);
00102 vtkcells->Delete();
00103
00104 if (debug)
00105 {
00106 Info<< "<end> Foam::vtkPV3Foam::faceSetVTKMesh" << endl;
00107 printMemory();
00108 }
00109
00110 return vtkmesh;
00111 }
00112
00113
00114 vtkPolyData* Foam::vtkPV3Foam::pointSetVTKMesh
00115 (
00116 const fvMesh& mesh,
00117 const pointSet& pSet
00118 )
00119 {
00120 vtkPolyData* vtkmesh = vtkPolyData::New();
00121
00122 if (debug)
00123 {
00124 Info<< "<beg> Foam::vtkPV3Foam::pointSetVTKMesh" << endl;
00125 printMemory();
00126 }
00127
00128 const pointField& meshPoints = mesh.points();
00129
00130 vtkPoints *vtkpoints = vtkPoints::New();
00131 vtkpoints->Allocate( pSet.size() );
00132
00133 forAllConstIter(pointSet, pSet, iter)
00134 {
00135 vtkPV3FoamInsertNextPoint(vtkpoints, meshPoints[iter.key()]);
00136 }
00137
00138 vtkmesh->SetPoints(vtkpoints);
00139 vtkpoints->Delete();
00140
00141 if (debug)
00142 {
00143 Info<< "<end> Foam::vtkPV3Foam::pointSetVTKMesh" << endl;
00144 printMemory();
00145 }
00146
00147 return vtkmesh;
00148 }
00149
00150
00151
Copyright © 2000-2009 OpenCFD Ltd