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

@ -95,7 +95,7 @@ void profile(const TriangleMesh &mesh)
Eigen::MatrixXd occlusion_output1;
{
std::vector<Vec3d> vertices;
std::vector<Vec3i> triangles;
std::vector<Vec3i32> triangles;
for (int i = 0; i < V.rows(); ++ i)
vertices.emplace_back(V.row(i).transpose());
for (int i = 0; i < F.rows(); ++ i)

View file

@ -45,7 +45,7 @@ FaceNeighborIndex its_create_neighbors_index_1(const indexed_triangle_set &its)
// Go through all edges of all facets and mark the facets touching each edge
for (size_t face_id = 0; face_id < its.indices.size(); ++face_id) {
const Vec3i &face = its.indices[face_id];
const Vec3i32 &face = its.indices[face_id];
EdgeID e1 = hash(face(0), face(1)), e2 = hash(face(1), face(2)),
e3 = hash(face(2), face(0));
@ -59,7 +59,7 @@ FaceNeighborIndex its_create_neighbors_index_1(const indexed_triangle_set &its)
// Now collect the neighbors for each facet into the final index
for (size_t face_id = 0; face_id < its.indices.size(); ++face_id) {
const Vec3i &face = its.indices[face_id];
const Vec3i32 &face = its.indices[face_id];
EdgeID e1 = hash(face(0), face(1)), e2 = hash(face(1), face(2)),
e3 = hash(face(2), face(0));
@ -77,9 +77,9 @@ FaceNeighborIndex its_create_neighbors_index_1(const indexed_triangle_set &its)
return index;
}
std::vector<Vec3i> its_create_neighbors_index_2(const indexed_triangle_set &its)
std::vector<Vec3i32> its_create_neighbors_index_2(const indexed_triangle_set &its)
{
std::vector<Vec3i> out(its.indices.size(), Vec3i(-1, -1, -1));
std::vector<Vec3i32> out(its.indices.size(), Vec3i32(-1, -1, -1));
// Create a mapping from triangle edge into face.
struct EdgeToFace {
@ -157,9 +157,9 @@ std::vector<Vec3i> its_create_neighbors_index_2(const indexed_triangle_set &its)
return out;
}
std::vector<Vec3i> its_create_neighbors_index_3(const indexed_triangle_set &its)
std::vector<Vec3i32> its_create_neighbors_index_3(const indexed_triangle_set &its)
{
std::vector<Vec3i> out(its.indices.size(), Vec3i(-1, -1, -1));
std::vector<Vec3i32> out(its.indices.size(), Vec3i32(-1, -1, -1));
// Create a mapping from triangle edge into face.
struct EdgeToFace {
@ -288,7 +288,7 @@ FaceNeighborIndex its_create_neighbors_index_4(const indexed_triangle_set &its)
// Go through all edges of all facets and mark the facets touching each edge
for (size_t face_id = 0; face_id < its.indices.size(); ++face_id) {
const Vec3i &face = its.indices[face_id];
const Vec3i32 &face = its.indices[face_id];
EdgeID e1 = hash(face(0), face(1)), e2 = hash(face(1), face(2)),
e3 = hash(face(2), face(0));
@ -302,7 +302,7 @@ FaceNeighborIndex its_create_neighbors_index_4(const indexed_triangle_set &its)
// Now collect the neighbors for each facet into the final index
for (size_t face_id = 0; face_id < its.indices.size(); ++face_id) {
const Vec3i &face = its.indices[face_id];
const Vec3i32 &face = its.indices[face_id];
EdgeID e1 = hash(face(0), face(1)), e2 = hash(face(1), face(2)),
e3 = hash(face(2), face(0));
@ -443,7 +443,7 @@ std::vector<std::array<size_t, 3>> its_create_neighbors_index_6(const indexed_tr
// Go through all edges of all facets and mark the facets touching each edge
for (size_t face_id = 0; face_id < facenum; ++face_id) {
const Vec3i &face = its.indices[face_id];
const Vec3i32 &face = its.indices[face_id];
edge_map[face_id * 3] = {hash(face(0), face(1)), face_id};
edge_map[face_id * 3 + 1] = {hash(face(1), face(2)), face_id};
@ -503,7 +503,7 @@ std::vector<std::array<size_t, 3>> its_create_neighbors_index_7(const indexed_tr
// Go through all edges of all facets and mark the facets touching each edge
for (size_t face_id = 0; face_id < facenum; ++face_id) {
const Vec3i &face = its.indices[face_id];
const Vec3i32 &face = its.indices[face_id];
edge_map[face_id * 3] = {hash(face(0), face(1)), face_id};
edge_map[face_id * 3 + 1] = {hash(face(1), face(2)), face_id};
@ -568,7 +568,7 @@ FaceNeighborIndex its_create_neighbors_index_8(const indexed_triangle_set &its)
// Go through all edges of all facets and mark the facets touching each edge
for (size_t face_id = 0; face_id < its.indices.size(); ++face_id) {
const Vec3i &face = its.indices[face_id];
const Vec3i32 &face = its.indices[face_id];
EdgeID e1 = hash(face(0), face(1)), e2 = hash(face(1), face(2)),
e3 = hash(face(2), face(0));
@ -582,7 +582,7 @@ FaceNeighborIndex its_create_neighbors_index_8(const indexed_triangle_set &its)
// Now collect the neighbors for each facet into the final index
for (size_t face_id = 0; face_id < its.indices.size(); ++face_id) {
const Vec3i &face = its.indices[face_id];
const Vec3i32 &face = its.indices[face_id];
EdgeID e1 = hash(face(0), face(1)), e2 = hash(face(1), face(2)),
e3 = hash(face(2), face(0));
@ -605,7 +605,7 @@ std::vector<Vec3crd> its_create_neighbors_index_9(const indexed_triangle_set &it
return create_face_neighbors_index(ex_seq, its);
}
std::vector<Vec3i> its_create_neighbors_index_10(const indexed_triangle_set &its)
std::vector<Vec3i32> its_create_neighbors_index_10(const indexed_triangle_set &its)
{
return create_face_neighbors_index(ex_tbb, its);
}

View file

@ -4,8 +4,8 @@
namespace Slic3r {
using FaceNeighborIndex = std::vector<std::array<size_t, 3>>;
FaceNeighborIndex its_create_neighbors_index_1(const indexed_triangle_set &its);
std::vector<Vec3i> its_create_neighbors_index_2(const indexed_triangle_set &its);
std::vector<Vec3i> its_create_neighbors_index_3(const indexed_triangle_set &its);
std::vector<Vec3i32> its_create_neighbors_index_2(const indexed_triangle_set &its);
std::vector<Vec3i32> its_create_neighbors_index_3(const indexed_triangle_set &its);
FaceNeighborIndex its_create_neighbors_index_4(const indexed_triangle_set &its);
//FaceNeighborIndex its_create_neighbors_index_4(const indexed_triangle_set &its);
std::vector<Vec3crd> its_create_neighbors_index_5(const indexed_triangle_set &its);
@ -13,7 +13,7 @@ std::vector<std::array<size_t, 3>> its_create_neighbors_index_6(const indexed_tr
std::vector<std::array<size_t, 3>> its_create_neighbors_index_7(const indexed_triangle_set &its);
FaceNeighborIndex its_create_neighbors_index_8(const indexed_triangle_set &its);
std::vector<Vec3crd> its_create_neighbors_index_9(const indexed_triangle_set &its);
std::vector<Vec3i> its_create_neighbors_index_10(const indexed_triangle_set &its);
std::vector<Vec3i32> its_create_neighbors_index_10(const indexed_triangle_set &its);
std::vector<std::vector<size_t>> create_vertex_faces_index(const indexed_triangle_set &its);
}

View file

@ -364,7 +364,7 @@ void Controller::on_scroll(long v, long d, MouseInput::WheelAxis /*wa*/)
void Controller::on_moved_to(long x, long y)
{
if (m_left_btn) {
call_cameras(&Camera::rotate, (Vec2i{x, y} - m_mouse_pos).cast<float>());
call_cameras(&Camera::rotate, (Vec2i32{x, y} - m_mouse_pos).cast<float>());
call(&Display::repaint, m_displays);
}

View file

@ -358,7 +358,7 @@ private:
class Display : public Scene::Listener
{
protected:
Vec2i m_size;
Vec2i32 m_size;
bool m_initialized = false;
std::shared_ptr<Camera> m_camera;
@ -379,7 +379,7 @@ public:
virtual void swap_buffers() = 0;
virtual void set_active(long width, long height);
virtual void set_screen_size(long width, long height);
Vec2i get_screen_size() const { return m_size; }
Vec2i32 get_screen_size() const { return m_size; }
virtual void repaint();
@ -438,7 +438,7 @@ class Controller : public std::enable_shared_from_this<Controller>,
public Scene::Listener
{
long m_wheel_pos = 0;
Vec2i m_mouse_pos, m_mouse_pos_rprev, m_mouse_pos_lprev;
Vec2i32 m_mouse_pos, m_mouse_pos_rprev, m_mouse_pos_lprev;
bool m_left_btn = false, m_right_btn = false;
std::shared_ptr<Scene> m_scene;

View file

@ -87,10 +87,10 @@ struct HashEdge {
bool load_nearby(const stl_file *stl, const stl_vertex &a, const stl_vertex &b, float tolerance)
{
// Index of a grid cell spaced by tolerance.
typedef Eigen::Matrix<int32_t, 3, 1, Eigen::DontAlign> Vec3i;
Vec3i vertex1 = ((a - stl->stats.min) / tolerance).cast<int32_t>();
Vec3i vertex2 = ((b - stl->stats.min) / tolerance).cast<int32_t>();
static_assert(sizeof(Vec3i) == 12, "size of Vec3i incorrect");
typedef Eigen::Matrix<int32_t, 3, 1, Eigen::DontAlign> Vec3i32;
Vec3i32 vertex1 = ((a - stl->stats.min) / tolerance).cast<int32_t>();
Vec3i32 vertex2 = ((b - stl->stats.min) / tolerance).cast<int32_t>();
static_assert(sizeof(Vec3i32) == 12, "size of Vec3i32 incorrect");
if (vertex1 == vertex2)
// Both vertices hash to the same value

View file

@ -80,7 +80,7 @@ enum PolyFillType { pftEvenOdd, pftNonZero, pftPositive, pftNegative };
// If defined, Clipper will work with 32bit signed int coordinates to reduce memory
// consumption and to speed up exact orientation predicate calculation.
// In that case, coordinates and their differences (vectors of the coordinates) have to fit int32_t.
#define CLIPPERLIB_INT32
// #define CLIPPERLIB_INT32
// Point coordinate type
#ifdef CLIPPERLIB_INT32

View file

@ -122,7 +122,7 @@ const std::vector<Vec3f>& AABBMesh::vertices() const
const std::vector<Vec3i>& AABBMesh::indices() const
const std::vector<Vec3i32>& AABBMesh::indices() const
{
return m_tm->indices;
}
@ -136,7 +136,7 @@ const Vec3f& AABBMesh::vertices(size_t idx) const
const Vec3i& AABBMesh::indices(size_t idx) const
const Vec3i32& AABBMesh::indices(size_t idx) const
{
return m_tm->indices[idx];
}

View file

@ -31,7 +31,7 @@ class AABBMesh {
std::unique_ptr<AABBImpl> m_aabb;
VertexFaceIndex m_vfidx; // vertex-face index
std::vector<Vec3i> m_fnidx; // face-neighbor index
std::vector<Vec3i32> m_fnidx; // face-neighbor index
#ifdef SLIC3R_HOLE_RAYCASTER
// This holds a copy of holes in the mesh. Initialized externally
@ -57,9 +57,9 @@ public:
~AABBMesh();
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 {
@ -133,7 +133,7 @@ public:
const indexed_triangle_set * get_triangle_mesh() const { return m_tm; }
const VertexFaceIndex &vertex_face_index() const { return m_vfidx; }
const std::vector<Vec3i> &face_neighbor_index() const { return m_fnidx; }
const std::vector<Vec3i32> &face_neighbor_index() const { return m_fnidx; }
};

View file

@ -229,7 +229,7 @@ public:
m_bbox(bbox.min - Point(SCALED_EPSILON, SCALED_EPSILON), bbox.max + Point(SCALED_EPSILON, SCALED_EPSILON)) {}
size_t idx() const { return m_idx; }
const BoundingBox& bbox() const { return m_bbox; }
Point centroid() const { return ((m_bbox.min().cast<int64_t>() + m_bbox.max().cast<int64_t>()) / 2).cast<int32_t>(); }
Point centroid() const { return (m_bbox.min() + m_bbox.max() / 2); }
private:
size_t m_idx;
BoundingBox m_bbox;

View file

@ -32,7 +32,7 @@ inline static bool isInsideCorner(const Point &a, const Point &b, const Point &c
//
auto normal = [](const Point &p0, coord_t len) -> Point {
int64_t _len = p0.cast<int64_t>().norm();
int64_t _len = p0.norm();
if (_len < 1)
return {len, 0};
return (p0.cast<int64_t>() * int64_t(len) / _len).cast<coord_t>();

View file

@ -706,7 +706,7 @@ using IsOnSides = std::vector<std::array<bool, 4>>;
/// <param name="t">Triangle</param>
/// <param name="is_on_sides">Flag is vertex index out of plane</param>
/// <returns>True when triangle is out of one of plane</returns>
bool is_all_on_one_side(const Vec3i &t, const IsOnSides& is_on_sides);
bool is_all_on_one_side(const Vec3i32 &t, const IsOnSides& is_on_sides);
} // namespace priv
@ -718,7 +718,7 @@ bool priv::is_out_of(const Vec3d &v, const PointNormal &point_normal)
return signed_distance > 1e-5;
};
bool priv::is_all_on_one_side(const Vec3i &t, const IsOnSides& is_on_sides) {
bool priv::is_all_on_one_side(const Vec3i32 &t, const IsOnSides& is_on_sides) {
for (size_t side = 0; side < 4; side++) {
bool result = true;
for (auto vi : t) {
@ -1891,7 +1891,7 @@ uint32_t priv::get_closest_point_index(const SearchData &sd,
const Polygon &poly = (id.polygon_index == 0) ?
shape.contour :
shape.holes[id.polygon_index - 1];
Vec2i p_ = p.cast<int>();
auto p_ = p.cast<coord_t>();
return p_ == poly[id.point_index];
};
@ -3559,7 +3559,7 @@ SurfaceCut priv::patch2cut(SurfacePatch &patch)
assert(mesh.next(mesh.next(mesh.next(hi))) == hi);
// triangle indicies
Vec3i ti;
Vec3i32 ti;
size_t i = 0;
for (VI vi : { mesh.source(hi),
mesh.target(hi),
@ -3742,7 +3742,7 @@ indexed_triangle_set priv::create_indexed_triangle_set(
HI hi_end = hi;
int ti = 0;
Vec3i t;
Vec3i32 t;
do {
VI vi = mesh.source(hi);
@ -3802,8 +3802,8 @@ void priv::store(const CutAOIs &aois, const CutMesh &mesh, const std::string &di
size_t bi2 = its.vertices.size();
its.vertices.push_back(b + dir);
its.indices.push_back(Vec3i(ai, ai2, bi));
its.indices.push_back(Vec3i(ai2, bi2, bi));
its.indices.push_back(Vec3i32(ai, ai2, bi));
its.indices.push_back(Vec3i32(ai2, bi2, bi));
}
return its;
};
@ -4002,8 +4002,8 @@ indexed_triangle_set priv::create_contour_its(
size_t bi2 = result.vertices.size();
result.vertices.push_back(b + dir);
result.indices.push_back(Vec3i(ai, bi, ai2));
result.indices.push_back(Vec3i(ai2, bi, bi2));
result.indices.push_back(Vec3i32(ai, bi, ai2));
result.indices.push_back(Vec3i32(ai2, bi, bi2));
prev_vi = vi;
}
return result;

View file

@ -1504,7 +1504,7 @@ indexed_triangle_set polygons2model_unique(
const Points &points)
{
// CW order of triangle indices
std::vector<Vec3i> shape_triangles=Triangulation::triangulate(shape2d, points);
std::vector<Vec3i32> shape_triangles=Triangulation::triangulate(shape2d, points);
uint32_t count_point = points.size();
indexed_triangle_set result;
@ -1525,10 +1525,10 @@ indexed_triangle_set polygons2model_unique(
std::make_move_iterator(back_points.end()));
result.indices.reserve(shape_triangles.size() * 2 + points.size() * 2);
// top triangles - change to CCW
for (const Vec3i &t : shape_triangles)
for (const Vec3i32 &t : shape_triangles)
result.indices.emplace_back(t.x(), t.z(), t.y());
// bottom triangles - use CW
for (const Vec3i &t : shape_triangles)
for (const Vec3i32 &t : shape_triangles)
result.indices.emplace_back(t.x() + count_point,
t.y() + count_point,
t.z() + count_point);
@ -1564,7 +1564,7 @@ indexed_triangle_set polygons2model_duplicit(
{
// CW order of triangle indices
std::vector<uint32_t> changes = Triangulation::create_changes(points, duplicits);
std::vector<Vec3i> shape_triangles = Triangulation::triangulate(shape2d, points, changes);
std::vector<Vec3i32> shape_triangles = Triangulation::triangulate(shape2d, points, changes);
uint32_t count_point = *std::max_element(changes.begin(), changes.end()) + 1;
indexed_triangle_set result;
@ -1596,10 +1596,10 @@ indexed_triangle_set polygons2model_duplicit(
result.indices.reserve(shape_triangles.size() * 2 + points.size() * 2);
// top triangles - change to CCW
for (const Vec3i &t : shape_triangles)
for (const Vec3i32 &t : shape_triangles)
result.indices.emplace_back(t.x(), t.z(), t.y());
// bottom triangles - use CW
for (const Vec3i &t : shape_triangles)
for (const Vec3i32 &t : shape_triangles)
result.indices.emplace_back(t.x() + count_point, t.y() + count_point,
t.z() + count_point);

View file

@ -24,6 +24,7 @@
#include "FillLightning.hpp"
#include "FillConcentricInternal.hpp"
#include "FillConcentric.hpp"
#include "libslic3r.h"
namespace Slic3r {
@ -336,7 +337,7 @@ void split_solid_surface(size_t layer_id, const SurfaceFill &fill, ExPolygons &n
squared_distance_limit_reconnection) {
traced_poly.lows.push_back(candidates_begin->a);
} else {
traced_poly.lows.push_back(traced_poly.lows.back() + Point{scaled_spacing / 2, 0});
traced_poly.lows.push_back(traced_poly.lows.back() + Point{scaled_spacing / 2, coord_t(0)});
traced_poly.lows.push_back(candidates_begin->a - Point{scaled_spacing / 2, 0});
traced_poly.lows.push_back(candidates_begin->a);
}

View file

@ -413,7 +413,7 @@ ModelVolumeType type_from_string(const std::string &s)
struct Geometry
{
std::vector<Vec3f> vertices;
std::vector<Vec3i> triangles;
std::vector<Vec3i32> triangles;
std::vector<std::string> custom_supports;
std::vector<std::string> custom_seam;
std::vector<std::string> mmu_segmentation;
@ -2107,7 +2107,7 @@ ModelVolumeType type_from_string(const std::string &s)
{
int min_id = its.indices.front()[0];
int max_id = min_id;
for (const Vec3i& face : its.indices) {
for (const Vec3i32& face : its.indices) {
for (const int tri_id : face) {
if (tri_id < 0 || tri_id >= int(geometry.vertices.size())) {
add_error("Found invalid vertex id");
@ -2120,7 +2120,7 @@ ModelVolumeType type_from_string(const std::string &s)
its.vertices.assign(geometry.vertices.begin() + min_id, geometry.vertices.begin() + max_id + 1);
// rebase indices to the current vertices list
for (Vec3i& face : its.indices)
for (Vec3i32& face : its.indices)
for (int& tri_id : face)
tri_id -= min_id;
}
@ -2786,7 +2786,7 @@ ModelVolumeType type_from_string(const std::string &s)
for (int i = 0; i < int(its.indices.size()); ++ i) {
{
const Vec3i &idx = its.indices[i];
const Vec3i32 &idx = its.indices[i];
char *ptr = buf;
boost::spirit::karma::generate(ptr, boost::spirit::lit(" <") << TRIANGLE_TAG <<
" v1=\"" << boost::spirit::int_ <<

View file

@ -248,7 +248,7 @@ struct AMFParserContext
// Current volume allocated for an amf/object/mesh/volume subtree.
ModelVolume *m_volume { nullptr };
// Faces collected for the current m_volume.
std::vector<Vec3i> m_volume_facets;
std::vector<Vec3i32> m_volume_facets;
// Transformation matrix of a volume mesh from its coordinate system to Object's coordinate system.
Transform3d m_volume_transform;
// Current material allocated for an amf/metadata subtree.
@ -632,7 +632,7 @@ void AMFParserContext::endElement(const char * /* name */)
// Verify validity of face indices, find the vertex span.
int min_id = m_volume_facets.front()[0];
int max_id = min_id;
for (const Vec3i& face : m_volume_facets) {
for (const Vec3i32& face : m_volume_facets) {
for (const int tri_id : face) {
if (tri_id < 0 || tri_id >= int(m_object_vertices.size())) {
this->stop("Found a malformed triangle mesh");
@ -644,8 +644,8 @@ void AMFParserContext::endElement(const char * /* name */)
}
// rebase indices to the current vertices list
for (Vec3i &face : m_volume_facets)
face -= Vec3i(min_id, min_id, min_id);
for (Vec3i32 &face : m_volume_facets)
face -= Vec3i32(min_id, min_id, min_id);
indexed_triangle_set its { std::move(m_volume_facets), { m_object_vertices.begin() + min_id, m_object_vertices.begin() + max_id + 1 } };
its_compactify_vertices(its);

View file

@ -303,7 +303,7 @@ ConfigSubstitutions import_sla_archive(const std::string &zipfname, DynamicPrint
// function return if the archive did not contain any profile.
ConfigSubstitutions import_sla_archive(
const std::string & zipfname,
Vec2i windowsize,
Vec2i32 windowsize,
indexed_triangle_set & out,
DynamicPrintConfig & profile_out,
std::function<bool(int)> progr)

View file

@ -42,14 +42,14 @@ ConfigSubstitutions import_sla_archive(const std::string &zipfname, DynamicPrint
ConfigSubstitutions import_sla_archive(
const std::string & zipfname,
Vec2i windowsize,
Vec2i32 windowsize,
indexed_triangle_set & out,
DynamicPrintConfig & profile,
std::function<bool(int)> progr = [](int) { return true; });
inline ConfigSubstitutions import_sla_archive(
const std::string & zipfname,
Vec2i windowsize,
Vec2i32 windowsize,
indexed_triangle_set & out,
std::function<bool(int)> progr = [](int) { return true; })
{

View file

@ -658,7 +658,7 @@ void PlateData::parse_filament_info(GCodeProcessorResult *result)
struct Geometry
{
std::vector<Vec3f> vertices;
std::vector<Vec3i> triangles;
std::vector<Vec3i32> triangles;
std::vector<std::string> custom_supports;
std::vector<std::string> custom_seam;
std::vector<std::string> mmu_segmentation;
@ -4608,7 +4608,7 @@ void PlateData::parse_filament_info(GCodeProcessorResult *result)
// add_error("found no trianges in the object " + std::to_string(sub_object->id));
// return false;
//}
for (const Vec3i& face : its.indices) {
for (const Vec3i32& face : its.indices) {
for (const int tri_id : face) {
if (tri_id < 0 || tri_id >= int(sub_object->geometry.vertices.size())) {
add_error("invalid vertex id in object " + std::to_string(sub_object->id));
@ -4783,7 +4783,7 @@ void PlateData::parse_filament_info(GCodeProcessorResult *result)
{
int min_id = its.indices.front()[0];
int max_id = min_id;
for (const Vec3i& face : its.indices) {
for (const Vec3i32& face : its.indices) {
for (const int tri_id : face) {
if (tri_id < 0 || tri_id >= int(geometry.vertices.size())) {
add_error("Found invalid vertex id");
@ -4803,7 +4803,7 @@ void PlateData::parse_filament_info(GCodeProcessorResult *result)
}
// rebase indices to the current vertices list
for (Vec3i& face : its.indices)
for (Vec3i32& face : its.indices)
for (int& tri_id : face)
tri_id -= min_id;
}
@ -6850,7 +6850,7 @@ void PlateData::parse_filament_info(GCodeProcessorResult *result)
for (int i = 0; i < int(its.indices.size()); ++ i) {
{
const Vec3i &idx = its.indices[i];
const Vec3i32 &idx = its.indices[i];
char *ptr = buf;
boost::spirit::karma::generate(ptr, boost::spirit::lit(" <") << TRIANGLE_TAG <<
" v1=\"" << boost::spirit::int_ <<

View file

@ -856,7 +856,7 @@ void debug_export_points(const std::vector<PrintObjectSeamData::LayerSeams> &lay
float max_weight = min_weight;
for (const SeamCandidate &point : layers[layer_idx].points) {
Vec3i color = value_to_rgbi(-PI, PI, point.local_ccw_angle);
Vec3i32 color = value_to_rgbi(-PI, PI, point.local_ccw_angle);
std::string fill = "rgb(" + std::to_string(color.x()) + "," + std::to_string(color.y()) + ","
+ std::to_string(color.z()) + ")";
angles_svg.draw(scaled(Vec2f(point.position.head<2>())), fill);
@ -879,19 +879,19 @@ void debug_export_points(const std::vector<PrintObjectSeamData::LayerSeams> &lay
SVG overhangs_svg { overhangs_file_name, bounding_box };
for (const SeamCandidate &point : layers[layer_idx].points) {
Vec3i color = value_to_rgbi(min_vis, max_vis, point.visibility);
Vec3i32 color = value_to_rgbi(min_vis, max_vis, point.visibility);
std::string visibility_fill = "rgb(" + std::to_string(color.x()) + "," + std::to_string(color.y()) + ","
+ std::to_string(color.z()) + ")";
visibility_svg.draw(scaled(Vec2f(point.position.head<2>())), visibility_fill);
Vec3i weight_color = value_to_rgbi(min_weight, max_weight,
Vec3i32 weight_color = value_to_rgbi(min_weight, max_weight,
-compute_angle_penalty(point.local_ccw_angle));
std::string weight_fill = "rgb(" + std::to_string(weight_color.x()) + "," + std::to_string(weight_color.y())
+ ","
+ std::to_string(weight_color.z()) + ")";
weight_svg.draw(scaled(Vec2f(point.position.head<2>())), weight_fill);
Vec3i overhang_color = value_to_rgbi(-0.5, 0.5, std::clamp(point.overhang, -0.5f, 0.5f));
Vec3i32 overhang_color = value_to_rgbi(-0.5, 0.5, std::clamp(point.overhang, -0.5f, 0.5f));
std::string overhang_fill = "rgb(" + std::to_string(overhang_color.x()) + ","
+ std::to_string(overhang_color.y())
+ ","

View file

@ -48,14 +48,24 @@ enum Orientation
// As the points are limited to 30 bits + signum,
// the temporaries u, v, w are limited to 61 bits + signum,
// and d is limited to 63 bits + signum and we are good.
static inline Orientation orient(const Point &a, const Point &b, const Point &c)
{
static_assert(sizeof(coord_t) * 2 == sizeof(int64_t), "orient works with 32 bit coordinates");
int64_t u = int64_t(b.x()) * int64_t(c.y()) - int64_t(b.y()) * int64_t(c.x());
int64_t v = int64_t(a.x()) * int64_t(c.y()) - int64_t(a.y()) * int64_t(c.x());
int64_t w = int64_t(a.x()) * int64_t(b.y()) - int64_t(a.y()) * int64_t(b.x());
int64_t d = u - v + w;
return (d > 0) ? ORIENTATION_CCW : ((d == 0) ? ORIENTATION_COLINEAR : ORIENTATION_CW);
//note: now coord_t is int64_t, so the algorithm is now adjusted to fallback to double is too big.
static inline Orientation orient(const Point &a, const Point &b, const Point &c) {
//static_assert(sizeof(coord_t) * 2 == sizeof(int64_t), "orient works with 32 bit coordinates");
// BOOST_STATIC_ASSERT(sizeof(coord_t) == sizeof(int64_t));
if (a.x() <= 0xffffffff && b.x() <= 0xffffffff && c.x() <= 0xffffffff &&
a.y() <= 0xffffffff && b.y() <= 0xffffffff && c.y() <= 0xffffffff) {
int64_t u = int64_t(b(0)) * int64_t(c(1)) - int64_t(b(1)) * int64_t(c(0));
int64_t v = int64_t(a(0)) * int64_t(c(1)) - int64_t(a(1)) * int64_t(c(0));
int64_t w = int64_t(a(0)) * int64_t(b(1)) - int64_t(a(1)) * int64_t(b(0));
int64_t d = u - v + w;
return (d > 0) ? ORIENTATION_CCW : ((d == 0) ? ORIENTATION_COLINEAR : ORIENTATION_CW);
} else {
double u = double(b(0)) * double(c(1)) - double(b(1)) * double(c(0));
double v = double(a(0)) * double(c(1)) - double(a(1)) * double(c(0));
double w = double(a(0)) * double(b(1)) - double(a(1)) * double(b(0));
double d = u - v + w;
return (d > 0) ? ORIENTATION_CCW : ((d == 0) ? ORIENTATION_COLINEAR : ORIENTATION_CW);
}
}
// Return orientation of the polygon by checking orientation of the left bottom corner of the polygon

View file

@ -594,13 +594,13 @@ bool MedialAxis::validate_edge(const VD::edge_type* edge)
};
// prevent overflows and detect almost-infinite edges
#ifndef CLIPPERLIB_INT32
if (std::abs(edge->vertex0()->x()) > double(CLIPPER_MAX_COORD_UNSCALED) ||
std::abs(edge->vertex0()->y()) > double(CLIPPER_MAX_COORD_UNSCALED) ||
std::abs(edge->vertex1()->x()) > double(CLIPPER_MAX_COORD_UNSCALED) ||
std::abs(edge->vertex1()->y()) > double(CLIPPER_MAX_COORD_UNSCALED))
return false;
#endif // CLIPPERLIB_INT32
// #ifndef CLIPPERLIB_INT32
// if (std::abs(edge->vertex0()->x()) > double(CLIPPER_MAX_COORD_UNSCALED) ||
// std::abs(edge->vertex0()->y()) > double(CLIPPER_MAX_COORD_UNSCALED) ||
// std::abs(edge->vertex1()->x()) > double(CLIPPER_MAX_COORD_UNSCALED) ||
// std::abs(edge->vertex1()->y()) > double(CLIPPER_MAX_COORD_UNSCALED))
// return false;
// #endif // CLIPPERLIB_INT32
// construct the line representing this edge of the Voronoi diagram
const Line line({ edge->vertex0()->x(), edge->vertex0()->y() },

View file

@ -4,6 +4,7 @@
#include <MultiMaterialSegmentation.hpp>
#include "VoronoiUtils.hpp"
#include "libslic3r.h"
namespace Slic3r::Geometry {
@ -123,7 +124,7 @@ VoronoiUtils::discretize_parabola(const Point &source_point, const Segment &sour
Point pxx;
Line(a, b).distance_to_infinite_squared(source_point, &pxx);
const Point ppxx = pxx - source_point;
const coord_t d = ppxx.cast<int64_t>().norm();
const coord_t d = ppxx.norm();
const Vec2d rot = perp(ppxx).cast<double>().normalized();
const double rot_cos_theta = rot.x();
@ -136,8 +137,8 @@ VoronoiUtils::discretize_parabola(const Point &source_point, const Segment &sour
}
const double marking_bound = atan(transitioning_angle * 0.5);
int64_t msx = -marking_bound * int64_t(d); // projected marking_start
int64_t mex = marking_bound * int64_t(d); // projected marking_end
int64_t msx = -marking_bound * d; // projected marking_start
int64_t mex = marking_bound * d; // projected marking_end
const coord_t marking_start_end_h = msx * msx / (2 * d) + d / 2;
Point marking_start = Point(coord_t(msx), marking_start_end_h).rotated(rot_cos_theta, rot_sin_theta) + pxx;
@ -151,7 +152,7 @@ VoronoiUtils::discretize_parabola(const Point &source_point, const Segment &sour
bool add_marking_start = msx * int64_t(dir) > int64_t(sx - px) * int64_t(dir) && msx * int64_t(dir) < int64_t(ex - px) * int64_t(dir);
bool add_marking_end = mex * int64_t(dir) > int64_t(sx - px) * int64_t(dir) && mex * int64_t(dir) < int64_t(ex - px) * int64_t(dir);
const Point apex = Point(0, d / 2).rotated(rot_cos_theta, rot_sin_theta) + pxx;
const Point apex = Point(coord_t(0), coord_t(d / 2)).rotated(rot_cos_theta, rot_sin_theta) + pxx;
bool add_apex = int64_t(sx - px) * int64_t(dir) < 0 && int64_t(ex - px) * int64_t(dir) > 0;
assert(!add_marking_start || !add_marking_end || add_apex);

View file

@ -114,7 +114,7 @@ void MeasuringImpl::update_planes()
const size_t num_of_facets = m_its.indices.size();
m_face_to_plane.resize(num_of_facets, size_t(-1));
const std::vector<Vec3f> face_normals = its_face_normals(m_its);
const std::vector<Vec3i> face_neighbors = its_face_neighbors(m_its);
const std::vector<Vec3i32> face_neighbors = its_face_neighbors(m_its);
std::vector<int> facet_queue(num_of_facets, 0);
int facet_queue_cnt = 0;
const stl_normal* normal_ptr = nullptr;
@ -149,7 +149,7 @@ void MeasuringImpl::update_planes()
int facet_idx = facet_queue[-- facet_queue_cnt];
const stl_normal& this_normal = face_normals[facet_idx];
if (is_same_normal(this_normal, *normal_ptr)) {
// const Vec3i& face = m_its.indices[facet_idx];
// const Vec3i32& face = m_its.indices[facet_idx];
m_face_to_plane[facet_idx] = m_planes.size() - 1;
m_planes.back().facets.emplace_back(facet_idx);

View file

@ -210,7 +210,7 @@ indexed_triangle_set cgal_to_indexed_triangle_set(const _Mesh &cgalmesh)
auto vtc = cgalmesh.vertices_around_face(cgalmesh.halfedge(face));
int i = 0;
Vec3i facet;
Vec3i32 facet;
for (auto v : vtc) {
int iv = v;
if (i > 2 || iv < 0 || iv >= vsize) { i = 0; break; }
@ -550,7 +550,7 @@ TriangleMesh mcut_to_triangle_mesh(const McutMesh &mcutmesh)
int faceVertexOffsetBase = 0;
// for each face in CC
std::vector<Vec3i> faces(ccFaceCount);
std::vector<Vec3i32> faces(ccFaceCount);
for (uint32_t f = 0; f < ccFaceCount; ++f) {
int faceSize = faceSizes.at(f);
@ -730,7 +730,7 @@ bool do_boolean_single(McutMesh &srcMesh, const McutMesh &cutMesh, const std::st
int faceVertexOffsetBase = 0;
// for each face in CC
std::vector<Vec3i> faces(ccFaceCount);
std::vector<Vec3i32> faces(ccFaceCount);
for (uint32_t f = 0; f < ccFaceCount; ++f) {
bool reverseWindingOrder = (fragmentLocation == MC_FRAGMENT_LOCATION_BELOW) && (patchLocation == MC_PATCH_LOCATION_OUTSIDE);
int faceSize = faceSizes.at(f);

View file

@ -14,7 +14,7 @@
namespace Slic3r {
template<class ExPolicy>
std::vector<Vec3i> create_face_neighbors_index(ExPolicy &&ex, const indexed_triangle_set &its);
std::vector<Vec3i32> create_face_neighbors_index(ExPolicy &&ex, const indexed_triangle_set &its);
namespace meshsplit_detail {
@ -26,7 +26,7 @@ template<class Its, class Enable = void> struct ItsWithNeighborsIndex_ {
// Define a default neighbors index for indexed_triangle_set
template<> struct ItsWithNeighborsIndex_<indexed_triangle_set> {
using Index = std::vector<Vec3i>;
using Index = std::vector<Vec3i32>;
static const indexed_triangle_set &get_its(const indexed_triangle_set &its) noexcept { return its; }
static Index get_index(const indexed_triangle_set &its) noexcept
{
@ -161,7 +161,7 @@ void its_split(const Its &m, OutputIt out_it)
// Assign the facets to the new mesh.
for (size_t face_id : facets) {
const auto &face = its.indices[face_id];
Vec3i new_face;
Vec3i32 new_face;
for (size_t v = 0; v < 3; ++v) {
auto vi = face(v);
@ -221,7 +221,7 @@ size_t its_number_of_patches(const Its &m)
}
template<class ExPolicy>
std::vector<Vec3i> create_face_neighbors_index(ExPolicy &&ex, const indexed_triangle_set &its)
std::vector<Vec3i32> create_face_neighbors_index(ExPolicy &&ex, const indexed_triangle_set &its)
{
const std::vector<stl_triangle_vertex_indices> &indices = its.indices;
@ -231,14 +231,14 @@ std::vector<Vec3i> create_face_neighbors_index(ExPolicy &&ex, const indexed_tria
auto vertex_triangles = VertexFaceIndex{its};
static constexpr int no_value = -1;
std::vector<Vec3i> neighbors(indices.size(),
Vec3i(no_value, no_value, no_value));
std::vector<Vec3i32> neighbors(indices.size(),
Vec3i32(no_value, no_value, no_value));
//for (int face_idx = 0; face_idx < indices.size(); face_idx++) {
execution::for_each(ex, size_t(0), indices.size(),
[&neighbors, &indices, &vertex_triangles] (size_t face_idx)
{
Vec3i& neighbor = neighbors[face_idx];
Vec3i32& neighbor = neighbors[face_idx];
const stl_triangle_vertex_indices & triangle_indices = indices[face_idx];
for (int edge_index = 0; edge_index < 3; ++edge_index) {
// check if done
@ -246,7 +246,7 @@ std::vector<Vec3i> create_face_neighbors_index(ExPolicy &&ex, const indexed_tria
if (neighbor_edge != no_value)
// This edge already has a neighbor assigned.
continue;
Vec2i edge_indices = its_triangle_edge(triangle_indices, edge_index);
Vec2i32 edge_indices = its_triangle_edge(triangle_indices, edge_index);
// IMPROVE: use same vector for 2 sides of triangle
for (const size_t other_face : vertex_triangles[edge_indices[0]]) {
if (other_face <= face_idx) continue;

View file

@ -19,7 +19,7 @@ std::vector<Vec3f> NormalUtils::create_triangle_normals(
{
std::vector<Vec3f> normals;
normals.reserve(its.indices.size());
for (const Vec3crd &index : its.indices) {
for (const auto &index : its.indices) {
normals.push_back(create_triangle_normal(index, its.vertices));
}
return normals;
@ -31,7 +31,7 @@ NormalUtils::Normals NormalUtils::create_normals_average_neighbor(
size_t count_vertices = its.vertices.size();
std::vector<Vec3f> normals(count_vertices, Vec3f(.0f, .0f, .0f));
std::vector<unsigned int> count(count_vertices, 0);
for (const Vec3crd &indice : its.indices) {
for (const auto &indice : its.indices) {
Vec3f normal = create_triangle_normal(indice, its.vertices);
for (int i = 0; i < 3; ++i) {
normals[indice[i]] += normal;
@ -48,7 +48,7 @@ NormalUtils::Normals NormalUtils::create_normals_average_neighbor(
// calc triangle angle of vertex defined by index to triangle indices
float NormalUtils::indice_angle(int i,
const Vec3crd & indice,
const Vec3i32 & indice,
const std::vector<stl_vertex> &vertices)
{
int i1 = (i == 0) ? 2 : (i - 1);
@ -74,7 +74,7 @@ NormalUtils::Normals NormalUtils::create_normals_angle_weighted(
size_t count_vertices = its.vertices.size();
std::vector<Vec3f> normals(count_vertices, Vec3f(.0f, .0f, .0f));
std::vector<float> count(count_vertices, 0.f);
for (const Vec3crd &indice : its.indices) {
for (const auto &indice : its.indices) {
Vec3f normal = create_triangle_normal(indice, its.vertices);
Vec3f angles(indice_angle(0, indice, its.vertices),
indice_angle(1, indice, its.vertices), 0.f);
@ -100,7 +100,7 @@ NormalUtils::Normals NormalUtils::create_normals_nelson_weighted(
std::vector<Vec3f> normals(count_vertices, Vec3f(.0f, .0f, .0f));
std::vector<float> count(count_vertices, 0.f);
const std::vector<stl_vertex> &vertices = its.vertices;
for (const Vec3crd &indice : its.indices) {
for (const auto &indice : its.indices) {
Vec3f normal = create_triangle_normal(indice, vertices);
const stl_vertex &v0 = vertices[indice[0]];

View file

@ -61,7 +61,7 @@ public:
/// <param name="vertices">vertices data</param>
/// <returns>Angle [in radian]</returns>
static float indice_angle(int i,
const Vec3crd & indice,
const Vec3i32 & indice,
const std::vector<stl_vertex> &vertices);
};

View file

@ -17,7 +17,7 @@ namespace Slic3r {
inline Vec3f to_vec3f(const openvdb::Vec3s &v) { return Vec3f{v.x(), v.y(), v.z()}; }
inline Vec3d to_vec3d(const openvdb::Vec3s &v) { return to_vec3f(v).cast<double>(); }
inline Vec3i to_vec3i(const openvdb::Vec3I &v) { return Vec3i{int(v[0]), int(v[1]), int(v[2])}; }
inline Vec3i32 to_vec3i(const openvdb::Vec3I &v) { return Vec3i32{int(v[0]), int(v[1]), int(v[2])}; }
// Here voxel_scale defines the scaling of voxels which affects the voxel count.
// 1.0 value means a voxel for every unit cube. 2 means the model is scaled to

View file

@ -76,9 +76,9 @@ void Point::rotate(double angle, const Point &center)
*/
double Point::ccw(const Point &p1, const Point &p2) const
{
static_assert(sizeof(coord_t) == 4, "Point::ccw() requires a 32 bit coord_t");
return cross2((p2 - p1).cast<int64_t>(), (*this - p1).cast<int64_t>());
// return cross2((p2 - p1).cast<double>(), (*this - p1).cast<double>());
// static_assert(sizeof(coord_t) == 4, "Point::ccw() requires a 32 bit coord_t");
// return cross2((p2 - p1).cast<int64_t>(), (*this - p1).cast<int64_t>());
return cross2((p2 - p1).cast<double>(), (*this - p1).cast<double>());
}
double Point::ccw(const Line &line) const

View file

@ -42,13 +42,14 @@ template<int N, class T> using Vec = Mat<N, 1, T>;
// Vector types with a fixed point coordinate base type.
using Vec2crd = Eigen::Matrix<coord_t, 2, 1, Eigen::DontAlign>;
using Vec3crd = Eigen::Matrix<coord_t, 3, 1, Eigen::DontAlign>;
using Vec2i = Eigen::Matrix<int, 2, 1, Eigen::DontAlign>;
using Vec3i = Eigen::Matrix<int, 3, 1, Eigen::DontAlign>;
using Vec4i = Eigen::Matrix<int, 4, 1, Eigen::DontAlign>;
// using Vec2i = Eigen::Matrix<int, 2, 1, Eigen::DontAlign>;
// using Vec3i = Eigen::Matrix<int, 3, 1, Eigen::DontAlign>;
// using Vec4i = Eigen::Matrix<int, 4, 1, Eigen::DontAlign>;
using Vec2i32 = Eigen::Matrix<int32_t, 2, 1, Eigen::DontAlign>;
using Vec2i64 = Eigen::Matrix<int64_t, 2, 1, Eigen::DontAlign>;
using Vec3i32 = Eigen::Matrix<int32_t, 3, 1, Eigen::DontAlign>;
using Vec3i64 = Eigen::Matrix<int64_t, 3, 1, Eigen::DontAlign>;
using Vec4i32 = Eigen::Matrix<int32_t, 4, 1, Eigen::DontAlign>;
// Vector types with a double coordinate base type.
using Vec2f = Eigen::Matrix<float, 2, 1, Eigen::DontAlign>;
@ -185,6 +186,8 @@ public:
Point() : Vec2crd(0, 0) {}
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(int64_t x, int32_t y) : Vec2crd(coord_t(x), coord_t(y)) {}
Point(int32_t x, int64_t y) : Vec2crd(coord_t(x), coord_t(y)) {}
Point(double x, double y) : Vec2crd(coord_t(std::round(x)), coord_t(std::round(y))) {}
Point(const Point &rhs) { *this = rhs; }
explicit Point(const Vec2d& rhs) : Vec2crd(coord_t(std::round(rhs.x())), coord_t(std::round(rhs.y()))) {}
@ -652,10 +655,10 @@ namespace boost { namespace polygon {
namespace cereal {
// template<class Archive> void serialize(Archive& archive, Slic3r::Vec2crd &v) { archive(v.x(), v.y()); }
// template<class Archive> void serialize(Archive& archive, Slic3r::Vec3crd &v) { archive(v.x(), v.y(), v.z()); }
template<class Archive> void serialize(Archive& archive, Slic3r::Vec2i &v) { archive(v.x(), v.y()); }
template<class Archive> void serialize(Archive& archive, Slic3r::Vec3i &v) { archive(v.x(), v.y(), v.z()); }
// template<class Archive> void serialize(Archive& archive, Slic3r::Vec2i64 &v) { archive(v.x(), v.y()); }
// template<class Archive> void serialize(Archive& archive, Slic3r::Vec3i64 &v) { archive(v.x(), v.y(), v.z()); }
template<class Archive> void serialize(Archive& archive, Slic3r::Vec2i32 &v) { archive(v.x(), v.y()); }
template<class Archive> void serialize(Archive& archive, Slic3r::Vec3i32 &v) { archive(v.x(), v.y(), v.z()); }
template<class Archive> void serialize(Archive& archive, Slic3r::Vec2i64 &v) { archive(v.x(), v.y()); }
template<class Archive> void serialize(Archive& archive, Slic3r::Vec3i64 &v) { archive(v.x(), v.y(), v.z()); }
template<class Archive> void serialize(Archive& archive, Slic3r::Vec2f &v) { archive(v.x(), v.y()); }
template<class Archive> void serialize(Archive& archive, Slic3r::Vec3f &v) { archive(v.x(), v.y(), v.z()); }
template<class Archive> void serialize(Archive& archive, Slic3r::Vec2d &v) { archive(v.x(), v.y()); }

View file

@ -692,12 +692,12 @@ StringObjectException Print::sequential_print_clearance_valid(const Print &print
float unsafe_dist = scale_(print_config.extruder_clearance_max_radius.value - print_config.extruder_clearance_radius.value);
struct VecHash
{
size_t operator()(const Vec2i &n1) const
size_t operator()(const Vec2i32 &n1) const
{
return std::hash<coord_t>()(int(n1(0) * 100 + 100)) + std::hash<coord_t>()(int(n1(1) * 100 + 100)) * 101;
}
};
std::unordered_set<Vec2i, VecHash> left_right_pair; // pairs in this vector must strictly obey the left-right order
std::unordered_set<Vec2i32, VecHash> left_right_pair; // pairs in this vector must strictly obey the left-right order
for (size_t i = 0; i < print_instance_with_bounding_box.size();i++) {
auto &inst = print_instance_with_bounding_box[i];
inst.index = i;

View file

@ -523,7 +523,7 @@ void PrintConfigDef::init_common_params()
def->tooltip = L("Maximum printable height which is limited by mechanism of printer");
def->sidetext = L("mm");
def->min = 0;
def->max = 2000;
def->max = 214700;
def->mode = comSimple;
def->set_default_value(new ConfigOptionFloat(100.0));

View file

@ -263,13 +263,13 @@ void Slic3r::its_quadric_edge_collapse(
is_flipped(new_vertex0, ti0, ti1, v_info1, t_infos, e_infos, its)) {
// try other triangle's edge
Vec3d errors = calculate_3errors(t0, its.vertices, v_infos);
Vec3i ord = (errors[0] < errors[1]) ?
Vec3i32 ord = (errors[0] < errors[1]) ?
((errors[0] < errors[2])?
((errors[1] < errors[2]) ? Vec3i(0, 1, 2) : Vec3i(0, 2, 1)) :
Vec3i(2, 0, 1)):
((errors[1] < errors[2]) ? Vec3i32(0, 1, 2) : Vec3i32(0, 2, 1)) :
Vec3i32(2, 0, 1)):
((errors[1] < errors[2])?
((errors[0] < errors[2]) ? Vec3i(1, 0, 2) : Vec3i(1, 2, 0)) :
Vec3i(2, 1, 0));
((errors[0] < errors[2]) ? Vec3i32(1, 0, 2) : Vec3i32(1, 2, 0)) :
Vec3i32(2, 1, 0));
if (t_info0.min_index == ord[0]) {
t_info0.min_index = ord[1];
e.value = errors[t_info0.min_index];
@ -880,7 +880,7 @@ void QuadricEdgeCollapse::store_surround(const char *obj_filename,
triangles.insert(ti);
if (item.second == 0) continue;
const Vec3i &t = its.indices[ti];
const Vec3i32 &t = its.indices[ti];
for (size_t i = 0; i < 3; ++i) {
const auto &v_info = v_infos[t[i]];
for (size_t d = 0; d < v_info.count; ++d) {

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;
}

View file

@ -183,7 +183,7 @@ struct FaceHash {
return ret;
}
static std::string facekey(const Vec3i &face, const std::vector<Vec3f> &vertices)
static std::string facekey(const Vec3i32 &face, const std::vector<Vec3f> &vertices)
{
// Scale to integer to avoid floating points
std::array<Vec<3, int64_t>, 3> pts = {
@ -204,7 +204,7 @@ struct FaceHash {
FaceHash (const indexed_triangle_set &its): facehash(its.indices.size())
{
for (const Vec3i &face : its.indices)
for (const Vec3i32 &face : its.indices)
facehash.insert(facekey(face, its.vertices));
}
@ -231,7 +231,7 @@ static std::vector<bool> create_exclude_mask(
VertexFaceIndex neighbor_index{its};
auto exclude_neighbors = [&neighbor_index, &exclude_mask](const Vec3i &face)
auto exclude_neighbors = [&neighbor_index, &exclude_mask](const Vec3i32 &face)
{
for (int i = 0; i < 3; ++i) {
const auto &neighbors_range = neighbor_index[face(i)];

View file

@ -33,7 +33,7 @@ void its_short_edge_collpase(indexed_triangle_set &mesh, size_t target_triangle_
// if face is removed, mark it here
std::vector<bool> face_removal_flags(mesh.indices.size(), false);
std::vector<Vec3i> triangles_neighbors = its_face_neighbors_par(mesh);
std::vector<Vec3i32> triangles_neighbors = its_face_neighbors_par(mesh);
// now compute vertices dot product - this is used during edge collapse,
// to determine which vertex to remove and which to keep; We try to keep the one with larger angle, because it defines the shape "more".
@ -46,7 +46,7 @@ void its_short_edge_collpase(indexed_triangle_set &mesh, size_t target_triangle_
std::vector<Vec3f> vertex_normals = NormalUtils::create_normals(mesh);
for (size_t face_idx = 0; face_idx < mesh.indices.size(); ++face_idx) {
Vec3i t = mesh.indices[face_idx];
Vec3i32 t = mesh.indices[face_idx];
Vec3f n = face_normals[face_idx];
min_vertex_dot_product[t[0]] = std::min(min_vertex_dot_product[t[0]], n.dot(vertex_normals[t[0]]));
min_vertex_dot_product[t[1]] = std::min(min_vertex_dot_product[t[1]], n.dot(vertex_normals[t[1]]));
@ -60,7 +60,7 @@ void its_short_edge_collpase(indexed_triangle_set &mesh, size_t target_triangle_
return;
}
face_removal_flags[face_idx] = true;
Vec3i neighbors = triangles_neighbors[face_idx];
Vec3i32 neighbors = triangles_neighbors[face_idx];
int n_a = neighbors[0] != other_face_idx ? neighbors[0] : neighbors[1];
int n_b = neighbors[2] != other_face_idx ? neighbors[2] : neighbors[1];
if (n_a > 0)
@ -157,10 +157,10 @@ void its_short_edge_collpase(indexed_triangle_set &mesh, size_t target_triangle_
//Extract the result mesh
std::unordered_map<size_t, size_t> final_vertices_mapping;
std::vector<Vec3f> final_vertices;
std::vector<Vec3i> final_indices;
std::vector<Vec3i32> final_indices;
final_indices.reserve(face_indices.size());
for (size_t idx : face_indices) {
Vec3i final_face;
Vec3i32 final_face;
for (size_t i = 0; i < 3; ++i) {
final_face[i] = get_final_index(mesh.indices[idx][i]);
}

View file

@ -72,7 +72,7 @@ namespace Slic3r {
#define SUPPORT_SURFACES_OFFSET_PARAMETERS ClipperLib::jtSquare, 0.
#ifdef SUPPORT_USE_AGG_RASTERIZER
static std::vector<unsigned char> rasterize_polygons(const Vec2i &grid_size, const double pixel_size, const Point &left_bottom, const Polygons &polygons)
static std::vector<unsigned char> rasterize_polygons(const Vec2i32 &grid_size, const double pixel_size, const Point &left_bottom, const Polygons &polygons)
{
std::vector<unsigned char> data(grid_size.x() * grid_size.y());
agg::rendering_buffer rendering_buffer(data.data(), unsigned(grid_size.x()), unsigned(grid_size.y()), grid_size.x());
@ -106,7 +106,7 @@ static std::vector<unsigned char> rasterize_polygons(const Vec2i &grid_size, con
return data;
}
// Grid has to have the boundary pixels unset.
static Polygons contours_simplified(const Vec2i &grid_size, const double pixel_size, Point left_bottom, const std::vector<unsigned char> &grid, coord_t offset, bool fill_holes)
static Polygons contours_simplified(const Vec2i32 &grid_size, const double pixel_size, Point left_bottom, const std::vector<unsigned char> &grid, coord_t offset, bool fill_holes)
{
assert(std::abs(2 * offset) < pixel_size - 10);
@ -542,13 +542,13 @@ public:
// Add one empty column / row boundaries.
m_bbox.offset(m_pixel_size);
// Grid size fitting the support polygons plus one pixel boundary around the polygons.
Vec2i grid_size_raw(int(ceil((m_bbox.max.x() - m_bbox.min.x()) / m_pixel_size)),
Vec2i32 grid_size_raw(int(ceil((m_bbox.max.x() - m_bbox.min.x()) / m_pixel_size)),
int(ceil((m_bbox.max.y() - m_bbox.min.y()) / m_pixel_size)));
// Overlay macro blocks of (oversampling x oversampling) over the grid.
Vec2i grid_blocks((grid_size_raw.x() + oversampling - 1 - 2) / oversampling,
Vec2i32 grid_blocks((grid_size_raw.x() + oversampling - 1 - 2) / oversampling,
(grid_size_raw.y() + oversampling - 1 - 2) / oversampling);
// and resize the grid to fit the macro blocks + one pixel boundary.
m_grid_size = grid_blocks * oversampling + Vec2i(2, 2);
m_grid_size = grid_blocks * oversampling + Vec2i32(2, 2);
assert(m_grid_size.x() >= grid_size_raw.x());
assert(m_grid_size.y() >= grid_size_raw.y());
m_grid2 = rasterize_polygons(m_grid_size, m_pixel_size, m_bbox.min, *m_support_polygons);
@ -837,7 +837,7 @@ private:
#ifdef SUPPORT_USE_AGG_RASTERIZER
// Dilate the trimming region (unmask the boundary pixels).
static std::vector<unsigned char> dilate_trimming_region(const std::vector<unsigned char> &trimming, const Vec2i &grid_size)
static std::vector<unsigned char> dilate_trimming_region(const std::vector<unsigned char> &trimming, const Vec2i32 &grid_size)
{
std::vector<unsigned char> dilated(trimming.size(), 0);
for (int r = 1; r + 1 < grid_size.y(); ++ r)
@ -858,7 +858,7 @@ private:
}
// Seed fill each of the (oversampling x oversampling) block up to the dilated trimming region.
static void seed_fill_block(std::vector<unsigned char> &grid, Vec2i grid_size, const std::vector<unsigned char> &trimming,const Vec2i &grid_blocks, int oversampling)
static void seed_fill_block(std::vector<unsigned char> &grid, Vec2i32 grid_size, const std::vector<unsigned char> &trimming,const Vec2i32 &grid_blocks, int oversampling)
{
int size = oversampling;
int stride = grid_size.x();
@ -968,7 +968,7 @@ private:
coordf_t m_support_material_closing_radius;
#ifdef SUPPORT_USE_AGG_RASTERIZER
Vec2i m_grid_size;
Vec2i32 m_grid_size;
double m_pixel_size;
BoundingBox m_bbox;
std::vector<unsigned char> m_grid2;

View file

@ -26,6 +26,7 @@
#include "../Polygon.hpp"
#include "../Polyline.hpp"
#include "../MutablePolygon.hpp"
#include "libslic3r.h"
#include <cassert>
#include <chrono>
@ -771,7 +772,7 @@ static std::optional<std::pair<Point, size_t>> polyline_sample_next_point_at_dis
Polygons collision_trimmed_buffer;
auto collision_trimmed = [&collision_trimmed_buffer, &collision, &ret, distance]() -> const Polygons& {
if (collision_trimmed_buffer.empty() && ! collision.empty())
collision_trimmed_buffer = ClipperUtils::clip_clipper_polygons_with_subject_bbox(collision, get_extents(ret).inflated(std::max(0, distance) + SCALED_EPSILON));
collision_trimmed_buffer = ClipperUtils::clip_clipper_polygons_with_subject_bbox(collision, get_extents(ret).inflated(std::max((coord_t)0, distance) + SCALED_EPSILON));
return collision_trimmed_buffer;
};
@ -970,7 +971,7 @@ private:
std::vector<SupportElements> &move_bounds;
// Temps
static constexpr const auto m_base_radius = scaled<int>(0.01);
static constexpr const auto m_base_radius = scaled<coord_t>(0.01);
const Polygon m_base_circle { make_circle(m_base_radius, SUPPORT_TREE_CIRCLE_RESOLUTION) };
// Mutexes, guards

View file

@ -78,7 +78,7 @@ TreeSupportMeshGroupSettings::TreeSupportMeshGroupSettings(const PrintObject &pr
this->support_tree_branch_diameter_angle = std::clamp<double>(config.tree_support_branch_diameter_angle * M_PI / 180., 0., 0.5 * M_PI - EPSILON);
this->support_tree_top_rate = config.tree_support_top_rate.value; // percent
// this->support_tree_tip_diameter = this->support_line_width;
this->support_tree_tip_diameter = std::clamp(scaled<coord_t>(config.tree_support_tip_diameter.value), 0, this->support_tree_branch_diameter);
this->support_tree_tip_diameter = std::clamp(scaled<coord_t>(config.tree_support_tip_diameter.value), (coord_t)0, this->support_tree_branch_diameter);
std::cout << "\n---------------\n"
<< "layer_height: " << layer_height << "\nresolution: " << resolution << "\nmin_feature_size: " << min_feature_size

View file

@ -167,7 +167,7 @@ void export_print_z_polygons_and_extrusions_to_svg(
#endif /* SLIC3R_DEBUG */
#ifdef SUPPORT_USE_AGG_RASTERIZER
static std::vector<unsigned char> rasterize_polygons(const Vec2i &grid_size, const double pixel_size, const Point &left_bottom, const Polygons &polygons)
static std::vector<unsigned char> rasterize_polygons(const Vec2i32 &grid_size, const double pixel_size, const Point &left_bottom, const Polygons &polygons)
{
std::vector<unsigned char> data(grid_size.x() * grid_size.y());
agg::rendering_buffer rendering_buffer(data.data(), unsigned(grid_size.x()), unsigned(grid_size.y()), grid_size.x());
@ -201,7 +201,7 @@ static std::vector<unsigned char> rasterize_polygons(const Vec2i &grid_size, con
return data;
}
// Grid has to have the boundary pixels unset.
static Polygons contours_simplified(const Vec2i &grid_size, const double pixel_size, Point left_bottom, const std::vector<unsigned char> &grid, coord_t offset, bool fill_holes)
static Polygons contours_simplified(const Vec2i32 &grid_size, const double pixel_size, Point left_bottom, const std::vector<unsigned char> &grid, coord_t offset, bool fill_holes)
{
assert(std::abs(2 * offset) < pixel_size - 10);
@ -862,13 +862,13 @@ public:
// Add one empty column / row boundaries.
m_bbox.offset(m_pixel_size);
// Grid size fitting the support polygons plus one pixel boundary around the polygons.
Vec2i grid_size_raw(int(ceil((m_bbox.max.x() - m_bbox.min.x()) / m_pixel_size)),
Vec2i32 grid_size_raw(int(ceil((m_bbox.max.x() - m_bbox.min.x()) / m_pixel_size)),
int(ceil((m_bbox.max.y() - m_bbox.min.y()) / m_pixel_size)));
// Overlay macro blocks of (oversampling x oversampling) over the grid.
Vec2i grid_blocks((grid_size_raw.x() + oversampling - 1 - 2) / oversampling,
Vec2i32 grid_blocks((grid_size_raw.x() + oversampling - 1 - 2) / oversampling,
(grid_size_raw.y() + oversampling - 1 - 2) / oversampling);
// and resize the grid to fit the macro blocks + one pixel boundary.
m_grid_size = grid_blocks * oversampling + Vec2i(2, 2);
m_grid_size = grid_blocks * oversampling + Vec2i32(2, 2);
assert(m_grid_size.x() >= grid_size_raw.x());
assert(m_grid_size.y() >= grid_size_raw.y());
m_grid2 = rasterize_polygons(m_grid_size, m_pixel_size, m_bbox.min, *m_support_polygons);
@ -1150,7 +1150,7 @@ private:
#ifdef SUPPORT_USE_AGG_RASTERIZER
// Dilate the trimming region (unmask the boundary pixels).
static std::vector<unsigned char> dilate_trimming_region(const std::vector<unsigned char> &trimming, const Vec2i &grid_size)
static std::vector<unsigned char> dilate_trimming_region(const std::vector<unsigned char> &trimming, const Vec2i32 &grid_size)
{
std::vector<unsigned char> dilated(trimming.size(), 0);
for (int r = 1; r + 1 < grid_size.y(); ++ r)
@ -1171,7 +1171,7 @@ private:
}
// Seed fill each of the (oversampling x oversampling) block up to the dilated trimming region.
static void seed_fill_block(std::vector<unsigned char> &grid, Vec2i grid_size, const std::vector<unsigned char> &trimming,const Vec2i &grid_blocks, int oversampling)
static void seed_fill_block(std::vector<unsigned char> &grid, Vec2i32 grid_size, const std::vector<unsigned char> &trimming,const Vec2i32 &grid_blocks, int oversampling)
{
int size = oversampling;
int stride = grid_size.x();
@ -1281,7 +1281,7 @@ private:
coordf_t m_support_material_closing_radius;
#ifdef SUPPORT_USE_AGG_RASTERIZER
Vec2i m_grid_size;
Vec2i32 m_grid_size;
double m_pixel_size;
BoundingBox m_bbox;
std::vector<unsigned char> m_grid2;

View file

@ -224,7 +224,7 @@ private:
Vec3f cell_size;
Vec3f origin;
Vec3f size;
Vec3i cell_count;
Vec3i32 cell_count;
std::unordered_set<size_t> taken_cells{};
@ -239,16 +239,16 @@ public:
origin = min;
size = max - min;
cell_count = size.cwiseQuotient(cell_size).cast<int>() + Vec3i::Ones();
cell_count = size.cwiseQuotient(cell_size).cast<int>() + Vec3i32::Ones();
}
Vec3i to_cell_coords(const Vec3f &position) const
Vec3i32 to_cell_coords(const Vec3f &position) const
{
Vec3i cell_coords = (position - this->origin).cwiseQuotient(this->cell_size).cast<int>();
Vec3i32 cell_coords = (position - this->origin).cwiseQuotient(this->cell_size).cast<int>();
return cell_coords;
}
size_t to_cell_index(const Vec3i &cell_coords) const
size_t to_cell_index(const Vec3i32 &cell_coords) const
{
#ifdef DETAILED_DEBUG_LOGS
assert(cell_coords.x() >= 0);
@ -261,7 +261,7 @@ public:
return cell_coords.z() * cell_count.x() * cell_count.y() + cell_coords.y() * cell_count.x() + cell_coords.x();
}
Vec3f get_cell_center(const Vec3i &cell_coords) const
Vec3f get_cell_center(const Vec3i32 &cell_coords) const
{
return origin + cell_coords.cast<float>().cwiseProduct(this->cell_size) + this->cell_size.cwiseQuotient(Vec3f(2.0f, 2.0f, 2.0f));
}

View file

@ -153,12 +153,12 @@ public:
bool is_border(Halfedge_index h) const { return m_face_neighbors[h.m_face][h.m_side] == -1; }
bool is_same_vertex(const Vertex_index& a, const Vertex_index& b) const { return m_its.indices[a.m_face][a.m_vertex_idx] == m_its.indices[b.m_face][b.m_vertex_idx]; }
Vec3i get_face_neighbors(Face_index face_id) const { assert(int(face_id) < int(m_face_neighbors.size())); return m_face_neighbors[face_id]; }
Vec3i32 get_face_neighbors(Face_index face_id) const { assert(int(face_id) < int(m_face_neighbors.size())); return m_face_neighbors[face_id]; }
private:
const std::vector<Vec3i> m_face_neighbors;
const std::vector<Vec3i32> m_face_neighbors;
const indexed_triangle_set& m_its;
};

View file

@ -63,17 +63,17 @@ static void fill_initial_stats(const indexed_triangle_set &its, TriangleMeshStat
out.volume = its_volume(its);
update_bounding_box(its, out);
const std::vector<Vec3i> face_neighbors = its_face_neighbors(its);
const std::vector<Vec3i32> face_neighbors = its_face_neighbors(its);
out.number_of_parts = its_number_of_patches(its, face_neighbors);
out.open_edges = its_num_open_edges(face_neighbors);
}
TriangleMesh::TriangleMesh(const std::vector<Vec3f> &vertices, const std::vector<Vec3i> &faces) : its { faces, vertices }
TriangleMesh::TriangleMesh(const std::vector<Vec3f> &vertices, const std::vector<Vec3i32> &faces) : its { faces, vertices }
{
fill_initial_stats(this->its, m_stats);
}
TriangleMesh::TriangleMesh(std::vector<Vec3f> &&vertices, const std::vector<Vec3i> &&faces) : its { std::move(faces), std::move(vertices) }
TriangleMesh::TriangleMesh(std::vector<Vec3f> &&vertices, const std::vector<Vec3i32> &&faces) : its { std::move(faces), std::move(vertices) }
{
fill_initial_stats(this->its, m_stats);
}
@ -578,9 +578,9 @@ static std::vector<EdgeToFace> create_edge_map(
// Map from a face edge to a unique edge identifier or -1 if no neighbor exists.
// Two neighbor faces share a unique edge identifier even if they are flipped.
template<typename FaceFilter, typename ThrowOnCancelCallback>
static inline std::vector<Vec3i> its_face_edge_ids_impl(const indexed_triangle_set &its, FaceFilter face_filter, ThrowOnCancelCallback throw_on_cancel)
static inline std::vector<Vec3i32> its_face_edge_ids_impl(const indexed_triangle_set &its, FaceFilter face_filter, ThrowOnCancelCallback throw_on_cancel)
{
std::vector<Vec3i> out(its.indices.size(), Vec3i(-1, -1, -1));
std::vector<Vec3i32> out(its.indices.size(), Vec3i32(-1, -1, -1));
std::vector<EdgeToFace> edges_map = create_edge_map(its, face_filter, throw_on_cancel);
@ -628,36 +628,36 @@ static inline std::vector<Vec3i> its_face_edge_ids_impl(const indexed_triangle_s
return out;
}
std::vector<Vec3i> its_face_edge_ids(const indexed_triangle_set &its)
std::vector<Vec3i32> its_face_edge_ids(const indexed_triangle_set &its)
{
return its_face_edge_ids_impl(its, [](const uint32_t){ return true; }, [](){});
}
std::vector<Vec3i> its_face_edge_ids(const indexed_triangle_set &its, std::function<void()> throw_on_cancel_callback)
std::vector<Vec3i32> its_face_edge_ids(const indexed_triangle_set &its, std::function<void()> throw_on_cancel_callback)
{
return its_face_edge_ids_impl(its, [](const uint32_t){ return true; }, throw_on_cancel_callback);
}
std::vector<Vec3i> its_face_edge_ids(const indexed_triangle_set &its, const std::vector<bool> &face_mask)
std::vector<Vec3i32> its_face_edge_ids(const indexed_triangle_set &its, const std::vector<bool> &face_mask)
{
return its_face_edge_ids_impl(its, [&face_mask](const uint32_t idx){ return face_mask[idx]; }, [](){});
}
// Having the face neighbors available, assign unique edge IDs to face edges for chaining of polygons over slices.
std::vector<Vec3i> its_face_edge_ids(const indexed_triangle_set &its, std::vector<Vec3i> &face_neighbors, bool assign_unbound_edges, int *num_edges)
std::vector<Vec3i32> its_face_edge_ids(const indexed_triangle_set &its, std::vector<Vec3i32> &face_neighbors, bool assign_unbound_edges, int *num_edges)
{
// out elements are not initialized!
std::vector<Vec3i> out(face_neighbors.size());
std::vector<Vec3i32> out(face_neighbors.size());
int last_edge_id = 0;
for (int i = 0; i < int(face_neighbors.size()); ++ i) {
const stl_triangle_vertex_indices &triangle = its.indices[i];
const Vec3i &neighbors = face_neighbors[i];
const Vec3i32 &neighbors = face_neighbors[i];
for (int j = 0; j < 3; ++ j) {
int n = neighbors[j];
if (n > i) {
const stl_triangle_vertex_indices &triangle2 = its.indices[n];
int edge_id = last_edge_id ++;
Vec2i edge = its_triangle_edge(triangle, j);
Vec2i32 edge = its_triangle_edge(triangle, j);
// First find an edge with opposite orientation.
std::swap(edge(0), edge(1));
int k = its_triangle_edge_index(triangle2, edge);
@ -804,7 +804,7 @@ bool its_store_triangle(const indexed_triangle_set &its,
size_t triangle_index)
{
if (its.indices.size() <= triangle_index) return false;
Vec3i t = its.indices[triangle_index];
Vec3i32 t = its.indices[triangle_index];
indexed_triangle_set its2;
its2.indices = {{0, 1, 2}};
its2.vertices = {its.vertices[t[0]], its.vertices[t[1]],
@ -822,8 +822,8 @@ bool its_store_triangles(const indexed_triangle_set &its,
std::map<size_t, size_t> vertex_map;
for (auto ti : triangles) {
if (its.indices.size() <= ti) return false;
Vec3i t = its.indices[ti];
Vec3i new_t;
Vec3i32 t = its.indices[ti];
Vec3i32 new_t;
for (size_t i = 0; i < 3; ++i) {
size_t vi = t[i];
auto it = vertex_map.find(vi);
@ -1301,7 +1301,7 @@ indexed_triangle_set its_make_snap(double r, double h, float space_proportion, f
indexed_triangle_set its_convex_hull(const std::vector<Vec3f> &pts)
{
std::vector<Vec3f> dst_vertices;
std::vector<Vec3i> dst_facets;
std::vector<Vec3i32> dst_facets;
if (! pts.empty()) {
// The qhull call:
@ -1337,7 +1337,7 @@ indexed_triangle_set its_convex_hull(const std::vector<Vec3f> &pts)
#endif // NDEBUG
for (const orgQhull::QhullFacet &facet : qhull.facetList()) {
// Collect face vertices first, allocate unique vertices in dst_vertices based on QHull's vertex ID.
Vec3i indices;
Vec3i32 indices;
int cnt = 0;
for (const orgQhull::QhullVertex vertex : facet.vertices()) {
int id = vertex.id();
@ -1397,7 +1397,7 @@ void its_merge(indexed_triangle_set &A, const indexed_triangle_set &B)
A.indices.insert(A.indices.end(), B.indices.begin(), B.indices.end());
for(size_t n = N_f; n < A.indices.size(); n++)
A.indices[n] += Vec3i{N, N, N};
A.indices[n] += Vec3i32{N, N, N};
}
void its_merge(indexed_triangle_set &A, const std::vector<Vec3f> &triangles)
@ -1466,7 +1466,7 @@ size_t its_number_of_patches(const indexed_triangle_set &its)
{
return its_number_of_patches<>(its);
}
size_t its_number_of_patches(const indexed_triangle_set &its, const std::vector<Vec3i> &face_neighbors)
size_t its_number_of_patches(const indexed_triangle_set &its, const std::vector<Vec3i32> &face_neighbors)
{
return its_number_of_patches<>(ItsNeighborsWrapper{ its, face_neighbors });
}
@ -1476,15 +1476,15 @@ bool its_is_splittable(const indexed_triangle_set &its)
{
return its_is_splittable<>(its);
}
bool its_is_splittable(const indexed_triangle_set &its, const std::vector<Vec3i> &face_neighbors)
bool its_is_splittable(const indexed_triangle_set &its, const std::vector<Vec3i32> &face_neighbors)
{
return its_is_splittable<>(ItsNeighborsWrapper{ its, face_neighbors });
}
size_t its_num_open_edges(const std::vector<Vec3i> &face_neighbors)
size_t its_num_open_edges(const std::vector<Vec3i32> &face_neighbors)
{
size_t num_open_edges = 0;
for (Vec3i neighbors : face_neighbors)
for (Vec3i32 neighbors : face_neighbors)
for (int n : neighbors)
if (n < 0)
++ num_open_edges;
@ -1521,12 +1521,12 @@ void VertexFaceIndex::create(const indexed_triangle_set &its)
m_vertex_to_face_start.front() = 0;
}
std::vector<Vec3i> its_face_neighbors(const indexed_triangle_set &its)
std::vector<Vec3i32> its_face_neighbors(const indexed_triangle_set &its)
{
return create_face_neighbors_index(ex_seq, its);
}
std::vector<Vec3i> its_face_neighbors_par(const indexed_triangle_set &its)
std::vector<Vec3i32> its_face_neighbors_par(const indexed_triangle_set &its)
{
return create_face_neighbors_index(ex_tbb, its);
}

View file

@ -99,8 +99,8 @@ class TriangleMesh
{
public:
TriangleMesh() = default;
TriangleMesh(const std::vector<Vec3f> &vertices, const std::vector<Vec3i> &faces);
TriangleMesh(std::vector<Vec3f> &&vertices, const std::vector<Vec3i> &&faces);
TriangleMesh(const std::vector<Vec3f> &vertices, const std::vector<Vec3i32> &faces);
TriangleMesh(std::vector<Vec3f> &&vertices, const std::vector<Vec3i32> &&faces);
explicit TriangleMesh(const indexed_triangle_set &M);
explicit TriangleMesh(indexed_triangle_set &&M, const RepairedMeshErrors& repaired_errors = RepairedMeshErrors());
void clear() { this->its.clear(); this->m_stats.clear(); }
@ -201,15 +201,15 @@ private:
// Map from a face edge to a unique edge identifier or -1 if no neighbor exists.
// Two neighbor faces share a unique edge identifier even if they are flipped.
// Used for chaining slice lines into polygons.
std::vector<Vec3i> its_face_edge_ids(const indexed_triangle_set &its);
std::vector<Vec3i> its_face_edge_ids(const indexed_triangle_set &its, std::function<void()> throw_on_cancel_callback);
std::vector<Vec3i> its_face_edge_ids(const indexed_triangle_set &its, const std::vector<bool> &face_mask);
std::vector<Vec3i32> its_face_edge_ids(const indexed_triangle_set &its);
std::vector<Vec3i32> its_face_edge_ids(const indexed_triangle_set &its, std::function<void()> throw_on_cancel_callback);
std::vector<Vec3i32> its_face_edge_ids(const indexed_triangle_set &its, const std::vector<bool> &face_mask);
// Having the face neighbors available, assign unique edge IDs to face edges for chaining of polygons over slices.
std::vector<Vec3i> its_face_edge_ids(const indexed_triangle_set &its, std::vector<Vec3i> &face_neighbors, bool assign_unbound_edges = false, int *num_edges = nullptr);
std::vector<Vec3i32> its_face_edge_ids(const indexed_triangle_set &its, std::vector<Vec3i32> &face_neighbors, bool assign_unbound_edges = false, int *num_edges = nullptr);
// Create index that gives neighbor faces for each face. Ignores face orientations.
std::vector<Vec3i> its_face_neighbors(const indexed_triangle_set &its);
std::vector<Vec3i> its_face_neighbors_par(const indexed_triangle_set &its);
std::vector<Vec3i32> its_face_neighbors(const indexed_triangle_set &its);
std::vector<Vec3i32> its_face_neighbors_par(const indexed_triangle_set &its);
// After applying a transformation with negative determinant, flip the faces to keep the transformed mesh volume positive.
void its_flip_triangles(indexed_triangle_set &its);
@ -230,18 +230,18 @@ bool its_store_triangle(const indexed_triangle_set &its, const char *obj_filenam
bool its_store_triangles(const indexed_triangle_set &its, const char *obj_filename, const std::vector<size_t>& triangles);
std::vector<indexed_triangle_set> its_split(const indexed_triangle_set &its);
std::vector<indexed_triangle_set> its_split(const indexed_triangle_set &its, std::vector<Vec3i> &face_neighbors);
std::vector<indexed_triangle_set> its_split(const indexed_triangle_set &its, std::vector<Vec3i32> &face_neighbors);
// Number of disconnected patches (faces are connected if they share an edge, shared edge defined with 2 shared vertex indices).
size_t its_number_of_patches(const indexed_triangle_set &its);
size_t its_number_of_patches(const indexed_triangle_set &its, const std::vector<Vec3i> &face_neighbors);
size_t its_number_of_patches(const indexed_triangle_set &its, const std::vector<Vec3i32> &face_neighbors);
// Same as its_number_of_patches(its) > 1, but faster.
bool its_is_splittable(const indexed_triangle_set &its);
bool its_is_splittable(const indexed_triangle_set &its, const std::vector<Vec3i> &face_neighbors);
bool its_is_splittable(const indexed_triangle_set &its, const std::vector<Vec3i32> &face_neighbors);
// Calculate number of unconnected face edges. There should be no unconnected edge in a manifold mesh.
size_t its_num_open_edges(const indexed_triangle_set &its);
size_t its_num_open_edges(const std::vector<Vec3i> &face_neighbors);
size_t its_num_open_edges(const std::vector<Vec3i32> &face_neighbors);
// Shrink the vectors of its.vertices and its.faces to a minimum size by reallocating the two vectors.
void its_shrink_to_fit(indexed_triangle_set &its);
@ -262,14 +262,14 @@ inline int its_triangle_vertex_index(const stl_triangle_vertex_indices &triangle
vertex_idx == triangle_indices[2] ? 2 : -1;
}
inline Vec2i its_triangle_edge(const stl_triangle_vertex_indices &triangle_indices, int edge_idx)
inline Vec2i32 its_triangle_edge(const stl_triangle_vertex_indices &triangle_indices, int edge_idx)
{
int next_edge_idx = (edge_idx == 2) ? 0 : edge_idx + 1;
return { triangle_indices[edge_idx], triangle_indices[next_edge_idx] };
}
// Index of an edge inside triangle.
inline int its_triangle_edge_index(const stl_triangle_vertex_indices &triangle_indices, const Vec2i &triangle_edge)
inline int its_triangle_edge_index(const stl_triangle_vertex_indices &triangle_indices, const Vec2i32 &triangle_edge)
{
return triangle_edge(0) == triangle_indices[0] && triangle_edge(1) == triangle_indices[1] ? 0 :
triangle_edge(0) == triangle_indices[1] && triangle_edge(1) == triangle_indices[2] ? 1 :

View file

@ -163,7 +163,7 @@ static FacetSliceType slice_facet(
// 3 vertices of the triangle, XY scaled. Z scaled or unscaled (same as slice_z).
const stl_vertex *vertices,
const stl_triangle_vertex_indices &indices,
const Vec3i &edge_ids,
const Vec3i32 &edge_ids,
const int idx_vertex_lowest,
const bool horizontal,
IntersectionLine &line_out)
@ -330,7 +330,7 @@ static FacetSliceType slice_facet_for_cut_mesh(
// 3 vertices of the triangle, XY scaled. Z scaled or unscaled (same as slice_z).
const stl_vertex * vertices,
const stl_triangle_vertex_indices &indices,
const Vec3i & edge_ids,
const Vec3i32 & edge_ids,
const int idx_vertex_lowest,
const bool horizontal,
IntersectionLine & line_out)
@ -482,7 +482,7 @@ void slice_facet_at_zs(
const std::vector<Vec3f> &mesh_vertices,
const TransformVertex &transform_vertex_fn,
const stl_triangle_vertex_indices &indices,
const Vec3i &edge_ids,
const Vec3i32 &edge_ids,
// Scaled or unscaled zs. If vertices have their zs scaled or transform_vertex_fn scales them, then zs have to be scaled as well.
const std::vector<float> &zs,
std::vector<IntersectionLines> &lines,
@ -516,7 +516,7 @@ static inline std::vector<IntersectionLines> slice_make_lines(
const std::vector<stl_vertex> &vertices,
const TransformVertex &transform_vertex_fn,
const std::vector<stl_triangle_vertex_indices> &indices,
const std::vector<Vec3i> &face_edge_ids,
const std::vector<Vec3i32> &face_edge_ids,
const std::vector<float> &zs,
const ThrowOnCancel throw_on_cancel_fn)
{
@ -540,14 +540,14 @@ static inline IntersectionLines slice_make_lines(
const std::vector<stl_vertex> &mesh_vertices,
const TransformVertex &transform_vertex_fn,
const std::vector<stl_triangle_vertex_indices> &mesh_faces,
const std::vector<Vec3i> &face_edge_ids,
const std::vector<Vec3i32> &face_edge_ids,
const float plane_z,
FaceFilter face_filter)
{
IntersectionLines lines;
for (int face_idx = 0; face_idx < int(mesh_faces.size()); ++ face_idx)
if (face_filter(face_idx)) {
const Vec3i &indices = mesh_faces[face_idx];
const Vec3i32 &indices = mesh_faces[face_idx];
stl_vertex vertices[3] { transform_vertex_fn(mesh_vertices[indices(0)]), transform_vertex_fn(mesh_vertices[indices(1)]), transform_vertex_fn(mesh_vertices[indices(2)]) };
// find facet extents
const float min_z = fminf(vertices[0].z(), fminf(vertices[1].z(), vertices[2].z()));
@ -593,8 +593,8 @@ void slice_facet_with_slabs(
const std::vector<Vec3f> &mesh_vertices,
const std::vector<stl_triangle_vertex_indices> &mesh_triangles,
const size_t facet_idx,
const Vec3i &facet_neighbors,
const Vec3i &facet_edge_ids,
const Vec3i32 &facet_neighbors,
const Vec3i32 &facet_edge_ids,
// Increase edge_ids at the top plane of the slab edges by num_edges to allow chaining
// from bottom plane of the slab to the top plane of the slab and vice versa.
const int num_edges,
@ -915,8 +915,8 @@ template<typename ThrowOnCancel>
inline std::pair<SlabLines, SlabLines> slice_slabs_make_lines(
const std::vector<stl_vertex> &vertices,
const std::vector<stl_triangle_vertex_indices> &indices,
const std::vector<Vec3i> &face_neighbors,
const std::vector<Vec3i> &face_edge_ids,
const std::vector<Vec3i32> &face_neighbors,
const std::vector<Vec3i32> &face_edge_ids,
// Total number of edges. All face_edge_ids are lower than num_edges.
// num_edges will be used to distinguish between intersections with the top and bottom plane.
const int num_edges,
@ -949,9 +949,9 @@ inline std::pair<SlabLines, SlabLines> slice_slabs_make_lines(
if ((face_idx & 0x0ffff) == 0)
throw_on_cancel_fn();
FaceOrientation fo = face_orientation[face_idx];
Vec3i edge_ids = face_edge_ids[face_idx];
Vec3i32 edge_ids = face_edge_ids[face_idx];
if (top && (fo == FaceOrientation::Up || fo == FaceOrientation::Degenerate)) {
Vec3i neighbors = face_neighbors[face_idx];
Vec3i32 neighbors = face_neighbors[face_idx];
// Reset neighborship of this triangle in case the other triangle is oriented backwards from this one.
for (int i = 0; i < 3; ++ i)
if (neighbors(i) != -1) {
@ -963,7 +963,7 @@ inline std::pair<SlabLines, SlabLines> slice_slabs_make_lines(
}
// BBS: add vertical faces option
if (bottom && (fo == FaceOrientation::Down || fo == FaceOrientation::Degenerate)) {
Vec3i neighbors = face_neighbors[face_idx];
Vec3i32 neighbors = face_neighbors[face_idx];
// Reset neighborship of this triangle in case the other triangle is oriented backwards from this one.
for (int i = 0; i < 3; ++ i)
if (neighbors(i) != -1) {
@ -1882,7 +1882,7 @@ std::vector<Polygons> slice_mesh(
// Instead of edge identifiers, one shall use a sorted pair of edge vertex indices.
// However facets_edges assigns a single edge ID to two triangles only, thus when factoring facets_edges out, one will have
// to make sure that no code relies on it.
std::vector<Vec3i> face_edge_ids = its_face_edge_ids(mesh);
std::vector<Vec3i32> face_edge_ids = its_face_edge_ids(mesh);
if (zs.size() <= 1) {
// It likely is not worthwile to copy the vertices. Apply the transformation in place.
if (is_identity(params.trafo)) {
@ -1977,14 +1977,14 @@ Polygons slice_mesh(
// 2) Mark faces crossing the plane.
for (size_t i = 0; i < mesh.indices.size(); ++ i) {
const Vec3i &face = mesh.indices[i];
const Vec3i32 &face = mesh.indices[i];
int sides[3] = { vertex_side[face(0)], vertex_side[face(1)], vertex_side[face(2)] };
face_mask[i] = sides[0] * sides[1] <= 0 || sides[1] * sides[2] <= 0 || sides[0] * sides[2] <= 0;
}
}
// 3) Calculate face neighbors for just the faces in face_mask.
std::vector<Vec3i> face_edge_ids = its_face_edge_ids(mesh, face_mask);
std::vector<Vec3i32> face_edge_ids = its_face_edge_ids(mesh, face_mask);
// 4) Slice "face_mask" triangles, collect line segments.
// It likely is not worthwile to copy the vertices. Apply the transformation in place.
@ -2141,9 +2141,9 @@ void slice_mesh_slabs(
face_orientation[&tri - mesh.indices.data()] = fo;
}
std::vector<Vec3i> face_neighbors = its_face_neighbors_par(mesh);
std::vector<Vec3i32> face_neighbors = its_face_neighbors_par(mesh);
int num_edges;
std::vector<Vec3i> face_edge_ids = its_face_edge_ids(mesh, face_neighbors, true, &num_edges);
std::vector<Vec3i32> face_edge_ids = its_face_edge_ids(mesh, face_neighbors, true, &num_edges);
std::pair<SlabLines, SlabLines> lines = slice_slabs_make_lines(
vertices_transformed, mesh.indices, face_neighbors, face_edge_ids, num_edges, face_orientation, zs,
out_top != nullptr, out_bottom != nullptr, throw_on_cancel);
@ -2346,7 +2346,7 @@ void cut_mesh(const indexed_triangle_set& mesh, float z, indexed_triangle_set* u
// To triangulate the caps after slicing.
IntersectionLines upper_lines, lower_lines;
std::vector<int> upper_slice_vertices, lower_slice_vertices;
std::vector<Vec3i> facets_edge_ids = its_face_edge_ids(mesh);
std::vector<Vec3i32> facets_edge_ids = its_face_edge_ids(mesh);
std::map<int, Vec3f *> section_vertices_map;
for (int facet_idx = 0; facet_idx < int(mesh.indices.size()); ++ facet_idx) {

View file

@ -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);

View file

@ -208,8 +208,8 @@ public:
}
};
std::pair<std::vector<Vec3i>, std::vector<Vec3i>> precompute_all_neighbors() const;
void precompute_all_neighbors_recursive(int facet_idx, const Vec3i &neighbors, const Vec3i &neighbors_propagated, std::vector<Vec3i> &neighbors_out, std::vector<Vec3i> &neighbors_normal_out) const;
std::pair<std::vector<Vec3i32>, std::vector<Vec3i32>> precompute_all_neighbors() const;
void precompute_all_neighbors_recursive(int facet_idx, const Vec3i32 &neighbors, const Vec3i32 &neighbors_propagated, std::vector<Vec3i32> &neighbors_out, std::vector<Vec3i32> &neighbors_normal_out) const;
// Set a limit to the edge length, below which the edge will not be split by select_patch().
// Called by select_patch() internally. Made public for debugging purposes, see TriangleSelectorGUI::render_debug().
@ -221,7 +221,7 @@ public:
// Returns the facet_idx of the unsplit triangle containing the "hit". Returns -1 if the triangle isn't found.
[[nodiscard]] int select_unsplit_triangle(const Vec3f &hit, int facet_idx) const;
[[nodiscard]] int select_unsplit_triangle(const Vec3f &hit, int facet_idx, const Vec3i &neighbors) const;
[[nodiscard]] int select_unsplit_triangle(const Vec3f &hit, int facet_idx, const Vec3i32 &neighbors) const;
// Select all triangles fully inside the circle, subdivide where needed.
void select_patch(int facet_start, // facet of the original mesh (unsplit) that the hit point belongs to
@ -254,7 +254,7 @@ public:
// Get facets at a given state. Triangulate T-joints.
indexed_triangle_set get_facets_strict(EnforcerBlockerType state) const;
// Get edges around the selected area by seed fill.
std::vector<Vec2i> get_seed_fill_contour() const;
std::vector<Vec2i32> get_seed_fill_contour() const;
// BBS
void get_facets(std::vector<indexed_triangle_set>& facets_per_type) const;
@ -351,14 +351,14 @@ protected:
};
void append_touching_subtriangles(int itriangle, int vertexi, int vertexj, std::vector<int>& touching_subtriangles_out) const;
bool verify_triangle_neighbors(const Triangle& tr, const Vec3i& neighbors) const;
bool verify_triangle_neighbors(const Triangle& tr, const Vec3i32& neighbors) const;
// Lists of vertices and triangles, both original and new
std::vector<Vertex> m_vertices;
std::vector<Triangle> m_triangles;
const TriangleMesh &m_mesh;
const std::vector<Vec3i> m_neighbors;
const std::vector<Vec3i32> m_neighbors;
const std::vector<Vec3f> m_face_normals;
// BBS
@ -381,15 +381,15 @@ protected:
// Private functions:
private:
bool select_triangle(int facet_idx, EnforcerBlockerType type, bool triangle_splitting);
bool select_triangle_recursive(int facet_idx, const Vec3i &neighbors, EnforcerBlockerType type, bool triangle_splitting);
bool select_triangle_recursive(int facet_idx, const Vec3i32 &neighbors, EnforcerBlockerType type, bool triangle_splitting);
void undivide_triangle(int facet_idx);
void split_triangle(int facet_idx, const Vec3i &neighbors);
void split_triangle(int facet_idx, const Vec3i32 &neighbors);
void remove_useless_children(int facet_idx); // No hidden meaning. Triangles are meant.
bool is_facet_clipped(int facet_idx, const ClippingPlane &clp) const;
int push_triangle(int a, int b, int c, int source_triangle, EnforcerBlockerType state = EnforcerBlockerType{0});
void perform_split(int facet_idx, const Vec3i &neighbors, EnforcerBlockerType old_state);
Vec3i child_neighbors(const Triangle &tr, const Vec3i &neighbors, int child_idx) const;
Vec3i child_neighbors_propagated(const Triangle &tr, const Vec3i &neighbors_propagated, int child_idx, const Vec3i &child_neighbors) const;
void perform_split(int facet_idx, const Vec3i32 &neighbors, EnforcerBlockerType old_state);
Vec3i32 child_neighbors(const Triangle &tr, const Vec3i32 &neighbors, int child_idx) const;
Vec3i32 child_neighbors_propagated(const Triangle &tr, const Vec3i32 &neighbors_propagated, int child_idx, const Vec3i32 &child_neighbors) const;
// Return child of itriangle at a CCW oriented side (vertexi, vertexj), either first or 2nd part.
// If itriangle == -1 or if the side sharing (vertexi, vertexj) is not split, return -1.
enum class Partition {
@ -406,21 +406,21 @@ private:
std::pair<int, int> triangle_subtriangles(int itriangle, int vertexi, int vertexj) const;
//void append_touching_subtriangles(int itriangle, int vertexi, int vertexj, std::vector<int> &touching_subtriangles_out) const;
void append_touching_edges(int itriangle, int vertexi, int vertexj, std::vector<Vec2i> &touching_edges_out) const;
void append_touching_edges(int itriangle, int vertexi, int vertexj, std::vector<Vec2i32> &touching_edges_out) const;
#ifndef NDEBUG
//bool verify_triangle_neighbors(const Triangle& tr, const Vec3i& neighbors) const;
//bool verify_triangle_neighbors(const Triangle& tr, const Vec3i32& neighbors) const;
bool verify_triangle_midpoints(const Triangle& tr) const;
#endif // NDEBUG
void get_facets_strict_recursive(
const Triangle &tr,
const Vec3i &neighbors,
const Vec3i32 &neighbors,
EnforcerBlockerType state,
std::vector<stl_triangle_vertex_indices> &out_triangles) const;
void get_facets_split_by_tjoints(const Vec3i &vertices, const Vec3i &neighbors, std::vector<stl_triangle_vertex_indices> &out_triangles) const;
void get_facets_split_by_tjoints(const Vec3i32 &vertices, const Vec3i32 &neighbors, std::vector<stl_triangle_vertex_indices> &out_triangles) const;
void get_seed_fill_contour_recursive(int facet_idx, const Vec3i &neighbors, const Vec3i &neighbors_propagated, std::vector<Vec2i> &edges_out) const;
void get_seed_fill_contour_recursive(int facet_idx, const Vec3i32 &neighbors, const Vec3i32 &neighbors_propagated, std::vector<Vec2i32> &edges_out) const;
int m_free_triangles_head { -1 };
int m_free_vertices_head { -1 };

View file

@ -75,16 +75,16 @@ namespace Slic3r {
// offring->init(imin);
// }
// void emplace_indices(std::vector<Vec3i> &indices)
// void emplace_indices(std::vector<Vec3i32> &indices)
// {
// Vec3i tr{int(onring->pos().first), int(onring->pos().second),
// Vec3i32 tr{int(onring->pos().first), int(onring->pos().second),
// int(offring->pos().first)};
// if (onring->is_lower()) std::swap(tr(0), tr(1));
// indices.emplace_back(tr);
// }
//public:
// void run(std::vector<Vec3i> &indices)
// void run(std::vector<Vec3i32> &indices)
// {
// synchronize_rings();

View file

@ -79,16 +79,16 @@ class Triangulator {
offring->init(imin);
}
void emplace_indices(std::vector<Vec3i> &indices)
void emplace_indices(std::vector<Vec3i32> &indices)
{
Vec3i tr{int(onring->pos().first), int(onring->pos().second),
Vec3i32 tr{int(onring->pos().first), int(onring->pos().second),
int(offring->pos().first)};
if (onring->is_lower()) std::swap(tr(0), tr(1));
indices.emplace_back(tr);
}
public:
void run(std::vector<Vec3i> &indices)
void run(std::vector<Vec3i32> &indices)
{
synchronize_rings();
@ -138,7 +138,7 @@ void triangulate_wall(std::vector<Vec<3, Sc>> &pts,
t.run(ind);
}
//using Wall = std::pair<std::vector<Vec3d>, std::vector<Vec3i>>;
//using Wall = std::pair<std::vector<Vec3d>, std::vector<Vec3i32>>;
//Wall triangulate_wall(
// const Polygon & lower,

View file

@ -165,7 +165,7 @@ Triangulation::Indices Triangulation::triangulate(const Points &points,
};
#ifdef VISUALIZE_TRIANGULATION
std::vector<Vec3i> indices2;
std::vector<Vec3i32> indices2;
indices2.reserve(num_faces);
for (CDT::Face_handle fh : faces)
if (inside(fh)) indices2.emplace_back(fh->vertex(0)->info(), fh->vertex(1)->info(), fh->vertex(2)->info());
@ -196,7 +196,7 @@ Triangulation::Indices Triangulation::triangulate(const Points &points,
}
}
std::vector<Vec3i> indices;
std::vector<Vec3i32> indices;
indices.reserve(num_faces);
for (CDT::Face_handle fh : faces)
if (inside(fh))
@ -257,7 +257,7 @@ Triangulation::Indices Triangulation::triangulate(const ExPolygons &expolygons){
changes2[changes[i]] = i;
// convert indices into expolygons indicies
for (Vec3i &t : indices)
for (Vec3i32 &t : indices)
for (size_t ti = 0; ti < 3; ti++) t[ti] = changes2[t[ti]];
return indices;

View file

@ -21,7 +21,7 @@ public:
// define oriented connection of 2 vertices(defined by its index)
using HalfEdge = std::pair<uint32_t, uint32_t>;
using HalfEdges = std::vector<HalfEdge>;
using Indices = std::vector<Vec3i>;
using Indices = std::vector<Vec3i32>;
/// <summary>
/// Connect points by triangulation to create filled surface by triangles

View file

@ -35,7 +35,7 @@
#include "Technologies.hpp"
#include "Semver.hpp"
#if 1
#if 0
// Saves around 32% RAM after slicing step, 6.7% after G-code export (tested on PrusaSlicer 2.2.0 final).
using coord_t = int32_t;
#else

View file

@ -44,7 +44,7 @@ void BedShape::append_option_line(ConfigOptionsGroupShp optgroup, Parameter para
def.type = coPoints;
def.set_default_value(new ConfigOptionPoints{ Vec2d(200, 200) });
def.min = 0;
def.max = 2147;
def.max = 214700;
def.label = get_option_label(param);
def.tooltip = L("Size in X and Y of the rectangular plate.");
key = "rect_size";
@ -52,8 +52,8 @@ void BedShape::append_option_line(ConfigOptionsGroupShp optgroup, Parameter para
case Parameter::RectOrigin:
def.type = coPoints;
def.set_default_value(new ConfigOptionPoints{ Vec2d(0, 0) });
def.min = -1073.5;
def.max = 1073.5;
def.min = -107350;
def.max = 107350;
def.label = get_option_label(param);
def.tooltip = L("Distance of the 0,0 G-code coordinate from the front left corner of the rectangle.");
key = "rect_origin";

View file

@ -11,7 +11,7 @@ using namespace GUI;
Points CameraUtils::project(const Camera & camera,
const std::vector<Vec3d> &points)
{
Vec4i viewport(camera.get_viewport().data());
Vec4i32 viewport(camera.get_viewport().data());
// Convert our std::vector to Eigen dynamic matrix.
Eigen::Matrix<double, Eigen::Dynamic, 3, Eigen::DontAlign>
@ -100,7 +100,7 @@ void CameraUtils::ray_from_ortho_screen_pos(const Camera &camera, const Vec2d &p
assert(camera.get_type() == Camera::EType::Ortho);
Matrix4d modelview = camera.get_view_matrix().matrix();
Matrix4d projection = camera.get_projection_matrix().matrix();
Vec4i viewport(camera.get_viewport().data());
Vec4i32 viewport(camera.get_viewport().data());
igl::unproject(screen_point(camera,position), modelview, projection, viewport, point);
direction = camera.get_dir_forward();
}
@ -109,7 +109,7 @@ void CameraUtils::ray_from_persp_screen_pos(const Camera &camera, const Vec2d &p
assert(camera.get_type() == Camera::EType::Perspective);
Matrix4d modelview = camera.get_view_matrix().matrix();
Matrix4d projection = camera.get_projection_matrix().matrix();
Vec4i viewport(camera.get_viewport().data());
Vec4i32 viewport(camera.get_viewport().data());
igl::unproject(screen_point(camera, position), modelview, projection, viewport, point);
direction = point - camera.get_position();
}

View file

@ -8721,7 +8721,7 @@ Vec3d GLCanvas3D::_mouse_to_3d(const Point& mouse_pos, float* z)
}
else {
const Camera& camera = wxGetApp().plater()->get_camera();
const Vec4i viewport(camera.get_viewport().data());
const Vec4i32 viewport(camera.get_viewport().data());
Vec3d out;
igl::unproject(Vec3d(mouse_pos.x(), viewport[3] - mouse_pos.y(), *z), camera.get_view_matrix().matrix(), camera.get_projection_matrix().matrix(), viewport, out);
return out;

View file

@ -274,7 +274,7 @@ std::string GLGizmoCut3D::get_tooltip() const
bool GLGizmoCut3D::on_mouse(const wxMouseEvent &mouse_event)
{
Vec2i mouse_coord(mouse_event.GetX(), mouse_event.GetY());
Vec2i32 mouse_coord(mouse_event.GetX(), mouse_event.GetY());
Vec2d mouse_pos = mouse_coord.cast<double>();
if (mouse_event.ShiftDown() && mouse_event.LeftDown())

View file

@ -264,7 +264,7 @@ struct GuiCfg
float max_tooltip_width = 0.f;
// maximal width and height of style image
Vec2i max_style_image_size = Vec2i(0, 0);
Vec2i32 max_style_image_size = Vec2i32(0, 0);
float indent = 0.f;
float input_offset = 0.f;
@ -274,7 +274,7 @@ struct GuiCfg
ImVec2 text_size;
// maximal size of face name image
Vec2i face_name_size = Vec2i(0, 0);
Vec2i32 face_name_size = Vec2i32(0, 0);
float face_name_texture_offset_x = 0.f;
// maximal texture generate jobs running at once
@ -1567,7 +1567,7 @@ void GLGizmoEmboss::init_font_name_texture() {
glsafe(::glBindTexture(target, id));
glsafe(::glTexParameteri(target, GL_TEXTURE_MIN_FILTER, GL_NEAREST));
glsafe(::glTexParameteri(target, GL_TEXTURE_MAG_FILTER, GL_NEAREST));
const Vec2i &size = m_gui_cfg->face_name_size;
const Vec2i32 &size = m_gui_cfg->face_name_size;
GLint w = size.x(), h = m_face_names->count_cached_textures * size.y();
std::vector<unsigned char> data(4*w * h, {0});
const GLenum format = GL_RGBA, type = GL_UNSIGNED_BYTE;
@ -3698,8 +3698,8 @@ GuiCfg create_gui_configuration()
int max_style_image_width = static_cast<int>(std::round(cfg.max_style_name_width/2 - 2 * style.FramePadding.x));
int max_style_image_height = static_cast<int>(std::round(input_height));
cfg.max_style_image_size = Vec2i(max_style_image_width, line_height);
cfg.face_name_size = Vec2i(cfg.input_width, line_height_with_spacing);
cfg.max_style_image_size = Vec2i32(max_style_image_width, line_height);
cfg.face_name_size = Vec2i32(cfg.input_width, line_height_with_spacing);
cfg.face_name_texture_offset_x = cfg.face_name_size.x() + space;
cfg.max_tooltip_width = ImGui::GetFontSize() * 20.0f;

View file

@ -176,7 +176,7 @@ void GLGizmoFlatten::update_planes()
// This part is still performed in mesh coordinate system.
const int num_of_facets = ch.facets_count();
const std::vector<Vec3f> face_normals = its_face_normals(ch.its);
const std::vector<Vec3i> face_neighbors = its_face_neighbors(ch.its);
const std::vector<Vec3i32> face_neighbors = its_face_neighbors(ch.its);
std::vector<int> facet_queue(num_of_facets, 0);
std::vector<bool> facet_visited(num_of_facets, false);
int facet_queue_cnt = 0;
@ -199,7 +199,7 @@ void GLGizmoFlatten::update_planes()
int facet_idx = facet_queue[-- facet_queue_cnt];
const stl_normal& this_normal = face_normals[facet_idx];
if (std::abs(this_normal(0) - (*normal_ptr)(0)) < 0.001 && std::abs(this_normal(1) - (*normal_ptr)(1)) < 0.001 && std::abs(this_normal(2) - (*normal_ptr)(2)) < 0.001) {
const Vec3i face = ch.its.indices[facet_idx];
const Vec3i32 face = ch.its.indices[facet_idx];
for (int j=0; j<3; ++j)
m_planes.back().vertices.emplace_back(ch.its.vertices[face[j]].cast<double>());

View file

@ -87,7 +87,7 @@ bool GLGizmoMeshBoolean::gizmo_event(SLAGizmoEventType action, const Vec2d& mous
bool GLGizmoMeshBoolean::on_mouse(const wxMouseEvent &mouse_event)
{
// wxCoord == int --> wx/types.h
Vec2i mouse_coord(mouse_event.GetX(), mouse_event.GetY());
Vec2i32 mouse_coord(mouse_event.GetX(), mouse_event.GetY());
Vec2d mouse_pos = mouse_coord.cast<double>();
// when control is down we allow scene pan and rotation even when clicking

View file

@ -910,7 +910,7 @@ bool GLGizmoPainterBase::gizmo_event(SLAGizmoEventType action, const Vec2d& mous
bool GLGizmoPainterBase::on_mouse(const wxMouseEvent &mouse_event)
{
// wxCoord == int --> wx/types.h
Vec2i mouse_coord(mouse_event.GetX(), mouse_event.GetY());
Vec2i32 mouse_coord(mouse_event.GetX(), mouse_event.GetY());
Vec2d mouse_pos = mouse_coord.cast<double>();
if (mouse_event.Moving()) {
@ -1365,11 +1365,11 @@ void TriangleSelectorPatch::update_triangles_per_patch()
bool using_wireframe = (m_need_wireframe && wxGetApp().plater()->is_wireframe_enabled() && wxGetApp().plater()->is_show_wireframe()) ? true : false;
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);
@ -1745,14 +1745,14 @@ void TriangleSelectorGUI::update_paint_contour()
m_paint_contour.reset();
GLModel::Geometry init_data;
const std::vector<Vec2i> contour_edges = this->get_seed_fill_contour();
const std::vector<Vec2i32> contour_edges = this->get_seed_fill_contour();
init_data.format = { GLModel::Geometry::EPrimitiveType::Lines, GLModel::Geometry::EVertexLayout::P3 };
init_data.reserve_vertices(2 * contour_edges.size());
init_data.reserve_indices(2 * contour_edges.size());
init_data.color = ColorRGBA::WHITE();
// vertices + indices
unsigned int vertices_count = 0;
for (const Vec2i& edge : contour_edges) {
for (const Vec2i32& edge : contour_edges) {
init_data.add_vertex(m_vertices[edge(0)].v);
init_data.add_vertex(m_vertices[edge(1)].v);
vertices_count += 2;

View file

@ -360,7 +360,7 @@ private:
mutable float m_cursor_z{0};
mutable double m_height_start_z_in_imgui{0};
mutable bool m_is_set_height_start_z_by_imgui{false};
mutable Vec2i m_height_start_pos{0, 0};
mutable Vec2i32 m_height_start_pos{0, 0};
mutable bool m_is_cursor_in_imgui{false};
BoundingBoxf3 bounding_box() const;
void update_contours(int i, const TriangleMesh& vol_mesh, float cursor_z, float max_z, float min_z) const;

View file

@ -447,7 +447,7 @@ bool GLGizmoText::gizmo_event(SLAGizmoEventType action, const Vec2d &mouse_posit
bool GLGizmoText::on_mouse(const wxMouseEvent &mouse_event)
{
// wxCoord == int --> wx/types.h
Vec2i mouse_coord(mouse_event.GetX(), mouse_event.GetY());
Vec2i32 mouse_coord(mouse_event.GetX(), mouse_event.GetY());
Vec2d mouse_pos = mouse_coord.cast<double>();
bool control_down = mouse_event.CmdDown();

View file

@ -571,7 +571,7 @@ bool GLGizmosManager::gizmos_toolbar_on_mouse(const wxMouseEvent &mouse_event) {
static MouseCapture mc;
// wxCoord == int --> wx/types.h
Vec2i mouse_coord(mouse_event.GetX(), mouse_event.GetY());
Vec2i32 mouse_coord(mouse_event.GetX(), mouse_event.GetY());
Vec2d mouse_pos = mouse_coord.cast<double>();
EType gizmo = get_gizmo_from_mouse(mouse_pos);

View file

@ -2217,7 +2217,7 @@ ImVec2 ImGuiWrapper::suggest_location(const ImVec2 &dialog_size,
offseted_center.y() + diff_norm.y() * move_size.y());
// move offset close to center
Points window_polygon = {offset.cast<int>(),
Points window_polygon = {offset.cast<coord_t>(),
Point(offset.x(), offset.y() + dialog_size.y),
Point(offset.x() + dialog_size.x,
offset.y() + dialog_size.y),
@ -2227,12 +2227,12 @@ ImVec2 ImGuiWrapper::suggest_location(const ImVec2 &dialog_size,
double allowed_space = 10; // in px
double allowed_space_sq = allowed_space * allowed_space;
Vec2d move_vec = (center - (offset.cast<int>() + half_dialog_size))
Vec2d move_vec = (center - (offset.cast<coord_t>() + half_dialog_size))
.cast<double>();
Vec2d result_move(0, 0);
do {
move_vec = move_vec / 2.;
Point move_point = (move_vec + result_move).cast<int>();
Point move_point = (move_vec + result_move).cast<coord_t>();
Points moved_polygon = window_polygon; // copy
for (Point &p : moved_polygon) p += move_point;
if (Slic3r::intersection(interest, Polygon(moved_polygon)).empty())

View file

@ -11,7 +11,7 @@
#include <wx/string.h>
#include <wx/fontenc.h>
#include "Job.hpp"
#include "libslic3r/Point.hpp" // Vec2i
#include "libslic3r/Point.hpp" // Vec2i32
namespace Slic3r::GUI {
@ -32,7 +32,7 @@ struct FontImageData
size_t index;
// Height of each text
// And Limit for width
Vec2i size; // in px
Vec2i32 size; // in px
// bigger value create darker image
// divide value 255

View file

@ -14,6 +14,7 @@
#include <libslic3r/BuildVolume.hpp> // create object
#include <libslic3r/SLA/ReprojectPointsOnMesh.hpp>
#include "libslic3r/libslic3r.h"
#include "slic3r/GUI/Plater.hpp"
#include "slic3r/GUI/NotificationManager.hpp"
#include "slic3r/GUI/GLCanvas3D.hpp"
@ -322,9 +323,9 @@ void CreateObjectJob::process(Ctl &ctl)
Points bed_shape_;
bed_shape_.reserve(m_input.bed_shape.size());
for (const Vec2d &p : m_input.bed_shape)
bed_shape_.emplace_back(p.cast<int>());
bed_shape_.emplace_back(p.cast<coord_t>());
Slic3r::Polygon bed(bed_shape_);
if (!bed.contains(bed_coor.cast<int>()))
if (!bed.contains(bed_coor.cast<coord_t>()))
// mouse pose is out of build plate so create object in center of plate
bed_coor = bed.centroid().cast<double>();
@ -836,7 +837,7 @@ std::vector<BoundingBoxes> create_line_bounds(const ExPolygonsWithIds &shapes, s
template<typename Fnc> TriangleMesh create_mesh_per_glyph(DataBase &input, Fnc was_canceled)
{
// method use square of coord stored into int64_t
static_assert(std::is_same<Point::coord_type, int32_t>());
// static_assert(std::is_same<Point::coord_type, int32_t>());
const EmbossShape &shape = input.create_shape();
if (shape.shapes_with_ids.empty())
return {};
@ -853,7 +854,7 @@ template<typename Fnc> TriangleMesh create_mesh_per_glyph(DataBase &input, Fnc w
// half of font em size for direction of letter emboss
// double em_2_mm = prop.size_in_mm / 2.; // TODO: fix it
double em_2_mm = 5.;
int32_t em_2_polygon = static_cast<int32_t>(std::round(scale_(em_2_mm)));
coord_t em_2_polygon = static_cast<coord_t>(std::round(scale_(em_2_mm)));
size_t s_i_offset = 0; // shape index offset(for next lines)
indexed_triangle_set result;
@ -1277,7 +1278,7 @@ indexed_triangle_set cut_surface_to_its(const ExPolygons &shapes, const Transfor
if (is_text_reflected) {
for (SurfaceCut::Contour &c : cut.contours)
std::reverse(c.begin(), c.end());
for (Vec3i &t : cut.indices)
for (Vec3i32 &t : cut.indices)
std::swap(t[0], t[1]);
}

View file

@ -84,7 +84,7 @@ public:
return Sel(std::min(int(Sel::modelOnly), std::max(0, sel)));
}
Vec2i get_marchsq_windowsize() const override
Vec2i32 get_marchsq_windowsize() const override
{
enum { Accurate, Balanced, Fast };

View file

@ -27,7 +27,7 @@ public:
indexed_triangle_set mesh;
DynamicPrintConfig profile;
wxString path;
Vec2i win = {2, 2};
Vec2i32 win = {2, 2};
std::string err;
ConfigSubstitutions config_substitutions;

View file

@ -18,7 +18,7 @@ public:
virtual ~SLAImportJobView() = default;
virtual Sel get_selection() const = 0;
virtual Vec2i get_marchsq_windowsize() const = 0;
virtual Vec2i32 get_marchsq_windowsize() const = 0;
virtual std::string get_path() const = 0;
};

View file

@ -11,6 +11,7 @@
#include "libslic3r/Model.hpp"
#include "libslic3r/CSGMesh/SliceCSGMesh.hpp"
#include "libslic3r/libslic3r.h"
#include "slic3r/GUI/GUI_App.hpp"
#include "slic3r/GUI/Plater.hpp"
#include "slic3r/GUI/Camera.hpp"
@ -355,8 +356,8 @@ void MeshClipper::recalculate_triangles()
// To prevent overflow after scaling, downscale the input if needed:
double extra_scale = 1.;
int32_t limit = int32_t(std::min(std::numeric_limits<coord_t>::max() / (2. * std::max(1., scale_x)), std::numeric_limits<coord_t>::max() / (2. * std::max(1., scale_y))));
int32_t max_coord = 0;
coord_t limit = coord_t(std::min(std::numeric_limits<coord_t>::max() / (2. * std::max(1., scale_x)), std::numeric_limits<coord_t>::max() / (2. * std::max(1., scale_y))));
coord_t max_coord = 0;
for (const Point& pt : exp.contour)
max_coord = std::max(max_coord, std::max(std::abs(pt.x()), std::abs(pt.y())));
if (max_coord + m_contour_width >= limit)

View file

@ -488,7 +488,7 @@ namespace {
Vec2d mouse_position(const wxMouseEvent &mouse_event){
// wxCoord == int --> wx/types.h
Vec2i mouse_coord(mouse_event.GetX(), mouse_event.GetY());
Vec2i32 mouse_coord(mouse_event.GetX(), mouse_event.GetY());
return mouse_coord.cast<double>();
}
@ -542,7 +542,7 @@ bool start_dragging(const Vec2d &mouse_pos,
// zero point of volume in world coordinate system
Vec3d volume_center = to_world.translation();
// screen coordinate of volume center
Vec2i coor = CameraUtils::project(camera, volume_center);
auto coor = CameraUtils::project(camera, volume_center);
Vec2d mouse_offset = coor.cast<double>() - mouse_pos;
Vec2d mouse_offset_without_sla_shift = mouse_offset;
if (double sla_shift = gl_volume.get_sla_shift_z(); !is_approx(sla_shift, 0.)) {

View file

@ -209,10 +209,10 @@ GLModel::Geometry create_geometry(const TextLines &lines, float radius, bool is_
if (is_mirrored) {
// change order of indices
for (Vec3i t : its.indices)
for (Vec3i32 t : its.indices)
geometry.add_triangle(t[0], t[2], t[1]);
} else {
for (Vec3i t : its.indices)
for (Vec3i32 t : its.indices)
geometry.add_triangle(t[0], t[1], t[2]);
}
return geometry;

View file

@ -976,7 +976,7 @@ bool CalibUtils::process_and_store_3mf(Model *model, const DynamicPrintConfig &f
double print_height = full_config.opt_float("printable_height");
double current_width = bedfs[2].x() - bedfs[0].x();
double current_depth = bedfs[2].y() - bedfs[0].y();
Vec3i plate_size;
Vec3i32 plate_size;
plate_size[0] = bedfs[2].x() - bedfs[0].x();
plate_size[1] = bedfs[2].y() - bedfs[0].y();
plate_size[2] = print_height;

View file

@ -351,7 +351,7 @@ void StyleManager::init_trunc_names(float max_width) {
#include "slic3r/GUI/MainFrame.hpp"
#include "slic3r/GUI/Gizmos/GizmoObjectManipulation.hpp"
void StyleManager::init_style_images(const Vec2i &max_size,
void StyleManager::init_style_images(const Vec2i32 &max_size,
const std::string &text)
{
// check already initialized

View file

@ -170,7 +170,7 @@ public:
/// </summary>
/// <param name="max_size">Maximal width and height of one style texture</param>
/// <param name="text">Text to render by style</param>
void init_style_images(const Vec2i& max_size, const std::string &text);
void init_style_images(const Vec2i32& max_size, const std::string &text);
void free_style_images();
// access to all managed font styles
@ -295,7 +295,7 @@ private:
// Keep styles to render
Items styles;
// Maximal width and height in pixels of image
Vec2i max_size;
Vec2i32 max_size;
// Text to render
std::string text;

View file

@ -151,7 +151,7 @@ std::optional<RaycastManager::Hit> RaycastManager::first_hit(const Vec3d& point,
// Calculate normal from transformed triangle
// NOTE: Anisotropic transformation of normal is not perpendiculat to triangle
const Vec3i tri = hit_mesh->indices(hit_face);
const Vec3i32 tri = hit_mesh->indices(hit_face);
std::array<Vec3d,3> pts;
auto tr = hit_tramsformation->linear();
for (int i = 0; i < 3; ++i)

View file

@ -22,7 +22,7 @@ static inline TriangleMesh make_cube() { return make_cube(20., 20, 20); }
SCENARIO( "TriangleMesh: Basic mesh statistics") {
GIVEN( "A 20mm cube, built from constexpr std::array" ) {
std::vector<Vec3f> 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} };
std::vector<Vec3i32> 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);
THEN( "Volume is appropriate for 20mm square cube.") {
@ -155,7 +155,7 @@ SCENARIO( "TriangleMesh: slice behavior.") {
}
GIVEN( "A STL with an irregular shape.") {
const std::vector<Vec3f> 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}};
const std::vector<Vec3i32> 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}};
auto cube = make_cube();
WHEN(" a top tangent plane is sliced") {

View file

@ -199,7 +199,7 @@ bool is_similar(const indexed_triangle_set &from,
collect_distances(vertex);
}
for (const Vec3i &t : to.indices) {
for (const Vec3i32 &t : to.indices) {
Vec3f center(0,0,0);
for (size_t i = 0; i < 3; ++i) {
center += to.vertices[t[i]] / 3;
@ -222,8 +222,8 @@ TEST_CASE("Reduce one edge by Quadric Edge Collapse", "[its]")
Vec3f(1.f, 0.f, 0.f), Vec3f(0.f, 0.f, 1.f),
// vertex to be removed
Vec3f(0.9f, .1f, -.1f)};
its.indices = {Vec3i(1, 0, 3), Vec3i(2, 1, 3), Vec3i(0, 2, 3),
Vec3i(0, 1, 4), Vec3i(1, 2, 4), Vec3i(2, 0, 4)};
its.indices = {Vec3i32(1, 0, 3), Vec3i32(2, 1, 3), Vec3i32(0, 2, 3),
Vec3i32(0, 1, 4), Vec3i32(1, 2, 4), Vec3i32(2, 0, 4)};
// edge to remove is between vertices 2 and 4 on trinagles 4 and 5
indexed_triangle_set its_ = its; // copy

View file

@ -84,13 +84,13 @@ static ExPolygons circle_with_hole(double r, Point center = {0, 0}) {
return {poly};
}
static const Vec2i W4x4 = {4, 4};
static const Vec2i W2x2 = {2, 2};
static const Vec2i32 W4x4 = {4, 4};
static const Vec2i32 W2x2 = {2, 2};
template<class Rst>
static void test_expolys(Rst && rst,
const ExPolygons & ref,
Vec2i window,
Vec2i32 window,
const std::string &name = "test")
{
for (const ExPolygon &expoly : ref) rst.draw(expoly);

View file

@ -50,14 +50,14 @@ TriangleMesh::ReadFromPerl(vertices, facets)
out_vertices.push_back(Slic3r::Vec3f(SvNV(*av_fetch(vertex_av, 0, 0)), SvNV(*av_fetch(vertex_av, 1, 0)), SvNV(*av_fetch(vertex_av, 2, 0))));
}
}
std::vector<Slic3r::Vec3i> out_indices;
std::vector<Slic3r::Vec3i32> out_indices;
{
AV* facets_av = (AV*)SvRV(facets);
int number_of_facets = av_len(facets_av) + 1;
out_indices.reserve(number_of_facets);
for (int i = 0; i < number_of_facets; ++ i) {
AV* facet_av = (AV*)SvRV(*av_fetch(facets_av, i, 0));
out_indices.push_back(Slic3r::Vec3i(SvIV(*av_fetch(facet_av, 0, 0)), SvIV(*av_fetch(facet_av, 1, 0)), SvIV(*av_fetch(facet_av, 2, 0))));
out_indices.push_back(Slic3r::Vec3i32(SvIV(*av_fetch(facet_av, 0, 0)), SvIV(*av_fetch(facet_av, 1, 0)), SvIV(*av_fetch(facet_av, 2, 0))));
}
}
*THIS = TriangleMesh(std::move(out_vertices), std::move(out_indices));