Update/clean code where a wrong int type is used (unsafe int, bad type, ...)

as that that can be problematic if the type of coord_t change.
This commit is contained in:
supermerill 2019-04-08 19:41:04 +02:00
parent 0f65a8d815
commit 782d3706e1
14 changed files with 121 additions and 127 deletions

View File

@ -20,12 +20,12 @@ typedef Point Vector;
// Eigen types, to replace the Slic3r's own types in the future. // Eigen types, to replace the Slic3r's own types in the future.
// Vector types with a fixed point coordinate base type. // Vector types with a fixed point coordinate base type.
typedef Eigen::Matrix<coord_t, 2, 1, Eigen::DontAlign> Vec2crd; typedef Eigen::Matrix<int32_t, 2, 1, Eigen::DontAlign> Vec2i32;
typedef Eigen::Matrix<coord_t, 3, 1, Eigen::DontAlign> Vec3crd; typedef Eigen::Matrix<int32_t, 3, 1, Eigen::DontAlign> Vec3i32;
typedef Eigen::Matrix<int, 2, 1, Eigen::DontAlign> Vec2i; typedef Eigen::Matrix<int64_t, 2, 1, Eigen::DontAlign> Vec2i64;
typedef Eigen::Matrix<int, 3, 1, Eigen::DontAlign> Vec3i; typedef Eigen::Matrix<int64_t, 3, 1, Eigen::DontAlign> Vec3i64;
typedef Eigen::Matrix<int64_t, 2, 1, Eigen::DontAlign> Vec2i64; typedef Vec2i64 Vec2crd;
typedef Eigen::Matrix<int64_t, 3, 1, Eigen::DontAlign> Vec3i64; typedef Vec3i64 Vec3crd;
// Vector types with a double coordinate base type. // Vector types with a double coordinate base type.
typedef Eigen::Matrix<float, 2, 1, Eigen::DontAlign> Vec2f; typedef Eigen::Matrix<float, 2, 1, Eigen::DontAlign> Vec2f;
@ -47,23 +47,23 @@ 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 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 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 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 double cross2(const Vec2d &v1, const Vec2d &v2) { return v1(0) * v2(1) - v1(1) * v2(0); }
inline coordf_t dot(const Vec2d &v1, const Vec2d &v2) { return v1.x() * v2.x() + v1.y() * v2.y(); } inline coordf_t dot(const Vec2d &v1, const Vec2d &v2) { return v1.x() * v2.x() + v1.y() * v2.y(); }
inline coordf_t dot(const Vec2d &v) { return v.x() * v.x() + v.y() * v.y(); } inline coordf_t dot(const Vec2d &v) { return v.x() * v.x() + v.y() * v.y(); }
inline Vec2crd to_2d(const Vec3crd &pt3) { return Vec2crd(pt3(0), pt3(1)); } inline Vec3i32 to_2d(const Vec3i32 &pt3) { return Vec3i32(pt3(0), pt3(1)); }
inline Vec2i64 to_2d(const Vec3i64 &pt3) { return Vec2i64(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 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)); } inline Vec2d to_2d(const Vec3d &pt3) { return Vec2d (pt3(0), pt3(1)); }
inline Vec3d to_3d(const Vec2d &v, double z) { return Vec3d(v(0), v(1), z); } inline Vec3d to_3d(const Vec2d &v, double z) { return Vec3d(v(0), v(1), z); }
inline Vec3f to_3d(const Vec2f &v, float z) { return Vec3f(v(0), v(1), z); } inline Vec3f to_3d(const Vec2f &v, float z) { return Vec3f(v(0), v(1), z); }
inline Vec3i32 to_3d(const Vec3i32 &v, float z) { return Vec3i32(int32_t(v(0)), int32_t(v(1)), int32_t(z)); }
inline Vec3i64 to_3d(const Vec2i64 &v, float z) { return Vec3i64(int64_t(v(0)), int64_t(v(1)), int64_t(z)); } inline Vec3i64 to_3d(const Vec2i64 &v, float z) { return Vec3i64(int64_t(v(0)), int64_t(v(1)), int64_t(z)); }
inline Vec3crd to_3d(const Vec3crd &p, coord_t z) { return Vec3crd(p(0), p(1), z); }
inline Vec2d unscale(coord_t x, coord_t y) { return Vec2d(unscale<double>(x), unscale<double>(y)); } inline Vec2d unscale(coord_t x, coord_t y) { return Vec2d(unscale<double>(x), unscale<double>(y)); }
inline Vec2d unscale(const Vec2crd &pt) { return Vec2d(unscale<double>(pt(0)), unscale<double>(pt(1))); } inline Vec2d unscale(const Vec2crd &pt) { return Vec2d(unscale<double>(pt(0)), unscale<double>(pt(1))); }
@ -86,15 +86,16 @@ public:
typedef coord_t coord_type; typedef coord_t coord_type;
Point() : Vec2crd() { (*this)(0) = 0; (*this)(1) = 0; } Point() : Vec2crd() { (*this)(0) = 0; (*this)(1) = 0; }
Point(coord_t x, coord_t y) { (*this)(0) = x; (*this)(1) = y; } Point(int32_t x, int32_t y) { (*this)(0) = coord_t(x); (*this)(1) = coord_t(y); }
Point(int64_t x, int64_t y) { (*this)(0) = coord_t(x); (*this)(1) = coord_t(y); } // for Clipper Point(int64_t x, int64_t y) { (*this)(0) = coord_t(x); (*this)(1) = coord_t(y); }
Point(double x, double y) { (*this)(0) = coord_t(lrint(x)); (*this)(1) = coord_t(lrint(y)); } Point(double x, double y) { (*this)(0) = coord_t(lrintl(x)); (*this)(1) = coord_t(lrintl(y)); }
Point(const Point &rhs) { *this = rhs; } Point(const Point &rhs) { *this = rhs; }
// This constructor allows you to construct Point from Eigen expressions // This constructor allows you to construct Point from Eigen expressions
template<typename OtherDerived> template<typename OtherDerived>
Point(const Eigen::MatrixBase<OtherDerived> &other) : Vec2crd(other) {} Point(const Eigen::MatrixBase<OtherDerived> &other) : Vec2crd(other) {}
static Point new_scale(coordf_t x, coordf_t y) { return Point(coord_t(scale_(x)), coord_t(scale_(y))); } static Point new_scale(coordf_t x, coordf_t y) { return Point(coord_t(scale_(x)), coord_t(scale_(y))); }
static Point new_scale(const Point &p) { return Point(coord_t(scale_(p.x())), coord_t(scale_(p.y()))); } static Point new_scale(const Point &p) { return Point(coord_t(scale_(p.x())), coord_t(scale_(p.y()))); }
static Point new_scale(const Vec2d &p) { return Point(scale_(p.x()), scale_(p.y())); }
// This method allows you to assign Eigen expressions to MyVectorType // This method allows you to assign Eigen expressions to MyVectorType
template<typename OtherDerived> template<typename OtherDerived>

