libslic3r
Library for generating gcode from 3d models
|
#include <Model.hpp>
Public Member Functions | |
Model () | |
Model constructor. More... | |
Model (const Model &other) | |
Model & | operator= (Model other) |
void | swap (Model &other) |
~Model () | |
Model destructor. More... | |
ModelObject * | add_object () |
ModelObject * | add_object (const ModelObject &other, bool copy_volumes=true) |
void | delete_object (size_t idx) |
void | clear_objects () |
Delete all ModelObjects found in the current Model. More... | |
ModelMaterial * | add_material (t_model_material_id material_id) |
ModelMaterial * | add_material (t_model_material_id material_id, const ModelMaterial &other) |
ModelMaterial * | get_material (t_model_material_id material_id) |
void | delete_material (t_model_material_id material_id) |
void | clear_materials () |
Delete all the ModelMaterial objects found in the current Model. More... | |
bool | has_objects_with_no_instances () const |
bool | add_default_instances () |
BoundingBoxf3 | bounding_box () const |
void | repair () |
void | center_instances_around_point (const Pointf &point) |
void | align_instances_to_origin () |
void | translate (coordf_t x, coordf_t y, coordf_t z) |
TriangleMesh | mesh () const |
TriangleMesh | raw_mesh () const |
bool | _arrange (const Pointfs &sizes, coordf_t dist, const BoundingBoxf *bb, Pointfs &out) const |
bool | arrange_objects (coordf_t dist, const BoundingBoxf *bb=NULL) |
void | duplicate (size_t copies_num, coordf_t dist, const BoundingBoxf *bb=NULL) |
void | duplicate_objects (size_t copies_num, coordf_t dist, const BoundingBoxf *bb=NULL) |
void | duplicate_objects_grid (size_t x, size_t y, coordf_t dist) |
void | print_info () const |
This function calls the print_info() function of each ModelObject. More... | |
bool | looks_like_multipart_object () const |
void | convert_multipart_object () |
Take all of the ModelObjects in the current Model and combines them into a single ModelObject. More... | |
Static Public Member Functions | |
static Model | read_from_file (std::string input_file) |
Public Attributes | |
ModelMaterialMap | materials |
ModelObjectPtrs | objects |
std::map< std::string, std::string > | metadata |
Model metadata <name, value>, this is needed for 3MF format read/write. More... | |
Model Class representing the print bed content Description of a triangular model with multiple materials, multiple instances with various affine transformations and with multiple modifier meshes. A model groups multiple objects, each object having possibly multiple instances, all objects may share multiple materials.
Slic3r::Model::Model | ( | ) |
Model constructor.
Slic3r::Model::Model | ( | const Model & | other | ) |
Slic3r::Model::~Model | ( | ) |
Model destructor.
bool Slic3r::Model::_arrange | ( | const Pointfs & | sizes, |
coordf_t | dist, | ||
const BoundingBoxf * | bb, | ||
Pointfs & | out | ||
) | const |
Arrange ModelInstances. ModelInstances of the same ModelObject do not preserve their relative positions. It uses the given BoundingBoxf as a hint, but falls back to free arrangement if it's not possible to fit all the parts in it.
sizes | Pointfs& number of parts |
dist | coordf_t distance between cells |
bb | BoundingBoxf* (optional) pointer to the bounding box of the area to fill |
out | Pointfs& vector of the output positions |
bool Slic3r::Model::add_default_instances | ( | ) |
Add a new ModelInstance to each ModelObject having no ModelInstance objects
ModelMaterial * Slic3r::Model::add_material | ( | t_model_material_id | material_id | ) |
Add a new ModelMaterial to the model.
material_id | t_model_material_id the id of the new ModelMaterial to be added |
ModelMaterial * Slic3r::Model::add_material | ( | t_model_material_id | material_id, |
const ModelMaterial & | other | ||
) |
Add a new ModelMaterial to the current Model. This function copies another ModelMaterial, It also delete the current ModelMaterial carrying the same material id in the map.
material_id | t_model_material_id the id of the new ModelMaterial to be added |
other | ModelMaterial the model material to be copied |
ModelObject * Slic3r::Model::add_object | ( | ) |
ModelObject * Slic3r::Model::add_object | ( | const ModelObject & | other, |
bool | copy_volumes = true |
||
) |
Create a new object and add it to the current Model. This function copies another model object
other | ModelObject the ModelObject to be copied |
copy_volumes | if you also want to copy volumes of the other object. By default = true |
void Slic3r::Model::align_instances_to_origin | ( | ) |
bool Slic3r::Model::arrange_objects | ( | coordf_t | dist, |
const BoundingBoxf * | bb = NULL |
||
) |
Arrange ModelObjects preserving their ModelInstance count but altering their ModelInstance positions.
dist | coordf_t distance between cells |
bb | BoundingBoxf* (optional) pointer to the bounding box of the area to fill |
BoundingBoxf3 Slic3r::Model::bounding_box | ( | ) | const |
Get the bounding box of the transformed instances.
void Slic3r::Model::center_instances_around_point | ( | const Pointf & | point | ) |
Center the total bounding box of the instances around a point. This transformation works in the XY plane only and no transformation in Z is performed.
point | pointf object to center the model instances of model objects around |
void Slic3r::Model::clear_materials | ( | ) |
Delete all the ModelMaterial objects found in the current Model.
void Slic3r::Model::clear_objects | ( | ) |
Delete all ModelObjects found in the current Model.
void Slic3r::Model::convert_multipart_object | ( | ) |
Take all of the ModelObjects in the current Model and combines them into a single ModelObject.
void Slic3r::Model::delete_material | ( | t_model_material_id | material_id | ) |
Delete a ModelMaterial carrying a certain material id if found.
material_id | t_model_material_id the id of the ModelMaterial to be deleted |
void Slic3r::Model::delete_object | ( | size_t | idx | ) |
Delete a ModelObject from the current Model.
idx | size_t the index of the desired ModelObject |
void Slic3r::Model::duplicate | ( | size_t | copies_num, |
coordf_t | dist, | ||
const BoundingBoxf * | bb = NULL |
||
) |
Duplicate the ModelInstances of each ModelObject as a whole preserving their relative positions. This function croaks if the duplicated objects do not fit the print bed.
copies_num | size_t number of copies |
dist | coordf_t distance between cells |
bb | BoundingBoxf* (optional) pointer to the bounding box of the area to fill |
void Slic3r::Model::duplicate_objects | ( | size_t | copies_num, |
coordf_t | dist, | ||
const BoundingBoxf * | bb = NULL |
||
) |
Duplicate each entire ModelInstances of the each ModelObject as a whole. This function will append more instances to each object and then calls arrange_objects() function to automatically rearrange everything.
copies_num | size_t number of copies |
dist | coordf_t distance between cells |
bb | BoundingBoxf* (optional) pointer to the bounding box of the area to fill |
void Slic3r::Model::duplicate_objects_grid | ( | size_t | x, |
size_t | y, | ||
coordf_t | dist | ||
) |
Duplicate a single ModelObject and arranges them on a grid. Grid duplication is not supported with multiple objects. It throws an exception if there is more than one ModelObject. It also throws an exception if there are no ModelObjects in the current Model.
x | size_t number of duplicates in x direction |
y | size_t offset number of duplicates in y direction |
dist | coordf_t distance supposed to be between the duplicated ModelObjects |
ModelMaterial * Slic3r::Model::get_material | ( | t_model_material_id | material_id | ) |
Get the ModelMaterial object instance having a certain material id. Returns null if the ModelMaterial object instance is not found.
material_id | t_model_material_id the id of the needed ModelMaterial object instance |
bool Slic3r::Model::has_objects_with_no_instances | ( | ) | const |
Check if any ModelObject has no ModelInstances.
bool Slic3r::Model::looks_like_multipart_object | ( | ) | const |
Check to see if the current Model has characteristics of having multiple parts (usually multiple volumes, etc).
TriangleMesh Slic3r::Model::mesh | ( | ) | const |
Flatten all ModelInstances to a single mesh after performing instance transformations (if the object was rotated or translated).
void Slic3r::Model::print_info | ( | ) | const |
This function calls the print_info() function of each ModelObject.
TriangleMesh Slic3r::Model::raw_mesh | ( | ) | const |
Flatten all ModelVolumes to a single mesh without any extra processing (i.e. without applying any instance duplication and/or transformation).
|
static |
void Slic3r::Model::repair | ( | ) |
Repair the ModelObjects of the current Model. This function calls repair function on each TriangleMesh of each model object volume
void Slic3r::Model::swap | ( | Model & | other | ) |
Swap objects and materials with another model.
other | Model the model to be swapped with |
Translate each ModelObject with x, y, z units.
x | coordf_t units in the x direction |
y | coordf_t units in the y direction |
z | coordf_t units in the z direction |
ModelMaterialMap Slic3r::Model::materials |
Materials are owned by a model and referenced by objects through t_model_material_id. Single material may be shared by multiple models.
std::map<std::string, std::string> Slic3r::Model::metadata |
Model metadata <name, value>, this is needed for 3MF format read/write.
ModelObjectPtrs Slic3r::Model::objects |
Objects are owned by a model. Each object may have multiple instances , each instance having its own transformation (shift, scale, rotation).