2014-05-10 13:08:49 +00:00
# ifndef slic3r_GCode_hpp_
# define slic3r_GCode_hpp_
2015-12-07 23:39:54 +00:00
# include "libslic3r.h"
2015-07-01 18:14:05 +00:00
# include "ExPolygon.hpp"
2015-07-01 19:47:17 +00:00
# include "GCodeWriter.hpp"
# include "Layer.hpp"
2015-07-01 18:14:05 +00:00
# include "MotionPlanner.hpp"
2015-07-01 19:47:17 +00:00
# include "Point.hpp"
# include "PlaceholderParser.hpp"
# include "PrintConfig.hpp"
2017-05-03 16:28:22 +00:00
# include "GCode/CoolingBuffer.hpp"
# include "GCode/SpiralVase.hpp"
2017-05-16 11:45:28 +00:00
# include "GCode/ToolOrdering.hpp"
# include "GCode/WipeTower.hpp"
2020-02-14 07:31:31 +00:00
# if ENABLE_GCODE_VIEWER
# include "GCode/GCodeProcessor.hpp"
2020-05-07 08:49:12 +00:00
# else
# include "GCode/Analyzer.hpp"
2017-12-11 08:06:29 +00:00
# include "GCodeTimeEstimator.hpp"
2020-08-05 13:43:46 +00:00
# endif // ENABLE_GCODE_VIEWER
2017-05-03 16:28:22 +00:00
# include "EdgeGrid.hpp"
2019-11-22 11:39:03 +00:00
# include "GCode/ThumbnailData.hpp"
2017-05-03 16:28:22 +00:00
2017-05-03 16:35:55 +00:00
# include <memory>
2014-05-10 13:08:49 +00:00
# include <string>
2019-01-29 17:07:45 +00:00
# ifdef HAS_PRESSURE_EQUALIZER
# include "GCode/PressureEqualizer.hpp"
# endif /* HAS_PRESSURE_EQUALIZER */
2014-05-10 13:08:49 +00:00
namespace Slic3r {
2016-09-12 14:25:15 +00:00
// Forward declarations.
2015-07-01 21:00:52 +00:00
class GCode ;
2020-05-07 08:49:12 +00:00
# if !ENABLE_GCODE_VIEWER
2018-02-14 19:35:59 +00:00
class GCodePreviewData ;
2020-05-07 08:49:12 +00:00
# endif // !ENABLE_GCODE_VIEWER
2014-05-10 13:08:49 +00:00
2020-05-26 09:09:38 +00:00
namespace { struct Item ; }
struct PrintInstance ;
using PrintObjectPtrs = std : : vector < PrintObject * > ;
2015-07-01 18:14:05 +00:00
class AvoidCrossingPerimeters {
2017-05-03 16:28:22 +00:00
public :
2014-05-10 13:08:49 +00:00
2015-07-01 18:14:05 +00:00
// this flag triggers the use of the external configuration space
bool use_external_mp ;
bool use_external_mp_once ; // just for the next travel move
// this flag disables avoid_crossing_perimeters just for the next travel move
// we enable it by default for the first travel move in print
bool disable_once ;
2017-05-05 07:59:56 +00:00
AvoidCrossingPerimeters ( ) : use_external_mp ( false ) , use_external_mp_once ( false ) , disable_once ( true ) { }
~ AvoidCrossingPerimeters ( ) { }
2019-08-26 07:55:00 +00:00
void reset ( ) { m_external_mp . reset ( ) ; m_layer_mp . reset ( ) ; }
2019-08-25 07:01:01 +00:00
void init_external_mp ( const Print & print ) ;
2017-05-05 07:59:56 +00:00
void init_layer_mp ( const ExPolygons & islands ) { m_layer_mp = Slic3r : : make_unique < MotionPlanner > ( islands ) ; }
2017-06-02 11:33:19 +00:00
Polyline travel_to ( const GCode & gcodegen , const Point & point ) ;
2017-05-05 07:59:56 +00:00
2017-05-03 16:28:22 +00:00
private :
2019-08-25 07:01:01 +00:00
// For initializing the regions to avoid.
static Polygons collect_contours_all_layers ( const PrintObjectPtrs & objects ) ;
2017-05-05 07:59:56 +00:00
std : : unique_ptr < MotionPlanner > m_external_mp ;
std : : unique_ptr < MotionPlanner > m_layer_mp ;
2014-05-10 13:08:49 +00:00
} ;
2015-07-01 19:01:42 +00:00
class OozePrevention {
2017-04-26 12:24:31 +00:00
public :
2015-07-01 19:01:42 +00:00
bool enable ;
Points standby_points ;
2017-04-26 12:24:31 +00:00
OozePrevention ( ) : enable ( false ) { }
2015-07-02 13:02:20 +00:00
std : : string pre_toolchange ( GCode & gcodegen ) ;
std : : string post_toolchange ( GCode & gcodegen ) ;
2017-04-26 12:24:31 +00:00
private :
2015-07-02 13:02:20 +00:00
int _get_temp ( GCode & gcodegen ) ;
2015-07-01 19:01:42 +00:00
} ;
2015-07-01 18:57:16 +00:00
class Wipe {
2017-04-26 12:24:31 +00:00
public :
2015-07-01 18:57:16 +00:00
bool enable ;
Polyline path ;
2017-04-26 12:24:31 +00:00
Wipe ( ) : enable ( false ) { }
bool has_path ( ) const { return ! this - > path . points . empty ( ) ; }
void reset_path ( ) { this - > path = Polyline ( ) ; }
2015-07-01 21:00:52 +00:00
std : : string wipe ( GCode & gcodegen , bool toolchange = false ) ;
2015-07-01 18:57:16 +00:00
} ;
2017-05-18 14:53:19 +00:00
class WipeTowerIntegration {
public :
2017-05-25 20:27:53 +00:00
WipeTowerIntegration (
const PrintConfig & print_config ,
2019-06-14 10:28:24 +00:00
const std : : vector < WipeTower : : ToolChangeResult > & priming ,
2017-05-25 20:27:53 +00:00
const std : : vector < std : : vector < WipeTower : : ToolChangeResult > > & tool_changes ,
const WipeTower : : ToolChangeResult & final_purge ) :
2018-07-27 13:56:27 +00:00
m_left ( /*float(print_config.wipe_tower_x.value)*/ 0.f ) ,
m_right ( float ( /*print_config.wipe_tower_x.value +*/ print_config . wipe_tower_width . value ) ) ,
m_wipe_tower_pos ( float ( print_config . wipe_tower_x . value ) , float ( print_config . wipe_tower_y . value ) ) ,
m_wipe_tower_rotation ( float ( print_config . wipe_tower_rotation_angle ) ) ,
2019-07-19 10:59:56 +00:00
m_extruder_offsets ( print_config . extruder_offset . values ) ,
2017-09-01 15:30:18 +00:00
m_priming ( priming ) ,
2017-05-25 20:27:53 +00:00
m_tool_changes ( tool_changes ) ,
m_final_purge ( final_purge ) ,
m_layer_idx ( - 1 ) ,
m_tool_change_idx ( 0 ) ,
m_brim_done ( false ) { }
2017-09-01 15:30:18 +00:00
std : : string prime ( GCode & gcodegen ) ;
2017-05-25 20:27:53 +00:00
void next_layer ( ) { + + m_layer_idx ; m_tool_change_idx = 0 ; }
2019-06-14 10:49:43 +00:00
std : : string tool_change ( GCode & gcodegen , int extruder_id , bool finish_layer ) ;
2017-05-25 20:27:53 +00:00
std : : string finalize ( GCode & gcodegen ) ;
2018-09-17 13:12:13 +00:00
std : : vector < float > used_filament_length ( ) const ;
2017-05-18 14:53:19 +00:00
private :
2017-05-25 20:27:53 +00:00
WipeTowerIntegration & operator = ( const WipeTowerIntegration & ) ;
2019-09-19 12:58:04 +00:00
std : : string append_tcr ( GCode & gcodegen , const WipeTower : : ToolChangeResult & tcr , int new_extruder_id , double z = - 1. ) const ;
2017-05-25 20:27:53 +00:00
2019-07-19 10:59:56 +00:00
// Postprocesses gcode: rotates and moves G1 extrusions and returns result
std : : string post_process_wipe_tower_moves ( const WipeTower : : ToolChangeResult & tcr , const Vec2f & translation , float angle ) const ;
2018-07-27 13:56:27 +00:00
2017-05-25 20:27:53 +00:00
// Left / right edges of the wipe tower, for the planning of wipe moves.
const float m_left ;
const float m_right ;
2019-06-17 08:16:07 +00:00
const Vec2f m_wipe_tower_pos ;
2018-07-27 13:56:27 +00:00
const float m_wipe_tower_rotation ;
2019-07-19 10:59:56 +00:00
const std : : vector < Vec2d > m_extruder_offsets ;
2017-05-25 20:27:53 +00:00
// Reference to cached values at the Printer class.
2019-06-14 10:28:24 +00:00
const std : : vector < WipeTower : : ToolChangeResult > & m_priming ;
2017-05-25 20:27:53 +00:00
const std : : vector < std : : vector < WipeTower : : ToolChangeResult > > & m_tool_changes ;
const WipeTower : : ToolChangeResult & m_final_purge ;
// Current layer index.
int m_layer_idx ;
int m_tool_change_idx ;
bool m_brim_done ;
2018-07-27 13:56:27 +00:00
bool i_have_brim = false ;
2019-09-19 12:58:04 +00:00
double m_last_wipe_tower_print_z = 0.f ;
2017-05-18 14:53:19 +00:00
} ;
2020-05-07 08:49:12 +00:00
# if ENABLE_GCODE_VIEWER
class ColorPrintColors
{
static const std : : vector < std : : string > Colors ;
public :
static const std : : vector < std : : string > & get ( ) { return Colors ; }
} ;
# endif // ENABLE_GCODE_VIEWER
2015-07-01 19:47:17 +00:00
class GCode {
2017-05-03 16:28:22 +00:00
public :
GCode ( ) :
2018-08-21 18:34:45 +00:00
m_origin ( Vec2d : : Zero ( ) ) ,
2017-05-03 16:28:22 +00:00
m_enable_loop_clipping ( true ) ,
m_enable_cooling_markers ( false ) ,
m_enable_extrusion_role_markers ( false ) ,
2020-05-07 08:49:12 +00:00
# if ENABLE_GCODE_VIEWER
m_last_processor_extrusion_role ( erNone ) ,
# else
2018-02-14 19:35:59 +00:00
m_enable_analyzer ( false ) ,
2018-05-07 12:23:07 +00:00
m_last_analyzer_extrusion_role ( erNone ) ,
2020-05-07 08:49:12 +00:00
# endif // ENABLE_GCODE_VIEWER
2017-05-03 16:28:22 +00:00
m_layer_count ( 0 ) ,
m_layer_index ( - 1 ) ,
m_layer ( nullptr ) ,
m_volumetric_speed ( 0 ) ,
m_last_pos_defined ( false ) ,
m_last_extrusion_role ( erNone ) ,
2020-08-17 08:06:41 +00:00
# if ENABLE_GCODE_VIEWER_DATA_CHECKING
m_last_mm3_per_mm ( 0.0 ) ,
2020-08-17 12:37:26 +00:00
m_last_width ( 0.0f ) ,
2020-08-17 08:06:41 +00:00
# endif // ENABLE_GCODE_VIEWER_DATA_CHECKING
2020-07-30 11:49:57 +00:00
# if !ENABLE_GCODE_VIEWER
2018-01-08 12:44:10 +00:00
m_last_mm3_per_mm ( GCodeAnalyzer : : Default_mm3_per_mm ) ,
m_last_width ( GCodeAnalyzer : : Default_Width ) ,
m_last_height ( GCodeAnalyzer : : Default_Height ) ,
2020-07-30 11:49:57 +00:00
# endif // !ENABLE_GCODE_VIEWER
2017-05-03 16:28:22 +00:00
m_brim_done ( false ) ,
m_second_layer_things_done ( false ) ,
2020-08-05 13:43:46 +00:00
# if !ENABLE_GCODE_VIEWER
2018-06-27 13:35:47 +00:00
m_normal_time_estimator ( GCodeTimeEstimator : : Normal ) ,
2018-05-30 10:08:03 +00:00
m_silent_time_estimator ( GCodeTimeEstimator : : Silent ) ,
2020-08-05 13:43:46 +00:00
# endif // !ENABLE_GCODE_VIEWER
2018-06-22 12:01:27 +00:00
m_silent_time_estimator_enabled ( false ) ,
2017-05-10 09:25:57 +00:00
m_last_obj_copy ( nullptr , Point ( std : : numeric_limits < coord_t > : : max ( ) , std : : numeric_limits < coord_t > : : max ( ) ) )
2017-05-03 16:28:22 +00:00
{ }
~ GCode ( ) { }
2018-03-28 15:05:31 +00:00
// throws std::runtime_exception on error,
// throws CanceledException through print->throw_if_canceled().
2020-03-02 14:13:23 +00:00
# if ENABLE_GCODE_VIEWER
2020-05-07 08:49:12 +00:00
void do_export ( Print * print , const char * path , GCodeProcessor : : Result * result = nullptr , ThumbnailsGeneratorCallback thumbnail_cb = nullptr ) ;
2019-10-23 11:31:24 +00:00
# else
2019-11-22 11:39:03 +00:00
void do_export ( Print * print , const char * path , GCodePreviewData * preview_data = nullptr , ThumbnailsGeneratorCallback thumbnail_cb = nullptr ) ;
2020-03-02 14:13:23 +00:00
# endif // ENABLE_GCODE_VIEWER
2017-05-03 16:28:22 +00:00
// Exported for the helper classes (OozePrevention, Wipe) and for the Perl binding for unit tests.
2019-01-14 18:57:41 +00:00
const Vec2d & origin ( ) const { return m_origin ; }
2018-08-21 19:05:24 +00:00
void set_origin ( const Vec2d & pointf ) ;
void set_origin ( const coordf_t x , const coordf_t y ) { this - > set_origin ( Vec2d ( x , y ) ) ; }
2017-05-03 16:28:22 +00:00
const Point & last_pos ( ) const { return m_last_pos ; }
2019-01-14 18:57:41 +00:00
Vec2d point_to_gcode ( const Point & point ) const ;
2018-08-21 19:05:24 +00:00
Point gcode_to_point ( const Vec2d & point ) const ;
2017-05-03 16:28:22 +00:00
const FullPrintConfig & config ( ) const { return m_config ; }
const Layer * layer ( ) const { return m_layer ; }
GCodeWriter & writer ( ) { return m_writer ; }
2017-11-30 15:01:47 +00:00
PlaceholderParser & placeholder_parser ( ) { return m_placeholder_parser ; }
2018-09-10 07:11:49 +00:00
const PlaceholderParser & placeholder_parser ( ) const { return m_placeholder_parser ; }
2017-12-05 14:54:24 +00:00
// Process a template through the placeholder parser, collect error messages to be reported
// inside the generated string and after the G-code export finishes.
std : : string placeholder_parser_process ( const std : : string & name , const std : : string & templ , unsigned int current_extruder_id , const DynamicConfig * config_override = nullptr ) ;
2017-05-03 16:28:22 +00:00
bool enable_cooling_markers ( ) const { return m_enable_cooling_markers ; }
// For Perl bindings, to be used exclusively by unit tests.
unsigned int layer_count ( ) const { return m_layer_count ; }
void set_layer_count ( unsigned int value ) { m_layer_count = value ; }
void apply_print_config ( const PrintConfig & print_config ) ;
2018-02-13 14:19:55 +00:00
// append full config to the given string
static void append_full_config ( const Print & print , std : : string & str ) ;
2020-01-14 09:31:18 +00:00
// Object and support extrusions of the same PrintObject at the same print_z.
// public, so that it could be accessed by free helper functions from GCode.cpp
struct LayerToPrint
{
LayerToPrint ( ) : object_layer ( nullptr ) , support_layer ( nullptr ) { }
const Layer * object_layer ;
const SupportLayer * support_layer ;
const Layer * layer ( ) const { return ( object_layer ! = nullptr ) ? object_layer : support_layer ; }
const PrintObject * object ( ) const { return ( this - > layer ( ) ! = nullptr ) ? this - > layer ( ) - > object ( ) : nullptr ; }
coordf_t print_z ( ) const { return ( object_layer ! = nullptr & & support_layer ! = nullptr ) ? 0.5 * ( object_layer - > print_z + support_layer - > print_z ) : this - > layer ( ) - > print_z ; }
} ;
2020-01-10 10:26:52 +00:00
private :
2020-01-14 09:31:18 +00:00
void _do_export ( Print & print , FILE * file , ThumbnailsGeneratorCallback thumbnail_cb ) ;
2017-08-03 15:31:31 +00:00
2019-09-26 14:39:50 +00:00
static std : : vector < LayerToPrint > collect_layers_to_print ( const PrintObject & object ) ;
2017-05-23 15:09:43 +00:00
static std : : vector < std : : pair < coordf_t , std : : vector < LayerToPrint > > > collect_layers_to_print ( const Print & print ) ;
2017-05-10 09:25:57 +00:00
void process_layer (
// Write into the output file.
FILE * file ,
const Print & print ,
// Set of object & print layers of the same PrintObject and with the same print_z.
const std : : vector < LayerToPrint > & layers ,
2019-09-26 14:39:50 +00:00
const LayerTools & layer_tools ,
// Pairs of PrintObject index and its instance index.
2020-01-23 08:53:06 +00:00
const std : : vector < const PrintInstance * > * ordering ,
2017-05-10 09:25:57 +00:00
// If set to size_t(-1), then print all copies of all objects.
// Otherwise print a single copy of a single object.
const size_t single_object_idx = size_t ( - 1 ) ) ;
2017-05-03 16:28:22 +00:00
void set_last_pos ( const Point & pos ) { m_last_pos = pos ; m_last_pos_defined = true ; }
bool last_pos_defined ( ) const { return m_last_pos_defined ; }
void set_extruders ( const std : : vector < unsigned int > & extruder_ids ) ;
std : : string preamble ( ) ;
2017-05-10 09:25:57 +00:00
std : : string change_layer ( coordf_t print_z ) ;
2017-05-15 09:32:59 +00:00
std : : string extrude_entity ( const ExtrusionEntity & entity , std : : string description = " " , double speed = - 1. , std : : unique_ptr < EdgeGrid : : Grid > * lower_layer_edge_grid = nullptr ) ;
2017-05-10 09:25:57 +00:00
std : : string extrude_loop ( ExtrusionLoop loop , std : : string description , double speed = - 1. , std : : unique_ptr < EdgeGrid : : Grid > * lower_layer_edge_grid = nullptr ) ;
std : : string extrude_multi_path ( ExtrusionMultiPath multipath , std : : string description = " " , double speed = - 1. ) ;
std : : string extrude_path ( ExtrusionPath path , std : : string description = " " , double speed = - 1. ) ;
// Extruding multiple objects with soluble / non-soluble / combined supports
// on a multi-material printer, trying to minimize tool switches.
// Following structures sort extrusions by the extruder ID, by an order of objects and object islands.
struct ObjectByExtruder
2017-05-03 16:28:22 +00:00
{
2017-05-10 09:25:57 +00:00
ObjectByExtruder ( ) : support ( nullptr ) , support_extrusion_role ( erNone ) { }
const ExtrusionEntityCollection * support ;
// erSupportMaterial / erSupportMaterialInterface or erMixed.
ExtrusionRole support_extrusion_role ;
struct Island
{
struct Region {
2020-01-09 09:00:38 +00:00
// Non-owned references to LayerRegion::perimeters::entities
// std::vector<const ExtrusionEntity*> would be better here, but there is no way in C++ to convert from std::vector<T*> std::vector<const T*> without copying.
ExtrusionEntitiesPtr perimeters ;
// Non-owned references to LayerRegion::fills::entities
ExtrusionEntitiesPtr infills ;
2018-06-20 10:52:00 +00:00
2020-01-08 13:58:12 +00:00
std : : vector < const WipingExtrusions : : ExtruderPerCopy * > infills_overrides ;
std : : vector < const WipingExtrusions : : ExtruderPerCopy * > perimeters_overrides ;
enum Type {
PERIMETERS ,
INFILL ,
} ;
2018-06-20 10:52:00 +00:00
// Appends perimeter/infill entities and writes don't indices of those that are not to be extruder as part of perimeter/infill wiping
2020-01-08 13:58:12 +00:00
void append ( const Type type , const ExtrusionEntityCollection * eec , const WipingExtrusions : : ExtruderPerCopy * copy_extruders ) ;
2017-05-10 09:25:57 +00:00
} ;
2018-06-20 10:52:00 +00:00
2020-01-08 13:58:12 +00:00
2018-06-06 16:24:42 +00:00
std : : vector < Region > by_region ; // all extrusions for this island, grouped by regions
2020-01-08 13:58:12 +00:00
// Fills in by_region_per_copy_cache and returns its reference.
2020-01-10 10:26:52 +00:00
const std : : vector < Region > & by_region_per_copy ( std : : vector < Region > & by_region_per_copy_cache , unsigned int copy , unsigned int extruder , bool wiping_entities = false ) const ;
2017-05-03 16:28:22 +00:00
} ;
2017-05-10 09:25:57 +00:00
std : : vector < Island > islands ;
2017-05-03 16:28:22 +00:00
} ;
2018-05-31 14:21:10 +00:00
2019-09-26 14:39:50 +00:00
struct InstanceToPrint
{
InstanceToPrint ( ObjectByExtruder & object_by_extruder , size_t layer_id , const PrintObject & print_object , size_t instance_id ) :
object_by_extruder ( object_by_extruder ) , layer_id ( layer_id ) , print_object ( print_object ) , instance_id ( instance_id ) { }
2020-01-08 13:58:12 +00:00
// Repository
ObjectByExtruder & object_by_extruder ;
// Index into std::vector<LayerToPrint>, which contains Object and Support layers for the current print_z, collected for a single object, or for possibly multiple objects with multiple instances.
2019-09-26 14:39:50 +00:00
const size_t layer_id ;
const PrintObject & print_object ;
// Instance idx of the copy of a print object.
const size_t instance_id ;
} ;
std : : vector < InstanceToPrint > sort_print_object_instances (
2020-01-08 13:58:12 +00:00
std : : vector < ObjectByExtruder > & objects_by_extruder ,
// Object and Support layers for the current print_z, collected for a single object, or for possibly multiple objects with multiple instances.
2019-09-26 14:39:50 +00:00
const std : : vector < LayerToPrint > & layers ,
// Ordering must be defined for normal (non-sequential print).
2020-01-23 08:53:06 +00:00
const std : : vector < const PrintInstance * > * ordering ,
2019-09-26 14:39:50 +00:00
// For sequential print, the instance of the object to be printing has to be defined.
const size_t single_object_instance_idx ) ;
2018-05-31 14:21:10 +00:00
2017-05-10 09:25:57 +00:00
std : : string extrude_perimeters ( const Print & print , const std : : vector < ObjectByExtruder : : Island : : Region > & by_region , std : : unique_ptr < EdgeGrid : : Grid > & lower_layer_edge_grid ) ;
2020-04-14 09:53:28 +00:00
std : : string extrude_infill ( const Print & print , const std : : vector < ObjectByExtruder : : Island : : Region > & by_region , bool ironing ) ;
2017-05-10 09:25:57 +00:00
std : : string extrude_support ( const ExtrusionEntityCollection & support_fills ) ;
2017-05-03 16:28:22 +00:00
std : : string travel_to ( const Point & point , ExtrusionRole role , std : : string comment ) ;
bool needs_retraction ( const Polyline & travel , ExtrusionRole role = erNone ) ;
std : : string retract ( bool toolchange = false ) ;
2017-05-10 09:25:57 +00:00
std : : string unretract ( ) { return m_writer . unlift ( ) + m_writer . unretract ( ) ; }
2019-01-29 11:02:48 +00:00
std : : string set_extruder ( unsigned int extruder_id , double print_z ) ;
2017-05-03 16:28:22 +00:00
2015-07-01 19:47:17 +00:00
/* Origin of print coordinates expressed in unscaled G-code coordinates.
This affects the input arguments supplied to the extrude * ( ) and travel_to ( )
methods . */
2019-01-29 11:02:48 +00:00
Vec2d m_origin ;
2017-05-03 16:28:22 +00:00
FullPrintConfig m_config ;
GCodeWriter m_writer ;
PlaceholderParser m_placeholder_parser ;
2017-12-05 14:54:24 +00:00
// Collection of templates, on which the placeholder substitution failed.
std : : set < std : : string > m_placeholder_parser_failed_templates ;
2017-05-03 16:28:22 +00:00
OozePrevention m_ooze_prevention ;
Wipe m_wipe ;
AvoidCrossingPerimeters m_avoid_crossing_perimeters ;
bool m_enable_loop_clipping ;
2016-09-13 11:30:00 +00:00
// If enabled, the G-code generator will put following comments at the ends
// of the G-code lines: _EXTRUDE_SET_SPEED, _WIPE, _BRIDGE_FAN_START, _BRIDGE_FAN_END
// Those comments are received and consumed (removed from the G-code) by the CoolingBuffer.pm Perl module.
2017-05-03 16:28:22 +00:00
bool m_enable_cooling_markers ;
2016-09-12 14:25:15 +00:00
// Markers for the Pressure Equalizer to recognize the extrusion type.
// The Pressure Equalizer removes the markers from the final G-code.
2017-05-03 16:28:22 +00:00
bool m_enable_extrusion_role_markers ;
2020-05-07 08:49:12 +00:00
# if ENABLE_GCODE_VIEWER
// Keeps track of the last extrusion role passed to the processor
ExtrusionRole m_last_processor_extrusion_role ;
# else
2018-01-08 12:44:10 +00:00
// Enableds the G-code Analyzer.
// Extended markers will be added during G-code generation.
// The G-code Analyzer will remove these comments from the final G-code.
bool m_enable_analyzer ;
2018-05-07 12:23:07 +00:00
ExtrusionRole m_last_analyzer_extrusion_role ;
2020-05-07 08:49:12 +00:00
# endif // ENABLE_GCODE_VIEWER
2016-09-26 10:52:40 +00:00
// How many times will change_layer() be called?
// change_layer() will update the progress bar.
2017-05-03 16:28:22 +00:00
unsigned int m_layer_count ;
2016-09-26 10:52:40 +00:00
// Progress bar indicator. Increments from -1 up to layer_count.
2017-05-03 16:28:22 +00:00
int m_layer_index ;
2016-09-26 10:52:40 +00:00
// Current layer processed. Insequential printing mode, only a single copy will be printed.
// In non-sequential mode, all its copies will be printed.
2017-05-03 16:28:22 +00:00
const Layer * m_layer ;
std : : map < const PrintObject * , Point > m_seam_position ;
double m_volumetric_speed ;
2016-09-12 14:25:15 +00:00
// Support for the extrusion role markers. Which marker is active?
2017-05-03 16:28:22 +00:00
ExtrusionRole m_last_extrusion_role ;
2020-07-29 08:04:10 +00:00
# if ENABLE_GCODE_VIEWER
// Support for G-Code Processor
2020-07-30 11:49:57 +00:00
float m_last_height { 0.0f } ;
float m_last_layer_z { 0.0f } ;
2020-08-17 08:06:41 +00:00
# if ENABLE_GCODE_VIEWER_DATA_CHECKING
double m_last_mm3_per_mm ;
2020-08-17 12:37:26 +00:00
float m_last_width { 0.0f } ;
2020-08-17 08:06:41 +00:00
# endif // ENABLE_GCODE_VIEWER_DATA_CHECKING
2020-07-29 08:04:10 +00:00
# else
2018-01-08 12:44:10 +00:00
// Support for G-Code Analyzer
double m_last_mm3_per_mm ;
float m_last_width ;
float m_last_height ;
2020-07-29 08:04:10 +00:00
# endif // ENABLE_GCODE_VIEWER
2017-05-03 16:28:22 +00:00
Point m_last_pos ;
bool m_last_pos_defined ;
std : : unique_ptr < CoolingBuffer > m_cooling_buffer ;
std : : unique_ptr < SpiralVase > m_spiral_vase ;
2019-01-29 17:07:45 +00:00
# ifdef HAS_PRESSURE_EQUALIZER
2017-05-03 16:28:22 +00:00
std : : unique_ptr < PressureEqualizer > m_pressure_equalizer ;
2019-01-29 17:07:45 +00:00
# endif /* HAS_PRESSURE_EQUALIZER */
2017-05-18 14:53:19 +00:00
std : : unique_ptr < WipeTowerIntegration > m_wipe_tower ;
2017-05-03 16:28:22 +00:00
2020-01-14 13:24:38 +00:00
// Heights (print_z) at which the skirt has already been extruded.
2017-05-10 09:25:57 +00:00
std : : vector < coordf_t > m_skirt_done ;
2017-05-03 16:28:22 +00:00
// Has the brim been extruded already? Brim is being extruded only for the first object of a multi-object print.
bool m_brim_done ;
// Flag indicating whether the nozzle temperature changes from 1st to 2nd layer were performed.
bool m_second_layer_things_done ;
2017-05-10 09:25:57 +00:00
// Index of a last object copy extruded.
std : : pair < const PrintObject * , Point > m_last_obj_copy ;
2017-05-03 16:28:22 +00:00
2020-08-05 13:43:46 +00:00
# if !ENABLE_GCODE_VIEWER
2018-05-30 10:08:03 +00:00
// Time estimators
2018-06-27 13:35:47 +00:00
GCodeTimeEstimator m_normal_time_estimator ;
2018-05-30 10:08:03 +00:00
GCodeTimeEstimator m_silent_time_estimator ;
2020-08-05 13:43:46 +00:00
# endif // !ENABLE_GCODE_VIEWER
2018-06-22 12:01:27 +00:00
bool m_silent_time_estimator_enabled ;
2017-12-11 08:06:29 +00:00
2020-02-14 07:31:31 +00:00
# if ENABLE_GCODE_VIEWER
// Processor
GCodeProcessor m_processor ;
2020-05-07 08:49:12 +00:00
# else
// Analyzer
GCodeAnalyzer m_analyzer ;
2020-02-14 07:31:31 +00:00
# endif // ENABLE_GCODE_VIEWER
2017-12-14 08:18:28 +00:00
// Write a string into a file.
2018-01-08 12:44:10 +00:00
void _write ( FILE * file , const std : : string & what ) { this - > _write ( file , what . c_str ( ) ) ; }
void _write ( FILE * file , const char * what ) ;
2017-12-14 08:18:28 +00:00
// Write a string into a file.
// Add a newline, if the string does not end with a newline already.
// Used to export a custom G-code section processed by the PlaceholderParser.
void _writeln ( FILE * file , const std : : string & what ) ;
// Formats and write into a file the given data.
void _write_format ( FILE * file , const char * format , . . . ) ;
2017-02-15 16:51:46 +00:00
std : : string _extrude ( const ExtrusionPath & path , std : : string description = " " , double speed = - 1 ) ;
2018-07-17 17:37:24 +00:00
void print_machine_envelope ( FILE * file , Print & print ) ;
2017-11-28 14:19:57 +00:00
void _print_first_layer_bed_temperature ( FILE * file , Print & print , const std : : string & gcode , unsigned int first_printing_extruder_id , bool wait ) ;
void _print_first_layer_extruder_temperatures ( FILE * file , Print & print , const std : : string & gcode , unsigned int first_printing_extruder_id , bool wait ) ;
2017-05-10 09:25:57 +00:00
// this flag triggers first layer speeds
bool on_first_layer ( ) const { return m_layer ! = nullptr & & m_layer - > id ( ) = = 0 ; }
2017-05-03 16:28:22 +00:00
2017-05-10 09:25:57 +00:00
friend ObjectByExtruder & object_by_extruder (
std : : map < unsigned int , std : : vector < ObjectByExtruder > > & by_extruder ,
unsigned int extruder_id ,
size_t object_idx ,
size_t num_objects ) ;
friend std : : vector < ObjectByExtruder : : Island > & object_islands_by_extruder (
std : : map < unsigned int , std : : vector < ObjectByExtruder > > & by_extruder ,
unsigned int extruder_id ,
size_t object_idx ,
size_t num_objects ,
size_t num_islands ) ;
2017-05-18 14:53:19 +00:00
2019-01-14 18:57:41 +00:00
friend class Wipe ;
2017-05-18 14:53:19 +00:00
friend class WipeTowerIntegration ;
2015-07-01 19:47:17 +00:00
} ;
2020-02-03 10:44:26 +00:00
std : : vector < const PrintInstance * > sort_object_instances_by_model_order ( const Print & print ) ;
2014-05-10 13:08:49 +00:00
}
# endif