Loading [MathJax]/extensions/TeX/AMSsymbols.js
Open3D (C++ API)  0.14.1
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 
34 
35 namespace open3d {
36 namespace core {
37 
38 class SizeVector;
39 
47 class DynamicSizeVector : public std::vector<utility::optional<int64_t>> {
48 public:
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 
66  SizeVector ToSizeVector() const;
67 
69 
71 
72  std::string ToString() const;
73 
74  bool IsDynamic() const;
75 };
76 
79 class SizeVector : public std::vector<int64_t> {
80 public:
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 
95  SizeVector& operator=(const SizeVector& v);
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
SizeVector()
Definition: SizeVector.h:81
DynamicSizeVector()
Definition: SizeVector.h:49
Definition: SizeVector.h:47
DynamicSizeVector & operator=(const DynamicSizeVector &v)
Definition: SizeVector.cpp:69
Definition: Device.h:138
SizeVector ToSizeVector() const
Definition: SizeVector.cpp:58
DynamicSizeVector(InputIterator first, InputIterator last)
Definition: SizeVector.h:61
bool IsDynamic() const
Definition: SizeVector.cpp:99
Definition: SizeVector.h:79
SizeVector(InputIterator first, InputIterator last)
Definition: SizeVector.h:92
Definition: PinholeCameraIntrinsic.cpp:35
std::string ToString() const
Definition: SizeVector.cpp:79