libvcad_compilers — compiler classes

class CompilerBase
#include <compiler_base.h>

Subclassed by ColorInkjetCompiler, MaterialInkjetCompiler, SlicerProjectCompiler

Public Functions

void cancel()
virtual void compile() = 0
CompilerBase() = default
void set_progress_callback(const std::function<void(double)> &progress_callback)
virtual std::vector<std::string> supported_attributes() const = 0
virtual ~CompilerBase() = default

Protected Functions

bool is_cancelled() const
void report_progress(double progress)
void reset_cancel()
void throw_if_cancelled() const
void validate_attributes(const std::shared_ptr<Node> &root) const

Protected Attributes

std::atomic<bool> m_cancelled = {false}
std::function<void(double)> m_progress_callback = nullptr
class MaterialInkjetCompiler : public CompilerBase
#include <material_inkjet_compiler.h>

Public Functions

virtual void compile() override
std::unordered_map<uint8_t, size_t> material_voxel_counts() const
MaterialInkjetCompiler(const std::shared_ptr<Node> &root, glm::vec3 voxel_size, const std::string &output_directory, const std::string &file_prefix, const std::shared_ptr<MaterialDefs> &material_defs, double liquid_keep_out_distance = 0.0)
std::tuple<size_t, size_t, size_t> resolution() const
void set_fallback_material_id(uint8_t material_id)

Sets the fallback material ID used for voxels where VOLUME_FRACTIONS is undefined.

Only used when strict mode is off.

Parameters:

material_id – The fallback material ID (default is 0, the void material).

void set_strict_mode(bool strict)

Enables or disables strict mode.

When strict mode is on, the compiler throws a std::runtime_error if any inside voxel is missing the required VOLUME_FRACTIONS attribute. When off (default), the fallback material is used instead.

virtual std::vector<std::string> supported_attributes() const override

Private Members

uint8_t m_fallback_material_id = 0
std::string m_file_prefix
double m_liquid_keep_out_distance
std::shared_ptr<MaterialDefs> m_material_defs
std::unordered_map<uint8_t, size_t> m_material_voxel_counts
std::string m_output_directory
std::shared_ptr<Node> m_root
bool m_strict_mode = false
glm::vec3 m_voxel_size
size_t m_x_resolution = 0
size_t m_y_resolution = 0
size_t m_z_resolution = 0
class ColorInkjetCompiler : public CompilerBase
#include <color_inkjet_compiler.h>

Public Functions

ColorInkjetCompiler(const std::shared_ptr<Node> &root, glm::vec3 voxel_size, const std::string &output_directory, const std::string &file_prefix, const std::string &icc_profile = "default")
virtual void compile() override
std::tuple<size_t, size_t, size_t> resolution() const
void set_fallback_color(glm::vec4 color)

Sets the fallback RGBA color used for voxels where COLOR_RGBA is undefined.

Each component is in [0, 1]. Only used when strict mode is off.

Parameters:

color – The fallback sRGBA color (default is fully transparent: 0,0,0,0).

void set_strict_mode(bool strict)

Enables or disables strict mode.

When strict mode is on, the compiler throws a std::runtime_error if any inside voxel is missing the required COLOR_RGBA attribute. When off (default), the fallback color is used instead.

virtual std::vector<std::string> supported_attributes() const override

Private Members

glm::vec4 m_fallback_color = glm::vec4(0.0f, 0.0f, 0.0f, 0.0f)
std::string m_file_prefix
std::string m_icc_profile
std::string m_output_directory
std::shared_ptr<Node> m_root
bool m_strict_mode = false
glm::vec3 m_voxel_size
size_t m_x_resolution = 0
size_t m_y_resolution = 0
size_t m_z_resolution = 0
class SlicerProjectCompiler : public CompilerBase
#include <slicer_project_compiler.h>

Public Functions

virtual void compile() override
SlicerProjectCompiler(const std::shared_ptr<Node> &root, glm::vec3 voxel_size, const std::string &output_file_path, const std::string &printer_profile_path, const std::string &filament_profile_path, size_t num_regions = 10, const std::vector<std::string> &ignored_attributes = {})
inline virtual std::vector<std::string> supported_attributes() const override

Private Functions

size_t add_extruder(int temperature, int flow_rate)
void add_setting_entry_to_xml(pugi::xml_node &parent_node, const std::string &attribute, double min_value, double max_value, size_t num_steps, const std::unordered_map<std::string, std::pair<double, double>> &min_max_map)
std::unordered_map<std::string, std::pair<double, double>> compute_attribute_ranges(const std::unordered_map<std::string, bool> &attribute_type_map)
vtkSmartPointer<vtkImageData> compute_filtered_image_data(const std::unordered_map<std::string, std::pair<double, double>> &attribute_ranges_map, const std::unordered_map<std::string, bool> &attribute_type_map)

Private Members

std::vector<std::pair<int, int>> m_extruders
std::string m_filament_profile_path
std::vector<std::string> m_ignored_attributes
glm::vec3 m_max_coord
glm::vec3 m_min_coord
size_t m_num_regions
std::string m_output_file_path
std::string m_printer_profile_path
std::shared_ptr<Node> m_root
std::vector<std::pair<std::optional<double>, std::optional<AttributeSamples>>> m_sample_array
size_t m_size_x
size_t m_size_y
size_t m_size_z
glm::vec3 m_voxel_size

Private Static Functions

static std::unordered_map<std::string, bool> compute_attribute_type_map(const std::vector<std::string> &attributes)