OrcaSlicer latest
OrcaSlicer
Loading...
Searching...
No Matches
Slic3r::GCodeReader Class Reference

#include </home/runner/work/OrcaSlicer/OrcaSlicer/src/libslic3r/GCodeReader.hpp>

Collaboration diagram for Slic3r::GCodeReader:

Classes

class  GCodeLine

Public Types

typedef std::function< void(GCodeReader &, const GCodeLine &)> callback_t
typedef std::function< void(GCodeReader &, const char *, const char *)> raw_line_callback_t

Public Member Functions

 GCodeReader ()
void reset ()
void apply_config (const GCodeConfig &config)
void apply_config (const DynamicPrintConfig &config)
const GCodeConfig & config ()
template<typename Callback>
void parse_buffer (const std::string &buffer, Callback callback)
void parse_buffer (const std::string &buffer)
template<typename Callback>
const char * parse_line (const char *ptr, const char *end, GCodeLine &gline, Callback &callback)
template<typename Callback>
void parse_line (const std::string &line, Callback callback)
bool parse_file (const std::string &file, callback_t callback)
bool parse_file (const std::string &file, callback_t callback, std::vector< size_t > &lines_ends)
bool parse_file_raw (const std::string &file, raw_line_callback_t callback)
void quit_parsing ()
float & x ()
float x () const
float & y ()
float y () const
float & z ()
float z () const
float & e ()
float e () const
float & f ()
float f () const
float & i ()
float i () const
float & j ()
float j () const
GCodeConfig get_config () const

Private Member Functions

template<typename ParseLineCallback, typename LineEndCallback>
bool parse_file_raw_internal (const std::string &filename, ParseLineCallback parse_line_callback, LineEndCallback line_end_callback)
template<typename ParseLineCallback, typename LineEndCallback>
bool parse_file_internal (const std::string &filename, ParseLineCallback parse_line_callback, LineEndCallback line_end_callback)
const char * parse_line_internal (const char *ptr, const char *end, GCodeLine &gline, std::pair< const char *, const char * > &command)
void update_coordinates (GCodeLine &gline, std::pair< const char *, const char * > &command)

Static Private Member Functions

static bool is_whitespace (char c)
static bool is_end_of_line (char c)
static bool is_end_of_gcode_line (char c)
static bool is_end_of_word (char c)
static const char * skip_whitespaces (const char *c)
static const char * skip_word (const char *c)
static const char * axis_pos (const char *raw_str, char axis)
static const GCodeConfig & default_config ()

Private Attributes

std::shared_ptr< const GCodeConfig > m_config
bool m_use_relative_e_distances { default_config().use_relative_e_distances.value }
float m_position [NUM_AXES]
bool m_verbose
bool m_parsing { false }

Detailed Description

Member Typedef Documentation

◆ callback_t

typedef std::function<void(GCodeReader&, const GCodeLine&)> Slic3r::GCodeReader::callback_t

◆ raw_line_callback_t

typedef std::function<void(GCodeReader&, const char*, const char*)> Slic3r::GCodeReader::raw_line_callback_t

Constructor & Destructor Documentation

◆ GCodeReader()

Slic3r::GCodeReader::GCodeReader ( )
inline
112: m_verbose(false) { this->reset(); }
bool m_verbose
Definition GCodeReader.hpp:210
void reset()
Definition GCodeReader.hpp:113

References m_verbose, and reset().

Referenced by parse_buffer().

Here is the call graph for this function:
Here is the caller graph for this function:

Member Function Documentation

◆ apply_config() [1/2]

void Slic3r::GCodeReader::apply_config ( const DynamicPrintConfig & config)
46{
47 auto applied = std::make_shared<GCodeConfig>(m_config ? *m_config : default_config());
48 applied->apply(config, true);
49 m_use_relative_e_distances = applied->use_relative_e_distances.value;
50 m_config = std::move(applied);
51}
std::shared_ptr< const GCodeConfig > m_config
Definition GCodeReader.hpp:207
bool m_use_relative_e_distances
Definition GCodeReader.hpp:208
const GCodeConfig & config()
Definition GCodeReader.hpp:116
static const GCodeConfig & default_config()
Definition GCodeReader.cpp:33

