forked from openscad/openscad
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGeometryUtils.h
39 lines (31 loc) · 1.1 KB
/
GeometryUtils.h
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
#pragma once
#include "linalg.h"
#include <vector>
typedef std::vector<Vector3d> Polygon;
typedef std::vector<Polygon> Polygons;
typedef std::vector<int> IndexedFace;
typedef Vector3i IndexedTriangle;
struct IndexedPolygons {
std::vector<Vector3f> vertices;
std::vector<IndexedFace> faces;
};
struct IndexedTriangleMesh {
std::vector<Vector3f> vertices;
std::vector<IndexedTriangle> triangles;
};
// Indexed polygon mesh, where each polygon can have holes
struct IndexedPolyMesh {
std::vector<Vector3f> vertices;
std::vector<std::vector<IndexedFace>> polygons;
};
namespace GeometryUtils {
bool tessellatePolygon(const Polygon &polygon,
Polygons &triangles,
const Vector3f *normal = nullptr);
bool tessellatePolygonWithHoles(const std::vector<Vector3f>& vertices,
const std::vector<IndexedFace> &faces,
std::vector<IndexedTriangle> &triangles,
const Vector3f *normal = nullptr);
int findUnconnectedEdges(const std::vector<std::vector<IndexedFace>> &polygons);
int findUnconnectedEdges(const std::vector<IndexedTriangle> &triangles);
}