Open3D (C++ API)  0.12.0
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  SelectionPolygon &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
The base geometry class.
Definition: Geometry.h:37
std::vector< Eigen::Vector2d > polygon_
Definition: SelectionPolygon.h:92
Definition: SelectionPolygon.h:51
geometry::Image polygon_interior_mask_
Definition: SelectionPolygon.h:94
View controller for visualizer.
Definition: ViewControl.h:41
A point cloud consists of point coordinates, and optionally point colors and point normals...
Definition: PointCloud.h:54
The base geometry class for 2D geometries.
Definition: Geometry2D.h:41
SectionPolygonType
Definition: SelectionPolygon.h:53
SelectionPolygon()
Definition: SelectionPolygon.h:60
Definition: PinholeCameraIntrinsic.cpp:35
~SelectionPolygon() override
Definition: SelectionPolygon.h:62
GeometryType
Specifies possible geometry types.
Definition: Geometry.h:42
int height
Definition: FilePCD.cpp:72
Triangle mesh contains vertices and triangles represented by the indices to the vertices.
Definition: TriangleMesh.h:54
The Image class stores image with customizable width, height, num of channels and bytes per channel...
Definition: Image.h:53
int width
Definition: FilePCD.cpp:71