Open3D (C++ API)  0.15.1
SizeVector.h
Go to the documentation of this file.
1// ----------------------------------------------------------------------------
2// - Open3D: www.open3d.org -
3// ----------------------------------------------------------------------------
4// The MIT License (MIT)
5//
6// Copyright (c) 2018-2021 www.open3d.org
7//
8// Permission is hereby granted, free of charge, to any person obtaining a copy
9// of this software and associated documentation files (the "Software"), to deal
10// in the Software without restriction, including without limitation the rights
11// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12// copies of the Software, and to permit persons to whom the Software is
13// furnished to do so, subject to the following conditions:
14//
15// The above copyright notice and this permission notice shall be included in
16// all copies or substantial portions of the Software.
17//
18// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
24// IN THE SOFTWARE.
25// ----------------------------------------------------------------------------
26
27#pragma once
28
29#include <cstddef>
30#include <string>
31#include <vector>
32
34
35namespace open3d {
36namespace core {
37
38class SizeVector;
39
47class DynamicSizeVector : public std::vector<utility::optional<int64_t>> {
48public:
50
52 const std::initializer_list<utility::optional<int64_t>>& dim_sizes);
53
54 DynamicSizeVector(const std::vector<utility::optional<int64_t>>& dim_sizes);
55
57
58 explicit DynamicSizeVector(int64_t n, int64_t initial_value = 0);
59
60 template <class InputIterator>
61 DynamicSizeVector(InputIterator first, InputIterator last)
62 : std::vector<utility::optional<int64_t>>(first, last) {}
63
64 DynamicSizeVector(const SizeVector& dim_sizes);
65
67
69
71
72 std::string ToString() const;
73
74 bool IsDynamic() const;
75};
76
79class SizeVector : public std::vector<int64_t> {
80public:
82
83 SizeVector(const std::initializer_list<int64_t>& dim_sizes);
84
85 SizeVector(const std::vector<int64_t>& dim_sizes);
86
87 SizeVector(const SizeVector& other);
88
89 explicit SizeVector(int64_t n, int64_t initial_value = 0);
90
91 template <class InputIterator>
92 SizeVector(InputIterator first, InputIterator last)
93 : std::vector<int64_t>(first, last) {}
94
96
98
99 int64_t NumElements() const;
100
101 int64_t GetLength() const;
102
103 std::string ToString() const;
104
105 void AssertCompatible(const DynamicSizeVector& dsv,
106 const std::string msg = "") const;
107
108 bool IsCompatible(const DynamicSizeVector& dsv) const;
109};
110
111} // namespace core
112} // namespace open3d
Definition: SizeVector.h:47
DynamicSizeVector(InputIterator first, InputIterator last)
Definition: SizeVector.h:61
bool IsDynamic() const
Definition: SizeVector.cpp:100
SizeVector ToSizeVector() const
Definition: SizeVector.cpp:59
DynamicSizeVector & operator=(const DynamicSizeVector &v)
Definition: SizeVector.cpp:70
std::string ToString() const
Definition: SizeVector.cpp:80
DynamicSizeVector()
Definition: SizeVector.h:49
Definition: SizeVector.h:79
bool IsCompatible(const DynamicSizeVector &dsv) const
Definition: SizeVector.cpp:166
void AssertCompatible(const DynamicSizeVector &dsv, const std::string msg="") const
Definition: SizeVector.cpp:153
SizeVector()
Definition: SizeVector.h:81
int64_t NumElements() const
Definition: SizeVector.cpp:127
SizeVector(InputIterator first, InputIterator last)
Definition: SizeVector.h:92
SizeVector & operator=(const SizeVector &v)
Definition: SizeVector.cpp:117
int64_t GetLength() const
Definition: SizeVector.cpp:143
std::string ToString() const
Definition: SizeVector.cpp:151
Definition: PinholeCameraIntrinsic.cpp:35
Definition: Device.h:138