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
5
namespace
MR
6
{
9
10
12
enum class
ScalarType
13
{
14
UInt8
,
15
Int8
,
16
UInt16
,
17
Int16
,
18
UInt32
,
19
Int32
,
20
UInt64
,
21
Int64
,
22
Float32
,
23
Float64
,
24
Float32_4
,
25
Unknown
,
26
Count
27
};
28
33
MRVOXELS_API std::function<float (
const
char
* )>
getTypeConverter
(
ScalarType
scalarType, Uint64 range,
Int64
min );
34
35
37
template
<
typename
F>
38
std::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
{
44
case
ScalarType::UInt8
:
45
M
( uint8_t )
46
case
ScalarType::UInt16
:
47
M
( uint16_t )
48
case
ScalarType::Int8
:
49
M
( int8_t )
50
case
ScalarType::Int16
:
51
M
( int16_t )
52
case
ScalarType::Int32
:
53
M
( int32_t )
54
case
ScalarType::UInt32
:
55
M
( uint32_t )
56
case
ScalarType::UInt64
:
57
M
( uint64_t )
58
case
ScalarType::Int64
:
59
M
( int64_t )
60
case
ScalarType::Float32
:
61
M
(
float
)
62
case
ScalarType::Float64
:
63
M
(
double
)
64
case
ScalarType::Float32_4
:
65
return
f( *((
const
float
*)c + 3 ) );
66
case
ScalarType::Unknown
:
67
return
{};
68
case
ScalarType::Count
:
69
MR_UNREACHABLE
70
}
71
MR_UNREACHABLE
72
#undef M
73
}
74
75
76
}
M
#define M(T)
MR::getTypeConverter
MRVOXELS_API std::function< float(const char *)> getTypeConverter(ScalarType scalarType, Uint64 range, Int64 min)
MR::ScalarType
ScalarType
scalar value's binary format type
Definition
MRScalarConvert.h:13
MR::visitScalarType
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
MR::PdfBuildinFont::Count
@ Count
MR::ScalarType::Float32
@ Float32
MR::ScalarType::Int16
@ Int16
MR::ScalarType::Float32_4
@ Float32_4
the last value from float[4]
MR::ScalarType::Int8
@ Int8
MR::ScalarType::Unknown
@ Unknown
MR::ScalarType::UInt16
@ UInt16
MR::ScalarType::UInt64
@ UInt64
MR::ScalarType::UInt8
@ UInt8
MR::ScalarType::Int32
@ Int32
MR::ScalarType::Float64
@ Float64
MR::ScalarType::UInt32
@ UInt32
MR::ScalarType::Count
@ Count
MR::ScalarType::Int64
@ Int64
MR
only for bindings generation
Definition
MRCameraOrientationPlugin.h:8
MeshLib
source
MRVoxels
MRScalarConvert.h
Generated by
1.11.0