1#ifndef __FIBEROPERATIONS_CONVERSION_HPP
2#define __FIBEROPERATIONS_CONVERSION_HPP
4#include "fish/fiber/field/Field.hpp"
5#include "FiberHDF5/mtoolslib/MDefs.hpp"
10template<
int N,
class T,
class O>
11RefPtr<MemArray<N, T> > convertData( RefPtr<Field>& field, RefPtr<FragmentID> fid )
13RefPtr<MemArray<N, O>> original = field->getData( fid );
18RefPtr<MemArray<N, T>> converted =
new MemArray<N, T>( original->Size() );
20MultiArray<N, O>& o_data = *original;
21MultiArray<N, T>& c_data = *converted;
24 for(
unsigned i = 0; i < N ; ++i)
29 c_data[mi] = T( o_data[mi] );
32 while( mi.inc( original->Size() ) );
38template<
int N,
class T>
39RefPtr<MemArray<N, T> > getConvertedData( RefPtr<Field>& field, RefPtr<FragmentID> fid )
41 MTOOLS_RETURN_EV( !field,
"Fiber::getConvertedData() no field found!",
NullPtr() );
43RefPtr<MemArray<N, T>> result = field->getData( fid );
48 RefPtr<FiberTypeBase> ftb = field->getElementFiberType();
49 RefPtr<FiberTypeBase> ftb_e = ftb->element_type();
54 if( ftb_e->getType() ==
typeid( uint8_t ) )
55 result = convertData<N, T, uint8_t>( field, fid );
56 else if( ftb_e->getType() ==
typeid( uint16_t ) )
57 result = convertData<N, T, uint16_t>( field, fid );
58 else if( ftb_e->getType() ==
typeid( uint32_t ) )
59 result = convertData<N, T, uint32_t>( field, fid );
60 else if( ftb_e->getType() ==
typeid( uint64_t ) )
61 result = convertData<N, T, uint64_t>( field, fid );
62 else if( ftb_e->getType() ==
typeid(
float ) )
63 result = convertData<N, T, float>( field, fid );
64 else if( ftb_e->getType() ==
typeid(
double ) )
65 result = convertData<N, T, double>( field, fid );
66 else if( ftb_e->getType() ==
typeid( int8_t ) )
67 result = convertData<N, T, int8_t>( field, fid );
68 else if( ftb_e->getType() ==
typeid( int16_t ) )
69 result = convertData<N, T, int16_t>( field, fid );
70 else if( ftb_e->getType() ==
typeid( int32_t ) )
71 result = convertData<N, T, int32_t>( field, fid );
72 else if( ftb_e->getType() ==
typeid( int64_t ) )
73 result = convertData<N, T, int64_t>( field, fid );
75 MTOOLS_ERR_LOG(
"Fiber::getConvertedData( no type matched for conversion" );
Given a fragmented field of curvilinear coordinates, (3D array of coordinates), build a uniform Grid ...
Definition FAQ.dox:2