Skip to content

Commit

Permalink
Refactor a bit
Browse files Browse the repository at this point in the history
  • Loading branch information
Noisyfox committed Jun 21, 2024
1 parent 3fbacce commit a6ea73d
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 13 deletions.
12 changes: 6 additions & 6 deletions src/libslic3r/Interlocking/InterlockingGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ template<> struct hash<Slic3r::GridPoint3>

namespace Slic3r {

void PrintObject::generate_interlocking_structure()
void InterlockingGenerator::generate_interlocking_structure(PrintObject* print_object)
{
const float rotation = Geometry::deg2rad(22.5); //(global_settings.get<AngleDegrees>("interlocking_orientation"));
const coord_t beam_layer_count = 2; // global_settings.get<int>("interlocking_beam_layer_count");
Expand All @@ -37,18 +37,18 @@ void PrintObject::generate_interlocking_structure()
const coord_t cell_width = beam_width + beam_width;
const Vec3crd cell_size(cell_width, cell_width, 2 * beam_layer_count);

for (size_t region_a_index = 0; region_a_index < num_printing_regions(); region_a_index++) {
const PrintRegion& region_a = printing_region(region_a_index);
for (size_t region_a_index = 0; region_a_index < print_object->num_printing_regions(); region_a_index++) {
const PrintRegion& region_a = print_object->printing_region(region_a_index);
const auto extruder_nr_a = region_a.extruder(FlowRole::frExternalPerimeter);

for (size_t region_b_index = region_a_index + 1; region_b_index < num_printing_regions(); region_b_index++) {
const PrintRegion& region_b = printing_region(region_b_index);
for (size_t region_b_index = region_a_index + 1; region_b_index < print_object->num_printing_regions(); region_b_index++) {
const PrintRegion& region_b = print_object->printing_region(region_b_index);
const auto extruder_nr_b = region_b.extruder(FlowRole::frExternalPerimeter);
if (extruder_nr_a == extruder_nr_b) {
continue;
}

InterlockingGenerator gen(*this, region_a_index, region_b_index, beam_width, boundary_avoidance, rotation, cell_size, beam_layer_count,
InterlockingGenerator gen(*print_object, region_a_index, region_b_index, beam_width, boundary_avoidance, rotation, cell_size, beam_layer_count,
interface_dilation, air_dilation, air_filtering);
gen.generateInterlockingStructure();
}
Expand Down
8 changes: 6 additions & 2 deletions src/libslic3r/Interlocking/InterlockingGenerator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@ namespace Slic3r {
class InterlockingGenerator
{
public:
/*!
* Generate an interlocking structure between each two adjacent meshes.
*/
static void generate_interlocking_structure(PrintObject* print_object);

private:
/*!
* Generate an interlocking structure between two meshes
*/
Expand Down Expand Up @@ -83,8 +89,6 @@ class InterlockingGenerator
, air_dilation(air_dilation)
, air_filtering(air_filtering)
{}

private:

/*! Given two polygons, return the parts that border on air, and grow 'perpendicular' up to 'detect' distance.
*
Expand Down
4 changes: 0 additions & 4 deletions src/libslic3r/Print.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -550,10 +550,6 @@ class PrintObject : public PrintObjectBaseWithState<Print, PrintObjectStep, posC
size_t m_id;
void apply_conical_overhang();

// Generate an interlocking structure between each two adjacent meshes.
friend class InterlockingGenerator;
void generate_interlocking_structure();

public:
//BBS: When printing multi-material objects, this settings will make slicer to clip the overlapping object parts one by the other.
//(2nd part will be clipped by the 1st, 3rd part will be clipped by the 1st and 2nd etc).
Expand Down
4 changes: 3 additions & 1 deletion src/libslic3r/PrintObjectSlice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@
#include "MultiMaterialSegmentation.hpp"
#include "Print.hpp"
#include "ClipperUtils.hpp"
#include "Interlocking/InterlockingGenerator.hpp"
//BBS
#include "ShortestPath.hpp"

#include <boost/log/trivial.hpp>

#include <tbb/parallel_for.h>


//! macro used to mark string used at localization, return same string
#define L(s) Slic3r::I18N::translate(s)

Expand Down Expand Up @@ -1072,7 +1074,7 @@ void PrintObject::slice_volumes()
this->apply_conical_overhang();
m_print->throw_if_canceled();

this->generate_interlocking_structure();
InterlockingGenerator::generate_interlocking_structure(this);
m_print->throw_if_canceled();

BOOST_LOG_TRIVIAL(debug) << "Slicing volumes - make_slices in parallel - begin";
Expand Down

0 comments on commit a6ea73d

Please sign in to comment.