mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-19 20:57:53 -06:00
Support larger printer sizes by using 64-bit.
SuperSlicer is referenced for some changes. Co-authored-by: Merill <merill@free.fr>
This commit is contained in:
parent
5bceebdd9d
commit
9b2c2bff1d
87 changed files with 380 additions and 362 deletions
|
@ -134,7 +134,7 @@ bool TriangleSelector::verify_triangle_midpoints(const Triangle &tr) const
|
|||
return true;
|
||||
}
|
||||
|
||||
bool TriangleSelector::verify_triangle_neighbors(const Triangle &tr, const Vec3i &neighbors) const
|
||||
bool TriangleSelector::verify_triangle_neighbors(const Triangle &tr, const Vec3i32 &neighbors) const
|
||||
{
|
||||
assert(neighbors(0) >= -1);
|
||||
assert(neighbors(1) >= -1);
|
||||
|
@ -187,7 +187,7 @@ inline bool is_point_inside_triangle(const Vec3f &pt, const Vec3f &p1, const Vec
|
|||
return std::all_of(begin(barycentric_cords), end(barycentric_cords), [](float cord) { return 0.f <= cord && cord <= 1.0; });
|
||||
}
|
||||
|
||||
int TriangleSelector::select_unsplit_triangle(const Vec3f &hit, int facet_idx, const Vec3i &neighbors) const
|
||||
int TriangleSelector::select_unsplit_triangle(const Vec3f &hit, int facet_idx, const Vec3i32 &neighbors) const
|
||||
{
|
||||
assert(facet_idx < int(m_triangles.size()));
|
||||
const Triangle *tr = &m_triangles[facet_idx];
|
||||
|
@ -226,7 +226,7 @@ int TriangleSelector::select_unsplit_triangle(const Vec3f &hit, int facet_idx) c
|
|||
if (!m_triangles[facet_idx].valid())
|
||||
return -1;
|
||||
|
||||
Vec3i neighbors = m_neighbors[facet_idx];
|
||||
Vec3i32 neighbors = m_neighbors[facet_idx];
|
||||
assert(this->verify_triangle_neighbors(m_triangles[facet_idx], neighbors));
|
||||
return this->select_unsplit_triangle(hit, facet_idx, neighbors);
|
||||
}
|
||||
|
@ -372,7 +372,7 @@ void TriangleSelector::seed_fill_select_triangles(const Vec3f &hit, int facet_st
|
|||
}
|
||||
}
|
||||
|
||||
void TriangleSelector::precompute_all_neighbors_recursive(const int facet_idx, const Vec3i &neighbors, const Vec3i &neighbors_propagated, std::vector<Vec3i> &neighbors_out, std::vector<Vec3i> &neighbors_propagated_out) const
|
||||
void TriangleSelector::precompute_all_neighbors_recursive(const int facet_idx, const Vec3i32 &neighbors, const Vec3i32 &neighbors_propagated, std::vector<Vec3i32> &neighbors_out, std::vector<Vec3i32> &neighbors_propagated_out) const
|
||||
{
|
||||
assert(facet_idx < int(m_triangles.size()));
|
||||
|
||||
|
@ -392,7 +392,7 @@ void TriangleSelector::precompute_all_neighbors_recursive(const int facet_idx, c
|
|||
assert(tr->children[i] < int(m_triangles.size()));
|
||||
// Recursion, deep first search over the children of this triangle.
|
||||
// All children of this triangle were created by splitting a single source triangle of the original mesh.
|
||||
const Vec3i child_neighbors = this->child_neighbors(*tr, neighbors, i);
|
||||
const Vec3i32 child_neighbors = this->child_neighbors(*tr, neighbors, i);
|
||||
this->precompute_all_neighbors_recursive(tr->children[i], child_neighbors,
|
||||
this->child_neighbors_propagated(*tr, neighbors_propagated, i, child_neighbors), neighbors_out,
|
||||
neighbors_propagated_out);
|
||||
|
@ -401,10 +401,10 @@ void TriangleSelector::precompute_all_neighbors_recursive(const int facet_idx, c
|
|||
}
|
||||
}
|
||||
|
||||
std::pair<std::vector<Vec3i>, std::vector<Vec3i>> TriangleSelector::precompute_all_neighbors() const
|
||||
std::pair<std::vector<Vec3i32>, std::vector<Vec3i32>> TriangleSelector::precompute_all_neighbors() const
|
||||
{
|
||||
std::vector<Vec3i> neighbors(m_triangles.size(), Vec3i(-1, -1, -1));
|
||||
std::vector<Vec3i> neighbors_propagated(m_triangles.size(), Vec3i(-1, -1, -1));
|
||||
std::vector<Vec3i32> neighbors(m_triangles.size(), Vec3i32(-1, -1, -1));
|
||||
std::vector<Vec3i32> neighbors_propagated(m_triangles.size(), Vec3i32(-1, -1, -1));
|
||||
for (int facet_idx = 0; facet_idx < this->m_orig_size_indices; ++facet_idx) {
|
||||
neighbors[facet_idx] = m_neighbors[facet_idx];
|
||||
neighbors_propagated[facet_idx] = neighbors[facet_idx];
|
||||
|
@ -442,7 +442,7 @@ void TriangleSelector::append_touching_subtriangles(int itriangle, int vertexi,
|
|||
|
||||
// It appends all edges that are touching the edge (vertexi, vertexj) of the triangle and are not selected by seed fill
|
||||
// It doesn't append the edges that are touching the triangle only by part of the edge that means the triangles are from lower depth.
|
||||
void TriangleSelector::append_touching_edges(int itriangle, int vertexi, int vertexj, std::vector<Vec2i> &touching_edges_out) const
|
||||
void TriangleSelector::append_touching_edges(int itriangle, int vertexi, int vertexj, std::vector<Vec2i32> &touching_edges_out) const
|
||||
{
|
||||
if (itriangle == -1)
|
||||
return;
|
||||
|
@ -497,11 +497,11 @@ void TriangleSelector::bucket_fill_select_triangles(const Vec3f& hit, int facet_
|
|||
// seed_fill_angle < 0.f to disable edge detection
|
||||
const double facet_angle_limit = (seed_fill_angle < 0.f ? -1.f : cos(Geometry::deg2rad(seed_fill_angle))) - EPSILON;
|
||||
|
||||
auto get_all_touching_triangles = [this](int facet_idx, const Vec3i &neighbors, const Vec3i &neighbors_propagated) -> std::vector<int> {
|
||||
auto get_all_touching_triangles = [this](int facet_idx, const Vec3i32 &neighbors, const Vec3i32 &neighbors_propagated) -> std::vector<int> {
|
||||
assert(facet_idx != -1 && facet_idx < int(m_triangles.size()));
|
||||
assert(this->verify_triangle_neighbors(m_triangles[facet_idx], neighbors));
|
||||
std::vector<int> touching_triangles;
|
||||
Vec3i vertices = {m_triangles[facet_idx].verts_idxs[0], m_triangles[facet_idx].verts_idxs[1], m_triangles[facet_idx].verts_idxs[2]};
|
||||
Vec3i32 vertices = {m_triangles[facet_idx].verts_idxs[0], m_triangles[facet_idx].verts_idxs[1], m_triangles[facet_idx].verts_idxs[2]};
|
||||
append_touching_subtriangles(neighbors(0), vertices(1), vertices(0), touching_triangles);
|
||||
append_touching_subtriangles(neighbors(1), vertices(2), vertices(1), touching_triangles);
|
||||
append_touching_subtriangles(neighbors(2), vertices(0), vertices(2), touching_triangles);
|
||||
|
@ -557,7 +557,7 @@ bool TriangleSelector::select_triangle(int facet_idx, EnforcerBlockerType type,
|
|||
if (! m_triangles[facet_idx].valid())
|
||||
return false;
|
||||
|
||||
Vec3i neighbors = m_neighbors[facet_idx];
|
||||
Vec3i32 neighbors = m_neighbors[facet_idx];
|
||||
assert(this->verify_triangle_neighbors(m_triangles[facet_idx], neighbors));
|
||||
|
||||
if (! select_triangle_recursive(facet_idx, neighbors, type, triangle_splitting))
|
||||
|
@ -741,7 +741,7 @@ int TriangleSelector::triangle_midpoint_or_allocate(int itriangle, int vertexi,
|
|||
// Returns -1 if such a neighbor does not exist at all, or it does not exist
|
||||
// at the same depth as the ith child.
|
||||
// Using the same splitting strategy as TriangleSelector::split_triangle()
|
||||
Vec3i TriangleSelector::child_neighbors(const Triangle &tr, const Vec3i &neighbors, int child_idx) const
|
||||
Vec3i32 TriangleSelector::child_neighbors(const Triangle &tr, const Vec3i32 &neighbors, int child_idx) const
|
||||
{
|
||||
assert(this->verify_triangle_neighbors(tr, neighbors));
|
||||
|
||||
|
@ -750,7 +750,7 @@ Vec3i TriangleSelector::child_neighbors(const Triangle &tr, const Vec3i &neighbo
|
|||
int j = next_idx_modulo(i, 3);
|
||||
int k = next_idx_modulo(j, 3);
|
||||
|
||||
Vec3i out;
|
||||
Vec3i32 out;
|
||||
switch (tr.number_of_split_sides()) {
|
||||
case 1:
|
||||
switch (child_idx) {
|
||||
|
@ -828,13 +828,13 @@ Vec3i TriangleSelector::child_neighbors(const Triangle &tr, const Vec3i &neighbo
|
|||
|
||||
// Return neighbors of the ith child of a triangle given neighbors of the triangle.
|
||||
// If such a neighbor doesn't exist, return the neighbor from the previous depth.
|
||||
Vec3i TriangleSelector::child_neighbors_propagated(const Triangle &tr, const Vec3i &neighbors_propagated, int child_idx, const Vec3i &child_neighbors) const
|
||||
Vec3i32 TriangleSelector::child_neighbors_propagated(const Triangle &tr, const Vec3i32 &neighbors_propagated, int child_idx, const Vec3i32 &child_neighbors) const
|
||||
{
|
||||
int i = tr.special_side();
|
||||
int j = next_idx_modulo(i, 3);
|
||||
int k = next_idx_modulo(j, 3);
|
||||
|
||||
Vec3i out = child_neighbors;
|
||||
Vec3i32 out = child_neighbors;
|
||||
auto replace_if_not_exists = [&out, &neighbors_propagated](int index_to_replace, int neighbor_idx) {
|
||||
if (out(index_to_replace) == -1)
|
||||
out(index_to_replace) = neighbors_propagated(neighbor_idx);
|
||||
|
@ -900,7 +900,7 @@ Vec3i TriangleSelector::child_neighbors_propagated(const Triangle &tr, const Vec
|
|||
return out;
|
||||
}
|
||||
|
||||
bool TriangleSelector::select_triangle_recursive(int facet_idx, const Vec3i &neighbors, EnforcerBlockerType type, bool triangle_splitting)
|
||||
bool TriangleSelector::select_triangle_recursive(int facet_idx, const Vec3i32 &neighbors, EnforcerBlockerType type, bool triangle_splitting)
|
||||
{
|
||||
assert(facet_idx < int(m_triangles.size()));
|
||||
|
||||
|
@ -963,7 +963,7 @@ void TriangleSelector::set_facet(int facet_idx, EnforcerBlockerType state)
|
|||
|
||||
// called by select_patch()->select_triangle()...select_triangle()
|
||||
// to decide which sides of the triangle to split and to actually split it calling set_division() and perform_split().
|
||||
void TriangleSelector::split_triangle(int facet_idx, const Vec3i &neighbors)
|
||||
void TriangleSelector::split_triangle(int facet_idx, const Vec3i32 &neighbors)
|
||||
{
|
||||
if (m_triangles[facet_idx].is_split()) {
|
||||
// The triangle is divided already.
|
||||
|
@ -1320,7 +1320,7 @@ int TriangleSelector::push_triangle(int a, int b, int c, int source_triangle, co
|
|||
// Split a triangle based on Triangle::number_of_split_sides() and Triangle::special_side()
|
||||
// by allocating child triangles and midpoint vertices.
|
||||
// Midpoint vertices are possibly reused by traversing children of neighbor triangles.
|
||||
void TriangleSelector::perform_split(int facet_idx, const Vec3i &neighbors, EnforcerBlockerType old_state)
|
||||
void TriangleSelector::perform_split(int facet_idx, const Vec3i32 &neighbors, EnforcerBlockerType old_state)
|
||||
{
|
||||
// Reserve space for the new triangles upfront, so that the reference to this triangle will not change.
|
||||
{
|
||||
|
@ -1381,7 +1381,7 @@ void TriangleSelector::perform_split(int facet_idx, const Vec3i &neighbors, Enfo
|
|||
#ifndef NDEBUG
|
||||
assert(this->verify_triangle_neighbors(tr, neighbors));
|
||||
for (int i = 0; i <= tr.number_of_split_sides(); ++i) {
|
||||
Vec3i n = this->child_neighbors(tr, neighbors, i);
|
||||
Vec3i32 n = this->child_neighbors(tr, neighbors, i);
|
||||
assert(this->verify_triangle_neighbors(m_triangles[tr.children[i]], n));
|
||||
}
|
||||
#endif // NDEBUG
|
||||
|
@ -1480,7 +1480,7 @@ indexed_triangle_set TriangleSelector::get_facets_strict(EnforcerBlockerType sta
|
|||
|
||||
void TriangleSelector::get_facets_strict_recursive(
|
||||
const Triangle &tr,
|
||||
const Vec3i &neighbors,
|
||||
const Vec3i32 &neighbors,
|
||||
EnforcerBlockerType state,
|
||||
std::vector<stl_triangle_vertex_indices> &out_triangles) const
|
||||
{
|
||||
|
@ -1494,10 +1494,10 @@ void TriangleSelector::get_facets_strict_recursive(
|
|||
this->get_facets_split_by_tjoints({tr.verts_idxs[0], tr.verts_idxs[1], tr.verts_idxs[2]}, neighbors, out_triangles);
|
||||
}
|
||||
|
||||
void TriangleSelector::get_facets_split_by_tjoints(const Vec3i &vertices, const Vec3i &neighbors, std::vector<stl_triangle_vertex_indices> &out_triangles) const
|
||||
void TriangleSelector::get_facets_split_by_tjoints(const Vec3i32 &vertices, const Vec3i32 &neighbors, std::vector<stl_triangle_vertex_indices> &out_triangles) const
|
||||
{
|
||||
// Export this triangle, but first collect the T-joint vertices along its edges.
|
||||
Vec3i midpoints(
|
||||
Vec3i32 midpoints(
|
||||
this->triangle_midpoint(neighbors(0), vertices(1), vertices(0)),
|
||||
this->triangle_midpoint(neighbors(1), vertices(2), vertices(1)),
|
||||
this->triangle_midpoint(neighbors(2), vertices(0), vertices(2)));
|
||||
|
@ -1578,10 +1578,10 @@ void TriangleSelector::get_facets_split_by_tjoints(const Vec3i &vertices, const
|
|||
}
|
||||
}
|
||||
|
||||
std::vector<Vec2i> TriangleSelector::get_seed_fill_contour() const {
|
||||
std::vector<Vec2i> edges_out;
|
||||
std::vector<Vec2i32> TriangleSelector::get_seed_fill_contour() const {
|
||||
std::vector<Vec2i32> edges_out;
|
||||
for (int facet_idx = 0; facet_idx < this->m_orig_size_indices; ++facet_idx) {
|
||||
const Vec3i neighbors = m_neighbors[facet_idx];
|
||||
const Vec3i32 neighbors = m_neighbors[facet_idx];
|
||||
assert(this->verify_triangle_neighbors(m_triangles[facet_idx], neighbors));
|
||||
this->get_seed_fill_contour_recursive(facet_idx, neighbors, neighbors, edges_out);
|
||||
}
|
||||
|
@ -1589,7 +1589,7 @@ std::vector<Vec2i> TriangleSelector::get_seed_fill_contour() const {
|
|||
return edges_out;
|
||||
}
|
||||
|
||||
void TriangleSelector::get_seed_fill_contour_recursive(const int facet_idx, const Vec3i &neighbors, const Vec3i &neighbors_propagated, std::vector<Vec2i> &edges_out) const {
|
||||
void TriangleSelector::get_seed_fill_contour_recursive(const int facet_idx, const Vec3i32 &neighbors, const Vec3i32 &neighbors_propagated, std::vector<Vec2i32> &edges_out) const {
|
||||
assert(facet_idx != -1 && facet_idx < int(m_triangles.size()));
|
||||
assert(this->verify_triangle_neighbors(m_triangles[facet_idx], neighbors));
|
||||
const Triangle *tr = &m_triangles[facet_idx];
|
||||
|
@ -1604,13 +1604,13 @@ void TriangleSelector::get_seed_fill_contour_recursive(const int facet_idx, cons
|
|||
assert(tr->children[i] < int(m_triangles.size()));
|
||||
// Recursion, deep first search over the children of this triangle.
|
||||
// All children of this triangle were created by splitting a single source triangle of the original mesh.
|
||||
const Vec3i child_neighbors = this->child_neighbors(*tr, neighbors, i);
|
||||
const Vec3i32 child_neighbors = this->child_neighbors(*tr, neighbors, i);
|
||||
this->get_seed_fill_contour_recursive(tr->children[i], child_neighbors,
|
||||
this->child_neighbors_propagated(*tr, neighbors_propagated, i, child_neighbors), edges_out);
|
||||
}
|
||||
}
|
||||
} else if (tr->is_selected_by_seed_fill()) {
|
||||
Vec3i vertices = {m_triangles[facet_idx].verts_idxs[0], m_triangles[facet_idx].verts_idxs[1], m_triangles[facet_idx].verts_idxs[2]};
|
||||
Vec3i32 vertices = {m_triangles[facet_idx].verts_idxs[0], m_triangles[facet_idx].verts_idxs[1], m_triangles[facet_idx].verts_idxs[2]};
|
||||
append_touching_edges(neighbors(0), vertices(1), vertices(0), edges_out);
|
||||
append_touching_edges(neighbors(1), vertices(2), vertices(1), edges_out);
|
||||
append_touching_edges(neighbors(2), vertices(0), vertices(2), edges_out);
|
||||
|
@ -1720,7 +1720,7 @@ void TriangleSelector::deserialize(const std::pair<std::vector<std::pair<int, in
|
|||
// Vector to store all parents that have offsprings.
|
||||
struct ProcessingInfo {
|
||||
int facet_id = 0;
|
||||
Vec3i neighbors { -1, -1, -1 };
|
||||
Vec3i32 neighbors { -1, -1, -1 };
|
||||
int processed_children = 0;
|
||||
int total_children = 0;
|
||||
};
|
||||
|
@ -1760,7 +1760,7 @@ void TriangleSelector::deserialize(const std::pair<std::vector<std::pair<int, in
|
|||
if (is_split) {
|
||||
// root is split, add it into list of parents and split it.
|
||||
// then go to the next.
|
||||
Vec3i neighbors = m_neighbors[triangle_id];
|
||||
Vec3i32 neighbors = m_neighbors[triangle_id];
|
||||
parents.push_back({triangle_id, neighbors, 0, num_of_children});
|
||||
m_triangles[triangle_id].set_division(num_of_split_sides, special_side);
|
||||
perform_split(triangle_id, neighbors, EnforcerBlockerType::NONE);
|
||||
|
@ -1780,7 +1780,7 @@ void TriangleSelector::deserialize(const std::pair<std::vector<std::pair<int, in
|
|||
// split the triangle and save it as parent of the next ones.
|
||||
const Triangle &tr = m_triangles[last.facet_id];
|
||||
int child_idx = last.total_children - last.processed_children - 1;
|
||||
Vec3i neighbors = this->child_neighbors(tr, last.neighbors, child_idx);
|
||||
Vec3i32 neighbors = this->child_neighbors(tr, last.neighbors, child_idx);
|
||||
int this_idx = tr.children[child_idx];
|
||||
m_triangles[this_idx].set_division(num_of_split_sides, special_side);
|
||||
perform_split(this_idx, neighbors, EnforcerBlockerType::NONE);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue