Open3D (C++ API)
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
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 <Eigen/Core>
30 #include <memory>
31 #include <vector>
32 
34 
35 namespace open3d {
36 namespace geometry {
37 
38 class PointCloud;
39 class OrientedBoundingBox;
40 class AxisAlignedBoundingBox;
41 class TriangleMesh;
42 class TetraMesh;
43 
44 class LineSet : public Geometry3D {
45 public:
47  ~LineSet() override {}
48 
49 public:
50  LineSet &Clear() override;
51  bool IsEmpty() const override;
52  Eigen::Vector3d GetMinBound() const override;
53  Eigen::Vector3d GetMaxBound() const override;
54  Eigen::Vector3d GetCenter() const override;
57  LineSet &Transform(const Eigen::Matrix4d &transformation) override;
58  LineSet &Translate(const Eigen::Vector3d &translation,
59  bool relative = true) override;
60  LineSet &Scale(const double scale, bool center = true) override;
61  LineSet &Rotate(const Eigen::Vector3d &rotation,
62  bool center = true,
64 
65  LineSet &operator+=(const LineSet &lineset);
66  LineSet operator+(const LineSet &lineset) const;
67 
68  bool HasPoints() const { return points_.size() > 0; }
69 
70  bool HasLines() const { return HasPoints() && lines_.size() > 0; }
71 
72  bool HasColors() const {
73  return HasLines() && colors_.size() == lines_.size();
74  }
75 
76  std::pair<Eigen::Vector3d, Eigen::Vector3d> GetLineCoordinate(
77  size_t line_index) const {
78  return std::make_pair(points_[lines_[line_index][0]],
79  points_[lines_[line_index][1]]);
80  }
81 
83  LineSet &PaintUniformColor(const Eigen::Vector3d &color) {
85  return *this;
86  }
87 
91  static std::shared_ptr<LineSet> CreateFromPointCloudCorrespondences(
92  const PointCloud &cloud0,
93  const PointCloud &cloud1,
94  const std::vector<std::pair<int, int>> &correspondences);
95 
96  static std::shared_ptr<LineSet> CreateFromOrientedBoundingBox(
97  const OrientedBoundingBox &box);
98  static std::shared_ptr<LineSet> CreateFromAxisAlignedBoundingBox(
99  const AxisAlignedBoundingBox &box);
100 
103  static std::shared_ptr<LineSet> CreateFromTriangleMesh(
104  const TriangleMesh &mesh);
105 
108  static std::shared_ptr<LineSet> CreateFromTetraMesh(const TetraMesh &mesh);
109 
110 public:
111  std::vector<Eigen::Vector3d> points_;
112  std::vector<Eigen::Vector2i> lines_;
113  std::vector<Eigen::Vector3d> colors_;
114 };
115 
116 } // namespace geometry
117 } // namespace open3d
std::vector< Eigen::Vector2i > lines_
Definition: LineSet.h:112
Definition: Geometry.h:32
Definition: BoundingVolume.h:90
Definition: BoundingVolume.h:38
Definition: PointCloud.h:50
static std::shared_ptr< LineSet > CreateFromAxisAlignedBoundingBox(const AxisAlignedBoundingBox &box)
Definition: LineSetFactory.cpp:104
LineSet & Clear() override
Definition: LineSet.cpp:35
bool HasColors() const
Definition: LineSet.h:72
RotationType
Definition: Geometry3D.h:43
static std::shared_ptr< LineSet > CreateFromTriangleMesh(const TriangleMesh &mesh)
Definition: LineSetFactory.cpp:60
LineSet & Translate(const Eigen::Vector3d &translation, bool relative=true) override
Definition: LineSet.cpp:67
std::vector< Eigen::Vector3d > points_
Definition: LineSet.h:111
~LineSet() override
Definition: LineSet.h:47
std::vector< Eigen::Vector3d > colors_
Definition: LineSet.h:113
std::pair< Eigen::Vector3d, Eigen::Vector3d > GetLineCoordinate(size_t line_index) const
Definition: LineSet.h:76
Definition: Geometry3D.h:41
LineSet & operator+=(const LineSet &lineset)
Definition: LineSet.cpp:84
Eigen::Vector3d GetMaxBound() const override
Definition: LineSet.cpp:48
OrientedBoundingBox GetOrientedBoundingBox() const override
Definition: LineSet.cpp:58
Definition: TetraMesh.h:44
static std::shared_ptr< LineSet > CreateFromPointCloudCorrespondences(const PointCloud &cloud0, const PointCloud &cloud1, const std::vector< std::pair< int, int >> &correspondences)
Definition: LineSetFactory.cpp:38
Eigen::Vector3d GetCenter() const override
Definition: LineSet.cpp:52
char type
Definition: FilePCD.cpp:56
LineSet & Scale(const double scale, bool center=true) override
Definition: LineSet.cpp:72
Definition: PinholeCameraIntrinsic.cpp:34
GeometryType
Definition: Geometry.h:34
static std::shared_ptr< LineSet > CreateFromOrientedBoundingBox(const OrientedBoundingBox &box)
Definition: LineSetFactory.cpp:84
LineSet & PaintUniformColor(const Eigen::Vector3d &color)
Assigns each line in the LineSet the same color.
Definition: LineSet.h:83
bool HasPoints() const
Definition: LineSet.h:68
bool IsEmpty() const override
Definition: LineSet.cpp:42
LineSet()
Definition: LineSet.h:46
void ResizeAndPaintUniformColor(std::vector< Eigen::Vector3d > &colors, const size_t size, const Eigen::Vector3d &color) const
Definition: Geometry3D.cpp:71
AxisAlignedBoundingBox GetAxisAlignedBoundingBox() const override
Definition: LineSet.cpp:54
LineSet & Rotate(const Eigen::Vector3d &rotation, bool center=true, RotationType type=RotationType::XYZ) override
Definition: LineSet.cpp:77
bool HasLines() const
Definition: LineSet.h:70
Definition: TriangleMesh.h:43
Definition: LineSet.h:44
Eigen::Vector3d GetMinBound() const override
Definition: LineSet.cpp:44
LineSet operator+(const LineSet &lineset) const
Definition: LineSet.cpp:114
static std::shared_ptr< LineSet > CreateFromTetraMesh(const TetraMesh &mesh)
Definition: LineSetFactory.cpp:124
long line_index
Definition: FilePLY.cpp:216
LineSet & Transform(const Eigen::Matrix4d &transformation) override
Definition: LineSet.cpp:62