vtkPV3FoamPatchField.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 vtkPV3FoamPatchField_H
00031 #define vtkPV3FoamPatchField_H
00032
00033
00034 #include "vtkCellData.h"
00035 #include "vtkFloatArray.h"
00036 #include "vtkMultiBlockDataSet.h"
00037 #include "vtkPointData.h"
00038 #include "vtkPolyData.h"
00039
00040
00041
00042 template<class Type>
00043 void Foam::vtkPV3Foam::convertPatchField
00044 (
00045 const word& name,
00046 const Field<Type>& ptf,
00047 vtkMultiBlockDataSet* output,
00048 const partInfo& selector,
00049 const label datasetNo
00050 )
00051 {
00052 const label nComp = pTraits<Type>::nComponents;
00053
00054 vtkFloatArray* cellData = vtkFloatArray::New();
00055 cellData->SetNumberOfTuples( ptf.size() );
00056 cellData->SetNumberOfComponents( nComp );
00057 cellData->Allocate( nComp*ptf.size() );
00058 cellData->SetName( name.c_str() );
00059
00060 float vec[nComp];
00061 forAll(ptf, i)
00062 {
00063 const Type& t = ptf[i];
00064 for (direction d=0; d<nComp; d++)
00065 {
00066 vec[d] = component(t, d);
00067 }
00068 cellData->InsertTuple(i, vec);
00069 }
00070
00071 vtkPolyData::SafeDownCast
00072 (
00073 GetDataSetFromBlock(output, selector, datasetNo)
00074 ) ->GetCellData()
00075 ->AddArray(cellData);
00076
00077 cellData->Delete();
00078 }
00079
00080
00081
00082 template<class Type>
00083 void Foam::vtkPV3Foam::convertPatchPointField
00084 (
00085 const word& name,
00086 const Field<Type>& pptf,
00087 vtkMultiBlockDataSet* output,
00088 const partInfo& selector,
00089 const label datasetNo
00090 )
00091 {
00092 const label nComp = pTraits<Type>::nComponents;
00093
00094 vtkFloatArray *pointData = vtkFloatArray::New();
00095 pointData->SetNumberOfTuples( pptf.size() );
00096 pointData->SetNumberOfComponents( nComp );
00097 pointData->Allocate( nComp*pptf.size() );
00098 pointData->SetName( name.c_str() );
00099
00100 float vec[nComp];
00101 forAll(pptf, i)
00102 {
00103 const Type& t = pptf[i];
00104 for (direction d=0; d<nComp; d++)
00105 {
00106 vec[d] = component(t, d);
00107 }
00108
00109 pointData->InsertTuple(i, vec);
00110 }
00111
00112 vtkPolyData::SafeDownCast
00113 (
00114 GetDataSetFromBlock(output, selector, datasetNo)
00115 ) ->GetPointData()
00116 ->AddArray(pointData);
00117
00118 pointData->Delete();
00119 }
00120
00121
00122
00123 #endif
00124
00125
Copyright © 2000-2009 OpenCFD Ltd