OrcaSlicer latest
OrcaSlicer
Loading...
Searching...
No Matches
TreeSupport3D.cpp File Reference
#include "TreeSupport3D.hpp"
#include "AABBTreeIndirect.hpp"
#include "AABBTreeLines.hpp"
#include "BuildVolume.hpp"
#include "ClipperUtils.hpp"
#include "EdgeGrid.hpp"
#include "libslic3r/Exception.hpp"
#include "libslic3r/ExPolygon.hpp"
#include "Fill/Fill.hpp"
#include "libslic3r/Flow.hpp"
#include "libslic3r/Fill/FillBase.hpp"
#include "Layer.hpp"
#include "libslic3r/Point.hpp"
#include "libslic3r/Line.hpp"
#include "Print.hpp"
#include "MultiPoint.hpp"
#include "Polygon.hpp"
#include "Polyline.hpp"
#include "MutablePolygon.hpp"
#include "BeltFloorContext.hpp"
#include "libslic3r/Support/TreeSupportCommon.hpp"
#include "libslic3r/PrintConfig.hpp"
#include "libslic3r/Support/TreeModelVolumes.hpp"
#include "libslic3r/Support/SupportParameters.hpp"
#include "libslic3r/Support/SupportLayer.hpp"
#include "SupportCommon.hpp"
#include "libslic3r/Surface.hpp"
#include "TriangleMeshSlicer.hpp"
#include "TreeSupport.hpp"
#include "I18N.hpp"
#include "libslic3r/libslic3r.h"
#include "libslic3r/Utils.hpp"
#include <algorithm>
#include <Eigen/Geometry>
#include <atomic>
#include <cassert>
#include <chrono>
#include <cstdint>
#include <functional>
#include <cstdlib>
#include <cmath>
#include <limits>
#include <memory>
#include <math.h>
#include <mutex>
#include <numeric>
#include <iterator>
#include <optional>
#include <stdio.h>
#include <string>
#include <string_view>
#include <boost/log/trivial.hpp>
#include <tbb/parallel_for.h>
#include <tbb/parallel_for_each.h>
#include <tbb/spin_mutex.h>
#include <vector>
#include <utility>
#include <unordered_set>
#include <tuple>
#include "libslic3r/BoundingBox.hpp"
#include "libslic3r/Config.hpp"
#include "libslic3r/MultiMaterialSegmentation.hpp"
#include "libslic3r/Slicing.hpp"

Go to the source code of this file.

Classes

class  Slic3r::TreeSupport3D::RichInterfacePlacer
struct  Slic3r::TreeSupport3D::SupportElementInfluenceAreas
struct  Slic3r::TreeSupport3D::SupportElementMerging

Namespaces

namespace  Slic3r
 |/ Copyright (c) Prusa Research 2020 - 2023 Enrico Turri @enricoturri1966 |/ |/ PrusaSlicer is released under the terms of the AGPLv3 or higher |/
namespace  Slic3r::TreeSupport3D

Macros

#define TREE_SUPPORT_ORGANIC_NUDGE_NEW   1
#define _L(s)

Typedefs

using Slic3r::TreeSupport3D::LineInformation = std::vector<std::pair<Point, LineStatus>>
using Slic3r::TreeSupport3D::LineInformations = std::vector<LineInformation>

Functions

static void Slic3r::TreeSupport3D::validate_range (const Point &pt)
static void Slic3r::TreeSupport3D::validate_range (const Points &points)
static void Slic3r::TreeSupport3D::validate_range (const MultiPoint &mp)
static void Slic3r::TreeSupport3D::validate_range (const Polygons &polygons)
static void Slic3r::TreeSupport3D::validate_range (const Polylines &polylines)
static void Slic3r::TreeSupport3D::validate_range (const LineInformation &lines)
static void Slic3r::TreeSupport3D::validate_range (const LineInformations &lines)
static void Slic3r::TreeSupport3D::check_self_intersections (const Polygons &polygons, const std::string_view message)
static void Slic3r::TreeSupport3D::check_self_intersections (const ExPolygon &expoly, const std::string_view message)
static std::vector< std::pair< TreeSupportSettings, std::vector< size_t > > > Slic3r::TreeSupport3D::group_meshes (const Print &print, const std::vector< size_t > &print_object_ids)
static LayerIndex Slic3r::TreeSupport3D::precalculate (const Print &print, const std::vector< Polygons > &overhangs, const TreeSupportSettings &config, const std::vector< size_t > &object_ids, TreeModelVolumes &volumes, std::function< void()> throw_on_cancel)
 Precalculates all avoidances, that could be required.
LineStatus Slic3r::TreeSupport3D::get_avoidance_status (const Point &p, coord_t radius, LayerIndex layer_idx, const TreeModelVolumes &volumes, const TreeSupportSettings &config)
static LineInformations Slic3r::TreeSupport3D::convert_lines_to_internal (const TreeModelVolumes &volumes, const TreeSupportSettings &config, const Polylines &polylines, LayerIndex layer_idx)
 Converts a Polygons object representing a line into the internal format.
