Compilers — inkjet

class GCVFExporter
#include <gcvf_exporter.h>

Public Types

enum ProgressPhase

Values:

enumerator GENERATE_PNG_STACK
enumerator GENERATE_ZBUFFER
enumerator GENERATE_MESH
enumerator ZIP_FILES

Public Functions

void compile()
GCVFExporter(const std::shared_ptr<Node> &m_root, glm::vec3 voxel_size, const std::shared_ptr<MaterialDefs> &material_defs, const std::string &filename, bool liquid_keep_out, double liquid_keep_out_distance)
void setProgressCallback(const std::function<void(ProgressPhase, double)> &progress_callback)

Private Functions

void cleanup()
void generate_bbox_file()
void generate_png_stack()
void generate_stl()
void generate_xml_config()
void generate_zbuffer_image()
void prepare_temp_dir()
void zip_files()

Private Members

std::string m_filename
bool m_liquid_keep_out = false
double m_liquid_keep_out_distance = 0.0
std::shared_ptr<MaterialDefs> m_material_defs
std::unordered_map<uint8_t, size_t> m_material_voxel_counts
glm::vec3 m_max
glm::vec3 m_min
std::function<void(ProgressPhase, double)> m_progress_callback
std::shared_ptr<Node> m_root
size_t m_slice_thickness_nm = 27000
std::string m_temp_path = "temp_gcvf_export"
glm::vec3 m_voxel_size
size_t m_x_dpi = 600
size_t m_x_resolution
size_t m_y_dpi = 300
size_t m_y_resolution
size_t m_z_resolution
class DirectMaterialCompiler
#include <direct_material_compiler.h>

This class samples an OpenVCAD tree into a stack of images. This makes the assumption that the user is directly expressing the materials in the tree.

Public Functions

void compile()
DirectMaterialCompiler(const std::shared_ptr<Node> &m_root, glm::vec3 voxel_size, const std::shared_ptr<MaterialDefs> &material_defs, const std::string &output_directory, const std::string &file_prefix, bool liquid_keep_out, double liquid_keep_out_distance)
inline std::unordered_map<uint8_t, size_t> material_voxel_counts() const
inline std::tuple<size_t, size_t, size_t> resolution() const
void setProgressCallback(const std::function<void(double)> &progress_callback)

Private Functions

void remove_empty_images_from_beginning(std::vector<size_t> active_voxel_counts, const std::string &filename_root)
void remove_empty_images_from_end(std::vector<size_t> active_voxel_counts, const std::string &filename_root)

Private Members

const std::string m_file_prefix
bool m_liquid_keep_out = false
double m_liquid_keep_out_distance = 0.0
std::shared_ptr<MaterialDefs> m_material_defs
std::unordered_map<uint8_t, size_t> m_material_voxel_counts
glm::vec3 m_max
glm::vec3 m_min
const std::string m_output_directory
std::function<void(double)> m_progress_callback = nullptr
std::shared_ptr<Node> m_root
glm::vec3 m_voxel_size
size_t m_x_resolution
size_t m_y_resolution
size_t m_z_resolution

Variables

int MAX_IMAGE_WIDTH = 880
class MyersonCompiler
#include <myerson_compiler.h>

Public Functions

void compile()
MyersonCompiler(double layer_height, size_t x_dpi, size_t y_dpi, double taper_angle_deg, double extra_width, const std::string &output_path, const std::shared_ptr<Node> &root, const std::shared_ptr<MaterialDefs> &material_defs)

Constructor.

Parameters:
  • layer_height – Layer height in mm

  • x_dpi – X resolution in dots per inch

  • y_dpi – Y resolution in dots per inch

  • root – Root node of the OpenVCAD tree

  • material_defs – Material definitions

void setProgressCallback(const std::function<void(double)> &progress_callback)

Private Functions

std::vector<bool> centerImageData(const std::vector<bool> &data, int original_width, int original_height, int y_padding)
void write1BitBmpFile(const std::string &filename, int width, int height, const std::vector<bool> &data)

Private Members

double m_extra_width = 0.0
std::shared_ptr<MaterialDefs> m_material_defs
std::string m_output_path
std::function<void(double)> m_progress_callback = nullptr
std::shared_ptr<Node> m_root
double m_taper_angle_deg = 0.0
glm::vec3 m_voxel_size
class FullColorCompiler
#include <full_color_compiler.h>

Public Functions

void compile()
FullColorCompiler(const std::shared_ptr<Node> &m_root, vec3 voxel_size, const std::string &attribute_def_file_path, const std::string &output_directory, const std::string &file_prefix, const std::vector<glm::vec4> &color_palette, bool use_transparency)
void setProgressCallback(std::function<void(double)> &progress_callback)

Public Static Functions

static void ApplyCMYK(std::vector<std::vector<vec3>> &image, const std::vector<vec4> &palette_rgba)

Private Members

const std::string m_attribute_def_file_path
const std::vector<glm::vec4> m_color_palette
const std::string m_file_prefix
vec3 m_max
vec3 m_min
const std::string m_output_directory
std::function<void(double)> m_progress_callback = nullptr
std::shared_ptr<Node> m_root
bool m_use_transparency
vec3 m_voxel_size

Private Static Functions

static void ApplyTransparency(Node::ColorGridType::Ptr color_grid, Node::GridType::Ptr alpha_grid, glm::vec3 clear_color, glm::vec3 dims)

Given a color grid and alpha grid, apply transparency by mixing in a clear material.

Parameters:
  • color_grid – The color grid to apply transparency to

  • alpha_grid – The alpha grid to apply transparency to

  • palette – The color palette to apply transparency to

  • palette_alpha – The alpha values of the color palette

  • clear_color – The clear color to mix in

  • dims – The dimensions of the grid

static glm::vec4 RGBtoCMYK(const glm::vec3 &rgb)
static void SaveImage(const std::vector<unsigned char> &image, size_t height, size_t width, const std::string &filename)
static void SliceGridIntoPNGStack(Node::ColorGridType::Ptr color_grid, Node::GridType::Ptr alpha_grid, glm::vec3 dims, const std::string &filename_root)

Given a color and alpha grid, slice the grids into a stack of PNG images.

Parameters:
  • color_grid – The color grid to slice

  • alpha_grid – The alpha grid to slice

  • dims – The dimensions of the grid

  • filename_root – The filename template of the PNG stack