References config(), default_config(), m_config, and m_use_relative_e_distances.

Here is the call graph for this function:

◆ apply_config() [2/2]

void Slic3r::GCodeReader::apply_config ( const GCodeConfig & config)
40{
41 m_config = std::make_shared<const GCodeConfig>(config);
42 m_use_relative_e_distances = config.use_relative_e_distances.value;
43}

References config(), Slic3r::GCodeConfig, m_config, and m_use_relative_e_distances.

Here is the call graph for this function:

◆ axis_pos()

const char * Slic3r::GCodeReader::axis_pos ( const char * raw_str,
char axis )
staticprivate
250{
251 const char *c = raw_str;
252 // Skip the whitespaces.
253 c = skip_whitespaces(c);
254 // Skip the command.
255 c = skip_word(c);
256 // Up to the end of line or comment.
257 while (! is_end_of_gcode_line(*c)) {
258 // Skip whitespaces.
259 c = skip_whitespaces(c);
260 if (is_end_of_gcode_line(*c))
261 break;
262 // Check the name of the axis.
263 if (*c == axis)
264 return c;
265 // Skip the rest of the word.
266 c = skip_word(c);
267 }
268 return nullptr;
269}
static bool is_end_of_gcode_line(char c)
Definition GCodeReader.hpp:191
static const char * skip_word(const char *c)
Definition GCodeReader.hpp:198
static const char * skip_whitespaces(const char *c)
Definition GCodeReader.hpp:193

References is_end_of_gcode_line(), skip_whitespaces(), and skip_word().

Referenced by Slic3r::GCodeReader::GCodeLine::axis_pos().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ config()

const GCodeConfig & Slic3r::GCodeReader::config ( )
inline
116{ return m_config ? *m_config : default_config(); };

References default_config(), Slic3r::GCodeConfig, and m_config.

Referenced by apply_config(), apply_config(), and default_config().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ default_config()

const GCodeConfig & Slic3r::GCodeReader::default_config ( )
staticprivate
34{
35 static const GCodeConfig config;
36 return config;
37}
zaa_minimize_perimeter_height GCodeConfig
Definition PrintConfig.hpp:1951

References config(), and Slic3r::GCodeConfig.

Referenced by apply_config(), config(), and get_config().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ e() [1/2]

float & Slic3r::GCodeReader::e ( )
inline
165{ return m_position[E]; }
float m_position[NUM_AXES]
Definition GCodeReader.hpp:209
@ E
Definition libslic3r.h:144

References Slic3r::E, and m_position.

Referenced by Slic3r::FanMover::_process_gcode_line(), Slic3r::GCodeReader::GCodeLine::dist_E(), and Slic3r::GCodeReader::GCodeLine::new_E().

Here is the caller graph for this function:

◆ e() [2/2]

float Slic3r::GCodeReader::e ( ) const
inline
166{ return m_position[E]; }

References Slic3r::E, and m_position.

◆ f() [1/2]

float & Slic3r::GCodeReader::f ( )
inline
167{ return m_position[F]; }
@ F
Definition libslic3r.h:145

References Slic3r::F, and m_position.

Referenced by Slic3r::GCodeReader::GCodeLine::new_F().

Here is the caller graph for this function:

◆ f() [2/2]

float Slic3r::GCodeReader::f ( ) const
inline
168{ return m_position[F]; }

References Slic3r::F, and m_position.

◆ get_config()

GCodeConfig Slic3r::GCodeReader::get_config ( ) const
inline
176 {
177 return m_config ? *m_config : default_config();
178 }

References default_config(), Slic3r::GCodeConfig, and m_config.

Here is the call graph for this function:

◆ i() [1/2]

float & Slic3r::GCodeReader::i ( )
inline
170{ return m_position[I]; }
@ I
Definition libslic3r.h:147

References Slic3r::I, and m_position.

Referenced by update_coordinates().

