Comparar commits
14 Commits
| Autor | SHA1 | Data | |
|---|---|---|---|
| e84ec85ca7 | |||
| 5f7ce40b89 | |||
| c97097a7e2 | |||
| 44612c2e71 | |||
| d1f64718ea | |||
| a9390abd61 | |||
| d3837f7efe | |||
| 1890d51b03 | |||
| 6d9eef9fa9 | |||
| 76df240798 | |||
| 0425676f13 | |||
| ebd308f229 | |||
| cad9a12ade | |||
| 95b2034739 |
@@ -7,14 +7,8 @@
|
||||
NUL
|
||||
*.gcode
|
||||
|
||||
## Directories used for other stuff
|
||||
Trash/*
|
||||
output/*
|
||||
callgrind/*
|
||||
|
||||
## Building result.
|
||||
build/*
|
||||
debug_build/*
|
||||
*.pyc
|
||||
*.exe
|
||||
*.a
|
||||
|
||||
+1
-1
@@ -91,6 +91,7 @@ set(engine_SRCS # Except main.cpp.
|
||||
src/Wireframe2gcode.cpp
|
||||
|
||||
src/infill/NoZigZagConnectorProcessor.cpp
|
||||
src/infill/SpaghettiInfill.cpp
|
||||
src/infill/ZigzagConnectorProcessorConnectedEndPieces.cpp
|
||||
src/infill/ZigzagConnectorProcessorDisconnectedEndPieces.cpp
|
||||
src/infill/ZigzagConnectorProcessorEndPieces.cpp
|
||||
@@ -106,7 +107,6 @@ set(engine_SRCS # Except main.cpp.
|
||||
src/progress/Progress.cpp
|
||||
src/progress/ProgressStageEstimator.cpp
|
||||
|
||||
src/settings/PathConfigStorage.cpp
|
||||
src/settings/SettingConfig.cpp
|
||||
src/settings/SettingContainer.cpp
|
||||
src/settings/SettingRegistry.cpp
|
||||
|
||||
+282
-183
Diferenças do arquivo suprimidas por serem muito extensas
Carregar Diff
+69
-42
@@ -74,19 +74,18 @@ private:
|
||||
|
||||
std::vector<FanSpeedLayerTimeSettings> fan_speed_layer_time_settings_per_extruder; //!< The settings used relating to minimal layer time and fan speeds. Configured for each extruder.
|
||||
|
||||
|
||||
GCodePlanner::PlanningState planner_state;
|
||||
|
||||
Point last_position_planned; //!< The position of the head before planning the next layer
|
||||
int current_extruder_planned; //!< The extruder train in use before planning the next layer
|
||||
bool is_inside_mesh_layer_part; //!< Whether the last position was inside a layer part (used in combing)
|
||||
public:
|
||||
FffGcodeWriter(SettingsBase* settings_)
|
||||
: SettingsMessenger(settings_)
|
||||
, max_object_height(0)
|
||||
, layer_plan_buffer(this, gcode)
|
||||
, extruder_prime_is_planned {} // initialize all values in array with [false]
|
||||
, planner_state{ no_point
|
||||
, 0 // changed somewhere early in FffGcodeWriter::writeGCode
|
||||
, false
|
||||
}
|
||||
, last_position_planned(no_point)
|
||||
, current_extruder_planned(0) // changed somewhere early in FffGcodeWriter::writeGCode
|
||||
, is_inside_mesh_layer_part(false)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -173,6 +172,17 @@ private:
|
||||
* \param[out] storage The data storage to which to save the configurations
|
||||
*/
|
||||
void setConfigRetraction(SliceDataStorage& storage);
|
||||
|
||||
/*!
|
||||
* Initialize the GcodePathConfig config parameters which don't change over
|
||||
* all layers, for each feature.
|
||||
*
|
||||
* The features are: skirt or brim, support and for each mesh: outer wall,
|
||||
* inner walls, skin, infill (and combined infill).
|
||||
*
|
||||
* \param[out] storage The data storage to which to save the configurations.
|
||||
*/
|
||||
void initConfigs(SliceDataStorage& storage);
|
||||
|
||||
/*!
|
||||
* Get the extruder with which to start the print.
|
||||
@@ -182,7 +192,7 @@ private:
|
||||
*
|
||||
* \param[in] storage where to get settings from.
|
||||
*/
|
||||
unsigned int getStartExtruder(const SliceDataStorage& storage);
|
||||
unsigned int getStartExtruder(SliceDataStorage& storage);
|
||||
|
||||
/*!
|
||||
* Set temperatures and perform initial priming.
|
||||
@@ -192,14 +202,14 @@ private:
|
||||
* \param[in] storage where the slice data is stored.
|
||||
* \param[in] start_extruder_nr The extruder with which to start the print.
|
||||
*/
|
||||
void processStartingCode(const SliceDataStorage& storage, const unsigned int start_extruder_nr);
|
||||
void processStartingCode(SliceDataStorage& storage, const unsigned int start_extruder_nr);
|
||||
|
||||
/*!
|
||||
* Move up and over the already printed meshgroups to print the next meshgroup.
|
||||
*
|
||||
* \param[in] storage where the slice data is stored.
|
||||
*/
|
||||
void processNextMeshGroupCode(const SliceDataStorage& storage);
|
||||
void processNextMeshGroupCode(SliceDataStorage& storage);
|
||||
|
||||
/*!
|
||||
* Add raft layer plans onto the FffGcodeWriter::layer_plan_buffer
|
||||
@@ -207,7 +217,7 @@ private:
|
||||
* \param[in,out] storage where the slice data is stored.
|
||||
* \param total_layers The total number of layers.
|
||||
*/
|
||||
void processRaft(const SliceDataStorage& storage, unsigned int total_layers);
|
||||
void processRaft(SliceDataStorage& storage, unsigned int total_layers);
|
||||
|
||||
/*!
|
||||
* Convert the polygon data of a layer into a layer plan on the FffGcodeWriter::layer_plan_buffer
|
||||
@@ -218,16 +228,15 @@ private:
|
||||
* \param[in] storage where the slice data is stored.
|
||||
* \param layer_nr The index of the layer to write the gcode of.
|
||||
* \param total_layers The total number of layers.
|
||||
* \return The layer plans
|
||||
*/
|
||||
GCodePlanner& processLayer(const SliceDataStorage& storage, int layer_nr, unsigned int total_layers) const;
|
||||
void processLayer(SliceDataStorage& storage, int layer_nr, unsigned int total_layers);
|
||||
|
||||
/*!
|
||||
* Whether the extruders need to be primed separately just before they are used.
|
||||
*
|
||||
* \return whether the extruders need to be primed separately just before they are used
|
||||
*/
|
||||
bool getExtrudersNeedPrimeDuringFirstLayer() const;
|
||||
bool getExtrudersNeedPrimeDuringFirstLayer();
|
||||
|
||||
/*!
|
||||
* Plan priming of all used extruders which haven't been primed yet
|
||||
@@ -235,7 +244,7 @@ private:
|
||||
* \param layer_plan The initial planning of the g-code of the layer.
|
||||
* \param layer_nr The index of the layer to write the gcode of.
|
||||
*/
|
||||
void ensureAllExtrudersArePrimed(const SliceDataStorage& storage, GCodePlanner& layer_plan, const int layer_nr) const;
|
||||
void ensureAllExtrudersArePrimed(SliceDataStorage& storage, GCodePlanner& layer_plan, const int layer_nr);
|
||||
|
||||
/*!
|
||||
* Add the skirt or the brim to the layer plan \p gcodeLayer.
|
||||
@@ -245,7 +254,7 @@ private:
|
||||
* \param extruder_nr The extruder train for which to process the skirt or
|
||||
* brim.
|
||||
*/
|
||||
void processSkirtBrim(const SliceDataStorage& storage, GCodePlanner& gcodeLayer, unsigned int extruder_nr) const;
|
||||
void processSkirtBrim(SliceDataStorage& storage, GCodePlanner& gcodeLayer, unsigned int extruder_nr);
|
||||
|
||||
/*!
|
||||
* Adds the ooze shield to the layer plan \p gcodeLayer.
|
||||
@@ -254,7 +263,7 @@ private:
|
||||
* \param gcodeLayer The initial planning of the gcode of the layer.
|
||||
* \param layer_nr The index of the layer to write the gcode of.
|
||||
*/
|
||||
void processOozeShield(const SliceDataStorage& storage, GCodePlanner& gcodeLayer, unsigned int layer_nr) const;
|
||||
void processOozeShield(SliceDataStorage& storage, GCodePlanner& gcodeLayer, unsigned int layer_nr);
|
||||
|
||||
/*!
|
||||
* Adds the draft protection screen to the layer plan \p gcodeLayer.
|
||||
@@ -263,7 +272,7 @@ private:
|
||||
* \param gcodeLayer The initial planning of the gcode of the layer.
|
||||
* \param layer_nr The index of the layer to write the gcode of.
|
||||
*/
|
||||
void processDraftShield(const SliceDataStorage& storage, GCodePlanner& gcodeLayer, unsigned int layer_nr) const;
|
||||
void processDraftShield(SliceDataStorage& storage, GCodePlanner& gcodeLayer, unsigned int layer_nr);
|
||||
|
||||
/*!
|
||||
* Calculate in which order to plan the extruders
|
||||
@@ -272,7 +281,7 @@ private:
|
||||
* \param current_extruder The current extruder with which we last printed
|
||||
* \return A vector of pairs of extruder numbers coupled with the mesh indices ordered on print order for that extruder.
|
||||
*/
|
||||
std::vector<int> calculateExtruderOrder(const SliceDataStorage& storage, int current_extruder) const;
|
||||
std::vector<int> calculateExtruderOrder(SliceDataStorage& storage, int current_extruder);
|
||||
|
||||
/*!
|
||||
* Calculate in which order to plan the meshes of a specific extruder
|
||||
@@ -281,95 +290,114 @@ private:
|
||||
* \param extruder_nr The extruder for which to determine the order
|
||||
* \return A vector of pairs of extruder numbers coupled with the mesh indices ordered on print order for that extruder.
|
||||
*/
|
||||
std::vector<unsigned int> calculateMeshOrder(const SliceDataStorage& storage, int extruder_nr) const;
|
||||
std::vector<unsigned int> calculateMeshOrder(SliceDataStorage& storage, int extruder_nr);
|
||||
|
||||
/*!
|
||||
* Add a single layer from a single mesh-volume to the layer plan \p gcodeLayer in mesh surface mode.
|
||||
*
|
||||
* \param[in] storage where the slice data is stored.
|
||||
* \param mesh The mesh to add to the layer plan \p gcodeLayer.
|
||||
* \param mesh_config the line config with which to print a print feature
|
||||
* \param gcodeLayer The initial planning of the gcode of the layer.
|
||||
* \param layer_nr The index of the layer to write the gcode of.
|
||||
*
|
||||
*/
|
||||
void addMeshLayerToGCode_meshSurfaceMode(const SliceDataStorage& storage, const SliceMeshStorage* mesh, const PathConfigStorage::MeshPathConfigs& mesh_config, GCodePlanner& gcodeLayer, int layer_nr) const;
|
||||
void addMeshLayerToGCode_meshSurfaceMode(SliceDataStorage& storage, SliceMeshStorage* mesh, GCodePlanner& gcodeLayer, int layer_nr);
|
||||
|
||||
/*!
|
||||
* Add the open polylines from a single layer from a single mesh-volume to the layer plan \p gcodeLayer for mesh the surface modes.
|
||||
*
|
||||
* \param[in] storage where the slice data is stored.
|
||||
* \param mesh The mesh for which to add to the layer plan \p gcodeLayer.
|
||||
* \param mesh_config the line config with which to print a print feature
|
||||
* \param gcodeLayer The initial planning of the gcode of the layer.
|
||||
* \param layer_nr The index of the layer to write the gcode of.
|
||||
*
|
||||
*/
|
||||
void addMeshOpenPolyLinesToGCode(const SliceDataStorage& storage, const SliceMeshStorage* mesh, const PathConfigStorage::MeshPathConfigs& mesh_config, GCodePlanner& gcode_layer, int layer_nr) const;
|
||||
void addMeshOpenPolyLinesToGCode(SliceDataStorage& storage, SliceMeshStorage* mesh, GCodePlanner& gcode_layer, int layer_nr);
|
||||
|
||||
/*!
|
||||
* Add a single layer from a single mesh-volume to the layer plan \p gcode_layer.
|
||||
*
|
||||
* \param[in] storage where the slice data is stored.
|
||||
* \param mesh The mesh to add to the layer plan \p gcode_layer.
|
||||
* \param mesh_config the line config with which to print a print feature
|
||||
* \param gcode_layer The initial planning of the gcode of the layer.
|
||||
* \param layer_nr The index of the layer to write the gcode of.
|
||||
*
|
||||
*/
|
||||
void addMeshLayerToGCode(const SliceDataStorage& storage, const SliceMeshStorage* mesh, const PathConfigStorage::MeshPathConfigs& mesh_config, GCodePlanner& gcode_layer, int layer_nr) const;
|
||||
void addMeshLayerToGCode(SliceDataStorage& storage, SliceMeshStorage* mesh, GCodePlanner& gcode_layer, int layer_nr);
|
||||
|
||||
/*!
|
||||
* Add a single part from a given layer of a mesh-volume to the layer plan \p gcode_layer.
|
||||
*
|
||||
* \param[in] storage where the slice data is stored.
|
||||
* \param mesh The mesh to add to the layer plan \p gcode_layer.
|
||||
* \param mesh_config the line config with which to print a print feature
|
||||
* \param part The part to add
|
||||
* \param gcode_layer The initial planning of the gcode of the layer.
|
||||
* \param layer_nr The index of the layer to write the gcode of.
|
||||
*
|
||||
*/
|
||||
void addMeshPartToGCode(const SliceDataStorage& storage, const SliceMeshStorage* mesh, const PathConfigStorage::MeshPathConfigs& mesh_config, const SliceLayerPart& part, GCodePlanner& gcode_layer, int layer_nr) const;
|
||||
|
||||
void addMeshPartToGCode(SliceDataStorage& storage, SliceMeshStorage* mesh, SliceLayerPart& part, GCodePlanner& gcode_layer, int layer_nr);
|
||||
|
||||
/*!
|
||||
* Add sparse infill for a given part in a layer plan.
|
||||
*
|
||||
* \param gcodeLayer The initial planning of the gcode of the layer.
|
||||
* \param mesh The mesh for which to add to the layer plan \p gcodeLayer.
|
||||
* \param part The part for which to create gcode
|
||||
* \param layer_nr The current layer number.
|
||||
* \param infill_line_distance The distance between the infill lines
|
||||
* \param infill_overlap The distance by which the infill overlaps with the wall insets.
|
||||
* \param fillAngle The angle in the XY plane at which the infill is generated.
|
||||
*/
|
||||
void processInfill(GCodePlanner& gcodeLayer, SliceMeshStorage* mesh, SliceLayerPart& part, unsigned int layer_nr, int infill_line_distance, int infill_overlap, int fillAngle);
|
||||
|
||||
/*!
|
||||
* Add spaghetti infill for a given part in a layer plan.
|
||||
*
|
||||
* \param gcodeLayer The initial planning of the gcode of the layer.
|
||||
* \param mesh The mesh for which to add to the layer plan \p gcodeLayer.
|
||||
* \param part The part for which to create gcode
|
||||
* \param layer_nr The current layer number.
|
||||
* \param infill_line_distance The distance between the infill lines
|
||||
* \param infill_overlap The distance by which the infill overlaps with the wall insets.
|
||||
* \param fillAngle The angle in the XY plane at which the infill is generated.
|
||||
*/
|
||||
void processSpaghettiInfill(GCodePlanner& gcodeLayer, SliceMeshStorage* mesh, SliceLayerPart& part, unsigned int layer_nr, int infill_line_distance, int infill_overlap, int fillAngle);
|
||||
|
||||
/*!
|
||||
* Add thicker (multiple layers) sparse infill for a given part in a layer plan.
|
||||
*
|
||||
* \param gcodeLayer The initial planning of the gcode of the layer.
|
||||
* \param mesh The mesh for which to add to the layer plan \p gcodeLayer.
|
||||
* \param mesh_config the line config with which to print a print feature
|
||||
* \param part The part for which to create gcode
|
||||
* \param layer_nr The current layer number.
|
||||
* \param infill_line_distance The distance between the infill lines
|
||||
* \param infill_overlap The distance by which the infill overlaps with the wall insets.
|
||||
* \param fillAngle The angle in the XY plane at which the infill is generated.
|
||||
*/
|
||||
void processMultiLayerInfill(GCodePlanner& gcodeLayer, const SliceMeshStorage* mesh, const PathConfigStorage::MeshPathConfigs& mesh_config, const SliceLayerPart& part, unsigned int layer_nr, int infill_line_distance, int infill_overlap, int fillAngle) const;
|
||||
void processMultiLayerInfill(GCodePlanner& gcodeLayer, SliceMeshStorage* mesh, SliceLayerPart& part, unsigned int layer_nr, int infill_line_distance, int infill_overlap, int fillAngle);
|
||||
|
||||
/*!
|
||||
* Add normal sparse infill for a given part in a layer.
|
||||
* \param gcodeLayer The initial planning of the gcode of the layer.
|
||||
* \param mesh The mesh for which to add to the layer plan \p gcodeLayer.
|
||||
* \param mesh_config the line config with which to print a print feature
|
||||
* \param part The part for which to create gcode
|
||||
* \param layer_nr The current layer number.
|
||||
* \param infill_line_distance The distance between the infill lines
|
||||
* \param infill_overlap The distance by which the infill overlaps with the wall insets.
|
||||
* \param fillAngle The angle in the XY plane at which the infill is generated.
|
||||
*/
|
||||
void processSingleLayerInfill(GCodePlanner& gcodeLayer, const SliceMeshStorage* mesh, const PathConfigStorage::MeshPathConfigs& mesh_config, const SliceLayerPart& part, unsigned int layer_nr, int infill_line_distance, int infill_overlap, int fillAngle) const;
|
||||
void processSingleLayerInfill(GCodePlanner& gcodeLayer, SliceMeshStorage* mesh, SliceLayerPart& part, unsigned int layer_nr, int infill_line_distance, int infill_overlap, int fillAngle);
|
||||
|
||||
/*!
|
||||
* Generate the insets for the walls of a given layer part.
|
||||
* \param gcodeLayer The initial planning of the gcode of the layer.
|
||||
* \param mesh The mesh for which to add to the layer plan \p gcodeLayer.
|
||||
* \param mesh_config the line config with which to print a print feature
|
||||
* \param part The part for which to create gcode
|
||||
* \param layer_nr The current layer number.
|
||||
* \param z_seam_type dir3ective for where to start the outer paerimeter of a part
|
||||
* \param z_seam_pos The location near where to start the outer inset in case \p z_seam_type is 'back'
|
||||
*/
|
||||
void processInsets(GCodePlanner& gcodeLayer, const SliceMeshStorage* mesh, const PathConfigStorage::MeshPathConfigs& mesh_config, const SliceLayerPart& part, unsigned int layer_nr, EZSeamType z_seam_type, Point z_seam_pos) const;
|
||||
void processInsets(GCodePlanner& gcodeLayer, SliceMeshStorage* mesh, SliceLayerPart& part, unsigned int layer_nr, EZSeamType z_seam_type, Point z_seam_pos);
|
||||
|
||||
|
||||
/*!
|
||||
@@ -380,13 +408,12 @@ private:
|
||||
*
|
||||
* \param gcodeLayer The initial planning of the gcode of the layer.
|
||||
* \param mesh The mesh for which to add to the layer plan \p gcodeLayer.
|
||||
* \param mesh_config the line config with which to print a print feature
|
||||
* \param part The part for which to create gcode
|
||||
* \param layer_nr The current layer number.
|
||||
* \param skin_overlap The distance by which the skin overlaps with the wall insets and the distance by which the perimeter gaps overlap with adjacent print features.
|
||||
* \param fillAngle The angle in the XY plane at which the infill is generated.
|
||||
*/
|
||||
void processSkinAndPerimeterGaps(GCodePlanner& gcode_layer, const SliceMeshStorage* mesh, const PathConfigStorage::MeshPathConfigs& mesh_config, const SliceLayerPart& part, unsigned int layer_nr, int skin_overlap, int infill_angle) const;
|
||||
void processSkinAndPerimeterGaps(cura::GCodePlanner& gcode_layer, cura::SliceMeshStorage* mesh, cura::SliceLayerPart& part, unsigned int layer_nr, int skin_overlap, int infill_angle);
|
||||
|
||||
/*!
|
||||
* Add the support to the layer plan \p gcodeLayer of the current layer for all support parts with the given \p extruder_nr.
|
||||
@@ -395,7 +422,7 @@ private:
|
||||
* \param layer_nr The index of the layer to write the gcode of.
|
||||
* \return whether any support was added to the layer plan
|
||||
*/
|
||||
bool addSupportToGCode(const SliceDataStorage& storage, GCodePlanner& gcodeLayer, int layer_nr, int extruder_nr) const;
|
||||
bool addSupportToGCode(SliceDataStorage& storage, GCodePlanner& gcodeLayer, int layer_nr, int extruder_nr);
|
||||
/*!
|
||||
* Add the support lines/walls to the layer plan \p gcodeLayer of the current layer.
|
||||
* \param[in] storage where the slice data is stored.
|
||||
@@ -403,7 +430,7 @@ private:
|
||||
* \param layer_nr The index of the layer to write the gcode of.
|
||||
* \return whether any support infill was added to the layer plan
|
||||
*/
|
||||
bool addSupportInfillToGCode(const SliceDataStorage& storage, GCodePlanner& gcodeLayer, int layer_nr) const;
|
||||
bool addSupportInfillToGCode(SliceDataStorage& storage, GCodePlanner& gcodeLayer, int layer_nr);
|
||||
/*!
|
||||
* Add the support skins to the layer plan \p gcodeLayer of the current layer.
|
||||
* \param[in] storage where the slice data is stored.
|
||||
@@ -411,7 +438,7 @@ private:
|
||||
* \param layer_nr The index of the layer to write the gcode of.
|
||||
* \return whether any support skin was added to the layer plan
|
||||
*/
|
||||
bool addSupportRoofsToGCode(const SliceDataStorage& storage, GCodePlanner& gcodeLayer, int layer_nr) const;
|
||||
bool addSupportRoofsToGCode(SliceDataStorage& storage, GCodePlanner& gcodeLayer, int layer_nr);
|
||||
|
||||
/*!
|
||||
* Change to a new extruder, and add the prime tower instructions if the new extruder is different from the last.
|
||||
@@ -423,7 +450,7 @@ private:
|
||||
* \param layer_nr The index of the layer to write the gcode of.
|
||||
* \param extruder_nr The extruder to which to switch
|
||||
*/
|
||||
void setExtruder_addPrime(const SliceDataStorage& storage, GCodePlanner& gcode_layer, int layer_nr, int extruder_nr) const;
|
||||
void setExtruder_addPrime(SliceDataStorage& storage, GCodePlanner& gcode_layer, int layer_nr, int extruder_nr);
|
||||
|
||||
/*!
|
||||
* Add the prime tower gcode for the current layer.
|
||||
@@ -432,7 +459,7 @@ private:
|
||||
* \param layer_nr The index of the layer to write the gcode of.
|
||||
* \param prev_extruder The current extruder with which we last printed.
|
||||
*/
|
||||
void addPrimeTower(const SliceDataStorage& storage, GCodePlanner& gcodeLayer, int layer_nr, int prev_extruder) const;
|
||||
void addPrimeTower(SliceDataStorage& storage, GCodePlanner& gcodeLayer, int layer_nr, int prev_extruder);
|
||||
|
||||
/*!
|
||||
* Add the end gcode and set all temperatures to zero.
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
#include <algorithm>
|
||||
#include <map> // multimap (ordered map allowing duplicate keys)
|
||||
#include <omp.h>
|
||||
|
||||
#include "utils/math.h"
|
||||
#include "utils/algorithm.h"
|
||||
@@ -16,6 +15,7 @@
|
||||
#include "WallsComputation.h"
|
||||
#include "SkirtBrim.h"
|
||||
#include "skin.h"
|
||||
#include "infill/SpaghettiInfill.h"
|
||||
#include "infill.h"
|
||||
#include "raft.h"
|
||||
#include "progress/Progress.h"
|
||||
@@ -346,24 +346,12 @@ void FffPolygonGenerator::processBasicWallsSkinInfill(SliceDataStorage& storage,
|
||||
|
||||
|
||||
// walls
|
||||
unsigned int processed_layer_count = 0;
|
||||
#pragma omp parallel for default(none) shared(mesh_layer_count, mesh, inset_skin_progress_estimate, processed_layer_count) schedule(dynamic)
|
||||
for (unsigned int layer_number = 0; layer_number < mesh.layers.size(); layer_number++)
|
||||
{
|
||||
logDebug("Processing insets for layer %i of %i\n", layer_number, mesh_layer_count);
|
||||
processInsets(mesh, layer_number);
|
||||
#ifdef _OPENMP
|
||||
if (omp_get_thread_num() == 0)
|
||||
#endif
|
||||
{ // progress estimation is done only in one thread so that no two threads message progress at the same time
|
||||
int _processed_layer_count;
|
||||
#pragma omp atomic read
|
||||
_processed_layer_count = processed_layer_count;
|
||||
double progress = inset_skin_progress_estimate.progress(_processed_layer_count);
|
||||
Progress::messageProgress(Progress::Stage::INSET_SKIN, progress * 100, 100);
|
||||
}
|
||||
#pragma omp atomic
|
||||
processed_layer_count++;
|
||||
double progress = inset_skin_progress_estimate.progress(layer_number);
|
||||
Progress::messageProgress(Progress::Stage::INSET_SKIN, progress * 100, 100);
|
||||
}
|
||||
|
||||
ProgressEstimatorLinear* skin_estimator = new ProgressEstimatorLinear(mesh_layer_count);
|
||||
@@ -394,33 +382,16 @@ void FffPolygonGenerator::processBasicWallsSkinInfill(SliceDataStorage& storage,
|
||||
{
|
||||
mesh_max_bottom_layer_count = std::max(mesh_max_bottom_layer_count, mesh.getSettingAsCount("bottom_layers"));
|
||||
}
|
||||
|
||||
processed_layer_count = 0;
|
||||
#pragma omp parallel default(none) shared(mesh_layer_count, mesh, mesh_max_bottom_layer_count, process_infill, inset_skin_progress_estimate, processed_layer_count)
|
||||
for (unsigned int layer_number = 0; layer_number < mesh.layers.size(); layer_number++)
|
||||
{
|
||||
|
||||
#pragma omp for schedule(dynamic)
|
||||
for (unsigned int layer_number = 0; layer_number < mesh.layers.size(); layer_number++)
|
||||
logDebug("Processing skins and infill layer %i of %i\n", layer_number, mesh_layer_count);
|
||||
if (!mesh.getSettingBoolean("magic_spiralize") || static_cast<int>(layer_number) < mesh_max_bottom_layer_count) //Only generate up/downskin and infill for the first X layers when spiralize is choosen.
|
||||
{
|
||||
logDebug("Processing skins and infill layer %i of %i\n", layer_number, mesh_layer_count);
|
||||
if (!mesh.getSettingBoolean("magic_spiralize") || static_cast<int>(layer_number) < mesh_max_bottom_layer_count) //Only generate up/downskin and infill for the first X layers when spiralize is choosen.
|
||||
{
|
||||
processSkinsAndInfill(mesh, layer_number, process_infill);
|
||||
}
|
||||
#ifdef _OPENMP
|
||||
if (omp_get_thread_num() == 0)
|
||||
#endif
|
||||
{ // progress estimation is done only in one thread so that no two threads message progress at the same time
|
||||
int _processed_layer_count;
|
||||
#pragma omp atomic read
|
||||
_processed_layer_count = processed_layer_count;
|
||||
double progress = inset_skin_progress_estimate.progress(_processed_layer_count);
|
||||
Progress::messageProgress(Progress::Stage::INSET_SKIN, progress * 100, 100);
|
||||
}
|
||||
#pragma omp atomic
|
||||
processed_layer_count++;
|
||||
}
|
||||
processSkinsAndInfill(mesh, layer_number, process_infill);
|
||||
}
|
||||
double progress = inset_skin_progress_estimate.progress(layer_number);
|
||||
Progress::messageProgress(Progress::Stage::INSET_SKIN, progress * 100, 100);
|
||||
}
|
||||
}
|
||||
|
||||
void FffPolygonGenerator::processInfillMesh(SliceDataStorage& storage, unsigned int mesh_order_idx, std::vector<unsigned int>& mesh_order)
|
||||
@@ -496,18 +467,27 @@ void FffPolygonGenerator::processInfillMesh(SliceDataStorage& storage, unsigned
|
||||
|
||||
void FffPolygonGenerator::processDerivedWallsSkinInfill(SliceMeshStorage& mesh)
|
||||
{
|
||||
// create gradual infill areas
|
||||
SkinInfillAreaComputation::generateGradualInfill(mesh, mesh.getSettingInMicrons("gradual_infill_step_height"), mesh.getSettingAsCount("gradual_infill_steps"));
|
||||
|
||||
//SubDivCube Pre-compute Octree
|
||||
if (mesh.getSettingAsFillMethod("infill_pattern") == EFillMethod::CUBICSUBDIV)
|
||||
// generate spaghetti infill filling areas and volumes
|
||||
if (mesh.getSettingBoolean("spaghetti_infill_enabled"))
|
||||
{
|
||||
SubDivCube::precomputeOctree(mesh);
|
||||
SpaghettiInfill::generateSpaghettiInfill(mesh);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
// combine infill
|
||||
unsigned int combined_infill_layers = std::max(1U, round_divide(mesh.getSettingInMicrons("infill_sparse_thickness"), std::max(getSettingInMicrons("layer_height"), (coord_t)1))); //How many infill layers to combine to obtain the requested sparse thickness.
|
||||
combineInfillLayers(mesh,combined_infill_layers);
|
||||
// create gradual infill areas
|
||||
SkinInfillAreaComputation::generateGradualInfill(mesh, mesh.getSettingInMicrons("gradual_infill_step_height"), mesh.getSettingAsCount("gradual_infill_steps"));
|
||||
|
||||
//SubDivCube Pre-compute Octree
|
||||
if (mesh.getSettingAsFillMethod("infill_pattern") == EFillMethod::CUBICSUBDIV)
|
||||
{
|
||||
SubDivCube::precomputeOctree(mesh);
|
||||
}
|
||||
|
||||
// combine infill
|
||||
unsigned int combined_infill_layers = std::max(1U, round_divide(mesh.getSettingInMicrons("infill_sparse_thickness"), std::max(getSettingInMicrons("layer_height"), (coord_t)1))); //How many infill layers to combine to obtain the requested sparse thickness.
|
||||
combineInfillLayers(mesh,combined_infill_layers);
|
||||
}
|
||||
|
||||
// fuzzy skin
|
||||
if (mesh.getSettingBoolean("magic_fuzzy_skin_enabled"))
|
||||
@@ -516,12 +496,6 @@ void FffPolygonGenerator::processDerivedWallsSkinInfill(SliceMeshStorage& mesh)
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* This function is executed in a parallel region based on layer_nr.
|
||||
* When modifying make sure any changes does not introduce data races.
|
||||
*
|
||||
* processInsets only reads and writes data for the current layer
|
||||
*/
|
||||
void FffPolygonGenerator::processInsets(SliceMeshStorage& mesh, unsigned int layer_nr)
|
||||
{
|
||||
SliceLayer* layer = &mesh.layers[layer_nr];
|
||||
@@ -603,18 +577,8 @@ void FffPolygonGenerator::removeEmptyFirstLayers(SliceDataStorage& storage, cons
|
||||
support_layers.erase(support_layers.begin(), support_layers.begin() + n_empty_first_layers);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* This function is executed in a parallel region based on layer_nr.
|
||||
* When modifying make sure any changes does not introduce data races.
|
||||
*
|
||||
* generateSkins read (depend on) data from mesh.layers[*].parts[*].insets and write mesh.layers[n].parts[*].skin_parts
|
||||
* generateInfill read mesh.layers[n].parts[*].{insets,skin_parts,boundingBox} and write mesh.layers[n].parts[*].infill_area
|
||||
*
|
||||
* processSkinsAndInfill read (depend on) mesh.layers[*].parts[*].{insets,boundingBox}.
|
||||
* write mesh.layers[n].parts[*].{skin_parts,infill_area}.
|
||||
*/
|
||||
void FffPolygonGenerator::processSkinsAndInfill(SliceMeshStorage& mesh, unsigned int layer_nr, bool process_infill)
|
||||
|
||||
void FffPolygonGenerator::processSkinsAndInfill(SliceMeshStorage& mesh, unsigned int layer_nr, bool process_infill)
|
||||
{
|
||||
if (mesh.getSettingAsSurfaceMode("magic_mesh_surface_mode") == ESurfaceMode::SURFACE)
|
||||
{
|
||||
|
||||
+64
-33
@@ -6,74 +6,105 @@
|
||||
namespace cura
|
||||
{
|
||||
|
||||
GCodePathConfig::GCodePathConfig(const GCodePathConfig& other)
|
||||
: type(other.type)
|
||||
, speed_derivatives(other.speed_derivatives)
|
||||
, line_width(other.line_width)
|
||||
, layer_thickness(other.layer_thickness)
|
||||
, flow(other.flow)
|
||||
, extrusion_mm3_per_mm(other.extrusion_mm3_per_mm)
|
||||
GCodePathConfig::BasicConfig::BasicConfig()
|
||||
: speed(0)
|
||||
, acceleration(0)
|
||||
, jerk(0)
|
||||
, line_width(0)
|
||||
, flow(100)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
|
||||
GCodePathConfig::GCodePathConfig(PrintFeatureType type, int line_width, int layer_height, double flow, GCodePathConfig::SpeedDerivatives speed_derivatives)
|
||||
: type(type)
|
||||
, speed_derivatives(speed_derivatives)
|
||||
GCodePathConfig::BasicConfig::BasicConfig(double speed, double acceleration, double jerk, int line_width, double flow)
|
||||
: speed(speed)
|
||||
, acceleration(acceleration)
|
||||
, jerk(jerk)
|
||||
, line_width(line_width)
|
||||
, layer_thickness(layer_height)
|
||||
, flow(flow)
|
||||
, extrusion_mm3_per_mm(calculateExtrusion())
|
||||
{
|
||||
}
|
||||
|
||||
void GCodePathConfig::smoothSpeed(GCodePathConfig::SpeedDerivatives first_layer_config, int layer_nr, int max_speed_layer_nr)
|
||||
void GCodePathConfig::BasicConfig::set(double speed, double acceleration, double jerk, int line_width, double flow)
|
||||
{
|
||||
double max_speed_layer = max_speed_layer_nr;
|
||||
speed_derivatives.speed = (speed_derivatives.speed * layer_nr) / max_speed_layer + (first_layer_config.speed * (max_speed_layer - layer_nr) / max_speed_layer);
|
||||
speed_derivatives.acceleration = (speed_derivatives.acceleration * layer_nr) / max_speed_layer + (first_layer_config.acceleration * (max_speed_layer - layer_nr) / max_speed_layer);
|
||||
speed_derivatives.jerk = (speed_derivatives.jerk * layer_nr) / max_speed_layer + (first_layer_config.jerk * (max_speed_layer - layer_nr) / max_speed_layer);
|
||||
this->speed = speed;
|
||||
this->acceleration = acceleration;
|
||||
this->jerk = jerk;
|
||||
this->line_width = line_width;
|
||||
this->flow = flow;
|
||||
}
|
||||
|
||||
double GCodePathConfig::getExtrusionMM3perMM() const
|
||||
|
||||
GCodePathConfig::GCodePathConfig(PrintFeatureType type)
|
||||
: extrusion_mm3_per_mm(0.0)
|
||||
, type(type)
|
||||
{
|
||||
}
|
||||
|
||||
void GCodePathConfig::init(double speed, double acceleration, double jerk, int line_width, double flow)
|
||||
{
|
||||
iconic_config.set(speed, acceleration, jerk, line_width, flow);
|
||||
current_config = iconic_config;
|
||||
}
|
||||
|
||||
void GCodePathConfig::setLayerHeight(int layer_height)
|
||||
{
|
||||
this->layer_thickness = layer_height;
|
||||
calculateExtrusion();
|
||||
}
|
||||
|
||||
void GCodePathConfig::smoothSpeed(GCodePathConfig::BasicConfig first_layer_config, int layer_nr, double max_speed_layer)
|
||||
{
|
||||
current_config.speed = (iconic_config.speed * layer_nr) / max_speed_layer + (first_layer_config.speed * (max_speed_layer - layer_nr) / max_speed_layer);
|
||||
current_config.acceleration = (iconic_config.acceleration * layer_nr) / max_speed_layer + (first_layer_config.acceleration * (max_speed_layer - layer_nr) / max_speed_layer);
|
||||
current_config.jerk = (iconic_config.jerk * layer_nr) / max_speed_layer + (first_layer_config.jerk * (max_speed_layer - layer_nr) / max_speed_layer);
|
||||
}
|
||||
|
||||
void GCodePathConfig::setSpeedIconic()
|
||||
{
|
||||
current_config.speed = iconic_config.speed;
|
||||
current_config.acceleration = iconic_config.acceleration;
|
||||
current_config.jerk = iconic_config.jerk;
|
||||
}
|
||||
|
||||
double GCodePathConfig::getExtrusionMM3perMM()
|
||||
{
|
||||
return extrusion_mm3_per_mm;
|
||||
}
|
||||
|
||||
double GCodePathConfig::getSpeed() const
|
||||
double GCodePathConfig::getSpeed()
|
||||
{
|
||||
return speed_derivatives.speed;
|
||||
return current_config.speed;
|
||||
}
|
||||
|
||||
double GCodePathConfig::getAcceleration() const
|
||||
double GCodePathConfig::getAcceleration()
|
||||
{
|
||||
return speed_derivatives.acceleration;
|
||||
return current_config.acceleration;
|
||||
}
|
||||
|
||||
double GCodePathConfig::getJerk() const
|
||||
double GCodePathConfig::getJerk()
|
||||
{
|
||||
return speed_derivatives.jerk;
|
||||
return current_config.jerk;
|
||||
}
|
||||
|
||||
int GCodePathConfig::getLineWidth() const
|
||||
int GCodePathConfig::getLineWidth()
|
||||
{
|
||||
return line_width;
|
||||
return current_config.line_width;
|
||||
}
|
||||
|
||||
bool GCodePathConfig::isTravelPath() const
|
||||
bool GCodePathConfig::isTravelPath()
|
||||
{
|
||||
return line_width == 0;
|
||||
return current_config.line_width == 0;
|
||||
}
|
||||
|
||||
double GCodePathConfig::getFlowPercentage() const
|
||||
double GCodePathConfig::getFlowPercentage()
|
||||
{
|
||||
return flow;
|
||||
return current_config.flow;
|
||||
}
|
||||
|
||||
double GCodePathConfig::calculateExtrusion() const
|
||||
void GCodePathConfig::calculateExtrusion()
|
||||
{
|
||||
return INT2MM(line_width) * INT2MM(layer_thickness) * double(flow) / 100.0;
|
||||
extrusion_mm3_per_mm = INT2MM(current_config.line_width) * INT2MM(layer_thickness) * double(current_config.flow) / 100.0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
+47
-23
@@ -16,70 +16,94 @@ class GCodePathConfig
|
||||
friend class GCodePlannerTest;
|
||||
public:
|
||||
/*!
|
||||
* A simple wrapper class for all derivatives of position which are used when printing a line
|
||||
* The path config settings which may change from layer to layer
|
||||
*/
|
||||
struct SpeedDerivatives
|
||||
struct BasicConfig
|
||||
{
|
||||
double speed; //!< movement speed (mm/s)
|
||||
double acceleration; //!< acceleration of head movement (mm/s^2)
|
||||
double jerk; //!< jerk of the head movement (around stand still) as instantaneous speed change (mm/s)
|
||||
double jerk; //!< jerk of the head movement (around stand still) (mm/s^3)
|
||||
int line_width; //!< width of the line extruded
|
||||
double flow; //!< extrusion flow modifier in %
|
||||
BasicConfig(); //!< basic contructor initializing with inaccurate values
|
||||
BasicConfig(double speed, double acceleration, double jerk, int line_width, double flow); //!< basic contructor initializing all values
|
||||
void set(double speed, double acceleration, double jerk, int line_width, double flow); //!< Set all config values
|
||||
};
|
||||
const PrintFeatureType type; //!< name of the feature type
|
||||
private:
|
||||
SpeedDerivatives speed_derivatives; //!< The speed settings (and acceleration and jerk) of the extruded line. May be changed when smoothSpeed is called.
|
||||
const int line_width; //!< width of the line extruded
|
||||
const int layer_thickness; //!< current layer height in micron
|
||||
const double flow; //!< extrusion flow modifier in %
|
||||
const double extrusion_mm3_per_mm;//!< current mm^3 filament moved per mm line traversed
|
||||
BasicConfig iconic_config; //!< The basic path configuration iconic to this print feature type
|
||||
BasicConfig current_config; //!< The current path configuration for the current layer
|
||||
int layer_thickness; //!< current layer height in micron
|
||||
double extrusion_mm3_per_mm;//!< current mm^3 filament moved per mm line traversed
|
||||
public:
|
||||
GCodePathConfig(PrintFeatureType type, int line_width, int layer_height, double flow, SpeedDerivatives speed_derivatives); // , SpeedDerivatives slowdown_speed_derivatives, int layer_nr, int max_speed_layer_nr);
|
||||
const PrintFeatureType type; //!< name of the feature type
|
||||
|
||||
/*!
|
||||
* copy constructor
|
||||
* Basic constructor.
|
||||
*/
|
||||
GCodePathConfig(const GCodePathConfig& other);
|
||||
GCodePathConfig(PrintFeatureType type);
|
||||
|
||||
/*!
|
||||
* Initialize some of the member variables.
|
||||
*
|
||||
* \warning GCodePathConfig::setLayerHeight still has to be called before this object can be used.
|
||||
*
|
||||
* \param speed The regular speed with which to print this feature
|
||||
* \param line_width The line width for this feature
|
||||
* \param flow The flow modifier to apply to the extruded filament when printing this feature
|
||||
*/
|
||||
void init(double speed, double acceleration, double jerk, int line_width, double flow);
|
||||
|
||||
/*!
|
||||
* Set the layer height and (re)compute the extrusion_per_mm
|
||||
*/
|
||||
void setLayerHeight(int layer_height);
|
||||
|
||||
/*!
|
||||
* Set the speed to somewhere between the speed of @p first_layer_config and the iconic speed.
|
||||
*
|
||||
* \warning This functions should not be called with @p layer_nr > @p max_speed_layer !
|
||||
*
|
||||
* \warning Calling this function twice will smooth the speed more toward \p first_layer_config
|
||||
*
|
||||
* \param first_layer_config The speed settings at layer zero
|
||||
* \param layer_nr The layer number
|
||||
* \param max_speed_layer The layer number for which the speed_iconic should be used.
|
||||
*/
|
||||
void smoothSpeed(SpeedDerivatives first_layer_config, int layer_nr, int max_speed_layer);
|
||||
void smoothSpeed(BasicConfig first_layer_config, int layer_nr, double max_speed_layer);
|
||||
|
||||
/*!
|
||||
* Set the speed config to the iconic speed config, i.e. the normal speed of the feature type for which this is a config.
|
||||
*
|
||||
* Does the same for acceleration and jerk.
|
||||
*/
|
||||
void setSpeedIconic();
|
||||
|
||||
/*!
|
||||
* Can only be called after the layer height has been set (which is done while writing the gcode!)
|
||||
*/
|
||||
double getExtrusionMM3perMM() const;
|
||||
double getExtrusionMM3perMM();
|
||||
|
||||
/*!
|
||||
* Get the movement speed in mm/s
|
||||
*/
|
||||
double getSpeed() const;
|
||||
double getSpeed();
|
||||
|
||||
/*!
|
||||
* Get the current acceleration of this config
|
||||
*/
|
||||
double getAcceleration() const;
|
||||
double getAcceleration();
|
||||
|
||||
/*!
|
||||
* Get the current jerk of this config
|
||||
*/
|
||||
double getJerk() const;
|
||||
double getJerk();
|
||||
|
||||
int getLineWidth() const;
|
||||
int getLineWidth();
|
||||
|
||||
bool isTravelPath() const;
|
||||
bool isTravelPath();
|
||||
|
||||
double getFlowPercentage() const;
|
||||
double getFlowPercentage();
|
||||
|
||||
private:
|
||||
double calculateExtrusion() const;
|
||||
void calculateExtrusion();
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ void LayerPlanBuffer::flush()
|
||||
}
|
||||
while (!buffer.empty())
|
||||
{
|
||||
buffer.front()->writeGCode(gcode);
|
||||
buffer.front().writeGCode(gcode);
|
||||
if (CommandSocket::isInstantiated())
|
||||
{
|
||||
CommandSocket::getInstance()->flushGcode();
|
||||
@@ -324,7 +324,7 @@ void LayerPlanBuffer::insertFinalPrintTempCommand(std::vector<ExtruderPlan*>& ex
|
||||
|
||||
void LayerPlanBuffer::insertTempCommands()
|
||||
{
|
||||
if (buffer.back()->extruder_plans.size() == 0 || (buffer.back()->extruder_plans.size() == 1 && buffer.back()->extruder_plans[0].paths.size() == 0))
|
||||
if (buffer.back().extruder_plans.size() == 0 || (buffer.back().extruder_plans.size() == 1 && buffer.back().extruder_plans[0].paths.size() == 0))
|
||||
{ // disregard empty layer
|
||||
buffer.pop_back();
|
||||
return;
|
||||
@@ -332,9 +332,9 @@ void LayerPlanBuffer::insertTempCommands()
|
||||
|
||||
std::vector<ExtruderPlan*> extruder_plans;
|
||||
extruder_plans.reserve(buffer.size() * 2);
|
||||
for (GCodePlanner* layer_plan : buffer)
|
||||
for (GCodePlanner& layer_plan : buffer)
|
||||
{
|
||||
for (ExtruderPlan& extr_plan : layer_plan->extruder_plans)
|
||||
for (ExtruderPlan& extr_plan : layer_plan.extruder_plans)
|
||||
{
|
||||
extruder_plans.push_back(&extr_plan);
|
||||
}
|
||||
@@ -342,7 +342,7 @@ void LayerPlanBuffer::insertTempCommands()
|
||||
|
||||
|
||||
// insert commands for all extruder plans on this layer
|
||||
GCodePlanner& layer_plan = *buffer.back();
|
||||
GCodePlanner& layer_plan = buffer.back();
|
||||
for (unsigned int extruder_plan_idx = 0; extruder_plan_idx < layer_plan.extruder_plans.size(); extruder_plan_idx++)
|
||||
{
|
||||
unsigned int overall_extruder_plan_idx = extruder_plans.size() - layer_plan.extruder_plans.size() + extruder_plan_idx;
|
||||
|
||||
+9
-19
@@ -42,7 +42,7 @@ class LayerPlanBuffer : SettingsMessenger
|
||||
|
||||
std::vector<bool> extruder_used_in_meshgroup; //!< For each extruder whether it has already been planned once in this meshgroup. This is used to see whether we should heat to the initial_print_temp or to the printing_temperature
|
||||
public:
|
||||
std::list<GCodePlanner*> buffer; //!< The buffer containing several layer plans (GCodePlanner) before writing them to gcode.
|
||||
std::list<GCodePlanner> buffer; //!< The buffer containing several layer plans (GCodePlanner) before writing them to gcode.
|
||||
|
||||
LayerPlanBuffer(SettingsBaseVirtual* settings, GCodeExport& gcode)
|
||||
: SettingsMessenger(settings)
|
||||
@@ -54,39 +54,29 @@ public:
|
||||
{
|
||||
preheat_config.setConfig(settings);
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
* Push a new layer plan into the buffer
|
||||
* Place a new layer plan (GcodePlanner) by constructing it with the given arguments.
|
||||
* Pop back the oldest layer plan is it exceeds the buffer size and write it to gcode.
|
||||
*/
|
||||
void push(GCodePlanner& layer_plan)
|
||||
{
|
||||
buffer.push_back(&layer_plan);
|
||||
}
|
||||
|
||||
/*!
|
||||
* Process all layers in the buffer
|
||||
* This inserts the temperature commands to start warming for a given layer in earlier layers
|
||||
*
|
||||
* Pop out the earliest layer in the buffer if the buffer size is exceeded
|
||||
* \return A nullptr or the popped gcode_layer
|
||||
*/
|
||||
GCodePlanner* processBuffer()
|
||||
template<typename... Args>
|
||||
GCodePlanner& emplace_back(Args&&... constructor_args)
|
||||
{
|
||||
if (buffer.size() > 0)
|
||||
{
|
||||
insertTempCommands(); // insert preheat commands of the just completed layer plan (not the newly emplaced one)
|
||||
}
|
||||
buffer.emplace_back(constructor_args...);
|
||||
if (buffer.size() > buffer_size)
|
||||
{
|
||||
GCodePlanner* ret = buffer.front();
|
||||
buffer.front().writeGCode(gcode);
|
||||
if (CommandSocket::isInstantiated())
|
||||
{
|
||||
CommandSocket::getInstance()->flushGcode();
|
||||
}
|
||||
buffer.pop_front();
|
||||
return ret;
|
||||
}
|
||||
return nullptr;
|
||||
return buffer.back();
|
||||
}
|
||||
|
||||
/*!
|
||||
|
||||
@@ -17,7 +17,7 @@ class MergeInfillLines
|
||||
std::vector<GCodePath>& paths; //!< The paths currently under consideration
|
||||
ExtruderPlan& extruder_plan; //!< The extruder plan of the paths currently under consideration
|
||||
|
||||
const GCodePathConfig& travelConfig; //!< The travel settings used to see whether a path is a travel path or an extrusion path
|
||||
GCodePathConfig& travelConfig; //!< The travel settings used to see whether a path is a travel path or an extrusion path
|
||||
int64_t nozzle_size; //!< The diameter of the hole in the nozzle
|
||||
bool speed_equalize_flow_enabled; //!< Should the speed be varied with extrusion width
|
||||
double speed_equalize_flow_max; //!< Maximum speed when adjusting speed for flow
|
||||
@@ -64,18 +64,9 @@ public:
|
||||
/*!
|
||||
* Simple constructor only used by MergeInfillLines::isConvertible to easily convey the environment
|
||||
*/
|
||||
MergeInfillLines(GCodeExport& gcode, int layer_nr, std::vector<GCodePath>& paths, ExtruderPlan& extruder_plan, const GCodePathConfig& travelConfig, int64_t nozzle_size, bool speed_equalize_flow_enabled, double speed_equalize_flow_max)
|
||||
: gcode(gcode)
|
||||
, layer_nr(layer_nr)
|
||||
, paths(paths)
|
||||
, extruder_plan(extruder_plan)
|
||||
, travelConfig(travelConfig)
|
||||
, nozzle_size(nozzle_size)
|
||||
, speed_equalize_flow_enabled(speed_equalize_flow_enabled)
|
||||
, speed_equalize_flow_max(speed_equalize_flow_max)
|
||||
{
|
||||
}
|
||||
|
||||
MergeInfillLines(GCodeExport& gcode, int layer_nr, std::vector<GCodePath>& paths, ExtruderPlan& extruder_plan, GCodePathConfig& travelConfig, int64_t nozzle_size, bool speed_equalize_flow_enabled, double speed_equalize_flow_max)
|
||||
: gcode(gcode), layer_nr(layer_nr), paths(paths), extruder_plan(extruder_plan), travelConfig(travelConfig), nozzle_size(nozzle_size), speed_equalize_flow_enabled(speed_equalize_flow_enabled), speed_equalize_flow_max(speed_equalize_flow_max) { }
|
||||
|
||||
/*!
|
||||
* Check for lots of small moves and combine them into one large line.
|
||||
* Updates \p path_idx to the next path which is not combined.
|
||||
|
||||
+52
-14
@@ -15,7 +15,12 @@ namespace cura
|
||||
PrimeTower::PrimeTower(const SliceDataStorage& storage)
|
||||
: is_hollow(false)
|
||||
, wipe_from_middle(false)
|
||||
, current_pre_wipe_location_idx(0)
|
||||
{
|
||||
for (int extruder_nr = 0; extruder_nr < MAX_EXTRUDERS; extruder_nr++)
|
||||
{
|
||||
last_prime_tower_poly_printed[extruder_nr] = -1;
|
||||
}
|
||||
enabled = storage.getSettingBoolean("prime_tower_enable")
|
||||
&& storage.getSettingInMicrons("prime_tower_wall_thickness") > 10
|
||||
&& storage.getSettingInMicrons("prime_tower_size") > 10;
|
||||
@@ -25,6 +30,34 @@ PrimeTower::PrimeTower(const SliceDataStorage& storage)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void PrimeTower::initConfigs(const MeshGroup* meshgroup)
|
||||
{
|
||||
extruder_count = meshgroup->getExtruderCount();
|
||||
|
||||
for (int extr = 0; extr < extruder_count; extr++)
|
||||
{
|
||||
config_per_extruder.emplace_back(PrintFeatureType::Support);// so that visualization in the old Cura still works (TODO)
|
||||
}
|
||||
for (int extr = 0; extr < extruder_count; extr++)
|
||||
{
|
||||
const ExtruderTrain* train = meshgroup->getExtruderTrain(extr);
|
||||
config_per_extruder[extr].init(train->getSettingInMillimetersPerSecond("speed_prime_tower"), train->getSettingInMillimetersPerSecond("acceleration_prime_tower"), train->getSettingInMillimetersPerSecond("jerk_prime_tower"), train->getSettingInMicrons("prime_tower_line_width"), train->getSettingInPercentage("prime_tower_flow"));
|
||||
}
|
||||
}
|
||||
|
||||
void PrimeTower::setConfigs(const MeshGroup* meshgroup, const int layer_thickness)
|
||||
{
|
||||
extruder_count = meshgroup->getExtruderCount();
|
||||
|
||||
for (int extr = 0; extr < extruder_count; extr++)
|
||||
{
|
||||
GCodePathConfig& conf = config_per_extruder[extr];
|
||||
conf.setLayerHeight(layer_thickness);
|
||||
}
|
||||
}
|
||||
|
||||
void PrimeTower::generateGroundpoly(const SliceDataStorage& storage)
|
||||
{
|
||||
extruder_count = storage.meshgroup->getExtruderCount();
|
||||
@@ -94,13 +127,18 @@ void PrimeTower::generatePaths_denseInfill(const SliceDataStorage& storage)
|
||||
}
|
||||
|
||||
|
||||
void PrimeTower::addToGcode(const SliceDataStorage& storage, GCodePlanner& gcodeLayer, const GCodeExport& gcode, const int layer_nr, const int prev_extruder, const int new_extruder) const
|
||||
void PrimeTower::addToGcode(const SliceDataStorage& storage, GCodePlanner& gcodeLayer, const GCodeExport& gcode, const int layer_nr, const int prev_extruder, const int new_extruder)
|
||||
{
|
||||
if (!enabled)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (gcodeLayer.getPrimeTowerIsPlanned())
|
||||
bool prime_tower_added = false;
|
||||
for (int extruder = 0; extruder < storage.meshgroup->getExtruderCount() && !prime_tower_added; extruder++)
|
||||
{
|
||||
prime_tower_added = last_prime_tower_poly_printed[extruder] == int(layer_nr);
|
||||
}
|
||||
if (prime_tower_added)
|
||||
{ // don't print the prime tower if it has been printed already
|
||||
return;
|
||||
}
|
||||
@@ -121,7 +159,7 @@ void PrimeTower::addToGcode(const SliceDataStorage& storage, GCodePlanner& gcode
|
||||
// pre-wipe:
|
||||
if (pre_wipe)
|
||||
{
|
||||
preWipe(storage, gcodeLayer, layer_nr, new_extruder);
|
||||
preWipe(storage, gcodeLayer, new_extruder);
|
||||
}
|
||||
|
||||
addToGcode_denseInfill(gcodeLayer, layer_nr, new_extruder);
|
||||
@@ -131,21 +169,21 @@ void PrimeTower::addToGcode(const SliceDataStorage& storage, GCodePlanner& gcode
|
||||
{ //Make sure we wipe the old extruder on the prime tower.
|
||||
gcodeLayer.addTravel(post_wipe_point - gcode.getExtruderOffset(prev_extruder) + gcode.getExtruderOffset(new_extruder));
|
||||
}
|
||||
|
||||
gcodeLayer.setPrimeTowerIsPlanned();
|
||||
}
|
||||
|
||||
void PrimeTower::addToGcode_denseInfill(GCodePlanner& gcode_layer, const int layer_nr, const int extruder_nr) const
|
||||
void PrimeTower::addToGcode_denseInfill(GCodePlanner& gcodeLayer, const int layer_nr, const int extruder)
|
||||
{
|
||||
const ExtrusionMoves& pattern = patterns_per_extruder[extruder_nr][((layer_nr % 2) + 2) % 2]; // +2) %2 to handle negative layer numbers
|
||||
ExtrusionMoves& pattern = patterns_per_extruder[extruder][((layer_nr % 2) + 2) % 2]; // +2) %2 to handle negative layer numbers
|
||||
|
||||
const GCodePathConfig& config = gcode_layer.configs_storage.prime_tower_config_per_extruder[extruder_nr];
|
||||
GCodePathConfig& config = config_per_extruder[extruder];
|
||||
|
||||
gcode_layer.addPolygonsByOptimizer(pattern.polygons, &config);
|
||||
gcode_layer.addLinesByOptimizer(pattern.lines, &config, SpaceFillType::Lines);
|
||||
gcodeLayer.addPolygonsByOptimizer(pattern.polygons, &config);
|
||||
gcodeLayer.addLinesByOptimizer(pattern.lines, &config, SpaceFillType::Lines);
|
||||
|
||||
last_prime_tower_poly_printed[extruder] = layer_nr;
|
||||
}
|
||||
|
||||
Point PrimeTower::getLocationBeforePrimeTower(const SliceDataStorage& storage) const
|
||||
Point PrimeTower::getLocationBeforePrimeTower(const SliceDataStorage& storage)
|
||||
{
|
||||
Point ret(0, 0);
|
||||
int absolute_starting_points = 0;
|
||||
@@ -225,10 +263,10 @@ void PrimeTower::generateWipeLocations(const SliceDataStorage& storage)
|
||||
PolygonUtils::spreadDots(segment_start, segment_end, number_of_pre_wipe_locations, pre_wipe_locations);
|
||||
}
|
||||
|
||||
void PrimeTower::preWipe(const SliceDataStorage& storage, GCodePlanner& gcode_layer, const int layer_nr, const int extruder_nr) const
|
||||
void PrimeTower::preWipe(const SliceDataStorage& storage, GCodePlanner& gcode_layer, const int extruder_nr)
|
||||
{
|
||||
int current_pre_wipe_location_idx = (pre_wipe_location_skip * layer_nr) % number_of_pre_wipe_locations;
|
||||
const ClosestPolygonPoint wipe_location = pre_wipe_locations[current_pre_wipe_location_idx];
|
||||
current_pre_wipe_location_idx = (current_pre_wipe_location_idx + pre_wipe_location_skip) % number_of_pre_wipe_locations;
|
||||
|
||||
ExtruderTrain& train = *storage.meshgroup->getExtruderTrain(extruder_nr);
|
||||
const int inward_dist = train.getSettingInMicrons("machine_nozzle_size") * 3 / 2 ;
|
||||
@@ -256,7 +294,7 @@ void PrimeTower::preWipe(const SliceDataStorage& storage, GCodePlanner& gcode_la
|
||||
gcode_layer.addTravel(start);
|
||||
}
|
||||
float flow = 0.0001; // force this path being interpreted as an extrusion path, so that no Z hop will occur (TODO: really separately handle travel and extrusion moves)
|
||||
gcode_layer.addExtrusionMove(end, &gcode_layer.configs_storage.prime_tower_config_per_extruder[extruder_nr], SpaceFillType::None, flow);
|
||||
gcode_layer.addExtrusionMove(end, &config_per_extruder[extruder_nr], SpaceFillType::None, flow);
|
||||
}
|
||||
|
||||
void PrimeTower::subtractFromSupport(SliceDataStorage& storage)
|
||||
|
||||
+27
-5
@@ -34,6 +34,7 @@ private:
|
||||
Polygons lines;
|
||||
};
|
||||
int extruder_count; //!< number of extruders
|
||||
std::vector<GCodePathConfig> config_per_extruder; //!< Path config for prime tower for each extruder
|
||||
|
||||
bool is_hollow; //!< Whether the prime tower is hollow
|
||||
|
||||
@@ -46,6 +47,7 @@ private:
|
||||
const unsigned int pre_wipe_location_skip = 13; //!< How big the steps are when stepping through \ref PrimeTower::wipe_locations
|
||||
const unsigned int number_of_pre_wipe_locations = 21; //!< The required size of \ref PrimeTower::wipe_locations
|
||||
// note that the above are two consecutive numbers in the Fibonacci sequence
|
||||
int current_pre_wipe_location_idx; //!< Index into \ref PrimeTower::wipe_locations of where to pre-wipe the nozzle
|
||||
|
||||
public:
|
||||
bool enabled; //!< Whether the prime tower is enabled.
|
||||
@@ -61,6 +63,21 @@ public:
|
||||
*/
|
||||
PrimeTower(const SliceDataStorage& storage);
|
||||
|
||||
/*!
|
||||
* Initialize \ref PrimeTower::config_per_extruder with speed and line width settings.
|
||||
*
|
||||
* \param meshgroup Where to retrieve the setttings for each extruder
|
||||
*/
|
||||
void initConfigs(const MeshGroup* meshgroup);
|
||||
|
||||
/*!
|
||||
* Complete the \ref PrimeTower::config_per_extruder by settings the layer height.
|
||||
*
|
||||
* \param meshgroup Where to retrieve the setttings for each extruder
|
||||
* \param layer_thickness The current layer thickness
|
||||
*/
|
||||
void setConfigs(const MeshGroup* meshgroup, const int layer_thickness);
|
||||
|
||||
/*!
|
||||
* Generate the prime tower area to be used on each layer
|
||||
*
|
||||
@@ -87,7 +104,7 @@ public:
|
||||
* \param prev_extruder The previous extruder with which paths were planned; from which extruder a switch was made
|
||||
* \param new_extruder The switched to extruder with which the prime tower paths should be generated.
|
||||
*/
|
||||
void addToGcode(const SliceDataStorage& storage, GCodePlanner& gcode_layer, const GCodeExport& gcode, const int layer_nr, const int prev_extruder, const int new_extruder) const;
|
||||
void addToGcode(const SliceDataStorage& storage, GCodePlanner& gcode_layer, const GCodeExport& gcode, const int layer_nr, const int prev_extruder, const int new_extruder);
|
||||
|
||||
/*!
|
||||
* \brief Subtract the prime tower from the support areas in storage.
|
||||
@@ -98,6 +115,12 @@ public:
|
||||
void subtractFromSupport(SliceDataStorage& storage);
|
||||
|
||||
private:
|
||||
/*!
|
||||
* Layer number of the last layer in which a prime tower has been printed per extruder train.
|
||||
*
|
||||
* This is recorded per extruder to account for a prime tower per extruder, instead of the mixed prime tower.
|
||||
*/
|
||||
int last_prime_tower_poly_printed[MAX_EXTRUDERS];
|
||||
|
||||
/*!
|
||||
* Find an approriate representation for the point representing the location before going to the prime tower
|
||||
@@ -107,7 +130,7 @@ private:
|
||||
* \param storage where to get settings from
|
||||
* \return that location
|
||||
*/
|
||||
Point getLocationBeforePrimeTower(const SliceDataStorage& storage) const;
|
||||
Point getLocationBeforePrimeTower(const SliceDataStorage& storage);
|
||||
|
||||
/*!
|
||||
* \param storage where to get settings from
|
||||
@@ -136,17 +159,16 @@ private:
|
||||
* \param extruder The extruder we just switched to, with which the prime
|
||||
* tower paths should be drawn.
|
||||
*/
|
||||
void addToGcode_denseInfill(GCodePlanner& gcode_layer, const int layer_nr, const int extruder) const;
|
||||
void addToGcode_denseInfill(GCodePlanner& gcode_layer, const int layer_nr, const int extruder);
|
||||
|
||||
/*!
|
||||
* Plan the moves for wiping the current nozzles oozed material before starting to print the prime tower.
|
||||
*
|
||||
* \param storage where to get settings from
|
||||
* \param[out] gcode_layer where to add the planned paths for wiping
|
||||
* \param layer_nr The layer number of the \p gcode_layer
|
||||
* \param extruder_nr The current extruder
|
||||
*/
|
||||
void preWipe(const SliceDataStorage& storage, GCodePlanner& gcode_layer, const int layer_nr, const int extruder_nr) const;
|
||||
void preWipe(const SliceDataStorage& storage, GCodePlanner& gcode_layer, const int extruder_nr);
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -12,12 +12,6 @@ WallsComputation::WallsComputation(int wall_0_inset, int line_width_0, int line_
|
||||
{
|
||||
}
|
||||
|
||||
/*
|
||||
* This function is executed in a parallel region based on layer_nr.
|
||||
* When modifying make sure any changes does not introduce data races.
|
||||
*
|
||||
* generateInsets only reads and writes data for the current layer
|
||||
*/
|
||||
void WallsComputation::generateInsets(SliceLayerPart* part)
|
||||
{
|
||||
if (insetCount == 0)
|
||||
@@ -64,12 +58,6 @@ void WallsComputation::generateInsets(SliceLayerPart* part)
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* This function is executed in a parallel region based on layer_nr.
|
||||
* When modifying make sure any changes does not introduce data races.
|
||||
*
|
||||
* generateInsets only reads and writes data for the current layer
|
||||
*/
|
||||
void WallsComputation::generateInsets(SliceLayer* layer)
|
||||
{
|
||||
for(unsigned int partNr = 0; partNr < layer->parts.size(); partNr++)
|
||||
|
||||
+2
-2
@@ -389,7 +389,7 @@ void Weaver::chainify_polygons(Polygons& parts1, Point start_close_to, Polygons&
|
||||
{
|
||||
for (unsigned int prt = 0 ; prt < parts1.size(); prt++)
|
||||
{
|
||||
ConstPolygonRef upperPart = parts1[prt];
|
||||
const PolygonRef upperPart = parts1[prt];
|
||||
|
||||
ClosestPolygonPoint closestInPoly = PolygonUtils::findClosest(start_close_to, upperPart);
|
||||
|
||||
@@ -439,7 +439,7 @@ void Weaver::connect_polygons(Polygons& supporting, int z0, Polygons& supported,
|
||||
for (unsigned int prt = 0 ; prt < supported.size(); prt++)
|
||||
{
|
||||
|
||||
ConstPolygonRef upperPart(supported[prt]);
|
||||
const PolygonRef upperPart = supported[prt];
|
||||
|
||||
|
||||
parts.emplace_back(prt);
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@
|
||||
|
||||
namespace cura {
|
||||
|
||||
int bridgeAngle(Polygons outline, const SliceLayer* prevLayer)
|
||||
int bridgeAngle(Polygons outline, SliceLayer* prevLayer)
|
||||
{
|
||||
AABB boundaryBox(outline);
|
||||
//To detect if we have a bridge, first calculate the intersection of the current layer with the previous layer.
|
||||
|
||||
+1
-1
@@ -6,7 +6,7 @@ namespace cura {
|
||||
class Polygons;
|
||||
class SliceLayer;
|
||||
|
||||
int bridgeAngle(Polygons outline, const SliceLayer* prevLayer);
|
||||
int bridgeAngle(Polygons outline, SliceLayer* prevLayer);
|
||||
|
||||
}//namespace cura
|
||||
|
||||
|
||||
@@ -215,7 +215,7 @@ public:
|
||||
/*!
|
||||
* Adds closed polygon to the current path
|
||||
*/
|
||||
void sendPolygon(PrintFeatureType print_feature_type, ConstPolygonRef poly, int width);
|
||||
void sendPolygon(PrintFeatureType print_feature_type, Polygon poly, int width);
|
||||
private:
|
||||
/*!
|
||||
* Convert and add a point to the points buffer, each point being represented as two consecutive floats. All members adding a 2D point to the data should use this function.
|
||||
@@ -522,7 +522,7 @@ void CommandSocket::sendPolygons(PrintFeatureType type, const Polygons& polygons
|
||||
#endif
|
||||
}
|
||||
|
||||
void CommandSocket::sendPolygon(PrintFeatureType type, ConstPolygonRef polygon, int line_width)
|
||||
void CommandSocket::sendPolygon(PrintFeatureType type, Polygon& polygon, int line_width)
|
||||
{
|
||||
#ifdef ARCUS
|
||||
if (CommandSocket::isInstantiated())
|
||||
@@ -799,7 +799,7 @@ void CommandSocket::PathCompiler::sendLineTo(PrintFeatureType print_feature_type
|
||||
}
|
||||
}
|
||||
|
||||
void CommandSocket::PathCompiler::sendPolygon(PrintFeatureType print_feature_type, ConstPolygonRef polygon, int width)
|
||||
void CommandSocket::PathCompiler::sendPolygon(PrintFeatureType print_feature_type, Polygon polygon, int width)
|
||||
{
|
||||
if (polygon.size() < 2)
|
||||
{
|
||||
|
||||
@@ -64,7 +64,7 @@ public:
|
||||
/*!
|
||||
* Send a polygon to the front-end. This is used for the layerview in the GUI
|
||||
*/
|
||||
static void sendPolygon(cura::PrintFeatureType type, ConstPolygonRef polygon, int line_width);
|
||||
static void sendPolygon(cura::PrintFeatureType type, Polygon& polygon, int line_width);
|
||||
|
||||
/*!
|
||||
* Send a line to the front-end. This is used for the layerview in the GUI
|
||||
|
||||
@@ -270,7 +270,7 @@ void GCodeExport::setFlavor(EGCodeFlavor flavor)
|
||||
}
|
||||
}
|
||||
|
||||
EGCodeFlavor GCodeExport::getFlavor() const
|
||||
EGCodeFlavor GCodeExport::getFlavor()
|
||||
{
|
||||
return this->flavor;
|
||||
}
|
||||
@@ -775,7 +775,7 @@ void GCodeExport::switchExtruder(int new_extruder, const RetractionConfig& retra
|
||||
|
||||
bool force = true;
|
||||
bool extruder_switch = true;
|
||||
writeRetraction(retraction_config_old_extruder, force, extruder_switch);
|
||||
writeRetraction(const_cast<RetractionConfig&>(retraction_config_old_extruder), force, extruder_switch);
|
||||
|
||||
resetExtrusionValue(); // zero the E value on the old extruder, so that the current_e_value is registered on the old extruder
|
||||
|
||||
|
||||
+1
-1
@@ -188,7 +188,7 @@ public:
|
||||
Point getGcodePos(const int64_t x, const int64_t y, const int extruder_train) const;
|
||||
|
||||
void setFlavor(EGCodeFlavor flavor);
|
||||
EGCodeFlavor getFlavor() const;
|
||||
EGCodeFlavor getFlavor();
|
||||
|
||||
void setZ(int z);
|
||||
|
||||
|
||||
+140
-38
@@ -10,7 +10,7 @@
|
||||
namespace cura {
|
||||
|
||||
|
||||
ExtruderPlan::ExtruderPlan(int extruder, Point start_position, int layer_nr, bool is_initial_layer, int layer_thickness, const FanSpeedLayerTimeSettings& fan_speed_layer_time_settings, const RetractionConfig& retraction_config)
|
||||
ExtruderPlan::ExtruderPlan(int extruder, Point start_position, int layer_nr, bool is_initial_layer, int layer_thickness, FanSpeedLayerTimeSettings& fan_speed_layer_time_settings, const RetractionConfig& retraction_config)
|
||||
: extruder(extruder)
|
||||
, heated_pre_travel_time(0)
|
||||
, initial_printing_temperature(-1)
|
||||
@@ -56,7 +56,7 @@ double ExtruderPlan::getFanSpeed()
|
||||
}
|
||||
|
||||
|
||||
GCodePath* GCodePlanner::getLatestPathWithConfig(const GCodePathConfig* config, SpaceFillType space_fill_type, float flow, bool spiralize)
|
||||
GCodePath* GCodePlanner::getLatestPathWithConfig(GCodePathConfig* config, SpaceFillType space_fill_type, float flow, bool spiralize)
|
||||
{
|
||||
std::vector<GCodePath>& paths = extruder_plans.back().paths;
|
||||
if (paths.size() > 0 && paths.back().config == config && !paths.back().done && paths.back().flow == flow) // spiralize can only change when a travel path is in between
|
||||
@@ -81,26 +81,23 @@ void GCodePlanner::forceNewPathStart()
|
||||
paths[paths.size()-1].done = true;
|
||||
}
|
||||
|
||||
GCodePlanner::GCodePlanner(const SliceDataStorage& storage, int layer_nr, int z, int layer_thickness, PlanningState last_planned_state, const std::vector<FanSpeedLayerTimeSettings>& fan_speed_layer_time_settings_per_extruder, CombingMode combing_mode, int64_t comb_boundary_offset, bool travel_avoid_other_parts, int64_t travel_avoid_distance)
|
||||
GCodePlanner::GCodePlanner(SliceDataStorage& storage, int layer_nr, int z, int layer_thickness, Point last_position, int current_extruder, bool is_inside_mesh, std::vector<FanSpeedLayerTimeSettings>& fan_speed_layer_time_settings_per_extruder, CombingMode combing_mode, int64_t comb_boundary_offset, bool travel_avoid_other_parts, int64_t travel_avoid_distance)
|
||||
: storage(storage)
|
||||
, configs_storage(storage, layer_nr, layer_thickness)
|
||||
, layer_nr(layer_nr)
|
||||
, is_initial_layer(layer_nr == 0 - Raft::getTotalExtraLayers(storage))
|
||||
, z(z)
|
||||
, layer_thickness(layer_thickness)
|
||||
, start_position(last_planned_state.last_position)
|
||||
, lastPosition(last_planned_state.last_position)
|
||||
, has_prime_tower_planned(false)
|
||||
, last_extruder_previous_layer(last_planned_state.current_extruder)
|
||||
, last_planned_extruder_setting_base(storage.meshgroup->getExtruderTrain(last_planned_state.current_extruder))
|
||||
, start_position(last_position)
|
||||
, lastPosition(last_position)
|
||||
, last_extruder_previous_layer(current_extruder)
|
||||
, last_planned_extruder_setting_base(storage.meshgroup->getExtruderTrain(current_extruder))
|
||||
, comb_boundary_inside(computeCombBoundaryInside(combing_mode))
|
||||
, fan_speed_layer_time_settings_per_extruder(fan_speed_layer_time_settings_per_extruder)
|
||||
{
|
||||
int current_extruder = last_planned_state.current_extruder;
|
||||
extruder_plans.reserve(storage.meshgroup->getExtruderCount());
|
||||
extruder_plans.emplace_back(current_extruder, start_position, layer_nr, is_initial_layer, layer_thickness, fan_speed_layer_time_settings_per_extruder[current_extruder], storage.retraction_config_per_extruder[current_extruder]);
|
||||
comb = nullptr;
|
||||
was_inside = last_planned_state.is_inside_mesh_layer_part;
|
||||
was_inside = is_inside_mesh;
|
||||
is_inside = false; // assumes the next move will not be to inside a layer part (overwritten just before going into a layer part)
|
||||
if (combing_mode != CombingMode::OFF)
|
||||
{
|
||||
@@ -142,12 +139,12 @@ Polygons GCodePlanner::computeCombBoundaryInside(CombingMode combing_mode)
|
||||
else
|
||||
{
|
||||
Polygons comb_boundary;
|
||||
for (const SliceMeshStorage& mesh : storage.meshes)
|
||||
for (SliceMeshStorage& mesh : storage.meshes)
|
||||
{
|
||||
const SliceLayer& layer = mesh.layers[layer_nr];
|
||||
SliceLayer& layer = mesh.layers[layer_nr];
|
||||
if (mesh.getSettingAsCombingMode("retraction_combing") == CombingMode::NO_SKIN)
|
||||
{
|
||||
for (const SliceLayerPart& part : layer.parts)
|
||||
for (SliceLayerPart& part : layer.parts)
|
||||
{
|
||||
comb_boundary.add(part.infill_area);
|
||||
}
|
||||
@@ -244,12 +241,12 @@ void GCodePlanner::moveInsideCombBoundary(int distance)
|
||||
GCodePath& GCodePlanner::addTravel(Point p)
|
||||
{
|
||||
GCodePath* path = nullptr;
|
||||
const GCodePathConfig& travel_config = configs_storage.travel_config_per_extruder[getExtruder()];
|
||||
const RetractionConfig& retraction_config = storage.retraction_config_per_extruder[getExtruder()];
|
||||
GCodePathConfig& travel_config = storage.travel_config_per_extruder[getExtruder()];
|
||||
RetractionConfig& retraction_config = storage.retraction_config_per_extruder[getExtruder()];
|
||||
|
||||
bool combed = false;
|
||||
|
||||
const SettingsBaseVirtual* extr = getLastPlannedExtruderTrainSettings();
|
||||
SettingsBaseVirtual* extr = getLastPlannedExtruderTrainSettings();
|
||||
|
||||
const bool perform_z_hops = extr->getSettingBoolean("retraction_hop_enabled");
|
||||
|
||||
@@ -336,7 +333,7 @@ GCodePath& GCodePlanner::addTravel_simple(Point p, GCodePath* path)
|
||||
{
|
||||
if (path == nullptr)
|
||||
{
|
||||
path = getLatestPathWithConfig(&configs_storage.travel_config_per_extruder[getExtruder()], SpaceFillType::None);
|
||||
path = getLatestPathWithConfig(&storage.travel_config_per_extruder[getExtruder()], SpaceFillType::None);
|
||||
}
|
||||
path->points.push_back(p);
|
||||
lastPosition = p;
|
||||
@@ -352,27 +349,27 @@ void GCodePlanner::planPrime()
|
||||
forceNewPathStart();
|
||||
}
|
||||
|
||||
void GCodePlanner::addExtrusionMove(Point p, const GCodePathConfig* config, SpaceFillType space_fill_type, float flow, bool spiralize)
|
||||
void GCodePlanner::addExtrusionMove(Point p, GCodePathConfig* config, SpaceFillType space_fill_type, float flow, bool spiralize)
|
||||
{
|
||||
getLatestPathWithConfig(config, space_fill_type, flow, spiralize)->points.push_back(p);
|
||||
lastPosition = p;
|
||||
}
|
||||
|
||||
void GCodePlanner::addPolygon(ConstPolygonRef polygon, int start_idx, const GCodePathConfig* config, WallOverlapComputation* wall_overlap_computation, coord_t wall_0_wipe_dist, bool spiralize)
|
||||
void GCodePlanner::addPolygon(PolygonRef polygon, int start_idx, GCodePathConfig* config, WallOverlapComputation* wall_overlap_computation, coord_t wall_0_wipe_dist, bool spiralize, float flow_ratio)
|
||||
{
|
||||
Point p0 = polygon[start_idx];
|
||||
addTravel(p0);
|
||||
for (unsigned int point_idx = 1; point_idx < polygon.size(); point_idx++)
|
||||
{
|
||||
Point p1 = polygon[(start_idx + point_idx) % polygon.size()];
|
||||
float flow = (wall_overlap_computation)? wall_overlap_computation->getFlow(p0, p1) : 1.0;
|
||||
float flow = (wall_overlap_computation)? flow_ratio * wall_overlap_computation->getFlow(p0, p1) : flow_ratio;
|
||||
addExtrusionMove(p1, config, SpaceFillType::Polygons, flow, spiralize);
|
||||
p0 = p1;
|
||||
}
|
||||
if (polygon.size() > 2)
|
||||
{
|
||||
const Point& p1 = polygon[start_idx];
|
||||
float flow = (wall_overlap_computation)? wall_overlap_computation->getFlow(p0, p1) : 1.0;
|
||||
Point& p1 = polygon[start_idx];
|
||||
float flow = (wall_overlap_computation)? flow_ratio * wall_overlap_computation->getFlow(p0, p1) : flow_ratio;
|
||||
addExtrusionMove(p1, config, SpaceFillType::Polygons, flow, spiralize);
|
||||
|
||||
if (wall_0_wipe_dist > 0)
|
||||
@@ -406,7 +403,7 @@ void GCodePlanner::addPolygon(ConstPolygonRef polygon, int start_idx, const GCod
|
||||
}
|
||||
}
|
||||
|
||||
void GCodePlanner::addPolygonsByOptimizer(const Polygons& polygons, const GCodePathConfig* config, WallOverlapComputation* wall_overlap_computation, EZSeamType z_seam_type, Point z_seam_pos, coord_t wall_0_wipe_dist, bool spiralize)
|
||||
void GCodePlanner::addPolygonsByOptimizer(Polygons& polygons, GCodePathConfig* config, WallOverlapComputation* wall_overlap_computation, EZSeamType z_seam_type, Point z_seam_pos, coord_t wall_0_wipe_dist, bool spiralize, float flow_ratio)
|
||||
{
|
||||
if (polygons.size() == 0)
|
||||
{
|
||||
@@ -420,10 +417,10 @@ void GCodePlanner::addPolygonsByOptimizer(const Polygons& polygons, const GCodeP
|
||||
orderOptimizer.optimize();
|
||||
for (unsigned int poly_idx : orderOptimizer.polyOrder)
|
||||
{
|
||||
addPolygon(polygons[poly_idx], orderOptimizer.polyStart[poly_idx], config, wall_overlap_computation, wall_0_wipe_dist, spiralize);
|
||||
addPolygon(polygons[poly_idx], orderOptimizer.polyStart[poly_idx], config, wall_overlap_computation, wall_0_wipe_dist, spiralize, flow_ratio);
|
||||
}
|
||||
}
|
||||
void GCodePlanner::addLinesByOptimizer(const Polygons& polygons, const GCodePathConfig* config, SpaceFillType space_fill_type, int wipe_dist)
|
||||
void GCodePlanner::addLinesByOptimizer(Polygons& polygons, GCodePathConfig* config, SpaceFillType space_fill_type, int wipe_dist, float flow_ratio)
|
||||
{
|
||||
LineOrderOptimizer orderOptimizer(lastPosition);
|
||||
for (unsigned int line_idx = 0; line_idx < polygons.size(); line_idx++)
|
||||
@@ -433,13 +430,13 @@ void GCodePlanner::addLinesByOptimizer(const Polygons& polygons, const GCodePath
|
||||
orderOptimizer.optimize();
|
||||
for (int poly_idx : orderOptimizer.polyOrder)
|
||||
{
|
||||
ConstPolygonRef polygon = polygons[poly_idx];
|
||||
PolygonRef polygon = polygons[poly_idx];
|
||||
int start = orderOptimizer.polyStart[poly_idx];
|
||||
int end = 1 - start;
|
||||
const Point& p0 = polygon[start];
|
||||
Point& p0 = polygon[start];
|
||||
addTravel(p0);
|
||||
const Point& p1 = polygon[end];
|
||||
addExtrusionMove(p1, config, space_fill_type);
|
||||
Point& p1 = polygon[end];
|
||||
addExtrusionMove(p1, config, space_fill_type, flow_ratio);
|
||||
if (wipe_dist != 0)
|
||||
{
|
||||
int line_width = config->getLineWidth();
|
||||
@@ -556,7 +553,7 @@ TimeMaterialEstimates ExtruderPlan::computeNaiveTimeEstimates()
|
||||
|
||||
void ExtruderPlan::processFanSpeedAndMinimalLayerTime(bool force_minimal_layer_time)
|
||||
{
|
||||
const FanSpeedLayerTimeSettings& fsml = fan_speed_layer_time_settings;
|
||||
FanSpeedLayerTimeSettings& fsml = fan_speed_layer_time_settings;
|
||||
TimeMaterialEstimates estimates = computeNaiveTimeEstimates();
|
||||
totalPrintTime = estimates.getTotalTime();
|
||||
if (force_minimal_layer_time)
|
||||
@@ -639,6 +636,8 @@ void GCodePlanner::processFanSpeedAndMinimalLayerTime()
|
||||
|
||||
void GCodePlanner::writeGCode(GCodeExport& gcode)
|
||||
{
|
||||
completeConfigs();
|
||||
|
||||
CommandSocket::setLayerForSend(layer_nr);
|
||||
CommandSocket::setSendCurrentPosition( gcode.getPositionXY() );
|
||||
gcode.setLayerNr(layer_nr);
|
||||
@@ -654,7 +653,7 @@ void GCodePlanner::writeGCode(GCodeExport& gcode)
|
||||
gcode.setZ(z);
|
||||
|
||||
|
||||
const GCodePathConfig* last_extrusion_config = nullptr; // used to check whether we need to insert a TYPE comment in the gcode.
|
||||
GCodePathConfig* last_extrusion_config = nullptr; // used to check whether we need to insert a TYPE comment in the gcode.
|
||||
|
||||
int extruder = gcode.getExtruderNr();
|
||||
bool acceleration_enabled = storage.getSettingBoolean("acceleration_enabled");
|
||||
@@ -663,7 +662,7 @@ void GCodePlanner::writeGCode(GCodeExport& gcode)
|
||||
for(unsigned int extruder_plan_idx = 0; extruder_plan_idx < extruder_plans.size(); extruder_plan_idx++)
|
||||
{
|
||||
ExtruderPlan& extruder_plan = extruder_plans[extruder_plan_idx];
|
||||
const RetractionConfig& retraction_config = storage.retraction_config_per_extruder[extruder_plan.extruder];
|
||||
RetractionConfig& retraction_config = storage.retraction_config_per_extruder[extruder_plan.extruder];
|
||||
|
||||
if (extruder != extruder_plan.extruder)
|
||||
{
|
||||
@@ -765,7 +764,7 @@ void GCodePlanner::writeGCode(GCodeExport& gcode)
|
||||
else
|
||||
speed *= extruder_plan.getExtrudeSpeedFactor();
|
||||
|
||||
if (MergeInfillLines(gcode, layer_nr, paths, extruder_plan, configs_storage.travel_config_per_extruder[extruder], nozzle_size, speed_equalize_flow_enabled, speed_equalize_flow_max).mergeInfillLines(path_idx)) // !! has effect on path_idx !!
|
||||
if (MergeInfillLines(gcode, layer_nr, paths, extruder_plan, storage.travel_config_per_extruder[extruder], nozzle_size, speed_equalize_flow_enabled, speed_equalize_flow_max).mergeInfillLines(path_idx)) // !! has effect on path_idx !!
|
||||
{ // !! has effect on path_idx !!
|
||||
// works when path_idx is the index of the travel move BEFORE the infill lines to be merged
|
||||
continue;
|
||||
@@ -788,7 +787,7 @@ void GCodePlanner::writeGCode(GCodeExport& gcode)
|
||||
bool spiralize = path.spiralize;
|
||||
if (!spiralize) // normal (extrusion) move (with coasting
|
||||
{
|
||||
const CoastingConfig& coasting_config = storage.coasting_config[extruder];
|
||||
CoastingConfig& coasting_config = storage.coasting_config[extruder];
|
||||
bool coasting = coasting_config.coasting_enable;
|
||||
if (coasting)
|
||||
{
|
||||
@@ -859,15 +858,15 @@ void GCodePlanner::writeGCode(GCodeExport& gcode)
|
||||
if (train->getSettingBoolean("cool_lift_head") && extruder_plan.extraTime > 0.0)
|
||||
{
|
||||
gcode.writeComment("Small layer, adding delay");
|
||||
const RetractionConfig& retraction_config = storage.retraction_config_per_extruder[gcode.getExtruderNr()];
|
||||
RetractionConfig& retraction_config = storage.retraction_config_per_extruder[gcode.getExtruderNr()];
|
||||
gcode.writeRetraction(retraction_config);
|
||||
if (extruder_plan_idx == extruder_plans.size() - 1 || !train->getSettingBoolean("machine_extruder_end_pos_abs"))
|
||||
{ // only move the head if it's the last extruder plan; otherwise it's already at the switching bay area
|
||||
// or do it anyway when we switch extruder in-place
|
||||
gcode.setZ(gcode.getPositionZ() + MM2INT(3.0));
|
||||
gcode.writeMove(gcode.getPositionXY(), configs_storage.travel_config_per_extruder[extruder].getSpeed(), 0);
|
||||
gcode.writeMove(gcode.getPositionXY(), storage.travel_config_per_extruder[extruder].getSpeed(), 0);
|
||||
// TODO: is this safe?! wouldn't the head move into the sides then?!
|
||||
gcode.writeMove(gcode.getPositionXY() - Point(-MM2INT(20.0), 0), configs_storage.travel_config_per_extruder[extruder].getSpeed(), 0);
|
||||
gcode.writeMove(gcode.getPositionXY() - Point(-MM2INT(20.0), 0), storage.travel_config_per_extruder[extruder].getSpeed(), 0);
|
||||
}
|
||||
gcode.writeDelay(extruder_plan.extraTime);
|
||||
}
|
||||
@@ -887,6 +886,109 @@ void GCodePlanner::overrideFanSpeeds(double speed)
|
||||
}
|
||||
|
||||
|
||||
void GCodePlanner::completeConfigs()
|
||||
{
|
||||
storage.support_config.setLayerHeight(layer_thickness);
|
||||
storage.support_skin_config.setLayerHeight(layer_thickness);
|
||||
|
||||
for (SliceMeshStorage& mesh : storage.meshes)
|
||||
{
|
||||
mesh.inset0_config.setLayerHeight(layer_thickness);
|
||||
|
||||
mesh.insetX_config.setLayerHeight(layer_thickness);
|
||||
mesh.skin_config.setLayerHeight(layer_thickness);
|
||||
mesh.perimeter_gap_config.setLayerHeight(layer_thickness);
|
||||
for(unsigned int idx=0; idx<MAX_INFILL_COMBINE; idx++)
|
||||
{
|
||||
mesh.infill_config[idx].setLayerHeight(layer_thickness);
|
||||
}
|
||||
}
|
||||
|
||||
storage.primeTower.setConfigs(storage.meshgroup, layer_thickness);
|
||||
|
||||
processInitialLayersSpeedup();
|
||||
}
|
||||
|
||||
|
||||
void GCodePlanner::processInitialLayersSpeedup()
|
||||
{
|
||||
int initial_speedup_layers = storage.getSettingAsCount("speed_slowdown_layers");
|
||||
if (layer_nr >= 0 && layer_nr < initial_speedup_layers)
|
||||
{
|
||||
GCodePathConfig::BasicConfig initial_layer_speed_config;
|
||||
int extruder_nr_support_infill = storage.getSettingAsIndex((layer_nr == 0)? "support_extruder_nr_layer_0" : "support_infill_extruder_nr");
|
||||
initial_layer_speed_config.speed = storage.meshgroup->getExtruderTrain(extruder_nr_support_infill)->getSettingInMillimetersPerSecond("speed_print_layer_0");
|
||||
initial_layer_speed_config.acceleration = storage.meshgroup->getExtruderTrain(extruder_nr_support_infill)->getSettingInMillimetersPerSecond("acceleration_print_layer_0");
|
||||
initial_layer_speed_config.jerk = storage.meshgroup->getExtruderTrain(extruder_nr_support_infill)->getSettingInMillimetersPerSecond("jerk_print_layer_0");
|
||||
|
||||
//Support (global).
|
||||
storage.support_config.smoothSpeed(initial_layer_speed_config, layer_nr, initial_speedup_layers);
|
||||
|
||||
//Support roof (global).
|
||||
int extruder_nr_support_skin = storage.getSettingAsIndex("support_interface_extruder_nr");
|
||||
initial_layer_speed_config.speed = storage.meshgroup->getExtruderTrain(extruder_nr_support_skin)->getSettingInMillimetersPerSecond("speed_print_layer_0");
|
||||
initial_layer_speed_config.acceleration = storage.meshgroup->getExtruderTrain(extruder_nr_support_skin)->getSettingInMillimetersPerSecond("acceleration_print_layer_0");
|
||||
initial_layer_speed_config.jerk = storage.meshgroup->getExtruderTrain(extruder_nr_support_skin)->getSettingInMillimetersPerSecond("jerk_print_layer_0");
|
||||
storage.support_skin_config.smoothSpeed(initial_layer_speed_config, layer_nr, initial_speedup_layers);
|
||||
|
||||
for (int extruder_nr = 0; extruder_nr < storage.meshgroup->getExtruderCount(); ++extruder_nr)
|
||||
{
|
||||
const ExtruderTrain* extruder_train = storage.meshgroup->getExtruderTrain(extruder_nr);
|
||||
initial_layer_speed_config.speed = extruder_train->getSettingInMillimetersPerSecond("speed_travel_layer_0");
|
||||
initial_layer_speed_config.acceleration = extruder_train->getSettingInMillimetersPerSecond("acceleration_travel_layer_0");
|
||||
initial_layer_speed_config.jerk = extruder_train->getSettingInMillimetersPerSecond("jerk_travel_layer_0");
|
||||
|
||||
//Travel speed (per extruder).
|
||||
storage.travel_config_per_extruder[extruder_nr].smoothSpeed(initial_layer_speed_config, layer_nr, initial_speedup_layers);
|
||||
}
|
||||
|
||||
for (SliceMeshStorage& mesh : storage.meshes)
|
||||
{
|
||||
initial_layer_speed_config.speed = mesh.getSettingInMillimetersPerSecond("speed_print_layer_0");
|
||||
initial_layer_speed_config.acceleration = mesh.getSettingInMillimetersPerSecond("acceleration_print_layer_0");
|
||||
initial_layer_speed_config.jerk = mesh.getSettingInMillimetersPerSecond("jerk_print_layer_0");
|
||||
|
||||
//Outer wall speed (per mesh).
|
||||
mesh.inset0_config.smoothSpeed(initial_layer_speed_config, layer_nr, initial_speedup_layers);
|
||||
|
||||
//Inner wall speed (per mesh).
|
||||
mesh.insetX_config.smoothSpeed(initial_layer_speed_config, layer_nr, initial_speedup_layers);
|
||||
|
||||
//Skin speed (per mesh).
|
||||
mesh.skin_config.smoothSpeed(initial_layer_speed_config, layer_nr, initial_speedup_layers);
|
||||
mesh.perimeter_gap_config.smoothSpeed(initial_layer_speed_config, layer_nr, initial_speedup_layers);
|
||||
|
||||
for (unsigned int idx = 0; idx < MAX_INFILL_COMBINE; idx++)
|
||||
{
|
||||
//Infill speed (per combine part per mesh).
|
||||
mesh.infill_config[idx].smoothSpeed(initial_layer_speed_config, layer_nr, initial_speedup_layers);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (layer_nr == initial_speedup_layers) //At the topmost layer of the gradient, reset all speeds to the typical speeds.
|
||||
{
|
||||
storage.support_config.setSpeedIconic();
|
||||
storage.support_skin_config.setSpeedIconic();
|
||||
for (int extruder_nr = 0; extruder_nr < storage.meshgroup->getExtruderCount(); ++extruder_nr)
|
||||
{
|
||||
storage.travel_config_per_extruder[extruder_nr].setSpeedIconic();
|
||||
}
|
||||
for (SliceMeshStorage& mesh : storage.meshes)
|
||||
{
|
||||
mesh.inset0_config.setSpeedIconic();
|
||||
mesh.insetX_config.setSpeedIconic();
|
||||
mesh.skin_config.setSpeedIconic();
|
||||
mesh.perimeter_gap_config.setSpeedIconic();
|
||||
for (unsigned int idx = 0; idx < MAX_INFILL_COMBINE; idx++)
|
||||
{
|
||||
mesh.infill_config[idx].setSpeedIconic();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool GCodePlanner::makeRetractSwitchRetract(GCodeExport& gcode, unsigned int extruder_plan_idx, unsigned int path_idx)
|
||||
{
|
||||
std::vector<GCodePath>& paths = extruder_plans[extruder_plan_idx].paths;
|
||||
|
||||
+34
-57
@@ -16,7 +16,6 @@
|
||||
#include "FanSpeedLayerTime.h"
|
||||
#include "SpaceFillType.h"
|
||||
#include "GCodePathConfig.h"
|
||||
#include "settings/PathConfigStorage.h"
|
||||
|
||||
#include "utils/optional.h"
|
||||
|
||||
@@ -58,7 +57,7 @@ public:
|
||||
* \param extruder The extruder number for which this object is a plan.
|
||||
* \param start_position The position the head is when this extruder plan starts
|
||||
*/
|
||||
ExtruderPlan(int extruder, Point start_position, int layer_nr, bool is_initial_layer, int layer_thickness, const FanSpeedLayerTimeSettings& fan_speed_layer_time_settings, const RetractionConfig& retraction_config);
|
||||
ExtruderPlan(int extruder, Point start_position, int layer_nr, bool is_initial_layer, int layer_thickness, FanSpeedLayerTimeSettings& fan_speed_layer_time_settings, const RetractionConfig& retraction_config);
|
||||
|
||||
/*!
|
||||
* Add a new Insert, constructed with the given arguments
|
||||
@@ -166,7 +165,7 @@ protected:
|
||||
|
||||
int layer_thickness; //!< The thickness of this layer in Z-direction
|
||||
|
||||
const FanSpeedLayerTimeSettings& fan_speed_layer_time_settings; //!< The fan speed and layer time settings used to limit this extruder plan
|
||||
FanSpeedLayerTimeSettings& fan_speed_layer_time_settings; //!< The fan speed and layer time settings used to limit this extruder plan
|
||||
|
||||
const RetractionConfig& retraction_config; //!< The retraction settings for the extruder of this plan
|
||||
|
||||
@@ -216,25 +215,9 @@ class GCodePlanner : public NoCopy
|
||||
{
|
||||
friend class LayerPlanBuffer;
|
||||
friend class GCodePlannerTest;
|
||||
public:
|
||||
/*!
|
||||
* The state which is passed along between layer plans.
|
||||
* This is what a \ref GCodePlanner delivers to further computation in \ref FffGcodeWriter
|
||||
* This is the state which is currently planned, not which is written to gcode.
|
||||
*/
|
||||
struct PlanningState
|
||||
{
|
||||
Point last_position; //!< The position of the head before planning the next layer
|
||||
int current_extruder; //!< The extruder train in use before planning the next layer
|
||||
bool is_inside_mesh_layer_part; //!< Whether the last position was inside a layer part (used in combing)
|
||||
};
|
||||
private:
|
||||
const SliceDataStorage& storage; //!< The polygon data obtained from FffPolygonProcessor
|
||||
SliceDataStorage& storage; //!< The polygon data obtained from FffPolygonProcessor
|
||||
|
||||
public:
|
||||
const PathConfigStorage configs_storage; //!< The line configs for this layer for each feature type
|
||||
|
||||
private:
|
||||
int layer_nr; //!< The layer number of this layer plan
|
||||
int is_initial_layer; //!< Whether this is the first layer (which might be raft)
|
||||
|
||||
@@ -244,9 +227,7 @@ private:
|
||||
|
||||
Point start_position;
|
||||
Point lastPosition;
|
||||
|
||||
bool has_prime_tower_planned;
|
||||
|
||||
|
||||
std::vector<ExtruderPlan> extruder_plans; //!< should always contain at least one ExtruderPlan
|
||||
|
||||
int last_extruder_previous_layer; //!< The last id of the extruder with which was printed in the previous layer
|
||||
@@ -257,7 +238,7 @@ private:
|
||||
Comb* comb;
|
||||
|
||||
|
||||
const std::vector<FanSpeedLayerTimeSettings>& fan_speed_layer_time_settings_per_extruder;
|
||||
std::vector<FanSpeedLayerTimeSettings>& fan_speed_layer_time_settings_per_extruder;
|
||||
|
||||
private:
|
||||
/*!
|
||||
@@ -270,7 +251,7 @@ private:
|
||||
* \param spiralize Whether to gradually increase the z while printing. (Note that this path may be part of a sequence of spiralized paths, forming one polygon)
|
||||
* \return A path with the given config which is now the last path in GCodePlanner::paths
|
||||
*/
|
||||
GCodePath* getLatestPathWithConfig(const GCodePathConfig* config, SpaceFillType space_fill_type, float flow = 1.0, bool spiralize = false);
|
||||
GCodePath* getLatestPathWithConfig(GCodePathConfig* config, SpaceFillType space_fill_type, float flow = 1.0, bool spiralize = false);
|
||||
|
||||
public:
|
||||
/*!
|
||||
@@ -293,7 +274,7 @@ public:
|
||||
* \param last_position The position of the head at the start of this gcode layer
|
||||
* \param combing_mode Whether combing is enabled and full or within infill only.
|
||||
*/
|
||||
GCodePlanner(const SliceDataStorage& storage, int layer_nr, int z, int layer_height, PlanningState last_planned_state, const std::vector<FanSpeedLayerTimeSettings>& fan_speed_layer_time_settings_per_extruder, CombingMode combing_mode, int64_t comb_boundary_offset, bool travel_avoid_other_parts, int64_t travel_avoid_distance);
|
||||
GCodePlanner(SliceDataStorage& storage, int layer_nr, int z, int layer_height, Point last_position, int current_extruder, bool is_inside_mesh, std::vector<FanSpeedLayerTimeSettings>& fan_speed_layer_time_settings_per_extruder, CombingMode combing_mode, int64_t comb_boundary_offset, bool travel_avoid_other_parts, int64_t travel_avoid_distance);
|
||||
~GCodePlanner();
|
||||
|
||||
void overrideFanSpeeds(double speed);
|
||||
@@ -311,21 +292,12 @@ private:
|
||||
Polygons computeCombBoundaryInside(CombingMode combing_mode);
|
||||
|
||||
public:
|
||||
int getLayerNr() const
|
||||
int getLayerNr()
|
||||
{
|
||||
return layer_nr;
|
||||
}
|
||||
|
||||
PlanningState getPlanningState() const
|
||||
{
|
||||
PlanningState ret;
|
||||
ret.last_position = lastPosition;
|
||||
ret.current_extruder = getExtruder();
|
||||
ret.is_inside_mesh_layer_part = was_inside;
|
||||
return ret;
|
||||
}
|
||||
|
||||
Point getLastPosition() const
|
||||
|
||||
Point getLastPosition()
|
||||
{
|
||||
return lastPosition;
|
||||
}
|
||||
@@ -333,25 +305,14 @@ public:
|
||||
/*!
|
||||
* return whether the last position planned was inside the mesh (used in combing)
|
||||
*/
|
||||
bool getIsInsideMesh() const
|
||||
bool getIsInsideMesh()
|
||||
{
|
||||
return was_inside;
|
||||
}
|
||||
|
||||
bool getPrimeTowerIsPlanned() const
|
||||
{
|
||||
return has_prime_tower_planned;
|
||||
}
|
||||
|
||||
void setPrimeTowerIsPlanned()
|
||||
{
|
||||
has_prime_tower_planned = true;
|
||||
}
|
||||
|
||||
/*!
|
||||
* send a line segment through the command socket from the previous point to the given point \p to
|
||||
*/
|
||||
void sendLineTo(PrintFeatureType print_feature_type, Point to, int line_width) const
|
||||
void sendLineTo(PrintFeatureType print_feature_type, Point to, int line_width)
|
||||
{
|
||||
CommandSocket::sendLineTo(print_feature_type, to, line_width);
|
||||
}
|
||||
@@ -375,7 +336,7 @@ public:
|
||||
/*!
|
||||
* Get the last planned extruder.
|
||||
*/
|
||||
int getExtruder() const
|
||||
int getExtruder()
|
||||
{
|
||||
return extruder_plans.back().extruder;
|
||||
}
|
||||
@@ -416,7 +377,7 @@ public:
|
||||
* \param flow A modifier of the extrusion width which would follow from the \p config
|
||||
* \param spiralize Whether to gradually increase the z while printing. (Note that this path may be part of a sequence of spiralized paths, forming one polygon)
|
||||
*/
|
||||
void addExtrusionMove(Point p, const GCodePathConfig* config, SpaceFillType space_fill_type, float flow = 1.0, bool spiralize = false);
|
||||
void addExtrusionMove(Point p, GCodePathConfig* config, SpaceFillType space_fill_type, float flow = 1.0, bool spiralize = false);
|
||||
|
||||
/*!
|
||||
* Add polygon to the gcode starting at vertex \p startIdx
|
||||
@@ -426,8 +387,9 @@ public:
|
||||
* \param wall_overlap_computation The wall overlap compensation calculator for each given segment (optionally nullptr)
|
||||
* \param wall_0_wipe_dist The distance to travel along the polygon after it has been laid down, in order to wipe the start and end of the wall together
|
||||
* \param spiralize Whether to gradually increase the z height from the normal layer height to the height of the next layer over this polygon
|
||||
* \param flow_ratio The ratio with which to multiply the extrusion amount
|
||||
*/
|
||||
void addPolygon(ConstPolygonRef polygon, int startIdx, const GCodePathConfig* config, WallOverlapComputation* wall_overlap_computation = nullptr, coord_t wall_0_wipe_dist = 0, bool spiralize = false);
|
||||
void addPolygon(PolygonRef polygon, int startIdx, GCodePathConfig* config, WallOverlapComputation* wall_overlap_computation = nullptr, coord_t wall_0_wipe_dist = 0, bool spiralize = false, float flow_ratio = 1.0);
|
||||
|
||||
/*!
|
||||
* Add polygons to the gcode with optimized order.
|
||||
@@ -445,8 +407,9 @@ public:
|
||||
* \param z_seam_pos The location near where to start each part in case \p z_seam_type is 'back'
|
||||
* \param wall_0_wipe_dist The distance to travel along each polygon after it has been laid down, in order to wipe the start and end of the wall together
|
||||
* \param spiralize Whether to gradually increase the z height from the normal layer height to the height of the next layer over each polygon printed
|
||||
* \param flow_ratio The ratio with which to multiply the extrusion amount
|
||||
*/
|
||||
void addPolygonsByOptimizer(const Polygons& polygons, const GCodePathConfig* config, WallOverlapComputation* wall_overlap_computation = nullptr, EZSeamType z_seam_type = EZSeamType::SHORTEST, Point z_seam_pos = Point(0, 0), coord_t wall_0_wipe_dist = 0, bool spiralize = false);
|
||||
void addPolygonsByOptimizer(Polygons& polygons, GCodePathConfig* config, WallOverlapComputation* wall_overlap_computation = nullptr, EZSeamType z_seam_type = EZSeamType::SHORTEST, Point z_seam_pos = Point(0, 0), coord_t wall_0_wipe_dist = 0, bool spiralize = false, float flow_ratio = 1.0);
|
||||
|
||||
/*!
|
||||
* Add lines to the gcode with optimized order.
|
||||
@@ -454,8 +417,9 @@ public:
|
||||
* \param config The config of the lines
|
||||
* \param space_fill_type The type of space filling used to generate the line segments (should be either Lines or PolyLines!)
|
||||
* \param wipe_dist (optional) the distance wiped without extruding after laying down a line.
|
||||
* \param flow_ratio The ratio with which to multiply the extrusion amount
|
||||
*/
|
||||
void addLinesByOptimizer(const Polygons& polygons, const GCodePathConfig* config, SpaceFillType space_fill_type, int wipe_dist = 0);
|
||||
void addLinesByOptimizer(Polygons& polygons, GCodePathConfig* config, SpaceFillType space_fill_type, int wipe_dist = 0, float flow_ratio = 1.0);
|
||||
|
||||
/*!
|
||||
* Compute naive time estimates (without accounting for slow down at corners etc.) and naive material estimates (without accounting for MergeInfillLines)
|
||||
@@ -473,7 +437,20 @@ public:
|
||||
* \param gcode The gcode to write the planned paths to
|
||||
*/
|
||||
void writeGCode(GCodeExport& gcode);
|
||||
|
||||
|
||||
/*!
|
||||
* Complete all GcodePathConfigs by
|
||||
* - altering speeds to conform to speed_print_layer_0 and
|
||||
* speed_travel_layer_0
|
||||
* - setting the layer_height (and thereby computing the extrusionMM3perMM)
|
||||
*/
|
||||
void completeConfigs();
|
||||
|
||||
/*!
|
||||
* Interpolate between the initial layer speeds and the eventual speeds.
|
||||
*/
|
||||
void processInitialLayersSpeedup();
|
||||
|
||||
/*!
|
||||
* Whether the current retracted path is to be an extruder switch retraction.
|
||||
* This function is used to avoid a G10 S1 after a G10.
|
||||
|
||||
+2
-2
@@ -17,7 +17,7 @@ int Infill::computeScanSegmentIdx(int x, int line_width)
|
||||
return x / line_width;
|
||||
}
|
||||
|
||||
void Infill::generate(Polygons& result_polygons, Polygons& result_lines, const SliceMeshStorage* mesh)
|
||||
void Infill::generate(Polygons& result_polygons, Polygons& result_lines, SliceMeshStorage* mesh)
|
||||
{
|
||||
if (in_outline.size() == 0) return;
|
||||
if (line_distance == 0) return;
|
||||
@@ -144,7 +144,7 @@ void Infill::generateTriangleInfill(Polygons& result)
|
||||
generateLineInfill(result, line_distance, fill_angle + 120, 0);
|
||||
}
|
||||
|
||||
void Infill::generateCubicSubDivInfill(Polygons& result, const SliceMeshStorage& mesh)
|
||||
void Infill::generateCubicSubDivInfill(Polygons& result, SliceMeshStorage& mesh)
|
||||
{
|
||||
Polygons uncropped;
|
||||
mesh.base_subdiv_cube->generateSubdivisionLines(z, uncropped);
|
||||
|
||||
+3
-3
@@ -80,7 +80,7 @@ public:
|
||||
* \param result_lines (output) The resulting line segments (from linear infill types)
|
||||
* \param mesh The mesh for which to geenrate infill (should only be used for non-helper objects)
|
||||
*/
|
||||
void generate(Polygons& result_polygons, Polygons& result_lines, const SliceMeshStorage* mesh = nullptr);
|
||||
void generate(Polygons& result_polygons, Polygons& result_lines, SliceMeshStorage* mesh = nullptr);
|
||||
|
||||
private:
|
||||
/*!
|
||||
@@ -148,8 +148,8 @@ private:
|
||||
* \param[out] result The resulting lines
|
||||
* \param[in] mesh Where the Cubic Subdivision Infill precomputation is stored
|
||||
*/
|
||||
void generateCubicSubDivInfill(Polygons& result, const SliceMeshStorage& mesh);
|
||||
|
||||
void generateCubicSubDivInfill(Polygons& result, SliceMeshStorage& mesh);
|
||||
|
||||
/*!
|
||||
* Convert a mapping from scanline to line_segment-scanline-intersections (\p cut_list) into line segments, using the even-odd rule
|
||||
* \param result (output) The resulting lines
|
||||
|
||||
@@ -0,0 +1,139 @@
|
||||
/** Copyright (C) 2017 Ultimaker - Released under terms of the AGPLv3 License */
|
||||
#include "SpaghettiInfill.h"
|
||||
|
||||
namespace cura {
|
||||
|
||||
|
||||
void SpaghettiInfill::generateSpaghettiInfill(SliceMeshStorage& mesh)
|
||||
{
|
||||
coord_t layer_height = mesh.getSettingInMicrons("layer_height");
|
||||
coord_t line_width = mesh.getSettingInMicrons("infill_line_width");
|
||||
double layer_height_mm = INT2MM(layer_height);
|
||||
int spaghetti_max_layer_count = std::max(1, static_cast<int>(mesh.getSettingInMicrons("spaghetti_max_height") / layer_height));
|
||||
// TODO: account for the initial layer height
|
||||
|
||||
coord_t filling_area_inset = mesh.getSettingInMicrons("spaghetti_inset");
|
||||
|
||||
if (mesh.getSettingInAngleDegrees("spaghetti_max_infill_angle") >= 90)
|
||||
{
|
||||
return; // infill cannot be combined into pillars
|
||||
}
|
||||
coord_t connection_inset_dist = tan(mesh.getSettingInAngleRadians("spaghetti_max_infill_angle")) * layer_height; // Horizontal component of the spaghetti_max_infill_angle
|
||||
|
||||
std::list<SpaghettiInfill::InfillPillar> pillar_base;
|
||||
size_t min_layer = mesh.getSettingAsCount("bottom_layers") + 1;
|
||||
size_t max_layer = mesh.layers.size() - 1 - mesh.getSettingAsCount("top_layers");
|
||||
for (size_t layer_idx = min_layer; layer_idx <= max_layer; layer_idx++) //Skip every few layers, but extrude more.
|
||||
{
|
||||
SliceLayer& layer = mesh.layers[layer_idx];
|
||||
|
||||
// add infill parts to pillar_base
|
||||
for (SliceLayerPart& slice_layer_part : layer.parts)
|
||||
{
|
||||
std::vector<PolygonsPart> part_infill_parts = slice_layer_part.getOwnInfillArea().splitIntoParts();
|
||||
|
||||
// add parts to pillar_base
|
||||
for (PolygonsPart& infill_part : part_infill_parts)
|
||||
{
|
||||
SpaghettiInfill::InfillPillar& pillar = addPartToPillarBase(infill_part, pillar_base, connection_inset_dist);
|
||||
pillar.top_slice_layer_part = &slice_layer_part;
|
||||
pillar.last_layer_added = layer_idx;
|
||||
pillar.layer_count++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// handle finished pillars
|
||||
for (auto it = pillar_base.begin(); it != pillar_base.end();)
|
||||
{
|
||||
InfillPillar& pillar = *it;
|
||||
if (pillar.layer_count >= spaghetti_max_layer_count
|
||||
|| pillar.last_layer_added < static_cast<int>(layer_idx)
|
||||
)
|
||||
{
|
||||
pillar.addToTopSliceLayerPart(layer_height_mm, filling_area_inset, line_width);
|
||||
auto to_be_erased = it;
|
||||
++it;
|
||||
pillar_base.erase(to_be_erased);
|
||||
}
|
||||
else
|
||||
{
|
||||
++it;
|
||||
}
|
||||
}
|
||||
}
|
||||
// handle unfinished pillars
|
||||
for (auto it = pillar_base.begin(); it != pillar_base.end(); ++it)
|
||||
{
|
||||
it->addToTopSliceLayerPart(layer_height_mm, filling_area_inset, line_width);
|
||||
}
|
||||
}
|
||||
|
||||
void SpaghettiInfill::InfillPillar::addToTopSliceLayerPart(double layer_height_mm, coord_t filling_area_inset, coord_t line_width)
|
||||
{
|
||||
SliceLayerPart& slice_layer_part = *top_slice_layer_part;
|
||||
double volume = total_area_mm2 * layer_height_mm;
|
||||
assert(volume > 0.0);
|
||||
|
||||
// get filling area
|
||||
Polygons filling_area = top_part.offset(-filling_area_inset);
|
||||
assert(top_part.size() > 0 && top_part[0].size() > 0 && "the top part must be a non-zero area!");
|
||||
if (filling_area.size() == 0)
|
||||
{
|
||||
AABB aabb(top_part);
|
||||
Point inside = (aabb.min + aabb.max) / 2;
|
||||
if (!top_part.inside(inside))
|
||||
{
|
||||
inside = top_part[0][0];
|
||||
}
|
||||
filling_area = PolygonsPart();
|
||||
PolygonRef poly = filling_area.newPoly();
|
||||
poly.emplace_back(inside + Point(-line_width / 2 - 10, line_width / 2 + 10));
|
||||
poly.emplace_back(inside + Point(line_width / 2 + 10, line_width / 2 + 10));
|
||||
poly.emplace_back(inside + Point(line_width / 2 + 10, -line_width / 2 - 10));
|
||||
poly.emplace_back(inside + Point(-line_width / 2 - 10, -line_width / 2 - 10));
|
||||
}
|
||||
slice_layer_part.spaghetti_infill_volumes.emplace_back(top_part, volume);
|
||||
}
|
||||
|
||||
bool SpaghettiInfill::InfillPillar::isConnected(const PolygonsPart& infill_part) const
|
||||
{
|
||||
Polygons insetted = infill_part.offset(-connection_inset_dist);
|
||||
if (insetted.intersection(top_part).size() > 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
SpaghettiInfill::InfillPillar& SpaghettiInfill::addPartToPillarBase(const PolygonsPart& infill_part, std::list<SpaghettiInfill::InfillPillar>& pillar_base, coord_t connection_inset_dist)
|
||||
{
|
||||
std::list<SpaghettiInfill::InfillPillar>::iterator ret = pillar_base.end();
|
||||
for (auto it = pillar_base.begin(); it != pillar_base.end(); ++it)
|
||||
{
|
||||
InfillPillar& pillar = *it;
|
||||
if (pillar.isConnected(infill_part))
|
||||
{
|
||||
pillar.total_area_mm2 += INT2MM(INT2MM(infill_part.area()));
|
||||
pillar.top_part = infill_part;
|
||||
if (ret != pillar_base.end())
|
||||
{ // connecting two pillars of the layer below via one area on this layer
|
||||
pillar.total_area_mm2 += ret->total_area_mm2;
|
||||
pillar_base.erase(ret);
|
||||
}
|
||||
ret = it;
|
||||
}
|
||||
}
|
||||
if (ret == pillar_base.end())
|
||||
{ // couldn't connect to any existing pillar
|
||||
pillar_base.emplace_back(infill_part, connection_inset_dist);
|
||||
return pillar_base.back();
|
||||
}
|
||||
return *ret;
|
||||
}
|
||||
|
||||
|
||||
}//namespace cura
|
||||
@@ -0,0 +1,95 @@
|
||||
/** Copyright (C) 2017 Ultimaker - Released under terms of the AGPLv3 License */
|
||||
#ifndef INFILL_SPAGHETTI_INFILL_H
|
||||
#define INFILL_SPAGHETTI_INFILL_H
|
||||
|
||||
#include <list>
|
||||
|
||||
#include "../utils/intpoint.h"
|
||||
#include "../utils/polygon.h"
|
||||
#include "../sliceDataStorage.h"
|
||||
|
||||
namespace cura {
|
||||
|
||||
/*!
|
||||
* Spaghetti infill is a type of infill which fills every so many layers, but extrudes as much filament corresponding to the total unfilled volume under the filling area.
|
||||
*
|
||||
* A filling layer is inserted when a a pillar of infill areas is becoming too high, or when the angle between the filling areas is too shallow.
|
||||
*
|
||||
* The filling area might be smaller than the actual infill area, so that we fill the pillar from a smaller top area.
|
||||
*
|
||||
* Infill pillars can join each other if they are connected on the top. The total volume will then be extruded from the top.
|
||||
*
|
||||
* Where the model spits into two from bottom to top, one of the top pieces will be connected to the lower part as one big pillar, while a new pillar will be generated for the other top part.
|
||||
* Which part the base will be connected to is arbitrary.
|
||||
*
|
||||
*/
|
||||
class SpaghettiInfill
|
||||
{
|
||||
public:
|
||||
/*!
|
||||
* Generate the filling areas and corresponding volume to extrude over such areas for spaghetti infill.
|
||||
*/
|
||||
static void generateSpaghettiInfill(SliceMeshStorage& mesh);
|
||||
|
||||
protected:
|
||||
struct InfillPillar
|
||||
{
|
||||
SliceLayerPart* top_slice_layer_part = nullptr; //!< A reference to the slice_layer_part from which the top part is generated
|
||||
PolygonsPart top_part; //!< The top area of this pillar
|
||||
double total_area_mm2; //!< The total volume of the pillar divided by the layer height
|
||||
coord_t connection_inset_dist; //!< Horizontal component of the spaghetti_max_infill_angle: the distance insetted corresponding to the maximum angle which can be filled by spaghetti infill.
|
||||
int layer_count; //!< The height of the pillar in numer of layers
|
||||
int last_layer_added = -1; //!< The last layer from which areas got added to this pillar
|
||||
|
||||
/*!
|
||||
* Basic constructor of a pillar from a single area, which is to be the top of the new pillar
|
||||
*
|
||||
* \param _top_part The area which is the base and the top of the new pillar
|
||||
* \param connection_inset_dist Horizontal component of the spaghetti_max_infill_angle
|
||||
*/
|
||||
InfillPillar(const PolygonsPart& _top_part, coord_t connection_inset_dist)
|
||||
: top_part(_top_part) // TODO: prevent copy construction! Is that possible?
|
||||
, total_area_mm2(INT2MM(INT2MM(top_part.area())))
|
||||
, connection_inset_dist(connection_inset_dist)
|
||||
, layer_count(1)
|
||||
{
|
||||
}
|
||||
|
||||
/*!
|
||||
* Check whether the top of this pillar is connected (enough) to the given \p infill_part.
|
||||
* It is assumed the infill_part is on the layer directly above the top part of this pillar.
|
||||
*
|
||||
* \param infill_part The part to check for connectivity
|
||||
* \return Whether the infill part can be incorporated in this pillar
|
||||
*/
|
||||
bool isConnected(const PolygonsPart& infill_part) const;
|
||||
|
||||
/*!
|
||||
* Register the volume of this infill pillar in the sliceDataStorage.
|
||||
* The filling area and the volume are saved in \ref SliceLayerPart::spaghetti_infill_volumes
|
||||
*
|
||||
* Note that the filling area is different from the infill area, because the spaghetti can curl toward the sides.
|
||||
*
|
||||
* \param layer_height_mm The layer height in millimeters
|
||||
* \param filling_area_inset The inset from the boundary of the walls to get from the infill area to the filling area
|
||||
* \param line_width The line width used to generate an area just large enough for infill lines to be generated, when the infill area would otherwise be too small to get infill
|
||||
*/
|
||||
void addToTopSliceLayerPart(double layer_height_mm, coord_t filling_area_inset, coord_t line_width);
|
||||
};
|
||||
private:
|
||||
/*!
|
||||
* Add an area to the pillar base:
|
||||
* - add it to an existing pillar if possible
|
||||
* - otherwise create a new pillar for this area
|
||||
* The pillar to which the area was added is returned
|
||||
*
|
||||
* \param infill_part The area to add to the base
|
||||
* \param pillar_base The collection of pillars used up till the current layer
|
||||
* \param connection_inset_dist The distance insetted corresponding to the maximum angle which can be filled by spaghetti infill
|
||||
*/
|
||||
static InfillPillar& addPartToPillarBase(const PolygonsPart& infill_part, std::list<InfillPillar>& pillar_base, coord_t connection_inset_dist);
|
||||
};
|
||||
|
||||
}//namespace cura
|
||||
|
||||
#endif//INFILL_SPAGHETTI_INFILL_H
|
||||
+1
-4
@@ -44,10 +44,7 @@ void createLayerWithParts(SliceLayer& storageLayer, SlicerLayer* layer, bool uni
|
||||
}
|
||||
void createLayerParts(SliceMeshStorage& mesh, Slicer* slicer, bool union_layers, bool union_all_remove_holes)
|
||||
{
|
||||
const auto total_layers = slicer->layers.size();
|
||||
assert(mesh.layers.size() == total_layers);
|
||||
#pragma omp parallel for default(none) shared(mesh,slicer) firstprivate(union_layers,union_all_remove_holes) schedule(dynamic)
|
||||
for(unsigned int layer_nr = 0; layer_nr < total_layers; layer_nr++)
|
||||
for(unsigned int layer_nr = 0; layer_nr < slicer->layers.size(); layer_nr++)
|
||||
{
|
||||
mesh.layers[layer_nr].sliceZ = slicer->layers[layer_nr].z;
|
||||
mesh.layers[layer_nr].printZ = slicer->layers[layer_nr].z;
|
||||
|
||||
+1
-15
@@ -20,8 +20,6 @@
|
||||
|
||||
#include "settings/SettingsToGV.h"
|
||||
|
||||
#include <omp.h> // omp_get_num_threads
|
||||
|
||||
namespace cura
|
||||
{
|
||||
|
||||
@@ -330,19 +328,7 @@ int main(int argc, char **argv)
|
||||
print_usage();
|
||||
exit(1);
|
||||
}
|
||||
|
||||
#pragma omp parallel
|
||||
{
|
||||
#pragma omp master
|
||||
{
|
||||
#ifdef _OPENMP
|
||||
log("OpenMP multithreading enabled, likely number of threads to be used: %u\n", omp_get_num_threads());
|
||||
#else
|
||||
log("OpenMP multithreading disabled\n");
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (stringcasecompare(argv[1], "connect") == 0)
|
||||
{
|
||||
connect(argc, argv);
|
||||
|
||||
@@ -16,7 +16,7 @@ void PathOrderOptimizer::optimize()
|
||||
bool picked[polygons.size()];
|
||||
memset(picked, false, sizeof(bool) * polygons.size());/// initialized as falses
|
||||
|
||||
for (ConstPolygonRef poly : polygons) /// find closest point to initial starting point within each polygon +initialize picked
|
||||
for (PolygonRef poly : polygons) /// find closest point to initial starting point within each polygon +initialize picked
|
||||
{
|
||||
int best = -1;
|
||||
float bestDist = std::numeric_limits<float>::infinity();
|
||||
@@ -102,15 +102,15 @@ int PathOrderOptimizer::getPolyStart(Point prev_point, int poly_idx)
|
||||
|
||||
int PathOrderOptimizer::getClosestPointInPolygon(Point prev_point, int poly_idx)
|
||||
{
|
||||
ConstPolygonRef poly = polygons[poly_idx];
|
||||
PolygonRef poly = polygons[poly_idx];
|
||||
|
||||
int best_point_idx = -1;
|
||||
float best_point_score = std::numeric_limits<float>::infinity();
|
||||
Point p0 = poly.back();
|
||||
for (unsigned int point_idx = 0; point_idx < poly.size(); point_idx++)
|
||||
{
|
||||
const Point& p1 = poly[point_idx];
|
||||
const Point& p2 = poly[(point_idx + 1) % poly.size()];
|
||||
Point& p1 = poly[point_idx];
|
||||
Point& p2 = poly[(point_idx + 1) % poly.size()];
|
||||
int64_t dist = vSize2(p1 - prev_point);
|
||||
float is_on_inside_corner_score = -LinearAlg2D::getAngleLeft(p0, p1, p2) / M_PI * 5000 * 5000; // prefer inside corners
|
||||
// this score is in the order of 5 mm
|
||||
@@ -143,7 +143,7 @@ void LineOrderOptimizer::optimize()
|
||||
{
|
||||
int best_point_idx = -1;
|
||||
float best_point_dist = std::numeric_limits<float>::infinity();
|
||||
ConstPolygonRef poly = polygons[poly_idx];
|
||||
PolygonRef poly = polygons[poly_idx];
|
||||
for (unsigned int point_idx = 0; point_idx < poly.size(); point_idx++) /// get closest point from polygon
|
||||
{
|
||||
float dist = vSize2f(poly[point_idx] - startPoint);
|
||||
@@ -199,13 +199,13 @@ void LineOrderOptimizer::optimize()
|
||||
|
||||
if (best_line_idx > -1) /// should always be true; we should have been able to identify the best next polygon
|
||||
{
|
||||
ConstPolygonRef best_line = polygons[best_line_idx];
|
||||
PolygonRef best_line = polygons[best_line_idx];
|
||||
assert(best_line.size() == 2);
|
||||
|
||||
int line_start_point_idx = polyStart[best_line_idx];
|
||||
int line_end_point_idx = line_start_point_idx * -1 + 1; /// 1 -> 0 , 0 -> 1
|
||||
const Point& line_start = best_line[line_start_point_idx];
|
||||
const Point& line_end = best_line[line_end_point_idx];
|
||||
Point& line_start = best_line[line_start_point_idx];
|
||||
Point& line_end = best_line[line_end_point_idx];
|
||||
prev_point = line_end;
|
||||
incoming_perpundicular_normal = turn90CCW(normal(line_end - line_start, 1000));
|
||||
|
||||
@@ -221,8 +221,8 @@ void LineOrderOptimizer::optimize()
|
||||
|
||||
inline void LineOrderOptimizer::updateBestLine(unsigned int poly_idx, int& best, float& best_score, Point prev_point, Point incoming_perpundicular_normal)
|
||||
{
|
||||
const Point& p0 = polygons[poly_idx][0];
|
||||
const Point& p1 = polygons[poly_idx][1];
|
||||
Point& p0 = polygons[poly_idx][0];
|
||||
Point& p1 = polygons[poly_idx][1];
|
||||
float dot_score = getAngleScore(incoming_perpundicular_normal, p0, p1);
|
||||
{ /// check distance to first point on line (0)
|
||||
float score = vSize2f(p0 - prev_point) + dot_score; // prefer 90 degree corners
|
||||
|
||||
@@ -20,7 +20,7 @@ public:
|
||||
EZSeamType type;
|
||||
Point startPoint; //!< A location near the prefered start location
|
||||
Point z_seam_pos; //!< The position near where to create the z_seam (if \ref PathOrderOptimizer::type == 'back')
|
||||
std::vector<ConstPolygonRef> polygons; //!< the parts of the layer (in arbitrary order)
|
||||
std::vector<PolygonRef> polygons; //!< the parts of the layer (in arbitrary order)
|
||||
std::vector<int> polyStart; //!< polygons[i][polyStart[i]] = point of polygon i which is to be the starting point in printing the polygon
|
||||
std::vector<int> polyOrder; //!< the optimized order as indices in #polygons
|
||||
|
||||
@@ -33,15 +33,10 @@ public:
|
||||
|
||||
void addPolygon(PolygonRef polygon)
|
||||
{
|
||||
this->polygons.emplace_back(polygon);
|
||||
this->polygons.push_back(polygon);
|
||||
}
|
||||
|
||||
void addPolygon(ConstPolygonRef polygon)
|
||||
{
|
||||
this->polygons.emplace_back(polygon);
|
||||
}
|
||||
|
||||
void addPolygons(const Polygons& polygons)
|
||||
void addPolygons(Polygons& polygons)
|
||||
{
|
||||
for(unsigned int i=0;i<polygons.size(); i++)
|
||||
this->polygons.push_back(polygons[i]);
|
||||
@@ -71,7 +66,7 @@ class LineOrderOptimizer
|
||||
{
|
||||
public:
|
||||
Point startPoint; //!< The location of the nozzle before starting to print the current layer
|
||||
std::vector<ConstPolygonRef> polygons; //!< the parts of the layer (in arbitrary order)
|
||||
std::vector<PolygonRef> polygons; //!< the parts of the layer (in arbitrary order)
|
||||
std::vector<int> polyStart; //!< polygons[i][polyStart[i]] = point of polygon i which is to be the starting point in printing the polygon
|
||||
std::vector<int> polyOrder; //!< the optimized order as indices in #polygons
|
||||
|
||||
@@ -85,11 +80,6 @@ public:
|
||||
this->polygons.push_back(polygon);
|
||||
}
|
||||
|
||||
void addPolygon(ConstPolygonRef polygon)
|
||||
{
|
||||
this->polygons.push_back(polygon);
|
||||
}
|
||||
|
||||
void addPolygons(Polygons& polygons)
|
||||
{
|
||||
for(unsigned int i=0;i<polygons.size(); i++)
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
#include <unordered_set>
|
||||
|
||||
#include "../utils/polygonUtils.h"
|
||||
#include "../utils/linearAlg2D.h"
|
||||
#include "../utils/PolygonsPointIndex.h"
|
||||
#include "../sliceDataStorage.h"
|
||||
#include "../utils/SVG.h"
|
||||
@@ -23,7 +22,7 @@ Polygons& Comb::getBoundaryOutside()
|
||||
return *boundary_outside;
|
||||
}
|
||||
|
||||
Comb::Comb(const SliceDataStorage& storage, int layer_nr, const Polygons& comb_boundary_inside, int64_t comb_boundary_offset, bool travel_avoid_other_parts, int64_t travel_avoid_distance)
|
||||
Comb::Comb(SliceDataStorage& storage, int layer_nr, Polygons& comb_boundary_inside, int64_t comb_boundary_offset, bool travel_avoid_other_parts, int64_t travel_avoid_distance)
|
||||
: storage(storage)
|
||||
, layer_nr(layer_nr)
|
||||
, offset_from_outlines(comb_boundary_offset) // between second wall and infill / other walls
|
||||
@@ -32,7 +31,7 @@ Comb::Comb(const SliceDataStorage& storage, int layer_nr, const Polygons& comb_b
|
||||
, offset_from_inside_to_outside(offset_from_outlines + offset_from_outlines_outside)
|
||||
, max_crossing_dist2(offset_from_inside_to_outside * offset_from_inside_to_outside * 2) // so max_crossing_dist = offset_from_inside_to_outside * sqrt(2) =approx 1.5 to allow for slightly diagonal crossings and slightly inaccurate crossing computation
|
||||
, avoid_other_parts(travel_avoid_other_parts)
|
||||
, boundary_inside( comb_boundary_inside ) // copy the boundary, because the partsView_inside will reorder the polygons
|
||||
, boundary_inside( comb_boundary_inside )
|
||||
, partsView_inside( boundary_inside.splitIntoPartsView() ) // WARNING !! changes the order of boundary_inside !!
|
||||
, inside_loc_to_line(PolygonUtils::createLocToLineGrid(boundary_inside, comb_boundary_offset))
|
||||
, boundary_outside(
|
||||
@@ -214,7 +213,7 @@ Comb::Crossing::Crossing(const Point& dest_point, const bool dest_is_inside, con
|
||||
{
|
||||
if (dest_is_inside)
|
||||
{
|
||||
dest_crossing_poly.emplace(boundary_inside[dest_part_boundary_crossing_poly_idx]); // initialize with most obvious poly, cause mostly a combing move will move outside the part, rather than inside a hole in the part
|
||||
dest_crossing_poly = boundary_inside[dest_part_boundary_crossing_poly_idx]; // initialize with most obvious poly, cause mostly a combing move will move outside the part, rather than inside a hole in the part
|
||||
}
|
||||
}
|
||||
|
||||
@@ -333,7 +332,7 @@ bool Comb::Crossing::findOutside(const Polygons& outside, const Point close_to,
|
||||
}
|
||||
|
||||
|
||||
std::shared_ptr<std::pair<ClosestPolygonPoint, ClosestPolygonPoint>> Comb::Crossing::findBestCrossing(const Polygons& outside, ConstPolygonRef from, const Point estimated_start, const Point estimated_end, Comb& comber)
|
||||
std::shared_ptr<std::pair<ClosestPolygonPoint, ClosestPolygonPoint>> Comb::Crossing::findBestCrossing(const Polygons& outside, const PolygonRef from, const Point estimated_start, const Point estimated_end, Comb& comber)
|
||||
{
|
||||
ClosestPolygonPoint* best_in = nullptr;
|
||||
ClosestPolygonPoint* best_out = nullptr;
|
||||
|
||||
@@ -48,7 +48,7 @@ private:
|
||||
Point in_or_mid; //!< The point on the inside boundary, or in between the inside and outside boundary if the start/end point isn't inside the inside boudary
|
||||
Point out; //!< The point on the outside boundary
|
||||
PolygonsPart dest_part; //!< The assembled inside-boundary PolygonsPart in which the dest_point lies. (will only be initialized when Crossing::dest_is_inside holds)
|
||||
std::optional<ConstPolygonRef> dest_crossing_poly; //!< The polygon of the part in which dest_point lies, which will be crossed (often will be the outside polygon)
|
||||
std::optional<PolygonRef> dest_crossing_poly; //!< The polygon of the part in which dest_point lies, which will be crossed (often will be the outside polygon)
|
||||
const Polygons& boundary_inside; //!< The inside boundary as in \ref Comb::boundary_inside
|
||||
const LocToLineGrid* inside_loc_to_line; //!< The loc to line grid \ref Comb::inside_loc_to_line
|
||||
|
||||
@@ -97,11 +97,11 @@ private:
|
||||
* \param comber[in] The combing calculator which has references to the offsets and boundaries to use in combing.
|
||||
* \return A pair of which the first is the crossing point on the inside boundary and the second the crossing point on the outside boundary
|
||||
*/
|
||||
std::shared_ptr<std::pair<ClosestPolygonPoint, ClosestPolygonPoint>> findBestCrossing(const Polygons& outside, ConstPolygonRef from, Point estimated_start, Point estimated_end, Comb& comber);
|
||||
std::shared_ptr<std::pair<ClosestPolygonPoint, ClosestPolygonPoint>> findBestCrossing(const Polygons& outside, const PolygonRef from, Point estimated_start, Point estimated_end, Comb& comber);
|
||||
};
|
||||
|
||||
|
||||
const SliceDataStorage& storage; //!< The storage from which to compute the outside boundary, when needed.
|
||||
SliceDataStorage& storage; //!< The storage from which to compute the outside boundary, when needed.
|
||||
const int layer_nr; //!< The layer number for the layer for which to compute the outside boundary, when needed.
|
||||
|
||||
const int64_t offset_from_outlines; //!< Offset from the boundary of a part to the comb path. (nozzle width / 2)
|
||||
@@ -115,8 +115,8 @@ private:
|
||||
|
||||
const bool avoid_other_parts; //!< Whether to perform inverse combing a.k.a. avoid parts.
|
||||
|
||||
Polygons boundary_inside; //!< The boundary within which to comb. (Will be reordered by the partsView_inside)
|
||||
const PartsView partsView_inside; //!< Structured indices onto boundary_inside which shows which polygons belong to which part.
|
||||
Polygons& boundary_inside; //!< The boundary within which to comb.
|
||||
PartsView partsView_inside; //!< Structured indices onto boundary_inside which shows which polygons belong to which part.
|
||||
LocToLineGrid* inside_loc_to_line; //!< The SparsePointGridInclusive mapping locations to line segments of the inner boundary.
|
||||
LazyInitialization<Polygons> boundary_outside; //!< The boundary outside of which to stay to avoid collision with other layer parts. This is a pointer cause we only compute it when we move outside the boundary (so not when there is only a single part in the layer)
|
||||
LazyInitialization<LocToLineGrid, Comb*, const int64_t> outside_loc_to_line; //!< The SparsePointGridInclusive mapping locations to line segments of the outside boundary.
|
||||
@@ -153,7 +153,7 @@ public:
|
||||
* \param travel_avoid_other_parts Whether to avoid other layer parts when traveling through air.
|
||||
* \param travel_avoid_distance The distance by which to avoid other layer parts when traveling through air.
|
||||
*/
|
||||
Comb(const SliceDataStorage& storage, int layer_nr, const Polygons& comb_boundary_inside, int64_t offset_from_outlines, bool travel_avoid_other_parts, int64_t travel_avoid_distance);
|
||||
Comb(SliceDataStorage& storage, int layer_nr, Polygons& comb_boundary_inside, int64_t offset_from_outlines, bool travel_avoid_other_parts, int64_t travel_avoid_distance);
|
||||
|
||||
~Comb();
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ namespace cura
|
||||
class GCodePath
|
||||
{
|
||||
public:
|
||||
const GCodePathConfig* config; //!< The configuration settings of the path.
|
||||
GCodePathConfig* config; //!< The configuration settings of the path.
|
||||
SpaceFillType space_fill_type; //!< The type of space filling of which this path is a part
|
||||
float flow; //!< A type-independent flow configuration (used for wall overlap compensation)
|
||||
bool retract; //!< Whether the path is a move path preceded by a retraction move; whether the path is a retracted move path.
|
||||
|
||||
@@ -1,235 +0,0 @@
|
||||
/** Copyright (C) 2017 Ultimaker - Released under terms of the AGPLv3 License */
|
||||
#include "PathConfigStorage.h"
|
||||
|
||||
#include "settings.h" // MAX_INFILL_COMBINE
|
||||
#include "../sliceDataStorage.h" // SliceDataStorage
|
||||
|
||||
|
||||
namespace cura
|
||||
{
|
||||
|
||||
GCodePathConfig getPerimeterGapConfig(const SliceMeshStorage& mesh, int layer_thickness)
|
||||
{
|
||||
// The perimeter gap config follows the skin config, but has a different line width:
|
||||
// wall_line_width_x divided by two because the gaps are between 0 and 1 times the wall line width
|
||||
const int perimeter_gaps_line_width = mesh.getSettingInMicrons("wall_line_width_x") / 2;
|
||||
double perimeter_gaps_speed = mesh.getSettingInMillimetersPerSecond("speed_topbottom");
|
||||
if (mesh.getSettingBoolean("speed_equalize_flow_enabled"))
|
||||
{
|
||||
perimeter_gaps_speed = perimeter_gaps_speed * mesh.getSettingInMicrons("skin_line_width") / perimeter_gaps_line_width;
|
||||
}
|
||||
return GCodePathConfig(
|
||||
PrintFeatureType::Skin
|
||||
, perimeter_gaps_line_width
|
||||
, layer_thickness
|
||||
, mesh.getSettingInPercentage("material_flow")
|
||||
, GCodePathConfig::SpeedDerivatives{perimeter_gaps_speed, mesh.getSettingInMillimetersPerSecond("acceleration_topbottom"), mesh.getSettingInMillimetersPerSecond("jerk_topbottom")}
|
||||
);
|
||||
}
|
||||
|
||||
PathConfigStorage::MeshPathConfigs::MeshPathConfigs(const SliceMeshStorage& mesh, int layer_thickness)
|
||||
: inset0_config(
|
||||
PrintFeatureType::OuterWall
|
||||
, mesh.getSettingInMicrons("wall_line_width_0")
|
||||
, layer_thickness
|
||||
, mesh.getSettingInPercentage("material_flow")
|
||||
, GCodePathConfig::SpeedDerivatives{mesh.getSettingInMillimetersPerSecond("speed_wall_0"), mesh.getSettingInMillimetersPerSecond("acceleration_wall_0"), mesh.getSettingInMillimetersPerSecond("jerk_wall_0")}
|
||||
)
|
||||
, insetX_config(
|
||||
PrintFeatureType::InnerWall
|
||||
, mesh.getSettingInMicrons("wall_line_width_x")
|
||||
, layer_thickness
|
||||
, mesh.getSettingInPercentage("material_flow")
|
||||
, GCodePathConfig::SpeedDerivatives{mesh.getSettingInMillimetersPerSecond("speed_wall_x"), mesh.getSettingInMillimetersPerSecond("acceleration_wall_x"), mesh.getSettingInMillimetersPerSecond("jerk_wall_x")}
|
||||
)
|
||||
, skin_config(
|
||||
PrintFeatureType::Skin
|
||||
, mesh.getSettingInMicrons("skin_line_width")
|
||||
, layer_thickness
|
||||
, mesh.getSettingInPercentage("material_flow")
|
||||
, GCodePathConfig::SpeedDerivatives{mesh.getSettingInMillimetersPerSecond("speed_topbottom"), mesh.getSettingInMillimetersPerSecond("acceleration_topbottom"), mesh.getSettingInMillimetersPerSecond("jerk_topbottom")}
|
||||
)
|
||||
|
||||
, perimeter_gap_config(getPerimeterGapConfig(mesh, layer_thickness))
|
||||
{
|
||||
infill_config.reserve(MAX_INFILL_COMBINE);
|
||||
for (int combine_idx = 0; combine_idx < MAX_INFILL_COMBINE; combine_idx++)
|
||||
{
|
||||
infill_config.emplace_back(
|
||||
PrintFeatureType::Infill
|
||||
, mesh.getSettingInMicrons("infill_line_width") * (combine_idx + 1)
|
||||
, layer_thickness
|
||||
, mesh.getSettingInPercentage("material_flow")
|
||||
, GCodePathConfig::SpeedDerivatives{mesh.getSettingInMillimetersPerSecond("speed_infill"), mesh.getSettingInMillimetersPerSecond("acceleration_infill"), mesh.getSettingInMillimetersPerSecond("jerk_infill")}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
PathConfigStorage::PathConfigStorage(const SliceDataStorage& storage, int layer_nr, int layer_thickness)
|
||||
: adhesion_extruder_train(storage.meshgroup->getExtruderTrain(storage.getSettingAsIndex("adhesion_extruder_nr")))
|
||||
, support_infill_train(storage.meshgroup->getExtruderTrain(storage.getSettingAsIndex("support_infill_extruder_nr")))
|
||||
, support_interface_train(storage.meshgroup->getExtruderTrain(storage.getSettingAsIndex("support_interface_extruder_nr")))
|
||||
, raft_base_config(
|
||||
PrintFeatureType::SupportInterface
|
||||
, adhesion_extruder_train->getSettingInMicrons("raft_base_line_width")
|
||||
, adhesion_extruder_train->getSettingInMicrons("raft_base_thickness")
|
||||
, adhesion_extruder_train->getSettingInPercentage("material_flow")
|
||||
, GCodePathConfig::SpeedDerivatives{adhesion_extruder_train->getSettingInMillimetersPerSecond("raft_base_speed"), adhesion_extruder_train->getSettingInMillimetersPerSecond("raft_base_acceleration"), adhesion_extruder_train->getSettingInMillimetersPerSecond("raft_base_jerk")}
|
||||
)
|
||||
, raft_interface_config(
|
||||
PrintFeatureType::Support
|
||||
, adhesion_extruder_train->getSettingInMicrons("raft_interface_line_width")
|
||||
, adhesion_extruder_train->getSettingInMicrons("raft_interface_thickness")
|
||||
, adhesion_extruder_train->getSettingInPercentage("material_flow")
|
||||
, GCodePathConfig::SpeedDerivatives{adhesion_extruder_train->getSettingInMillimetersPerSecond("raft_interface_speed"), adhesion_extruder_train->getSettingInMillimetersPerSecond("raft_interface_acceleration"), adhesion_extruder_train->getSettingInMillimetersPerSecond("raft_interface_jerk")}
|
||||
)
|
||||
, raft_surface_config(
|
||||
PrintFeatureType::SupportInterface
|
||||
, adhesion_extruder_train->getSettingInMicrons("raft_surface_line_width")
|
||||
, adhesion_extruder_train->getSettingInMicrons("raft_surface_thickness")
|
||||
, adhesion_extruder_train->getSettingInPercentage("material_flow")
|
||||
, GCodePathConfig::SpeedDerivatives{adhesion_extruder_train->getSettingInMillimetersPerSecond("raft_surface_speed"), adhesion_extruder_train->getSettingInMillimetersPerSecond("raft_surface_acceleration"), adhesion_extruder_train->getSettingInMillimetersPerSecond("raft_surface_jerk")}
|
||||
)
|
||||
, support_infill_config(
|
||||
PrintFeatureType::Support
|
||||
, support_infill_train->getSettingInMicrons("support_line_width")
|
||||
, layer_thickness
|
||||
, support_infill_train->getSettingInPercentage("material_flow")
|
||||
, GCodePathConfig::SpeedDerivatives{support_infill_train->getSettingInMillimetersPerSecond("speed_support_infill"), support_infill_train->getSettingInMillimetersPerSecond("acceleration_support_infill"), support_infill_train->getSettingInMillimetersPerSecond("jerk_support_infill")}
|
||||
)
|
||||
, support_interface_config(
|
||||
PrintFeatureType::SupportInterface
|
||||
, support_interface_train->getSettingInMicrons("support_interface_line_width")
|
||||
, layer_thickness
|
||||
, support_interface_train->getSettingInPercentage("material_flow")
|
||||
, GCodePathConfig::SpeedDerivatives{support_interface_train->getSettingInMillimetersPerSecond("speed_support_interface"), support_interface_train->getSettingInMillimetersPerSecond("acceleration_support_interface"), support_interface_train->getSettingInMillimetersPerSecond("jerk_support_interface")}
|
||||
)
|
||||
{
|
||||
int extruder_count = storage.meshgroup->getExtruderCount();
|
||||
travel_config_per_extruder.reserve(extruder_count);
|
||||
skirt_brim_config.reserve(extruder_count);
|
||||
prime_tower_config_per_extruder.reserve(extruder_count);
|
||||
for (int extruder_nr = 0; extruder_nr < extruder_count; extruder_nr++)
|
||||
{
|
||||
const ExtruderTrain* train = storage.meshgroup->getExtruderTrain(extruder_nr);
|
||||
travel_config_per_extruder.emplace_back(
|
||||
PrintFeatureType::MoveCombing
|
||||
, 0
|
||||
, 0
|
||||
, 0.0
|
||||
, GCodePathConfig::SpeedDerivatives{train->getSettingInMillimetersPerSecond("speed_travel"), train->getSettingInMillimetersPerSecond("acceleration_travel"), train->getSettingInMillimetersPerSecond("jerk_travel")}
|
||||
);
|
||||
skirt_brim_config.emplace_back(
|
||||
PrintFeatureType::SkirtBrim
|
||||
, train->getSettingInMicrons("skirt_brim_line_width")
|
||||
, layer_thickness
|
||||
, train->getSettingInPercentage("material_flow")
|
||||
, GCodePathConfig::SpeedDerivatives{train->getSettingInMillimetersPerSecond("skirt_brim_speed"), train->getSettingInMillimetersPerSecond("acceleration_skirt_brim"), train->getSettingInMillimetersPerSecond("jerk_skirt_brim")}
|
||||
);
|
||||
prime_tower_config_per_extruder.emplace_back(
|
||||
PrintFeatureType::SupportInfill
|
||||
, train->getSettingInMicrons("prime_tower_line_width")
|
||||
, layer_thickness
|
||||
, train->getSettingInPercentage("prime_tower_flow")
|
||||
, GCodePathConfig::SpeedDerivatives{train->getSettingInMillimetersPerSecond("speed_prime_tower"), train->getSettingInMillimetersPerSecond("acceleration_prime_tower"), train->getSettingInMillimetersPerSecond("jerk_prime_tower")}
|
||||
);
|
||||
}
|
||||
|
||||
mesh_configs.reserve(storage.meshes.size());
|
||||
for (const SliceMeshStorage& mesh_storage : storage.meshes)
|
||||
{
|
||||
mesh_configs.emplace_back(mesh_storage, layer_thickness);
|
||||
}
|
||||
|
||||
int initial_speedup_layer_count = storage.getSettingAsCount("speed_slowdown_layers");
|
||||
if (layer_nr < initial_speedup_layer_count)
|
||||
{
|
||||
handleInitialLayerSpeedup(storage, layer_nr, initial_speedup_layer_count);
|
||||
}
|
||||
}
|
||||
|
||||
void cura::PathConfigStorage::handleInitialLayerSpeedup(const SliceDataStorage& storage, int layer_nr, int initial_speedup_layer_count)
|
||||
{
|
||||
std::vector<GCodePathConfig::SpeedDerivatives> global_first_layer_config_per_extruder;
|
||||
global_first_layer_config_per_extruder.reserve(storage.meshgroup->getExtruderCount());
|
||||
for (int extruder_nr = 0; extruder_nr < storage.meshgroup->getExtruderCount(); extruder_nr++)
|
||||
{
|
||||
const ExtruderTrain* extruder = storage.meshgroup->getExtruderTrain(extruder_nr);
|
||||
global_first_layer_config_per_extruder.emplace_back(
|
||||
GCodePathConfig::SpeedDerivatives{
|
||||
extruder->getSettingInMillimetersPerSecond("speed_print_layer_0")
|
||||
, extruder->getSettingInMillimetersPerSecond("acceleration_print_layer_0")
|
||||
, extruder->getSettingInMillimetersPerSecond("jerk_print_layer_0")
|
||||
});
|
||||
}
|
||||
|
||||
{ // support
|
||||
if (layer_nr < initial_speedup_layer_count)
|
||||
{
|
||||
int extruder_nr_support_infill = storage.getSettingAsIndex((layer_nr <= 0)? "support_extruder_nr_layer_0" : "support_infill_extruder_nr");
|
||||
GCodePathConfig::SpeedDerivatives& first_layer_config_infill = global_first_layer_config_per_extruder[extruder_nr_support_infill];
|
||||
support_infill_config.smoothSpeed(first_layer_config_infill, std::max(0, layer_nr), initial_speedup_layer_count);
|
||||
|
||||
int extruder_nr_support_interface = storage.getSettingAsIndex("support_interface_extruder_nr");
|
||||
GCodePathConfig::SpeedDerivatives& first_layer_config_interface = global_first_layer_config_per_extruder[extruder_nr_support_interface];
|
||||
support_interface_config.smoothSpeed(first_layer_config_interface, std::max(0, layer_nr), initial_speedup_layer_count);
|
||||
}
|
||||
}
|
||||
|
||||
{ // extruder configs: travel, skirt/brim (= shield)
|
||||
for (int extruder_nr = 0; extruder_nr < storage.meshgroup->getExtruderCount(); ++extruder_nr)
|
||||
{
|
||||
const ExtruderTrain* train = storage.meshgroup->getExtruderTrain(extruder_nr);
|
||||
GCodePathConfig::SpeedDerivatives initial_layer_speed_config{
|
||||
train->getSettingInMillimetersPerSecond("speed_travel_layer_0")
|
||||
, train->getSettingInMillimetersPerSecond("acceleration_travel_layer_0")
|
||||
, train->getSettingInMillimetersPerSecond("jerk_travel_layer_0")
|
||||
};
|
||||
GCodePathConfig& travel = travel_config_per_extruder[extruder_nr];
|
||||
|
||||
travel.smoothSpeed(initial_layer_speed_config, std::max(0, layer_nr), initial_speedup_layer_count);
|
||||
|
||||
// don't smooth speed for the skirt/brim!
|
||||
// NOTE: not smoothing skirt/brim means the speeds are also not smoothed for the draft/ooze shield
|
||||
|
||||
GCodePathConfig& prime_tower = prime_tower_config_per_extruder[extruder_nr];
|
||||
|
||||
prime_tower.smoothSpeed(initial_layer_speed_config, std::max(0, layer_nr), initial_speedup_layer_count);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
{ // meshes
|
||||
for (unsigned int mesh_idx = 0; mesh_idx < storage.meshes.size(); mesh_idx++)
|
||||
{
|
||||
const SliceMeshStorage& mesh = storage.meshes[mesh_idx];
|
||||
|
||||
|
||||
GCodePathConfig::SpeedDerivatives initial_layer_speed_config{
|
||||
mesh.getSettingInMillimetersPerSecond("speed_print_layer_0")
|
||||
, mesh.getSettingInMillimetersPerSecond("acceleration_print_layer_0")
|
||||
, mesh.getSettingInMillimetersPerSecond("jerk_print_layer_0")
|
||||
};
|
||||
|
||||
MeshPathConfigs& mesh_config = mesh_configs[mesh_idx];
|
||||
//Outer wall speed (per mesh).
|
||||
mesh_config.inset0_config.smoothSpeed(initial_layer_speed_config, layer_nr, initial_speedup_layer_count);
|
||||
|
||||
//Inner wall speed (per mesh).
|
||||
mesh_config.insetX_config.smoothSpeed(initial_layer_speed_config, layer_nr, initial_speedup_layer_count);
|
||||
|
||||
//Skin speed (per mesh).
|
||||
mesh_config.skin_config.smoothSpeed(initial_layer_speed_config, layer_nr, initial_speedup_layer_count);
|
||||
mesh_config.perimeter_gap_config.smoothSpeed(initial_layer_speed_config, layer_nr, initial_speedup_layer_count);
|
||||
|
||||
for (unsigned int idx = 0; idx < MAX_INFILL_COMBINE; idx++)
|
||||
{
|
||||
//Infill speed (per combine part per mesh).
|
||||
mesh_config.infill_config[idx].smoothSpeed(initial_layer_speed_config, layer_nr, initial_speedup_layer_count);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}//namespace cura
|
||||
@@ -1,63 +0,0 @@
|
||||
/** Copyright (C) 2017 Ultimaker - Released under terms of the AGPLv3 License */
|
||||
#ifndef SETTINGS_PATH_CONFIGS_H
|
||||
#define SETTINGS_PATH_CONFIGS_H
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "../utils/intpoint.h" // coord_t
|
||||
#include "../GCodePathConfig.h"
|
||||
|
||||
namespace cura
|
||||
{
|
||||
|
||||
class SliceDataStorage; // forward decl for SliceDataStorage
|
||||
class SliceMeshStorage; // forward decl for SliceDataStorage
|
||||
class ExtruderTrain; // forward decl for SliceDataStorage
|
||||
|
||||
/*!
|
||||
* A class to represent all configurations for all features types of printed lines in a meshgroup.
|
||||
*/
|
||||
class PathConfigStorage
|
||||
{
|
||||
private:
|
||||
const ExtruderTrain* adhesion_extruder_train;
|
||||
const ExtruderTrain* support_infill_train;
|
||||
const ExtruderTrain* support_interface_train;
|
||||
public:
|
||||
class MeshPathConfigs
|
||||
{
|
||||
public:
|
||||
GCodePathConfig inset0_config;
|
||||
GCodePathConfig insetX_config;
|
||||
GCodePathConfig skin_config;
|
||||
GCodePathConfig perimeter_gap_config;
|
||||
std::vector<GCodePathConfig> infill_config;
|
||||
|
||||
MeshPathConfigs(const SliceMeshStorage& mesh, int layer_thickness);
|
||||
};
|
||||
|
||||
GCodePathConfig raft_base_config;
|
||||
GCodePathConfig raft_interface_config;
|
||||
GCodePathConfig raft_surface_config;
|
||||
|
||||
std::vector<GCodePathConfig> travel_config_per_extruder; //!< The config used for travel moves (only speed is set!)
|
||||
std::vector<GCodePathConfig> skirt_brim_config; //!< Configuration for skirt and brim per extruder.
|
||||
std::vector<GCodePathConfig> prime_tower_config_per_extruder; //!< Configuration for the prime tower per extruder.
|
||||
|
||||
GCodePathConfig support_infill_config; //!< The config used to print the normal support, rather than the support interface
|
||||
GCodePathConfig support_interface_config; //!< The config to use to print the dense roofs and bottoms of support
|
||||
|
||||
std::vector<MeshPathConfigs> mesh_configs; //!< For each meash the config for all its feature types
|
||||
|
||||
/*!
|
||||
* \warning Note that the layer_nr might be below zero for raft (filler) layers
|
||||
*/
|
||||
PathConfigStorage(const SliceDataStorage& storage, int layer_nr, int layer_thickness);
|
||||
|
||||
private:
|
||||
void handleInitialLayerSpeedup(const SliceDataStorage& storage, int layer_nr, int initial_speedup_layer_count);
|
||||
};
|
||||
|
||||
}; // namespace cura
|
||||
|
||||
#endif // SETTINGS_PATH_CONFIGS_H
|
||||
@@ -93,23 +93,21 @@ void SettingsBase::setSettingInheritBase(std::string key, const SettingsBaseVirt
|
||||
|
||||
std::string SettingsBase::getSettingString(std::string key) const
|
||||
{
|
||||
auto value_it = setting_values.find(key);
|
||||
if (value_it != setting_values.end())
|
||||
if (setting_values.find(key) != setting_values.end())
|
||||
{
|
||||
return value_it->second;
|
||||
return setting_values.at(key);
|
||||
}
|
||||
auto inherit_override_it = setting_inherit_base.find(key);
|
||||
if (inherit_override_it != setting_inherit_base.end())
|
||||
if (setting_inherit_base.find(key) != setting_inherit_base.end())
|
||||
{
|
||||
return inherit_override_it->second->getSettingString(key);
|
||||
return setting_inherit_base.at(key)->getSettingString(key);
|
||||
}
|
||||
if (parent)
|
||||
{
|
||||
return parent->getSettingString(key);
|
||||
}
|
||||
|
||||
cura::logError("Trying to retrieve unregistered setting with no value given: '%s'\n", key.c_str());
|
||||
std::exit(-1);
|
||||
const_cast<SettingsBase&>(*this).setting_values[key] = "";
|
||||
cura::logWarning("Unregistered setting %s\n", key.c_str());
|
||||
return "";
|
||||
}
|
||||
|
||||
@@ -428,7 +426,7 @@ FillPerimeterGapMode SettingsBaseVirtual::getSettingAsFillPerimeterGapMode(std::
|
||||
return FillPerimeterGapMode::NOWHERE;
|
||||
}
|
||||
|
||||
CombingMode SettingsBaseVirtual::getSettingAsCombingMode(std::string key) const
|
||||
CombingMode SettingsBaseVirtual::getSettingAsCombingMode(std::string key)
|
||||
{
|
||||
std::string value = getSettingString(key);
|
||||
if (value == "off")
|
||||
@@ -446,7 +444,7 @@ CombingMode SettingsBaseVirtual::getSettingAsCombingMode(std::string key) const
|
||||
return CombingMode::ALL;
|
||||
}
|
||||
|
||||
SupportDistPriority SettingsBaseVirtual::getSettingAsSupportDistPriority(std::string key) const
|
||||
SupportDistPriority SettingsBaseVirtual::getSettingAsSupportDistPriority(std::string key)
|
||||
{
|
||||
std::string value = getSettingString(key);
|
||||
if (value == "xy_overrides_z")
|
||||
|
||||
@@ -251,8 +251,8 @@ public:
|
||||
EZSeamType getSettingAsZSeamType(std::string key) const;
|
||||
ESurfaceMode getSettingAsSurfaceMode(std::string key) const;
|
||||
FillPerimeterGapMode getSettingAsFillPerimeterGapMode(std::string key) const;
|
||||
CombingMode getSettingAsCombingMode(std::string key) const;
|
||||
SupportDistPriority getSettingAsSupportDistPriority(std::string key) const;
|
||||
CombingMode getSettingAsCombingMode(std::string key);
|
||||
SupportDistPriority getSettingAsSupportDistPriority(std::string key);
|
||||
};
|
||||
|
||||
class SettingRegistry;
|
||||
|
||||
+2
-28
@@ -10,16 +10,7 @@
|
||||
namespace cura
|
||||
{
|
||||
|
||||
|
||||
/*
|
||||
* This function is executed in a parallel region based on layer_nr.
|
||||
* When modifying make sure any changes does not introduce data races.
|
||||
*
|
||||
* generateSkinAreas reads data from mesh.layers.parts[*].insets and writes to mesh.layers[n].parts[*].skin_parts
|
||||
* generateSkinInsets only read/writes the skin_parts from the current layer.
|
||||
*
|
||||
* generateSkins therefore reads (depends on) data from mesh.layers[*].parts[*].insets and writes mesh.layers[n].parts[*].skin_parts
|
||||
*/
|
||||
|
||||
void generateSkins(int layerNr, SliceMeshStorage& mesh, int downSkinCount, int upSkinCount, int wall_line_count, int innermost_wall_line_width, int insetCount, bool no_small_gaps_heuristic)
|
||||
{
|
||||
generateSkinAreas(layerNr, mesh, innermost_wall_line_width, downSkinCount, upSkinCount, wall_line_count, no_small_gaps_heuristic);
|
||||
@@ -32,12 +23,6 @@ void generateSkins(int layerNr, SliceMeshStorage& mesh, int downSkinCount, int u
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* This function is executed in a parallel region based on layer_nr.
|
||||
* When modifying make sure any changes does not introduce data races.
|
||||
*
|
||||
* generateSkinAreas reads data from mesh.layers[*].parts[*].insets and writes to mesh.layers[n].parts[*].skin_parts
|
||||
*/
|
||||
void generateSkinAreas(int layer_nr, SliceMeshStorage& mesh, const int innermost_wall_line_width, int downSkinCount, int upSkinCount, int wall_line_count, bool no_small_gaps_heuristic)
|
||||
{
|
||||
SliceLayer& layer = mesh.layers[layer_nr];
|
||||
@@ -139,12 +124,7 @@ void generateSkinAreas(int layer_nr, SliceMeshStorage& mesh, const int innermost
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* This function is executed in a parallel region based on layer_nr.
|
||||
* When modifying make sure any changes does not introduce data races.
|
||||
*
|
||||
* generateSkinInsets only read/writes the skin_parts from the current layer.
|
||||
*/
|
||||
|
||||
void generateSkinInsets(SliceLayerPart* part, const int wall_line_width, int insetCount)
|
||||
{
|
||||
if (insetCount == 0)
|
||||
@@ -177,12 +157,6 @@ void generateSkinInsets(SliceLayerPart* part, const int wall_line_width, int ins
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* This function is executed in a parallel region based on layer_nr.
|
||||
* When modifying make sure any changes does not introduce data races.
|
||||
*
|
||||
* generateInfill read mesh.layers[n].parts[*].{insets,skin_parts,boundingBox} and write mesh.layers[n].parts[*].infill_area
|
||||
*/
|
||||
void generateInfill(int layerNr, SliceMeshStorage& mesh, const int innermost_wall_line_width, int infill_skin_overlap, int wall_line_count)
|
||||
{
|
||||
SliceLayer& layer = mesh.layers[layerNr];
|
||||
|
||||
@@ -35,7 +35,7 @@ void SliceLayer::getOutlines(Polygons& result, bool external_polys_only) const
|
||||
{
|
||||
if (external_polys_only)
|
||||
{
|
||||
result.add(part.outline.outerPolygon());
|
||||
result.add(const_cast<SliceLayerPart&>(part).outline.outerPolygon()); // TODO: make a const version of outerPolygon()
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -57,12 +57,12 @@ void SliceLayer::getSecondOrInnermostWalls(Polygons& layer_walls) const
|
||||
{
|
||||
// we want the 2nd inner walls
|
||||
if (part.insets.size() >= 2) {
|
||||
layer_walls.add(part.insets[1]);
|
||||
layer_walls.add(const_cast<SliceLayerPart&>(part).insets[1]); // TODO const cast!
|
||||
continue;
|
||||
}
|
||||
// but we'll also take the inner wall if the 2nd doesn't exist
|
||||
if (part.insets.size() == 1) {
|
||||
layer_walls.add(part.insets[0]);
|
||||
layer_walls.add(const_cast<SliceLayerPart&>(part).insets[0]); // TODO const cast!
|
||||
continue;
|
||||
}
|
||||
// offset_from_outlines was so large that it completely destroyed our isle,
|
||||
@@ -87,11 +87,38 @@ std::vector<RetractionConfig> SliceDataStorage::initializeRetractionConfigs()
|
||||
return ret;
|
||||
}
|
||||
|
||||
std::vector<GCodePathConfig> SliceDataStorage::initializeTravelConfigs()
|
||||
{
|
||||
std::vector<GCodePathConfig> ret;
|
||||
for (int extruder = 0; extruder < meshgroup->getExtruderCount(); extruder++)
|
||||
{
|
||||
travel_config_per_extruder.emplace_back(PrintFeatureType::MoveCombing);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
std::vector<GCodePathConfig> SliceDataStorage::initializeSkirtBrimConfigs()
|
||||
{
|
||||
std::vector<GCodePathConfig> ret;
|
||||
for (int extruder = 0; extruder < meshgroup->getExtruderCount(); extruder++)
|
||||
{
|
||||
skirt_brim_config.emplace_back(PrintFeatureType::SkirtBrim);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
SliceDataStorage::SliceDataStorage(MeshGroup* meshgroup) : SettingsMessenger(meshgroup),
|
||||
meshgroup(meshgroup != nullptr ? meshgroup : new MeshGroup(FffProcessor::getInstance())), //If no mesh group is provided, we roll our own.
|
||||
print_layer_count(0),
|
||||
retraction_config_per_extruder(initializeRetractionConfigs()),
|
||||
extruder_switch_retraction_config_per_extruder(initializeRetractionConfigs()),
|
||||
travel_config_per_extruder(initializeTravelConfigs()),
|
||||
skirt_brim_config(initializeSkirtBrimConfigs()),
|
||||
raft_base_config(PrintFeatureType::SupportInterface),
|
||||
raft_interface_config(PrintFeatureType::Support),
|
||||
raft_surface_config(PrintFeatureType::SupportInterface),
|
||||
support_config(PrintFeatureType::Support),
|
||||
support_skin_config(PrintFeatureType::SupportInterface),
|
||||
max_print_height_second_to_last_extruder(-1),
|
||||
primeTower(*this)
|
||||
{
|
||||
@@ -136,7 +163,7 @@ Polygons SliceDataStorage::getLayerOutlines(int layer_nr, bool include_helper_pa
|
||||
}
|
||||
const SliceLayer& layer = mesh.layers[layer_nr];
|
||||
layer.getOutlines(total, external_polys_only);
|
||||
if (mesh.getSettingAsSurfaceMode("magic_mesh_surface_mode") != ESurfaceMode::NORMAL)
|
||||
if (const_cast<SliceMeshStorage&>(mesh).getSettingAsSurfaceMode("magic_mesh_surface_mode") != ESurfaceMode::NORMAL) // TODO: make all getSetting functions const??
|
||||
{
|
||||
total = total.unionPolygons(layer.openPolyLines.offsetPolyLine(100));
|
||||
}
|
||||
@@ -180,7 +207,7 @@ Polygons SliceDataStorage::getLayerSecondOrInnermostWalls(int layer_nr, bool inc
|
||||
{
|
||||
const SliceLayer& layer = mesh.layers[layer_nr];
|
||||
layer.getSecondOrInnermostWalls(total);
|
||||
if (mesh.getSettingAsSurfaceMode("magic_mesh_surface_mode") != ESurfaceMode::NORMAL)
|
||||
if (const_cast<SliceMeshStorage&>(mesh).getSettingAsSurfaceMode("magic_mesh_surface_mode") != ESurfaceMode::NORMAL) // TODO: make getSetting const? make settings.setting_values mapping mutable??
|
||||
{
|
||||
total = total.unionPolygons(layer.openPolyLines.offsetPolyLine(100));
|
||||
}
|
||||
|
||||
+43
-12
@@ -8,9 +8,10 @@
|
||||
#include "utils/NoCopy.h"
|
||||
#include "utils/AABB.h"
|
||||
#include "mesh.h"
|
||||
#include "gcodePlanner.h"
|
||||
#include "MeshGroup.h"
|
||||
#include "PrimeTower.h"
|
||||
#include "gcodeExport.h" // CoastingConfig
|
||||
#include "GCodePathConfig.h"
|
||||
|
||||
namespace cura
|
||||
{
|
||||
@@ -73,6 +74,8 @@ public:
|
||||
* \return the own infill area
|
||||
*/
|
||||
Polygons& getOwnInfillArea();
|
||||
|
||||
std::vector<std::pair<PolygonsPart, double>> spaghetti_infill_volumes; //!< For each filling volume on this layer, the area within which to fill and the total volume to fill over the area
|
||||
};
|
||||
|
||||
/*!
|
||||
@@ -137,11 +140,7 @@ public:
|
||||
|
||||
std::vector<SupportLayer> supportLayers;
|
||||
|
||||
SupportStorage()
|
||||
: generated(false)
|
||||
, layer_nr_max_filled_layer(-1)
|
||||
{
|
||||
}
|
||||
SupportStorage() : generated(false), layer_nr_max_filled_layer(-1) { }
|
||||
~SupportStorage(){ supportLayers.clear(); }
|
||||
};
|
||||
/******************/
|
||||
@@ -155,14 +154,27 @@ public:
|
||||
|
||||
int layer_nr_max_filled_layer; //!< the layer number of the uppermost layer with content (modified while infill meshes are processed)
|
||||
|
||||
GCodePathConfig inset0_config;
|
||||
GCodePathConfig insetX_config;
|
||||
GCodePathConfig skin_config;
|
||||
GCodePathConfig perimeter_gap_config;
|
||||
std::vector<GCodePathConfig> infill_config;
|
||||
|
||||
SubDivCube* base_subdiv_cube;
|
||||
|
||||
SliceMeshStorage(SettingsBaseVirtual* settings, unsigned int slice_layer_count)
|
||||
: SettingsMessenger(settings)
|
||||
, layer_nr_max_filled_layer(0)
|
||||
, inset0_config(PrintFeatureType::OuterWall)
|
||||
, insetX_config(PrintFeatureType::InnerWall)
|
||||
, skin_config(PrintFeatureType::Skin)
|
||||
, perimeter_gap_config(PrintFeatureType::Skin)
|
||||
, base_subdiv_cube(nullptr)
|
||||
{
|
||||
layers.resize(slice_layer_count);
|
||||
infill_config.reserve(MAX_INFILL_COMBINE);
|
||||
for(int n=0; n<MAX_INFILL_COMBINE; n++)
|
||||
infill_config.emplace_back(PrintFeatureType::Infill);
|
||||
}
|
||||
|
||||
virtual ~SliceMeshStorage();
|
||||
@@ -181,8 +193,18 @@ public:
|
||||
std::vector<RetractionConfig> retraction_config_per_extruder; //!< Retraction config per extruder.
|
||||
std::vector<RetractionConfig> extruder_switch_retraction_config_per_extruder; //!< Retraction config per extruder for when performing an extruder switch
|
||||
|
||||
std::vector<GCodePathConfig> travel_config_per_extruder; //!< The config used for travel moves (only speed is set!)
|
||||
|
||||
std::vector<GCodePathConfig> skirt_brim_config; //!< Configuration for skirt and brim per extruder.
|
||||
std::vector<CoastingConfig> coasting_config; //!< coasting config per extruder
|
||||
|
||||
GCodePathConfig raft_base_config;
|
||||
GCodePathConfig raft_interface_config;
|
||||
GCodePathConfig raft_surface_config;
|
||||
|
||||
GCodePathConfig support_config;
|
||||
GCodePathConfig support_skin_config; //!< The config to use to print the dense roofs and bottoms of support
|
||||
|
||||
SupportStorage support;
|
||||
|
||||
Polygons skirt_brim[MAX_EXTRUDERS]; //!< Skirt and brim polygons per extruder, ordered from inner to outer polygons.
|
||||
@@ -197,6 +219,21 @@ public:
|
||||
std::vector<Polygons> oozeShield; //oozeShield per layer
|
||||
Polygons draft_protection_shield; //!< The polygons for a heightened skirt which protects from warping by gusts of wind and acts as a heated chamber.
|
||||
|
||||
/*!
|
||||
* Construct the initial retraction_config_per_extruder
|
||||
*/
|
||||
std::vector<RetractionConfig> initializeRetractionConfigs();
|
||||
|
||||
/*!
|
||||
* Construct the initial travel_config_per_extruder
|
||||
*/
|
||||
std::vector<GCodePathConfig> initializeTravelConfigs();
|
||||
|
||||
/*!
|
||||
* Construct the initial skirt & brim configurations for each extruder.
|
||||
*/
|
||||
std::vector<GCodePathConfig> initializeSkirtBrimConfigs();
|
||||
|
||||
/*!
|
||||
* \brief Creates a new slice data storage that stores the slice data of the
|
||||
* specified mesh group.
|
||||
@@ -246,12 +283,6 @@ public:
|
||||
* \return a vector of bools indicating whether the extruder with corresponding index is used in this layer.
|
||||
*/
|
||||
std::vector<bool> getExtrudersUsed(int layer_nr) const;
|
||||
|
||||
private:
|
||||
/*!
|
||||
* Construct the retraction_config_per_extruder
|
||||
*/
|
||||
std::vector<RetractionConfig> initializeRetractionConfigs();
|
||||
};
|
||||
|
||||
}//namespace cura
|
||||
|
||||
+5
-9
@@ -216,7 +216,7 @@ SlicerLayer::findPossibleStitches(
|
||||
// insert the starts of the polylines).
|
||||
for(unsigned int polyline_0_idx = 0; polyline_0_idx < open_polylines.size(); polyline_0_idx++)
|
||||
{
|
||||
ConstPolygonRef polyline_0 = open_polylines[polyline_0_idx];
|
||||
const PolygonRef polyline_0 = open_polylines[polyline_0_idx];
|
||||
|
||||
if (polyline_0.size() < 1) continue;
|
||||
|
||||
@@ -231,7 +231,7 @@ SlicerLayer::findPossibleStitches(
|
||||
{
|
||||
for(unsigned int polyline_0_idx = 0; polyline_0_idx < open_polylines.size(); polyline_0_idx++)
|
||||
{
|
||||
ConstPolygonRef polyline_0 = open_polylines[polyline_0_idx];
|
||||
const PolygonRef polyline_0 = open_polylines[polyline_0_idx];
|
||||
|
||||
if (polyline_0.size() < 1) continue;
|
||||
|
||||
@@ -245,7 +245,7 @@ SlicerLayer::findPossibleStitches(
|
||||
// search for nearby end points
|
||||
for(unsigned int polyline_1_idx = 0; polyline_1_idx < open_polylines.size(); polyline_1_idx++)
|
||||
{
|
||||
ConstPolygonRef polyline_1 = open_polylines[polyline_1_idx];
|
||||
const PolygonRef polyline_1 = open_polylines[polyline_1_idx];
|
||||
|
||||
if (polyline_1.size() < 1) continue;
|
||||
|
||||
@@ -887,14 +887,10 @@ Slicer::Slicer(Mesh* mesh, int initial, int thickness, int slice_layer_count, bo
|
||||
}
|
||||
}
|
||||
log("slice of mesh took %.3f seconds\n",slice_timer.restart());
|
||||
|
||||
std::vector<SlicerLayer>& layers_ref = layers; // force layers not to be copied into the threads
|
||||
#pragma omp parallel for default(none) shared(mesh,layers_ref) firstprivate(keep_none_closed, extensive_stitching)
|
||||
for(unsigned int layer_nr=0; layer_nr<layers_ref.size(); layer_nr++)
|
||||
for(unsigned int layer_nr=0; layer_nr<layers.size(); layer_nr++)
|
||||
{
|
||||
layers_ref[layer_nr].makePolygons(mesh, keep_none_closed, extensive_stitching);
|
||||
layers[layer_nr].makePolygons(mesh, keep_none_closed, extensive_stitching);
|
||||
}
|
||||
|
||||
mesh->expandXY(mesh->getSettingInMicrons("xy_offset"));
|
||||
log("slice make polygons took %.3f seconds\n",slice_timer.restart());
|
||||
}
|
||||
|
||||
+2
-6
@@ -165,7 +165,6 @@ void AreaSupport::generateSupportAreas(SliceDataStorage& storage, unsigned int m
|
||||
const int supportTowerDiameter = mesh.getSettingInMicrons("support_tower_diameter");
|
||||
const int supportMinAreaSqrt = mesh.getSettingInMicrons("support_minimal_diameter");
|
||||
const double supportTowerRoofAngle = mesh.getSettingInAngleRadians("support_tower_roof_angle");
|
||||
const bool use_towers = mesh.getSettingBoolean("support_use_towers") && supportMinAreaSqrt > 0;
|
||||
|
||||
const int layerThickness = storage.getSettingInMicrons("layer_height");
|
||||
const int supportXYDistance = mesh.getSettingInMicrons("support_xy_distance");
|
||||
@@ -235,10 +234,7 @@ void AreaSupport::generateSupportAreas(SliceDataStorage& storage, unsigned int m
|
||||
|
||||
|
||||
std::vector<std::pair<int, std::vector<Polygons>>> overhang_points; // stores overhang_points along with the layer index at which the overhang point occurs
|
||||
if (use_towers)
|
||||
{
|
||||
AreaSupport::detectOverhangPoints(storage, mesh, overhang_points, layer_count, supportMinAreaSqrt);
|
||||
}
|
||||
AreaSupport::detectOverhangPoints(storage, mesh, overhang_points, layer_count, supportMinAreaSqrt);
|
||||
|
||||
std::deque<std::pair<Polygons, Polygons>> basic_and_full_overhang_above;
|
||||
for (unsigned int layer_idx = support_layer_count - 1; layer_idx != support_layer_count - 1 - layerZdistanceTop ; layer_idx--)
|
||||
@@ -268,7 +264,7 @@ void AreaSupport::generateSupportAreas(SliceDataStorage& storage, unsigned int m
|
||||
supportLayer_this = supportLayer_this.offset(extension_offset);
|
||||
}
|
||||
|
||||
if (use_towers)
|
||||
if (supportMinAreaSqrt > 0)
|
||||
{
|
||||
// handle straight walls
|
||||
AreaSupport::handleWallStruts(supportLayer_this, supportMinAreaSqrt, supportTowerDiameter);
|
||||
|
||||
@@ -24,7 +24,7 @@ AABB::AABB(const Polygons& polys)
|
||||
calculate(polys);
|
||||
}
|
||||
|
||||
AABB::AABB(ConstPolygonRef poly)
|
||||
AABB::AABB(const PolygonRef poly)
|
||||
: min(POINT_MAX, POINT_MAX), max(POINT_MIN, POINT_MIN)
|
||||
{
|
||||
calculate(poly);
|
||||
@@ -43,7 +43,7 @@ void AABB::calculate(const Polygons& polys)
|
||||
}
|
||||
}
|
||||
|
||||
void AABB::calculate(ConstPolygonRef poly)
|
||||
void AABB::calculate(const PolygonRef poly)
|
||||
{
|
||||
min = Point(POINT_MAX, POINT_MAX);
|
||||
max = Point(POINT_MIN, POINT_MIN);
|
||||
|
||||
+2
-2
@@ -20,10 +20,10 @@ public:
|
||||
AABB(); //!< initializes with invalid min and max
|
||||
AABB(Point& min, Point& max); //!< initializes with given min and max
|
||||
AABB(const Polygons& polys); //!< Computes the boundary box for the given polygons
|
||||
AABB(ConstPolygonRef poly); //!< Computes the boundary box for the given polygons
|
||||
AABB(const PolygonRef poly); //!< Computes the boundary box for the given polygons
|
||||
|
||||
void calculate(const Polygons& polys); //!< Calculates the aabb for the given polygons (throws away old min and max data of this aabb)
|
||||
void calculate(ConstPolygonRef poly); //!< Calculates the aabb for the given polygon (throws away old min and max data of this aabb)
|
||||
void calculate(const PolygonRef poly); //!< Calculates the aabb for the given polygon (throws away old min and max data of this aabb)
|
||||
|
||||
/*!
|
||||
* Check whether this aabb overlaps with another.
|
||||
|
||||
@@ -10,21 +10,21 @@ namespace cura
|
||||
{
|
||||
|
||||
|
||||
void ListPolyIt::convertPolygonsToLists(const Polygons& polys, ListPolygons& result)
|
||||
void ListPolyIt::convertPolygonsToLists(Polygons& polys, ListPolygons& result)
|
||||
{
|
||||
for (ConstPolygonRef poly : polys)
|
||||
for (PolygonRef poly : polys)
|
||||
{
|
||||
result.emplace_back();
|
||||
convertPolygonToList(poly, result.back());
|
||||
}
|
||||
}
|
||||
|
||||
void ListPolyIt::convertPolygonToList(ConstPolygonRef poly, ListPolygon& result)
|
||||
void ListPolyIt::convertPolygonToList(PolygonRef poly, ListPolygon& result)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
Point last = poly.back();
|
||||
#endif // DEBUG
|
||||
for (const Point& p : poly)
|
||||
for (Point& p : poly)
|
||||
{
|
||||
result.push_back(p);
|
||||
#ifdef DEBUG
|
||||
@@ -39,7 +39,7 @@ void ListPolyIt::convertPolygonToList(ConstPolygonRef poly, ListPolygon& result)
|
||||
}
|
||||
|
||||
|
||||
void ListPolyIt::convertListPolygonsToPolygons(const ListPolygons& list_polygons, Polygons& polygons)
|
||||
void ListPolyIt::convertListPolygonsToPolygons(ListPolygons& list_polygons, Polygons& polygons)
|
||||
{
|
||||
for (unsigned int poly_idx = 0; poly_idx < polygons.size(); poly_idx++)
|
||||
{
|
||||
@@ -48,9 +48,9 @@ void ListPolyIt::convertListPolygonsToPolygons(const ListPolygons& list_polygons
|
||||
}
|
||||
}
|
||||
|
||||
void ListPolyIt::convertListPolygonToPolygon(const ListPolygon& list_polygon, PolygonRef polygon)
|
||||
void ListPolyIt::convertListPolygonToPolygon(ListPolygon& list_polygon, PolygonRef polygon)
|
||||
{
|
||||
for (const Point& p : list_polygon)
|
||||
for (Point& p : list_polygon)
|
||||
{
|
||||
polygon.add(p);
|
||||
}
|
||||
|
||||
@@ -94,28 +94,28 @@ public:
|
||||
* \param polys The polygons to convert
|
||||
* \param result The converted polygons
|
||||
*/
|
||||
static void convertPolygonsToLists(const Polygons& polys, ListPolygons& result);
|
||||
static void convertPolygonsToLists(Polygons& polys, ListPolygons& result);
|
||||
/*!
|
||||
* Convert Polygons to ListPolygons
|
||||
*
|
||||
* \param polys The polygons to convert
|
||||
* \param result The converted polygons
|
||||
*/
|
||||
static void convertPolygonToList(ConstPolygonRef poly, ListPolygon& result);
|
||||
static void convertPolygonToList(PolygonRef poly, ListPolygon& result);
|
||||
/*!
|
||||
* Convert ListPolygons to Polygons
|
||||
*
|
||||
* \param list_polygons The polygons to convert
|
||||
* \param polygons The converted polygons
|
||||
*/
|
||||
static void convertListPolygonsToPolygons(const ListPolygons& list_polygons, Polygons& polygons);
|
||||
static void convertListPolygonsToPolygons(ListPolygons& list_polygons, Polygons& polygons);
|
||||
/*!
|
||||
* Convert ListPolygons to Polygons
|
||||
*
|
||||
* \param list_polygons The polygons to convert
|
||||
* \param polygons The converted polygons
|
||||
*/
|
||||
static void convertListPolygonToPolygon(const ListPolygon& list_polygon, PolygonRef polygon);
|
||||
static void convertListPolygonToPolygon(ListPolygon& list_polygon, PolygonRef polygon);
|
||||
|
||||
/*!
|
||||
* Insert a point into a ListPolygon if it's not a duplicate of the point before or the point after.
|
||||
|
||||
@@ -46,7 +46,7 @@ public:
|
||||
/*!
|
||||
* Get the polygon to which this PolygonsPointIndex refers
|
||||
*/
|
||||
ConstPolygonRef getPolygon() const
|
||||
const PolygonRef getPolygon() const
|
||||
{
|
||||
return (*polygons)[poly_idx];
|
||||
}
|
||||
|
||||
+6
-5
@@ -93,8 +93,9 @@ public:
|
||||
{
|
||||
for(unsigned int j=0;j<parts.size();j++)
|
||||
{
|
||||
Polygon poly = parts[j];
|
||||
fprintf(out, "<polygon points=\"");
|
||||
for (Point& p : parts[j])
|
||||
for(Point& p : poly)
|
||||
{
|
||||
Point fp = transform(p);
|
||||
fprintf(out, "%lli,%lli ", fp.X, fp.Y);
|
||||
@@ -129,9 +130,9 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
void writePoints(ConstPolygonRef poly, bool write_coords=false, int size = 5, Color color = Color::BLACK)
|
||||
void writePoints(PolygonRef poly, bool write_coords=false, int size = 5, Color color = Color::BLACK)
|
||||
{
|
||||
for (const Point& p : poly)
|
||||
for (Point& p : poly)
|
||||
{
|
||||
writePoint(p, write_coords, size, color);
|
||||
}
|
||||
@@ -208,12 +209,12 @@ public:
|
||||
}
|
||||
void writePolygons(const Polygons& polys, Color color = Color::BLACK)
|
||||
{
|
||||
for (ConstPolygonRef poly : polys)
|
||||
for (const PolygonRef poly : const_cast<Polygons&>(polys))
|
||||
{
|
||||
writePolygon(poly, color);
|
||||
}
|
||||
}
|
||||
void writePolygon(ConstPolygonRef poly, Color color = Color::BLACK)
|
||||
void writePolygon(const PolygonRef poly, Color color = Color::BLACK)
|
||||
{
|
||||
Point p0 = poly.back();
|
||||
for (Point p1 : poly)
|
||||
|
||||
+58
-32
@@ -8,9 +8,9 @@
|
||||
namespace cura
|
||||
{
|
||||
|
||||
bool ConstPolygonRef::shorterThan(int64_t check_length) const
|
||||
bool PolygonRef::shorterThan(int64_t check_length) const
|
||||
{
|
||||
const ConstPolygonRef& polygon = *this;
|
||||
const PolygonRef& polygon = *this;
|
||||
const Point* p0 = &polygon.back();
|
||||
int64_t length = 0;
|
||||
for (const Point& p1 : polygon)
|
||||
@@ -25,9 +25,9 @@ bool ConstPolygonRef::shorterThan(int64_t check_length) const
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ConstPolygonRef::_inside(Point p, bool border_result) const
|
||||
bool PolygonRef::_inside(Point p, bool border_result) const
|
||||
{
|
||||
const ConstPolygonRef thiss = *this;
|
||||
PolygonRef thiss = *this;
|
||||
if (size() < 1)
|
||||
{
|
||||
return false;
|
||||
@@ -190,6 +190,22 @@ unsigned int Polygons::findInside(Point p, bool border_result)
|
||||
return ret;
|
||||
}
|
||||
|
||||
int64_t Polygons::polyLineLength() const
|
||||
{
|
||||
int64_t length = 0;
|
||||
for (unsigned int poly_idx = 0; poly_idx < paths.size(); poly_idx++)
|
||||
{
|
||||
Point p0 = paths[poly_idx][0];
|
||||
for (unsigned int point_idx = 1; point_idx < paths[poly_idx].size(); point_idx++)
|
||||
{
|
||||
Point p1 = paths[poly_idx][point_idx];
|
||||
length += vSize(p0 - p1);
|
||||
p0 = p1;
|
||||
}
|
||||
}
|
||||
return length;
|
||||
}
|
||||
|
||||
Polygons Polygons::offset(int distance, ClipperLib::JoinType join_type, double miter_limit) const
|
||||
{
|
||||
Polygons ret;
|
||||
@@ -200,11 +216,11 @@ Polygons Polygons::offset(int distance, ClipperLib::JoinType join_type, double m
|
||||
return ret;
|
||||
}
|
||||
|
||||
Polygons ConstPolygonRef::offset(int distance, ClipperLib::JoinType join_type, double miter_limit) const
|
||||
Polygons PolygonRef::offset(int distance, ClipperLib::JoinType joinType, double miter_limit) const
|
||||
{
|
||||
Polygons ret;
|
||||
ClipperLib::ClipperOffset clipper(miter_limit, 10.0);
|
||||
clipper.AddPath(*path, join_type, ClipperLib::etClosedPolygon);
|
||||
clipper.AddPath(*path, joinType, ClipperLib::etClosedPolygon);
|
||||
clipper.MiterLimit = miter_limit;
|
||||
clipper.Execute(ret.paths, distance);
|
||||
return ret;
|
||||
@@ -521,7 +537,7 @@ void Polygons::removeEmptyHoles_processPolyTreeNode(const ClipperLib::PolyNode&
|
||||
}
|
||||
}
|
||||
|
||||
bool ConstPolygonRef::smooth_corner_complex(ListPolygon& poly, const Point p1, ListPolyIt& p0_it, ListPolyIt& p2_it, const int64_t shortcut_length)
|
||||
bool PolygonRef::smooth_corner_complex(ListPolygon& poly, const Point p1, ListPolyIt& p0_it, ListPolyIt& p2_it, const int64_t shortcut_length)
|
||||
{
|
||||
// walk away from the corner until the shortcut > shortcut_length or it would smooth a piece inward
|
||||
// - walk in both directions untill shortcut > shortcut_length
|
||||
@@ -703,7 +719,7 @@ bool ConstPolygonRef::smooth_corner_complex(ListPolygon& poly, const Point p1, L
|
||||
return false;
|
||||
}
|
||||
|
||||
void ConstPolygonRef::smooth_outward_step(const Point p1, const int64_t shortcut_length2, ListPolyIt& p0_it, ListPolyIt& p2_it, bool& forward_is_blocked, bool& backward_is_blocked, bool& forward_is_too_far, bool& backward_is_too_far)
|
||||
void PolygonRef::smooth_outward_step(const Point p1, const int64_t shortcut_length2, ListPolyIt& p0_it, ListPolyIt& p2_it, bool& forward_is_blocked, bool& backward_is_blocked, bool& forward_is_too_far, bool& backward_is_too_far)
|
||||
{
|
||||
const bool forward_has_converged = forward_is_blocked || forward_is_too_far;
|
||||
const bool backward_has_converged = backward_is_blocked || backward_is_too_far;
|
||||
@@ -759,7 +775,7 @@ void ConstPolygonRef::smooth_outward_step(const Point p1, const int64_t shortcut
|
||||
}
|
||||
}
|
||||
|
||||
void ConstPolygonRef::smooth_corner_simple(ListPolygon& poly, const Point p0, const Point p1, const Point p2, const ListPolyIt p0_it, const ListPolyIt p1_it, const ListPolyIt p2_it, const Point v10, const Point v12, const Point v02, const int64_t shortcut_length, float cos_angle)
|
||||
void PolygonRef::smooth_corner_simple(ListPolygon& poly, const Point p0, const Point p1, const Point p2, const ListPolyIt p0_it, const ListPolyIt p1_it, const ListPolyIt p2_it, const Point v10, const Point v12, const Point v02, const int64_t shortcut_length, float cos_angle)
|
||||
{
|
||||
// 1----b---->2
|
||||
// ^ /
|
||||
@@ -849,7 +865,7 @@ void ConstPolygonRef::smooth_corner_simple(ListPolygon& poly, const Point p0, co
|
||||
}
|
||||
}
|
||||
|
||||
void ConstPolygonRef::smooth_outward(float min_angle, int shortcut_length, PolygonRef result) const
|
||||
void PolygonRef::smooth_outward(float min_angle, int shortcut_length, PolygonRef result) const
|
||||
{
|
||||
// example of smoothed out corner:
|
||||
//
|
||||
@@ -952,8 +968,7 @@ Polygons Polygons::smooth_outward(float max_angle, int shortcut_length)
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
void ConstPolygonRef::smooth(int remove_length, PolygonRef result) const
|
||||
void PolygonRef::smooth(int remove_length, PolygonRef result)
|
||||
{
|
||||
// a typical zigzag with the middle part to be removed by removing (1) :
|
||||
//
|
||||
@@ -968,7 +983,7 @@ void ConstPolygonRef::smooth(int remove_length, PolygonRef result) const
|
||||
// |
|
||||
// |
|
||||
// 0
|
||||
const ConstPolygonRef& thiss = *path;
|
||||
PolygonRef& thiss = *this;
|
||||
ClipperLib::Path* poly = result.path;
|
||||
if (size() > 0)
|
||||
{
|
||||
@@ -1037,12 +1052,12 @@ void ConstPolygonRef::smooth(int remove_length, PolygonRef result) const
|
||||
}
|
||||
}
|
||||
|
||||
Polygons Polygons::smooth(int remove_length) const
|
||||
Polygons Polygons::smooth(int remove_length)
|
||||
{
|
||||
Polygons ret;
|
||||
for (unsigned int p = 0; p < size(); p++)
|
||||
{
|
||||
ConstPolygonRef poly(paths[p]);
|
||||
PolygonRef poly(paths[p]);
|
||||
if (poly.size() < 3)
|
||||
{
|
||||
continue;
|
||||
@@ -1062,23 +1077,23 @@ Polygons Polygons::smooth(int remove_length) const
|
||||
return ret;
|
||||
}
|
||||
|
||||
void ConstPolygonRef::smooth2(int remove_length, PolygonRef result) const
|
||||
void PolygonRef::smooth2(int remove_length, PolygonRef result)
|
||||
{
|
||||
const ConstPolygonRef& thiss = *this;
|
||||
PolygonRef& thiss = *this;
|
||||
ClipperLib::Path* poly = result.path;
|
||||
if (thiss.size() > 0)
|
||||
if (size() > 0)
|
||||
{
|
||||
poly->push_back(thiss[0]);
|
||||
}
|
||||
for (unsigned int poly_idx = 1; poly_idx < thiss.size(); poly_idx++)
|
||||
for (unsigned int poly_idx = 1; poly_idx < size(); poly_idx++)
|
||||
{
|
||||
const Point& last = thiss[poly_idx - 1];
|
||||
const Point& now = thiss[poly_idx];
|
||||
const Point& next = thiss[(poly_idx + 1) % thiss.size()];
|
||||
if (shorterThen(last - now, remove_length) && shorterThen(now - next, remove_length))
|
||||
Point& last = thiss[poly_idx - 1];
|
||||
Point& now = thiss[poly_idx];
|
||||
Point& next = thiss[(poly_idx + 1) % size()];
|
||||
if (shorterThen(last - now, remove_length) && shorterThen(now - next, remove_length))
|
||||
{
|
||||
poly_idx++; // skip the next line piece (dont escalate the removal of edges)
|
||||
if (poly_idx < thiss.size())
|
||||
if (poly_idx < size())
|
||||
{
|
||||
poly->push_back(thiss[poly_idx]);
|
||||
}
|
||||
@@ -1090,12 +1105,12 @@ void ConstPolygonRef::smooth2(int remove_length, PolygonRef result) const
|
||||
}
|
||||
}
|
||||
|
||||
Polygons Polygons::smooth2(int remove_length, int min_area) const
|
||||
Polygons Polygons::smooth2(int remove_length, int min_area)
|
||||
{
|
||||
Polygons ret;
|
||||
for (unsigned int p = 0; p < size(); p++)
|
||||
{
|
||||
ConstPolygonRef poly(paths[p]);
|
||||
PolygonRef poly(paths[p]);
|
||||
if (poly.size() == 0)
|
||||
{
|
||||
continue;
|
||||
@@ -1117,6 +1132,17 @@ Polygons Polygons::smooth2(int remove_length, int min_area) const
|
||||
return ret;
|
||||
}
|
||||
|
||||
double PolygonsPart::area() const
|
||||
{
|
||||
double area = 0;
|
||||
for (unsigned int poly_idx = 0; poly_idx < size(); poly_idx++)
|
||||
{
|
||||
area += operator[](poly_idx).area();
|
||||
// note: holes have negative area
|
||||
}
|
||||
return area;
|
||||
}
|
||||
|
||||
std::vector<PolygonsPart> Polygons::splitIntoParts(bool unionAll) const
|
||||
{
|
||||
std::vector<PolygonsPart> ret;
|
||||
@@ -1148,14 +1174,14 @@ void Polygons::splitIntoParts_processPolyTreeNode(ClipperLib::PolyNode* node, st
|
||||
}
|
||||
}
|
||||
|
||||
unsigned int PartsView::getPartContaining(unsigned int poly_idx, unsigned int* boundary_poly_idx) const
|
||||
unsigned int PartsView::getPartContaining(unsigned int poly_idx, unsigned int* boundary_poly_idx)
|
||||
{
|
||||
const PartsView& partsView = *this;
|
||||
PartsView& partsView = *this;
|
||||
for (unsigned int part_idx_now = 0; part_idx_now < partsView.size(); part_idx_now++)
|
||||
{
|
||||
const std::vector<unsigned int>& partView = partsView[part_idx_now];
|
||||
std::vector<unsigned int>& partView = partsView[part_idx_now];
|
||||
if (partView.size() == 0) { continue; }
|
||||
std::vector<unsigned int>::const_iterator result = std::find(partView.begin(), partView.end(), poly_idx);
|
||||
std::vector<unsigned int>::iterator result = std::find(partView.begin(), partView.end(), poly_idx);
|
||||
if (result != partView.end())
|
||||
{
|
||||
if (boundary_poly_idx) { *boundary_poly_idx = partView[0]; }
|
||||
@@ -1179,7 +1205,7 @@ PolygonsPart PartsView::assemblePart(unsigned int part_idx) const
|
||||
return ret;
|
||||
}
|
||||
|
||||
PolygonsPart PartsView::assemblePartContaining(unsigned int poly_idx, unsigned int* boundary_poly_idx) const
|
||||
PolygonsPart PartsView::assemblePartContaining(unsigned int poly_idx, unsigned int* boundary_poly_idx)
|
||||
{
|
||||
PolygonsPart ret;
|
||||
unsigned int part_idx = getPartContaining(poly_idx, boundary_poly_idx);
|
||||
@@ -1216,7 +1242,7 @@ void Polygons::splitIntoPartsView_processPolyTreeNode(PartsView& partsView, Poly
|
||||
partsView.emplace_back();
|
||||
unsigned int pos = partsView.size() - 1;
|
||||
partsView[pos].push_back(reordered.size());
|
||||
reordered.add(child->Contour); //TODO: should this steal the internal representation for speed?
|
||||
reordered.add(child->Contour);
|
||||
for(int i = 0; i < child->ChildCount(); i++)
|
||||
{
|
||||
partsView[pos].push_back(reordered.size());
|
||||
|
||||
+126
-185
@@ -27,8 +27,6 @@ namespace cura {
|
||||
|
||||
class PartsView;
|
||||
class Polygons;
|
||||
class Polygon;
|
||||
class PolygonRef;
|
||||
|
||||
class ListPolyIt;
|
||||
|
||||
@@ -38,60 +36,31 @@ typedef std::vector<ListPolygon> ListPolygons; //!< Polygons represented by a ve
|
||||
const static int clipper_init = (0);
|
||||
#define NO_INDEX (std::numeric_limits<unsigned int>::max())
|
||||
|
||||
class ConstPolygonRef
|
||||
class PolygonRef
|
||||
{
|
||||
friend class Polygons;
|
||||
friend class Polygon;
|
||||
friend class PolygonRef;
|
||||
protected:
|
||||
ClipperLib::Path* path;
|
||||
ConstPolygonRef()
|
||||
PolygonRef()
|
||||
: path(nullptr)
|
||||
{}
|
||||
public:
|
||||
ConstPolygonRef(const ClipperLib::Path& polygon)
|
||||
: path(const_cast<ClipperLib::Path*>(&polygon))
|
||||
PolygonRef(ClipperLib::Path& polygon)
|
||||
: path(&polygon)
|
||||
{}
|
||||
|
||||
bool operator==(ConstPolygonRef& other) const =delete;
|
||||
|
||||
// needed in std::optional<ConstPolygonRef>
|
||||
// ConstPolygonRef& operator=(const ConstPolygonRef& other) =delete;
|
||||
ConstPolygonRef& operator=(const ConstPolygonRef& other)
|
||||
{
|
||||
path = other.path;
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
unsigned int size() const
|
||||
{
|
||||
return path->size();
|
||||
}
|
||||
|
||||
const Point& operator[] (unsigned int index) const
|
||||
Point& operator[] (unsigned int index) const
|
||||
{
|
||||
POLY_ASSERT(index < size());
|
||||
POLY_ASSERT(index < size() && index <= std::numeric_limits<int>::max());
|
||||
return (*path)[index];
|
||||
}
|
||||
|
||||
const ClipperLib::Path& operator*() const
|
||||
void* data()
|
||||
{
|
||||
return *path;
|
||||
}
|
||||
|
||||
ClipperLib::Path::const_iterator begin() const
|
||||
{
|
||||
return path->begin();
|
||||
}
|
||||
|
||||
ClipperLib::Path::const_iterator end() const
|
||||
{
|
||||
return path->end();
|
||||
}
|
||||
|
||||
ClipperLib::Path::const_reference back() const
|
||||
{
|
||||
return path->back();
|
||||
return path->data();
|
||||
}
|
||||
|
||||
const void* data() const
|
||||
@@ -99,10 +68,37 @@ public:
|
||||
return path->data();
|
||||
}
|
||||
|
||||
void add(const Point p)
|
||||
{
|
||||
path->push_back(p);
|
||||
}
|
||||
|
||||
PolygonRef& operator=(const PolygonRef& other) { path = other.path; return *this; }
|
||||
|
||||
bool operator==(const PolygonRef& other) const =delete;
|
||||
|
||||
ClipperLib::Path& operator*() { return *path; }
|
||||
|
||||
template <typename... Args>
|
||||
void emplace_back(Args&&... args)
|
||||
{
|
||||
path->emplace_back(args...);
|
||||
}
|
||||
|
||||
void remove(unsigned int index)
|
||||
{
|
||||
POLY_ASSERT(index < size() && index <= std::numeric_limits<int>::max());
|
||||
path->erase(path->begin() + index);
|
||||
}
|
||||
|
||||
void clear()
|
||||
{
|
||||
path->clear();
|
||||
}
|
||||
|
||||
/*!
|
||||
* On Y-axis positive upward displays, Orientation will return true if the polygon's orientation is counter-clockwise.
|
||||
*
|
||||
*
|
||||
* from http://www.angusj.com/delphi/clipper/documentation/Docs/Units/ClipperLib/Functions/Orientation.htm
|
||||
*/
|
||||
bool orientation() const
|
||||
@@ -110,6 +106,11 @@ public:
|
||||
return ClipperLib::Orientation(*path);
|
||||
}
|
||||
|
||||
void reverse()
|
||||
{
|
||||
ClipperLib::ReversePath(*path);
|
||||
}
|
||||
|
||||
Polygons offset(int distance, ClipperLib::JoinType joinType = ClipperLib::jtMiter, double miter_limit = 1.2) const;
|
||||
|
||||
int64_t polygonLength() const
|
||||
@@ -124,7 +125,7 @@ public:
|
||||
}
|
||||
return length;
|
||||
}
|
||||
|
||||
|
||||
bool shorterThan(int64_t check_length) const;
|
||||
|
||||
Point min() const
|
||||
@@ -137,7 +138,7 @@ public:
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
Point max() const
|
||||
{
|
||||
Point ret = Point(POINT_MIN, POINT_MIN);
|
||||
@@ -153,6 +154,19 @@ public:
|
||||
{
|
||||
return ClipperLib::Area(*path);
|
||||
}
|
||||
|
||||
/*!
|
||||
* Translate the whole polygon in some direction.
|
||||
*
|
||||
* \param translation The direction in which to move the polygon
|
||||
*/
|
||||
void translate(Point translation)
|
||||
{
|
||||
for (Point& p : *this)
|
||||
{
|
||||
p += translation;
|
||||
}
|
||||
}
|
||||
|
||||
Point centerOfMass() const
|
||||
{
|
||||
@@ -169,14 +183,14 @@ public:
|
||||
}
|
||||
|
||||
double area = Area(*path);
|
||||
|
||||
|
||||
x = x / 6 / area;
|
||||
y = y / 6 / area;
|
||||
|
||||
return Point(x, y);
|
||||
}
|
||||
|
||||
Point closestPointTo(Point p) const
|
||||
Point closestPointTo(Point p)
|
||||
{
|
||||
Point ret = p;
|
||||
float bestDist = FLT_MAX;
|
||||
@@ -191,7 +205,7 @@ public:
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
* Check if we are inside the polygon. We do this by tracing from the point towards the positive X direction,
|
||||
* every line we cross increments the crossings counter. If we have an even number of crossings then we are not inside the polygon.
|
||||
@@ -227,7 +241,7 @@ public:
|
||||
}
|
||||
return res == 1;
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
* Smooth out small perpendicular segments and store the result in \p result.
|
||||
* Smoothing is performed by removing the inner most vertex of a line segment smaller than \p remove_length
|
||||
@@ -239,7 +253,7 @@ public:
|
||||
* \param remove_length The length of the largest segment removed
|
||||
* \param result (output) The result polygon, assumed to be empty
|
||||
*/
|
||||
void smooth(int remove_length, PolygonRef result) const;
|
||||
void smooth(int remove_length, PolygonRef result);
|
||||
|
||||
/*!
|
||||
* Smooth out sharp inner corners, by taking a shortcut which bypasses the corner
|
||||
@@ -257,8 +271,51 @@ public:
|
||||
* \param remove_length The length of the largest segment removed
|
||||
* \param result (output) The result polygon, assumed to be empty
|
||||
*/
|
||||
void smooth2(int remove_length, PolygonRef result) const;
|
||||
void smooth2(int remove_length, PolygonRef result);
|
||||
|
||||
/*!
|
||||
* Removes consecutive line segments with same orientation and changes this polygon.
|
||||
*
|
||||
* Removes verts which are connected to line segments which are both too small.
|
||||
* Removes verts which detour from a direct line from the previous and next vert by a too small amount.
|
||||
*
|
||||
* \param smallest_line_segment_squared maximal squared length of removed line segments
|
||||
* \param allowed_error_distance_squared The square of the distance of the middle point to the line segment of the consecutive and previous point for which the middle point is removed
|
||||
*/
|
||||
void simplify(int smallest_line_segment_squared = 100, int allowed_error_distance_squared = 25);
|
||||
|
||||
void pop_back()
|
||||
{
|
||||
path->pop_back();
|
||||
}
|
||||
|
||||
ClipperLib::Path::reference back() const
|
||||
{
|
||||
return path->back();
|
||||
}
|
||||
|
||||
ClipperLib::Path::iterator begin()
|
||||
{
|
||||
return path->begin();
|
||||
}
|
||||
|
||||
ClipperLib::Path::iterator end()
|
||||
{
|
||||
return path->end();
|
||||
}
|
||||
|
||||
ClipperLib::Path::const_iterator begin() const
|
||||
{
|
||||
return path->begin();
|
||||
}
|
||||
|
||||
ClipperLib::Path::const_iterator end() const
|
||||
{
|
||||
return path->end();
|
||||
}
|
||||
|
||||
friend class Polygons;
|
||||
friend class Polygon;
|
||||
|
||||
private:
|
||||
/*!
|
||||
@@ -318,113 +375,6 @@ private:
|
||||
static void smooth_outward_step(const Point p1, const int64_t shortcut_length2, ListPolyIt& p0_it, ListPolyIt& p2_it, bool& forward_is_blocked, bool& backward_is_blocked, bool& forward_is_too_far, bool& backward_is_too_far);
|
||||
};
|
||||
|
||||
|
||||
class PolygonRef : public ConstPolygonRef
|
||||
{
|
||||
PolygonRef()
|
||||
: ConstPolygonRef()
|
||||
{}
|
||||
public:
|
||||
PolygonRef(ClipperLib::Path& polygon)
|
||||
: ConstPolygonRef(polygon)
|
||||
{}
|
||||
|
||||
PolygonRef& operator=(const PolygonRef& other)
|
||||
{
|
||||
path = other.path;
|
||||
return *this;
|
||||
}
|
||||
|
||||
Point& operator[] (unsigned int index)
|
||||
{
|
||||
POLY_ASSERT(index < size());
|
||||
return (*path)[index];
|
||||
}
|
||||
|
||||
ClipperLib::Path::iterator begin()
|
||||
{
|
||||
return path->begin();
|
||||
}
|
||||
|
||||
ClipperLib::Path::iterator end()
|
||||
{
|
||||
return path->end();
|
||||
}
|
||||
|
||||
ClipperLib::Path::reference back()
|
||||
{
|
||||
return path->back();
|
||||
}
|
||||
|
||||
void* data()
|
||||
{
|
||||
return path->data();
|
||||
}
|
||||
|
||||
void add(const Point p)
|
||||
{
|
||||
path->push_back(p);
|
||||
}
|
||||
|
||||
PolygonRef& operator=(ConstPolygonRef& other) { path = other.path; return *this; }
|
||||
|
||||
ClipperLib::Path& operator*()
|
||||
{
|
||||
return *path;
|
||||
}
|
||||
|
||||
template <typename... Args>
|
||||
void emplace_back(Args&&... args)
|
||||
{
|
||||
path->emplace_back(args...);
|
||||
}
|
||||
|
||||
void remove(unsigned int index)
|
||||
{
|
||||
POLY_ASSERT(index < size() && index <= std::numeric_limits<int>::max());
|
||||
path->erase(path->begin() + index);
|
||||
}
|
||||
|
||||
void clear()
|
||||
{
|
||||
path->clear();
|
||||
}
|
||||
|
||||
void reverse()
|
||||
{
|
||||
ClipperLib::ReversePath(*path);
|
||||
}
|
||||
|
||||
/*!
|
||||
* Translate the whole polygon in some direction.
|
||||
*
|
||||
* \param translation The direction in which to move the polygon
|
||||
*/
|
||||
void translate(Point translation)
|
||||
{
|
||||
for (Point& p : *this)
|
||||
{
|
||||
p += translation;
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
* Removes consecutive line segments with same orientation and changes this polygon.
|
||||
*
|
||||
* Removes verts which are connected to line segments which are both too small.
|
||||
* Removes verts which detour from a direct line from the previous and next vert by a too small amount.
|
||||
*
|
||||
* \param smallest_line_segment_squared maximal squared length of removed line segments
|
||||
* \param allowed_error_distance_squared The square of the distance of the middle point to the line segment of the consecutive and previous point for which the middle point is removed
|
||||
*/
|
||||
void simplify(int smallest_line_segment_squared = 100, int allowed_error_distance_squared = 25);
|
||||
|
||||
void pop_back()
|
||||
{
|
||||
path->pop_back();
|
||||
}
|
||||
};
|
||||
|
||||
class Polygon : public PolygonRef
|
||||
{
|
||||
ClipperLib::Path poly;
|
||||
@@ -434,7 +384,7 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
Polygon(PolygonRef& other)
|
||||
Polygon(const PolygonRef& other)
|
||||
: PolygonRef(poly)
|
||||
{
|
||||
poly = *other.path;
|
||||
@@ -447,7 +397,6 @@ class Polygons
|
||||
{
|
||||
friend class Polygon;
|
||||
friend class PolygonRef;
|
||||
friend class ConstPolygonRef;
|
||||
protected:
|
||||
ClipperLib::Paths paths;
|
||||
public:
|
||||
@@ -461,12 +410,11 @@ public:
|
||||
PolygonRef operator[] (unsigned int index)
|
||||
{
|
||||
POLY_ASSERT(index < size() && index <= std::numeric_limits<int>::max());
|
||||
return paths[index];
|
||||
return PolygonRef(paths[index]);
|
||||
}
|
||||
ConstPolygonRef operator[] (unsigned int index) const
|
||||
const PolygonRef operator[] (unsigned int index) const
|
||||
{
|
||||
POLY_ASSERT(index < size() && index <= std::numeric_limits<int>::max());
|
||||
return paths[index];
|
||||
return const_cast<Polygons*>(this)->operator[](index);
|
||||
}
|
||||
ClipperLib::Paths::iterator begin()
|
||||
{
|
||||
@@ -509,11 +457,7 @@ public:
|
||||
{
|
||||
paths.clear();
|
||||
}
|
||||
void add(ConstPolygonRef& poly)
|
||||
{
|
||||
paths.push_back(*poly.path);
|
||||
}
|
||||
void add(const ConstPolygonRef& poly)
|
||||
void add(const PolygonRef& poly)
|
||||
{
|
||||
paths.push_back(*poly.path);
|
||||
}
|
||||
@@ -549,10 +493,6 @@ public:
|
||||
{
|
||||
return PolygonRef(paths.back());
|
||||
}
|
||||
ConstPolygonRef back() const
|
||||
{
|
||||
return ConstPolygonRef(paths.back());
|
||||
}
|
||||
|
||||
Polygons() {}
|
||||
|
||||
@@ -707,7 +647,7 @@ public:
|
||||
* \param remove_length The length of the largest segment removed
|
||||
* \return The smoothed polygon
|
||||
*/
|
||||
Polygons smooth(int remove_length) const;
|
||||
Polygons smooth(int remove_length);
|
||||
|
||||
/*!
|
||||
* Smooth out sharp inner corners, by taking a shortcut which bypasses the corner
|
||||
@@ -718,7 +658,7 @@ public:
|
||||
*/
|
||||
Polygons smooth_outward(float angle, int shortcut_length);
|
||||
|
||||
Polygons smooth2(int remove_length, int min_area) const; //!< removes points connected to small lines
|
||||
Polygons smooth2(int remove_length, int min_area); //!< removes points connected to small lines
|
||||
|
||||
/*!
|
||||
* removes points connected to similarly oriented lines
|
||||
@@ -858,16 +798,16 @@ public:
|
||||
* Removes the same polygons from this set (and also empty polygons).
|
||||
* Polygons are considered the same if all points lie within [same_distance] of their counterparts.
|
||||
*/
|
||||
Polygons remove(const Polygons& to_be_removed, int same_distance = 0) const
|
||||
Polygons remove(Polygons& to_be_removed, int same_distance = 0)
|
||||
{
|
||||
Polygons result;
|
||||
for (unsigned int poly_keep_idx = 0; poly_keep_idx < size(); poly_keep_idx++)
|
||||
{
|
||||
ConstPolygonRef poly_keep = (*this)[poly_keep_idx];
|
||||
PolygonRef poly_keep = (*this)[poly_keep_idx];
|
||||
bool should_be_removed = false;
|
||||
if (poly_keep.size() > 0)
|
||||
// for (int hole_poly_idx = 0; hole_poly_idx < to_be_removed.size(); hole_poly_idx++)
|
||||
for (ConstPolygonRef poly_rem : to_be_removed)
|
||||
for (PolygonRef poly_rem : to_be_removed)
|
||||
{
|
||||
// PolygonRef poly_rem = to_be_removed[hole_poly_idx];
|
||||
if (poly_rem.size() != poly_keep.size() || poly_rem.size() == 0) continue;
|
||||
@@ -934,6 +874,8 @@ public:
|
||||
}
|
||||
return length;
|
||||
}
|
||||
|
||||
int64_t polyLineLength() const;
|
||||
|
||||
Point min() const
|
||||
{
|
||||
@@ -983,16 +925,13 @@ public:
|
||||
class PolygonsPart : public Polygons
|
||||
{
|
||||
public:
|
||||
PolygonRef outerPolygon()
|
||||
PolygonRef outerPolygon()
|
||||
{
|
||||
return this->paths[0];
|
||||
}
|
||||
ConstPolygonRef outerPolygon() const
|
||||
{
|
||||
return this->paths[0];
|
||||
Polygons& thiss = *this;
|
||||
return thiss[0];
|
||||
}
|
||||
|
||||
bool inside(Point p)
|
||||
bool inside(Point p) const
|
||||
{
|
||||
if (size() < 1)
|
||||
return false;
|
||||
@@ -1005,6 +944,8 @@ public:
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
double area() const;
|
||||
};
|
||||
|
||||
/*!
|
||||
@@ -1022,7 +963,7 @@ public:
|
||||
* \param boundary_poly_idx Optional output parameter: The index of the boundary polygon of the part in \p polygons
|
||||
* \return The PolygonsPart containing the polygon with index \p poly_idx
|
||||
*/
|
||||
unsigned int getPartContaining(unsigned int poly_idx, unsigned int* boundary_poly_idx = nullptr) const;
|
||||
unsigned int getPartContaining(unsigned int poly_idx, unsigned int* boundary_poly_idx = nullptr);
|
||||
/*!
|
||||
* Assemble the PolygonsPart of which the polygon with index \p poly_idx is part.
|
||||
*
|
||||
@@ -1030,7 +971,7 @@ public:
|
||||
* \param boundary_poly_idx Optional output parameter: The index of the boundary polygon of the part in \p polygons
|
||||
* \return The PolygonsPart containing the polygon with index \p poly_idx
|
||||
*/
|
||||
PolygonsPart assemblePartContaining(unsigned int poly_idx, unsigned int* boundary_poly_idx = nullptr) const;
|
||||
PolygonsPart assemblePartContaining(unsigned int poly_idx, unsigned int* boundary_poly_idx = nullptr);
|
||||
/*!
|
||||
* Assemble the PolygonsPart of which the polygon with index \p poly_idx is part.
|
||||
*
|
||||
|
||||
@@ -22,7 +22,7 @@ int64_t PolygonUtils::segmentLength(PolygonsPointIndex start, PolygonsPointIndex
|
||||
assert(start.poly_idx == end.poly_idx);
|
||||
int64_t segment_length = 0;
|
||||
Point prev_vert = start.p();
|
||||
ConstPolygonRef poly = (*start.polygons)[start.poly_idx];
|
||||
const PolygonRef poly = (*start.polygons)[start.poly_idx];
|
||||
for (unsigned int point_idx = 1; point_idx <= poly.size(); point_idx++)
|
||||
{
|
||||
unsigned int vert_idx = (start.point_idx + point_idx) % poly.size();
|
||||
@@ -44,7 +44,7 @@ void PolygonUtils::spreadDots(PolygonsPointIndex start, PolygonsPointIndex end,
|
||||
assert(start.poly_idx == end.poly_idx);
|
||||
int64_t segment_length = segmentLength(start, end);
|
||||
|
||||
ConstPolygonRef poly = (*start.polygons)[start.poly_idx];
|
||||
const PolygonRef poly = (*start.polygons)[start.poly_idx];
|
||||
unsigned int n_dots_in_between = n_dots;
|
||||
if (start == end)
|
||||
{
|
||||
@@ -80,7 +80,7 @@ void PolygonUtils::spreadDots(PolygonsPointIndex start, PolygonsPointIndex end,
|
||||
assert(result.size() == n_dots && "we didn't generate as many wipe locations as we asked for.");
|
||||
}
|
||||
|
||||
Point PolygonUtils::getVertexInwardNormal(ConstPolygonRef poly, unsigned int point_idx)
|
||||
Point PolygonUtils::getVertexInwardNormal(PolygonRef poly, unsigned int point_idx)
|
||||
{
|
||||
Point p1 = poly[point_idx];
|
||||
|
||||
@@ -110,7 +110,7 @@ Point PolygonUtils::getVertexInwardNormal(ConstPolygonRef poly, unsigned int poi
|
||||
break;
|
||||
}
|
||||
}
|
||||
const Point& p2 = poly[p2_idx];
|
||||
Point& p2 = poly[p2_idx];
|
||||
|
||||
Point off0 = turn90CCW(normal(p1 - p0, MM2INT(10.0))); // 10.0 for some precision
|
||||
Point off1 = turn90CCW(normal(p2 - p1, MM2INT(10.0))); // 10.0 for some precision
|
||||
@@ -119,7 +119,7 @@ Point PolygonUtils::getVertexInwardNormal(ConstPolygonRef poly, unsigned int poi
|
||||
}
|
||||
|
||||
|
||||
Point PolygonUtils::getBoundaryPointWithOffset(ConstPolygonRef poly, unsigned int point_idx, int64_t offset)
|
||||
Point PolygonUtils::getBoundaryPointWithOffset(PolygonRef poly, unsigned int point_idx, int64_t offset)
|
||||
{
|
||||
return poly[point_idx] + normal(getVertexInwardNormal(poly, point_idx), -offset);
|
||||
}
|
||||
@@ -130,7 +130,7 @@ Point PolygonUtils::moveInsideDiagonally(ClosestPolygonPoint point_on_boundary,
|
||||
{
|
||||
return no_point;
|
||||
}
|
||||
ConstPolygonRef poly = *point_on_boundary.poly;
|
||||
PolygonRef poly = *point_on_boundary.poly;
|
||||
Point p0 = poly[point_on_boundary.point_idx];
|
||||
Point p1 = poly[(point_on_boundary.point_idx + 1) % poly.size()];
|
||||
if (vSize2(p0 - point_on_boundary.location) < vSize2(p1 - point_on_boundary.location))
|
||||
@@ -163,7 +163,7 @@ ClosestPolygonPoint PolygonUtils::moveInside2(const Polygons& polygons, Point& f
|
||||
return _moveInside2(*closest_polygon_point, distance, from, max_dist2);
|
||||
}
|
||||
|
||||
ClosestPolygonPoint PolygonUtils::moveInside2(const Polygons& loc_to_line_polygons, ConstPolygonRef polygon, Point& from, const int distance, const int64_t max_dist2, const LocToLineGrid* loc_to_line_grid, const std::function<int(Point)>& penalty_function)
|
||||
ClosestPolygonPoint PolygonUtils::moveInside2(const Polygons& loc_to_line_polygons, const PolygonRef polygon, Point& from, const int distance, const int64_t max_dist2, const LocToLineGrid* loc_to_line_grid, const std::function<int(Point)>& penalty_function)
|
||||
{
|
||||
std::optional<ClosestPolygonPoint> closest_polygon_point;
|
||||
if (loc_to_line_grid)
|
||||
@@ -225,7 +225,7 @@ unsigned int PolygonUtils::moveInside(const Polygons& polygons, Point& from, int
|
||||
bool is_already_on_correct_side_of_boundary = false; // whether [from] is already on the right side of the boundary
|
||||
for (unsigned int poly_idx = 0; poly_idx < polygons.size(); poly_idx++)
|
||||
{
|
||||
ConstPolygonRef poly = polygons[poly_idx];
|
||||
const PolygonRef poly = polygons[poly_idx];
|
||||
if (poly.size() < 2)
|
||||
continue;
|
||||
Point p0 = poly[poly.size()-2];
|
||||
@@ -344,11 +344,11 @@ Point PolygonUtils::moveInside(const ClosestPolygonPoint& cpp, const int distanc
|
||||
{ // the point which is assumed to be on the boundary doesn't have to be moved
|
||||
return cpp.location;
|
||||
}
|
||||
ConstPolygonRef poly = *cpp.poly;
|
||||
const PolygonRef poly = *cpp.poly;
|
||||
unsigned int point_idx = cpp.point_idx;
|
||||
const Point& on_boundary = cpp.location;
|
||||
|
||||
const Point& p1 = poly[point_idx];
|
||||
Point& p1 = poly[point_idx];
|
||||
unsigned int p2_idx;
|
||||
for (p2_idx = point_idx + 1; p2_idx != point_idx; p2_idx = p2_idx + 1)
|
||||
{ // find the next point different from p1
|
||||
@@ -361,7 +361,7 @@ Point PolygonUtils::moveInside(const ClosestPolygonPoint& cpp, const int distanc
|
||||
break;
|
||||
}
|
||||
}
|
||||
const Point& p2 = poly[p2_idx];
|
||||
Point& p2 = poly[p2_idx];
|
||||
|
||||
if (on_boundary == p1)
|
||||
{
|
||||
@@ -392,7 +392,7 @@ ClosestPolygonPoint PolygonUtils::ensureInsideOrOutside(const Polygons& polygons
|
||||
{
|
||||
return ClosestPolygonPoint(); // we couldn't move inside
|
||||
}
|
||||
ConstPolygonRef closest_poly = *closest_polygon_point.poly;
|
||||
PolygonRef closest_poly = *closest_polygon_point.poly;
|
||||
bool is_outside_boundary = closest_poly.orientation();
|
||||
|
||||
{
|
||||
@@ -481,8 +481,8 @@ void PolygonUtils::findSmallestConnection(ClosestPolygonPoint& poly1_result, Clo
|
||||
{
|
||||
return;
|
||||
}
|
||||
ConstPolygonRef poly1 = *poly1_result.poly;
|
||||
ConstPolygonRef poly2 = *poly2_result.poly;
|
||||
PolygonRef poly1 = *poly1_result.poly;
|
||||
PolygonRef poly2 = *poly2_result.poly;
|
||||
if (poly1.size() == 0 || poly2.size() == 0)
|
||||
{
|
||||
return;
|
||||
@@ -515,8 +515,8 @@ void PolygonUtils::walkToNearestSmallestConnection(ClosestPolygonPoint& poly1_re
|
||||
{
|
||||
return;
|
||||
}
|
||||
ConstPolygonRef poly1 = *poly1_result.poly;
|
||||
ConstPolygonRef poly2 = *poly2_result.poly;
|
||||
PolygonRef poly1 = *poly1_result.poly;
|
||||
PolygonRef poly2 = *poly2_result.poly;
|
||||
if (poly1_result.point_idx < 0 || poly2_result.point_idx < 0)
|
||||
{
|
||||
return;
|
||||
@@ -537,7 +537,7 @@ void PolygonUtils::walkToNearestSmallestConnection(ClosestPolygonPoint& poly1_re
|
||||
}
|
||||
}
|
||||
|
||||
ClosestPolygonPoint PolygonUtils::findNearestClosest(Point from, ConstPolygonRef polygon, int start_idx)
|
||||
ClosestPolygonPoint PolygonUtils::findNearestClosest(Point from, PolygonRef polygon, int start_idx)
|
||||
{
|
||||
ClosestPolygonPoint forth = findNearestClosest(from, polygon, start_idx, 1);
|
||||
if (!forth.isValid())
|
||||
@@ -556,7 +556,7 @@ ClosestPolygonPoint PolygonUtils::findNearestClosest(Point from, ConstPolygonRef
|
||||
}
|
||||
}
|
||||
|
||||
ClosestPolygonPoint PolygonUtils::findNearestClosest(Point from, ConstPolygonRef polygon, int start_idx, int direction)
|
||||
ClosestPolygonPoint PolygonUtils::findNearestClosest(Point from, PolygonRef polygon, int start_idx, int direction)
|
||||
{
|
||||
if (polygon.size() == 0)
|
||||
{
|
||||
@@ -572,8 +572,8 @@ ClosestPolygonPoint PolygonUtils::findNearestClosest(Point from, ConstPolygonRef
|
||||
{
|
||||
int p1_idx = (polygon.size() + direction*p + start_idx) % polygon.size();
|
||||
int p2_idx = (polygon.size() + direction*(p+1) + start_idx) % polygon.size();
|
||||
const Point& p1 = polygon[p1_idx];
|
||||
const Point& p2 = polygon[p2_idx];
|
||||
Point& p1 = polygon[p1_idx];
|
||||
Point& p2 = polygon[p2_idx];
|
||||
|
||||
Point closest_here = LinearAlg2D::getClosestOnLineSegment(from, p1 ,p2);
|
||||
int64_t dist = vSize2(from - closest_here);
|
||||
@@ -600,7 +600,7 @@ ClosestPolygonPoint PolygonUtils::findClosest(Point from, const Polygons& polygo
|
||||
{
|
||||
return none;
|
||||
}
|
||||
ConstPolygonRef any_polygon = polygons[0];
|
||||
PolygonRef any_polygon = polygons[0];
|
||||
unsigned int any_poly_idx;
|
||||
for (any_poly_idx = 0; any_poly_idx < polygons.size(); any_poly_idx++)
|
||||
{ // find first point in all polygons
|
||||
@@ -620,7 +620,7 @@ ClosestPolygonPoint PolygonUtils::findClosest(Point from, const Polygons& polygo
|
||||
|
||||
for (unsigned int ply = 0; ply < polygons.size(); ply++)
|
||||
{
|
||||
ConstPolygonRef poly = polygons[ply];
|
||||
const PolygonRef poly = polygons[ply];
|
||||
if (poly.size() == 0) continue;
|
||||
ClosestPolygonPoint closest_here = findClosest(from, poly, penalty_function);
|
||||
if (!closest_here.isValid())
|
||||
@@ -639,7 +639,7 @@ ClosestPolygonPoint PolygonUtils::findClosest(Point from, const Polygons& polygo
|
||||
return best;
|
||||
}
|
||||
|
||||
ClosestPolygonPoint PolygonUtils::findClosest(Point from, ConstPolygonRef polygon, const std::function<int(Point)>& penalty_function)
|
||||
ClosestPolygonPoint PolygonUtils::findClosest(Point from, const PolygonRef polygon, const std::function<int(Point)>& penalty_function)
|
||||
{
|
||||
if (polygon.size() == 0)
|
||||
{
|
||||
@@ -653,11 +653,11 @@ ClosestPolygonPoint PolygonUtils::findClosest(Point from, ConstPolygonRef polygo
|
||||
//
|
||||
for (unsigned int p = 0; p<polygon.size(); p++)
|
||||
{
|
||||
const Point& p1 = polygon[p];
|
||||
Point& p1 = polygon[p];
|
||||
|
||||
unsigned int p2_idx = p+1;
|
||||
if (p2_idx >= polygon.size()) p2_idx = 0;
|
||||
const Point& p2 = polygon[p2_idx];
|
||||
Point& p2 = polygon[p2_idx];
|
||||
|
||||
Point closest_here = LinearAlg2D::getClosestOnLineSegment(from, p1 ,p2);
|
||||
int64_t dist2_score = vSize2(from - closest_here) + penalty_function(closest_here);
|
||||
@@ -678,7 +678,7 @@ PolygonsPointIndex PolygonUtils::findNearestVert(const Point from, const Polygon
|
||||
PolygonsPointIndex closest_vert;
|
||||
for (unsigned int poly_idx = 0; poly_idx < polys.size(); poly_idx++)
|
||||
{
|
||||
ConstPolygonRef poly = polys[poly_idx];
|
||||
const PolygonRef poly = polys[poly_idx];
|
||||
for (unsigned int point_idx = 0; point_idx < poly.size(); point_idx++)
|
||||
{
|
||||
int64_t dist2 = vSize2(poly[point_idx] - from);
|
||||
@@ -692,7 +692,7 @@ PolygonsPointIndex PolygonUtils::findNearestVert(const Point from, const Polygon
|
||||
return closest_vert;
|
||||
}
|
||||
|
||||
unsigned int PolygonUtils::findNearestVert(const Point from, ConstPolygonRef poly)
|
||||
unsigned int PolygonUtils::findNearestVert(const Point from, const PolygonRef poly)
|
||||
{
|
||||
int64_t best_dist2 = std::numeric_limits<int64_t>::max();
|
||||
unsigned int closest_vert_idx = -1;
|
||||
@@ -721,7 +721,7 @@ LocToLineGrid* PolygonUtils::createLocToLineGrid(const Polygons& polygons, int s
|
||||
|
||||
for (unsigned int poly_idx = 0; poly_idx < polygons.size(); poly_idx++)
|
||||
{
|
||||
ConstPolygonRef poly = polygons[poly_idx];
|
||||
const PolygonRef poly = polygons[poly_idx];
|
||||
for (unsigned int point_idx = 0; point_idx < poly.size(); point_idx++)
|
||||
{
|
||||
ret->insert(PolygonsPointIndex(&polygons, poly_idx, point_idx));
|
||||
@@ -752,9 +752,9 @@ std::optional<ClosestPolygonPoint> PolygonUtils::findClose(
|
||||
PolygonsPointIndex best_point_poly_idx(nullptr, NO_INDEX, NO_INDEX);
|
||||
for (PolygonsPointIndex& point_poly_index : near_lines)
|
||||
{
|
||||
ConstPolygonRef poly = polygons[point_poly_index.poly_idx];
|
||||
const Point& p1 = poly[point_poly_index.point_idx];
|
||||
const Point& p2 = poly[(point_poly_index.point_idx + 1) % poly.size()];
|
||||
const PolygonRef poly = polygons[point_poly_index.poly_idx];
|
||||
Point& p1 = poly[point_poly_index.point_idx];
|
||||
Point& p2 = poly[(point_poly_index.point_idx + 1) % poly.size()];
|
||||
|
||||
Point closest_here = LinearAlg2D::getClosestOnLineSegment(from, p1 ,p2);
|
||||
int64_t dist2_score = vSize2(from - closest_here) + penalty_function(closest_here);
|
||||
@@ -778,7 +778,7 @@ std::optional<ClosestPolygonPoint> PolygonUtils::findClose(
|
||||
|
||||
|
||||
std::vector<std::pair<ClosestPolygonPoint, ClosestPolygonPoint>> PolygonUtils::findClose(
|
||||
ConstPolygonRef from, const Polygons& destination,
|
||||
const PolygonRef from, const Polygons& destination,
|
||||
const LocToLineGrid& destination_loc_to_line,
|
||||
const std::function<int(Point)>& penalty_function)
|
||||
{
|
||||
@@ -817,7 +817,7 @@ std::vector<std::pair<ClosestPolygonPoint, ClosestPolygonPoint>> PolygonUtils::f
|
||||
|
||||
|
||||
|
||||
bool PolygonUtils::getNextPointWithDistance(Point from, int64_t dist, ConstPolygonRef poly, int start_idx, int poly_start_idx, GivenDistPoint& result)
|
||||
bool PolygonUtils::getNextPointWithDistance(Point from, int64_t dist, const PolygonRef poly, int start_idx, int poly_start_idx, GivenDistPoint& result)
|
||||
{
|
||||
|
||||
Point prev_poly_point = poly[(start_idx + poly_start_idx) % poly.size()];
|
||||
@@ -825,7 +825,7 @@ bool PolygonUtils::getNextPointWithDistance(Point from, int64_t dist, ConstPolyg
|
||||
for (unsigned int prev_idx = start_idx; prev_idx < poly.size(); prev_idx++)
|
||||
{
|
||||
int next_idx = (prev_idx + 1 + poly_start_idx) % poly.size(); // last checked segment is between last point in poly and poly[0]...
|
||||
const Point& next_poly_point = poly[next_idx];
|
||||
Point& next_poly_point = poly[next_idx];
|
||||
if ( !shorterThen(next_poly_point - from, dist) )
|
||||
{
|
||||
/*
|
||||
@@ -932,7 +932,7 @@ bool PolygonUtils::polygonCollidesWithLineSegment(const Point from, const Point
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool PolygonUtils::polygonCollidesWithLineSegment(ConstPolygonRef poly, const Point& transformed_startPoint, const Point& transformed_endPoint, PointMatrix transformation_matrix)
|
||||
bool PolygonUtils::polygonCollidesWithLineSegment(const PolygonRef poly, Point& transformed_startPoint, Point& transformed_endPoint, PointMatrix transformation_matrix)
|
||||
{
|
||||
Point p0 = transformation_matrix.apply(poly.back());
|
||||
for(Point p1_ : poly)
|
||||
@@ -947,7 +947,7 @@ bool PolygonUtils::polygonCollidesWithLineSegment(ConstPolygonRef poly, const Po
|
||||
return false;
|
||||
}
|
||||
|
||||
bool PolygonUtils::polygonCollidesWithLineSegment(ConstPolygonRef poly, const Point& startPoint, const Point& endPoint)
|
||||
bool PolygonUtils::polygonCollidesWithLineSegment(const PolygonRef poly, Point& startPoint, Point& endPoint)
|
||||
{
|
||||
Point diff = endPoint - startPoint;
|
||||
|
||||
@@ -958,9 +958,9 @@ bool PolygonUtils::polygonCollidesWithLineSegment(ConstPolygonRef poly, const Po
|
||||
return PolygonUtils::polygonCollidesWithLineSegment(poly, transformed_startPoint, transformed_endPoint, transformation_matrix);
|
||||
}
|
||||
|
||||
bool PolygonUtils::polygonCollidesWithLineSegment(const Polygons& polys, const Point& transformed_startPoint, const Point& transformed_endPoint, PointMatrix transformation_matrix)
|
||||
bool PolygonUtils::polygonCollidesWithLineSegment(const Polygons& polys, Point& transformed_startPoint, Point& transformed_endPoint, PointMatrix transformation_matrix)
|
||||
{
|
||||
for (ConstPolygonRef poly : polys)
|
||||
for (const PolygonRef poly : const_cast<Polygons&>(polys))
|
||||
{
|
||||
if (poly.size() == 0) { continue; }
|
||||
if (PolygonUtils::polygonCollidesWithLineSegment(poly, transformed_startPoint, transformed_endPoint, transformation_matrix))
|
||||
@@ -973,7 +973,7 @@ bool PolygonUtils::polygonCollidesWithLineSegment(const Polygons& polys, const P
|
||||
}
|
||||
|
||||
|
||||
bool PolygonUtils::polygonCollidesWithLineSegment(const Polygons& polys, const Point& startPoint, const Point& endPoint)
|
||||
bool PolygonUtils::polygonCollidesWithLineSegment(const Polygons& polys, Point& startPoint, Point& endPoint)
|
||||
{
|
||||
Point diff = endPoint - startPoint;
|
||||
|
||||
|
||||
+18
-18
@@ -20,12 +20,12 @@ namespace cura
|
||||
struct ClosestPolygonPoint
|
||||
{
|
||||
Point location; //!< Result location
|
||||
std::optional<ConstPolygonRef> poly; //!< Polygon in which the result was found (or none if no result was found)
|
||||
std::optional<PolygonRef> poly; //!< Polygon in which the result was found (or none if no result was found)
|
||||
unsigned int poly_idx; //!< The index of the polygon in some Polygons where ClosestPolygonPoint::poly can be found
|
||||
unsigned int point_idx; //!< Index to the first point in the polygon of the line segment on which the result was found
|
||||
ClosestPolygonPoint(Point p, int pos, ConstPolygonRef poly) : location(p), poly(true, poly), poly_idx(NO_INDEX), point_idx(pos) {};
|
||||
ClosestPolygonPoint(Point p, int pos, ConstPolygonRef poly, int poly_idx) : location(p), poly(true, poly), poly_idx(poly_idx), point_idx(pos) {};
|
||||
ClosestPolygonPoint(ConstPolygonRef poly) : poly(true, poly), poly_idx(NO_INDEX), point_idx(NO_INDEX) {};
|
||||
ClosestPolygonPoint(Point p, int pos, PolygonRef poly) : location(p), poly(true, poly), poly_idx(NO_INDEX), point_idx(pos) {};
|
||||
ClosestPolygonPoint(Point p, int pos, PolygonRef poly, int poly_idx) : location(p), poly(true, poly), poly_idx(poly_idx), point_idx(pos) {};
|
||||
ClosestPolygonPoint(PolygonRef poly) : poly(true, poly), poly_idx(NO_INDEX), point_idx(NO_INDEX) {};
|
||||
ClosestPolygonPoint() : poly_idx(NO_INDEX), point_idx(NO_INDEX) {};
|
||||
Point p() const
|
||||
{ // conformity with other classes
|
||||
@@ -53,7 +53,7 @@ struct PolygonsPointIndexSegmentLocator
|
||||
{
|
||||
std::pair<Point, Point> operator()(const PolygonsPointIndex& val) const
|
||||
{
|
||||
ConstPolygonRef poly = (*val.polygons)[val.poly_idx];
|
||||
PolygonRef poly = (*val.polygons)[val.poly_idx];
|
||||
Point start = poly[val.point_idx];
|
||||
unsigned int next_point_idx = (val.point_idx + 1) % poly.size();
|
||||
Point end = poly[next_point_idx];
|
||||
@@ -104,7 +104,7 @@ public:
|
||||
* \param poly The polygon.
|
||||
* \param point_idx The index of the point in the polygon.
|
||||
*/
|
||||
static Point getVertexInwardNormal(ConstPolygonRef poly, unsigned int point_idx);
|
||||
static Point getVertexInwardNormal(PolygonRef poly, unsigned int point_idx);
|
||||
|
||||
/*!
|
||||
* Get a point from the \p poly with a given \p offset.
|
||||
@@ -114,7 +114,7 @@ public:
|
||||
* \param offset The distance the point has to be moved outward from the polygon.
|
||||
* \return A point at the given distance inward from the point on the boundary polygon.
|
||||
*/
|
||||
static Point getBoundaryPointWithOffset(ConstPolygonRef poly, unsigned int point_idx, int64_t offset);
|
||||
static Point getBoundaryPointWithOffset(PolygonRef poly, unsigned int point_idx, int64_t offset);
|
||||
|
||||
/*!
|
||||
* Move a point away from the boundary by looking at the boundary normal of the nearest vert.
|
||||
@@ -178,7 +178,7 @@ public:
|
||||
* \param penalty_function A function returning a penalty term on the squared distance score of a candidate point.
|
||||
* \return The point on the polygon closest to \p from
|
||||
*/
|
||||
static ClosestPolygonPoint moveInside2(const Polygons& loc_to_line_polygons, ConstPolygonRef polygon, Point& from, const int distance = 0, const int64_t max_dist2 = std::numeric_limits<int64_t>::max(), const LocToLineGrid* loc_to_line_grid = nullptr, const std::function<int(Point)>& penalty_function = no_penalty_function);
|
||||
static ClosestPolygonPoint moveInside2(const Polygons& loc_to_line_polygons, const PolygonRef polygon, Point& from, const int distance = 0, const int64_t max_dist2 = std::numeric_limits<int64_t>::max(), const LocToLineGrid* loc_to_line_grid = nullptr, const std::function<int(Point)>& penalty_function = no_penalty_function);
|
||||
|
||||
/*!
|
||||
* The opposite of moveInside.
|
||||
@@ -298,7 +298,7 @@ public:
|
||||
* \param start_idx The index of the point in the polygon from which to start looking.
|
||||
* \return The nearest point from \p start_idx going along the \p polygon (in both directions) with a locally minimal distance to \p from.
|
||||
*/
|
||||
static ClosestPolygonPoint findNearestClosest(Point from, ConstPolygonRef polygon, int start_idx);
|
||||
static ClosestPolygonPoint findNearestClosest(Point from, const PolygonRef polygon, int start_idx);
|
||||
|
||||
/*!
|
||||
* Find the nearest closest point on a polygon from a given index walking in one direction along the polygon.
|
||||
@@ -309,7 +309,7 @@ public:
|
||||
* \param direction The direction to walk: 1 for walking along the \p polygon, -1 for walking in opposite direction
|
||||
* \return The nearest point from \p start_idx going along the \p polygon with a locally minimal distance to \p from.
|
||||
*/
|
||||
static ClosestPolygonPoint findNearestClosest(const Point from, ConstPolygonRef polygon, int start_idx, int direction);
|
||||
static ClosestPolygonPoint findNearestClosest(const Point from, const PolygonRef polygon, int start_idx, int direction);
|
||||
|
||||
/*!
|
||||
* Find the point closest to \p from in all polygons in \p polygons.
|
||||
@@ -327,7 +327,7 @@ public:
|
||||
*
|
||||
* \param penalty_function A function returning a penalty term on the squared distance score of a candidate point.
|
||||
*/
|
||||
static ClosestPolygonPoint findClosest(Point from, ConstPolygonRef polygon, const std::function<int(Point)>& penalty_function = no_penalty_function);
|
||||
static ClosestPolygonPoint findClosest(Point from, const PolygonRef polygon, const std::function<int(Point)>& penalty_function = no_penalty_function);
|
||||
|
||||
/*!
|
||||
* Find the nearest vertex to \p from in \p polys
|
||||
@@ -343,7 +343,7 @@ public:
|
||||
* \param poly The polygon in which to search
|
||||
* \return The index to the nearest vertex on the polygon
|
||||
*/
|
||||
static unsigned int findNearestVert(const Point from, ConstPolygonRef poly);
|
||||
static unsigned int findNearestVert(const Point from, const PolygonRef poly);
|
||||
|
||||
/*!
|
||||
* Create a SparsePointGridInclusive mapping from locations to line segments occurring in the \p polygons
|
||||
@@ -382,7 +382,7 @@ public:
|
||||
* \param penalty_function A function returning a penalty term on the squared distance score of a candidate point.
|
||||
* \return A collection of near crossing from the \p from polygon to the \p destination polygon. Each element in the sollection is a pair with as first a cpp in the \p from polygon and as second a cpp in the \p destination polygon.
|
||||
*/
|
||||
static std::vector<std::pair<ClosestPolygonPoint, ClosestPolygonPoint>> findClose(ConstPolygonRef from, const Polygons& destination, const LocToLineGrid& destination_loc_to_line, const std::function<int(Point)>& penalty_function = no_penalty_function);
|
||||
static std::vector<std::pair<ClosestPolygonPoint, ClosestPolygonPoint>> findClose(const PolygonRef from, const Polygons& destination, const LocToLineGrid& destination_loc_to_line, const std::function<int(Point)>& penalty_function = no_penalty_function);
|
||||
|
||||
/*!
|
||||
* Checks whether a given line segment collides with polygons as given in a loc_to_line grid.
|
||||
@@ -409,7 +409,7 @@ public:
|
||||
* \param start_idx the index of the prev poly point on the poly.
|
||||
* \param poly_start_idx The index of the point in the polygon which is to be handled as the start of the polygon. No point further than this point will be the result.
|
||||
*/
|
||||
static bool getNextPointWithDistance(Point from, int64_t dist, ConstPolygonRef poly, int start_idx, int poly_start_idx, GivenDistPoint& result);
|
||||
static bool getNextPointWithDistance(Point from, int64_t dist, const PolygonRef poly, int start_idx, int poly_start_idx, GivenDistPoint& result);
|
||||
|
||||
|
||||
|
||||
@@ -433,7 +433,7 @@ public:
|
||||
* \return whether the line segment collides with the boundary of the
|
||||
* polygon(s)
|
||||
*/
|
||||
static bool polygonCollidesWithLineSegment(ConstPolygonRef poly, const Point& transformed_startPoint, const Point& transformed_endPoint, PointMatrix transformation_matrix);
|
||||
static bool polygonCollidesWithLineSegment(const PolygonRef poly, Point& transformed_startPoint, Point& transformed_endPoint, PointMatrix transformation_matrix);
|
||||
|
||||
/*!
|
||||
* Checks whether a given line segment collides with a given polygon(s).
|
||||
@@ -449,7 +449,7 @@ public:
|
||||
* \return whether the line segment collides with the boundary of the
|
||||
* polygon(s)
|
||||
*/
|
||||
static bool polygonCollidesWithLineSegment(ConstPolygonRef poly, const Point& startPoint, const Point& endPoint);
|
||||
static bool polygonCollidesWithLineSegment(const PolygonRef poly, Point& startPoint, Point& endPoint);
|
||||
|
||||
/*!
|
||||
* Checks whether a given line segment collides with a given polygon(s).
|
||||
@@ -471,7 +471,7 @@ public:
|
||||
* \return whether the line segment collides with the boundary of the
|
||||
* polygon(s)
|
||||
*/
|
||||
static bool polygonCollidesWithLineSegment(const Polygons& polys, const Point& transformed_startPoint, const Point& transformed_endPoint, PointMatrix transformation_matrix);
|
||||
static bool polygonCollidesWithLineSegment(const Polygons& polys, Point& transformed_startPoint, Point& transformed_endPoint, PointMatrix transformation_matrix);
|
||||
|
||||
/*!
|
||||
* Checks whether a given line segment collides with a given polygon(s).
|
||||
@@ -487,7 +487,7 @@ public:
|
||||
* \return whether the line segment collides with the boundary of the
|
||||
* polygon(s)
|
||||
*/
|
||||
static bool polygonCollidesWithLineSegment(const Polygons& polys, const Point& startPoint, const Point& endPoint);
|
||||
static bool polygonCollidesWithLineSegment(const Polygons& polys, Point& startPoint, Point& endPoint);
|
||||
|
||||
private:
|
||||
/*!
|
||||
|
||||
@@ -18,7 +18,7 @@ WallOverlapComputation::WallOverlapComputation(Polygons& polygons, int line_widt
|
||||
}
|
||||
|
||||
|
||||
float WallOverlapComputation::getFlow(const Point& from, const Point& to)
|
||||
float WallOverlapComputation::getFlow(Point& from, Point& to)
|
||||
{
|
||||
using Point2LinkIt = PolygonProximityLinker::Point2Link::iterator;
|
||||
|
||||
|
||||
+1
-1
@@ -60,7 +60,7 @@ public:
|
||||
* \param to The ending of the line segment
|
||||
* \return a value between zero and one representing the reduced flow of the line segment
|
||||
*/
|
||||
float getFlow(const Point& from, const Point& to);
|
||||
float getFlow(Point& from, Point& to);
|
||||
|
||||
/*!
|
||||
* Computes the neccesary priliminaries in order to efficiently compute the flow when generatign gcode paths.
|
||||
|
||||
Referência em uma Nova Issue
Bloquear um usuário