forked from openscad/openscad
-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathGeometryUtils.h
More file actions
49 lines (37 loc) · 1.62 KB
/
Copy pathGeometryUtils.h
File metadata and controls
49 lines (37 loc) · 1.62 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
#pragma once
#include <boost/container/small_vector.hpp>
#include <memory>
#include <vector>
#include "geometry/Geometry.h"
#include "geometry/linalg.h"
using Polygon = std::vector<Vector3d>;
using Polygons = std::vector<Polygon>;
// faces are usually triangles or quads
using IndexedFace = boost::container::small_vector<int, 4>;
using IndexedTriangle = Vector3i;
using PolygonIndices = std::vector<IndexedFace>;
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);
Transform3d getResizeTransform(const BoundingBox& bbox, const Vector3d& newsize,
const Eigen::Matrix<bool, 3, 1>& autosize);
std::shared_ptr<const Geometry> getBackendSpecificGeometry(const std::shared_ptr<const Geometry>& geom);
} // namespace GeometryUtils