Loading [MathJax]/extensions/TeX/AMSsymbols.js
Open3D (C++ API)  0.16.0
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
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 
35 
36 namespace open3d {
37 namespace core {
38 
39 class SizeVector;
40 
50 class DynamicSizeVector : public SmallVector<utility::optional<int64_t>, 4> {
51 public:
54 
56  const std::initializer_list<utility::optional<int64_t>>& dim_sizes);
57 
58  DynamicSizeVector(const std::vector<utility::optional<int64_t>>& dim_sizes);
59 
61 
62  explicit DynamicSizeVector(int64_t n, int64_t initial_value = 0);
63 
64  template <class InputIterator>
65  DynamicSizeVector(InputIterator first, InputIterator last)
66  : super_t(first, last) {}
67 
68  DynamicSizeVector(const SizeVector& dim_sizes);
69 
70  SizeVector ToSizeVector() const;
71 
73 
75 
76  std::string ToString() const;
77 
78  bool IsDynamic() const;
79 
80  // required for pybind
81  void shrink_to_fit() {}
82 };
83 
88 class SizeVector : public SmallVector<int64_t, 4> {
89 public:
92 
93  SizeVector(const std::initializer_list<int64_t>& dim_sizes);
94 
95  SizeVector(const std::vector<int64_t>& dim_sizes);
96 
97  SizeVector(const SizeVector& other);
98 
99  explicit SizeVector(int64_t n, int64_t initial_value = 0);
100 
101  template <class InputIterator>
102  SizeVector(InputIterator first, InputIterator last)
103  : super_t(first, last) {}
104 
105  SizeVector& operator=(const SizeVector& v);
106 
108 
109  int64_t NumElements() const;
110 
111  int64_t GetLength() const;
112 
113  std::string ToString() const;
114 
115  void AssertCompatible(const DynamicSizeVector& dsv,
116  const std::string msg = "") const;
117 
118  bool IsCompatible(const DynamicSizeVector& dsv) const;
119 
120  operator std::vector<int64_t>() const {
121  return std::vector<int64_t>(begin(), end());
122  }
123 
124  // required for pybind
125  void shrink_to_fit() {}
126 };
127 
128 } // namespace core
129 } // namespace open3d
SizeVector()
Definition: SizeVector.h:91
DynamicSizeVector()
Definition: SizeVector.h:53
Definition: SizeVector.h:50
DynamicSizeVector & operator=(const DynamicSizeVector &v)
Definition: SizeVector.cpp:70
Definition: SmallVector.h:1279
SizeVector ToSizeVector() const
Definition: SizeVector.cpp:59
DynamicSizeVector(InputIterator first, InputIterator last)
Definition: SizeVector.h:65
bool IsDynamic() const
Definition: SizeVector.cpp:100
Definition: SizeVector.h:88
void shrink_to_fit()
Definition: SizeVector.h:81
void shrink_to_fit()
Definition: SizeVector.h:125
SizeVector(InputIterator first, InputIterator last)
Definition: SizeVector.h:102
Definition: PinholeCameraIntrinsic.cpp:35
std::string ToString() const
Definition: SizeVector.cpp:80