mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-10-22 16:21:24 -06:00
C++ supports sketched, but not finalized yet. Slic3r is still using
the old Perl supports, but this time with the C++ fillers.
This commit is contained in:
parent
8f40d9b34e
commit
7d7f093120
19 changed files with 602 additions and 557 deletions
|
@ -88,6 +88,7 @@ src/libslic3r/PrintConfig.cpp
|
|||
src/libslic3r/PrintConfig.hpp
|
||||
src/libslic3r/PrintObject.cpp
|
||||
src/libslic3r/PrintRegion.cpp
|
||||
src/libslic3r/SupportMaterial.cpp
|
||||
src/libslic3r/SupportMaterial.hpp
|
||||
src/libslic3r/Surface.cpp
|
||||
src/libslic3r/Surface.hpp
|
||||
|
|
|
@ -229,6 +229,21 @@ sub new {
|
|||
return $self;
|
||||
}
|
||||
|
||||
package Slic3r::Print::SupportMaterial2;
|
||||
|
||||
sub new {
|
||||
my ($class, %args) = @_;
|
||||
|
||||
return $class->_new(
|
||||
$args{print_config}, # required
|
||||
$args{object_config}, # required
|
||||
$args{first_layer_flow}, # required
|
||||
$args{flow}, # required
|
||||
$args{interface_flow}, # required
|
||||
$args{soluble_interface} // 0
|
||||
);
|
||||
}
|
||||
|
||||
package Slic3r::GUI::_3DScene::GLVertexArray;
|
||||
sub CLONE_SKIP { 1 }
|
||||
|
||||
|
@ -283,6 +298,7 @@ for my $class (qw(
|
|||
Slic3r::Print::State
|
||||
Slic3r::Surface
|
||||
Slic3r::Surface::Collection
|
||||
Slic3r::Print::SupportMaterial2
|
||||
Slic3r::TriangleMesh
|
||||
))
|
||||
{
|
||||
|
|
|
@ -14,13 +14,6 @@
|
|||
|
||||
namespace Slic3r {
|
||||
|
||||
Fill* Fill::new_from_type(const std::string &type)
|
||||
{
|
||||
static t_config_enum_values enum_keys_map = ConfigOptionEnum<InfillPattern>::get_enum_values();
|
||||
t_config_enum_values::const_iterator it = enum_keys_map.find(type);
|
||||
return (it == enum_keys_map.end()) ? NULL : new_from_type(InfillPattern(it->second));
|
||||
}
|
||||
|
||||
Fill* Fill::new_from_type(const InfillPattern type)
|
||||
{
|
||||
switch (type) {
|
||||
|
@ -39,6 +32,13 @@ Fill* Fill::new_from_type(const InfillPattern type)
|
|||
}
|
||||
}
|
||||
|
||||
Fill* Fill::new_from_type(const std::string &type)
|
||||
{
|
||||
static t_config_enum_values enum_keys_map = ConfigOptionEnum<InfillPattern>::get_enum_values();
|
||||
t_config_enum_values::const_iterator it = enum_keys_map.find(type);
|
||||
return (it == enum_keys_map.end()) ? NULL : new_from_type(InfillPattern(it->second));
|
||||
}
|
||||
|
||||
Polylines Fill::fill_surface(const Surface *surface, const FillParams ¶ms)
|
||||
{
|
||||
// Perform offset.
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
|
||||
#include "../libslic3r.h"
|
||||
#include "../BoundingBox.hpp"
|
||||
#include "../PrintConfig.hpp"
|
||||
|
||||
namespace Slic3r {
|
||||
|
||||
|
@ -52,6 +53,7 @@ public:
|
|||
public:
|
||||
virtual ~Fill() {}
|
||||
|
||||
static Fill* Fill::new_from_type(const InfillPattern type);
|
||||
static Fill* new_from_type(const std::string &type);
|
||||
|
||||
void set_bounding_box(const Slic3r::BoundingBox &bbox) { bounding_box = bbox; }
|
||||
|
|
|
@ -77,10 +77,11 @@ Flow::mm3_per_mm() const {
|
|||
}
|
||||
|
||||
/* This static method returns bridge width for a given nozzle diameter. */
|
||||
float
|
||||
Flow::_bridge_width(float nozzle_diameter, float bridge_flow_ratio) {
|
||||
if (bridge_flow_ratio == 1) return nozzle_diameter; // optimization to avoid sqrt()
|
||||
return sqrt(bridge_flow_ratio * (nozzle_diameter*nozzle_diameter));
|
||||
float Flow::_bridge_width(float nozzle_diameter, float bridge_flow_ratio) {
|
||||
return (bridge_flow_ratio == 1.) ?
|
||||
// optimization to avoid sqrt()
|
||||
nozzle_diameter :
|
||||
sqrt(bridge_flow_ratio) * nozzle_diameter;
|
||||
}
|
||||
|
||||
/* This static method returns a sane extrusion width default. */
|
||||
|
|
|
@ -26,7 +26,8 @@ class LayerRegion
|
|||
|
||||
public:
|
||||
Layer* layer();
|
||||
PrintRegion* region();
|
||||
PrintRegion* region() { return this->_region; }
|
||||
const PrintRegion* region() const { return this->_region; }
|
||||
|
||||
// collection of surfaces generated by slicing the original geometry
|
||||
// divided by type top/bottom/internal
|
||||
|
|
|
@ -28,12 +28,6 @@ LayerRegion::layer()
|
|||
return this->_layer;
|
||||
}
|
||||
|
||||
PrintRegion*
|
||||
LayerRegion::region()
|
||||
{
|
||||
return this->_region;
|
||||
}
|
||||
|
||||
Flow
|
||||
LayerRegion::flow(FlowRole role, bool bridge, double width) const
|
||||
{
|
||||
|
|
|
@ -120,7 +120,9 @@ public:
|
|||
size_t total_layer_count() const;
|
||||
size_t layer_count() const;
|
||||
void clear_layers();
|
||||
Layer* get_layer(int idx);
|
||||
Layer* get_layer(int idx) { return this->layers.at(idx); }
|
||||
const Layer* get_layer(int idx) const { return this->layers.at(idx); }
|
||||
|
||||
// print_z: top of the layer; slice_z: center of the layer.
|
||||
Layer* add_layer(int id, coordf_t height, coordf_t print_z, coordf_t slice_z);
|
||||
void delete_layer(int idx);
|
||||
|
|
|
@ -149,12 +149,6 @@ PrintObject::clear_layers()
|
|||
this->delete_layer(i);
|
||||
}
|
||||
|
||||
Layer*
|
||||
PrintObject::get_layer(int idx)
|
||||
{
|
||||
return this->layers.at(idx);
|
||||
}
|
||||
|
||||
Layer*
|
||||
PrintObject::add_layer(int id, coordf_t height, coordf_t print_z, coordf_t slice_z)
|
||||
{
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -3,6 +3,8 @@
|
|||
|
||||
namespace Slic3r {
|
||||
|
||||
class PrintObject;
|
||||
|
||||
// how much we extend support around the actual contact area
|
||||
#define SUPPORT_MATERIAL_MARGIN 1.5
|
||||
|
||||
|
@ -43,7 +45,7 @@ public:
|
|||
}
|
||||
|
||||
bool operator==(const MyLayer &layer2) const {
|
||||
return print_z == layer2.printz && height == layer2.height && bridging == layer2.bridging;
|
||||
return print_z == layer2.print_z && height == layer2.height && bridging == layer2.bridging;
|
||||
}
|
||||
|
||||
bool operator<(const MyLayer &layer2) const {
|
||||
|
@ -90,50 +92,59 @@ public:
|
|||
// top or bottom extreme
|
||||
bool is_top;
|
||||
|
||||
coordf_t z() const { return is_top ? layer->print_z : layer->print_z - height; }
|
||||
coordf_t z() const { return is_top ? layer->print_z : layer->print_z - layer->height; }
|
||||
|
||||
bool operator<(const LayerExtreme &other) const { return z() < other.z(); }
|
||||
}
|
||||
};
|
||||
|
||||
struct LayerPrintZ_Hash {
|
||||
static size_t operator(const MyLayer &layer) {
|
||||
return std::hash<double>(layer.print_z)^std::hash<double>(layer.height)^size_t(layer.bridging);
|
||||
size_t operator()(const MyLayer &layer) const {
|
||||
return std::hash<double>()(layer.print_z)^std::hash<double>()(layer.height)^size_t(layer.bridging);
|
||||
}
|
||||
};
|
||||
|
||||
typedef std::set<MyLayer, LayerPrintZ_Hash> MyLayersSet;
|
||||
typedef std::vector<Layer*> MyLayersPtr;
|
||||
typedef std::deque<Layer> MyLayersDeque;
|
||||
typedef std::deque<Layer> MyLayerStorage;
|
||||
typedef std::vector<MyLayer*> MyLayersPtr;
|
||||
typedef std::deque<MyLayer> MyLayerStorage;
|
||||
|
||||
public:
|
||||
PrintSupportMaterial() :
|
||||
m_object(NULL),
|
||||
m_print_config(NULL),
|
||||
m_object_config(NULL),
|
||||
m_soluble_interface(false),
|
||||
PrintSupportMaterial(
|
||||
const PrintConfig *print_config,
|
||||
const PrintObjectConfig *object_config,
|
||||
const Flow &flow,
|
||||
const Flow &first_layer_flow,
|
||||
const Flow &interface_flow,
|
||||
bool soluble_interface) :
|
||||
m_print_config(print_config),
|
||||
m_object_config(object_config),
|
||||
m_flow(flow),
|
||||
m_first_layer_flow(first_layer_flow),
|
||||
m_interface_flow(interface_flow),
|
||||
m_soluble_interface(soluble_interface),
|
||||
m_support_layer_height_max(0.),
|
||||
m_support_interface_layer_height_max(0.)
|
||||
{}
|
||||
|
||||
void setup(
|
||||
const PrintConfig *print_config;
|
||||
const ObjectConfig *object_config;
|
||||
Flow flow;
|
||||
Flow first_layer_flow;
|
||||
Flow interface_flow;
|
||||
bool soluble_interface)
|
||||
{
|
||||
this->m_object = object;
|
||||
this->m_print_config = print_config;
|
||||
this->m_object_config = object_config;
|
||||
this->m_flow = flow;
|
||||
this->m_first_layer_flow = first_layer_flow;
|
||||
this->m_interface_flow = interface_flow;
|
||||
this->m_soluble_interface = soluble_interface;
|
||||
}
|
||||
PrintSupportMaterial(
|
||||
PrintConfig *print_config,
|
||||
PrintObjectConfig *object_config,
|
||||
Flow *flow,
|
||||
Flow *first_layer_flow,
|
||||
Flow *interface_flow,
|
||||
bool soluble_interface) :
|
||||
m_print_config(print_config),
|
||||
m_object_config(object_config),
|
||||
m_flow(*flow),
|
||||
m_first_layer_flow(*first_layer_flow),
|
||||
m_interface_flow(*interface_flow),
|
||||
m_soluble_interface(soluble_interface),
|
||||
m_support_layer_height_max(0.),
|
||||
m_support_interface_layer_height_max(0.)
|
||||
{}
|
||||
|
||||
void generate(const PrintObject *object);
|
||||
// Generate support material for the object.
|
||||
// New support layers will be added to the object,
|
||||
// with extrusion paths and islands filled in for each support layer.
|
||||
void generate(PrintObject &object);
|
||||
|
||||
private:
|
||||
// Generate top contact layers supporting overhangs.
|
||||
|
@ -146,26 +157,29 @@ private:
|
|||
// otherwise set the layer height to a bridging flow of a support interface nozzle.
|
||||
MyLayersPtr bottom_contact_layers(const PrintObject &object, const MyLayersPtr &top_contacts, MyLayerStorage &layer_storage) const;
|
||||
|
||||
// Trim the top_contacts layers with the bottom_contacts layers if they overlap, so there would not be enough vertical space for both of them.
|
||||
void trim_top_contacts_by_bottom_contacts(const PrintObject &object, const MyLayersPtr &bottom_contacts, MyLayersPtr &top_contacts) const;
|
||||
|
||||
// Generate raft layers and the intermediate support layers between the bottom contact and top contact surfaces.
|
||||
MyLayersPtr raft_and_intermediate_support_layers(
|
||||
const PrintObject &object,
|
||||
const MyLayersPtr &bottom_contacts,
|
||||
const MyLayersPtr &top_contacts,
|
||||
MyLayerStorage &layer_storage,
|
||||
const coordf_t max_object_layer_height);
|
||||
const coordf_t max_object_layer_height) const;
|
||||
|
||||
void generate_base_layers(
|
||||
const PrintObject &object,
|
||||
const MyLayersPtr &bottom_contacts,
|
||||
const MyLayersPtr &top_contacts,
|
||||
MyLayersPtr &intermediate_layers);
|
||||
MyLayersPtr &intermediate_layers) const;
|
||||
|
||||
MyLayersPtr generate_interface_layers(
|
||||
const PrintObject &object,
|
||||
const MyLayersPtr &bottom_contacts,
|
||||
const MyLayersPtr &top_contacts,
|
||||
MyLayersPtr &intermediate_layers,
|
||||
MyLayerStorage &layer_storage);
|
||||
MyLayerStorage &layer_storage) const;
|
||||
|
||||
/*
|
||||
void generate_pillars_shape();
|
||||
|
@ -178,10 +192,10 @@ private:
|
|||
const MyLayersPtr &bottom_contacts,
|
||||
const MyLayersPtr &top_contacts,
|
||||
const MyLayersPtr &intermediate_layers,
|
||||
const MyLayersPtr &interface_layers);
|
||||
const MyLayersPtr &interface_layers) const;
|
||||
|
||||
const PrintConfig *m_print_config;
|
||||
const ObjectConfig *m_object_config;
|
||||
const PrintConfig *m_print_config;
|
||||
const PrintObjectConfig *m_object_config;
|
||||
Flow m_flow;
|
||||
Flow m_first_layer_flow;
|
||||
Flow m_interface_flow;
|
||||
|
@ -189,6 +203,9 @@ private:
|
|||
|
||||
coordf_t m_support_layer_height_max;
|
||||
coordf_t m_support_interface_layer_height_max;
|
||||
bool m_synchronize_support_layers_with_object;
|
||||
};
|
||||
|
||||
#endif
|
||||
} // namespace Slic3r
|
||||
|
||||
#endif /* slic3r_SupportMaterial_hpp_ */
|
||||
|
|
|
@ -56,6 +56,7 @@ REGISTER_CLASS(PrintConfig, "Config::Print");
|
|||
REGISTER_CLASS(FullPrintConfig, "Config::Full");
|
||||
REGISTER_CLASS(Surface, "Surface");
|
||||
REGISTER_CLASS(SurfaceCollection, "Surface::Collection");
|
||||
REGISTER_CLASS(PrintSupportMaterial, "Print::SupportMaterial2");
|
||||
REGISTER_CLASS(TriangleMesh, "TriangleMesh");
|
||||
REGISTER_CLASS(GLVertexArray, "GUI::_3DScene::GLVertexArray");
|
||||
|
||||
|
|
|
@ -1,7 +1,23 @@
|
|||
%module{Slic3r::XS};
|
||||
|
||||
%{
|
||||
#include <xsinit.h>
|
||||
#include "libslic3r/SupportMaterial.hpp"
|
||||
%}
|
||||
|
||||
%name{Slic3r::Print::SupportMaterial2} class PrintSupportMaterial {
|
||||
%name{_new} PrintSupportMaterial(
|
||||
PrintConfig *print_config,
|
||||
PrintObjectConfig *object_config,
|
||||
Flow *flow,
|
||||
Flow *first_layer_flow,
|
||||
Flow *interface_flow,
|
||||
bool soluble_interface);
|
||||
~PrintSupportMaterial();
|
||||
|
||||
void generate(PrintObject *object)
|
||||
%code{% THIS->generate(*object); %};
|
||||
};
|
||||
|
||||
%package{Slic3r::Print::SupportMaterial};
|
||||
%{
|
||||
|
@ -13,4 +29,4 @@ MARGIN()
|
|||
RETVAL = newSVnv(SUPPORT_MATERIAL_MARGIN);
|
||||
OUTPUT: RETVAL
|
||||
|
||||
%}
|
||||
%}
|
||||
|
|
|
@ -221,6 +221,10 @@ PerimeterGenerator* O_OBJECT_SLIC3R
|
|||
Ref<PerimeterGenerator> O_OBJECT_SLIC3R_T
|
||||
Clone<PerimeterGenerator> O_OBJECT_SLIC3R_T
|
||||
|
||||
PrintSupportMaterial* O_OBJECT_SLIC3R
|
||||
Ref<PrintSupportMaterial> O_OBJECT_SLIC3R_T
|
||||
Clone<PrintSupportMaterial> O_OBJECT_SLIC3R_T
|
||||
|
||||
GLVertexArray* O_OBJECT_SLIC3R
|
||||
|
||||
Axis T_UV
|
||||
|
|
|
@ -141,6 +141,10 @@
|
|||
%typemap{SupportLayer*};
|
||||
%typemap{Ref<SupportLayer>}{simple};
|
||||
|
||||
%typemap{PrintSupportMaterial*};
|
||||
%typemap{Ref<PrintSupportMaterial>}{simple};
|
||||
%typemap{Clone<PrintSupportMaterial>}{simple};
|
||||
|
||||
%typemap{PlaceholderParser*};
|
||||
%typemap{Ref<PlaceholderParser>}{simple};
|
||||
%typemap{Clone<PlaceholderParser>}{simple};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue