vtkFoamConvertPatchPointField.H
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
00030 #ifndef vtkFoamConvertPatchPointField_H
00031 #define vtkFoamConvertPatchPointField_H
00032
00033
00034
00035 template<class Type>
00036 void Foam::vtkFoam::convertPatchPointField
00037 (
00038 const word& name,
00039 const Field<Type>& pptf,
00040 const label regioni
00041 )
00042 {
00043 vtkUnstructuredGrid *vtkMesh =
00044 vtkUnstructuredGrid::SafeDownCast(reader_->GetOutput(regioni));
00045
00046 vtkFloatArray *pointTypes = vtkFloatArray::New();
00047 pointTypes->SetNumberOfTuples(pptf.size());
00048 pointTypes->SetNumberOfComponents(Type::nComponents);
00049 pointTypes->Allocate(Type::nComponents*pptf.size());
00050 pointTypes->SetName(name.c_str());
00051
00052 float vec[Type::nComponents];
00053
00054 forAll(pptf, i)
00055 {
00056 for (direction d=0; d<Type::nComponents; d++)
00057 {
00058 vec[d] = pptf[i][d];
00059 }
00060
00061 pointTypes->InsertTuple(i, vec);
00062 }
00063
00064 vtkMesh->GetPointData()->AddArray(pointTypes);
00065 pointTypes->Delete();
00066 }
00067
00068
00069 template<>
00070 void Foam::vtkFoam::convertPatchPointField
00071 (
00072 const word& name,
00073 const Field<scalar>& ppsf,
00074 const label regioni
00075 )
00076 {
00077 vtkUnstructuredGrid *vtkMesh =
00078 vtkUnstructuredGrid::SafeDownCast(reader_->GetOutput(regioni));
00079
00080 vtkFloatArray *pointScalars = vtkFloatArray::New();
00081 pointScalars->SetNumberOfTuples(ppsf.size());
00082 pointScalars->SetNumberOfComponents(1);
00083 pointScalars->Allocate(ppsf.size());
00084 pointScalars->SetName(name.c_str());
00085
00086 for (int i=0; i<ppsf.size(); i++)
00087 {
00088 pointScalars->InsertComponent(i, 0, ppsf[i]);
00089 }
00090
00091 vtkMesh->GetPointData()->AddArray(pointScalars);
00092 if (!vtkMesh->GetPointData()->GetScalars())
00093 {
00094 vtkMesh->GetPointData()->SetScalars(pointScalars);
00095 }
00096
00097 pointScalars->Delete();
00098 }
00099
00100
00101
00102
00103 #endif
00104
00105
Copyright © 2000-2009 OpenCFD Ltd