View File

@ -335,7 +335,7 @@ static inline std::vector<Vec2f> poisson_disk_from_samples(const std::vector<Vec
// Assign the raw samples to grid cells, sort the grid cells lexicographically. // Assign the raw samples to grid cells, sort the grid cells lexicographically.
struct RawSample { struct RawSample {
Vec2f coord; Vec2f coord;
Vec2i cell_id; Vec2i32 cell_id;
}; };
std::vector<RawSample> raw_samples_sorted; std::vector<RawSample> raw_samples_sorted;
RawSample sample; RawSample sample;
@ -361,7 +361,7 @@ static inline std::vector<Vec2f> poisson_disk_from_samples(const std::vector<Vec
}; };
struct CellIDHash { 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); return std::hash<int>()(cell_id.x()) ^ std::hash<int>()(cell_id.y() * 593);
} }
}; };
@ -369,11 +369,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. // 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 // (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.) // 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; Cells cells;
{ {
typename Cells::iterator last_cell_id_it; typename Cells::iterator last_cell_id_it;
Vec2i last_cell_id(-1, -1); Vec2i32 last_cell_id(-1, -1);
for (int i = 0; i < raw_samples_sorted.size(); ++ i) { for (int i = 0; i < raw_samples_sorted.size(); ++ i) {
const RawSample &sample = raw_samples_sorted[i]; const RawSample &sample = raw_samples_sorted[i];
if (sample.cell_id == last_cell_id) { if (sample.cell_id == last_cell_id) {
@ -397,7 +397,7 @@ static inline std::vector<Vec2f> poisson_disk_from_samples(const std::vector<Vec
for (int trial = 0; trial < max_trials; ++ trial) { for (int trial = 0; trial < max_trials; ++ trial) {
// Create sample points for each entry in cells. // Create sample points for each entry in cells.
for (auto &it : cells) { for (auto &it : cells) {
const Vec2i &cell_id = it.first; const Vec2i32 &cell_id = it.first;
PoissonDiskGridEntry &cell_data = it.second; 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. // 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; int next_sample_idx = cell_data.first_sample_idx + trial;
@ -410,7 +410,7 @@ static inline std::vector<Vec2f> poisson_disk_from_samples(const std::vector<Vec
bool conflict = refuse_function(candidate.coord); bool conflict = refuse_function(candidate.coord);
for (int i = -1; i < 2 && ! conflict; ++ i) { for (int i = -1; i < 2 && ! conflict; ++ i) {
for (int j = -1; j < 2; ++ j) { 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()) { if (it_neighbor != cells.end()) {
const PoissonDiskGridEntry &neighbor = it_neighbor->second; const PoissonDiskGridEntry &neighbor = it_neighbor->second;
for (int i_sample = 0; i_sample < neighbor.num_poisson_samples; ++ i_sample) for (int i_sample = 0; i_sample < neighbor.num_poisson_samples; ++ i_sample)

View File

@ -129,17 +129,17 @@ public:
struct PointGrid3D { struct PointGrid3D {
struct GridHash { 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); 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; Vec3f cell_size;
Grid grid; Grid grid;
Vec3i cell_id(const Vec3f &pos) { Vec3i32 cell_id(const Vec3f &pos) {
return Vec3i(int(floor(pos.x() / cell_size.x())), return Vec3i32(int(floor(pos.x() / cell_size.x())),
int(floor(pos.y() / cell_size.y())), int(floor(pos.y() / cell_size.y())),
int(floor(pos.z() / cell_size.z()))); int(floor(pos.z() / cell_size.z())));
} }
@ -153,7 +153,7 @@ public:
bool collides_with(const Vec2f &pos, Structure *island, float radius) { bool collides_with(const Vec2f &pos, Structure *island, float radius) {
Vec3f pos3d(pos.x(), pos.y(), float(island->layer->print_z)); Vec3f pos3d(pos.x(), pos.y(), float(island->layer->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); 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)) if (collides_with(pos3d, radius, it_pair.first, it_pair.second))
return true; return true;
@ -162,7 +162,7 @@ public:
for (int k = -1; k < 1; ++ k) { for (int k = -1; k < 1; ++ k) {
if (i == 0 && j == 0 && k == 0) if (i == 0 && j == 0 && k == 0)
continue; 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)) if (collides_with(pos3d, radius, it_pair.first, it_pair.second))
return true; return true;
} }

View File

@ -29,14 +29,14 @@ inline coordf_t& x(Vec3d& p) { return p(0); }
inline coordf_t& y(Vec3d& p) { return p(1); } inline coordf_t& y(Vec3d& p) { return p(1); }
inline coordf_t& z(Vec3d& p) { return p(2); } inline coordf_t& z(Vec3d& p) { return p(2); }
inline coord_t& x(Vec3crd& p) { return p(0); } inline int32_t& x(Vec3i32& p) { return p(0); }
inline coord_t& y(Vec3crd& p) { return p(1); } inline int32_t& y(Vec3i32& p) { return p(1); }
inline coord_t& z(Vec3crd& p) { return p(2); } inline int32_t& z(Vec3i32& p) { return p(2); }
inline coord_t x(const Vec3crd& p) { return p(0); } inline int32_t x(const Vec3i32& p) { return p(0); }
inline coord_t y(const Vec3crd& p) { return p(1); } inline int32_t y(const Vec3i32& p) { return p(1); }
inline coord_t z(const Vec3crd& p) { return p(2); } inline int32_t z(const Vec3i32& p) { return p(2); }
using Indices = std::vector<Vec3crd>; using Indices = std::vector<Vec3i32>;
/// Intermediate struct for a 3D mesh /// Intermediate struct for a 3D mesh
struct Contour3D { struct Contour3D {
@ -44,14 +44,14 @@ struct Contour3D {
Indices indices; Indices indices;
void merge(const Contour3D& ctr) { void merge(const Contour3D& ctr) {
auto s3 = coord_t(points.size()); size_t s3 = size_t(points.size());
auto s = indices.size(); size_t s = indices.size();
points.insert(points.end(), ctr.points.begin(), ctr.points.end()); points.insert(points.end(), ctr.points.begin(), ctr.points.end());
indices.insert(indices.end(), ctr.indices.begin(), ctr.indices.end()); indices.insert(indices.end(), ctr.indices.begin(), ctr.indices.end());
for(size_t n = s; n < indices.size(); n++) { for(size_t n = s; n < indices.size(); n++) {
auto& idx = indices[n]; x(idx) += s3; y(idx) += s3; z(idx) += s3; Vec3i32& idx = indices[n]; x(idx) += s3; y(idx) += s3; z(idx) += s3;
} }
} }
@ -71,7 +71,7 @@ struct Contour3D {
} }
for(auto& f : indices) { for(auto& f : indices) {
stream << "f " << (f + Vec3i(1, 1, 1)).transpose() << "\n"; stream << "f " << (f + Vec3i32(1, 1, 1)).transpose() << "\n";
} }
} }
}; };

View File

@ -102,8 +102,8 @@ Contour3D sphere(double rho, Portion portion = make_portion(0.0, 2.0*PI),
// prohibit close to zero radius // prohibit close to zero radius
if(rho <= 1e-6 && rho >= -1e-6) return ret; if(rho <= 1e-6 && rho >= -1e-6) return ret;
auto& vertices = ret.points; Pointf3s& vertices = ret.points;
auto& facets = ret.indices; Indices& facets = ret.indices;
// Algorithm: // Algorithm:
// Add points one-by-one to the sphere grid and form facets using relative // Add points one-by-one to the sphere grid and form facets using relative
@ -128,7 +128,7 @@ Contour3D sphere(double rho, Portion portion = make_portion(0.0, 2.0*PI),
if(sbegin == 0) if(sbegin == 0)
vertices.emplace_back(Vec3d(0.0, 0.0, -rho + increment*sbegin*2.0*rho)); vertices.emplace_back(Vec3d(0.0, 0.0, -rho + increment*sbegin*2.0*rho));
auto id = coord_t(vertices.size()); int32_t id = int32_t(vertices.size());
for (size_t i = 0; i < ring.size(); i++) { for (size_t i = 0; i < ring.size(); i++) {
// Fixed scaling // Fixed scaling
const double z = -rho + increment*rho*2.0 * (sbegin + 1.0); const double z = -rho + increment*rho*2.0 * (sbegin + 1.0);
@ -138,8 +138,8 @@ Contour3D sphere(double rho, Portion portion = make_portion(0.0, 2.0*PI),
vertices.emplace_back(Vec3d(b(0), b(1), z)); vertices.emplace_back(Vec3d(b(0), b(1), z));
if(sbegin == 0) if(sbegin == 0)
facets.emplace_back((i == 0) ? Vec3crd(coord_t(ring.size()), 0, 1) : facets.emplace_back((i == 0) ? Vec3i32(int32_t(ring.size()), 0, 1) :
Vec3crd(id - 1, 0, id)); Vec3i32(id - 1, 0, id));
++ id; ++ id;
} }
@ -152,15 +152,15 @@ Contour3D sphere(double rho, Portion portion = make_portion(0.0, 2.0*PI),
for (size_t i = 0; i < ring.size(); i++) { for (size_t i = 0; i < ring.size(); i++) {
Vec2d b = Eigen::Rotation2Dd(ring[i]) * Eigen::Vector2d(0, r); Vec2d b = Eigen::Rotation2Dd(ring[i]) * Eigen::Vector2d(0, r);
vertices.emplace_back(Vec3d(b(0), b(1), z)); vertices.emplace_back(Vec3d(b(0), b(1), z));
auto id_ringsize = coord_t(id - int(ring.size())); auto id_ringsize = int32_t(id - int(ring.size()));
if (i == 0) { if (i == 0) {
// wrap around // wrap around
facets.emplace_back(Vec3crd(id - 1, id, facets.emplace_back(Vec3i32(id - 1, id,
id + coord_t(ring.size() - 1))); id + int32_t(ring.size() - 1)));
facets.emplace_back(Vec3crd(id - 1, id_ringsize, id)); facets.emplace_back(Vec3i32(id - 1, id_ringsize, id));
} else { } else {
facets.emplace_back(Vec3crd(id_ringsize - 1, id_ringsize, id)); facets.emplace_back(Vec3i32(id_ringsize - 1, id_ringsize, id));
facets.emplace_back(Vec3crd(id - 1, id_ringsize - 1, id)); facets.emplace_back(Vec3i32(id - 1, id_ringsize - 1, id));
} }
id++; id++;
} }
@ -171,13 +171,13 @@ Contour3D sphere(double rho, Portion portion = make_portion(0.0, 2.0*PI),
if(send >= size_t(2*PI / angle)) { if(send >= size_t(2*PI / angle)) {
vertices.emplace_back(Vec3d(0.0, 0.0, -rho + increment*send*2.0*rho)); vertices.emplace_back(Vec3d(0.0, 0.0, -rho + increment*send*2.0*rho));
for (size_t i = 0; i < ring.size(); i++) { for (size_t i = 0; i < ring.size(); i++) {
auto id_ringsize = coord_t(id - int(ring.size())); auto id_ringsize = int32_t(id - int(ring.size()));
if (i == 0) { if (i == 0) {
// third vertex is on the other side of the ring. // third vertex is on the other side of the ring.
facets.emplace_back(Vec3crd(id - 1, id_ringsize, id)); facets.emplace_back(Vec3i32(id - 1, id_ringsize, id));
} else { } else {
auto ci = coord_t(id_ringsize + coord_t(i)); auto ci = int32_t(id_ringsize + int32_t(i));
facets.emplace_back(Vec3crd(ci - 1, ci, id)); facets.emplace_back(Vec3i32(ci - 1, ci, id));
} }
} }
} }
@ -195,9 +195,9 @@ Contour3D cylinder(double r, double h, size_t ssteps, const Vec3d sp = {0,0,0})
{ {
Contour3D ret; Contour3D ret;
auto steps = int(ssteps); int32_t steps = int32_t(ssteps);
auto& points = ret.points; Pointf3s& points = ret.points;
auto& indices = ret.indices; Indices& indices = ret.indices;
points.reserve(2*ssteps); points.reserve(2*ssteps);
double a = 2*PI/steps; double a = 2*PI/steps;
@ -222,7 +222,7 @@ Contour3D cylinder(double r, double h, size_t ssteps, const Vec3d sp = {0,0,0})
// Now create long triangles connecting upper and lower circles // Now create long triangles connecting upper and lower circles
indices.reserve(2*ssteps); indices.reserve(2*ssteps);
auto offs = steps; int32_t offs = steps;
for(int i = 0; i < steps - 1; ++i) { for(int i = 0; i < steps - 1; ++i) {
indices.emplace_back(i, i + offs, offs + i + 1); indices.emplace_back(i, i + offs, offs + i + 1);
indices.emplace_back(i, offs + i + 1, i + 1); indices.emplace_back(i, offs + i + 1, i + 1);
@ -237,16 +237,16 @@ Contour3D cylinder(double r, double h, size_t ssteps, const Vec3d sp = {0,0,0})
// a watertight body. So we create a triangle fan for the upper and lower // a watertight body. So we create a triangle fan for the upper and lower
// ending of the cylinder to close the geometry. // ending of the cylinder to close the geometry.
points.emplace_back(jp); size_t ci = points.size() - 1; points.emplace_back(jp); size_t ci = points.size() - 1;
for(int i = 0; i < steps - 1; ++i) for(int32_t i = 0; i < steps - 1; ++i)
indices.emplace_back(i + offs + 1, i + offs, ci); indices.emplace_back(int32_t(i + offs + 1), int32_t(i + offs), int32_t(ci));
indices.emplace_back(offs, steps + offs - 1, ci); indices.emplace_back(offs, int32_t(steps + offs - 1), int32_t(ci));
points.emplace_back(endp); ci = points.size() - 1; points.emplace_back(endp); ci = points.size() - 1;
for(int i = 0; i < steps - 1; ++i) for(int32_t i = 0; i < steps - 1; ++i)
indices.emplace_back(ci, i, i + 1); indices.emplace_back(int32_t(ci), i, i + 1);
indices.emplace_back(steps - 1, 0, ci); indices.emplace_back(int32_t(steps - 1), int32_t(0), int32_t(ci));
return ret; return ret;
} }
@ -306,10 +306,10 @@ struct Head {
// The calculated phi is an offset to the half circles needed to smooth // The calculated phi is an offset to the half circles needed to smooth
// the transition from the circle to the robe geometry // the transition from the circle to the robe geometry
auto&& s1 = sphere(r_big_mm, make_portion(0, PI/2 + phi), detail); Contour3D&& s1 = sphere(r_big_mm, make_portion(0, PI/2 + phi), detail);
auto&& s2 = sphere(r_small_mm, make_portion(PI/2 + phi, PI), detail); Contour3D&& s2 = sphere(r_small_mm, make_portion(PI/2 + phi, PI), detail);
for(auto& p : s2.points) z(p) += h; for(Vec3d & p : s2.points) z(p) += h;
mesh.merge(s1); mesh.merge(s1);
mesh.merge(s2); mesh.merge(s2);
@ -318,17 +318,17 @@ struct Head {
idx1 < s1.points.size() - 1; idx1 < s1.points.size() - 1;
idx1++, idx2++) idx1++, idx2++)
{ {
coord_t i1s1 = coord_t(idx1), i1s2 = coord_t(idx2); int32_t i1s1 = int32_t(idx1), i1s2 = int32_t(idx2);
coord_t i2s1 = i1s1 + 1, i2s2 = i1s2 + 1; int32_t i2s1 = i1s1 + 1, i2s2 = i1s2 + 1;
mesh.indices.emplace_back(i1s1, i2s1, i2s2); mesh.indices.emplace_back(i1s1, i2s1, i2s2);
mesh.indices.emplace_back(i1s1, i2s2, i1s2); mesh.indices.emplace_back(i1s1, i2s2, i1s2);
} }
auto i1s1 = coord_t(s1.points.size()) - coord_t(steps); int32_t i1s1 = int32_t(s1.points.size()) - int32_t(steps);
auto i2s1 = coord_t(s1.points.size()) - 1; int32_t i2s1 = int32_t(s1.points.size()) - 1;
auto i1s2 = coord_t(s1.points.size()); int32_t i1s2 = int32_t(s1.points.size());
auto i2s2 = coord_t(s1.points.size()) + coord_t(steps) - 1; int32_t i2s2 = int32_t(s1.points.size()) + int32_t(steps) - 1;
mesh.indices.emplace_back(i2s2, i2s1, i1s1); mesh.indices.emplace_back(i2s2, i2s1, i1s1);
mesh.indices.emplace_back(i1s2, i2s2, i1s1); mesh.indices.emplace_back(i1s2, i2s2, i1s1);

View File

@ -7,19 +7,12 @@
#include <memory> #include <memory>
#include <Eigen/Geometry> #include <Eigen/Geometry>
#include <libslic3r/Point.hpp>
#include "SLACommon.hpp" #include "SLACommon.hpp"
namespace Slic3r { namespace Slic3r {
// Needed types from Point.hpp
typedef int32_t coord_t;
typedef Eigen::Matrix<double, 3, 1, Eigen::DontAlign> Vec3d;
typedef Eigen::Matrix<float, 3, 1, Eigen::DontAlign> Vec3f;
typedef Eigen::Matrix<coord_t, 3, 1, Eigen::DontAlign> Vec3crd;
typedef std::vector<Vec3d> Pointf3s;
typedef std::vector<Vec3crd> Points3;
class TriangleMesh; class TriangleMesh;
class Model; class Model;
class ModelInstance; class ModelInstance;

View File

@ -287,11 +287,11 @@ PointSet normals(const PointSet& points,
} }
// vector for the neigboring triangles including the detected one. // vector for the neigboring triangles including the detected one.
std::vector<Vec3i> neigh; std::vector<Vec3i32> neigh;
if(ic >= 0) { // The point is right on a vertex of the triangle if(ic >= 0) { // The point is right on a vertex of the triangle
for(int n = 0; n < mesh.F().rows(); ++n) { for(int n = 0; n < mesh.F().rows(); ++n) {
thr(); thr();
Vec3i ni = mesh.F().row(n); Vec3i32 ni = mesh.F().row(n);
if((ni(X) == ic || ni(Y) == ic || ni(Z) == ic)) if((ni(X) == ic || ni(Y) == ic || ni(Z) == ic))
neigh.emplace_back(ni); neigh.emplace_back(ni);
} }
@ -300,7 +300,7 @@ PointSet normals(const PointSet& points,
// now get all the neigboring triangles // now get all the neigboring triangles
for(int n = 0; n < mesh.F().rows(); ++n) { for(int n = 0; n < mesh.F().rows(); ++n) {
thr(); thr();
Vec3i ni = mesh.F().row(n); Vec3i32 ni = mesh.F().row(n);
if((ni(X) == ia || ni(Y) == ia || ni(Z) == ia) && if((ni(X) == ia || ni(Y) == ia || ni(Z) == ia) &&
(ni(X) == ib || ni(Y) == ib || ni(Z) == ib)) (ni(X) == ib || ni(Y) == ib || ni(Z) == ib))
neigh.emplace_back(ni); neigh.emplace_back(ni);
@ -309,7 +309,7 @@ PointSet normals(const PointSet& points,
// Calculate the normals for the neighboring triangles // Calculate the normals for the neighboring triangles
std::vector<Vec3d> neighnorms; neighnorms.reserve(neigh.size()); std::vector<Vec3d> neighnorms; neighnorms.reserve(neigh.size());
for(const Vec3i& tri : neigh) { for(const Vec3i32& tri : neigh) {
const Vec3d& pt1 = mesh.V().row(tri(0)); const Vec3d& pt1 = mesh.V().row(tri(0));
const Vec3d& pt2 = mesh.V().row(tri(1)); const Vec3d& pt2 = mesh.V().row(tri(1));
const Vec3d& pt3 = mesh.V().row(tri(2)); const Vec3d& pt3 = mesh.V().row(tri(2));

View File

@ -591,15 +591,15 @@ int generate_layer_height_texture(
void *data, int rows, int cols, bool level_of_detail_2nd_level) void *data, int rows, int cols, bool level_of_detail_2nd_level)
{ {
// https://github.com/aschn/gnuplot-colorbrewer // https://github.com/aschn/gnuplot-colorbrewer
std::vector<Vec3crd> palette_raw; std::vector<Vec3i32> palette_raw;
palette_raw.push_back(Vec3crd(0x01A, 0x098, 0x050)); palette_raw.push_back(Vec3i32(0x01A, 0x098, 0x050));
palette_raw.push_back(Vec3crd(0x066, 0x0BD, 0x063)); palette_raw.push_back(Vec3i32(0x066, 0x0BD, 0x063));
palette_raw.push_back(Vec3crd(0x0A6, 0x0D9, 0x06A)); palette_raw.push_back(Vec3i32(0x0A6, 0x0D9, 0x06A));
palette_raw.push_back(Vec3crd(0x0D9, 0x0F1, 0x0EB)); palette_raw.push_back(Vec3i32(0x0D9, 0x0F1, 0x0EB));
palette_raw.push_back(Vec3crd(0x0FE, 0x0E6, 0x0EB)); palette_raw.push_back(Vec3i32(0x0FE, 0x0E6, 0x0EB));
palette_raw.push_back(Vec3crd(0x0FD, 0x0AE, 0x061)); palette_raw.push_back(Vec3i32(0x0FD, 0x0AE, 0x061));
palette_raw.push_back(Vec3crd(0x0F4, 0x06D, 0x043)); palette_raw.push_back(Vec3i32(0x0F4, 0x06D, 0x043));
palette_raw.push_back(Vec3crd(0x0D7, 0x030, 0x027)); palette_raw.push_back(Vec3i32(0x0D7, 0x030, 0x027));
// Clear the main texture and the 2nd LOD level. // Clear the main texture and the 2nd LOD level.
// memset(data, 0, rows * cols * (level_of_detail_2nd_level ? 5 : 4)); // memset(data, 0, rows * cols * (level_of_detail_2nd_level ? 5 : 4));
@ -630,8 +630,8 @@ int generate_layer_height_texture(
int idx1 = clamp(0, int(palette_raw.size() - 1), int(floor(idxf))); int idx1 = clamp(0, int(palette_raw.size() - 1), int(floor(idxf)));
int idx2 = std::min(int(palette_raw.size() - 1), idx1 + 1); int idx2 = std::min(int(palette_raw.size() - 1), idx1 + 1);
coordf_t t = idxf - coordf_t(idx1); coordf_t t = idxf - coordf_t(idx1);
const Vec3crd &color1 = palette_raw[idx1]; const Vec3i32 &color1 = palette_raw[idx1];
const Vec3crd &color2 = palette_raw[idx2]; const Vec3i32 &color2 = palette_raw[idx2];
coordf_t z = cell_to_z * coordf_t(cell); coordf_t z = cell_to_z * coordf_t(cell);
assert(z >= lo && z <= hi); assert(z >= lo && z <= hi);
// Intensity profile to visualize the layers. // Intensity profile to visualize the layers.
@ -666,8 +666,8 @@ int generate_layer_height_texture(
int idx1 = clamp(0, int(palette_raw.size() - 1), int(floor(idxf))); int idx1 = clamp(0, int(palette_raw.size() - 1), int(floor(idxf)));
int idx2 = std::min(int(palette_raw.size() - 1), idx1 + 1); int idx2 = std::min(int(palette_raw.size() - 1), idx1 + 1);
coordf_t t = idxf - coordf_t(idx1); coordf_t t = idxf - coordf_t(idx1);
const Vec3crd &color1 = palette_raw[idx1]; const Vec3i32 &color1 = palette_raw[idx1];
const Vec3crd &color2 = palette_raw[idx2]; const Vec3i32 &color2 = palette_raw[idx2];
// Color mapping from layer height to RGB. // Color mapping from layer height to RGB.
Vec3d color( Vec3d color(
lerp(coordf_t(color1(0)), coordf_t(color2(0)), t), lerp(coordf_t(color1(0)), coordf_t(color2(0)), t),

View File

@ -42,7 +42,7 @@
namespace Slic3r { namespace Slic3r {
TriangleMesh::TriangleMesh(const Pointf3s &points, const std::vector<Vec3crd>& facets) TriangleMesh::TriangleMesh(const Pointf3s &points, const std::vector<Vec3i32>& facets)
: repaired(false) : repaired(false)
{ {
stl_initialize(&this->stl); stl_initialize(&this->stl);
@ -581,7 +581,7 @@ TriangleMesh TriangleMesh::convex_hull_3d() const
// Let's collect results: // Let's collect results:
Pointf3s dst_vertices; Pointf3s dst_vertices;
std::vector<Vec3crd> facets; std::vector<Vec3i32> facets;
auto facet_list = qhull.facetList().toStdVector(); auto facet_list = qhull.facetList().toStdVector();
for (const orgQhull::QhullFacet& facet : facet_list) for (const orgQhull::QhullFacet& facet : facet_list)
{ // iterate through facets { // iterate through facets
@ -1833,14 +1833,14 @@ TriangleMesh make_cube(double x, double y, double z) {
Vec3d(0, y, 0), Vec3d(x, y, z), Vec3d(0, y, z), Vec3d(0, y, 0), Vec3d(x, y, z), Vec3d(0, y, z),
Vec3d(0, 0, z), Vec3d(x, 0, z) Vec3d(0, 0, z), Vec3d(x, 0, z)
}; };
Vec3crd fv[12] = { Vec3i32 fv[12] = {
Vec3crd(0, 1, 2), Vec3crd(0, 2, 3), Vec3crd(4, 5, 6), Vec3i32(0, 1, 2), Vec3i32(0, 2, 3), Vec3i32(4, 5, 6),
Vec3crd(4, 6, 7), Vec3crd(0, 4, 7), Vec3crd(0, 7, 1), Vec3i32(4, 6, 7), Vec3i32(0, 4, 7), Vec3i32(0, 7, 1),
Vec3crd(1, 7, 6), Vec3crd(1, 6, 2), Vec3crd(2, 6, 5), Vec3i32(1, 7, 6), Vec3i32(1, 6, 2), Vec3i32(2, 6, 5),
Vec3crd(2, 5, 3), Vec3crd(4, 0, 3), Vec3crd(4, 3, 5) Vec3i32(2, 5, 3), Vec3i32(4, 0, 3), Vec3i32(4, 3, 5)
}; };
std::vector<Vec3crd> facets(&fv[0], &fv[0]+12); std::vector<Vec3i32> facets(&fv[0], &fv[0]+12);
Pointf3s vertices(&pv[0], &pv[0]+8); Pointf3s vertices(&pv[0], &pv[0]+8);
TriangleMesh mesh(vertices ,facets); TriangleMesh mesh(vertices ,facets);
@ -1852,7 +1852,7 @@ TriangleMesh make_cube(double x, double y, double z) {
// Default is 360 sides, angle fa is in radians. // Default is 360 sides, angle fa is in radians.
TriangleMesh make_cylinder(double r, double h, double fa) { TriangleMesh make_cylinder(double r, double h, double fa) {
Pointf3s vertices; Pointf3s vertices;
std::vector<Vec3crd> facets; std::vector<Vec3i32> facets;
// 2 special vertices, top and bottom center, rest are relative to this // 2 special vertices, top and bottom center, rest are relative to this
vertices.emplace_back(Vec3d(0.0, 0.0, 0.0)); vertices.emplace_back(Vec3d(0.0, 0.0, 0.0));
@ -1873,16 +1873,16 @@ 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), 0.));
vertices.emplace_back(Vec3d(p(0), p(1), h)); vertices.emplace_back(Vec3d(p(0), p(1), h));
id = vertices.size() - 1; id = vertices.size() - 1;
facets.emplace_back(Vec3crd( 0, id - 1, id - 3)); // top facets.emplace_back(Vec3i32( 0, id - 1, id - 3)); // top
facets.emplace_back(Vec3crd(id, 1, id - 2)); // bottom facets.emplace_back(Vec3i32(id, 1, id - 2)); // bottom
facets.emplace_back(Vec3crd(id, id - 2, id - 3)); // upper-right of side facets.emplace_back(Vec3i32(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(Vec3i32(id, id - 3, id - 1)); // bottom-left of side
} }
// Connect the last set of vertices with the first. // Connect the last set of vertices with the first.
facets.emplace_back(Vec3crd( 2, 0, id - 1)); facets.emplace_back(Vec3i32( 2, 0, id - 1));
facets.emplace_back(Vec3crd( 1, 3, id)); facets.emplace_back(Vec3i32( 1, 3, id));
facets.emplace_back(Vec3crd(id, 3, 2)); facets.emplace_back(Vec3i32(id, 3, 2));
facets.emplace_back(Vec3crd(id, 2, id - 1)); facets.emplace_back(Vec3i32(id, 2, id - 1));
TriangleMesh mesh(vertices, facets); TriangleMesh mesh(vertices, facets);
return mesh; return mesh;
@ -1893,7 +1893,7 @@ TriangleMesh make_cylinder(double r, double h, double fa) {
// Default angle is 1 degree. // Default angle is 1 degree.
TriangleMesh make_sphere(double rho, double fa) { TriangleMesh make_sphere(double rho, double fa) {
Pointf3s vertices; Pointf3s vertices;
std::vector<Vec3crd> facets; std::vector<Vec3i32> facets;
// Algorithm: // Algorithm:
// Add points one-by-one to the sphere grid and form facets using relative coordinates. // Add points one-by-one to the sphere grid and form facets using relative coordinates.
@ -1921,7 +1921,7 @@ TriangleMesh make_sphere(double rho, double fa) {
const double r = sqrt(abs(rho*rho - z*z)); const double r = sqrt(abs(rho*rho - z*z));
Vec2d b = Eigen::Rotation2Dd(ring[i]) * Eigen::Vector2d(0, r); Vec2d b = Eigen::Rotation2Dd(ring[i]) * Eigen::Vector2d(0, r);
vertices.emplace_back(Vec3d(b(0), b(1), z)); vertices.emplace_back(Vec3d(b(0), b(1), z));
facets.emplace_back((i == 0) ? Vec3crd(1, 0, ring.size()) : Vec3crd(id, 0, id - 1)); facets.emplace_back((i == 0) ? Vec3i32(1, 0, ring.size()) : Vec3i32(id, 0, id - 1));
++ id; ++ id;
} }
@ -1935,11 +1935,11 @@ TriangleMesh make_sphere(double rho, double fa) {
vertices.emplace_back(Vec3d(b(0), b(1), z)); vertices.emplace_back(Vec3d(b(0), b(1), z));
if (i == 0) { if (i == 0) {
// wrap around // wrap around
facets.emplace_back(Vec3crd(id + ring.size() - 1 , id, id - 1)); facets.emplace_back(Vec3i32(id + ring.size() - 1 , id, id - 1));
facets.emplace_back(Vec3crd(id, id - ring.size(), id - 1)); facets.emplace_back(Vec3i32(id, id - ring.size(), id - 1));
} else { } else {
facets.emplace_back(Vec3crd(id , id - ring.size(), (id - 1) - ring.size())); facets.emplace_back(Vec3i32(id , id - ring.size(), (id - 1) - ring.size()));
facets.emplace_back(Vec3crd(id, id - 1 - ring.size() , id - 1)); facets.emplace_back(Vec3i32(id, id - 1 - ring.size() , id - 1));
} }
id++; id++;
} }
@ -1952,9 +1952,9 @@ TriangleMesh make_sphere(double rho, double fa) {
for (size_t i = 0; i < ring.size(); i++) { for (size_t i = 0; i < ring.size(); i++) {
if (i == 0) { if (i == 0) {
// third vertex is on the other side of the ring. // third vertex is on the other side of the ring.
facets.emplace_back(Vec3crd(id, id - ring.size(), id - 1)); facets.emplace_back(Vec3i32(id, id - ring.size(), id - 1));
} else { } else {
facets.emplace_back(Vec3crd(id, id - ring.size() + i, id - ring.size() + (i - 1))); facets.emplace_back(Vec3i32(id, id - ring.size() + i, id - ring.size() + (i - 1)));
} }
} }
id++; id++;

View File

@ -22,7 +22,7 @@ class TriangleMesh
{ {
public: public:
TriangleMesh() : repaired(false) { stl_initialize(&this->stl); } TriangleMesh() : repaired(false) { stl_initialize(&this->stl); }
TriangleMesh(const Pointf3s &points, const std::vector<Vec3crd> &facets); TriangleMesh(const Pointf3s &points, const std::vector<Vec3i32> &facets);
TriangleMesh(const TriangleMesh &other) : repaired(false) { stl_initialize(&this->stl); *this = other; } TriangleMesh(const TriangleMesh &other) : repaired(false) { stl_initialize(&this->stl); *this = other; }
TriangleMesh(TriangleMesh &&other) : repaired(false) { stl_initialize(&this->stl); this->swap(other); } TriangleMesh(TriangleMesh &&other) : repaired(false) { stl_initialize(&this->stl); this->swap(other); }
~TriangleMesh() { stl_close(&this->stl); } ~TriangleMesh() { stl_close(&this->stl); }

View File

@ -660,7 +660,7 @@ 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 // 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: // edge has y=0 and centerline of the back edge has y=depth:
Pointf3s points; Pointf3s points;
std::vector<Vec3crd> facets; std::vector<Vec3i32> 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 }, 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 } }; { 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 }, 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 },
@ -669,7 +669,7 @@ int GLVolumeCollection::load_wipe_tower_preview(
for (int i=0;i<16;++i) 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.push_back(Vec3d(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) 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.push_back(Vec3i32(out_facets_idx[i][0], out_facets_idx[i][1], out_facets_idx[i][2]));
TriangleMesh tooth_mesh(points, facets); 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 // 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
@ -1778,7 +1778,7 @@ void GLModel::render_legacy() const
bool GLArrow::on_init(bool useVBOs) bool GLArrow::on_init(bool useVBOs)
{ {
Pointf3s vertices; Pointf3s vertices;
std::vector<Vec3crd> triangles; std::vector<Vec3i32> triangles;
// bottom face // bottom face
vertices.emplace_back(0.5, 0.0, -0.1); vertices.emplace_back(0.5, 0.0, -0.1);
@ -1850,7 +1850,7 @@ GLCurvedArrow::GLCurvedArrow(unsigned int resolution)
bool GLCurvedArrow::on_init(bool useVBOs) bool GLCurvedArrow::on_init(bool useVBOs)
{ {
Pointf3s vertices; Pointf3s vertices;
std::vector<Vec3crd> triangles; std::vector<Vec3i32> triangles;
double ext_radius = 2.5; double ext_radius = 2.5;
double int_radius = 1.5; double int_radius = 1.5;

View File

@ -2576,7 +2576,7 @@ void GLCanvas3D::render()
// we need to set the mouse's scene position here because the depth buffer // we need to set the mouse's scene position here because the depth buffer
// could be invalidated by the following gizmo render methods // could be invalidated by the following gizmo render methods
// this position is used later into on_mouse() to drag the objects // 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_current_gizmo();
_render_selection_sidebar_hints(); _render_selection_sidebar_hints();

View File

@ -366,7 +366,7 @@ bool GLGizmoSlaSupports::gizmo_event(SLAGizmoEventType action, const Vec2d& mous
double z_offset = volume->get_sla_shift_z(); double z_offset = volume->get_sla_shift_z();
// bounding box created from the rectangle corners - will take care of order of the corners // bounding box created from the rectangle corners - will take care of order of the corners
BoundingBox rectangle(Points{Point(m_selection_rectangle_start_corner.cast<int>()), Point(m_selection_rectangle_end_corner.cast<int>())}); BoundingBox rectangle(Points{Point(m_selection_rectangle_start_corner.cast<coord_t>()), Point(m_selection_rectangle_end_corner.cast<coord_t>())});
const Transform3d& instance_matrix_no_translation = volume->get_instance_transformation().get_matrix(true); const Transform3d& instance_matrix_no_translation = volume->get_instance_transformation().get_matrix(true);
// we'll recover current look direction from the modelview matrix (in world coords)... // we'll recover current look direction from the modelview matrix (in world coords)...

View File

@ -1750,7 +1750,7 @@ std::vector<size_t> Plater::priv::load_model_objects(const ModelObjectPtrs &mode
#ifdef AUTOPLACEMENT_ON_LOAD #ifdef AUTOPLACEMENT_ON_LOAD
// FIXME distance should be a config value ///////////////////////////////// // FIXME distance should be a config value /////////////////////////////////
auto min_obj_distance = static_cast<coord_t>(6/SCALING_FACTOR); coord_t min_obj_distance = static_cast<coord_t>(6/SCALING_FACTOR);
const auto *bed_shape_opt = config->opt<ConfigOptionPoints>("bed_shape"); const auto *bed_shape_opt = config->opt<ConfigOptionPoints>("bed_shape");
assert(bed_shape_opt); assert(bed_shape_opt);
auto& bedpoints = bed_shape_opt->values; auto& bedpoints = bed_shape_opt->values;