Change in passing octree struct

This commit is contained in:
Lukáš Hejl 2020-09-02 22:53:10 +02:00
parent 423d1f2f40
commit 5997f2759c
4 changed files with 21 additions and 18 deletions

View file

@ -318,7 +318,7 @@ void export_group_fills_to_svg(const char *path, const std::vector<SurfaceFill>
#endif #endif
// friend to Layer // friend to Layer
void Layer::make_fills() void Layer::make_fills(FillAdaptive_Internal::Octree* adaptive_fill_octree)
{ {
for (LayerRegion *layerm : m_regions) for (LayerRegion *layerm : m_regions)
layerm->fills.clear(); layerm->fills.clear();
@ -345,7 +345,7 @@ void Layer::make_fills()
f->layer_id = this->id(); f->layer_id = this->id();
f->z = this->print_z; f->z = this->print_z;
f->angle = surface_fill.params.angle; f->angle = surface_fill.params.angle;
f->adapt_fill_octree = this->object()->adaptiveInfillOctree(); f->adapt_fill_octree = adaptive_fill_octree;
// calculate flow spacing for infill pattern generation // calculate flow spacing for infill pattern generation
bool using_internal_flow = ! surface_fill.surface.is_solid() && ! surface_fill.params.flow.bridge; bool using_internal_flow = ! surface_fill.surface.is_solid() && ! surface_fill.params.flow.bridge;

View file

@ -13,6 +13,10 @@ class Layer;
class PrintRegion; class PrintRegion;
class PrintObject; class PrintObject;
namespace FillAdaptive_Internal {
struct Octree;
};
class LayerRegion class LayerRegion
{ {
public: public:
@ -134,7 +138,7 @@ public:
return false; return false;
} }
void make_perimeters(); void make_perimeters();
void make_fills(); void make_fills(FillAdaptive_Internal::Octree* adaptive_fill_octree);
void make_ironing(); void make_ironing();
void export_region_slices_to_svg(const char *path) const; void export_region_slices_to_svg(const char *path) const;

View file

@ -11,7 +11,6 @@
#include "GCode/ToolOrdering.hpp" #include "GCode/ToolOrdering.hpp"
#include "GCode/WipeTower.hpp" #include "GCode/WipeTower.hpp"
#include "GCode/ThumbnailData.hpp" #include "GCode/ThumbnailData.hpp"
#include "Fill/FillAdaptive.hpp"
#include "libslic3r.h" #include "libslic3r.h"
@ -26,6 +25,9 @@ enum class SlicingMode : uint32_t;
class Layer; class Layer;
class SupportLayer; class SupportLayer;
namespace FillAdaptive_Internal {
struct Octree;
};
// Print step IDs for keeping track of the print state. // Print step IDs for keeping track of the print state.
enum PrintStep { enum PrintStep {
@ -193,7 +195,6 @@ public:
void project_and_append_custom_enforcers(std::vector<ExPolygons>& enforcers) const { project_and_append_custom_supports(FacetSupportType::ENFORCER, enforcers); } void project_and_append_custom_enforcers(std::vector<ExPolygons>& enforcers) const { project_and_append_custom_supports(FacetSupportType::ENFORCER, enforcers); }
void project_and_append_custom_blockers(std::vector<ExPolygons>& blockers) const { project_and_append_custom_supports(FacetSupportType::BLOCKER, blockers); } void project_and_append_custom_blockers(std::vector<ExPolygons>& blockers) const { project_and_append_custom_supports(FacetSupportType::BLOCKER, blockers); }
FillAdaptive_Internal::Octree* adaptiveInfillOctree() { return m_adapt_fill_octree.get(); }
private: private:
// to be called from Print only. // to be called from Print only.
friend class Print; friend class Print;
@ -235,7 +236,7 @@ private:
void discover_horizontal_shells(); void discover_horizontal_shells();
void combine_infill(); void combine_infill();
void _generate_support_material(); void _generate_support_material();
void prepare_adaptive_infill_data(); std::unique_ptr<FillAdaptive_Internal::Octree> prepare_adaptive_infill_data();
// XYZ in scaled coordinates // XYZ in scaled coordinates
Vec3crd m_size; Vec3crd m_size;
@ -256,8 +257,6 @@ private:
// so that next call to make_perimeters() performs a union() before computing loops // so that next call to make_perimeters() performs a union() before computing loops
bool m_typed_slices = false; bool m_typed_slices = false;
std::unique_ptr<FillAdaptive_Internal::Octree> m_adapt_fill_octree = nullptr;
std::vector<ExPolygons> slice_region(size_t region_id, const std::vector<float> &z, SlicingMode mode) const; std::vector<ExPolygons> slice_region(size_t region_id, const std::vector<float> &z, SlicingMode mode) const;
std::vector<ExPolygons> slice_modifiers(size_t region_id, const std::vector<float> &z) const; std::vector<ExPolygons> slice_modifiers(size_t region_id, const std::vector<float> &z) const;
std::vector<ExPolygons> slice_volumes(const std::vector<float> &z, SlicingMode mode, const std::vector<const ModelVolume*> &volumes) const; std::vector<ExPolygons> slice_volumes(const std::vector<float> &z, SlicingMode mode, const std::vector<const ModelVolume*> &volumes) const;

View file

@ -362,8 +362,6 @@ void PrintObject::prepare_infill()
} // for each layer } // for each layer
#endif /* SLIC3R_DEBUG_SLICE_PROCESSING */ #endif /* SLIC3R_DEBUG_SLICE_PROCESSING */
this->prepare_adaptive_infill_data();
this->set_done(posPrepareInfill); this->set_done(posPrepareInfill);
} }
@ -373,13 +371,15 @@ void PrintObject::infill()
this->prepare_infill(); this->prepare_infill();
if (this->set_started(posInfill)) { if (this->set_started(posInfill)) {
std::unique_ptr<FillAdaptive_Internal::Octree> octree = this->prepare_adaptive_infill_data();
BOOST_LOG_TRIVIAL(debug) << "Filling layers in parallel - start"; BOOST_LOG_TRIVIAL(debug) << "Filling layers in parallel - start";
tbb::parallel_for( tbb::parallel_for(
tbb::blocked_range<size_t>(0, m_layers.size()), tbb::blocked_range<size_t>(0, m_layers.size()),
[this](const tbb::blocked_range<size_t>& range) { [this, &octree](const tbb::blocked_range<size_t>& range) {
for (size_t layer_idx = range.begin(); layer_idx < range.end(); ++ layer_idx) { for (size_t layer_idx = range.begin(); layer_idx < range.end(); ++ layer_idx) {
m_print->throw_if_canceled(); m_print->throw_if_canceled();
m_layers[layer_idx]->make_fills(); m_layers[layer_idx]->make_fills(octree.get());
} }
} }
); );
@ -432,14 +432,14 @@ void PrintObject::generate_support_material()
} }
} }
void PrintObject::prepare_adaptive_infill_data() std::unique_ptr<FillAdaptive_Internal::Octree> PrintObject::prepare_adaptive_infill_data()
{ {
const ConfigOptionPercent* opt_fill_density = this->print()->full_print_config().option<ConfigOptionPercent>("fill_density"); const ConfigOptionPercent* opt_fill_density = this->print()->full_print_config().option<ConfigOptionPercent>("fill_density");
const ConfigOptionFloatOrPercent* opt_infill_extrusion_width = this->print()->full_print_config().option<ConfigOptionFloatOrPercent>("infill_extrusion_width"); const ConfigOptionFloatOrPercent* opt_infill_extrusion_width = this->print()->full_print_config().option<ConfigOptionFloatOrPercent>("infill_extrusion_width");
if(opt_fill_density == nullptr || opt_infill_extrusion_width == nullptr || opt_fill_density->value <= 0 || opt_infill_extrusion_width->value <= 0) if(opt_fill_density == nullptr || opt_infill_extrusion_width == nullptr || opt_fill_density->value <= 0 || opt_infill_extrusion_width->value <= 0)
{ {
return; return std::unique_ptr<FillAdaptive_Internal::Octree>{};
} }
float fill_density = opt_fill_density->value; float fill_density = opt_fill_density->value;
@ -448,15 +448,15 @@ void PrintObject::prepare_adaptive_infill_data()
coordf_t line_spacing = infill_extrusion_width / ((fill_density / 100.0f) * 0.333333333f); coordf_t line_spacing = infill_extrusion_width / ((fill_density / 100.0f) * 0.333333333f);
BoundingBoxf bed_shape(this->print()->config().bed_shape.values); BoundingBoxf bed_shape(this->print()->config().bed_shape.values);
BoundingBoxf3 printer_volume(Vec3d(bed_shape.min(0), bed_shape.min(1), 0), BoundingBoxf3 printer_volume(Vec3d(bed_shape.min.x(), bed_shape.min.y(), 0),
Vec3d(bed_shape.max(0), bed_shape.max(1), this->print()->config().max_print_height)); Vec3d(bed_shape.max.x(), bed_shape.max.y(), this->print()->config().max_print_height));
Vec3d model_center = this->model_object()->bounding_box().center(); Vec3d model_center = this->model_object()->bounding_box().center();
model_center(2) = 0.0f; // Set position in Z axis to 0 model_center.z() = 0.0f; // Set position in Z axis to 0
// Center of the first cube in octree // Center of the first cube in octree
TriangleMesh mesh = this->model_object()->mesh(); TriangleMesh mesh = this->model_object()->mesh();
this->m_adapt_fill_octree = FillAdaptive::build_octree(mesh, line_spacing, printer_volume, model_center); return FillAdaptive::build_octree(mesh, line_spacing, printer_volume, model_center);
} }
void PrintObject::clear_layers() void PrintObject::clear_layers()