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:
SoftFever
2024-05-10 23:42:28 +08:00
parent 5bceebdd9d
commit 9b2c2bff1d
87 changed files with 380 additions and 362 deletions

View File

@@ -365,7 +365,7 @@ double get_distance(const Vec3f &p, const Interior &interior)
// part of that mesh and the vertices it consists of.
enum { NEW_FACE = -1};
struct DivFace {
Vec3i indx;
Vec3i32 indx;
std::array<Vec3f, 3> verts;
long faceid = NEW_FACE;
long parent = NEW_FACE;
@@ -511,7 +511,7 @@ void remove_inside_triangles(TriangleMesh &mesh, const Interior &interior,
interior.reset_accessor();
exec_policy::for_each(size_t(0), faces.size(), [&] (size_t face_idx) {
const Vec3i &face = faces[face_idx];
const Vec3i32 &face = faces[face_idx];
// If the triangle is excluded, we need to keep it.
if (is_excluded(face_idx))
@@ -532,7 +532,7 @@ void remove_inside_triangles(TriangleMesh &mesh, const Interior &interior,
}, exec_policy::max_concurreny());
auto new_faces = reserve_vector<Vec3i>(faces.size() +
auto new_faces = reserve_vector<Vec3i32>(faces.size() +
mesh_mods.new_triangles.size());
for (size_t face_idx = 0; face_idx < faces.size(); ++face_idx) {

View File

@@ -116,7 +116,7 @@ const std::vector<Vec3f>& IndexedMesh::vertices() const
const std::vector<Vec3i>& IndexedMesh::indices() const
const std::vector<Vec3i32>& IndexedMesh::indices() const
{
return m_tm->indices;
}
@@ -130,7 +130,7 @@ const Vec3f& IndexedMesh::vertices(size_t idx) const
const Vec3i& IndexedMesh::indices(size_t idx) const
const Vec3i32& IndexedMesh::indices(size_t idx) const
{
return m_tm->indices[idx];
}
@@ -394,7 +394,7 @@ PointSet normals(const PointSet& points,
if (ic >= 0) { // The point is right on a vertex of the triangle
for (size_t n = 0; n < mesh.indices().size(); ++n) {
thr();
Vec3i ni = mesh.indices(n);
Vec3i32 ni = mesh.indices(n);
if ((ni(X) == ic || ni(Y) == ic || ni(Z) == ic))
neigh.emplace_back(n);
}
@@ -402,7 +402,7 @@ PointSet normals(const PointSet& points,
// now get all the neigboring triangles
for (size_t n = 0; n < mesh.indices().size(); ++n) {
thr();
Vec3i ni = mesh.indices(n);
Vec3i32 ni = mesh.indices(n);
if ((ni(X) == ia || ni(Y) == ia || ni(Z) == ia) &&
(ni(X) == ib || ni(Y) == ib || ni(Z) == ib))
neigh.emplace_back(n);

View File

@@ -64,9 +64,9 @@ public:
inline double ground_level_offset() const { return m_gnd_offset; }
const std::vector<Vec3f>& vertices() const;
const std::vector<Vec3i>& indices() const;
const std::vector<Vec3i32>& indices() const;
const Vec3f& vertices(size_t idx) const;
const Vec3i& indices(size_t idx) const;
const Vec3i32& indices(size_t idx) const;
// Result of a raycast
class hit_result {

View File

@@ -33,7 +33,7 @@ template<class Fn> void foreach_vertex(ExPolygon &poly, Fn &&fn)
for (auto &p : h.points) fn(p);
}
ExPolygons raster_to_polygons(const RasterGrayscaleAA &rst, Vec2i windowsize)
ExPolygons raster_to_polygons(const RasterGrayscaleAA &rst, Vec2i32 windowsize)
{
size_t rows = rst.resolution().height_px, cols = rst.resolution().width_px;

View File

@@ -8,7 +8,7 @@ namespace sla {
class RasterGrayscaleAA;
ExPolygons raster_to_polygons(const RasterGrayscaleAA &rst, Vec2i windowsize = {2, 2});
ExPolygons raster_to_polygons(const RasterGrayscaleAA &rst, Vec2i32 windowsize = {2, 2});
}} // namespace Slic3r::sla

View File

@@ -439,8 +439,8 @@ static inline std::vector<Vec2f> poisson_disk_from_samples(const std::vector<Vec
struct RawSample
{
Vec2f coord;
Vec2i cell_id;
RawSample(const Vec2f &crd = {}, const Vec2i &id = {}): coord{crd}, cell_id{id} {}
Vec2i32 cell_id;
RawSample(const Vec2f &crd = {}, const Vec2i32 &id = {}): coord{crd}, cell_id{id} {}
};
auto raw_samples_sorted = reserve_vector<RawSample>(raw_samples.size());
@@ -464,7 +464,7 @@ static inline std::vector<Vec2f> poisson_disk_from_samples(const std::vector<Vec
};
struct CellIDHash {
std::size_t operator()(const Vec2i &cell_id) const {
std::size_t operator()(const Vec2i32 &cell_id) const {
return std::hash<int>()(cell_id.x()) ^ std::hash<int>()(cell_id.y() * 593);
}
};
@@ -472,11 +472,11 @@ static inline std::vector<Vec2f> poisson_disk_from_samples(const std::vector<Vec
// Map from cell IDs to hash_data. Each hash_data points to the range in raw_samples corresponding to that cell.
// (We could just store the samples in hash_data. This implementation is an artifact of the reference paper, which
// is optimizing for GPU acceleration that we haven't implemented currently.)
typedef std::unordered_map<Vec2i, PoissonDiskGridEntry, CellIDHash> Cells;
typedef std::unordered_map<Vec2i32, PoissonDiskGridEntry, CellIDHash> Cells;
Cells cells;
{
typename Cells::iterator last_cell_id_it;
Vec2i last_cell_id(-1, -1);
Vec2i32 last_cell_id(-1, -1);
for (size_t i = 0; i < raw_samples_sorted.size(); ++ i) {
const RawSample &sample = raw_samples_sorted[i];
if (sample.cell_id == last_cell_id) {
@@ -500,7 +500,7 @@ static inline std::vector<Vec2f> poisson_disk_from_samples(const std::vector<Vec
for (int trial = 0; trial < max_trials; ++ trial) {
// Create sample points for each entry in cells.
for (auto &it : cells) {
const Vec2i &cell_id = it.first;
const Vec2i32 &cell_id = it.first;
PoissonDiskGridEntry &cell_data = it.second;
// This cell's raw sample points start at first_sample_idx. On trial 0, try the first one. On trial 1, try first_sample_idx + 1.
int next_sample_idx = cell_data.first_sample_idx + trial;
@@ -513,7 +513,7 @@ static inline std::vector<Vec2f> poisson_disk_from_samples(const std::vector<Vec
bool conflict = refuse_function(candidate.coord);
for (int i = -1; i < 2 && ! conflict; ++ i) {
for (int j = -1; j < 2; ++ j) {
const auto &it_neighbor = cells.find(cell_id + Vec2i(i, j));
const auto &it_neighbor = cells.find(cell_id + Vec2i32(i, j));
if (it_neighbor != cells.end()) {
const PoissonDiskGridEntry &neighbor = it_neighbor->second;
for (int i_sample = 0; i_sample < neighbor.num_poisson_samples; ++ i_sample)

View File

@@ -139,17 +139,17 @@ public:
struct PointGrid3D {
struct GridHash {
std::size_t operator()(const Vec3i &cell_id) const {
std::size_t operator()(const Vec3i32 &cell_id) const {
return std::hash<int>()(cell_id.x()) ^ std::hash<int>()(cell_id.y() * 593) ^ std::hash<int>()(cell_id.z() * 7919);
}
};
typedef std::unordered_multimap<Vec3i, RichSupportPoint, GridHash> Grid;
typedef std::unordered_multimap<Vec3i32, RichSupportPoint, GridHash> Grid;
Vec3f cell_size;
Grid grid;
Vec3i cell_id(const Vec3f &pos) {
return Vec3i(int(floor(pos.x() / cell_size.x())),
Vec3i32 cell_id(const Vec3f &pos) {
return Vec3i32(int(floor(pos.x() / cell_size.x())),
int(floor(pos.y() / cell_size.y())),
int(floor(pos.z() / cell_size.z())));
}
@@ -163,7 +163,7 @@ public:
bool collides_with(const Vec2f &pos, float print_z, float radius) {
Vec3f pos3d(pos.x(), pos.y(), print_z);
Vec3i cell = cell_id(pos3d);
Vec3i32 cell = cell_id(pos3d);
std::pair<Grid::const_iterator, Grid::const_iterator> it_pair = grid.equal_range(cell);
if (collides_with(pos3d, radius, it_pair.first, it_pair.second))
return true;
@@ -172,7 +172,7 @@ public:
for (int k = -1; k < 1; ++ k) {
if (i == 0 && j == 0 && k == 0)
continue;
it_pair = grid.equal_range(cell + Vec3i(i, j, k));
it_pair = grid.equal_range(cell + Vec3i32(i, j, k));
if (collides_with(pos3d, radius, it_pair.first, it_pair.second))
return true;
}