Here is the caller graph for this function:

◆ i() [2/2]

float Slic3r::GCodeReader::i ( ) const
inline
171{ return m_position[I]; }

References Slic3r::I, and m_position.

◆ is_end_of_gcode_line()

bool Slic3r::GCodeReader::is_end_of_gcode_line ( char c)
inlinestaticprivate
191{ return c == ';' || is_end_of_line(c); }
static bool is_end_of_line(char c)
Definition GCodeReader.hpp:190

References is_end_of_line().

Referenced by axis_pos(), Slic3r::GCodeReader::GCodeLine::has(), Slic3r::GCodeReader::GCodeLine::has_value(), is_end_of_word(), and parse_line_internal().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ is_end_of_line()

bool Slic3r::GCodeReader::is_end_of_line ( char c)
inlinestaticprivate
190{ return c == '\r' || c == '\n' || c == 0; }

Referenced by is_end_of_gcode_line(), and parse_line_internal().

Here is the caller graph for this function:

◆ is_end_of_word()

bool Slic3r::GCodeReader::is_end_of_word ( char c)
inlinestaticprivate
192{ return is_whitespace(c) || is_end_of_gcode_line(c); }
static bool is_whitespace(char c)
Definition GCodeReader.hpp:189

References is_end_of_gcode_line(), and is_whitespace().

Referenced by Slic3r::GCodeReader::GCodeLine::cmd_is(), Slic3r::GCodeReader::GCodeLine::has_value(), Slic3r::GCodeReader::GCodeLine::has_value(), parse_line_internal(), and skip_word().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ is_whitespace()

bool Slic3r::GCodeReader::is_whitespace ( char c)
inlinestaticprivate
189{ return c == ' ' || c == '\t'; }

Referenced by is_end_of_word(), and skip_whitespaces().

Here is the caller graph for this function:

◆ j() [1/2]

float & Slic3r::GCodeReader::j ( )
inline
172{ return m_position[J]; }
@ J
Definition libslic3r.h:148

References Slic3r::J, and m_position.

◆ j() [2/2]

float Slic3r::GCodeReader::j ( ) const
inline
173{ return m_position[J]; }

References Slic3r::J, and m_position.

◆ parse_buffer() [1/2]

void Slic3r::GCodeReader::parse_buffer ( const std::string & buffer)
inline
132 { this->parse_buffer(buffer, [](GCodeReader&, const GCodeReader::GCodeLine&){}); }
void parse_buffer(const std::string &buffer, Callback callback)
Definition GCodeReader.hpp:119
GCodeReader()
Definition GCodeReader.hpp:112

References GCodeReader(), and parse_buffer().

Here is the call graph for this function:

◆ parse_buffer() [2/2]

template<typename Callback>
void Slic3r::GCodeReader::parse_buffer ( const std::string & buffer,
Callback callback )
inline
120 {
121 const char *ptr = buffer.c_str();
122 const char *end = ptr + buffer.size();
123 GCodeLine gline;
124 m_parsing = true;
125 while (m_parsing && *ptr != 0) {
126 gline.reset();
127 ptr = this->parse_line(ptr, end, gline, callback);
128 }
129 }
Definition GCodeReader.hpp:21
const char * parse_line(const char *ptr, const char *end, GCodeLine &gline, Callback &callback)
Definition GCodeReader.hpp:135
bool m_parsing
Definition GCodeReader.hpp:212
T * end(Slic3r::Mat< N, M, T > &mat)
Definition Point.hpp:841

References m_parsing, parse_line(), and Slic3r::GCodeReader::GCodeLine::reset().

Referenced by Slic3r::GCodeProcessor::contains_reserved_tag(), Slic3r::GCodeProcessor::contains_reserved_tags(), Slic3r::custom_gcode_motion_state_changes(), Slic3r::anonymous_namespace{GCode.cpp}::emitted_xy_after_gcode(), parse_buffer(), and Slic3r::SpiralVase::process_layer().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ parse_file() [1/2]

