This repository was archived by the owner on Mar 24, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdecomposition.h
More file actions
56 lines (44 loc) · 2.65 KB
/
decomposition.h
File metadata and controls
56 lines (44 loc) · 2.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#pragma once
#include "decomposition-types.h"
namespace decomposition {
/**
* Finds all intersections of polygons (including self-intersections)
* @param vertices vertex coordinates, new vertices will be appended here
* @param polygonVertexIndices vertex indices per polygon
* @return vertex linkage objects, one per resulting vertex. All linkage objects constitutes one or more Eulerian graphs
*/
std::vector<VertexLinkage> insertSteinerVerticesForPolygons(std::vector<glm::dvec2>& vertices,
const std::vector<std::vector<int>>& polygonVertexIndices);
/**
* Transforms polygon vertex graph into set of non-intersecting polygons, keeping winding order of original polygons
* @param vertices vertex coordinates
* @param verticesLinkage vertex linkage objects, consumed by this function, see insertSteinerVerticesForPolygons()
* @return generated non-intersecting polygons
*/
std::vector<Polygon> decomposePolygonGraph(const std::vector<glm::dvec2>& vertices,
std::vector<VertexLinkage>&& verticesLinkage);
/**
* Builds trees from set of possibly nested and touching, but not intersecting polygons
* @param vertices vertex coordinates
* @param polygons input polygons, consumed by this function, see decomposePolygonGraph()
* @return root polygons of resulting trees
*/
std::vector<PolygonTree> buildPolygonTrees(const std::vector<glm::dvec2>& vertices,
std::vector<Polygon>&& polygons);
/**
* Rebuilds polygon trees to represent actual hierarchy of polygon areas rather than hierarchy of its contours
* @param tree input polygon tree, consumed by this function, see buildPolygonTrees()
* @return root polygons of resulting trees
*/
std::vector<PolygonWithHolesTree> buildPolygonAreaTrees(std::vector<PolygonTree>&& tree);
/**
* Optimally triangulates given polygon. Optimally means that it will try to minimize number of triangles and
* keep all triangles as close to equilateral as possible
* @param vertices vertex coordinates
* @param polygon input polygon, see buildPolygonAreaTrees()
* @return vertex indices of generated triangles. Winding order of triangles is derived from parent polygon.
* Number of triangles will not be more than 'vertices.size() + polygon.holes.size() * 2 - 2'
*/
std::vector<glm::ivec3> triangulatePolygonWithHoles(const std::vector<glm::dvec2>& vertices,
const PolygonWithHoles& polygon);
}