Initial implementation of C++ supports,
some documentation of the existing code.
This commit is contained in:
parent
c16eca0065
commit
8f40d9b34e
@ -2,6 +2,7 @@
|
||||
|
||||
#include "../ClipperUtils.hpp"
|
||||
#include "../Surface.hpp"
|
||||
#include "../PrintConfig.hpp"
|
||||
|
||||
#include "FillBase.hpp"
|
||||
#include "FillConcentric.hpp"
|
||||
@ -15,28 +16,27 @@ namespace Slic3r {
|
||||
|
||||
Fill* Fill::new_from_type(const std::string &type)
|
||||
{
|
||||
if (type == "concentric")
|
||||
return new FillConcentric();
|
||||
if (type == "honeycomb")
|
||||
return new FillHoneycomb();
|
||||
if (type == "3dhoneycomb")
|
||||
return new Fill3DHoneycomb();
|
||||
if (type == "rectilinear")
|
||||
// return new FillRectilinear();
|
||||
return new FillRectilinear2();
|
||||
if (type == "line")
|
||||
return new FillLine();
|
||||
if (type == "grid")
|
||||
// return new FillGrid();
|
||||
return new FillGrid2();
|
||||
if (type == "archimedeanchords")
|
||||
return new FillArchimedeanChords();
|
||||
if (type == "hilbertcurve")
|
||||
return new FillHilbertCurve();
|
||||
if (type == "octagramspiral")
|
||||
return new FillOctagramSpiral();
|
||||
CONFESS("unknown type");
|
||||
return NULL;
|
||||
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) {
|
||||
case ipConcentric: return new FillConcentric();
|
||||
case ipHoneycomb: return new FillHoneycomb();
|
||||
case ip3DHoneycomb: return new Fill3DHoneycomb();
|
||||
case ipRectilinear: return new FillRectilinear2();
|
||||
// case ipRectilinear: return new FillRectilinear();
|
||||
case ipLine: return new FillLine();
|
||||
case ipGrid: return new FillGrid2();
|
||||
// case ipGrid: return new FillGrid();
|
||||
case ipArchimedeanChords: return new FillArchimedeanChords();
|
||||
case ipHilbertCurve: return new FillHilbertCurve();
|
||||
case ipOctagramSpiral: return new FillOctagramSpiral();
|
||||
default: CONFESS("unknown type"); return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
Polylines Fill::fill_surface(const Surface *surface, const FillParams ¶ms)
|
||||
|
@ -76,7 +76,7 @@ class PrintObject
|
||||
{
|
||||
friend class Print;
|
||||
|
||||
public:
|
||||
public:
|
||||
// map of (vectors of volume ids), indexed by region_id
|
||||
/* (we use map instead of vector so that we don't have to worry about
|
||||
resizing it and the [] operator adds new items automagically) */
|
||||
@ -141,7 +141,7 @@ class PrintObject
|
||||
void discover_vertical_shells();
|
||||
void bridge_over_infill();
|
||||
|
||||
private:
|
||||
private:
|
||||
Print* _print;
|
||||
ModelObject* _model_object;
|
||||
Points _copies; // Slic3r::Point objects in scaled G-code coordinates
|
||||
|
1403
xs/src/libslic3r/SupportMaterial.cpp
Normal file
1403
xs/src/libslic3r/SupportMaterial.cpp
Normal file
File diff suppressed because it is too large
Load Diff
@ -6,6 +6,189 @@ namespace Slic3r {
|
||||
// how much we extend support around the actual contact area
|
||||
#define SUPPORT_MATERIAL_MARGIN 1.5
|
||||
|
||||
}
|
||||
// Instantiated by Slic3r::Print::Object->_support_material()
|
||||
class PrintSupportMaterial
|
||||
{
|
||||
public:
|
||||
enum SupporLayerType {
|
||||
sltUnknown = 0,
|
||||
sltRaft,
|
||||
stlFirstLayer,
|
||||
sltBottomContact,
|
||||
sltBottomInterface,
|
||||
sltBase,
|
||||
sltTopInterface,
|
||||
sltTopContact,
|
||||
// Some undecided type yet. It will turn into stlBase first, then it may turn into stlBottomInterface or stlTopInterface.
|
||||
stlIntermediate,
|
||||
};
|
||||
|
||||
class MyLayer
|
||||
{
|
||||
public:
|
||||
MyLayer() :
|
||||
layer_type(sltUnknown),
|
||||
print_z(0.),
|
||||
bottom_z(0.),
|
||||
height(0.),
|
||||
idx_object_layer_above(size_t(-1)),
|
||||
idx_object_layer_below(size_t(-1)),
|
||||
bridging(false)
|
||||
{}
|
||||
|
||||
~MyLayer()
|
||||
{
|
||||
delete aux_polygons;
|
||||
aux_polygons = NULL;
|
||||
}
|
||||
|
||||
bool operator==(const MyLayer &layer2) const {
|
||||
return print_z == layer2.printz && height == layer2.height && bridging == layer2.bridging;
|
||||
}
|
||||
|
||||
bool operator<(const MyLayer &layer2) const {
|
||||
if (print_z < layer2.print_z) {
|
||||
return true;
|
||||
} else if (print_z == layer2.print_z) {
|
||||
if (height > layer2.height)
|
||||
return true;
|
||||
else if (height == layer2.height) {
|
||||
return bridging < layer2.bridging;
|
||||
} else
|
||||
return false;
|
||||
} else
|
||||
return false;
|
||||
}
|
||||
|
||||
SupporLayerType layer_type;
|
||||
// Z used for printing in unscaled coordinates
|
||||
coordf_t print_z;
|
||||
// Bottom height of this layer. For soluble layers, bottom_z + height = print_z,
|
||||
// otherwise bottom_z + gap + height = print_z.
|
||||
coordf_t bottom_z;
|
||||
// layer height in unscaled coordinates
|
||||
coordf_t height;
|
||||
// Index of a PrintObject layer_id supported by this layer. This will be set for top contact layers.
|
||||
// If this is not a contact layer, it will be set to size_t(-1).
|
||||
size_t idx_object_layer_above;
|
||||
// Index of a PrintObject layer_id, which supports this layer. This will be set for bottom contact layers.
|
||||
// If this is not a contact layer, it will be set to size_t(-1).
|
||||
size_t idx_object_layer_below;
|
||||
// Use a bridging flow when printing this support layer.
|
||||
bool bridging;
|
||||
|
||||
// Polygons to be filled by the support pattern.
|
||||
Polygons polygons;
|
||||
// Currently for the contact layers only: Overhangs are stored here.
|
||||
Polygons *aux_polygons;
|
||||
};
|
||||
|
||||
struct LayerExtreme
|
||||
{
|
||||
LayerExtreme(MyLayer *alayer, bool ais_top) : layer(alayer), is_top(ais_top) {}
|
||||
MyLayer *layer;
|
||||
// top or bottom extreme
|
||||
bool is_top;
|
||||
|
||||
coordf_t z() const { return is_top ? layer->print_z : layer->print_z - 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);
|
||||
}
|
||||
};
|
||||
|
||||
typedef std::set<MyLayer, LayerPrintZ_Hash> MyLayersSet;
|
||||
typedef std::vector<Layer*> MyLayersPtr;
|
||||
typedef std::deque<Layer> MyLayersDeque;
|
||||
typedef std::deque<Layer> MyLayerStorage;
|
||||
|
||||
public:
|
||||
PrintSupportMaterial() :
|
||||
m_object(NULL),
|
||||
m_print_config(NULL),
|
||||
m_object_config(NULL),
|
||||
m_soluble_interface(false),
|
||||
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;
|
||||
}
|
||||
|
||||
void generate(const PrintObject *object);
|
||||
|
||||
private:
|
||||
// Generate top contact layers supporting overhangs.
|
||||
// For a soluble interface material synchronize the layer heights with the object, otherwise leave the layer height undefined.
|
||||
// If supports over bed surface only are requested, don't generate contact layers over an object.
|
||||
MyLayersPtr top_contact_layers(const PrintObject &object, MyLayerStorage &layer_storage) const;
|
||||
|
||||
// Generate bottom contact layers supporting the top contact layers.
|
||||
// For a soluble interface material synchronize the layer heights with the object,
|
||||
// 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;
|
||||
|
||||
// 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);
|
||||
|
||||
void generate_base_layers(
|
||||
const PrintObject &object,
|
||||
const MyLayersPtr &bottom_contacts,
|
||||
const MyLayersPtr &top_contacts,
|
||||
MyLayersPtr &intermediate_layers);
|
||||
|
||||
MyLayersPtr generate_interface_layers(
|
||||
const PrintObject &object,
|
||||
const MyLayersPtr &bottom_contacts,
|
||||
const MyLayersPtr &top_contacts,
|
||||
MyLayersPtr &intermediate_layers,
|
||||
MyLayerStorage &layer_storage);
|
||||
|
||||
/*
|
||||
void generate_pillars_shape();
|
||||
void clip_with_shape();
|
||||
*/
|
||||
|
||||
// Produce the actual G-code.
|
||||
void generate_toolpaths(
|
||||
const PrintObject &object,
|
||||
const MyLayersPtr &bottom_contacts,
|
||||
const MyLayersPtr &top_contacts,
|
||||
const MyLayersPtr &intermediate_layers,
|
||||
const MyLayersPtr &interface_layers);
|
||||
|
||||
const PrintConfig *m_print_config;
|
||||
const ObjectConfig *m_object_config;
|
||||
Flow m_flow;
|
||||
Flow m_first_layer_flow;
|
||||
Flow m_interface_flow;
|
||||
bool m_soluble_interface;
|
||||
|
||||
coordf_t m_support_layer_height_max;
|
||||
coordf_t m_support_interface_layer_height_max;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -6,11 +6,29 @@
|
||||
|
||||
namespace Slic3r {
|
||||
|
||||
enum SurfaceType { stTop, stBottom, stBottomBridge, stInternal, stInternalSolid, stInternalBridge, stInternalVoid, stPerimeter };
|
||||
enum SurfaceType {
|
||||
// Top horizontal surface, visible from the top.
|
||||
stTop,
|
||||
// Bottom horizontal surface, visible from the bottom, printed with a normal extrusion flow.
|
||||
stBottom,
|
||||
// Bottom horizontal surface, visible from the bottom, unsupported, printed with a bridging extrusion flow.
|
||||
stBottomBridge,
|
||||
// Normal sparse infill.
|
||||
stInternal,
|
||||
// Full infill, supporting the top surfaces and/or defining the verticall wall thickness.
|
||||
stInternalSolid,
|
||||
// 1st layer of dense infill over sparse infill, printed with a bridging extrusion flow.
|
||||
stInternalBridge,
|
||||
// stInternal turns into void surfaces if the sparse infill is used for supports only,
|
||||
// or if sparse infill layers get combined into a single layer.
|
||||
stInternalVoid,
|
||||
// Inner/outer perimeters.
|
||||
stPerimeter
|
||||
};
|
||||
|
||||
class Surface
|
||||
{
|
||||
public:
|
||||
public:
|
||||
SurfaceType surface_type;
|
||||
ExPolygon expolygon;
|
||||
double thickness; // in mm
|
||||
|
Loading…
Reference in New Issue
Block a user