diff options
author | Vojtech Bubnik <bubnikv@gmail.com> | 2020-09-18 11:35:03 +0300 |
---|---|---|
committer | Vojtech Bubnik <bubnikv@gmail.com> | 2020-09-18 11:35:03 +0300 |
commit | 462cc8dae952cc4cf9a3f6d26026d754b4edccfd (patch) | |
tree | 53a98f5de4fec76494eafed9a6bd6fb830a374a1 | |
parent | ce44c9e7080f81e9f69c0d80e06a031be021551c (diff) |
Adaptive infill: A bit more polishing.vb_adaptive_infill
-rw-r--r-- | src/libslic3r/Fill/FillAdaptive.cpp | 35 | ||||
-rw-r--r-- | src/libslic3r/Fill/FillAdaptive.hpp | 4 | ||||
-rw-r--r-- | src/libslic3r/PrintObject.cpp | 17 |
3 files changed, 24 insertions, 32 deletions
diff --git a/src/libslic3r/Fill/FillAdaptive.cpp b/src/libslic3r/Fill/FillAdaptive.cpp index a3222c579..d4ae191f3 100644 --- a/src/libslic3r/Fill/FillAdaptive.cpp +++ b/src/libslic3r/Fill/FillAdaptive.cpp @@ -310,21 +310,21 @@ struct FillContext Vec2d rotate(const Vec2d& v) { return Vec2d(this->cos_a * v.x() - this->sin_a * v.y(), this->sin_a * v.x() + this->cos_a * v.y()); } // Center of the root cube in the Octree coordinate system. - const Vec3d origin_world; - const std::vector<CubeProperties> &cubes_properties; + const Vec3d origin_world; + const std::vector<CubeProperties> &cubes_properties; // Top of the current layer. - const double z_position; + const double z_position; // Order of traversal for this line direction. - const std::array<int, 8> traversal_order; + const std::array<int, 8> traversal_order; // Rotation of the generated line for this line direction. - const double cos_a; - const double sin_a; + const double cos_a; + const double sin_a; // Linearized tree spanning a single Octree wall, used to connect lines spanning // neighboring Octree cells. Unused lines have the Line::a::x set to infinity. - std::vector<Line> temp_lines; + std::vector<Line> temp_lines; // Final output - std::vector<Line> output_lines; + std::vector<Line> output_lines; }; static constexpr double octree_rot[3] = { 5.0 * M_PI / 4.0, Geometry::deg2rad(215.264), M_PI / 6.0 }; @@ -343,11 +343,11 @@ Eigen::Quaterniond transform_to_octree() // Verify that the traversal order of the octree children matches the line direction, // therefore the infill line may get extended with O(1) time & space complexity. static bool verify_traversal_order( - FillContext &context, + FillContext &context, const Cube *cube, - int depth, - const Vec2d &line_from, - const Vec2d &line_to) + int depth, + const Vec2d &line_from, + const Vec2d &line_to) { std::array<Vec3d, 8> c; Eigen::Quaterniond to_world = transform_to_world(); @@ -377,11 +377,11 @@ static bool verify_traversal_order( #endif // NDEBUG static void generate_infill_lines_recursive( - FillContext &context, - const Cube *cube, + FillContext &context, + const Cube *cube, // Address of this wall in the octree, used to address context.temp_lines. - int address, - int depth) + int address, + int depth) { assert(cube != nullptr); @@ -607,7 +607,7 @@ static void transform_center(Cube *current_cube, const Eigen::Matrix3d &rot) transform_center(child, rot); } -OctreePtr build_octree(const indexed_triangle_set &triangle_mesh, const Vec3d &up_vector, coordf_t line_spacing, bool support_overhangs_only) +OctreePtr build_octree(const indexed_triangle_set &triangle_mesh, coordf_t line_spacing, bool support_overhangs_only) { assert(line_spacing > 0); assert(! std::isnan(line_spacing)); @@ -618,6 +618,7 @@ OctreePtr build_octree(const indexed_triangle_set &triangle_mesh, const Vec3d &u auto octree = OctreePtr(new Octree(cube_center, cubes_properties)); if (cubes_properties.size() > 1) { + auto up_vector = support_overhangs_only ? transform_to_octree() * Vec3d(0., 0., 1.) : Vec3d(); for (auto &tri : triangle_mesh.indices) { auto a = triangle_mesh.vertices[tri[0]].cast<double>(); auto b = triangle_mesh.vertices[tri[1]].cast<double>(); diff --git a/src/libslic3r/Fill/FillAdaptive.hpp b/src/libslic3r/Fill/FillAdaptive.hpp index 60591b60b..aca8d1d7b 100644 --- a/src/libslic3r/Fill/FillAdaptive.hpp +++ b/src/libslic3r/Fill/FillAdaptive.hpp @@ -11,8 +11,6 @@ #ifndef slic3r_FillAdaptive_hpp_ #define slic3r_FillAdaptive_hpp_ -#include "../AABBTreeIndirect.hpp" - #include "FillBase.hpp" struct indexed_triangle_set; @@ -43,8 +41,6 @@ Eigen::Quaterniond transform_to_octree(); FillAdaptive::OctreePtr build_octree( // Mesh is rotated to the coordinate system of the octree. const indexed_triangle_set &triangle_mesh, - // Up vector of the mesh rotated to the coordinate system of the octree. - const Vec3d &up_vector, coordf_t line_spacing, // If true, octree is densified below internal overhangs only. bool support_overhangs_only); diff --git a/src/libslic3r/PrintObject.cpp b/src/libslic3r/PrintObject.cpp index d8499bc12..ac47e1d10 100644 --- a/src/libslic3r/PrintObject.cpp +++ b/src/libslic3r/PrintObject.cpp @@ -443,18 +443,13 @@ std::pair<FillAdaptive::OctreePtr, FillAdaptive::OctreePtr> PrintObject::prepare return std::make_pair(OctreePtr(), OctreePtr()); indexed_triangle_set mesh = this->model_object()->raw_indexed_triangle_set(); - Vec3d up; - { - auto m = transform_to_octree().toRotationMatrix(); - up = m * Vec3d(0., 0., 1.); - // Rotate mesh and build octree on it with axis-aligned (standart base) cubes - Transform3d m2 = m_trafo; - m2.translate(Vec3d(- unscale<float>(m_center_offset.x()), - unscale<float>(m_center_offset.y()), 0)); - its_transform(mesh, m * m2, true); - } + // Rotate mesh and build octree on it with axis-aligned (standart base) cubes. + Transform3d m = m_trafo; + m.translate(Vec3d(- unscale<float>(m_center_offset.x()), - unscale<float>(m_center_offset.y()), 0)); + its_transform(mesh, transform_to_octree().toRotationMatrix() * m, true); return std::make_pair( - adaptive_line_spacing ? build_octree(mesh, up, adaptive_line_spacing, false) : OctreePtr(), - support_line_spacing ? build_octree(mesh, up, support_line_spacing, true) : OctreePtr()); + adaptive_line_spacing ? build_octree(mesh, adaptive_line_spacing, false) : OctreePtr(), + support_line_spacing ? build_octree(mesh, support_line_spacing, true) : OctreePtr()); } void PrintObject::clear_layers() |