Easy3D 2.5.3
polygon_partition.h
1/********************************************************************
2 * Copyright (C) 2015 Liangliang Nan <liangliang.nan@gmail.com>
3 * https://3d.bk.tudelft.nl/liangliang/
4 *
5 * This file is part of Easy3D. If it is useful in your research/work,
6 * I would be grateful if you show your appreciation by citing it:
7 * ------------------------------------------------------------------
8 * Liangliang Nan.
9 * Easy3D: a lightweight, easy-to-use, and efficient C++ library
10 * for processing and rendering 3D data.
11 * Journal of Open Source Software, 6(64), 3255, 2021.
12 * ------------------------------------------------------------------
13 *
14 * Easy3D is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License Version 3
16 * as published by the Free Software Foundation.
17 *
18 * Easy3D is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
22 *
23 * You should have received a copy of the GNU General Public License
24 * along with this program. If not, see <http://www.gnu.org/licenses/>.
25 ********************************************************************/
26
27#ifndef EASY3D_ALGO_POLYGON_PARTITION_H
28#define EASY3D_ALGO_POLYGON_PARTITION_H
29
30
31#include <vector>
32
33#include "easy3d/core/types.h"
34
35
36namespace easy3d {
37
45 public:
47 typedef std::vector<std::size_t> Polygon;
48
49 public:
51 PolygonPartition() = default;
52
65 static bool apply_OPT(const std::vector<vec2> &poly, std::vector<Polygon> &parts);
66
81 static bool apply_HM(const std::vector<vec2> &poly, std::vector<Polygon> &parts);
82
102 static bool apply(const std::vector<vec2> &points,
103 const std::vector<Polygon> &polys,
104 const std::vector<Polygon> &holes,
105 std::vector<Polygon> &parts);
106 };
107
108}
109
110
111#endif // EASY3D_ALGO_POLYGON_PARTITION_H
Convex partition of polygons.
Definition: polygon_partition.h:44
static bool apply_HM(const std::vector< vec2 > &poly, std::vector< Polygon > &parts)
Partition a polygon into convex polygons by using the Hertel-Mehlhorn algorithm.
Definition: polygon_partition.cpp:64
PolygonPartition()=default
Default constructor.
static bool apply(const std::vector< vec2 > &points, const std::vector< Polygon > &polys, const std::vector< Polygon > &holes, std::vector< Polygon > &parts)
Convex partition of a general polygon with an arbitrary number of non-hole and hole contours.
Definition: polygon_partition.cpp:92
static bool apply_OPT(const std::vector< vec2 > &poly, std::vector< Polygon > &parts)
Optimal convex partition (in terms of number of resulting convex polygons) of a polygon into convex p...
Definition: polygon_partition.cpp:36
std::vector< std::size_t > Polygon
An indexed polygon representation (defined by vertex indices).
Definition: polygon_partition.h:47
Definition: collider.cpp:182