Open3D (C++ API)
ViewTrajectory.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 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 <Eigen/Core>
30 #include <tuple>
31 #include <vector>
32 
35 
36 namespace open3d {
37 namespace visualization {
38 
40 public:
41  static const int INTERVAL_MAX;
42  static const int INTERVAL_MIN;
43  static const int INTERVAL_STEP;
44  static const int INTERVAL_DEFAULT;
45 
46 public:
48  ~ViewTrajectory() override {}
49 
50 public:
60 
61  void ChangeInterval(int change) {
62  int new_interval = interval_ + change * INTERVAL_STEP;
63  if (new_interval >= INTERVAL_MIN && new_interval <= INTERVAL_MAX) {
64  interval_ = new_interval;
65  }
66  }
67 
68  size_t NumOfFrames() const {
69  if (view_status_.empty()) {
70  return 0;
71  } else {
72  return is_loop_ ? (interval_ + 1) * view_status_.size()
73  : (interval_ + 1) * (view_status_.size() - 1) + 1;
74  }
75  }
76 
77  void Reset() {
78  is_loop_ = false;
80  view_status_.clear();
81  }
82 
83  std::tuple<bool, ViewParameters> GetInterpolatedFrame(size_t k);
84 
85  bool ConvertToJsonValue(Json::Value &value) const override;
86  bool ConvertFromJsonValue(const Json::Value &value) override;
87 
88 public:
89  std::vector<ViewParameters> view_status_;
90  bool is_loop_ = false;
92  std::vector<ViewParameters::Matrix17x4d,
95 };
96 
97 } // namespace visualization
98 } // namespace open3d
Definition: ViewTrajectory.h:39
void ChangeInterval(int change)
Definition: ViewTrajectory.h:61
void ComputeInterpolationCoefficients()
Definition: ViewTrajectory.cpp:42
bool is_loop_
Definition: ViewTrajectory.h:90
void Reset()
Definition: ViewTrajectory.h:77
static const int INTERVAL_MIN
Definition: ViewTrajectory.h:42
std::vector< ViewParameters > view_status_
Definition: ViewTrajectory.h:89
Eigen::Matrix< double, 17, 4, Eigen::RowMajor > Matrix17x4d
Definition: ViewParameters.h:39
Eigen::aligned_allocator< Matrix17x4d > Matrix17x4d_allocator
Definition: ViewParameters.h:41
bool ConvertToJsonValue(Json::Value &value) const override
Definition: ViewTrajectory.cpp:147
std::tuple< bool, ViewParameters > GetInterpolatedFrame(size_t k)
Definition: ViewTrajectory.cpp:130
ViewTrajectory()
Definition: ViewTrajectory.h:47
~ViewTrajectory() override
Definition: ViewTrajectory.h:48
int interval_
Definition: ViewTrajectory.h:91
static const int INTERVAL_MAX
Definition: ViewTrajectory.h:41
std::vector< ViewParameters::Matrix17x4d, ViewParameters::Matrix17x4d_allocator > coeff_
Definition: ViewTrajectory.h:94
Definition: Open3DViewer.h:29
size_t NumOfFrames() const
Definition: ViewTrajectory.h:68
static const int INTERVAL_DEFAULT
Definition: ViewTrajectory.h:44
bool ConvertFromJsonValue(const Json::Value &value) override
Definition: ViewTrajectory.cpp:165
static const int INTERVAL_STEP
Definition: ViewTrajectory.h:43
Definition: IJsonConvertible.h:42