bool Slic3r::GCodeReader::parse_file ( const std::string & file,
callback_t callback )
224{
225 BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(": before parse_file %1%") % file.c_str();
226 auto ret = this->parse_file_internal(file, callback, [](size_t) {});
227 BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(": finished parse_file %1%") % file.c_str();
228
229 return ret;
230}
bool parse_file_internal(const std::string &filename, ParseLineCallback parse_line_callback, LineEndCallback line_end_callback)
Definition GCodeReader.cpp:206

References parse_file_internal().

Here is the call graph for this function:

◆ parse_file() [2/2]

bool Slic3r::GCodeReader::parse_file ( const std::string & file,
callback_t callback,
std::vector< size_t > & lines_ends )
233{
234 lines_ends.clear();
235 BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(": before parse_file %1%") % file.c_str();
236 auto ret = this->parse_file_internal(file, callback, [&lines_ends](size_t file_pos){ lines_ends.emplace_back(file_pos); });
237 BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(": finished parse_file %1%") % file.c_str();
238
239 return ret;
240}

References parse_file_internal().

Here is the call graph for this function:

◆ parse_file_internal()

template<typename ParseLineCallback, typename LineEndCallback>
bool Slic3r::GCodeReader::parse_file_internal ( const std::string & filename,
ParseLineCallback parse_line_callback,
LineEndCallback line_end_callback )
private
207{
208 GCodeLine gline;
209 return this->parse_file_raw_internal(filename,
210 [this, &gline, parse_line_callback](const char *begin, const char *end) {
211 gline.reset();
212
213 const char* begin_new = begin;
214 begin_new = skip_whitespaces(begin_new);
215 if (std::toupper(*begin_new) == 'N')
216 begin_new = skip_word(begin_new);
217 begin_new = skip_whitespaces(begin_new);
218 this->parse_line(begin_new, end, gline, parse_line_callback);
219 },
220 line_end_callback);
221}
bool parse_file_raw_internal(const std::string &filename, ParseLineCallback parse_line_callback, LineEndCallback line_end_callback)
Definition GCodeReader.cpp:150
T * begin(Slic3r::Mat< N, M, T > &mat)
Definition Point.hpp:838

References parse_file_raw_internal(), parse_line(), Slic3r::GCodeReader::GCodeLine::reset(), skip_whitespaces(), and skip_word().

Referenced by parse_file(), and parse_file().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ parse_file_raw()

bool Slic3r::GCodeReader::parse_file_raw ( const std::string & file,
raw_line_callback_t callback )
243{
244 return this->parse_file_raw_internal(filename,
245 [this, line_callback](const char *begin, const char *end) { line_callback(*this, begin, end); },
246 [](size_t){});
247}

References parse_file_raw_internal().

Here is the call graph for this function:

◆ parse_file_raw_internal()

template<typename ParseLineCallback, typename LineEndCallback>
bool Slic3r::GCodeReader::parse_file_raw_internal ( const std::string & filename,
ParseLineCallback parse_line_callback,
LineEndCallback line_end_callback )
private
151{
152 FilePtr in{ boost::nowide::fopen(filename.c_str(), "rb") };
153
154 // Read the input stream 64kB at a time, extract lines and process them.
155 std::vector<char> buffer(65536 * 10, 0);
156 // Line buffer.
157 std::string gcode_line;
158 size_t file_pos = 0;
159 m_parsing = true;
160 for (;;) {
161 size_t cnt_read = ::fread(buffer.data(), 1, buffer.size(), in.f);
162 if (::ferror(in.f))
163 return false;
164 bool eof = cnt_read == 0;
165 auto it = buffer.begin();
166 auto it_bufend = buffer.begin() + cnt_read;
167 while (it != it_bufend || (eof && ! gcode_line.empty())) {
168 // Find end of line.
169 bool eol = false;
170 auto it_end = it;
171 for (; it_end != it_bufend && ! (eol = *it_end == '\r' || *it_end == '\n'); ++ it_end)
172 if (*it_end == '\n')
173 line_end_callback(file_pos + (it_end - buffer.begin()) + 1);
174 // End of line is indicated also if end of file was reached.
175 eol |= eof && it_end == it_bufend;
176 if (eol) {
177 if (gcode_line.empty())
178 parse_line_callback(&(*it), &(*it_end));
179 else {
180 gcode_line.insert(gcode_line.end(), it, it_end);
181 parse_line_callback(gcode_line.c_str(), gcode_line.c_str() + gcode_line.size());
182 gcode_line.clear();
183 }
184 if (! m_parsing)
185 // The callback wishes to exit.
186 return true;
187 } else
188 gcode_line.insert(gcode_line.end(), it, it_end);
189 // Skip EOL.
190 it = it_end;
191 if (it != it_bufend && *it == '\r')
192 ++ it;
193 if (it != it_bufend && *it == '\n') {
194 line_end_callback(file_pos + (it - buffer.begin()) + 1);
195 ++ it;
196 }
197 }
198 if (eof)
199 break;
200 file_pos += cnt_read;
201 }
202 return true;
203}

