vtkFoamAddPatch.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 "vtkFoam.H"
00030 #include "polyPatch.H"
00031
00032 #include "vtkUnstructuredGrid.h"
00033 #include "vtkCellArray.h"
00034
00035 #include "vtkFoamInsertNextPoint.H"
00036
00037
00038
00039 void Foam::vtkFoam::addPatch
00040 (
00041 const polyPatch& p,
00042 vtkUnstructuredGrid *vtkPatch
00043 )
00044 {
00045 if (debug)
00046 {
00047 Info<< "Adding patch " << p.name() << endl;
00048 }
00049
00050 SetName(vtkPatch, p.name().c_str());
00051
00052 if (debug)
00053 {
00054 Info<< "converting points" << endl;
00055 }
00056
00057 const Foam::pointField& points = p.localPoints();
00058
00059
00060 vtkPoints *vtkpoints = vtkPoints::New();
00061 vtkpoints->Allocate(points.size());
00062
00063 forAll(points, i)
00064 {
00065 vtkFoamInsertNextPoint(vtkpoints, points[i]);
00066 }
00067
00068 if (debug)
00069 {
00070 Info<< "converting faces" << endl;
00071 }
00072
00073 const faceList& faces = p.localFaces();
00074
00075 vtkPatch->Allocate(faces.size());
00076
00077 forAll(faces, facei)
00078 {
00079 const face& f = faces[facei];
00080
00081 if (f.size() == 3)
00082 {
00083 vtkPatch->InsertNextCell
00084 (
00085 VTK_TRIANGLE,
00086 3,
00087 const_cast<int*>(f.begin())
00088 );
00089 }
00090 else if (f.size() == 4)
00091 {
00092 vtkPatch->InsertNextCell
00093 (
00094 VTK_QUAD,
00095 4,
00096 const_cast<int*>(f.begin())
00097 );
00098 }
00099 else
00100 {
00101 vtkPatch->InsertNextCell
00102 (
00103 VTK_POLYGON,
00104 f.size(),
00105 const_cast<int*>(f.begin())
00106 );
00107 }
00108 }
00109
00110 vtkPatch->SetPoints(vtkpoints);
00111 vtkpoints->Delete();
00112 }
00113
00114
00115
Copyright © 2000-2009 OpenCFD Ltd