#pragma once #include #include #include #include "heightmap.h" namespace grbl { enum class instruction_type { gcode, comment, user_message }; struct instruction { static instruction new_gcode(size_t line, std::string cmd, std::string comment = ""); static instruction new_user_message(size_t line, std::string comment = ""); static instruction new_comment(size_t line, std::string comment = ""); size_t line = 0; instruction_type type = instruction_type::comment; std::string command; std::string comment; }; struct program { program() = default; explicit program(std::string filename); bool load_from_file(std::string filename); bool load_from_stream(std::istream& in); bool load_from_string(const std::string& content); bool load_from_lines(std::vector lines); void dump(std::ostream& out); size_t number_of_instructions() const { return instructions.size(); } instruction instruction_at(size_t index) { return instructions.at(index); } bool is_loaded = false; std::string filename; std::vector instructions{}; grbl::program apply_heightmap(grbl::heightmap& grid); void save(std::string path); }; }