MeshLib Documentation
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
{
7
9
enum class
ScalarType
10
{
11
UInt8
,
12
Int8
,
13
UInt16
,
14
Int16
,
15
UInt32
,
16
Int32
,
17
UInt64
,
18
Int64
,
19
Float32
,
20
Float64
,
21
Float32_4
,
22
Unknown
,
23
Count
24
};
25
30
MRVOXELS_API
std::function<float (
const
char
* )>
getTypeConverter
(
ScalarType
scalarType, uint64_t range, int64_t min );
31
32
34
template
<
typename
F>
35
std::invoke_result_t<F, int>
visitScalarType
( F&& f,
ScalarType
scalarType,
const
char
* c )
36
{
37
#define M(T) return f( *( const T* )( c ) );
38
39
switch
( scalarType )
40
{
41
case
ScalarType::UInt8
:
42
M
( uint8_t )
43
case
ScalarType::UInt16
:
44
M
( uint16_t )
45
case
ScalarType::Int8
:
46
M
( int8_t )
47
case
ScalarType::Int16
:
48
M
( int16_t )
49
case
ScalarType::Int32
:
50
M
( int32_t )
51
case
ScalarType::UInt32
:
52
M
( uint32_t )
53
case
ScalarType::UInt64
:
54
M
( uint64_t )
55
case
ScalarType::Int64
:
56
M
( int64_t )
57
case
ScalarType::Float32
:
58
M
(
float
)
59
case
ScalarType::Float64
:
60
M
(
double
)
61
case
ScalarType::Float32_4
:
62
return
f( *((
const
float
*)c + 3 ) );
63
case
ScalarType::Unknown
:
64
return
{};
65
case
ScalarType::Count
:
66
MR_UNREACHABLE
67
}
68
MR_UNREACHABLE
69
#undef M
70
}
71
72
73
}
// namespace MR
MR_UNREACHABLE
#define MR_UNREACHABLE
Definition
MRMesh/MRMeshFwd.h:637
M
#define M(T)
MRVoxelsFwd.h
MRVOXELS_API
#define MRVOXELS_API
Definition
MRVoxelsFwd.h:13
MR
Definition
MRCameraOrientationPlugin.h:8
MR::getTypeConverter
MRVOXELS_API std::function< float(const char *)> getTypeConverter(ScalarType scalarType, uint64_t range, int64_t min)
MR::Axis::Count
@ Count
MR::ScalarType
ScalarType
scalar value's binary format type
Definition
MRScalarConvert.h:10
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::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:35
MeshLib
source
MRVoxels
MRScalarConvert.h
Generated by
1.11.0