1
#ifndef slic3r_TriangleMesh_hpp_
2
#define slic3r_TriangleMesh_hpp_
5
#include <admesh/stl.h>
7
#include "BoundingBox.hpp"
10
#include "ExPolygon.hpp"
15
class TriangleMeshSlicer;
16
typedef std::vector<TriangleMesh*> TriangleMeshPtrs;
22
TriangleMesh(const TriangleMesh &other);
23
TriangleMesh& operator= (TriangleMesh other);
24
void swap(TriangleMesh &other);
26
void ReadSTLFile(char* input_file);
27
void write_ascii(char* output_file);
28
void write_binary(char* output_file);
30
void WriteOBJFile(char* output_file);
31
void scale(float factor);
32
void scale(std::vector<double> versor);
33
void translate(float x, float y, float z);
34
void rotate_x(float angle);
35
void rotate_y(float angle);
36
void rotate_z(float angle);
37
void align_to_origin();
38
void rotate(double angle, Point* center);
39
TriangleMeshPtrs split() const;
40
void merge(const TriangleMesh* mesh);
41
void horizontal_projection(ExPolygons &retval) const;
42
void convex_hull(Polygon* hull);
43
void bounding_box(BoundingBoxf3* bb) const;
44
void reset_repair_stats();
50
void ReadFromPerl(SV* vertices, SV* facets);
54
void require_shared_vertices();
55
friend class TriangleMeshSlicer;
58
enum FacetEdgeType { feNone, feTop, feBottom, feHorizontal };
60
class IntersectionPoint : public Point
65
IntersectionPoint() : point_id(-1), edge_id(-1) {};
68
class IntersectionLine
77
FacetEdgeType edge_type;
79
IntersectionLine() : a_id(-1), b_id(-1), edge_a_id(-1), edge_b_id(-1), edge_type(feNone), skip(false) {};
81
typedef std::vector<IntersectionLine> IntersectionLines;
82
typedef std::vector<IntersectionLine*> IntersectionLinePtrs;
84
class TriangleMeshSlicer
88
TriangleMeshSlicer(TriangleMesh* _mesh);
89
~TriangleMeshSlicer();
90
void slice(const std::vector<float> &z, std::vector<Polygons>* layers);
91
void slice(const std::vector<float> &z, std::vector<ExPolygons>* layers);
92
void slice_facet(float slice_z, const stl_facet &facet, const int &facet_idx, const float &min_z, const float &max_z, std::vector<IntersectionLine>* lines) const;
93
void cut(float z, TriangleMesh* upper, TriangleMesh* lower);
96
typedef std::vector< std::vector<int> > t_facets_edges;
97
t_facets_edges facets_edges;
98
stl_vertex* v_scaled_shared;
99
void make_loops(std::vector<IntersectionLine> &lines, Polygons* loops);
100
void make_expolygons(const Polygons &loops, ExPolygons* slices);
101
void make_expolygons_simple(std::vector<IntersectionLine> &lines, ExPolygons* slices);
102
void make_expolygons(std::vector<IntersectionLine> &lines, ExPolygons* slices);