Open3D (C++ API)  0.18.0+5c982c7
SelectionPolygon.h
Go to the documentation of this file.
1 // ----------------------------------------------------------------------------
2 // - Open3D: www.open3d.org -
3 // ----------------------------------------------------------------------------
4 // Copyright (c) 2018-2023 www.open3d.org
5 // SPDX-License-Identifier: MIT
6 // ----------------------------------------------------------------------------
7 
8 #pragma once
9 
10 #include <Eigen/Core>
11 #include <memory>
12 #include <vector>
13 
15 #include "open3d/geometry/Image.h"
16 
17 namespace open3d {
18 
19 namespace geometry {
20 class PointCloud;
21 class TriangleMesh;
22 } // namespace geometry
23 
24 namespace visualization {
25 class ViewControl;
26 class SelectionPolygonVolume;
27 
33 public:
34  enum class SectionPolygonType {
35  Unfilled = 0,
36  Rectangle = 1,
37  Polygon = 2,
38  };
39 
40 public:
42  : geometry::Geometry2D(geometry::Geometry::GeometryType::Unspecified) {}
43  ~SelectionPolygon() override {}
44 
45 public:
46  SelectionPolygon &Clear() override;
47  bool IsEmpty() const override;
48  Eigen::Vector2d GetMinBound() const final;
49  Eigen::Vector2d GetMaxBound() const final;
50  void FillPolygon(int width, int height);
51  std::shared_ptr<geometry::PointCloud> CropPointCloud(
52  const geometry::PointCloud &input, const ViewControl &view);
53  std::shared_ptr<geometry::TriangleMesh> CropTriangleMesh(
54  const geometry::TriangleMesh &input, const ViewControl &view);
56  const ViewControl &view);
57 
58 private:
59  std::shared_ptr<geometry::PointCloud> CropPointCloudInRectangle(
60  const geometry::PointCloud &input, const ViewControl &view);
61  std::shared_ptr<geometry::PointCloud> CropPointCloudInPolygon(
62  const geometry::PointCloud &input, const ViewControl &view);
63  std::shared_ptr<geometry::TriangleMesh> CropTriangleMeshInRectangle(
64  const geometry::TriangleMesh &input, const ViewControl &view);
65  std::shared_ptr<geometry::TriangleMesh> CropTriangleMeshInPolygon(
66  const geometry::TriangleMesh &input, const ViewControl &view);
67  std::vector<size_t> CropInRectangle(
68  const std::vector<Eigen::Vector3d> &input, const ViewControl &view);
69  std::vector<size_t> CropInPolygon(const std::vector<Eigen::Vector3d> &input,
70  const ViewControl &view);
71 
72 public:
73  std::vector<Eigen::Vector2d> polygon_;
74  bool is_closed_ = false;
77 };
78 
79 } // namespace visualization
80 } // namespace open3d
The base geometry class for 2D geometries.
Definition: Geometry2D.h:22
The base geometry class.
Definition: Geometry.h:18
GeometryType
Specifies possible geometry types.
Definition: Geometry.h:23
The Image class stores image with customizable width, height, num of channels and bytes per channel.
Definition: Image.h:34
A point cloud consists of point coordinates, and optionally point colors and point normals.
Definition: PointCloud.h:36
Triangle mesh contains vertices and triangles represented by the indices to the vertices.
Definition: TriangleMesh.h:35
Definition: SelectionPolygon.h:32
std::shared_ptr< geometry::TriangleMesh > CropTriangleMesh(const geometry::TriangleMesh &input, const ViewControl &view)
Definition: SelectionPolygon.cpp:124
SectionPolygonType
Definition: SelectionPolygon.h:34
Eigen::Vector2d GetMinBound() const final
Returns min bounds for geometry coordinates.
Definition: SelectionPolygon.cpp:35
void FillPolygon(int width, int height)
Definition: SelectionPolygon.cpp:69
std::shared_ptr< SelectionPolygonVolume > CreateSelectionPolygonVolume(const ViewControl &view)
Definition: SelectionPolygon.cpp:148
bool IsEmpty() const override
Returns true iff the geometry is empty.
Definition: SelectionPolygon.cpp:30
std::shared_ptr< geometry::PointCloud > CropPointCloud(const geometry::PointCloud &input, const ViewControl &view)
Definition: SelectionPolygon.cpp:108
SectionPolygonType polygon_type_
Definition: SelectionPolygon.h:76
~SelectionPolygon() override
Definition: SelectionPolygon.h:43
bool is_closed_
Definition: SelectionPolygon.h:74
SelectionPolygon()
Definition: SelectionPolygon.h:41
Eigen::Vector2d GetMaxBound() const final
Returns max bounds for geometry coordinates.
Definition: SelectionPolygon.cpp:52
std::vector< Eigen::Vector2d > polygon_
Definition: SelectionPolygon.h:73
SelectionPolygon & Clear() override
Clear all elements in the geometry.
Definition: SelectionPolygon.cpp:22
geometry::Image polygon_interior_mask_
Definition: SelectionPolygon.h:75
Select a polygon volume for cropping.
Definition: SelectionPolygonVolume.h:30
View controller for visualizer.
Definition: ViewControl.h:23
int width
Definition: FilePCD.cpp:52
int height
Definition: FilePCD.cpp:53
Definition: NonRigidOptimizer.cpp:22
Definition: PinholeCameraIntrinsic.cpp:16
Definition: Device.h:107