Open3D (C++ API)
SelectionPolygon.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 #include "Open3D/Geometry/Image.h"
35 
36 namespace open3d {
37 
38 namespace geometry {
39 class PointCloud;
40 class TriangleMesh;
41 } // namespace geometry
42 
43 namespace visualization {
44 class ViewControl;
45 class SelectionPolygonVolume;
46 
52 public:
53  enum class SectionPolygonType {
54  Unfilled = 0,
55  Rectangle = 1,
56  Polygon = 2,
57  };
58 
59 public:
61  : geometry::Geometry2D(geometry::Geometry::GeometryType::Unspecified) {}
62  ~SelectionPolygon() override {}
63 
64 public:
65  void Clear() override;
66  bool IsEmpty() const override;
67  Eigen::Vector2d GetMinBound() const final;
68  Eigen::Vector2d GetMaxBound() const final;
69  void FillPolygon(int width, int height);
70  std::shared_ptr<geometry::PointCloud> CropPointCloud(
71  const geometry::PointCloud &input, const ViewControl &view);
72  std::shared_ptr<geometry::TriangleMesh> CropTriangleMesh(
73  const geometry::TriangleMesh &input, const ViewControl &view);
74  std::shared_ptr<SelectionPolygonVolume> CreateSelectionPolygonVolume(
75  const ViewControl &view);
76 
77 private:
78  std::shared_ptr<geometry::PointCloud> CropPointCloudInRectangle(
79  const geometry::PointCloud &input, const ViewControl &view);
80  std::shared_ptr<geometry::PointCloud> CropPointCloudInPolygon(
81  const geometry::PointCloud &input, const ViewControl &view);
82  std::shared_ptr<geometry::TriangleMesh> CropTriangleMeshInRectangle(
83  const geometry::TriangleMesh &input, const ViewControl &view);
84  std::shared_ptr<geometry::TriangleMesh> CropTriangleMeshInPolygon(
85  const geometry::TriangleMesh &input, const ViewControl &view);
86  std::vector<size_t> CropInRectangle(
87  const std::vector<Eigen::Vector3d> &input, const ViewControl &view);
88  std::vector<size_t> CropInPolygon(const std::vector<Eigen::Vector3d> &input,
89  const ViewControl &view);
90 
91 public:
92  std::vector<Eigen::Vector2d> polygon_;
93  bool is_closed_ = false;
95  SectionPolygonType polygon_type_ = SectionPolygonType::Unfilled;
96 };
97 
98 } // namespace visualization
99 } // namespace open3d
std::shared_ptr< TriangleMesh > CropTriangleMesh(const TriangleMesh &input, const Eigen::Vector3d &min_bound, const Eigen::Vector3d &max_bound)
Definition: DownSample.cpp:490
Definition: Geometry.h:32
std::vector< Eigen::Vector2d > polygon_
Definition: SelectionPolygon.h:92
Definition: SelectionPolygon.h:51
geometry::Image polygon_interior_mask_
Definition: SelectionPolygon.h:94
Definition: ViewControl.h:38
Definition: PointCloud.h:49
Definition: Geometry2D.h:36
SectionPolygonType
Definition: SelectionPolygon.h:53
SelectionPolygon()
Definition: SelectionPolygon.h:60
Definition: PinholeCameraIntrinsic.cpp:34
~SelectionPolygon() override
Definition: SelectionPolygon.h:62
GeometryType
Definition: Geometry.h:34
int height
Definition: FilePCD.cpp:68
std::shared_ptr< PointCloud > CropPointCloud(const PointCloud &input, const Eigen::Vector3d &min_bound, const Eigen::Vector3d &max_bound)
Definition: DownSample.cpp:375
Definition: TriangleMesh.h:43
Definition: Image.h:44
int width
Definition: FilePCD.cpp:67