Merge branch 'master' of https://github.com/prusa3d/PrusaSlicer into et_canvas_manager
This commit is contained in:
commit
a54d77699b
17 changed files with 124 additions and 120 deletions
|
@ -218,10 +218,10 @@ public:
|
|||
bbox.min /= m_resolution;
|
||||
bbox.max /= m_resolution;
|
||||
// Trim with the cells.
|
||||
bbox.min.x() = std::max(bbox.min.x(), 0);
|
||||
bbox.min.y() = std::max(bbox.min.y(), 0);
|
||||
bbox.max.x() = std::min(bbox.max.x(), (coord_t)m_cols - 1);
|
||||
bbox.max.y() = std::min(bbox.max.y(), (coord_t)m_rows - 1);
|
||||
bbox.min.x() = std::max<coord_t>(bbox.min.x(), 0);
|
||||
bbox.min.y() = std::max<coord_t>(bbox.min.y(), 0);
|
||||
bbox.max.x() = std::min<coord_t>(bbox.max.x(), (coord_t)m_cols - 1);
|
||||
bbox.max.y() = std::min<coord_t>(bbox.max.y(), (coord_t)m_rows - 1);
|
||||
for (coord_t iy = bbox.min.y(); iy <= bbox.max.y(); ++ iy)
|
||||
for (coord_t ix = bbox.min.x(); ix <= bbox.max.x(); ++ ix)
|
||||
if (! visitor(iy, ix))
|
||||
|
|
|
@ -29,7 +29,7 @@ TriangleMesh eigen_to_triangle_mesh(const EigenMesh &emesh)
|
|||
auto &VC = emesh.first; auto &FC = emesh.second;
|
||||
|
||||
Pointf3s points(size_t(VC.rows()));
|
||||
std::vector<Vec3crd> facets(size_t(FC.rows()));
|
||||
std::vector<Vec3i> facets(size_t(FC.rows()));
|
||||
|
||||
for (Eigen::Index i = 0; i < VC.rows(); ++i)
|
||||
points[size_t(i)] = VC.row(i);
|
||||
|
@ -154,7 +154,7 @@ inline Vec3d to_vec3d(const _EpecMesh::Point &v)
|
|||
template<class _Mesh> TriangleMesh cgal_to_triangle_mesh(const _Mesh &cgalmesh)
|
||||
{
|
||||
Pointf3s points;
|
||||
std::vector<Vec3crd> facets;
|
||||
std::vector<Vec3i> facets;
|
||||
points.reserve(cgalmesh.num_vertices());
|
||||
facets.reserve(cgalmesh.num_faces());
|
||||
|
||||
|
@ -166,7 +166,7 @@ template<class _Mesh> TriangleMesh cgal_to_triangle_mesh(const _Mesh &cgalmesh)
|
|||
for (auto &face : cgalmesh.faces()) {
|
||||
auto vtc = cgalmesh.vertices_around_face(cgalmesh.halfedge(face));
|
||||
int i = 0;
|
||||
Vec3crd trface;
|
||||
Vec3i trface;
|
||||
for (auto v : vtc) trface(i++) = static_cast<int>(v);
|
||||
facets.emplace_back(trface);
|
||||
}
|
||||
|
|
|
@ -24,7 +24,9 @@ typedef Eigen::Matrix<coord_t, 2, 1, Eigen::DontAlign> Vec2crd;
|
|||
typedef Eigen::Matrix<coord_t, 3, 1, Eigen::DontAlign> Vec3crd;
|
||||
typedef Eigen::Matrix<int, 2, 1, Eigen::DontAlign> Vec2i;
|
||||
typedef Eigen::Matrix<int, 3, 1, Eigen::DontAlign> Vec3i;
|
||||
typedef Eigen::Matrix<int32_t, 2, 1, Eigen::DontAlign> Vec2i32;
|
||||
typedef Eigen::Matrix<int64_t, 2, 1, Eigen::DontAlign> Vec2i64;
|
||||
typedef Eigen::Matrix<int32_t, 3, 1, Eigen::DontAlign> Vec3i32;
|
||||
typedef Eigen::Matrix<int64_t, 3, 1, Eigen::DontAlign> Vec3i64;
|
||||
|
||||
// Vector types with a double coordinate base type.
|
||||
|
@ -53,12 +55,12 @@ typedef Eigen::Transform<double, 3, Eigen::Affine, Eigen::DontAlign> Transform3d
|
|||
|
||||
inline bool operator<(const Vec2d &lhs, const Vec2d &rhs) { return lhs(0) < rhs(0) || (lhs(0) == rhs(0) && lhs(1) < rhs(1)); }
|
||||
|
||||
inline int32_t cross2(const Vec2i32 &v1, const Vec2i32 &v2) { return v1(0) * v2(1) - v1(1) * v2(0); }
|
||||
inline int64_t cross2(const Vec2i64 &v1, const Vec2i64 &v2) { return v1(0) * v2(1) - v1(1) * v2(0); }
|
||||
inline coord_t cross2(const Vec2crd &v1, const Vec2crd &v2) { return v1(0) * v2(1) - v1(1) * v2(0); }
|
||||
inline float cross2(const Vec2f &v1, const Vec2f &v2) { return v1(0) * v2(1) - v1(1) * v2(0); }
|
||||
inline double cross2(const Vec2d &v1, const Vec2d &v2) { return v1(0) * v2(1) - v1(1) * v2(0); }
|
||||
|
||||
inline Vec2crd to_2d(const Vec3crd &pt3) { return Vec2crd(pt3(0), pt3(1)); }
|
||||
inline Vec2i32 to_2d(const Vec2i32 &pt3) { return Vec2i32(pt3(0), pt3(1)); }
|
||||
inline Vec2i64 to_2d(const Vec3i64 &pt3) { return Vec2i64(pt3(0), pt3(1)); }
|
||||
inline Vec2f to_2d(const Vec3f &pt3) { return Vec2f (pt3(0), pt3(1)); }
|
||||
inline Vec2d to_2d(const Vec3d &pt3) { return Vec2d (pt3(0), pt3(1)); }
|
||||
|
@ -89,8 +91,8 @@ public:
|
|||
typedef coord_t coord_type;
|
||||
|
||||
Point() : Vec2crd(0, 0) {}
|
||||
Point(coord_t x, coord_t y) : Vec2crd(x, y) {}
|
||||
Point(int64_t x, int64_t y) : Vec2crd(coord_t(x), coord_t(y)) {} // for Clipper
|
||||
Point(int32_t x, int32_t y) : Vec2crd(coord_t(x), coord_t(y)) {}
|
||||
Point(int64_t x, int64_t y) : Vec2crd(coord_t(x), coord_t(y)) {}
|
||||
Point(double x, double y) : Vec2crd(coord_t(lrint(x)), coord_t(lrint(y))) {}
|
||||
Point(const Point &rhs) { *this = rhs; }
|
||||
explicit Point(const Vec2d& rhs) : Vec2crd(coord_t(lrint(rhs.x())), coord_t(lrint(rhs.y()))) {}
|
||||
|
|
|
@ -228,7 +228,7 @@ void to_eigen_mesh(const TriangleMesh &tmesh, Eigen::MatrixXd &V, Eigen::MatrixX
|
|||
void to_triangle_mesh(const Eigen::MatrixXd &V, const Eigen::MatrixXi &F, TriangleMesh &out)
|
||||
{
|
||||
Pointf3s points(size_t(V.rows()));
|
||||
std::vector<Vec3crd> facets(size_t(F.rows()));
|
||||
std::vector<Vec3i> facets(size_t(F.rows()));
|
||||
|
||||
for (Eigen::Index i = 0; i < V.rows(); ++i)
|
||||
points[size_t(i)] = V.row(i);
|
||||
|
|
|
@ -48,9 +48,8 @@ Contour3D sphere(double rho, Portion portion, double fa) {
|
|||
vertices.emplace_back(Vec3d(b(0), b(1), z));
|
||||
|
||||
if (sbegin == 0)
|
||||
facets.emplace_back((i == 0) ?
|
||||
Vec3crd(coord_t(ring.size()), 0, 1) :
|
||||
Vec3crd(id - 1, 0, id));
|
||||
(i == 0) ? facets.emplace_back(coord_t(ring.size()), 0, 1) :
|
||||
facets.emplace_back(id - 1, 0, id);
|
||||
++id;
|
||||
}
|
||||
|
||||
|
@ -66,12 +65,11 @@ Contour3D sphere(double rho, Portion portion, double fa) {
|
|||
auto id_ringsize = coord_t(id - int(ring.size()));
|
||||
if (i == 0) {
|
||||
// wrap around
|
||||
facets.emplace_back(Vec3crd(id - 1, id,
|
||||
id + coord_t(ring.size() - 1)));
|
||||
facets.emplace_back(Vec3crd(id - 1, id_ringsize, id));
|
||||
facets.emplace_back(id - 1, id, id + coord_t(ring.size() - 1) );
|
||||
facets.emplace_back(id - 1, id_ringsize, id);
|
||||
} else {
|
||||
facets.emplace_back(Vec3crd(id_ringsize - 1, id_ringsize, id));
|
||||
facets.emplace_back(Vec3crd(id - 1, id_ringsize - 1, id));
|
||||
facets.emplace_back(id_ringsize - 1, id_ringsize, id);
|
||||
facets.emplace_back(id - 1, id_ringsize - 1, id);
|
||||
}
|
||||
id++;
|
||||
}
|
||||
|
@ -85,10 +83,10 @@ Contour3D sphere(double rho, Portion portion, double fa) {
|
|||
auto id_ringsize = coord_t(id - int(ring.size()));
|
||||
if (i == 0) {
|
||||
// third vertex is on the other side of the ring.
|
||||
facets.emplace_back(Vec3crd(id - 1, id_ringsize, id));
|
||||
facets.emplace_back(id - 1, id_ringsize, id);
|
||||
} else {
|
||||
auto ci = coord_t(id_ringsize + coord_t(i));
|
||||
facets.emplace_back(Vec3crd(ci - 1, ci, id));
|
||||
facets.emplace_back(ci - 1, ci, id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -42,7 +42,7 @@
|
|||
|
||||
namespace Slic3r {
|
||||
|
||||
TriangleMesh::TriangleMesh(const Pointf3s &points, const std::vector<Vec3crd>& facets) : repaired(false)
|
||||
TriangleMesh::TriangleMesh(const Pointf3s &points, const std::vector<Vec3i> &facets) : repaired(false)
|
||||
{
|
||||
stl_file &stl = this->stl;
|
||||
stl.stats.type = inmemory;
|
||||
|
@ -600,7 +600,7 @@ TriangleMesh TriangleMesh::convex_hull_3d() const
|
|||
|
||||
// Let's collect results:
|
||||
Pointf3s dst_vertices;
|
||||
std::vector<Vec3crd> facets;
|
||||
std::vector<Vec3i> facets;
|
||||
auto facet_list = qhull.facetList().toStdVector();
|
||||
for (const orgQhull::QhullFacet& facet : facet_list)
|
||||
{ // iterate through facets
|
||||
|
@ -1931,22 +1931,18 @@ void TriangleMeshSlicer::cut(float z, TriangleMesh* upper, TriangleMesh* lower)
|
|||
// Generate the vertex list for a cube solid of arbitrary size in X/Y/Z.
|
||||
TriangleMesh make_cube(double x, double y, double z)
|
||||
{
|
||||
Vec3d pv[8] = {
|
||||
Vec3d(x, y, 0), Vec3d(x, 0, 0), Vec3d(0, 0, 0),
|
||||
Vec3d(0, y, 0), Vec3d(x, y, z), Vec3d(0, y, z),
|
||||
Vec3d(0, 0, z), Vec3d(x, 0, z)
|
||||
};
|
||||
Vec3crd fv[12] = {
|
||||
Vec3crd(0, 1, 2), Vec3crd(0, 2, 3), Vec3crd(4, 5, 6),
|
||||
Vec3crd(4, 6, 7), Vec3crd(0, 4, 7), Vec3crd(0, 7, 1),
|
||||
Vec3crd(1, 7, 6), Vec3crd(1, 6, 2), Vec3crd(2, 6, 5),
|
||||
Vec3crd(2, 5, 3), Vec3crd(4, 0, 3), Vec3crd(4, 3, 5)
|
||||
};
|
||||
|
||||
std::vector<Vec3crd> facets(&fv[0], &fv[0]+12);
|
||||
Pointf3s vertices(&pv[0], &pv[0]+8);
|
||||
|
||||
TriangleMesh mesh(vertices ,facets);
|
||||
TriangleMesh mesh(
|
||||
{
|
||||
{x, y, 0}, {x, 0, 0}, {0, 0, 0},
|
||||
{0, y, 0}, {x, y, z}, {0, y, z},
|
||||
{0, 0, z}, {x, 0, z}
|
||||
},
|
||||
{
|
||||
{0, 1, 2}, {0, 2, 3}, {4, 5, 6},
|
||||
{4, 6, 7}, {0, 4, 7}, {0, 7, 1},
|
||||
{1, 7, 6}, {1, 6, 2}, {2, 6, 5},
|
||||
{2, 5, 3}, {4, 0, 3}, {4, 3, 5}
|
||||
});
|
||||
mesh.repair();
|
||||
return mesh;
|
||||
}
|
||||
|
@ -1960,7 +1956,7 @@ TriangleMesh make_cylinder(double r, double h, double fa)
|
|||
double angle_step = 2. * PI / n_steps;
|
||||
|
||||
Pointf3s vertices;
|
||||
std::vector<Vec3crd> facets;
|
||||
std::vector<Vec3i> facets;
|
||||
vertices.reserve(2 * n_steps + 2);
|
||||
facets.reserve(4 * n_steps);
|
||||
|
||||
|
@ -1980,17 +1976,17 @@ TriangleMesh make_cylinder(double r, double h, double fa)
|
|||
vertices.emplace_back(Vec3d(p(0), p(1), 0.));
|
||||
vertices.emplace_back(Vec3d(p(0), p(1), h));
|
||||
int id = (int)vertices.size() - 1;
|
||||
facets.emplace_back(Vec3crd( 0, id - 1, id - 3)); // top
|
||||
facets.emplace_back(Vec3crd(id, 1, id - 2)); // bottom
|
||||
facets.emplace_back(Vec3crd(id, id - 2, id - 3)); // upper-right of side
|
||||
facets.emplace_back(Vec3crd(id, id - 3, id - 1)); // bottom-left of side
|
||||
facets.emplace_back( 0, id - 1, id - 3); // top
|
||||
facets.emplace_back(id, 1, id - 2); // bottom
|
||||
facets.emplace_back(id, id - 2, id - 3); // upper-right of side
|
||||
facets.emplace_back(id, id - 3, id - 1); // bottom-left of side
|
||||
}
|
||||
// Connect the last set of vertices with the first.
|
||||
int id = (int)vertices.size() - 1;
|
||||
facets.emplace_back(Vec3crd( 0, 2, id - 1));
|
||||
facets.emplace_back(Vec3crd( 3, 1, id));
|
||||
facets.emplace_back(Vec3crd(id, 2, 3));
|
||||
facets.emplace_back(Vec3crd(id, id - 1, 2));
|
||||
facets.emplace_back( 0, 2, id - 1);
|
||||
facets.emplace_back( 3, 1, id);
|
||||
facets.emplace_back(id, 2, 3);
|
||||
facets.emplace_back(id, id - 1, 2);
|
||||
|
||||
TriangleMesh mesh(std::move(vertices), std::move(facets));
|
||||
mesh.repair();
|
||||
|
@ -2025,7 +2021,7 @@ TriangleMesh make_sphere(double radius, double fa)
|
|||
}
|
||||
}
|
||||
|
||||
std::vector<Vec3crd> facets;
|
||||
std::vector<Vec3i> facets;
|
||||
facets.reserve(2 * (stackCount - 1) * sectorCount);
|
||||
for (int i = 0; i < stackCount; ++ i) {
|
||||
// Beginning of current stack.
|
||||
|
@ -2040,11 +2036,11 @@ TriangleMesh make_sphere(double radius, double fa)
|
|||
int k2_next = k2;
|
||||
if (i != 0) {
|
||||
k1_next = (j + 1 == sectorCount) ? k1_first : (k1 + 1);
|
||||
facets.emplace_back(Vec3crd(k1, k2, k1_next));
|
||||
facets.emplace_back(k1, k2, k1_next);
|
||||
}
|
||||
if (i + 1 != stackCount) {
|
||||
k2_next = (j + 1 == sectorCount) ? k2_first : (k2 + 1);
|
||||
facets.emplace_back(Vec3crd(k1_next, k2, k2_next));
|
||||
facets.emplace_back(k1_next, k2, k2_next);
|
||||
}
|
||||
k1 = k1_next;
|
||||
k2 = k2_next;
|
||||
|
|
|
@ -22,7 +22,7 @@ class TriangleMesh
|
|||
{
|
||||
public:
|
||||
TriangleMesh() : repaired(false) {}
|
||||
TriangleMesh(const Pointf3s &points, const std::vector<Vec3crd> &facets);
|
||||
TriangleMesh(const Pointf3s &points, const std::vector<Vec3i> &facets);
|
||||
explicit TriangleMesh(const indexed_triangle_set &M);
|
||||
void clear() { this->stl.clear(); this->its.clear(); this->repaired = false; }
|
||||
bool ReadSTLFile(const char* input_file) { return stl_open(&stl, input_file); }
|
||||
|
|
|
@ -21,7 +21,13 @@
|
|||
#include "Technologies.hpp"
|
||||
#include "Semver.hpp"
|
||||
|
||||
#if 1
|
||||
// Saves around 32% RAM after slicing step, 6.7% after G-code export (tested on PrusaSlicer 2.2.0 final).
|
||||
typedef int32_t coord_t;
|
||||
#else
|
||||
typedef int64_t coord_t;
|
||||
#endif
|
||||
|
||||
typedef double coordf_t;
|
||||
|
||||
//FIXME This epsilon value is used for many non-related purposes:
|
||||
|
@ -33,6 +39,7 @@ typedef double coordf_t;
|
|||
// This scaling generates a following fixed point representation with for a 32bit integer:
|
||||
// 0..4294mm with 1nm resolution
|
||||
// int32_t fits an interval of (-2147.48mm, +2147.48mm)
|
||||
// with int64_t we don't have to worry anymore about the size of the int.
|
||||
#define SCALING_FACTOR 0.000001
|
||||
// RESOLUTION, SCALED_RESOLUTION: Used as an error threshold for a Douglas-Peucker polyline simplification algorithm.
|
||||
#define RESOLUTION 0.0125
|
||||
|
|
|
@ -535,16 +535,16 @@ int GLVolumeCollection::load_wipe_tower_preview(
|
|||
// We'll now create the box with jagged edge. y-coordinates of the pre-generated model are shifted so that the front
|
||||
// edge has y=0 and centerline of the back edge has y=depth:
|
||||
Pointf3s points;
|
||||
std::vector<Vec3crd> facets;
|
||||
std::vector<Vec3i> facets;
|
||||
float out_points_idx[][3] = { { 0, -depth, 0 }, { 0, 0, 0 }, { 38.453f, 0, 0 }, { 61.547f, 0, 0 }, { 100.0f, 0, 0 }, { 100.0f, -depth, 0 }, { 55.7735f, -10.0f, 0 }, { 44.2265f, 10.0f, 0 },
|
||||
{ 38.453f, 0, 1 }, { 0, 0, 1 }, { 0, -depth, 1 }, { 100.0f, -depth, 1 }, { 100.0f, 0, 1 }, { 61.547f, 0, 1 }, { 55.7735f, -10.0f, 1 }, { 44.2265f, 10.0f, 1 } };
|
||||
int out_facets_idx[][3] = { { 0, 1, 2 }, { 3, 4, 5 }, { 6, 5, 0 }, { 3, 5, 6 }, { 6, 2, 7 }, { 6, 0, 2 }, { 8, 9, 10 }, { 11, 12, 13 }, { 10, 11, 14 }, { 14, 11, 13 }, { 15, 8, 14 },
|
||||
{8, 10, 14}, {3, 12, 4}, {3, 13, 12}, {6, 13, 3}, {6, 14, 13}, {7, 14, 6}, {7, 15, 14}, {2, 15, 7}, {2, 8, 15}, {1, 8, 2}, {1, 9, 8},
|
||||
{0, 9, 1}, {0, 10, 9}, {5, 10, 0}, {5, 11, 10}, {4, 11, 5}, {4, 12, 11} };
|
||||
for (int i = 0; i < 16; ++i)
|
||||
points.push_back(Vec3d(out_points_idx[i][0] / (100.f / min_width), out_points_idx[i][1] + depth, out_points_idx[i][2]));
|
||||
points.emplace_back(out_points_idx[i][0] / (100.f / min_width), out_points_idx[i][1] + depth, out_points_idx[i][2]);
|
||||
for (int i = 0; i < 28; ++i)
|
||||
facets.push_back(Vec3crd(out_facets_idx[i][0], out_facets_idx[i][1], out_facets_idx[i][2]));
|
||||
facets.emplace_back(out_facets_idx[i][0], out_facets_idx[i][1], out_facets_idx[i][2]);
|
||||
TriangleMesh tooth_mesh(points, facets);
|
||||
|
||||
// We have the mesh ready. It has one tooth and width of min_width. We will now append several of these together until we are close to
|
||||
|
@ -1901,7 +1901,7 @@ void GLModel::render() const
|
|||
bool GLArrow::on_init()
|
||||
{
|
||||
Pointf3s vertices;
|
||||
std::vector<Vec3crd> triangles;
|
||||
std::vector<Vec3i> triangles;
|
||||
|
||||
// bottom face
|
||||
vertices.emplace_back(0.5, 0.0, -0.1);
|
||||
|
@ -1967,7 +1967,7 @@ GLCurvedArrow::GLCurvedArrow(unsigned int resolution)
|
|||
bool GLCurvedArrow::on_init()
|
||||
{
|
||||
Pointf3s vertices;
|
||||
std::vector<Vec3crd> triangles;
|
||||
std::vector<Vec3i> triangles;
|
||||
|
||||
double ext_radius = 2.5;
|
||||
double int_radius = 1.5;
|
||||
|
|
|
@ -2051,7 +2051,7 @@ void GLCanvas3D::render()
|
|||
// we need to set the mouse's scene position here because the depth buffer
|
||||
// could be invalidated by the following gizmo render methods
|
||||
// this position is used later into on_mouse() to drag the objects
|
||||
m_mouse.scene_position = _mouse_to_3d(m_mouse.position.cast<int>());
|
||||
m_mouse.scene_position = _mouse_to_3d(m_mouse.position.cast<coord_t>());
|
||||
|
||||
_render_current_gizmo();
|
||||
_render_selection_sidebar_hints();
|
||||
|
|
|
@ -48,7 +48,7 @@ namespace GUI {
|
|||
const Transform3d& projection_matrix = camera.get_projection_matrix();
|
||||
|
||||
// bounding box created from the rectangle corners - will take care of order of the corners
|
||||
BoundingBox rectangle(Points{ Point(m_start_corner.cast<int>()), Point(m_end_corner.cast<int>()) });
|
||||
BoundingBox rectangle(Points{ Point(m_start_corner.cast<coord_t>()), Point(m_end_corner.cast<coord_t>()) });
|
||||
|
||||
// Iterate over all points and determine whether they're in the rectangle.
|
||||
for (unsigned int i = 0; i<points.size(); ++i) {
|
||||
|
|
|
@ -223,7 +223,8 @@ void MainFrame::update_title()
|
|||
if (idx_plus != build_id.npos) {
|
||||
// Parse what is behind the '+'. If there is a number, then it is a build number after the label, and full build ID is shown.
|
||||
int commit_after_label;
|
||||
if (! boost::starts_with(build_id.data() + idx_plus + 1, "UNKNOWN") && sscanf(build_id.data() + idx_plus + 1, "%d-", &commit_after_label) == 0) {
|
||||
if (! boost::starts_with(build_id.data() + idx_plus + 1, "UNKNOWN") &&
|
||||
(build_id.at(idx_plus + 1) == '-' || sscanf(build_id.data() + idx_plus + 1, "%d-", &commit_after_label) == 0)) {
|
||||
// It is a release build.
|
||||
build_id.erase(build_id.begin() + idx_plus, build_id.end());
|
||||
#if defined(_WIN32) && ! defined(_WIN64)
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -18,8 +18,8 @@ using namespace std;
|
|||
|
||||
SCENARIO( "TriangleMesh: Basic mesh statistics") {
|
||||
GIVEN( "A 20mm cube, built from constexpr std::array" ) {
|
||||
std::vector<Vec3d> vertices { Vec3d(20,20,0), Vec3d(20,0,0), Vec3d(0,0,0), Vec3d(0,20,0), Vec3d(20,20,20), Vec3d(0,20,20), Vec3d(0,0,20), Vec3d(20,0,20) };
|
||||
std::vector<Vec3crd> facets { Vec3crd(0,1,2), Vec3crd(0,2,3), Vec3crd(4,5,6), Vec3crd(4,6,7), Vec3crd(0,4,7), Vec3crd(0,7,1), Vec3crd(1,7,6), Vec3crd(1,6,2), Vec3crd(2,6,5), Vec3crd(2,5,3), Vec3crd(4,0,3), Vec3crd(4,3,5) };
|
||||
std::vector<Vec3d> vertices { {20,20,0}, {20,0,0}, {0,0,0}, {0,20,0}, {20,20,20}, {0,20,20}, {0,0,20}, {20,0,20} };
|
||||
std::vector<Vec3i> facets { {0,1,2}, {0,2,3}, {4,5,6}, {4,6,7}, {0,4,7}, {0,7,1}, {1,7,6}, {1,6,2}, {2,6,5}, {2,5,3}, {4,0,3}, {4,3,5} };
|
||||
TriangleMesh cube(vertices, facets);
|
||||
cube.repair();
|
||||
|
||||
|
@ -68,8 +68,8 @@ SCENARIO( "TriangleMesh: Basic mesh statistics") {
|
|||
|
||||
}
|
||||
GIVEN( "A 20mm cube with one corner on the origin") {
|
||||
const std::vector<Vec3d> vertices { Vec3d(20,20,0), Vec3d(20,0,0), Vec3d(0,0,0), Vec3d(0,20,0), Vec3d(20,20,20), Vec3d(0,20,20), Vec3d(0,0,20), Vec3d(20,0,20) };
|
||||
const std::vector<Vec3crd> facets { Vec3crd(0,1,2), Vec3crd(0,2,3), Vec3crd(4,5,6), Vec3crd(4,6,7), Vec3crd(0,4,7), Vec3crd(0,7,1), Vec3crd(1,7,6), Vec3crd(1,6,2), Vec3crd(2,6,5), Vec3crd(2,5,3), Vec3crd(4,0,3), Vec3crd(4,3,5) };
|
||||
const std::vector<Vec3d> vertices { {20,20,0}, {20,0,0}, {0,0,0}, {0,20,0}, {20,20,20}, {0,20,20}, {0,0,20}, {20,0,20} };
|
||||
const std::vector<Vec3i> facets { {0,1,2}, {0,2,3}, {4,5,6}, {4,6,7}, {0,4,7}, {0,7,1}, {1,7,6}, {1,6,2}, {2,6,5}, {2,5,3}, {4,0,3}, {4,3,5} };
|
||||
|
||||
TriangleMesh cube(vertices, facets);
|
||||
cube.repair();
|
||||
|
@ -121,8 +121,8 @@ SCENARIO( "TriangleMesh: Basic mesh statistics") {
|
|||
|
||||
SCENARIO( "TriangleMesh: Transformation functions affect mesh as expected.") {
|
||||
GIVEN( "A 20mm cube with one corner on the origin") {
|
||||
const std::vector<Vec3d> vertices { Vec3d(20,20,0), Vec3d(20,0,0), Vec3d(0,0,0), Vec3d(0,20,0), Vec3d(20,20,20), Vec3d(0,20,20), Vec3d(0,0,20), Vec3d(20,0,20) };
|
||||
const std::vector<Vec3crd> facets { Vec3crd(0,1,2), Vec3crd(0,2,3), Vec3crd(4,5,6), Vec3crd(4,6,7), Vec3crd(0,4,7), Vec3crd(0,7,1), Vec3crd(1,7,6), Vec3crd(1,6,2), Vec3crd(2,6,5), Vec3crd(2,5,3), Vec3crd(4,0,3), Vec3crd(4,3,5) };
|
||||
const std::vector<Vec3d> vertices { {20,20,0}, {20,0,0}, {0,0,0}, {0,20,0}, {20,20,20}, {0,20,20}, {0,0,20}, {20,0,20} };
|
||||
const std::vector<Vec3i> facets { {0,1,2}, {0,2,3}, {4,5,6}, {4,6,7}, {0,4,7}, {0,7,1}, {1,7,6}, {1,6,2}, {2,6,5}, {2,5,3}, {4,0,3}, {4,3,5} };
|
||||
TriangleMesh cube(vertices, facets);
|
||||
cube.repair();
|
||||
|
||||
|
@ -184,8 +184,8 @@ SCENARIO( "TriangleMesh: Transformation functions affect mesh as expected.") {
|
|||
|
||||
SCENARIO( "TriangleMesh: slice behavior.") {
|
||||
GIVEN( "A 20mm cube with one corner on the origin") {
|
||||
const std::vector<Vec3d> vertices { Vec3d(20,20,0), Vec3d(20,0,0), Vec3d(0,0,0), Vec3d(0,20,0), Vec3d(20,20,20), Vec3d(0,20,20), Vec3d(0,0,20), Vec3d(20,0,20) };
|
||||
const std::vector<Vec3crd> facets { Vec3crd(0,1,2), Vec3crd(0,2,3), Vec3crd(4,5,6), Vec3crd(4,6,7), Vec3crd(0,4,7), Vec3crd(0,7,1), Vec3crd(1,7,6), Vec3crd(1,6,2), Vec3crd(2,6,5), Vec3crd(2,5,3), Vec3crd(4,0,3), Vec3crd(4,3,5) };
|
||||
const std::vector<Vec3d> vertices { {20,20,0}, {20,0,0}, {0,0,0}, {0,20,0}, {20,20,20}, {0,20,20}, {0,0,20}, {20,0,20} };
|
||||
const std::vector<Vec3i> facets { {0,1,2}, {0,2,3}, {4,5,6}, {4,6,7}, {0,4,7}, {0,7,1}, {1,7,6}, {1,6,2}, {2,6,5}, {2,5,3}, {4,0,3}, {4,3,5} };
|
||||
TriangleMesh cube(vertices, facets);
|
||||
cube.repair();
|
||||
|
||||
|
@ -205,8 +205,8 @@ SCENARIO( "TriangleMesh: slice behavior.") {
|
|||
}
|
||||
}
|
||||
GIVEN( "A STL with an irregular shape.") {
|
||||
const std::vector<Vec3d> vertices {Vec3d(0,0,0),Vec3d(0,0,20),Vec3d(0,5,0),Vec3d(0,5,20),Vec3d(50,0,0),Vec3d(50,0,20),Vec3d(15,5,0),Vec3d(35,5,0),Vec3d(15,20,0),Vec3d(50,5,0),Vec3d(35,20,0),Vec3d(15,5,10),Vec3d(50,5,20),Vec3d(35,5,10),Vec3d(35,20,10),Vec3d(15,20,10)};
|
||||
const std::vector<Vec3crd> facets {Vec3crd(0,1,2),Vec3crd(2,1,3),Vec3crd(1,0,4),Vec3crd(5,1,4),Vec3crd(0,2,4),Vec3crd(4,2,6),Vec3crd(7,6,8),Vec3crd(4,6,7),Vec3crd(9,4,7),Vec3crd(7,8,10),Vec3crd(2,3,6),Vec3crd(11,3,12),Vec3crd(7,12,9),Vec3crd(13,12,7),Vec3crd(6,3,11),Vec3crd(11,12,13),Vec3crd(3,1,5),Vec3crd(12,3,5),Vec3crd(5,4,9),Vec3crd(12,5,9),Vec3crd(13,7,10),Vec3crd(14,13,10),Vec3crd(8,15,10),Vec3crd(10,15,14),Vec3crd(6,11,8),Vec3crd(8,11,15),Vec3crd(15,11,13),Vec3crd(14,15,13)};
|
||||
const std::vector<Vec3d> vertices {{0,0,0},{0,0,20},{0,5,0},{0,5,20},{50,0,0},{50,0,20},{15,5,0},{35,5,0},{15,20,0},{50,5,0},{35,20,0},{15,5,10},{50,5,20},{35,5,10},{35,20,10},{15,20,10}};
|
||||
const std::vector<Vec3i> facets {{0,1,2},{2,1,3},{1,0,4},{5,1,4},{0,2,4},{4,2,6},{7,6,8},{4,6,7},{9,4,7},{7,8,10},{2,3,6},{11,3,12},{7,12,9},{13,12,7},{6,3,11},{11,12,13},{3,1,5},{12,3,5},{5,4,9},{12,5,9},{13,7,10},{14,13,10},{8,15,10},{10,15,14},{6,11,8},{8,11,15},{15,11,13},{14,15,13}};
|
||||
|
||||
TriangleMesh cube(vertices, facets);
|
||||
cube.repair();
|
||||
|
@ -294,8 +294,8 @@ SCENARIO( "make_xxx functions produce meshes.") {
|
|||
|
||||
SCENARIO( "TriangleMesh: split functionality.") {
|
||||
GIVEN( "A 20mm cube with one corner on the origin") {
|
||||
const std::vector<Vec3d> vertices { Vec3d(20,20,0), Vec3d(20,0,0), Vec3d(0,0,0), Vec3d(0,20,0), Vec3d(20,20,20), Vec3d(0,20,20), Vec3d(0,0,20), Vec3d(20,0,20) };
|
||||
const std::vector<Vec3crd> facets { Vec3crd(0,1,2), Vec3crd(0,2,3), Vec3crd(4,5,6), Vec3crd(4,6,7), Vec3crd(0,4,7), Vec3crd(0,7,1), Vec3crd(1,7,6), Vec3crd(1,6,2), Vec3crd(2,6,5), Vec3crd(2,5,3), Vec3crd(4,0,3), Vec3crd(4,3,5) };
|
||||
const std::vector<Vec3d> vertices { {20,20,0}, {20,0,0}, {0,0,0}, {0,20,0}, {20,20,20}, {0,20,20}, {0,0,20}, {20,0,20} };
|
||||
const std::vector<Vec3i> facets { {0,1,2}, {0,2,3}, {4,5,6}, {4,6,7}, {0,4,7}, {0,7,1}, {1,7,6}, {1,6,2}, {2,6,5}, {2,5,3}, {4,0,3}, {4,3,5} };
|
||||
|
||||
TriangleMesh cube(vertices, facets);
|
||||
cube.repair();
|
||||
|
@ -308,8 +308,8 @@ SCENARIO( "TriangleMesh: split functionality.") {
|
|||
}
|
||||
}
|
||||
GIVEN( "Two 20mm cubes, each with one corner on the origin, merged into a single TriangleMesh") {
|
||||
const std::vector<Vec3d> vertices { Vec3d(20,20,0), Vec3d(20,0,0), Vec3d(0,0,0), Vec3d(0,20,0), Vec3d(20,20,20), Vec3d(0,20,20), Vec3d(0,0,20), Vec3d(20,0,20) };
|
||||
const std::vector<Vec3crd> facets { Vec3crd(0,1,2), Vec3crd(0,2,3), Vec3crd(4,5,6), Vec3crd(4,6,7), Vec3crd(0,4,7), Vec3crd(0,7,1), Vec3crd(1,7,6), Vec3crd(1,6,2), Vec3crd(2,6,5), Vec3crd(2,5,3), Vec3crd(4,0,3), Vec3crd(4,3,5) };
|
||||
const std::vector<Vec3d> vertices { {20,20,0}, {20,0,0}, {0,0,0}, {0,20,0}, {20,20,20}, {0,20,20}, {0,0,20}, {20,0,20} };
|
||||
const std::vector<Vec3i> facets { {0,1,2}, {0,2,3}, {4,5,6}, {4,6,7}, {0,4,7}, {0,7,1}, {1,7,6}, {1,6,2}, {2,6,5}, {2,5,3}, {4,0,3}, {4,3,5} };
|
||||
|
||||
TriangleMesh cube(vertices, facets);
|
||||
cube.repair();
|
||||
|
@ -329,8 +329,8 @@ SCENARIO( "TriangleMesh: split functionality.") {
|
|||
|
||||
SCENARIO( "TriangleMesh: Mesh merge functions") {
|
||||
GIVEN( "Two 20mm cubes, each with one corner on the origin") {
|
||||
const std::vector<Vec3d> vertices { Vec3d(20,20,0), Vec3d(20,0,0), Vec3d(0,0,0), Vec3d(0,20,0), Vec3d(20,20,20), Vec3d(0,20,20), Vec3d(0,0,20), Vec3d(20,0,20) };
|
||||
const std::vector<Vec3crd> facets { Vec3crd(0,1,2), Vec3crd(0,2,3), Vec3crd(4,5,6), Vec3crd(4,6,7), Vec3crd(0,4,7), Vec3crd(0,7,1), Vec3crd(1,7,6), Vec3crd(1,6,2), Vec3crd(2,6,5), Vec3crd(2,5,3), Vec3crd(4,0,3), Vec3crd(4,3,5) };
|
||||
const std::vector<Vec3d> vertices { {20,20,0}, {20,0,0}, {0,0,0}, {0,20,0}, {20,20,20}, {0,20,20}, {0,0,20}, {20,0,20} };
|
||||
const std::vector<Vec3i> facets { {0,1,2}, {0,2,3}, {4,5,6}, {4,6,7}, {0,4,7}, {0,7,1}, {1,7,6}, {1,6,2}, {2,6,5}, {2,5,3}, {4,0,3}, {4,3,5} };
|
||||
|
||||
TriangleMesh cube(vertices, facets);
|
||||
cube.repair();
|
||||
|
@ -349,8 +349,8 @@ SCENARIO( "TriangleMesh: Mesh merge functions") {
|
|||
|
||||
SCENARIO( "TriangleMeshSlicer: Cut behavior.") {
|
||||
GIVEN( "A 20mm cube with one corner on the origin") {
|
||||
const std::vector<Vec3d> vertices { Vec3d(20,20,0), Vec3d(20,0,0), Vec3d(0,0,0), Vec3d(0,20,0), Vec3d(20,20,20), Vec3d(0,20,20), Vec3d(0,0,20), Vec3d(20,0,20) };
|
||||
const std::vector<Vec3crd> facets { Vec3crd(0,1,2), Vec3crd(0,2,3), Vec3crd(4,5,6), Vec3crd(4,6,7), Vec3crd(0,4,7), Vec3crd(0,7,1), Vec3crd(1,7,6), Vec3crd(1,6,2), Vec3crd(2,6,5), Vec3crd(2,5,3), Vec3crd(4,0,3), Vec3crd(4,3,5) };
|
||||
const std::vector<Vec3d> vertices { {20,20,0}, {20,0,0}, {0,0,0}, {0,20,0}, {20,20,20}, {0,20,20}, {0,0,20}, {20,0,20} };
|
||||
const std::vector<Vec3i> facets { {0,1,2}, {0,2,3}, {4,5,6}, {4,6,7}, {0,4,7}, {0,7,1}, {1,7,6}, {1,6,2}, {2,6,5}, {2,5,3}, {4,0,3}, {4,3,5} };
|
||||
|
||||
TriangleMesh cube(vertices, facets);
|
||||
cube.repair();
|
||||
|
|
|
@ -15,7 +15,7 @@ SCENARIO("Constant offset", "[ClipperUtils]") {
|
|||
coord_t s = 1000000;
|
||||
GIVEN("20mm box") {
|
||||
ExPolygon box20mm;
|
||||
box20mm.contour.points = { { 0, 0 }, { 20 * s, 0 }, { 20 * s, 20 * s}, { 0, 20 * s} };
|
||||
box20mm.contour.points = { Vec2crd{ 0, 0 }, Vec2crd{ 20 * s, 0 }, Vec2crd{ 20 * s, 20 * s}, Vec2crd{ 0, 20 * s} };
|
||||
std::vector<float> deltas_plus(box20mm.contour.points.size(), 1. * s);
|
||||
std::vector<float> deltas_minus(box20mm.contour.points.size(), - 1. * s);
|
||||
Polygons output;
|
||||
|
@ -87,8 +87,8 @@ SCENARIO("Constant offset", "[ClipperUtils]") {
|
|||
|
||||
GIVEN("20mm box with 10mm hole") {
|
||||
ExPolygon box20mm;
|
||||
box20mm.contour.points = { { 0, 0 }, { 20 * s, 0 }, { 20 * s, 20 * s}, { 0, 20 * s} };
|
||||
box20mm.holes.emplace_back(Slic3r::Polygon({ { 5 * s, 5 * s }, { 5 * s, 15 * s}, { 15 * s, 15 * s}, { 15 * s, 5 * s } }));
|
||||
box20mm.contour.points = { Vec2crd{ 0, 0 }, Vec2crd{ 20 * s, 0 }, Vec2crd{ 20 * s, 20 * s}, Vec2crd{ 0, 20 * s} };
|
||||
box20mm.holes.emplace_back(Slic3r::Polygon({ Vec2crd{ 5 * s, 5 * s }, Vec2crd{ 5 * s, 15 * s}, Vec2crd{ 15 * s, 15 * s}, Vec2crd{ 15 * s, 5 * s } }));
|
||||
std::vector<float> deltas_plus(box20mm.contour.points.size(), 1. * s);
|
||||
std::vector<float> deltas_minus(box20mm.contour.points.size(), -1. * s);
|
||||
ExPolygons output;
|
||||
|
@ -164,7 +164,7 @@ SCENARIO("Constant offset", "[ClipperUtils]") {
|
|||
|
||||
GIVEN("20mm right angle triangle") {
|
||||
ExPolygon triangle20mm;
|
||||
triangle20mm.contour.points = { { 0, 0 }, { 20 * s, 0 }, { 0, 20 * s} };
|
||||
triangle20mm.contour.points = { Vec2crd{ 0, 0 }, Vec2crd{ 20 * s, 0 }, Vec2crd{ 0, 20 * s } };
|
||||
Polygons output;
|
||||
double offset = 1.;
|
||||
// Angle of the sharp corner bisector.
|
||||
|
|
|
@ -246,7 +246,7 @@ TEST_CASE("Traversing Clipper PolyTree", "[ClipperUtils]") {
|
|||
// Create a polygon representing unit box
|
||||
Polygon unitbox;
|
||||
const auto UNIT = coord_t(1. / SCALING_FACTOR);
|
||||
unitbox.points = {{0, 0}, {UNIT, 0}, {UNIT, UNIT}, {0, UNIT}};
|
||||
unitbox.points = { Vec2crd{0, 0}, Vec2crd{UNIT, 0}, Vec2crd{UNIT, UNIT}, Vec2crd{0, UNIT}};
|
||||
|
||||
Polygon box_frame = unitbox;
|
||||
box_frame.scale(20, 10);
|
||||
|
|
|
@ -519,7 +519,7 @@ SCENARIO("Elephant foot compensation", "[ElephantFoot]") {
|
|||
// Rectangle
|
||||
ExPolygon expoly;
|
||||
coord_t scaled_w = coord_t(scale_(10));
|
||||
expoly.contour.points = { { 0, 0 }, { 0, scaled_w, }, { scaled_w, scaled_w }, { scaled_w, 0 } };
|
||||
expoly.contour.points = { Vec2crd{ 0, 0 }, Vec2crd{ 0, scaled_w, }, Vec2crd{ scaled_w, scaled_w }, Vec2crd{ scaled_w, 0 } };
|
||||
// Narrow part
|
||||
ExPolygon expoly2;
|
||||
coord_t scaled_h = coord_t(scale_(0.8));
|
||||
|
|
Loading…
Reference in a new issue