1
#ifndef slic3r_Model_hpp_
2
#define slic3r_Model_hpp_
5
#include "PrintConfig.hpp"
8
#include "TriangleMesh.hpp"
21
typedef std::string t_model_material_id;
22
typedef std::string t_model_material_attribute;
23
typedef std::map<t_model_material_attribute,std::string> t_model_material_attributes;
25
typedef std::map<t_model_material_id,ModelMaterial*> ModelMaterialMap;
26
typedef std::vector<ModelObject*> ModelObjectPtrs;
27
typedef std::vector<ModelVolume*> ModelVolumePtrs;
28
typedef std::vector<ModelInstance*> ModelInstancePtrs;
33
ModelMaterialMap materials;
34
ModelObjectPtrs objects;
37
Model(const Model &other);
38
Model& operator= (Model other);
39
void swap(Model &other);
41
ModelObject* add_object();
42
ModelObject* add_object(const ModelObject &other);
43
void delete_object(size_t idx);
46
ModelMaterial* add_material(t_model_material_id material_id);
47
ModelMaterial* add_material(t_model_material_id material_id, const ModelMaterial &other);
48
ModelMaterial* get_material(t_model_material_id material_id);
49
void delete_material(t_model_material_id material_id);
50
void clear_materials();
51
// void duplicate_objects_grid(unsigned int x, unsigned int y, coordf_t distance);
52
// void duplicate_objects(size_t copies_num, coordf_t distance, const BoundingBox &bb);
53
// void arrange_objects(coordf_t distance, const BoundingBox &bb);
54
// void duplicate(size_t copies_num, coordf_t distance, const BoundingBox &bb);
55
bool has_objects_with_no_instances() const;
56
// void bounding_box(BoundingBox* bb) const;
57
// void align_to_origin();
58
// void center_instances_around_point(const Pointf &point);
59
// void translate(coordf_t x, coordf_t y, coordf_t z);
60
// void mesh(TriangleMesh* mesh) const;
61
// void split_meshes();
62
// std::string get_material_name(t_model_material_id material_id);
66
void _arrange(const std::vector<Size> &sizes, coordf_t distance, const BoundingBox &bb) const;
73
t_model_material_attributes attributes;
74
DynamicPrintConfig config;
76
Model* get_model() const { return this->model; };
77
void apply(const t_model_material_attributes &attributes);
82
ModelMaterial(Model *model);
83
ModelMaterial(Model *model, const ModelMaterial &other);
90
std::string input_file;
91
ModelInstancePtrs instances;
92
ModelVolumePtrs volumes;
93
DynamicPrintConfig config;
94
t_layer_height_ranges layer_height_ranges;
95
Pointf origin_translation;
97
// these should be private but we need to expose them via XS until all methods are ported
98
BoundingBoxf3 _bounding_box;
99
bool _bounding_box_valid;
101
Model* get_model() const { return this->model; };
103
ModelVolume* add_volume(const TriangleMesh &mesh);
104
ModelVolume* add_volume(const ModelVolume &volume);
105
void delete_volume(size_t idx);
106
void clear_volumes();
108
ModelInstance* add_instance();
109
ModelInstance* add_instance(const ModelInstance &instance);
110
void delete_instance(size_t idx);
111
void delete_last_instance();
112
void clear_instances();
114
void invalidate_bounding_box();
116
//void raw_mesh(TriangleMesh* mesh) const;
117
//void mesh(TriangleMesh* mesh) const;
118
//void instance_bounding_box(size_t instance_idx, BoundingBox* bb) const;
119
//void center_around_origin();
120
//void translate(coordf_t x, coordf_t y, coordf_t z);
121
//size_t materials_count() const;
122
//void unique_materials(std::vector<t_model_material_id>* materials) const;
123
//size_t facets_count() const;
124
//bool needed_repair() const;
129
ModelObject(Model *model);
130
ModelObject(Model *model, const ModelObject &other);
131
ModelObject& operator= (ModelObject other);
132
void swap(ModelObject &other);
134
void update_bounding_box();
139
friend class ModelObject;
144
ModelObject* get_object() const { return this->object; };
145
t_model_material_id material_id() const;
146
void material_id(t_model_material_id material_id);
147
ModelMaterial* material() const;
151
t_model_material_id _material_id;
153
ModelVolume(ModelObject *object, const TriangleMesh &mesh);
154
ModelVolume(ModelObject *object, const ModelVolume &other);
159
friend class ModelObject;
161
double rotation; // around mesh center point
162
double scaling_factor;
163
Pointf offset; // in unscaled coordinates
165
ModelObject* get_object() const { return this->object; };
166
void transform_mesh(TriangleMesh* mesh, bool dont_translate) const;
167
void transform_polygon(Polygon* polygon) const;
172
ModelInstance(ModelObject *object);
173
ModelInstance(ModelObject *object, const ModelInstance &other);