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