References Slic3r::FilePtr::f, and m_parsing.

Referenced by parse_file_internal(), and parse_file_raw().

Here is the caller graph for this function:

◆ parse_line() [1/2]

template<typename Callback>
const char * Slic3r::GCodeReader::parse_line ( const char * ptr,
const char * end,
GCodeLine & gline,
Callback & callback )
inline
136 {
137 std::pair<const char*, const char*> cmd;
138 const char *line_end = parse_line_internal(ptr, end, gline, cmd);
139 callback(*this, gline);
140 update_coordinates(gline, cmd);
141 return line_end;
142 }
void update_coordinates(GCodeLine &gline, std::pair< const char *, const char * > &command)
Definition GCodeReader.cpp:134
const char * parse_line_internal(const char *ptr, const char *end, GCodeLine &gline, std::pair< const char *, const char * > &command)
Definition GCodeReader.cpp:53

References parse_line_internal(), and update_coordinates().

Referenced by parse_buffer(), parse_file_internal(), parse_line(), Slic3r::GCodeProcessor::process_G28(), Slic3r::GCodeProcessor::process_gcode_line(), and Slic3r::GCodeProcessor::run_post_process().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ parse_line() [2/2]

template<typename Callback>
void Slic3r::GCodeReader::parse_line ( const std::string & line,
Callback callback )
inline
146 { GCodeLine gline; this->parse_line(line.c_str(), line.c_str() + line.size(), gline, callback); }

References parse_line().

Here is the call graph for this function:

◆ parse_line_internal()

