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 #ifndef VISU_ElnoMeshValue_HeaderFile
00025 #define VISU_ElnoMeshValue_HeaderFile
00026
00027 #include "VISU_VTKTypeList.hxx"
00028 #include <vtkDataSetAttributes.h>
00029
00030
00036 namespace VISU
00037 {
00038
00039 template< int elno_type >
00040 struct TGetElnoNodeData
00041 {
00042 typedef typename TL::TEnum2VTKArrayType< elno_type >::TResult TVTKDataArray;
00043 typedef typename TL::TEnum2VTKBasicType< elno_type >::TResult TDataType;
00044 TVTKDataArray *myElnoDataArray;
00045 vtkIntArray *myElnoDataMapper;
00046 int myElemInfo[3];
00047
00048
00049
00050 TGetElnoNodeData( vtkDataArray *theElnoDataArray,
00051 vtkDataArray *theElnoDataMapper )
00052 : myElnoDataArray( TVTKDataArray::SafeDownCast( theElnoDataArray ) )
00053 , myElnoDataMapper( vtkIntArray::SafeDownCast( theElnoDataMapper ) )
00054 {}
00055
00056
00057
00058 TDataType*
00059 operator () ( vtkIdType theCellId, vtkIdType theLocalPntId )
00060 {
00061 myElnoDataMapper->GetTupleValue( theCellId, myElemInfo );
00062
00063 vtkIdType aPos = myElemInfo[ 0 ] + theLocalPntId * myElemInfo[ 1 ];
00064
00065 return myElnoDataArray->GetPointer( aPos );
00066 }
00067
00068
00069
00070 int
00071 getNbComp()
00072 {
00073 myElnoDataMapper->GetTupleValue( 0, myElemInfo );
00074
00075 return myElemInfo[ 1 ];
00076 }
00077 };
00078
00079
00080
00081 template< int elno_type >
00082 struct TSetElnoNodeData
00083 {
00084 typedef typename TL::TEnum2VTKArrayType< elno_type >::TResult TVTKDataArray;
00085 typedef typename TL::TEnum2VTKBasicType< elno_type >::TResult TDataType;
00086
00087
00088 TSetElnoNodeData( vtkIdType theEffectNbComp,
00089 vtkIdType theRealNbComp,
00090 vtkIdType theNbTuples,
00091 const char* theDataArrayName,
00092 const char* theMapperArrayName )
00093 : myElnoDataArray( TVTKDataArray::New() )
00094 , myElnoDataMapper( vtkIntArray::New() )
00095 {
00096 myElnoDataArray->SetNumberOfComponents( theEffectNbComp );
00097 myElnoDataArray->SetNumberOfTuples( theNbTuples );
00098 myElnoDataArray->SetName( theDataArrayName );
00099
00100 myElnoDataMapper->SetNumberOfComponents( 3 );
00101 myElnoDataMapper->Allocate( theNbTuples * 3 );
00102 myElnoDataMapper->SetName( theMapperArrayName );
00103
00104 myElemInfo[ 0 ] = 0;
00105 myElemInfo[ 1 ] = theRealNbComp;
00106 myElemInfo[ 2 ] = 0;
00107 }
00108
00109
00110
00111 ~TSetElnoNodeData()
00112 {
00113 myElnoDataArray->Delete();
00114 myElnoDataMapper->Delete();
00115 }
00116
00117
00118
00119 int
00120 AddNextPointData( TDataType* theDataPtr )
00121 {
00122 vtkIdType aPos = myElemInfo[ 0 ] + myElemInfo[ 2 ] * myElemInfo[ 1 ];
00123
00124 TDataType* aDataPtr = myElnoDataArray->GetPointer( aPos );
00125
00126 for ( vtkIdType aCompId = 0; aCompId < myElemInfo[ 1 ]; aCompId++ )
00127 *aDataPtr++ = *theDataPtr++;
00128
00129 return myElemInfo[ 2 ]++;
00130 }
00131
00132
00133
00134 void
00135 InsertNextCellData()
00136 {
00137 myElnoDataMapper->InsertNextTupleValue( myElemInfo );
00138 myElemInfo[ 0 ] += myElemInfo[ 2 ] * myElemInfo[ 1 ];
00139 myElemInfo[ 2 ] = 0;
00140 }
00141
00142
00143
00144 void
00145 AddData( vtkDataSetAttributes* theDataSetAttributes )
00146 {
00147 theDataSetAttributes->AddArray( myElnoDataArray );
00148 theDataSetAttributes->AddArray( myElnoDataMapper );
00149 }
00150
00151 protected:
00152 TVTKDataArray *myElnoDataArray;
00153 vtkIntArray *myElnoDataMapper;
00154 int myElemInfo[ 3 ];
00155 };
00156
00157
00158
00159 }
00160
00161 #endif