Open3D (C++ API)
LineSet.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 <vector>
30 #include <memory>
31 #include <Eigen/Core>
33 
34 namespace open3d {
35 namespace geometry {
36 
37 class PointCloud;
38 
39 class LineSet : public Geometry3D {
40 public:
42  ~LineSet() override {}
43 
44 public:
45  void Clear() override;
46  bool IsEmpty() const override;
47  Eigen::Vector3d GetMinBound() const override;
48  Eigen::Vector3d GetMaxBound() const override;
49  void Transform(const Eigen::Matrix4d &transformation) override;
50 
51 public:
52  LineSet &operator+=(const LineSet &lineset);
53  LineSet operator+(const LineSet &lineset) const;
54 
55 public:
56  bool HasPoints() const { return points_.size() > 0; }
57 
58  bool HasLines() const { return HasPoints() && lines_.size() > 0; }
59 
60  bool HasColors() const {
61  return HasLines() && colors_.size() == lines_.size();
62  }
63 
64  std::pair<Eigen::Vector3d, Eigen::Vector3d> GetLineCoordinate(
65  size_t line_index) const {
66  return std::make_pair(points_[lines_[line_index][0]],
67  points_[lines_[line_index][1]]);
68  }
69 
70 public:
71  std::vector<Eigen::Vector3d> points_;
72  std::vector<Eigen::Vector2i> lines_;
73  std::vector<Eigen::Vector3d> colors_;
74 };
75 
78 std::shared_ptr<LineSet> CreateLineSetFromPointCloudCorrespondences(
79  const PointCloud &cloud0,
80  const PointCloud &cloud1,
81  const std::vector<std::pair<int, int>> &correspondences);
82 
83 } // namespace geometry
84 } // namespace open3d
std::vector< Eigen::Vector2i > lines_
Definition: LineSet.h:72
Definition: Geometry.h:32
Definition: PointCloud.h:47
std::shared_ptr< LineSet > CreateLineSetFromPointCloudCorrespondences(const PointCloud &cloud0, const PointCloud &cloud1, const std::vector< std::pair< int, int >> &correspondences)
Definition: LineSetFactory.cpp:35
bool HasColors() const
Definition: LineSet.h:60
std::vector< Eigen::Vector3d > points_
Definition: LineSet.h:71
~LineSet() override
Definition: LineSet.h:42
std::vector< Eigen::Vector3d > colors_
Definition: LineSet.h:73
std::pair< Eigen::Vector3d, Eigen::Vector3d > GetLineCoordinate(size_t line_index) const
Definition: LineSet.h:64
Definition: Geometry3D.h:35
void Clear() override
Definition: LineSet.cpp:32
LineSet & operator+=(const LineSet &lineset)
Definition: LineSet.cpp:93
Eigen::Vector3d GetMaxBound() const override
Definition: LineSet.cpp:62
void Transform(const Eigen::Matrix4d &transformation) override
Definition: LineSet.cpp:84
Definition: PinholeCameraIntrinsic.cpp:33
GeometryType
Definition: Geometry.h:34
bool HasPoints() const
Definition: LineSet.h:56
bool IsEmpty() const override
Definition: LineSet.cpp:38
LineSet()
Definition: LineSet.h:41
bool HasLines() const
Definition: LineSet.h:58
Definition: LineSet.h:39
Eigen::Vector3d GetMinBound() const override
Definition: LineSet.cpp:40
LineSet operator+(const LineSet &lineset) const
Definition: LineSet.cpp:123
long line_index
Definition: FilePLY.cpp:205