MeshLib C++ Docs
Loading...
Searching...
No Matches
MRScalarConvert.h
Go to the documentation of this file.
1#pragma once
2
3#include "MRVoxelsFwd.h"
4
5namespace MR
6{
9
10
28
33MRVOXELS_API std::function<float ( const char* )> getTypeConverter( ScalarType scalarType, Uint64 range, Int64 min );
34
35
37template <typename F>
38std::invoke_result_t<F, int> visitScalarType( F&& f, ScalarType scalarType, const char* c )
39{
40#define M(T) return f( *( const T* )( c ) );
41
42 switch ( scalarType )
43 {
45 M( uint8_t )
47 M( uint16_t )
49 M( int8_t )
51 M( int16_t )
53 M( int32_t )
55 M( uint32_t )
57 M( uint64_t )
59 M( int64_t )
61 M( float )
63 M( double )
65 return f( *((const float*)c + 3 ) );
67 return {};
70 }
72#undef M
73}
74
75
76}
#define MR_UNREACHABLE
Definition MRMeshFwd.h:826
#define M(T)
#define MRVOXELS_API
see explanation in MRMesh/MRMeshFwd.h
Definition MRVoxelsFwd.h:14
std::uint64_t Uint64
Definition MRMeshFwd.h:201
ScalarType
scalar value's binary format type
Definition MRScalarConvert.h:13
std::function< float(const char *)> getTypeConverter(ScalarType scalarType, Uint64 range, Int64 min)
std::int64_t Int64
Definition MRMeshFwd.h:200
std::invoke_result_t< F, int > visitScalarType(F &&f, ScalarType scalarType, const char *c)
More general template to pass a single value of specified format scalarType to a generic function f.
Definition MRScalarConvert.h:38
@ Count
Definition MRPdf.h:42
@ Float32
Definition MRScalarConvert.h:22
@ Int16
Definition MRScalarConvert.h:17
@ Float32_4
the last value from float[4]
Definition MRScalarConvert.h:24
@ Int8
Definition MRScalarConvert.h:15
@ Unknown
Definition MRScalarConvert.h:25
@ UInt16
Definition MRScalarConvert.h:16
@ UInt64
Definition MRScalarConvert.h:20
@ UInt8
Definition MRScalarConvert.h:14
@ Int32
Definition MRScalarConvert.h:19
@ Float64
Definition MRScalarConvert.h:23
@ UInt32
Definition MRScalarConvert.h:18
@ Count
Definition MRScalarConvert.h:26
@ Int64
Definition MRScalarConvert.h:21
only for bindings generation
Definition MRCameraOrientationPlugin.h:8