static bool Slic3r::TreeSupport3D::evaluate_point_for_next_layer_function (const TreeModelVolumes &volumes, const TreeSupportSettings &config, size_t current_layer, const std::pair< Point, LineStatus > &p)
 Evaluates if a point has to be added now. Required for a split_lines call in generate_initial_areas().
template<typename EvaluatePointFn>
static std::pair< LineInformations, LineInformations > Slic3r::TreeSupport3D::split_lines (const LineInformations &lines, EvaluatePointFn evaluatePoint)
 Evaluates which points of some lines are not valid one layer below and which are. Assumes all points are valid on the current layer. Validity is evaluated using supplied lambda.
static std::optional< std::pair< Point, size_t > > Slic3r::TreeSupport3D::polyline_sample_next_point_at_distance (const Points &polyline, const Point &start_pt, size_t start_idx, double dist)
static Polylines Slic3r::TreeSupport3D::ensure_maximum_distance_polyline (const Polylines &input, double distance, size_t min_points)
 Eensures that every line segment is about distance in length. The resulting lines may differ from the original but all points are on the original.
static Polylines Slic3r::TreeSupport3D::generate_support_infill_lines (const Polygons &polygon, const SupportParameters &support_params, bool roof, LayerIndex layer_idx, coord_t support_infill_distance)
 Returns Polylines representing the (infill) lines that will result in slicing the given area.
static Polygons Slic3r::TreeSupport3D::safe_union (const Polygons first, const Polygons second={})
 Unions two Polygons. Ensures that if the input is non empty that the output also will be non empty.
static Polygons Slic3r::TreeSupport3D::safe_offset_inc (const Polygons &me, coord_t distance, const Polygons &collision, coord_t safe_step_size, coord_t last_step_offset_without_check, size_t min_amount_offset)
 Offsets (increases the area of) a polygons object in multiple steps to ensure that it does not lag through over a given obstacle.
int Slic3r::TreeSupport3D::generate_raft_contact (const PrintObject &print_object, const TreeSupportSettings &config, InterfacePlacer &interface_placer)
void Slic3r::TreeSupport3D::finalize_raft_contact (const PrintObject &print_object, const int raft_contact_layer_idx, SupportGeneratorLayersPtr &top_contacts, std::vector< SupportElements > &move_bounds)
void Slic3r::TreeSupport3D::sample_overhang_area (Polygons &&overhang_area, const bool large_horizontal_roof, const size_t layer_idx, const size_t num_support_roof_layers, const coord_t connect_length, const TreeSupportMeshGroupSettings &mesh_group_settings, RichInterfacePlacer &interface_placer)
static void Slic3r::TreeSupport3D::generate_initial_areas (const PrintObject &print_object, const TreeModelVolumes &volumes, const TreeSupportSettings &config, const std::vector< Polygons > &overhangs, std::vector< SupportElements > &move_bounds, InterfacePlacer &interface_placer, std::function< void()> throw_on_cancel)
 Creates the initial influence areas (that can later be propagated down) by placing them below the overhang.
static unsigned int Slic3r::TreeSupport3D::move_inside (const Polygons &polygons, Point &from, int distance=0, int64_t maxDist2=std::numeric_limits< int64_t >::max())
static Point Slic3r::TreeSupport3D::move_inside_if_outside (const Polygons &polygons, Point from, int distance=0, int64_t maxDist2=std::numeric_limits< int64_t >::max())
static std::optional< SupportElementState > Slic3r::TreeSupport3D::increase_single_area (const TreeModelVolumes &volumes, const TreeSupportSettings &config, const AreaIncreaseSettings &settings, const LayerIndex layer_idx, const SupportElement &parent, const Polygons &relevant_offset, Polygons &to_bp_data, Polygons &to_model_data, Polygons &increased, const coord_t overspeed, const bool mergelayer)
 Checks if an influence area contains a valid subsection and returns the corresponding metadata and the new Influence area.
static void Slic3r::TreeSupport3D::increase_areas_one_layer (const TreeModelVolumes &volumes, const TreeSupportSettings &config, std::vector< SupportElementMerging > &merging_areas, const LayerIndex layer_idx, SupportElements &layer_elements, const bool mergelayer, std::function< void()> throw_on_cancel)
 Increases influence areas as far as required.
static SupportElementState Slic3r::TreeSupport3D::merge_support_element_states (const SupportElementState &first, const SupportElementState &second, const Point &next_position, const coord_t layer_idx, const TreeSupportSettings &config)
static bool Slic3r::TreeSupport3D::merge_influence_areas_two_elements (const TreeModelVolumes &volumes, const TreeSupportSettings &config, const LayerIndex layer_idx, SupportElementMerging &dst, SupportElementMerging &src)
static SupportElementMerging * Slic3r::TreeSupport3D::merge_influence_areas_leaves (const TreeModelVolumes &volumes, const TreeSupportSettings &config, const LayerIndex layer_idx, SupportElementMerging *const dst_begin, SupportElementMerging *dst_end)
 Merges Influence Areas if possible.
