Open3D (C++ API)
0.18.0+252c867
cpp
open3d
core
Dispatch.h
Go to the documentation of this file.
1
// ----------------------------------------------------------------------------
2
// - Open3D: www.open3d.org -
3
// ----------------------------------------------------------------------------
4
// Copyright (c) 2018-2023 www.open3d.org
5
// SPDX-License-Identifier: MIT
6
// ----------------------------------------------------------------------------
7
8
#pragma once
9
10
#include "
open3d/core/Dtype.h
"
11
#include "
open3d/utility/Logging.h
"
12
30
#define DISPATCH_DTYPE_TO_TEMPLATE(DTYPE, ...) \
31
[&] { \
32
if (DTYPE == open3d::core::Float32) { \
33
using scalar_t = float; \
34
return __VA_ARGS__(); \
35
} else if (DTYPE == open3d::core::Float64) { \
36
using scalar_t = double; \
37
return __VA_ARGS__(); \
38
} else if (DTYPE == open3d::core::Int8) { \
39
using scalar_t = int8_t; \
40
return __VA_ARGS__(); \
41
} else if (DTYPE == open3d::core::Int16) { \
42
using scalar_t = int16_t; \
43
return __VA_ARGS__(); \
44
} else if (DTYPE == open3d::core::Int32) { \
45
using scalar_t = int32_t; \
46
return __VA_ARGS__(); \
47
} else if (DTYPE == open3d::core::Int64) { \
48
using scalar_t = int64_t; \
49
return __VA_ARGS__(); \
50
} else if (DTYPE == open3d::core::UInt8) { \
51
using scalar_t = uint8_t; \
52
return __VA_ARGS__(); \
53
} else if (DTYPE == open3d::core::UInt16) { \
54
using scalar_t = uint16_t; \
55
return __VA_ARGS__(); \
56
} else if (DTYPE == open3d::core::UInt32) { \
57
using scalar_t = uint32_t; \
58
return __VA_ARGS__(); \
59
} else if (DTYPE == open3d::core::UInt64) { \
60
using scalar_t = uint64_t; \
61
return __VA_ARGS__(); \
62
} else { \
63
open3d::utility::LogError("Unsupported data type."
); \
64
} \
65
}()
66
67
#define DISPATCH_DTYPE_TO_TEMPLATE_WITH_BOOL(DTYPE, ...) \
68
[&] { \
69
if (DTYPE == open3d::core::Bool) { \
70
using scalar_t = bool; \
71
return __VA_ARGS__(); \
72
} else { \
73
DISPATCH_DTYPE_TO_TEMPLATE(DTYPE, __VA_ARGS__); \
74
} \
75
}()
76
77
#define DISPATCH_FLOAT_DTYPE_TO_TEMPLATE(DTYPE, ...) \
78
[&] { \
79
if (DTYPE == open3d::core::Float32) { \
80
using scalar_t = float; \
81
return __VA_ARGS__(); \
82
} else if (DTYPE == open3d::core::Float64) { \
83
using scalar_t = double; \
84
return __VA_ARGS__(); \
85
} else { \
86
open3d::utility::LogError("Unsupported data type."
); \
87
} \
88
}()
89
90
#define DISPATCH_FLOAT_INT_DTYPE_TO_TEMPLATE(FDTYPE, IDTYPE, ...) \
91
[&] { \
92
if (FDTYPE == open3d::core::Float32 && \
93
IDTYPE == open3d::core::Int32) { \
94
using scalar_t = float; \
95
using int_t = int32_t; \
96
return __VA_ARGS__(); \
97
} else if (FDTYPE == open3d::core::Float32 && \
98
IDTYPE == open3d::core::Int64) { \
99
using scalar_t = float; \
100
using int_t = int64_t; \
101
return __VA_ARGS__(); \
102
} else if (FDTYPE == open3d::core::Float64 && \
103
IDTYPE == open3d::core::Int32) { \
104
using scalar_t = double; \
105
using int_t = int32_t; \
106
return __VA_ARGS__(); \
107
} else if (FDTYPE == open3d::core::Float64 && \
108
IDTYPE == open3d::core::Int64) { \
109
using scalar_t = double; \
110
using int_t = int64_t; \
111
return __VA_ARGS__(); \
112
} else { \
113
open3d::utility::LogError("Unsupported data type."
); \
114
} \
115
}()
116
117
#define DISPATCH_INT_DTYPE_PREFIX_TO_TEMPLATE(DTYPE, PREFIX, ...) \
118
[&] { \
119
if (DTYPE == open3d::core::Int8) { \
120
using scalar_##PREFIX##_t = int8_t; \
121
return __VA_ARGS__(); \
122
} else if (DTYPE == open3d::core::Int16) { \
123
using scalar_##PREFIX##_t = int16_t; \
124
return __VA_ARGS__(); \
125
} else if (DTYPE == open3d::core::Int32) { \
126
using scalar_##PREFIX##_t = int32_t; \
127
return __VA_ARGS__(); \
128
} else if (DTYPE == open3d::core::Int64) { \
129
using scalar_##PREFIX##_t = int64_t; \
130
return __VA_ARGS__(); \
131
} else if (DTYPE == open3d::core::UInt8) { \
132
using scalar_##PREFIX##_t = uint8_t; \
133
return __VA_ARGS__(); \
134
} else if (DTYPE == open3d::core::UInt16) { \
135
using scalar_##PREFIX##_t = uint16_t; \
136
return __VA_ARGS__(); \
137
} else if (DTYPE == open3d::core::UInt32) { \
138
using scalar_##PREFIX##_t = uint32_t; \
139
return __VA_ARGS__(); \
140
} else if (DTYPE == open3d::core::UInt64) { \
141
using scalar_##PREFIX##_t = uint64_t; \
142
return __VA_ARGS__(); \
143
} else { \
144
open3d::utility::LogError("Unsupported data type."
); \
145
} \
146
}()
Dtype.h
Logging.h
Generated by
1.9.1