Several minor fixes to Model
This commit is contained in:
parent
6e207d3830
commit
f76e2c2222
@ -250,6 +250,18 @@ ConfigBase::set_deserialize(const t_config_option_key opt_key, SV* str) {
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
DynamicConfig& DynamicConfig::operator= (DynamicConfig other)
|
||||||
|
{
|
||||||
|
this->swap(other);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
DynamicConfig::swap(DynamicConfig &other)
|
||||||
|
{
|
||||||
|
std::swap(this->options, other.options);
|
||||||
|
}
|
||||||
|
|
||||||
DynamicConfig::~DynamicConfig () {
|
DynamicConfig::~DynamicConfig () {
|
||||||
for (t_options_map::iterator it = this->options.begin(); it != this->options.end(); ++it) {
|
for (t_options_map::iterator it = this->options.begin(); it != this->options.end(); ++it) {
|
||||||
ConfigOption* opt = it->second;
|
ConfigOption* opt = it->second;
|
||||||
|
@ -488,6 +488,8 @@ class DynamicConfig : public ConfigBase
|
|||||||
public:
|
public:
|
||||||
DynamicConfig() {};
|
DynamicConfig() {};
|
||||||
DynamicConfig(const DynamicConfig& other);
|
DynamicConfig(const DynamicConfig& other);
|
||||||
|
DynamicConfig& operator= (DynamicConfig other);
|
||||||
|
void swap(DynamicConfig &other);
|
||||||
~DynamicConfig();
|
~DynamicConfig();
|
||||||
ConfigOption* option(const t_config_option_key opt_key, bool create = false);
|
ConfigOption* option(const t_config_option_key opt_key, bool create = false);
|
||||||
const ConfigOption* option(const t_config_option_key opt_key) const;
|
const ConfigOption* option(const t_config_option_key opt_key) const;
|
||||||
@ -495,7 +497,6 @@ class DynamicConfig : public ConfigBase
|
|||||||
void erase(const t_config_option_key opt_key);
|
void erase(const t_config_option_key opt_key);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
DynamicConfig& operator= (const DynamicConfig& other); // we disable this by making it private and unimplemented
|
|
||||||
typedef std::map<t_config_option_key,ConfigOption*> t_options_map;
|
typedef std::map<t_config_option_key,ConfigOption*> t_options_map;
|
||||||
t_options_map options;
|
t_options_map options;
|
||||||
};
|
};
|
||||||
|
@ -30,6 +30,19 @@ Model::Model(const Model &other)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Model& Model::operator= (Model other)
|
||||||
|
{
|
||||||
|
this->swap(other);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
Model::swap(Model &other)
|
||||||
|
{
|
||||||
|
std::swap(this->materials, other.materials);
|
||||||
|
std::swap(this->objects, other.objects);
|
||||||
|
}
|
||||||
|
|
||||||
Model::~Model()
|
Model::~Model()
|
||||||
{
|
{
|
||||||
this->clear_objects();
|
this->clear_objects();
|
||||||
@ -57,7 +70,8 @@ Model::delete_object(size_t idx)
|
|||||||
void
|
void
|
||||||
Model::clear_objects()
|
Model::clear_objects()
|
||||||
{
|
{
|
||||||
for (size_t i = this->objects.size()-1; i >= 0; --i)
|
// int instead of size_t because it can be -1 when vector is empty
|
||||||
|
for (int i = this->objects.size()-1; i >= 0; --i)
|
||||||
this->delete_object(i);
|
this->delete_object(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -194,6 +208,25 @@ ModelObject::ModelObject(const ModelObject &other)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ModelObject& ModelObject::operator= (ModelObject other)
|
||||||
|
{
|
||||||
|
this->swap(other);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
ModelObject::swap(ModelObject &other)
|
||||||
|
{
|
||||||
|
std::swap(this->input_file, other.input_file);
|
||||||
|
std::swap(this->instances, other.instances);
|
||||||
|
std::swap(this->volumes, other.volumes);
|
||||||
|
std::swap(this->config, other.config);
|
||||||
|
std::swap(this->layer_height_ranges, other.layer_height_ranges);
|
||||||
|
std::swap(this->origin_translation, other.origin_translation);
|
||||||
|
std::swap(this->_bounding_box, other._bounding_box);
|
||||||
|
std::swap(this->_bounding_box_valid, other._bounding_box_valid);
|
||||||
|
}
|
||||||
|
|
||||||
ModelObject::~ModelObject()
|
ModelObject::~ModelObject()
|
||||||
{
|
{
|
||||||
this->clear_volumes();
|
this->clear_volumes();
|
||||||
@ -222,7 +255,8 @@ ModelObject::delete_volume(size_t idx)
|
|||||||
void
|
void
|
||||||
ModelObject::clear_volumes()
|
ModelObject::clear_volumes()
|
||||||
{
|
{
|
||||||
for (size_t i = this->volumes.size()-1; i >= 0; --i)
|
// int instead of size_t because it can be -1 when vector is empty
|
||||||
|
for (int i = this->volumes.size()-1; i >= 0; --i)
|
||||||
this->delete_volume(i);
|
this->delete_volume(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -307,10 +341,6 @@ ModelInstance::ModelInstance(ModelObject *object, double rotation,
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
ModelInstance::~ModelInstance()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef SLIC3RXS
|
#ifdef SLIC3RXS
|
||||||
REGISTER_CLASS(ModelInstance, "Model::Instance");
|
REGISTER_CLASS(ModelInstance, "Model::Instance");
|
||||||
|
|
||||||
|
@ -35,6 +35,8 @@ class Model
|
|||||||
|
|
||||||
Model();
|
Model();
|
||||||
Model(const Model &other);
|
Model(const Model &other);
|
||||||
|
Model& operator= (Model other);
|
||||||
|
void swap(Model &other);
|
||||||
~Model();
|
~Model();
|
||||||
ModelObject* add_object(const std::string &input_file, const DynamicPrintConfig &config,
|
ModelObject* add_object(const std::string &input_file, const DynamicPrintConfig &config,
|
||||||
const t_layer_height_ranges &layer_height_ranges, const Pointf &origin_translation);
|
const t_layer_height_ranges &layer_height_ranges, const Pointf &origin_translation);
|
||||||
@ -82,12 +84,12 @@ class ModelObject
|
|||||||
DynamicPrintConfig config;
|
DynamicPrintConfig config;
|
||||||
t_layer_height_ranges layer_height_ranges;
|
t_layer_height_ranges layer_height_ranges;
|
||||||
Pointf origin_translation;
|
Pointf origin_translation;
|
||||||
BoundingBoxf3 _bounding_box;
|
|
||||||
bool _bounding_box_valid;
|
|
||||||
|
|
||||||
ModelObject(Model *model, const std::string &input_file, const DynamicPrintConfig &config,
|
ModelObject(Model *model, const std::string &input_file, const DynamicPrintConfig &config,
|
||||||
const t_layer_height_ranges &layer_height_ranges, const Pointf &origin_translation);
|
const t_layer_height_ranges &layer_height_ranges, const Pointf &origin_translation);
|
||||||
ModelObject(const ModelObject &other);
|
ModelObject(const ModelObject &other);
|
||||||
|
ModelObject& operator= (ModelObject other);
|
||||||
|
void swap(ModelObject &other);
|
||||||
~ModelObject();
|
~ModelObject();
|
||||||
|
|
||||||
ModelVolume* add_volume(const t_model_material_id &material_id,
|
ModelVolume* add_volume(const t_model_material_id &material_id,
|
||||||
@ -118,6 +120,9 @@ class ModelObject
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
BoundingBoxf3 _bounding_box;
|
||||||
|
bool _bounding_box_valid;
|
||||||
|
|
||||||
void update_bounding_box();
|
void update_bounding_box();
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -147,7 +152,6 @@ class ModelInstance
|
|||||||
|
|
||||||
ModelInstance(ModelObject *object, double rotation, double scaling_factor,
|
ModelInstance(ModelObject *object, double rotation, double scaling_factor,
|
||||||
const Pointf &offset);
|
const Pointf &offset);
|
||||||
~ModelInstance();
|
|
||||||
|
|
||||||
void transform_mesh(TriangleMesh* mesh, bool dont_translate) const;
|
void transform_mesh(TriangleMesh* mesh, bool dont_translate) const;
|
||||||
void transform_polygon(Polygon* polygon) const;
|
void transform_polygon(Polygon* polygon) const;
|
||||||
|
@ -50,6 +50,23 @@ TriangleMesh::TriangleMesh(const TriangleMesh &other)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TriangleMesh& TriangleMesh::operator= (TriangleMesh other)
|
||||||
|
{
|
||||||
|
this->swap(other);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
TriangleMesh::swap(TriangleMesh &other)
|
||||||
|
{
|
||||||
|
std::swap(this->stl, other.stl);
|
||||||
|
std::swap(this->repaired, other.repaired);
|
||||||
|
std::swap(this->stl.facet_start, other.stl.facet_start);
|
||||||
|
std::swap(this->stl.neighbors_start, other.stl.neighbors_start);
|
||||||
|
std::swap(this->stl.v_indices, other.stl.v_indices);
|
||||||
|
std::swap(this->stl.v_shared, other.stl.v_shared);
|
||||||
|
}
|
||||||
|
|
||||||
TriangleMesh::~TriangleMesh() {
|
TriangleMesh::~TriangleMesh() {
|
||||||
stl_close(&this->stl);
|
stl_close(&this->stl);
|
||||||
}
|
}
|
||||||
|
@ -20,6 +20,8 @@ class TriangleMesh
|
|||||||
public:
|
public:
|
||||||
TriangleMesh();
|
TriangleMesh();
|
||||||
TriangleMesh(const TriangleMesh &other);
|
TriangleMesh(const TriangleMesh &other);
|
||||||
|
TriangleMesh& operator= (TriangleMesh other);
|
||||||
|
void swap(TriangleMesh &other);
|
||||||
~TriangleMesh();
|
~TriangleMesh();
|
||||||
void ReadSTLFile(char* input_file);
|
void ReadSTLFile(char* input_file);
|
||||||
void write_ascii(char* output_file);
|
void write_ascii(char* output_file);
|
||||||
|
Loading…
Reference in New Issue
Block a user