const char * Slic3r::GCodeReader::parse_line_internal ( const char * ptr,
const char * end,
GCodeLine & gline,
std::pair< const char *, const char * > & command )
private
54{
55 PROFILE_FUNC();
56
58
59 // command and args
60 const char *c = ptr;
61 {
62 PROFILE_BLOCK(command_and_args);
63 // Skip the whitespaces.
64 command.first = skip_whitespaces(c);
65 // Skip the command.
66 c = command.second = skip_word(command.first);
67 // Up to the end of line or comment.
68 while (! is_end_of_gcode_line(*c)) {
69 // Skip whitespaces.
70 c = skip_whitespaces(c);
72 break;
73 // Check the name of the axis.
75 switch (*c) {
76 case 'X': axis = X; break;
77 case 'Y': axis = Y; break;
78 case 'Z': axis = Z; break;
79 case 'F': axis = F; break;
80 //BBS: add I and J axis
81 case 'I': axis = I; break;
82 case 'J': axis = J; break;
83 case 'E': axis = E; break;
84 case 'P': axis = P; break;
85 default:
86 if (*c >= 'A' && *c <= 'Z')
87 // Unknown axis, but we still want to remember that such a axis was seen.
88 axis = UNKNOWN_AXIS;
89 break;
90 }
91 if (axis != NUM_AXES_WITH_UNKNOWN) {
92 // Try to parse the numeric value.
93 double v;
94 auto [pend, ec] = fast_float::from_chars(++ c, end, v);
95 if (pend != c && is_end_of_word(*pend)) {
96 // The axis value has been parsed correctly.
97 if (axis != UNKNOWN_AXIS)
98 gline.m_axis[int(axis)] = v;
99 gline.m_mask |= 1 << int(axis);
100 c = pend;
101 } else
102 // Skip the rest of the word.
103 c = skip_word(c);
104 } else
105 // Skip the rest of the word.
106 c = skip_word(c);
107 }
108 }
109
110 if (gline.has(E) && m_use_relative_e_distances)
111 m_position[E] = 0;
112
113 // Skip the rest of the line.
114 for (; ! is_end_of_line(*c); ++ c);
115
116 // Copy the raw string including the comment, without the trailing newlines.
117 if (c > ptr) {
118 PROFILE_BLOCK(copy_raw_string);
119 gline.m_raw.assign(ptr, c);
120 }
121
122 // Skip the trailing newlines.
123 if (*c == '\r')
124 ++ c;
125 if (*c == '\n')
126 ++ c;
127
128 if (m_verbose)
129 std::cout << gline.m_raw << std::endl;
130
131 return c;
132}
static bool is_end_of_word(char c)
Definition GCodeReader.hpp:192
bool is_decimal_separator_point()
Definition LocalesUtils.cpp:78
Axis
Definition libslic3r.h:140
@ Y
Definition libslic3r.h:142
@ Z
Definition libslic3r.h:143
@ NUM_AXES_WITH_UNKNOWN
Definition libslic3r.h:153
@ P
Definition libslic3r.h:149
@ UNKNOWN_AXIS
Definition libslic3r.h:152
@ X
Definition libslic3r.h:141

References Slic3r::E, Slic3r::F, Slic3r::GCodeReader::GCodeLine::has(), Slic3r::I, Slic3r::is_decimal_separator_point(), is_end_of_gcode_line(), is_end_of_line(), is_end_of_word(), Slic3r::J, Slic3r::GCodeReader::GCodeLine::m_axis, Slic3r::GCodeReader::GCodeLine::m_mask, m_position, Slic3r::GCodeReader::GCodeLine::m_raw, m_use_relative_e_distances, m_verbose, Slic3r::NUM_AXES_WITH_UNKNOWN, Slic3r::P, skip_whitespaces(), skip_word(), Slic3r::UNKNOWN_AXIS, Slic3r::X, Slic3r::Y, and Slic3r::Z.

Referenced by parse_line().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ quit_parsing()

void Slic3r::GCodeReader::quit_parsing ( )
inline
157{ m_parsing = false; }

References m_parsing.

Referenced by Slic3r::GCodeProcessor::apply_config_simplify3d(), Slic3r::GCodeProcessor::contains_reserved_tag(), Slic3r::GCodeProcessor::contains_reserved_tags(), and Slic3r::custom_gcode_motion_state_changes().

Here is the caller graph for this function:

◆ reset()

void Slic3r::GCodeReader::reset ( )
inline
113{ memset(m_position, 0, sizeof(m_position)); }

References m_position.

Referenced by GCodeReader().

Here is the caller graph for this function:

◆ skip_whitespaces()

const char * Slic3r::GCodeReader::skip_whitespaces ( const char * c)
inlinestaticprivate
193 {
194 for (; is_whitespace(*c); ++ c)
195 ; // silence -Wempty-body
196 return c;
197 }

References is_whitespace().

Referenced by axis_pos(), Slic3r::GCodeReader::GCodeLine::cmd(), Slic3r::GCodeReader::GCodeLine::cmd_is(), Slic3r::GCodeReader::GCodeLine::cmd_starts_with(), Slic3r::GCodeReader::GCodeLine::has(), Slic3r::GCodeReader::GCodeLine::has_value(), parse_file_internal(), and parse_line_internal().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ skip_word()

const char * Slic3r::GCodeReader::skip_word ( const char * c)
inlinestaticprivate
198 {
199 for (; ! is_end_of_word(*c); ++ c)
200 ; // silence -Wempty-body
201 return c;
202 }

