mirror of
https://git.mirrors.martin98.com/https://github.com/slic3r/Slic3r.git
synced 2025-08-03 08:00:37 +08:00
Doxygen Documentation for Layer.hpp, Layer.cpp, LayerRegion.cpp, LayerRegionFill.cpp (#3979)
* Migrated comments in Layer.hpp * Comments for Layer Class * Comments for LayerRegion * Comments for LayerRegionFill
This commit is contained in:
parent
6fb8a91522
commit
af6b094d29
@ -5,6 +5,8 @@
|
||||
|
||||
namespace Slic3r {
|
||||
|
||||
/// Initialises upper_layer, lower_layer to NULL
|
||||
/// Initialises slicing_errors to false
|
||||
Layer::Layer(size_t id, PrintObject *object, coordf_t height, coordf_t print_z,
|
||||
coordf_t slice_z)
|
||||
: upper_layer(NULL),
|
||||
@ -20,6 +22,7 @@ Layer::Layer(size_t id, PrintObject *object, coordf_t height, coordf_t print_z,
|
||||
{
|
||||
}
|
||||
|
||||
/// Removes references to self and clears regions
|
||||
Layer::~Layer()
|
||||
{
|
||||
// remove references to self
|
||||
@ -34,25 +37,28 @@ Layer::~Layer()
|
||||
this->clear_regions();
|
||||
}
|
||||
|
||||
/// Getter for this->_id
|
||||
size_t
|
||||
Layer::id() const
|
||||
{
|
||||
return this->_id;
|
||||
}
|
||||
|
||||
/// Setter for this->_id
|
||||
void
|
||||
Layer::set_id(size_t id)
|
||||
{
|
||||
this->_id = id;
|
||||
}
|
||||
|
||||
|
||||
/// Getter for this->regions.size()
|
||||
size_t
|
||||
Layer::region_count() const
|
||||
{
|
||||
return this->regions.size();
|
||||
}
|
||||
|
||||
/// Deletes all regions using this->delete_region()
|
||||
void
|
||||
Layer::clear_regions()
|
||||
{
|
||||
@ -60,6 +66,7 @@ Layer::clear_regions()
|
||||
this->delete_region(i);
|
||||
}
|
||||
|
||||
/// Creates a LayerRegion from a PrintRegion and adds it to this->regions
|
||||
LayerRegion*
|
||||
Layer::add_region(PrintRegion* print_region)
|
||||
{
|
||||
@ -68,6 +75,7 @@ Layer::add_region(PrintRegion* print_region)
|
||||
return region;
|
||||
}
|
||||
|
||||
/// Deletes an individual region
|
||||
void
|
||||
Layer::delete_region(int idx)
|
||||
{
|
||||
@ -77,7 +85,8 @@ Layer::delete_region(int idx)
|
||||
delete item;
|
||||
}
|
||||
|
||||
// merge all regions' slices to get islands
|
||||
/// Merge all regions' slices to get islands
|
||||
//TODO: is this right?
|
||||
void
|
||||
Layer::make_slices()
|
||||
{
|
||||
@ -115,6 +124,7 @@ Layer::make_slices()
|
||||
this->slices.expolygons.push_back(slices[o]);
|
||||
}
|
||||
|
||||
/// Iterates over all of the LayerRegion and invokes LayerRegion->merge_slices()
|
||||
void
|
||||
Layer::merge_slices()
|
||||
{
|
||||
@ -123,6 +133,7 @@ Layer::merge_slices()
|
||||
}
|
||||
}
|
||||
|
||||
/// Uses LayerRegion->slices.any_internal_contains(item)
|
||||
template <class T>
|
||||
bool
|
||||
Layer::any_internal_region_slice_contains(const T &item) const
|
||||
@ -134,6 +145,7 @@ Layer::any_internal_region_slice_contains(const T &item) const
|
||||
}
|
||||
template bool Layer::any_internal_region_slice_contains<Polyline>(const Polyline &item) const;
|
||||
|
||||
/// Uses LayerRegion->slices.any_bottom_contains(item)
|
||||
template <class T>
|
||||
bool
|
||||
Layer::any_bottom_region_slice_contains(const T &item) const
|
||||
@ -145,10 +157,8 @@ Layer::any_bottom_region_slice_contains(const T &item) const
|
||||
}
|
||||
template bool Layer::any_bottom_region_slice_contains<Polyline>(const Polyline &item) const;
|
||||
|
||||
|
||||
// Here the perimeters are created cummulatively for all layer regions sharing the same parameters influencing the perimeters.
|
||||
// The perimeter paths and the thin fills (ExtrusionEntityCollection) are assigned to the first compatible layer region.
|
||||
// The resulting fill surface is split back among the originating regions.
|
||||
/// The perimeter paths and the thin fills (ExtrusionEntityCollection) are assigned to the first compatible layer region.
|
||||
/// The resulting fill surface is split back among the originating regions.
|
||||
void
|
||||
Layer::make_perimeters()
|
||||
{
|
||||
@ -232,6 +242,8 @@ Layer::make_perimeters()
|
||||
}
|
||||
}
|
||||
|
||||
/// Iterates over all of the LayerRegion and invokes LayerRegion->make_fill()
|
||||
/// Asserts that the fills created are not NULL
|
||||
void
|
||||
Layer::make_fills()
|
||||
{
|
||||
@ -249,15 +261,15 @@ Layer::make_fills()
|
||||
}
|
||||
}
|
||||
|
||||
// This function analyzes slices of a region (SurfaceCollection slices).
|
||||
// Each region slice (instance of Surface) is analyzed, whether it is supported or whether it is the top surface.
|
||||
// Initially all slices are of type S_TYPE_INTERNAL.
|
||||
// Slices are compared against the top / bottom slices and regions and classified to the following groups:
|
||||
// S_TYPE_TOP - Part of a region, which is not covered by any upper layer. This surface will be filled with a top solid infill.
|
||||
// S_TYPE_BOTTOMBRIDGE - Part of a region, which is not fully supported, but it hangs in the air, or it hangs losely on a support or a raft.
|
||||
// S_TYPE_BOTTOM - Part of a region, which is not supported by the same region, but it is supported either by another region, or by a soluble interface layer.
|
||||
// S_TYPE_INTERNAL - Part of a region, which is supported by the same region type.
|
||||
// If a part of a region is of S_TYPE_BOTTOM and S_TYPE_TOP, the S_TYPE_BOTTOM wins.
|
||||
/// Analyzes slices of a region (SurfaceCollection slices).
|
||||
/// Each region slice (instance of Surface) is analyzed, whether it is supported or whether it is the top surface.
|
||||
/// Initially all slices are of type S_TYPE_INTERNAL.
|
||||
/// Slices are compared against the top / bottom slices and regions and classified to the following groups:
|
||||
/// S_TYPE_TOP - Part of a region, which is not covered by any upper layer. This surface will be filled with a top solid infill.
|
||||
/// S_TYPE_BOTTOMBRIDGE - Part of a region, which is not fully supported, but it hangs in the air, or it hangs losely on a support or a raft.
|
||||
/// S_TYPE_BOTTOM - Part of a region, which is not supported by the same region, but it is supported either by another region, or by a soluble interface layer.
|
||||
/// S_TYPE_INTERNAL - Part of a region, which is supported by the same region type.
|
||||
/// If a part of a region is of S_TYPE_BOTTOM and S_TYPE_TOP, the S_TYPE_BOTTOM wins.
|
||||
void
|
||||
Layer::detect_surfaces_type()
|
||||
{
|
||||
@ -423,6 +435,7 @@ Layer::detect_surfaces_type()
|
||||
}
|
||||
}
|
||||
|
||||
///Iterates over all LayerRegions and invokes LayerRegion->process_external_surfaces
|
||||
void
|
||||
Layer::process_external_surfaces()
|
||||
{
|
||||
|
@ -31,97 +31,126 @@ class LayerRegion
|
||||
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
|
||||
/// Collection of surfaces generated by slicing the original geometry
|
||||
/// Divided by type top/bottom/internal
|
||||
SurfaceCollection slices;
|
||||
|
||||
// collection of extrusion paths/loops filling gaps
|
||||
/// Collection of extrusion paths/loops filling gaps
|
||||
ExtrusionEntityCollection thin_fills;
|
||||
|
||||
// collection of surfaces for infill generation
|
||||
/// Collection of surfaces for infill generation
|
||||
SurfaceCollection fill_surfaces;
|
||||
|
||||
// collection of expolygons representing the bridged areas (thus not
|
||||
// needing support material)
|
||||
/// Collection of expolygons representing the bridged areas (thus not
|
||||
/// needing support material)
|
||||
Polygons bridged;
|
||||
|
||||
// collection of polylines representing the unsupported bridge edges
|
||||
/// Collection of polylines representing the unsupported bridge edges
|
||||
PolylineCollection unsupported_bridge_edges;
|
||||
|
||||
// ordered collection of extrusion paths/loops to build all perimeters
|
||||
// (this collection contains only ExtrusionEntityCollection objects)
|
||||
/// Ordered collection of extrusion paths/loops to build all perimeters
|
||||
/// (this collection contains only ExtrusionEntityCollection objects)
|
||||
ExtrusionEntityCollection perimeters;
|
||||
|
||||
// ordered collection of extrusion paths to fill surfaces
|
||||
// (this collection contains only ExtrusionEntityCollection objects)
|
||||
/// Ordered collection of extrusion paths to fill surfaces
|
||||
/// (this collection contains only ExtrusionEntityCollection objects)
|
||||
ExtrusionEntityCollection fills;
|
||||
|
||||
/// Flow object which provides methods to predict material spacing.
|
||||
Flow flow(FlowRole role, bool bridge = false, double width = -1) const;
|
||||
/// Merges this->slices
|
||||
void merge_slices();
|
||||
/// Preprocesses fill surfaces
|
||||
void prepare_fill_surfaces();
|
||||
/// Generates and stores the perimeters and thin fills
|
||||
void make_perimeters(const SurfaceCollection &slices, SurfaceCollection* fill_surfaces);
|
||||
/// Generate infills for a LayerRegion.
|
||||
void make_fill();
|
||||
/// Processes external surfaces for bridges and top/bottom surfaces
|
||||
void process_external_surfaces();
|
||||
/// Gets the smallest fillable area
|
||||
double infill_area_threshold() const;
|
||||
|
||||
private:
|
||||
/// Pointer to associated Layer
|
||||
Layer *_layer;
|
||||
/// Pointer to associated PrintRegion
|
||||
PrintRegion *_region;
|
||||
/// Mutex object for slices.
|
||||
mutable boost::mutex _slices_mutex;
|
||||
|
||||
///Constructor
|
||||
LayerRegion(Layer *layer, PrintRegion *region)
|
||||
: _layer(layer), _region(region) {};
|
||||
///Destructor
|
||||
~LayerRegion() {};
|
||||
};
|
||||
|
||||
|
||||
/// A std::vector of LayerRegion Pointers
|
||||
typedef std::vector<LayerRegion*> LayerRegionPtrs;
|
||||
|
||||
class Layer {
|
||||
friend class PrintObject;
|
||||
|
||||
public:
|
||||
/// ID number
|
||||
size_t id() const;
|
||||
/// Setter for this->_id
|
||||
void set_id(size_t id);
|
||||
/// Getter for _object
|
||||
PrintObject* object() { return this->_object; };
|
||||
const PrintObject* object() const { return this->_object; };
|
||||
|
||||
Layer *upper_layer;
|
||||
Layer *lower_layer;
|
||||
LayerRegionPtrs regions;
|
||||
bool slicing_errors;
|
||||
coordf_t slice_z; // Z used for slicing in unscaled coordinates
|
||||
coordf_t print_z; // Z used for printing in unscaled coordinates
|
||||
coordf_t height; // layer height in unscaled coordinates
|
||||
|
||||
// collection of expolygons generated by slicing the original geometry;
|
||||
// also known as 'islands' (all regions and surface types are merged here)
|
||||
ExPolygonCollection slices;
|
||||
Layer *upper_layer; ///< Pointer to layer above
|
||||
Layer *lower_layer; ///< Pointer to layer below
|
||||
LayerRegionPtrs regions; ///< Vector of pointers to the LayerRegions of this layer
|
||||
bool slicing_errors; ///< Presence of slicing errors
|
||||
coordf_t slice_z; ///< Z used for slicing in unscaled coordinates
|
||||
coordf_t print_z; ///< Z used for printing in unscaled coordinates
|
||||
coordf_t height; ///< layer height in unscaled coordinates
|
||||
|
||||
ExPolygonCollection slices; ///< collection of expolygons generated by slicing the original geometry;
|
||||
///< also known as 'islands' (all regions and surface types are merged here)
|
||||
|
||||
/// Returns the number of regions
|
||||
size_t region_count() const;
|
||||
/// Gets a region at a specific id
|
||||
LayerRegion* get_region(size_t idx) { return this->regions.at(idx); };
|
||||
/// Gets a region at a specific id as const
|
||||
const LayerRegion* get_region(size_t idx) const { return this->regions.at(idx); };
|
||||
LayerRegion* add_region(PrintRegion* print_region);
|
||||
|
||||
/// Adds a PrintRegion
|
||||
LayerRegion* add_region(PrintRegion* print_region);
|
||||
/// Merge all regions' slices to get islands
|
||||
void make_slices();
|
||||
/// Merges all of the LayerRegions' slices
|
||||
void merge_slices();
|
||||
/// Template which iterates over all of the LayerRegion for internally containing the argument
|
||||
template <class T> bool any_internal_region_slice_contains(const T &item) const;
|
||||
/// Template which iterates over all of the LayerRegion for containing on the bottom the argument
|
||||
template <class T> bool any_bottom_region_slice_contains(const T &item) const;
|
||||
/// Creates the perimeters cummulatively for all layer regions sharing the same parameters influencing the perimeters.
|
||||
void make_perimeters();
|
||||
/// Makes fills for all the LayerRegion
|
||||
void make_fills();
|
||||
/// Determines the type of surface (top/bottombridge/bottom/internal) each region is
|
||||
void detect_surfaces_type();
|
||||
/// Processes the external surfaces
|
||||
void process_external_surfaces();
|
||||
|
||||
protected:
|
||||
size_t _id; // sequential number of layer, 0-based
|
||||
PrintObject* _object;
|
||||
size_t _id; ///< sequential number of layer, 0-based
|
||||
PrintObject* _object; ///< Associated PrintObject
|
||||
|
||||
/// Constructor
|
||||
Layer(size_t id, PrintObject *object, coordf_t height, coordf_t print_z,
|
||||
coordf_t slice_z);
|
||||
/// Destructor
|
||||
virtual ~Layer();
|
||||
|
||||
/// Deletes all regions
|
||||
void clear_regions();
|
||||
/// Deletes a specific region
|
||||
void delete_region(int idx);
|
||||
};
|
||||
|
||||
@ -130,14 +159,22 @@ class SupportLayer : public Layer {
|
||||
friend class PrintObject;
|
||||
|
||||
public:
|
||||
/// Collection of support islands.
|
||||
/// Populated in SupportMaterial.pm in sub generate_toolpaths
|
||||
ExPolygonCollection support_islands;
|
||||
/// Collection of support fills.
|
||||
/// Populated in SupportMaterial.pm in sub generate_toolpaths
|
||||
ExtrusionEntityCollection support_fills;
|
||||
/// Collection of support interface fills.
|
||||
/// Populated in SupportMaterial.pm in sub generate_toolpaths
|
||||
ExtrusionEntityCollection support_interface_fills;
|
||||
|
||||
protected:
|
||||
/// Constructor
|
||||
SupportLayer(size_t id, PrintObject *object, coordf_t height,
|
||||
coordf_t print_z, coordf_t slice_z)
|
||||
: Layer(id, object, height, print_z, slice_z) {};
|
||||
/// Destructor
|
||||
virtual ~SupportLayer() {};
|
||||
};
|
||||
|
||||
|
@ -8,6 +8,7 @@
|
||||
|
||||
namespace Slic3r {
|
||||
|
||||
/// Creates a new Flow object with the arguments and the variables of this LayerRegion
|
||||
Flow
|
||||
LayerRegion::flow(FlowRole role, bool bridge, double width) const
|
||||
{
|
||||
@ -21,6 +22,7 @@ LayerRegion::flow(FlowRole role, bool bridge, double width) const
|
||||
);
|
||||
}
|
||||
|
||||
/// Merges this->slices with union_ex, and then repopulates this->slices.surfaces
|
||||
void
|
||||
LayerRegion::merge_slices()
|
||||
{
|
||||
@ -33,6 +35,8 @@ LayerRegion::merge_slices()
|
||||
this->slices.surfaces.push_back(Surface(stInternal, *expoly));
|
||||
}
|
||||
|
||||
/// Creates a new PerimeterGenerator object
|
||||
/// Which will return the perimeters by its construction
|
||||
void
|
||||
LayerRegion::make_perimeters(const SurfaceCollection &slices, SurfaceCollection* fill_surfaces)
|
||||
{
|
||||
@ -66,8 +70,11 @@ LayerRegion::make_perimeters(const SurfaceCollection &slices, SurfaceCollection*
|
||||
g.process();
|
||||
}
|
||||
|
||||
// This function reads layer->slices and lower_layer->slices
|
||||
// and writes this->bridged and this->fill_surfaces, so it's thread-safe.
|
||||
/// Processes bridges with holes which are internal features.
|
||||
/// Detects same-orientation bridges and merges them.
|
||||
/// Processes and groups top and bottom surfaces
|
||||
/// This function reads layer->slices and lower_layer->slices
|
||||
/// and writes this->bridged and this->fill_surfaces, so it's thread-safe.
|
||||
void
|
||||
LayerRegion::process_external_surfaces()
|
||||
{
|
||||
@ -220,6 +227,8 @@ LayerRegion::process_external_surfaces()
|
||||
this->fill_surfaces = std::move(new_surfaces);
|
||||
}
|
||||
|
||||
/// If no solid layers are requested, turns top/bottom surfaces to internal
|
||||
/// Turns too small internal regions into solid regions according to the user setting
|
||||
void
|
||||
LayerRegion::prepare_fill_surfaces()
|
||||
{
|
||||
@ -259,6 +268,7 @@ LayerRegion::prepare_fill_surfaces()
|
||||
}
|
||||
}
|
||||
|
||||
/// Gets smallest area by squaring the Flow's scaled spacing
|
||||
double
|
||||
LayerRegion::infill_area_threshold() const
|
||||
{
|
||||
|
@ -8,23 +8,24 @@
|
||||
|
||||
namespace Slic3r {
|
||||
|
||||
/// Struct for the main attributes of a Surface
|
||||
/// Used for comparing properties
|
||||
struct SurfaceGroupAttrib
|
||||
{
|
||||
SurfaceGroupAttrib() : is_solid(false), fw(0.f), pattern(-1) {}
|
||||
/// True iff all all three attributes are the same
|
||||
bool operator==(const SurfaceGroupAttrib &other) const
|
||||
{ return is_solid == other.is_solid && fw == other.fw && pattern == other.pattern; }
|
||||
bool is_solid;
|
||||
float fw;
|
||||
// pattern is of type InfillPattern, -1 for an unset pattern.
|
||||
int pattern;
|
||||
bool is_solid; ///< if a solid infill should be used
|
||||
float fw; ///< flow Width
|
||||
int pattern; ///< pattern is of type InfillPattern, -1 for an unset pattern.
|
||||
};
|
||||
|
||||
// Generate infills for a LayerRegion.
|
||||
// The LayerRegion at this point of time may contain
|
||||
// surfaces of various types (internal/bridge/top/bottom/solid).
|
||||
// The infills are generated on the groups of surfaces with a compatible type.
|
||||
// Fills an array of ExtrusionPathCollection objects containing the infills generated now
|
||||
// and the thin fills generated by generate_perimeters().
|
||||
/// The LayerRegion at this point of time may contain
|
||||
/// surfaces of various types (internal/bridge/top/bottom/solid).
|
||||
/// The infills are generated on the groups of surfaces with a compatible type.
|
||||
/// Fills an array of ExtrusionPathCollection objects containing the infills generated now
|
||||
/// and the thin fills generated by generate_perimeters().
|
||||
void
|
||||
LayerRegion::make_fill()
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user