Open3D (C++ API)  0.16.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-2021 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
35
36namespace open3d {
37
38namespace geometry {
39class PointCloud;
40class TriangleMesh;
41} // namespace geometry
42
43namespace visualization {
44class ViewControl;
45class SelectionPolygonVolume;
46
52public:
53 enum class SectionPolygonType {
54 Unfilled = 0,
55 Rectangle = 1,
56 Polygon = 2,
57 };
58
59public:
61 : geometry::Geometry2D(geometry::Geometry::GeometryType::Unspecified) {}
62 ~SelectionPolygon() override {}
63
64public:
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);
75 const ViewControl &view);
76
77private:
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
91public:
92 std::vector<Eigen::Vector2d> polygon_;
93 bool is_closed_ = false;
96};
97
98} // namespace visualization
99} // namespace open3d
The base geometry class for 2D geometries.
Definition: Geometry2D.h:41
The base geometry class.
Definition: Geometry.h:37
GeometryType
Specifies possible geometry types.
Definition: Geometry.h:42
The Image class stores image with customizable width, height, num of channels and bytes per channel.
Definition: Image.h:53
A point cloud consists of point coordinates, and optionally point colors and point normals.
Definition: PointCloud.h:55
Triangle mesh contains vertices and triangles represented by the indices to the vertices.
Definition: TriangleMesh.h:54
Definition: SelectionPolygon.h:51
std::shared_ptr< geometry::TriangleMesh > CropTriangleMesh(const geometry::TriangleMesh &input, const ViewControl &view)
Definition: SelectionPolygon.cpp:143
SectionPolygonType
Definition: SelectionPolygon.h:53
Eigen::Vector2d GetMinBound() const final
Returns min bounds for geometry coordinates.
Definition: SelectionPolygon.cpp:54
void FillPolygon(int width, int height)
Definition: SelectionPolygon.cpp:88
std::shared_ptr< SelectionPolygonVolume > CreateSelectionPolygonVolume(const ViewControl &view)
Definition: SelectionPolygon.cpp:167
bool IsEmpty() const override
Returns true iff the geometry is empty.
Definition: SelectionPolygon.cpp:49
std::shared_ptr< geometry::PointCloud > CropPointCloud(const geometry::PointCloud &input, const ViewControl &view)
Definition: SelectionPolygon.cpp:127
SectionPolygonType polygon_type_
Definition: SelectionPolygon.h:95
~SelectionPolygon() override
Definition: SelectionPolygon.h:62
bool is_closed_
Definition: SelectionPolygon.h:93
SelectionPolygon()
Definition: SelectionPolygon.h:60
Eigen::Vector2d GetMaxBound() const final
Returns max bounds for geometry coordinates.
Definition: SelectionPolygon.cpp:71
std::vector< Eigen::Vector2d > polygon_
Definition: SelectionPolygon.h:92
SelectionPolygon & Clear() override
Clear all elements in the geometry.
Definition: SelectionPolygon.cpp:41
geometry::Image polygon_interior_mask_
Definition: SelectionPolygon.h:94
Select a polygon volume for cropping.
Definition: SelectionPolygonVolume.h:49
View controller for visualizer.
Definition: ViewControl.h:41
int width
Definition: FilePCD.cpp:71
int height
Definition: FilePCD.cpp:72
Definition: NonRigidOptimizer.cpp:41
Definition: PinholeCameraIntrinsic.cpp:35
Definition: Device.h:126