static SupportElementMerging * Slic3r::TreeSupport3D::merge_influence_areas_two_sets (const TreeModelVolumes &volumes, const TreeSupportSettings &config, const LayerIndex layer_idx, SupportElementMerging *const dst_begin, SupportElementMerging *dst_end, SupportElementMerging *src_begin, SupportElementMerging *const src_end)
static void Slic3r::TreeSupport3D::merge_influence_areas (const TreeModelVolumes &volumes, const TreeSupportSettings &config, const LayerIndex layer_idx, std::vector< SupportElementMerging > &influence_areas, std::function< void()> throw_on_cancel)
 Merges Influence Areas at one layer if possible.
static void Slic3r::TreeSupport3D::create_layer_pathing (const TreeModelVolumes &volumes, const TreeSupportSettings &config, std::vector< SupportElements > &move_bounds, std::function< void()> throw_on_cancel)
 Propagates influence downwards, and merges overlapping ones.
static void Slic3r::TreeSupport3D::set_points_on_areas (const SupportElement &elem, SupportElements *layer_above)
 Sets the result_on_layer for all parents based on the SupportElement supplied.
static void Slic3r::TreeSupport3D::set_to_model_contact_simple (SupportElement &elem)
static void Slic3r::TreeSupport3D::set_to_model_contact_to_model_gracious (const TreeModelVolumes &volumes, const TreeSupportSettings &config, std::vector< SupportElements > &move_bounds, SupportElement &first_elem, std::function< void()> throw_on_cancel)
 Get the best point to connect to the model and set the result_on_layer of the relevant SupportElement accordingly.
static void Slic3r::TreeSupport3D::remove_deleted_elements (std::vector< SupportElements > &move_bounds)
static void Slic3r::TreeSupport3D::create_nodes_from_area (const TreeModelVolumes &volumes, const TreeSupportSettings &config, std::vector< SupportElements > &move_bounds, std::function< void()> throw_on_cancel)
 Set the result_on_layer point for all influence areas.
template<bool flip_normals>
void Slic3r::TreeSupport3D::triangulate_fan (indexed_triangle_set &its, int ifan, int ibegin, int iend)
static void Slic3r::TreeSupport3D::triangulate_strip (indexed_triangle_set &its, int ibegin1, int iend1, int ibegin2, int iend2)
static std::pair< int, int > Slic3r::TreeSupport3D::discretize_circle (const Vec3f &center, const Vec3f &normal, const float radius, const float eps, std::vector< Vec3f > &pts)
static std::pair< float, float > Slic3r::TreeSupport3D::extrude_branch (const std::vector< const SupportElement * > &path, const TreeSupportSettings &config, const SlicingParameters &slicing_params, const std::vector< SupportElements > &move_bounds, bool has_root, indexed_triangle_set &result)
static void Slic3r::TreeSupport3D::organic_smooth_branches_avoid_collisions (const PrintObject &print_object, const TreeModelVolumes &volumes, const TreeSupportSettings &config, std::vector< SupportElements > &move_bounds, const std::vector< std::pair< SupportElement *, int > > &elements_with_link_down, const std::vector< size_t > &linear_data_layers, std::function< void()> throw_on_cancel)
static void Slic3r::TreeSupport3D::generate_support_areas (Print &print, TreeSupport *tree_support, const BuildVolume &build_volume, const std::vector< size_t > &print_object_ids, std::function< void()> throw_on_cancel)
 Create the areas that need support.
static void Slic3r::TreeSupport3D::recover_pending_branch_roofs (InterfacePlacer &interface_placer, const std::vector< const SupportElement * > &branch_path, const LayerIndex layer_begin, std::vector< Polygons > &slices)
void Slic3r::TreeSupport3D::organic_draw_branches (PrintObject &print_object, TreeModelVolumes &volumes, const TreeSupportSettings &config, std::vector< SupportElements > &move_bounds, SupportGeneratorLayersPtr &bottom_contacts, SupportGeneratorLayersPtr &top_contacts, InterfacePlacer &interface_placer, SupportGeneratorLayersPtr &intermediate_layers, SupportGeneratorLayerStorage &layer_storage, std::function< void()> throw_on_cancel)
void Slic3r::generate_tree_support_3D (PrintObject &print_object, TreeSupport *tree_support, std::function< void()> throw_on_cancel)

Macro Definition Documentation

◆ _L

#define _L ( s)
Value:
std::string translate(const std::string &s)
Definition I18N.hpp:18

Referenced by Slic3r::TreeSupport3D::generate_support_areas().

◆ TREE_SUPPORT_ORGANIC_NUDGE_NEW

#define TREE_SUPPORT_ORGANIC_NUDGE_NEW   1