References is_end_of_word().

Referenced by axis_pos(), Slic3r::GCodeReader::GCodeLine::cmd(), Slic3r::GCodeReader::GCodeLine::has(), Slic3r::GCodeReader::GCodeLine::has_value(), parse_file_internal(), and parse_line_internal().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ update_coordinates()

void Slic3r::GCodeReader::update_coordinates ( GCodeLine & gline,
std::pair< const char *, const char * > & command )
private
135{
136 PROFILE_FUNC();
137 if (*command.first == 'G') {
138 int cmd_len = int(command.second - command.first);
139 //BBS: add support of G2 and G3
140 if ((cmd_len == 2 && (command.first[1] == '0' || command.first[1] == '1' || command.first[1] == '2' || command.first[1] == '3')) ||
141 (cmd_len == 3 && command.first[1] == '9' && command.first[2] == '2')) {
142 for (size_t i = 0; i < NUM_AXES; ++ i)
143 if (gline.has(Axis(i)))
144 m_position[i] = gline.value(Axis(i));
145 }
146 }
147}
float & i()
Definition GCodeReader.hpp:170
@ NUM_AXES
Definition libslic3r.h:150

References Slic3r::GCodeReader::GCodeLine::has(), i(), m_position, Slic3r::NUM_AXES, and Slic3r::GCodeReader::GCodeLine::value().

Referenced by parse_line().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ x() [1/2]

float & Slic3r::GCodeReader::x ( )
inline
159{ return m_position[X]; }

References m_position, and Slic3r::X.

Referenced by Slic3r::FanMover::_process_gcode_line(), Slic3r::GCodeReader::GCodeLine::dist_X(), Slic3r::GCodeReader::GCodeLine::dist_XY(), and Slic3r::GCodeReader::GCodeLine::new_X().

Here is the caller graph for this function:

◆ x() [2/2]

float Slic3r::GCodeReader::x ( ) const
inline
160{ return m_position[X]; }

References m_position, and Slic3r::X.

◆ y() [1/2]

float & Slic3r::GCodeReader::y ( )
inline
161{ return m_position[Y]; }

References m_position, and Slic3r::Y.

Referenced by Slic3r::FanMover::_process_gcode_line(), Slic3r::GCodeReader::GCodeLine::dist_XY(), Slic3r::GCodeReader::GCodeLine::dist_Y(), and Slic3r::GCodeReader::GCodeLine::new_Y().

Here is the caller graph for this function:

◆ y() [2/2]

float Slic3r::GCodeReader::y ( ) const
inline
162{ return m_position[Y]; }

References m_position, and Slic3r::Y.

◆ z() [1/2]

float & Slic3r::GCodeReader::z ( )
inline
163{ return m_position[Z]; }

References m_position, and Slic3r::Z.

Referenced by Slic3r::FanMover::_process_gcode_line(), Slic3r::GCodeReader::GCodeLine::dist_Z(), and Slic3r::GCodeReader::GCodeLine::new_Z().

Here is the caller graph for this function:

◆ z() [2/2]

float Slic3r::GCodeReader::z ( ) const
inline
164{ return m_position[Z]; }

References m_position, and Slic3r::Z.

Member Data Documentation

◆ m_config

std::shared_ptr<const GCodeConfig> Slic3r::GCodeReader::m_config
private

◆ m_parsing

bool Slic3r::GCodeReader::m_parsing { false }
private
212{ false };

Referenced by parse_buffer(), parse_file_raw_internal(), and quit_parsing().

◆ m_position

float Slic3r::GCodeReader::m_position[NUM_AXES]
private

◆ m_use_relative_e_distances

bool Slic3r::GCodeReader::m_use_relative_e_distances { default_config().use_relative_e_distances.value }
private
208{ default_config().use_relative_e_distances.value };

Referenced by apply_config(), apply_config(), and parse_line_internal().

◆ m_verbose

bool Slic3r::GCodeReader::m_verbose
private

Referenced by GCodeReader(), and parse_line_internal().


The documentation for this class was generated from the following files: