Open3D (C++ API)
0.19.0
Toggle main menu visibility
Loading...
Searching...
No Matches
cpp
open3d
core
Dtype.h
Go to the documentation of this file.
1
// ----------------------------------------------------------------------------
2
// - Open3D: www.open3d.org -
3
// ----------------------------------------------------------------------------
4
// Copyright (c) 2018-2024 www.open3d.org
5
// SPDX-License-Identifier: MIT
6
// ----------------------------------------------------------------------------
7
8
#pragma once
9
10
#include <cstring>
11
#include <string>
12
13
#include "
open3d/Macro.h
"
14
#include "
open3d/core/Dispatch.h
"
15
#include "
open3d/utility/Logging.h
"
16
17
namespace
open3d
{
18
namespace
core
{
19
20
class
OPEN3D_API
Dtype
{
21
public
:
22
static
const
Dtype
Undefined
;
23
static
const
Dtype
Float32
;
24
static
const
Dtype
Float64
;
25
static
const
Dtype
Int8
;
26
static
const
Dtype
Int16
;
27
static
const
Dtype
Int32
;
28
static
const
Dtype
Int64
;
29
static
const
Dtype
UInt8
;
30
static
const
Dtype
UInt16
;
31
static
const
Dtype
UInt32
;
32
static
const
Dtype
UInt64
;
33
static
const
Dtype
Bool
;
34
35
public
:
36
enum class
DtypeCode
{
37
Undefined
,
38
Bool
,
// Needed to distinguish bool from uint8_t.
39
Int,
40
UInt,
41
Float,
42
Object,
43
};
44
45
Dtype
() :
Dtype
(
DtypeCode
::
Undefined
, 1,
"Undefined"
) {}
46
47
explicit
Dtype
(DtypeCode dtype_code,
48
int64_t byte_size,
49
const
std::string &name);
50
53
template
<
typename
T>
54
static
inline
const
Dtype
FromType
() {
55
utility::LogError(
"Unsupported data for Dtype::FromType."
);
56
}
57
58
int64_t
ByteSize
()
const
{
return
byte_size_; }
59
60
DtypeCode
GetDtypeCode
()
const
{
return
dtype_code_; }
61
62
bool
IsObject
()
const
{
return
dtype_code_ ==
DtypeCode::Object
; }
63
64
std::string
ToString
()
const
{
return
name_; }
65
66
bool
operator==(
const
Dtype
&other)
const
;
67
68
bool
operator!=(
const
Dtype
&other)
const
;
69
70
private
:
71
static
constexpr
size_t
max_name_len_ = 16;
72
DtypeCode dtype_code_;
73
int64_t byte_size_;
74
char
name_[max_name_len_];
// MSVC warns if std::string is exported to DLL.
75
};
76
77
OPEN3D_API
extern
const
Dtype
Undefined
;
78
OPEN3D_API
extern
const
Dtype
Float32
;
79
OPEN3D_API
extern
const
Dtype
Float64
;
80
OPEN3D_API
extern
const
Dtype
Int8
;
81
OPEN3D_API
extern
const
Dtype
Int16
;
82
OPEN3D_API
extern
const
Dtype
Int32
;
83
OPEN3D_API
extern
const
Dtype
Int64
;
84
OPEN3D_API
extern
const
Dtype
UInt8
;
85
OPEN3D_API
extern
const
Dtype
UInt16
;
86
OPEN3D_API
extern
const
Dtype
UInt32
;
87
OPEN3D_API
extern
const
Dtype
UInt64
;
88
OPEN3D_API
extern
const
Dtype
Bool
;
89
90
template
<>
91
inline
const
Dtype
Dtype::FromType<float>
() {
92
return
Dtype::Float32
;
93
}
94
95
template
<>
96
inline
const
Dtype
Dtype::FromType<double>
() {
97
return
Dtype::Float64
;
98
}
99
100
template
<>
101
inline
const
Dtype
Dtype::FromType<int8_t>
() {
102
return
Dtype::Int8
;
103
}
104
105
template
<>
106
inline
const
Dtype
Dtype::FromType<int16_t>
() {
107
return
Dtype::Int16
;
108
}
109
110
template
<>
111
inline
const
Dtype
Dtype::FromType<int32_t>
() {
112
return
Dtype::Int32
;
113
}
114
115
template
<>
116
inline
const
Dtype
Dtype::FromType<int64_t>
() {
117
return
Dtype::Int64
;
118
}
119
120
template
<>
121
inline
const
Dtype
Dtype::FromType<uint8_t>
() {
122
return
Dtype::UInt8
;
123
}
124
125
template
<>
126
inline
const
Dtype
Dtype::FromType<uint16_t>
() {
127
return
Dtype::UInt16
;
128
}
129
130
template
<>
131
inline
const
Dtype
Dtype::FromType<uint32_t>
() {
132
return
Dtype::UInt32
;
133
}
134
135
template
<>
136
inline
const
Dtype
Dtype::FromType<uint64_t>
() {
137
return
Dtype::UInt64
;
138
}
139
140
template
<>
141
inline
const
Dtype
Dtype::FromType<bool>
() {
142
return
Dtype::Bool
;
143
}
144
145
}
// namespace core
146
}
// namespace open3d
Dispatch.h
Logging.h
Macro.h
OPEN3D_API
#define OPEN3D_API
Definition
Macro.h:34
open3d::core::Dtype
Definition
Dtype.h:20
open3d::core::Dtype::UInt8
static const Dtype UInt8
Definition
Dtype.h:29
open3d::core::Dtype::Bool
static const Dtype Bool
Definition
Dtype.h:33
open3d::core::Dtype::Int16
static const Dtype Int16
Definition
Dtype.h:26
open3d::core::Dtype::GetDtypeCode
DtypeCode GetDtypeCode() const
Definition
Dtype.h:60
open3d::core::Dtype::UInt32
static const Dtype UInt32
Definition
Dtype.h:31
open3d::core::Dtype::Float64
static const Dtype Float64
Definition
Dtype.h:24
open3d::core::Dtype::Dtype
Dtype()
Definition
Dtype.h:45
open3d::core::Dtype::Int32
static const Dtype Int32
Definition
Dtype.h:27
open3d::core::Dtype::UInt16
static const Dtype UInt16
Definition
Dtype.h:30
open3d::core::Dtype::ToString
std::string ToString() const
Definition
Dtype.h:64
open3d::core::Dtype::UInt64
static const Dtype UInt64
Definition
Dtype.h:32
open3d::core::Dtype::Float32
static const Dtype Float32
Definition
Dtype.h:23
open3d::core::Dtype::IsObject
bool IsObject() const
Definition
Dtype.h:62
open3d::core::Dtype::Undefined
static const Dtype Undefined
Definition
Dtype.h:22
open3d::core::Dtype::ByteSize
int64_t ByteSize() const
Definition
Dtype.h:58
open3d::core::Dtype::Int8
static const Dtype Int8
Definition
Dtype.h:25
open3d::core::Dtype::FromType
static const Dtype FromType()
Definition
Dtype.h:54
open3d::core::Dtype::DtypeCode
DtypeCode
Definition
Dtype.h:36
open3d::core::Dtype::DtypeCode::Object
@ Object
Definition
Dtype.h:42
open3d::core::Dtype::Int64
static const Dtype Int64
Definition
Dtype.h:28
open3d::core
Definition
AdvancedIndexing.cpp:15
open3d::core::UInt32
const Dtype UInt32
Definition
Dtype.cpp:50
open3d::core::Int64
const Dtype Int64
Definition
Dtype.cpp:47
open3d::core::UInt16
const Dtype UInt16
Definition
Dtype.cpp:49
open3d::core::Bool
const Dtype Bool
Definition
Dtype.cpp:52
open3d::core::Int32
const Dtype Int32
Definition
Dtype.cpp:46
open3d::core::Int16
const Dtype Int16
Definition
Dtype.cpp:45
open3d::core::Undefined
const Dtype Undefined
Definition
Dtype.cpp:41
open3d::core::UInt8
const Dtype UInt8
Definition
Dtype.cpp:48
open3d::core::Float64
const Dtype Float64
Definition
Dtype.cpp:43
open3d::core::UInt64
const Dtype UInt64
Definition
Dtype.cpp:51
open3d::core::Int8
const Dtype Int8
Definition
Dtype.cpp:44
open3d::core::Float32
const Dtype Float32
Definition
Dtype.cpp:42
open3d
Definition
PinholeCameraIntrinsic.cpp:16
Generated by
1.17.0