FiberVISH 0.2
Fish - The Fiber Bundle API for the Vish Visualization Shell
Conversion.hpp
1#ifndef __FIBEROPERATIONS_CONVERSION_HPP
2#define __FIBEROPERATIONS_CONVERSION_HPP
3
4#include "fish/fiber/field/Field.hpp"
5#include "FiberHDF5/mtoolslib/MDefs.hpp"
6
7namespace Fiber
8{
9
10template<int N, class T, class O>
11RefPtr<MemArray<N, T> > convertData( RefPtr<Field>& field, RefPtr<FragmentID> fid )
12{
13RefPtr<MemArray<N, O>> original = field->getData( fid );
14
15 if( !original)
16 return NullPtr();
17
18RefPtr<MemArray<N, T>> converted = new MemArray<N, T>( original->Size() );
19
20MultiArray<N, O>& o_data = *original;
21MultiArray<N, T>& c_data = *converted;
22
23MultiIndex<N> mi;
24 for(unsigned i = 0; i < N ; ++i)
25 mi[i] = 0;
26
27 do
28 {
29 c_data[mi] = T( o_data[mi] );
30// std::cout << c_data[mi] << std::endl;
31 }
32 while( mi.inc( original->Size() ) );
33
34
35 return converted;
36}
37
38template<int N, class T>
39RefPtr<MemArray<N, T> > getConvertedData( RefPtr<Field>& field, RefPtr<FragmentID> fid )
40{
41 MTOOLS_RETURN_EV( !field, "Fiber::getConvertedData() no field found!", NullPtr() );
42
43RefPtr<MemArray<N, T>> result = field->getData( fid );
44
45
46 if(!result)
47 {
48 RefPtr<FiberTypeBase> ftb = field->getElementFiberType();
49 RefPtr<FiberTypeBase> ftb_e = ftb->element_type();
50 // ftb_e.speak();
51 //cout << "type:" << ftb_e.getType().name() << endl;
52 //cout << "type:" << typeid(ftb_e.getType()).name() << endl;
53
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 );
74 else
75 MTOOLS_ERR_LOG( "Fiber::getConvertedData( no type matched for conversion" );
76 }
77
78 return result;
79}
80}
81#endif
Given a fragmented field of curvilinear coordinates, (3D array of coordinates), build a uniform Grid ...
Definition FAQ.dox:2
std::nullptr_t NullPtr