PrusaSlicer-NonPlainar/xs/src/TriangleMesh.hpp

81 lines
2.0 KiB
C++
Raw Normal View History

2013-07-06 13:26:32 +00:00
#ifndef slic3r_TriangleMesh_hpp_
#define slic3r_TriangleMesh_hpp_
#include <myinit.h>
2013-06-24 17:35:49 +00:00
#include <admesh/stl.h>
2013-09-07 12:06:09 +00:00
#include <vector>
#include "BoundingBox.hpp"
2013-08-05 17:52:37 +00:00
#include "Point.hpp"
2013-09-07 12:06:09 +00:00
#include "Polygon.hpp"
2013-11-23 18:41:40 +00:00
#include "ExPolygon.hpp"
2013-06-24 17:35:49 +00:00
namespace Slic3r {
class TriangleMesh;
typedef std::vector<TriangleMesh*> TriangleMeshPtrs;
2013-06-24 17:35:49 +00:00
class TriangleMesh
{
public:
2013-09-11 18:00:51 +00:00
TriangleMesh();
2013-09-09 22:09:56 +00:00
TriangleMesh(const TriangleMesh &other);
2013-06-24 17:35:49 +00:00
~TriangleMesh();
void ReadSTLFile(char* input_file);
void write_ascii(char* output_file);
void write_binary(char* output_file);
2013-09-09 21:18:33 +00:00
void repair();
2013-06-24 17:35:49 +00:00
void WriteOBJFile(char* output_file);
2013-08-04 19:34:26 +00:00
void scale(float factor);
2013-09-09 21:38:49 +00:00
void scale(std::vector<double> versor);
void translate(float x, float y, float z);
2013-08-05 17:22:33 +00:00
void align_to_origin();
2013-08-05 17:52:37 +00:00
void rotate(double angle, Point* center);
void slice(const std::vector<float> &z, std::vector<Polygons>* layers);
void slice(const std::vector<float> &z, std::vector<ExPolygons>* layers);
TriangleMeshPtrs split() const;
2013-09-09 20:45:22 +00:00
void merge(const TriangleMesh* mesh);
2013-11-23 18:41:40 +00:00
void horizontal_projection(ExPolygons &retval) const;
void convex_hull(Polygon* hull);
void bounding_box(BoundingBoxf3* bb) const;
2013-06-24 17:35:49 +00:00
stl_file stl;
2013-09-09 21:09:56 +00:00
bool repaired;
#ifdef SLIC3RXS
SV* to_SV();
void ReadFromPerl(SV* vertices, SV* facets);
#endif
2013-12-18 15:34:31 +00:00
private:
void require_shared_vertices();
2013-06-24 17:35:49 +00:00
};
2013-09-07 19:08:53 +00:00
enum FacetEdgeType { feNone, feTop, feBottom };
class IntersectionPoint : public Point
{
public:
int point_id;
int edge_id;
IntersectionPoint() : point_id(-1), edge_id(-1) {};
};
class IntersectionLine
{
public:
Point a;
Point b;
int a_id;
int b_id;
int edge_a_id;
int edge_b_id;
FacetEdgeType edge_type;
2013-09-07 22:44:01 +00:00
bool skip;
IntersectionLine() : a_id(-1), b_id(-1), edge_a_id(-1), edge_b_id(-1), edge_type(feNone), skip(false) {};
2013-09-07 19:08:53 +00:00
};
typedef std::vector<IntersectionLine> IntersectionLines;
2013-09-07 22:44:01 +00:00
typedef std::vector<IntersectionLine*> IntersectionLinePtrs;
2013-09-07 19:08:53 +00:00
}
2013-07-06 13:26:32 +00:00
#endif