OrcaSlicer latest
OrcaSlicer
Loading...
Searching...
No Matches
Slic3r::Model Class Referencefinal

#include </home/runner/work/OrcaSlicer/OrcaSlicer/src/libslic3r/Model.hpp>

Inheritance diagram for Slic3r::Model:
Collaboration diagram for Slic3r::Model:

Public Types

using Timestamp = uint64_t

Public Member Functions

void SetDesigner (std::string designer, std::string designer_user_id)
const CustomGCode::Info get_curr_plate_custom_gcodes () const
 Model ()
 ~Model ()
 Model (const Model &rhs)
 Model (Model &&rhs)
Model & operator= (const Model &rhs)
Model & operator= (Model &&rhs)
ModelObject * add_object ()
ModelObject * add_object (const char *name, const char *path, const TriangleMesh &mesh)
ModelObject * add_object (const char *name, const char *path, TriangleMesh &&mesh)
ModelObject * add_object (const ModelObject &other)
void delete_object (size_t idx)
bool delete_object (ObjectID id)
bool delete_object (ModelObject *object)
void clear_objects ()
void collect_reusable_objects (std::vector< ObjectBase * > &objects)
void set_object_backup_id (ModelObject const &object, int uuid)
int get_object_backup_id (ModelObject const &object)
int get_object_backup_id (ModelObject const &object) const
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 ()
bool add_default_instances ()
BoundingBoxf3 bounding_box_approx () const
BoundingBoxf3 bounding_box_exact () const
double max_z () const
unsigned int update_print_volume_state (const BuildVolume &build_volume)
bool center_instances_around_point (const Vec2d &point)
void translate (coordf_t x, coordf_t y, coordf_t z)
TriangleMesh mesh () const
void duplicate_objects_grid (size_t x, size_t y, coordf_t dist)
bool looks_like_multipart_object () const
void convert_multipart_object (unsigned int max_extruders)
bool looks_like_imperial_units () const
void convert_from_imperial_units (bool only_small_volumes)
bool looks_like_saved_in_meters () const
void convert_from_meters (bool only_small_volumes)
int removed_objects_with_zero_volume ()
void adjust_min_z ()
void print_info () const
std::string propose_export_file_name_and_path () const
std::string propose_export_file_name_and_path (const std::string &new_extension) const
std::string get_auxiliary_file_temp_path ()
std::string get_backup_path ()
std::string get_backup_path (const std::string &sub_path)
void set_backup_path (const std::string &path)
void load_from (Model &model)
bool is_need_backup ()
void set_need_backup ()
void remove_backup_path_if_exist ()
bool is_fdm_support_painted () const
bool is_seam_painted () const
bool is_mm_painted () const
bool is_fuzzy_skin_painted () const
ObjectID id () const
virtual Timestamp timestamp () const

Static Public Member Functions

static Model read_from_step (const std::string &input_file, LoadStrategy options, ImportStepProgressFn stepFn, StepIsUtf8Fn stepIsUtf8Fn, std::function< int(Slic3r::Step &, double &, double &, bool &)> step_mesh_fn, double linear_deflection, double angle_deflection, bool is_split_compound)
static Model read_from_file (const std::string &input_file, DynamicPrintConfig *config=nullptr, ConfigSubstitutionContext *config_substitutions=nullptr, LoadStrategy options=LoadStrategy::AddDefaultInstances, PlateDataPtrs *plate_data=nullptr, std::vector< Preset * > *project_presets=nullptr, bool *is_xxx=nullptr, Semver *file_version=nullptr, Import3mfProgressFn proFn=nullptr, ImportstlProgressFn stlFn=nullptr, BBLProject *project=nullptr, int plate_id=0)
static bool obj_import_vertex_color_deal (const std::vector< unsigned char > &vertex_filament_ids, const unsigned char &first_extruder_id, Model *model)
static bool obj_import_face_color_deal (const std::vector< unsigned char > &face_filament_ids, const unsigned char &first_extruder_id, Model *model)
static double findMaxSpeed (const ModelObject *object)
static double getThermalLength (const ModelVolume *modelVolumePtr)
static double getThermalLength (const std::vector< ModelVolume * > modelVolumePtrs)
static Polygon getBedPolygon ()
static void setPrintSpeedTable (const DynamicPrintConfig &config, const PrintConfig &print_config)
static void setExtruderParams (const DynamicPrintConfig &config, int extruders_count)
static Model read_from_archive (const std::string &input_file, DynamicPrintConfig *config, ConfigSubstitutionContext *config_substitutions, En3mfType &out_file_type, LoadStrategy options=LoadStrategy::AddDefaultInstances, PlateDataPtrs *plate_data=nullptr, std::vector< Preset * > *project_presets=nullptr, Semver *file_version=nullptr, Import3mfProgressFn proFn=nullptr, BBLProject *project=nullptr)

Public Attributes

ModelMaterialMap materials
ModelObjectPtrs objects
ModelWipeTower wipe_tower
std::string stl_design_id
std::string stl_design_country
std::shared_ptr< ModelDesignInfo > design_info = nullptr
std::shared_ptr< ModelInfo > model_info = nullptr
std::shared_ptr< ModelProfileInfo > profile_info = nullptr
std::shared_ptr< TexturedMesh > texture_mesh
std::string mk_name
std::string mk_version
std::vector< std::string > md_name
std::vector< std::string > md_value
std::string cad_recipe
int curr_plate_index { 0 }
std::map< int, CustomGCode::Info > plates_custom_gcodes
std::unique_ptr< CalibPressureAdvancePattern > calib_pa_pattern

Static Public Attributes

static std::map< size_t, ExtruderParams > extruderParamsMap = { {0,{"",0,0}}}
static GlobalSpeedMap printSpeedMap {}

Protected Member Functions

void set_new_unique_id ()
void set_invalid_id ()
void copy_id (const ObjectBase &rhs)

Private Member Functions

 Model (int)
void assign_new_unique_ids_recursive ()
void update_links_bottom_up_recursive ()
template<class Archive>
void load (Archive &ar)
template<class Archive>
void save (Archive &ar) const
template<class Archive>
void serialize (Archive &ar)

Static Private Member Functions

static ObjectID generate_new_id ()
template<class Archive>
static void load_and_construct (Archive &ar, cereal::construct< ObjectBase > &construct)

Private Attributes

std::string backup_path
bool need_backup = false
std::map< int, int > object_backup_id_map
int next_object_backup_id = 1
ObjectID m_id

Static Private Attributes

static size_t s_last_id = 0

Friends

class cereal::access
class UndoRedo::StackImpl

Detailed Description

Member Typedef Documentation

◆ Timestamp

using Slic3r::ObjectBase::Timestamp = uint64_t
inherited

Constructor & Destructor Documentation

◆ Model() [1/4]

Slic3r::Model::Model ( )
inline
1753{ assert(this->id().valid()); }

Referenced by Model(), Model(), load_from(), obj_import_face_color_deal(), obj_import_vertex_color_deal(), operator=(), operator=(), read_from_archive(), read_from_file(), and read_from_step().

Here is the caller graph for this function:

◆ ~Model()

Slic3r::Model::~Model ( )
232{
233 this->clear_objects();
234 this->clear_materials();
235 // BBS: clear backup dir of temparary model
236 if (!backup_path.empty())
237 Slic3r::remove_backup(*this, true);
238}
std::string backup_path
Definition Model.hpp:1908
void clear_materials()
Definition Model.cpp:776
void clear_objects()
Definition Model.cpp:717
void remove_backup(Model &model, bool removeAll)
Definition bbs_3mf.cpp:9774

References backup_path, clear_materials(), clear_objects(), and Slic3r::remove_backup().

Here is the call graph for this function:

◆ Model() [2/4]

Slic3r::Model::Model ( const Model & rhs)
inline
1758: ObjectBase(-1) { assert(this->id().invalid()); this->assign_copy(rhs); assert(this->id().valid()); assert(this->id() == rhs.id()); }
ObjectBase()
Definition ObjectID.hpp:79

References Model(), Slic3r::ObjectBase::ObjectBase(), and Slic3r::ObjectBase::id().

Here is the call graph for this function:

◆ Model() [3/4]

Slic3r::Model::Model ( Model && rhs)
inline
1760: ObjectBase(-1) { assert(this->id().invalid()); this->assign_copy(std::move(rhs)); assert(this->id().valid()); assert(this->id() == rhs.id()); }

References Model(), and Slic3r::ObjectBase::ObjectBase().

Here is the call graph for this function:

◆ Model() [4/4]

Slic3r::Model::Model ( int )
inlineexplicitprivate
1888 : ObjectBase(-1)
1889 {
1890 assert(this->id().invalid());
1891 }

References Slic3r::ObjectBase::ObjectBase().

Here is the call graph for this function:

Member Function Documentation

◆ add_default_instances()

bool Slic3r::Model::add_default_instances ( )
806{
807 // apply a default position to all objects not having one
808 for (ModelObject *o : this->objects)
809 if (o->instances.empty())
810 o->add_instance();
811 return true;
812}
ModelObjectPtrs objects
Definition Model.hpp:1702

References add_default_instances().

Referenced by add_default_instances(), Slic3r::GUI::ObjectList::load_modifier(), read_from_archive(), read_from_step(), Slic3r::GUI::read_model_from_file(), and Slic3r::CLI::run().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ add_material() [1/2]

ModelMaterial * Slic3r::Model::add_material ( t_model_material_id material_id)
784{
785 assert(! material_id.empty());
786 ModelMaterial* material = this->get_material(material_id);
787 if (material == nullptr)
788 material = this->materials[material_id] = new ModelMaterial(this);
789 return material;
790}
ModelMaterial * get_material(t_model_material_id material_id)
Definition Model.hpp:1821
ModelMaterialMap materials
Definition Model.hpp:1700

References add_material(), and get_material().

Referenced by add_material(), and add_material().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ add_material() [2/2]

ModelMaterial * Slic3r::Model::add_material ( t_model_material_id material_id,
const ModelMaterial & other )
793{
794 assert(! material_id.empty());
795 // delete existing material if any
796 ModelMaterial* material = this->get_material(material_id);
797 delete material;
798 // set new material
799 material = new ModelMaterial(other);
800 material->set_model(this);
801 this->materials[material_id] = material;
802 return material;
803}

References add_material(), get_material(), and Slic3r::ModelMaterial::set_model().

Here is the call graph for this function:

◆ add_object() [1/4]

◆ add_object() [2/4]

ModelObject * Slic3r::Model::add_object ( const char * name,
const char * path,
const TriangleMesh & mesh )
614{
615 ModelObject* new_object = new ModelObject(this);
616 this->objects.push_back(new_object);
617 new_object->name = name;
618 new_object->input_file = path;
619 ModelVolume *new_volume = new_object->add_volume(mesh);
620 new_volume->name = name;
621 new_volume->source.input_file = path;
622 new_volume->source.object_idx = (int)this->objects.size() - 1;
623 new_volume->source.volume_idx = (int)new_object->volumes.size() - 1;
624 // BBS: set extruder id to 1
625 if (!new_object->config.has("extruder") || new_object->config.extruder() == 0)
626 new_object->config.set_key_value("extruder", new ConfigOptionInt(1));
627 new_object->invalidate_bounding_box();
628 return new_object;
629}
TriangleMesh mesh() const
Definition Model.cpp:872

References add_object(), Slic3r::ModelObject::add_volume(), Slic3r::ModelObject::config, Slic3r::ModelConfig::extruder(), Slic3r::ModelConfig::has(), Slic3r::ModelObject::input_file, Slic3r::ModelVolume::Source::input_file, Slic3r::ModelObject::invalidate_bounding_box(), mesh(), Slic3r::ModelObject::name, Slic3r::ModelVolume::name, Slic3r::ModelVolume::Source::object_idx, Slic3r::ModelConfig::set_key_value(), Slic3r::ModelVolume::source, Slic3r::ModelVolume::Source::volume_idx, and Slic3r::ModelObject::volumes.

Here is the call graph for this function:

◆ add_object() [3/4]

ModelObject * Slic3r::Model::add_object ( const char * name,
const char * path,
TriangleMesh && mesh )
632{
633 ModelObject* new_object = new ModelObject(this);
634 this->objects.push_back(new_object);
635 new_object->name = name;
636 new_object->input_file = path;
637 ModelVolume *new_volume = new_object->add_volume(std::move(mesh));
638 new_volume->name = name;
639 new_volume->source.input_file = path;
640 new_volume->source.object_idx = (int)this->objects.size() - 1;
641 new_volume->source.volume_idx = (int)new_object->volumes.size() - 1;
642 // BBS: set default extruder id to 1
643 if (!new_object->config.has("extruder") || new_object->config.extruder() == 0)
644 new_object->config.set_key_value("extruder", new ConfigOptionInt(1));
645 new_object->invalidate_bounding_box();
646 return new_object;
647}

References add_object(), Slic3r::ModelObject::add_volume(), Slic3r::ModelObject::config, Slic3r::ModelConfig::extruder(), Slic3r::ModelConfig::has(), Slic3r::ModelObject::input_file, Slic3r::ModelVolume::Source::input_file, Slic3r::ModelObject::invalidate_bounding_box(), mesh(), Slic3r::ModelObject::name, Slic3r::ModelVolume::name, Slic3r::ModelVolume::Source::object_idx, Slic3r::ModelConfig::set_key_value(), Slic3r::ModelVolume::source, Slic3r::ModelVolume::Source::volume_idx, and Slic3r::ModelObject::volumes.

Here is the call graph for this function:

◆ add_object() [4/4]

ModelObject * Slic3r::Model::add_object ( const ModelObject & other)
650{
651 ModelObject* new_object = ModelObject::new_clone(other);
652 new_object->set_model(this);
653 // BBS: set default extruder id to 1
654 if (!new_object->config.has("extruder") || new_object->config.extruder() == 0)
655 new_object->config.set_key_value("extruder", new ConfigOptionInt(1));
656 this->objects.push_back(new_object);
657 // BBS: backup
658 if (need_backup) {
659 if (auto model = other.get_model()) {
660 auto iter = object_backup_id_map.find(other.id().id);
661 if (iter != object_backup_id_map.end()) {
662 object_backup_id_map.emplace(new_object->id().id, iter->second);
663 object_backup_id_map.erase(iter);
664 return new_object;
665 }
666 }
667 Slic3r::save_object_mesh(*new_object);
668 }
669 return new_object;
670}
bool need_backup
Definition Model.hpp:1909
std::map< int, int > object_backup_id_map
Definition Model.hpp:1910
void save_object_mesh(ModelObject &object)
Definition bbs_3mf.cpp:9754

References add_object(), Slic3r::ModelObject::config, Slic3r::ModelConfig::extruder(), Slic3r::ModelObject::get_model(), Slic3r::ModelConfig::has(), Slic3r::ObjectBase::id(), Slic3r::ObjectID::id, need_backup, object_backup_id_map, Slic3r::save_object_mesh(), Slic3r::ModelConfig::set_key_value(), and Slic3r::ModelObject::set_model().

Here is the call graph for this function:

◆ adjust_min_z()

void Slic3r::Model::adjust_min_z ( )
1060{
1061 if (objects.empty())
1062 return;
1063
1064 if (this->bounding_box_exact().min.z() < 0.0)
1065 {
1066 for (ModelObject* obj : objects)
1067 {
1068 if (obj != nullptr)
1069 {
1070 coordf_t obj_min_z = obj->min_z();
1071 if (obj_min_z < 0.0)
1072 obj->translate_instances(Vec3d(0.0, 0.0, -obj_min_z));
1073 }
1074 }
1075 }
1076}
BoundingBoxf3 bounding_box_exact() const
Definition Model.cpp:823
Eigen::Matrix< double, 3, 1, Eigen::DontAlign > Vec3d
Definition Point.hpp:68
double coordf_t
Definition GUI_ObjectList.hpp:46

References adjust_min_z(), bounding_box_exact(), and objects.

Referenced by adjust_min_z().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ assign_new_unique_ids_recursive()

void Slic3r::Model::assign_new_unique_ids_recursive ( )
privatevirtual

Reimplemented from Slic3r::ObjectBase.

210{
211 this->set_new_unique_id();
212 for (std::pair<const t_model_material_id, ModelMaterial*> &m : this->materials)
213 m.second->assign_new_unique_ids_recursive();
214 for (ModelObject *model_object : this->objects)
215 model_object->assign_new_unique_ids_recursive();
216}
void set_new_unique_id()
Definition ObjectID.hpp:89

References Slic3r::ObjectBase::set_new_unique_id().

Here is the call graph for this function:

◆ bounding_box_approx()

BoundingBoxf3 Slic3r::Model::bounding_box_approx ( ) const
816{
817 BoundingBoxf3 bb;
818 for (ModelObject *o : this->objects)
819 bb.merge(o->bounding_box_approx());
820 return bb;
821}

References bounding_box_approx(), and Slic3r::BoundingBox3Base< PointType >::merge().

Referenced by bounding_box_approx().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ bounding_box_exact()

BoundingBoxf3 Slic3r::Model::bounding_box_exact ( ) const
824{
825 BoundingBoxf3 bb;
826 for (ModelObject *o : this->objects)
827 bb.merge(o->bounding_box_exact());
828 return bb;
829}

References bounding_box_exact(), and Slic3r::BoundingBox3Base< PointType >::merge().

Referenced by adjust_min_z(), bounding_box_exact(), and Slic3r::GUI::CalibUtils::process_and_store_3mf().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ center_instances_around_point()

bool Slic3r::Model::center_instances_around_point ( const Vec2d & point)
851{
852 BoundingBoxf3 bb;
853 for (ModelObject *o : this->objects)
854 for (size_t i = 0; i < o->instances.size(); ++ i)
855 bb.merge(o->instance_bounding_box(i, false));
856
857 Vec2d shift2 = point - to_2d(bb.center());
858 if (std::abs(shift2(0)) < EPSILON && std::abs(shift2(1)) < EPSILON)
859 // No significant shift, don't do anything.
860 return false;
861
862 Vec3d shift3 = Vec3d(shift2(0), shift2(1), 0.0);
863 for (ModelObject *o : this->objects) {
864 for (ModelInstance *i : o->instances)
865 i->set_offset(i->get_offset() + shift3);
866 o->invalidate_bounding_box();
867 }
868 return true;
869}
#define EPSILON
Definition ColorUtils.cpp:64
Eigen::Matrix< typename Derived::Scalar, 2, 1, Eigen::DontAlign > to_2d(const Eigen::MatrixBase< Derived > &ptN)
Definition Point.hpp:147
Eigen::Matrix< double, 2, 1, Eigen::DontAlign > Vec2d
Definition Point.hpp:67

References Slic3r::BoundingBox3Base< PointType >::center(), center_instances_around_point(), EPSILON, Slic3r::ModelInstance::get_offset(), Slic3r::BoundingBox3Base< PointType >::merge(), Slic3r::ModelInstance::set_offset(), and Slic3r::to_2d().

Referenced by center_instances_around_point(), and Slic3r::GUI::ObjectList::load_modifier().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ clear_materials()

void Slic3r::Model::clear_materials ( )
777{
778 for (auto &m : this->materials)
779 delete m.second;
780 this->materials.clear();
781}

References clear_materials().

Referenced by ~Model(), clear_materials(), construct_assemble_list(), Slic3r::UndoRedo::StackImpl::load_snapshot(), and Slic3r::CLI::run().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ clear_objects()

void Slic3r::Model::clear_objects ( )
718{
719 for (ModelObject* o : this->objects) {
720 // BBS: backup
722 delete o;
723 }
724 this->objects.clear();
725 object_backup_id_map.clear();
727 texture_mesh.reset();
728}
int next_object_backup_id
Definition Model.hpp:1911
std::shared_ptr< TexturedMesh > texture_mesh
Definition Model.hpp:1718
void delete_object_mesh(ModelObject &object)
Definition bbs_3mf.cpp:9763

References clear_objects(), Slic3r::delete_object_mesh(), next_object_backup_id, object_backup_id_map, and texture_mesh.

Referenced by ~Model(), clear_objects(), construct_assemble_list(), convert_multipart_object(), and Slic3r::CLI::run().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ collect_reusable_objects()

void Slic3r::Model::collect_reusable_objects ( std::vector< ObjectBase * > & objects)
732{
733 for (ModelObject* model_object : this->objects) {
734 objects.push_back(model_object);
735 for (ModelVolume* model_volume : model_object->volumes)
736 objects.push_back(model_volume);
737 std::transform(model_object->volumes.begin(),
738 model_object->volumes.end(),
739 std::back_inserter(model_object->volume_ids),
740 std::mem_fn(&ObjectBase::id));
741 model_object->volumes.clear();
742 }
743 // we never own these objects
744 this->objects.clear();
745}
ObjectID id() const
Definition ObjectID.hpp:69

References collect_reusable_objects(), Slic3r::ObjectBase::id(), and objects.

Referenced by collect_reusable_objects(), and Slic3r::UndoRedo::StackImpl::load_snapshot().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ convert_from_imperial_units()

void Slic3r::Model::convert_from_imperial_units ( bool only_small_volumes)
1004{
1005 static constexpr const float in_to_mm = 25.4f;
1006 for (ModelObject* obj : this->objects)
1007 if (! only_small_volumes || obj->get_object_stl_stats().volume < volume_threshold_inches) {
1008 obj->scale_mesh_after_creation(in_to_mm);
1009 for (ModelVolume* v : obj->volumes) {
1010 assert(! v->source.is_converted_from_meters);
1011 v->source.is_converted_from_inches = true;
1012 }
1013 }
1014}
static constexpr const double volume_threshold_inches
Definition Model.cpp:976

References convert_from_imperial_units(), Slic3r::ModelVolume::Source::is_converted_from_inches, Slic3r::ModelVolume::Source::is_converted_from_meters, Slic3r::ModelVolume::source, and Slic3r::volume_threshold_inches.

Referenced by convert_from_imperial_units().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ convert_from_meters()

void Slic3r::Model::convert_from_meters ( bool only_small_volumes)
1031{
1032 static constexpr const double m_to_mm = 1000;
1033 for (ModelObject* obj : this->objects)
1034 if (! only_small_volumes || obj->get_object_stl_stats().volume < volume_threshold_meters) {
1035 obj->scale_mesh_after_creation(m_to_mm);
1036 for (ModelVolume* v : obj->volumes) {
1037 assert(! v->source.is_converted_from_inches);
1038 v->source.is_converted_from_meters = true;
1039 }
1040 }
1041}
static constexpr const double volume_threshold_meters
Definition Model.cpp:1016

References convert_from_meters(), Slic3r::ModelVolume::Source::is_converted_from_inches, Slic3r::ModelVolume::Source::is_converted_from_meters, Slic3r::ModelVolume::source, and Slic3r::volume_threshold_meters.

Referenced by convert_from_meters().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ convert_multipart_object()

void Slic3r::Model::convert_multipart_object ( unsigned int max_extruders)
927{
928 assert(this->objects.size() >= 2);
929 if (this->objects.size() < 2)
930 return;
931
932 ModelObject* object = new ModelObject(this);
933 object->input_file = this->objects.front()->input_file;
934 object->name = boost::filesystem::path(this->objects.front()->input_file).stem().string();
935 //FIXME copy the config etc?
936
937 unsigned int extruder_counter = 0;
938
939 for (const ModelObject* o : this->objects)
940 for (const ModelVolume* v : o->volumes) {
941 // If there are more than one object, put all volumes together
942 // Each object may contain any number of volumes and instances
943 // The volumes transformations are relative to the object containing them...
944 Geometry::Transformation trafo_volume = v->get_transformation();
945 // Revert the centering operation.
946 trafo_volume.set_offset(trafo_volume.get_offset() - o->origin_translation);
947 int counter = 1;
948 auto copy_volume = [o, v, &counter](ModelVolume *new_v) {
949 assert(new_v != nullptr);
950 new_v->name = (counter > 1) ? o->name + "_" + std::to_string(counter++) : o->name;
951 //BBS: Use extruder priority: volumn > object > default
952 if (v->config.option("extruder"))
953 new_v->config.set("extruder", v->config.extruder());
954 else if (o->config.option("extruder"))
955 new_v->config.set("extruder", o->config.extruder());
956
957 return new_v;
958 };
959 if (o->instances.empty()) {
960 copy_volume(object->add_volume(*v))->set_transformation(trafo_volume);
961 } else {
962 for (const ModelInstance* i : o->instances)
963 // ...so, transform everything to a common reference system (world)
964 copy_volume(object->add_volume(*v))->set_transformation(i->get_transformation() * trafo_volume);
965 }
966 }
967
968 // commented-out to fix #2868
969// object->add_instance();
970// object->instances[0]->set_offset(object->raw_mesh_bounding_box().center());
971
972 this->clear_objects();
973 this->objects.push_back(object);
974}

References Slic3r::ModelObject::add_volume(), clear_objects(), convert_multipart_object(), Slic3r::Geometry::Transformation::get_offset(), Slic3r::ModelInstance::get_transformation(), Slic3r::ModelVolume::get_transformation(), and Slic3r::Geometry::Transformation::set_offset().

Referenced by convert_multipart_object().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ copy_id()

void Slic3r::ObjectBase::copy_id ( const ObjectBase & rhs)
inlineprotectedinherited
92{ m_id = rhs.id(); }
ObjectID m_id
Definition ObjectID.hpp:98

References ObjectBase(), id(), and m_id.

Referenced by Slic3r::CutObjectBase::copy().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ delete_material()

void Slic3r::Model::delete_material ( t_model_material_id material_id)
768{
769 ModelMaterialMap::iterator i = this->materials.find(material_id);
770 if (i != this->materials.end()) {
771 delete i->second;
772 this->materials.erase(i);
773 }
774}

References delete_material().

Referenced by delete_material().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ delete_object() [1/3]

bool Slic3r::Model::delete_object ( ModelObject * object)
682{
683 if (object != nullptr) {
684 size_t idx = 0;
685 for (ModelObject *model_object : objects) {
686 if (model_object == object) {
687 // BBS: backup
688 Slic3r::delete_object_mesh(*model_object);
689 delete model_object;
690 objects.erase(objects.begin() + idx);
691 return true;
692 }
693 ++ idx;
694 }
695 }
696 return false;
697}

References delete_object(), Slic3r::delete_object_mesh(), and objects.

Here is the call graph for this function:

◆ delete_object() [2/3]

bool Slic3r::Model::delete_object ( ObjectID id)
700{
701 if (id.id != 0) {
702 size_t idx = 0;
703 for (ModelObject *model_object : objects) {
704 if (model_object->id() == id) {
705 // BBS: backup
706 Slic3r::delete_object_mesh(*model_object);
707 delete model_object;
708 objects.erase(objects.begin() + idx);
709 return true;
710 }
711 ++ idx;
712 }
713 }
714 return false;
715}

References delete_object(), Slic3r::delete_object_mesh(), and objects.

Here is the call graph for this function:

◆ delete_object() [3/3]

void Slic3r::Model::delete_object ( size_t idx)
673{
674 ModelObjectPtrs::iterator i = this->objects.begin() + idx;
675 // BBS: backup
677 delete *i;
678 this->objects.erase(i);
679}

References delete_object(), and Slic3r::delete_object_mesh().

Referenced by Slic3r::GUI::Plater::apply_cut_object_to_model(), Slic3r::GUI::cut_model(), Slic3r::GUI::ObjectList::delete_all_connectors_for_object(), delete_object(), delete_object(), delete_object(), Slic3r::GUI::ensure_belt_purge_tower(), and removed_objects_with_zero_volume().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ duplicate_objects_grid()

void Slic3r::Model::duplicate_objects_grid ( size_t x,
size_t y,
coordf_t dist )
881{
882 if (this->objects.size() > 1) throw "Grid duplication is not supported with multiple objects";
883 if (this->objects.empty()) throw "No objects!";
884
885 ModelObject* object = this->objects.front();
886 object->clear_instances();
887
888 Vec3d ext_size = object->bounding_box_exact().size() + dist * Vec3d::Ones();
889
890 for (size_t x_copy = 1; x_copy <= x; ++x_copy) {
891 for (size_t y_copy = 1; y_copy <= y; ++y_copy) {
892 ModelInstance* instance = object->add_instance();
893 instance->set_offset(Vec3d(ext_size(0) * (double)(x_copy - 1), ext_size(1) * (double)(y_copy - 1), 0.0));
894 }
895 }
896}
T dist(const boost::polygon::point_data< T > &p1, const boost::polygon::point_data< T > &p2)
Definition Geometry.cpp:298

References Slic3r::ModelObject::clear_instances(), Slic3r::Geometry::dist(), duplicate_objects_grid(), and Slic3r::ModelInstance::set_offset().

Referenced by duplicate_objects_grid().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ findMaxSpeed()

double Slic3r::Model::findMaxSpeed ( const ModelObject * object)
static
3459 {
3460 auto objectKeys = object->config.keys();
3461 double objMaxSpeed = -1.;
3462 if (objectKeys.empty())
3464 double perimeterSpeedObj = Model::printSpeedMap.perimeterSpeed;
3465 double externalPerimeterSpeedObj = Model::printSpeedMap.externalPerimeterSpeed;
3466 double infillSpeedObj = Model::printSpeedMap.infillSpeed;
3467 double solidInfillSpeedObj = Model::printSpeedMap.solidInfillSpeed;
3468 double topSolidInfillSpeedObj = Model::printSpeedMap.topSolidInfillSpeed;
3469 double supportSpeedObj = Model::printSpeedMap.supportSpeed;
3470 double smallPerimeterSpeedObj = Model::printSpeedMap.smallPerimeterSpeed;
3471 double smallSupportPerimeterSpeedObj = Model::printSpeedMap.smallSupportPerimeterSpeed;
3472 for (std::string objectKey : objectKeys) {
3473 if (objectKey == "inner_wall_speed"){
3474 perimeterSpeedObj = object->config.get().opt_float_nullable(objectKey, 0);
3475 externalPerimeterSpeedObj = Model::printSpeedMap.externalPerimeterSpeed / Model::printSpeedMap.perimeterSpeed * perimeterSpeedObj;
3476 }
3477 if (objectKey == "sparse_infill_speed")
3478 infillSpeedObj = object->config.get().opt_float_nullable(objectKey, 0);
3479 if (objectKey == "internal_solid_infill_speed")
3480 solidInfillSpeedObj = object->config.get().opt_float_nullable(objectKey, 0);
3481 if (objectKey == "top_surface_speed")
3482 topSolidInfillSpeedObj = object->config.get().opt_float_nullable(objectKey, 0);
3483 if (objectKey == "support_speed")
3484 supportSpeedObj = object->config.get().opt_float_nullable(objectKey, 0);
3485 if (objectKey == "outer_wall_speed")
3486 externalPerimeterSpeedObj = object->config.get().opt_float_nullable(objectKey, 0);
3487 if (objectKey == "small_perimeter_speed")
3488 smallPerimeterSpeedObj = object->config.get().opt_float_or_percent_nullable(objectKey, 0).get_abs_value(externalPerimeterSpeedObj);
3489 if (objectKey == "small_support_perimeter_speed")
3490 smallSupportPerimeterSpeedObj = object->config.get().opt_float_or_percent_nullable(objectKey, 0).get_abs_value(supportSpeedObj);
3491 }
3492 objMaxSpeed = std::max(perimeterSpeedObj, std::max(externalPerimeterSpeedObj, std::max(infillSpeedObj, std::max(solidInfillSpeedObj, std::max(topSolidInfillSpeedObj, std::max(supportSpeedObj, std::max(smallPerimeterSpeedObj, std::max(smallSupportPerimeterSpeedObj, objMaxSpeed))))))));
3493 if (objMaxSpeed <= 0) objMaxSpeed = 250.;
3494 return objMaxSpeed;
3495}
static GlobalSpeedMap printSpeedMap
Definition Model.hpp:1707
double topSolidInfillSpeed
Definition Model.hpp:1638
double supportSpeed
Definition Model.hpp:1639
double maxSpeed
Definition Model.hpp:1642
double smallSupportPerimeterSpeed
Definition Model.hpp:1641
double infillSpeed
Definition Model.hpp:1636
double externalPerimeterSpeed
Definition Model.hpp:1635
double solidInfillSpeed
Definition Model.hpp:1637
double smallPerimeterSpeed
Definition Model.hpp:1640
double perimeterSpeed
Definition Model.hpp:1634

References findMaxSpeed(), and printSpeedMap.

Referenced by findMaxSpeed(), Slic3r::ModelInstance::get_auto_brim_width(), and Slic3r::outer_inner_brim_area().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ generate_new_id()

ObjectID Slic3r::ObjectBase::generate_new_id ( )
inlinestaticprivateinherited
100{ return ObjectID(++ s_last_id); }
static size_t s_last_id
Definition ObjectID.hpp:101

References s_last_id.

Referenced by ObjectBase(), and set_new_unique_id().

Here is the caller graph for this function:

◆ get_auxiliary_file_temp_path()

std::string Slic3r::Model::get_auxiliary_file_temp_path ( )
1100{
1101 return get_backup_path("Auxiliaries");
1102}
std::string get_backup_path()
Definition Model.cpp:1105

References get_auxiliary_file_temp_path(), and get_backup_path().

Referenced by Slic3r::_BBS_3MF_Importer::_extract_auxiliary_file_from_archive(), Slic3r::_BBS_3MF_Exporter::_save_model_to_file(), get_auxiliary_file_temp_path(), AuxiliaryList::init_auxiliary(), and Slic3r::GUI::AuxiliaryPanel::init_auxiliary().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_backup_path() [1/2]

std::string Slic3r::Model::get_backup_path ( )
1106{
1107 if (backup_path.empty())
1108 {
1109 auto pid = get_current_pid();
1110 boost::filesystem::path parent_path(temporary_dir());
1111 std::time_t t = std::time(0);
1112 std::tm* now_time = std::localtime(&t);
1113 std::stringstream buf;
1114 buf << "/orcaslicer_model/";
1115 buf << std::put_time(now_time, "%a_%b_%d/%H_%M_%S#");
1116 buf << pid << "#";
1117 buf << this->id().id;
1118
1119 backup_path = parent_path.string() + buf.str();
1120 BOOST_LOG_TRIVIAL(info) << boost::format("model %1%, id %2%, backup_path empty, set to %3%")%this%this->id().id%backup_path;
1121 boost::filesystem::path temp_path(backup_path);
1122 if (boost::filesystem::exists(temp_path))
1123 {
1124 BOOST_LOG_TRIVIAL(info) << boost::format("model %1%, id %2%, remove previous %3%")%this%this->id().id%backup_path;
1125 boost::filesystem::remove_all(temp_path);
1126 }
1127 }
1128 boost::filesystem::path temp_path(backup_path);
1129 try {
1130 if (!boost::filesystem::exists(temp_path))
1131 {
1132 BOOST_LOG_TRIVIAL(info) << "create /3D/Objects in " << temp_path;
1133 boost::filesystem::create_directories(backup_path + "/3D/Objects");
1134 BOOST_LOG_TRIVIAL(info) << "create /Metadata in " << temp_path;
1135 boost::filesystem::create_directories(backup_path + "/Metadata");
1136 BOOST_LOG_TRIVIAL(info) << "create /lock.txt in " << temp_path;
1137 save_string_file(backup_path + "/lock.txt",
1138 boost::lexical_cast<std::string>(get_current_pid()));
1139 }
1140 } catch (std::exception &ex) {
1141 BOOST_LOG_TRIVIAL(error) << "Failed to create backup path" << temp_path << ": " << ex.what();
1142 }
1143
1144 return backup_path;
1145}
size_t id
Definition ObjectID.hpp:39
void save_string_file(const boost::filesystem::path &p, const std::string &str)
Definition utils.cpp:2156
unsigned get_current_pid()
Definition utils.cpp:1480
const std::string & temporary_dir()
Definition utils.cpp:308

References backup_path, get_backup_path(), Slic3r::get_current_pid(), Slic3r::ObjectBase::id(), Slic3r::save_string_file(), and Slic3r::temporary_dir().

Referenced by Slic3r::_BBS_3MF_Exporter::_add_project_config_file_to_archive(), Slic3r::_BBS_3MF_Exporter::_add_project_embedded_presets_to_archive(), Slic3r::_BBS_3MF_Importer::_extract_project_config_from_archive(), get_auxiliary_file_temp_path(), get_backup_path(), get_backup_path(), load_from(), Slic3r::_BBS_3MF_Importer::load_model_from_file(), Slic3r::_BBS_Backup_Manager::remove_backup(), and Slic3r::_BBS_3MF_Exporter::save_model_to_file().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_backup_path() [2/2]

std::string Slic3r::Model::get_backup_path ( const std::string & sub_path)
1161{
1162 auto path = get_backup_path() + "/" + sub_path;
1163 try {
1164 if (!boost::filesystem::exists(path)) {
1165 BOOST_LOG_TRIVIAL(info) << "create missing sub_path" << path;
1166 boost::filesystem::create_directories(path);
1167 }
1168 } catch (std::exception &ex) {
1169 BOOST_LOG_TRIVIAL(error) << "Failed to create missing sub_path" << path << ": " << ex.what();
1170 }
1171 return path;
1172}

References get_backup_path().

Here is the call graph for this function:

◆ get_curr_plate_custom_gcodes()

const CustomGCode::Info Slic3r::Model::get_curr_plate_custom_gcodes ( ) const
inline
1745 {
1748 }
1749 return CustomGCode::Info();
1750 }
int curr_plate_index
Definition Model.hpp:1742
std::map< int, CustomGCode::Info > plates_custom_gcodes
Definition Model.hpp:1743

References curr_plate_index, and plates_custom_gcodes.

Referenced by Slic3r::ToolOrdering::ToolOrdering(), and Slic3r::ToolOrdering::assign_custom_gcodes().

Here is the caller graph for this function:

◆ get_material()

ModelMaterial * Slic3r::Model::get_material ( t_model_material_id material_id)
inline
1821 {
1822 ModelMaterialMap::iterator i = this->materials.find(material_id);
1823 return (i == this->materials.end()) ? nullptr : i->second;
1824 }

Referenced by add_material(), and add_material().

Here is the caller graph for this function:

◆ get_object_backup_id() [1/2]

int Slic3r::Model::get_object_backup_id ( ModelObject const & object)
754{
755 auto i = object_backup_id_map.find(object.id().id);
756 if (i == object_backup_id_map.end()) {
757 i = object_backup_id_map.insert(std::make_pair(object.id().id, next_object_backup_id++)).first;
758 }
759 return i->second;
760}

References get_object_backup_id(), next_object_backup_id, and object_backup_id_map.

Referenced by get_object_backup_id(), and get_object_backup_id().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_object_backup_id() [2/2]

int Slic3r::Model::get_object_backup_id ( ModelObject const & object) const
763{
764 return object_backup_id_map.find(object.id().id)->second;
765}

References get_object_backup_id(), and object_backup_id_map.

Here is the call graph for this function:

◆ getBedPolygon()

Polygon Slic3r::Model::getBedPolygon ( )
inlinestatic
Polygon bed_poly
Definition Model.hpp:1643

References printSpeedMap.

Referenced by Slic3r::outer_inner_brim_area().

Here is the caller graph for this function:

◆ getThermalLength() [1/2]

double Slic3r::Model::getThermalLength ( const ModelVolume * modelVolumePtr)
static
3498 {
3499 double thermalLength = 200.;
3500 auto aa = modelVolumePtr->extruder_id();
3502 double thermal_length = 200.0;
3503 if (MaterialType::get_thermal_length(Model::extruderParamsMap.at(aa).materialName, thermal_length)) {
3504 return thermal_length;
3505 }
3506 }
3507 return thermalLength;
3508}
static bool get_thermal_length(const std::string &type, double &thermal_length)
Definition MaterialType.cpp:160
static std::map< size_t, ExtruderParams > extruderParamsMap
Definition Model.hpp:1706
T * end(Slic3r::Mat< N, M, T > &mat)
Definition Point.hpp:841
RaycastManager::TrItems::iterator find(RaycastManager::TrItems &items, const RaycastManager::TrKey &key)
Definition RaycastManager.cpp:298

References Slic3r::ModelVolume::extruder_id(), extruderParamsMap, Slic3r::MaterialType::get_thermal_length(), and getThermalLength().

Referenced by Slic3r::configBrimWidthByVolumeGroups(), Slic3r::ModelInstance::get_auto_brim_width(), getThermalLength(), and getThermalLength().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getThermalLength() [2/2]

double Slic3r::Model::getThermalLength ( const std::vector< ModelVolume * > modelVolumePtrs)
static
3512{
3513 double thermalLength = 1250.;
3514
3515 for (const auto& modelVolumePtr : modelVolumePtrs) {
3516 if (modelVolumePtr != nullptr) {
3517 // the thermal length of a group is decided by the volume with shortest thermal length
3518 thermalLength = std::min(thermalLength, getThermalLength(modelVolumePtr));
3519 }
3520 }
3521 return thermalLength;
3522}
static double getThermalLength(const ModelVolume *modelVolumePtr)
Definition Model.cpp:3498

References getThermalLength().

Here is the call graph for this function:

◆ id()

ObjectID Slic3r::ObjectBase::id ( ) const
inlineinherited
69{ return m_id; }

References m_id.

Referenced by Slic3r::CutObjectBase::CutObjectBase(), Slic3r::Model::Model(), Slic3r::ModelInstance::ModelInstance(), Slic3r::ModelMaterial::ModelMaterial(), Slic3r::ModelObject::ModelObject(), Slic3r::ModelObject::ModelObject(), Slic3r::ModelObject::ModelObject(), Slic3r::ModelObject::ModelObject(), Slic3r::ModelObject::ModelObject(), Slic3r::ModelVolume::ModelVolume(), Slic3r::ModelVolume::ModelVolume(), Slic3r::ModelVolume::ModelVolume(), Slic3r::ModelVolume::ModelVolume(), Slic3r::ModelVolume::ModelVolume(), Slic3r::ModelVolume::ModelVolume(), ObjectBase(), Slic3r::PrintBase::SlicingStatus::SlicingStatus(), Slic3r::PrintBase::SlicingStatus::SlicingStatus(), Slic3r::_BBS_3MF_Exporter::_add_cut_information_file_to_archive(), Slic3r::_BBS_3MF_Exporter::_add_model_config_file_to_archive(), Slic3r::_BBS_3MF_Exporter::_add_slice_info_config_file_to_archive(), Slic3r::GUI::Plater::priv::actualize_slicing_warnings(), Slic3r::ModelObjectStatusDB::add(), Slic3r::ModelObjectStatusDB::add_if_new(), Slic3r::Model::add_object(), Slic3r::append_and_translate(), Slic3r::SLAPrint::apply(), Slic3r::GUI::calc_distance(), Slic3r::GUI::calc_surface_offset(), Slic3r::check_model_ids_equal(), Slic3r::check_model_ids_validity(), Slic3r::GUI::GLGizmoTextureDisplacement::close_image_adjust(), Slic3r::Model::collect_reusable_objects(), Slic3r::ModelObject::convert_units(), copy_id(), Slic3r::PrintObjectStatusDB::count(), anonymous_namespace{RaycastManager.cpp}::create_key(), Slic3r::GUI::create_meshes(), anonymous_namespace{EmbossJob.cpp}::create_volume(), Slic3r::GUI::Emboss::create_volume_sources(), Slic3r::GUI::GLGizmoPainterBase::data_changed(), Slic3r::GCode::do_export(), Slic3r::GUI::PartPlate::duplicate_all_instance(), Slic3r::GUI::PartPlateList::duplicate_plate(), Slic3r::GUI::PartPlate::estimate_wipe_tower_footprint(), Slic3r::Print::export_cached_data(), Slic3r::GUI::Plater::export_stl(), Slic3r::find_volume_extents(), Slic3r::PreciseSeam::detail::fragment_location(), Slic3r::GUI::Plater::priv::generate_first_layer_bbox(), Slic3r::ModelObjectStatusDB::get(), Slic3r::Model::get_backup_path(), Slic3r::GUI::GLCanvas3D::get_empty_cells(), Slic3r::ModelInstance::get_labeled_id(), Slic3r::GUI::get_model_volume(), Slic3r::PrintObjectStatusDB::get_range(), Slic3r::GUI::get_selected_volume(), Slic3r::GUI::get_volume(), Slic3r::CutObjectBase::has_same_id(), Slic3r::UndoRedo::StackImpl::immutable_object_id_impl(), Slic3r::GUI::GLGizmoFdmSupports::init_print_instance(), Slic3r::CutObjectBase::is_equal(), Slic3r::GUI::GLGizmoSVG::is_svg_object(), Slic3r::ModelVolume::is_the_only_one_part(), Slic3r::GUI::IMSlider::IsNewPrint(), Slic3r::ModelObject::load(), load_and_construct(), Slic3r::Print::load_cached_data(), Slic3r::GLVolumeCollection::load_object_auxiliary(), Slic3r::GLVolumeCollection::load_object_volume(), Slic3r::GUI::GCodeViewer::load_shells(), Slic3r::UndoRedo::StackImpl::load_snapshot(), Slic3r::GUI::GLCanvas3D::CenterOfMass::model_markers(), Slic3r::model_property_changed(), Slic3r::model_volume_list_changed(), Slic3r::model_volume_list_copy_configs(), Slic3r::ModelConfigObject::object_id_and_timestamp_match(), Slic3r::ObjectWithTimestamp::object_id_and_timestamp_match(), Slic3r::GUI::GLGizmoEmboss::on_mouse_change_selection(), Slic3r::GUI::GLGizmoSimplify::on_render_input_window(), Slic3r::GUI::GLGizmoTextureDisplacement::open_image_adjust(), Slic3r::CutObjectBase::operator<(), Slic3r::Model::operator=(), Slic3r::ModelObject::operator=(), Slic3r::ModelObject::operator=(), Slic3r::CutObjectBase::operator==(), Slic3r::outer_inner_brim_area(), Slic3r::GUI::GLGizmoTextureDisplacement::painted_area_mm2(), Slic3r::GUI::GLGizmoCut3D::perform_cut(), anonymous_namespace{GLGizmoEmboss.cpp}::prepare_volumes_to_slice(), Slic3r::GUI::GLGizmoTextureDisplacement::preview_part(), Slic3r::GCode::process_layer(), Slic3r::GUI::NotificationManager::push_slicing_warning_notification(), Slic3r::GUI::GLGizmoTextureDisplacement::queue_preview_job(), Slic3r::GUI::queue_texture_displacement_debug(), Slic3r::GUI::GLGizmoEmboss::re_emboss(), Slic3r::GUI::GLGizmoTextureDisplacement::rebuild_other_paint_overlay(), Slic3r::GUI::GLGizmoTextureDisplacement::rebuild_painted_colors(), Slic3r::GUI::GLCanvas3D::reload_scene(), Slic3r::_BBS_Backup_Manager::remove_backup(), Slic3r::Model::remove_backup_path_if_exist(), Slic3r::GUI::GLGizmoTextureDisplacement::render_image_adjust_window(), Slic3r::CLI::run(), Slic3r::GUI::GLCanvas3D::LayersEditing::select_object(), Slic3r::ModelMaterial::serialize(), Slic3r::Model::set_backup_path(), Slic3r::GUI::GLGizmoBrimEars::set_brim_data(), Slic3r::GUI::PartPlate::set_hover_id(), Slic3r::GUI::GLGizmoEmboss::set_volume_by_selection(), Slic3r::GUI::GLGizmoSVG::set_volume_by_selection(), Slic3r::sla_instances(), Slic3r::slices_to_regions(), Slic3r::ModelObject::split(), anonymous_namespace{EmbossJob.cpp}::start_create_volume_on_surface_job(), anonymous_namespace{SurfaceDrag.cpp}::start_dragging(), Slic3r::GUI::Emboss::start_update_volume(), Slic3r::UndoRedo::StackImpl::take_snapshot(), Slic3r::GUI::texture_displacement_bake_volume(), Slic3r::GUI::GLGizmoPainterBase::update_contours(), anonymous_namespace{EmbossJob.cpp}::update_name_in_list(), Slic3r::GUI::ObjectList::update_name_in_model(), Slic3r::GUI::update_object_cut_id(), Slic3r::GUI::GLGizmoTextureDisplacement::v2_recommendation(), Slic3r::verify_update_print_object_regions(), wipe_tower_instance_id, and wipe_tower_object_id.

◆ is_fdm_support_painted()

bool Slic3r::Model::is_fdm_support_painted ( ) const
1223{
1224 return std::any_of(this->objects.cbegin(), this->objects.cend(), [](const ModelObject *mo) { return mo->is_fdm_support_painted(); });
1225}

References is_fdm_support_painted().

Referenced by Slic3r::_3MF_Exporter::_add_model_file_to_archive(), and is_fdm_support_painted().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ is_fuzzy_skin_painted()

bool Slic3r::Model::is_fuzzy_skin_painted ( ) const
1238{
1239 return std::any_of(this->objects.cbegin(), this->objects.cend(), [](const ModelObject *mo) { return mo->is_fuzzy_skin_painted(); });
1240}

References is_fuzzy_skin_painted().

Referenced by is_fuzzy_skin_painted().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ is_mm_painted()

bool Slic3r::Model::is_mm_painted ( ) const
1233{
1234 return std::any_of(this->objects.cbegin(), this->objects.cend(), [](const ModelObject *mo) { return mo->is_mm_painted(); });
1235}

References is_mm_painted().

Referenced by Slic3r::_3MF_Exporter::_add_model_file_to_archive(), and is_mm_painted().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ is_need_backup()

bool Slic3r::Model::is_need_backup ( )
inline
1872{ return need_backup; }

References need_backup.

Referenced by Slic3r::_BBS_Backup_Manager::remove_backup().

Here is the caller graph for this function:

◆ is_seam_painted()

bool Slic3r::Model::is_seam_painted ( ) const
1228{
1229 return std::any_of(this->objects.cbegin(), this->objects.cend(), [](const ModelObject *mo) { return mo->is_seam_painted(); });
1230}

References is_seam_painted().

Referenced by Slic3r::_3MF_Exporter::_add_model_file_to_archive(), and is_seam_painted().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ load()

template<class Archive>
void Slic3r::Model::load ( Archive & ar)
inlineprivate
1897 {
1898 Internal::StaticSerializationWrapper<ModelWipeTower> wipe_tower_wrapper(wipe_tower);
1899 ar(materials, objects, wipe_tower_wrapper);
1900 }
ModelWipeTower wipe_tower
Definition Model.hpp:1704

References materials, objects, and wipe_tower.

◆ load_and_construct()

template<class Archive>
void Slic3r::ObjectBase::load_and_construct ( Archive & ar,
cereal::construct< ObjectBase > & construct )
inlinestaticprivateinherited
109{ ObjectID id; ar(id); construct(id); }

References id().

Here is the call graph for this function:

◆ load_from()

void Slic3r::Model::load_from ( Model & model)
1191{
1192 set_backup_path(model.get_backup_path());
1193 model.backup_path.clear();
1194 object_backup_id_map = model.object_backup_id_map;
1195 next_object_backup_id = model.next_object_backup_id;
1196 design_info = model.design_info;
1197 stl_design_id = model.stl_design_id;
1198 stl_design_country = model.stl_design_country;
1199 model_info = model.model_info;
1200 profile_info = model.profile_info;
1201 mk_name = model.mk_name;
1202 mk_version = model.mk_version;
1203 md_name = model.md_name;
1204 md_value = model.md_value;
1205 model.design_info.reset();
1206 model.model_info.reset();
1207 model.profile_info.reset();
1208 model.calib_pa_pattern.reset();
1209}
std::string stl_design_country
Definition Model.hpp:1711
std::shared_ptr< ModelDesignInfo > design_info
Definition Model.hpp:1712
std::string stl_design_id
Definition Model.hpp:1710
std::shared_ptr< ModelInfo > model_info
Definition Model.hpp:1713
std::shared_ptr< ModelProfileInfo > profile_info
Definition Model.hpp:1714
std::vector< std::string > md_value
Definition Model.hpp:1724
std::string mk_version
Definition Model.hpp:1722
std::vector< std::string > md_name
Definition Model.hpp:1723
std::string mk_name
Definition Model.hpp:1721
void set_backup_path(const std::string &path)
Definition Model.cpp:1174

References Model(), backup_path, calib_pa_pattern, design_info, get_backup_path(), load_from(), md_name, md_value, mk_name, mk_version, model_info, next_object_backup_id, object_backup_id_map, profile_info, set_backup_path(), stl_design_country, and stl_design_id.

Referenced by load_from(), and Slic3r::GUI::Plater::new_project().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ looks_like_imperial_units()

bool Slic3r::Model::looks_like_imperial_units ( ) const
979{
980 if (this->objects.size() == 0)
981 return false;
982
983 for (ModelObject* obj : this->objects)
984 if (obj->get_object_stl_stats().volume < volume_threshold_inches) {
985 if (!obj->is_cut())
986 return true;
987 bool all_cut_parts_look_like_imperial_units = true;
988 for (ModelObject* obj_other : this->objects) {
989 if (obj_other == obj)
990 continue;
991 if (obj_other->cut_id.is_equal(obj->cut_id) && obj_other->get_object_stl_stats().volume >= volume_threshold_inches) {
992 all_cut_parts_look_like_imperial_units = false;
993 break;
994 }
995 }
996 if (all_cut_parts_look_like_imperial_units)
997 return true;
998 }
999
1000 return false;
1001}

References looks_like_imperial_units(), and Slic3r::volume_threshold_inches.

Referenced by looks_like_imperial_units().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ looks_like_multipart_object()

bool Slic3r::Model::looks_like_multipart_object ( ) const
899{
900 if (this->objects.size() <= 1)
901 return false;
902 double zmin = std::numeric_limits<double>::max();
903 for (const ModelObject *obj : this->objects) {
904 if (obj->volumes.size() > 1 || obj->config.keys().size() > 1)
905 return false;
906
907 double zmin_this = obj->min_z();
908 if (zmin == std::numeric_limits<double>::max())
909 zmin = zmin_this;
910 else if (std::abs(zmin - zmin_this) > EPSILON)
911 // The Object don't share zmin.
912 return true;
913 }
914 return false;
915}

References EPSILON, and looks_like_multipart_object().

Referenced by looks_like_multipart_object().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ looks_like_saved_in_meters()

bool Slic3r::Model::looks_like_saved_in_meters ( ) const
1019{
1020 if (this->objects.size() == 0)
1021 return false;
1022
1023 for (ModelObject* obj : this->objects)
1024 if (obj->get_object_stl_stats().volume < volume_threshold_meters)
1025 return true;
1026
1027 return false;
1028}

References looks_like_saved_in_meters(), and Slic3r::volume_threshold_meters.

Referenced by looks_like_saved_in_meters().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ max_z()

double Slic3r::Model::max_z ( ) const
832{
833 double z = 0;
834 for (ModelObject *o : this->objects)
835 z = std::max(z, o->max_z());
836 return z;
837}

References max_z().

Referenced by max_z().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ mesh()

TriangleMesh Slic3r::Model::mesh ( ) const
873{
874 TriangleMesh mesh;
875 for (const ModelObject *o : this->objects)
876 mesh.merge(o->mesh());
877 return mesh;
878}

References mesh().

Referenced by add_object(), add_object(), Slic3r::GUI::GLModel::init_from_file(), Slic3r::GUI::ObjectList::load_modifier(), Slic3r::GUI::BedShapePanel::load_stl(), mesh(), Slic3r::store_drc(), Slic3r::store_obj(), and Slic3r::store_stl().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ obj_import_face_color_deal()

bool Slic3r::Model::obj_import_face_color_deal ( const std::vector< unsigned char > & face_filament_ids,
const unsigned char & first_extruder_id,
Model * model )
static
3427{
3428 if (face_filament_ids.size() == 0) { return false; }
3429 // 2.generate mmu_segmentation_facets
3430 if (model->objects.size() == 1) {
3431 auto obj = model->objects[0];
3432 obj->config.set("extruder", first_extruder_id);
3433 if (obj->volumes.size() == 1) {
3434 auto volume = obj->volumes[0];
3435 volume->config.set("extruder", first_extruder_id);
3436 auto face_count = volume->mesh().its.indices.size();
3437 volume->mmu_segmentation_facets.reset();
3438 volume->mmu_segmentation_facets.reserve(face_count);
3439 if (volume->mesh().its.indices.size() != face_filament_ids.size()) {
3440 return false;
3441 }
3442 for (size_t i = 0; i < volume->mesh().its.indices.size(); i++) {
3443 auto face = volume->mesh().its.indices[i];
3444 auto filament_id = face_filament_ids[i];
3445 if (filament_id < 1) {
3446 continue;
3447 }
3448 std::string result;
3449 get_real_filament_id(filament_id, result);
3450 volume->mmu_segmentation_facets.set_triangle_from_string(i, result);
3451 }
3452 return true;
3453 }
3454 }
3455 return false;
3456}
static void get_real_filament_id(const unsigned char &id, std::string &result)
Definition Model.cpp:3297

References Model(), Slic3r::get_real_filament_id(), obj_import_face_color_deal(), and objects.

Referenced by construct_assemble_list(), and obj_import_face_color_deal().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ obj_import_vertex_color_deal()

bool Slic3r::Model::obj_import_vertex_color_deal ( const std::vector< unsigned char > & vertex_filament_ids,
const unsigned char & first_extruder_id,
Model * model )
static
3307{
3308 if (vertex_filament_ids.size() == 0) {
3309 return false;
3310 }
3311 // 2.generate mmu_segmentation_facets
3312 if (model->objects.size() == 1 ) {
3313 auto obj = model->objects[0];
3314 obj->config.set("extruder", first_extruder_id);
3315 if (obj->volumes.size() == 1) {
3316 enum VertexColorCase {
3317 _3_SAME_COLOR,
3318 _3_DIFF_COLOR,
3319 _2_SAME_1_DIFF_COLOR,
3320 };
3321 auto calc_vertex_color_case = [](const unsigned char &c0, const unsigned char &c1, const unsigned char &c2, VertexColorCase &vertex_color_case,
3322 unsigned char &iso_index) {
3323 if (c0 == c1 && c1 == c2) {
3324 vertex_color_case = VertexColorCase::_3_SAME_COLOR;
3325 } else if (c0 != c1 && c1 != c2 && c0 != c2) {
3326 vertex_color_case = VertexColorCase::_3_DIFF_COLOR;
3327 } else if (c0 == c1) {
3328 vertex_color_case = _2_SAME_1_DIFF_COLOR;
3329 iso_index = 2;
3330 } else if (c1 == c2) {
3331 vertex_color_case = _2_SAME_1_DIFF_COLOR;
3332 iso_index = 0;
3333 } else if (c0 == c2) {
3334 vertex_color_case = _2_SAME_1_DIFF_COLOR;
3335 iso_index = 1;
3336 } else {
3337 std::cout << "error";
3338 }
3339 };
3340 auto calc_tri_area = [](const Vec3f &v0, const Vec3f &v1, const Vec3f &v2) {
3341 return std::abs((v0 - v1).cross(v0 - v2).norm()) / 2;
3342 };
3343 auto volume = obj->volumes[0];
3344 volume->config.set("extruder", first_extruder_id);
3345 auto face_count = volume->mesh().its.indices.size();
3346 volume->mmu_segmentation_facets.reset();
3347 volume->mmu_segmentation_facets.reserve(face_count);
3348 if (volume->mesh().its.vertices.size() != vertex_filament_ids.size()) {
3349 return false;
3350 }
3351 for (size_t i = 0; i < volume->mesh().its.indices.size(); i++) {
3352 auto face = volume->mesh().its.indices[i];
3353 auto filament_id0 = vertex_filament_ids[face[0]];
3354 auto filament_id1 = vertex_filament_ids[face[1]];
3355 auto filament_id2 = vertex_filament_ids[face[2]];
3356 if (filament_id0 <= 1 && filament_id1 <= 1 && filament_id2 <= 2) {
3357 continue;
3358 }
3359 VertexColorCase vertex_color_case;
3360 unsigned char iso_index;
3361 calc_vertex_color_case(filament_id0, filament_id1, filament_id2, vertex_color_case, iso_index);
3362 switch (vertex_color_case) {
3363 case _3_SAME_COLOR: {
3364 std::string result;
3365 get_real_filament_id(filament_id0, result);
3366 volume->mmu_segmentation_facets.set_triangle_from_string(i, result);
3367 break;
3368 }
3369 case _3_DIFF_COLOR: {
3370 std::string result0, result1, result2;
3371 get_real_filament_id(filament_id0, result0);
3372 get_real_filament_id(filament_id1, result1);
3373 get_real_filament_id(filament_id2, result2);
3374
3375 auto v0 = volume->mesh().its.vertices[face[0]];
3376 auto v1 = volume->mesh().its.vertices[face[1]];
3377 auto v2 = volume->mesh().its.vertices[face[2]];
3378 auto dir_0_1 = (v1 - v0).normalized().eval();
3379 auto dir_0_2 = (v2 - v0).normalized().eval();
3380 float sita0 = acos(dir_0_1.dot(dir_0_2));
3381 auto dir_1_0 = (-dir_0_1).eval();
3382 auto dir_1_2 = (v2 - v1).normalized().eval();
3383 float sita1 = acos(dir_1_0.dot(dir_1_2));
3384 float sita2 = PI - sita0 - sita1;
3385 std::array<float, 3> sitas = {sita0, sita1, sita2};
3386 float max_sita = sitas[0];
3387 int max_sita_vertex_index = 0;
3388 for (size_t j = 1; j < sitas.size(); j++) {
3389 if (sitas[j] > max_sita) {
3390 max_sita_vertex_index = j;
3391 max_sita = sitas[j];
3392 }
3393 }
3394 if (max_sita_vertex_index == 0) {
3395 volume->mmu_segmentation_facets.set_triangle_from_string(i, result0 + result1 + result2 + (result1 + result2 + "5" )+ "3"); //"1C0C2C0C1C13"
3396 } else if (max_sita_vertex_index == 1) {
3397 volume->mmu_segmentation_facets.set_triangle_from_string(i, result0 + result1 + result2 + (result0 + result2 + "9") + "3");
3398 } else{// if (max_sita_vertex_index == 2)
3399 volume->mmu_segmentation_facets.set_triangle_from_string(i, result0 + result1 + result2 + (result1 + result0 + "1") + "3");
3400 }
3401 break;
3402 }
3403 case _2_SAME_1_DIFF_COLOR: {
3404 std::string result0, result1, result2;
3405 get_real_filament_id(filament_id0, result0);
3406 get_real_filament_id(filament_id1, result1);
3407 get_real_filament_id(filament_id2, result2);
3408 if (iso_index == 0) {
3409 volume->mmu_segmentation_facets.set_triangle_from_string(i, result0 + result1 + result1 + "2");
3410 } else if (iso_index == 1) {
3411 volume->mmu_segmentation_facets.set_triangle_from_string(i, result1 + result0 + result0 + "6");
3412 } else if (iso_index == 2) {
3413 volume->mmu_segmentation_facets.set_triangle_from_string(i, result2 + result0 + result0 + "A");
3414 }
3415 break;
3416 }
3417 default: break;
3418 }
3419 }
3420 return true;
3421 }
3422 }
3423 return false;
3424}
static constexpr double PI
Definition libslic3r.h:81
Eigen::Matrix< float, 3, 1, Eigen::DontAlign > Vec3f
Definition Point.hpp:65
T cross(const boost::geometry::model::d2::point_xy< T > &v1, const boost::geometry::model::d2::point_xy< T > &v2)
Definition ExtrusionSimulator.cpp:168

References Model(), Slic3r::cross(), Slic3r::get_real_filament_id(), obj_import_vertex_color_deal(), objects, and PI.

Referenced by construct_assemble_list(), and obj_import_vertex_color_deal().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ operator=() [1/2]

Model & Slic3r::Model::operator= ( const Model & rhs)
inline
1761{ this->assign_copy(rhs); assert(this->id().valid()); assert(this->id() == rhs.id()); return *this; }

References Model(), and Slic3r::ObjectBase::id().

Here is the call graph for this function:

◆ operator=() [2/2]

Model & Slic3r::Model::operator= ( Model && rhs)
inline
1762{ this->assign_copy(std::move(rhs)); assert(this->id().valid()); assert(this->id() == rhs.id()); return *this; }

References Model().

Here is the call graph for this function:

◆ print_info()

void Slic3r::Model::print_info ( ) const
inline
1858{ for (const ModelObject *o : this->objects) o->print_info(); }

◆ propose_export_file_name_and_path() [1/2]

std::string Slic3r::Model::propose_export_file_name_and_path ( ) const
1081{
1082 std::string input_file;
1083 for (const ModelObject *model_object : this->objects)
1084 for (ModelInstance *model_instance : model_object->instances)
1085 if (model_instance->is_printable()) {
1086 input_file = model_object->get_export_filename();
1087
1088 if (!input_file.empty())
1089 goto end;
1090 // Other instances will produce the same name, skip them.
1091 break;
1092 }
1093end:
1094 return input_file;
1095}

References Slic3r::ModelInstance::is_printable(), and propose_export_file_name_and_path().

Referenced by Slic3r::CLI::output_filepath(), propose_export_file_name_and_path(), and propose_export_file_name_and_path().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ propose_export_file_name_and_path() [2/2]

std::string Slic3r::Model::propose_export_file_name_and_path ( const std::string & new_extension) const
1218{
1219 return boost::filesystem::path(this->propose_export_file_name_and_path()).replace_extension(new_extension).string();
1220}
std::string propose_export_file_name_and_path() const
Definition Model.cpp:1080

References propose_export_file_name_and_path().

Here is the call graph for this function:

◆ read_from_archive()

Model Slic3r::Model::read_from_archive ( const std::string & input_file,
DynamicPrintConfig * config,
ConfigSubstitutionContext * config_substitutions,
En3mfType & out_file_type,
LoadStrategy options = LoadStrategy::AddDefaultInstances,
PlateDataPtrs * plate_data = nullptr,
std::vector< Preset * > * project_presets = nullptr,
Semver * file_version = nullptr,
Import3mfProgressFn proFn = nullptr,
BBLProject * project = nullptr )
static
524{
525 assert(config != nullptr);
526 assert(config_substitutions != nullptr);
527
528 Model model;
529
530 bool result = false;
531 bool is_bbl_3mf = false;
532 bool is_orca_3mf = false;
533 if (boost::algorithm::iends_with(input_file, ".3mf")) {
534 PrusaFileParser prusa_file_parser;
535 if (prusa_file_parser.check_3mf_from_prusa(input_file)) {
536 // for Prusa 3mf
537 result = load_3mf(input_file.c_str(), *config, *config_substitutions, &model, true);
538 out_file_type = En3mfType::From_Prusa;
539 } else {
540 // BBS: add part plate related logic
541 // BBS: backup & restore
542 result = load_bbs_3mf(input_file.c_str(), config, config_substitutions, &model, plate_data, project_presets, &is_bbl_3mf, &is_orca_3mf, file_version, proFn, options, project);
543 }
544 }
545 else if (boost::algorithm::iends_with(input_file, ".zip.amf"))
546 result = load_amf(input_file.c_str(), config, config_substitutions, &model, &is_bbl_3mf);
547 else
548 throw Slic3r::RuntimeError(_L("Unknown file format: input file must have .3mf or .zip.amf extension."));
549
550 if (out_file_type != En3mfType::From_Prusa) {
551 if (is_orca_3mf)
552 out_file_type = En3mfType::From_Orca;
553 else
554 out_file_type = is_bbl_3mf ? En3mfType::From_BBS : En3mfType::From_Other;
555 }
556
557 if (!result)
558 throw Slic3r::RuntimeError(_L("Loading of a model file failed."));
559
560 for (ModelObject *o : model.objects) {
561// if (boost::algorithm::iends_with(input_file, ".zip.amf"))
562// {
563// // we remove the .zip part of the extension to avoid it be added to filenames when exporting
564// o->input_file = boost::ireplace_last_copy(input_file, ".zip.", ".");
565// }
566// else
567 o->input_file = input_file;
568 }
569
570 bool cb_cancel;
571 if (options & LoadStrategy::AddDefaultInstances) {
572 model.add_default_instances();
573 BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << ":" <<__LINE__ << boost::format("import 3mf IMPORT_STAGE_ADD_INSTANCE\n");
574 if (proFn) {
575 proFn(IMPORT_STAGE_ADD_INSTANCE, 0, 1, cb_cancel);
576 if (cb_cancel)
577 throw Slic3r::RuntimeError(_L("Canceled"));
578 }
579 }
580
581 //BBS
582 //CustomGCode::update_custom_gcode_per_print_z_from_config(model.custom_gcode_per_print_z, config);
583
584 BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << ":" << __LINE__ << boost::format("import 3mf IMPORT_STAGE_UPDATE_GCODE\n");
585 if (proFn) {
586 proFn(IMPORT_STAGE_UPDATE_GCODE, 0, 1, cb_cancel);
587 if (cb_cancel)
588 throw Slic3r::RuntimeError(_L("Canceled"));
589 }
590
591 //BBS
592 for (auto& plate_gcodes : model.plates_custom_gcodes)
594
595 BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << ":" << __LINE__ << boost::format("import 3mf IMPORT_STAGE_CHECK_MODE_GCODE\n");
596 if (proFn) {
597 proFn(IMPORT_STAGE_CHECK_MODE_GCODE, 0, 1, cb_cancel);
598 if (cb_cancel)
599 throw Slic3r::RuntimeError(_L("Canceled"));
600 }
601
602 handle_legacy_sla(*config);
603
604 return model;
605}
#define _L(s)
Definition OBJ.cpp:34
Model()
Definition Model.hpp:1753
void check_mode_for_custom_gcode_per_print_z(Info &info)
Definition CustomGCode.cpp:82
void handle_legacy_sla(DynamicPrintConfig &config)
Definition PrintConfig.cpp:10576
const int IMPORT_STAGE_ADD_INSTANCE
Definition bbs_3mf.hpp:266
bool load_3mf(const char *path, DynamicPrintConfig &config, ConfigSubstitutionContext &config_substitutions, Model *model, bool check_version)
Definition 3mf.cpp:3348
const int IMPORT_STAGE_UPDATE_GCODE
Definition bbs_3mf.hpp:267
bool load_amf(const char *path, DynamicPrintConfig *config, ConfigSubstitutionContext *config_substitutions, Model *model, bool *use_inches)
Definition AMF.cpp:1105
@ From_Prusa
Definition Model.hpp:754
@ From_Other
Definition Model.hpp:755
@ From_BBS
Definition Model.hpp:753
@ From_Orca
Definition Model.hpp:752
@ AddDefaultInstances
Definition bbs_3mf.hpp:220
const int IMPORT_STAGE_CHECK_MODE_GCODE
Definition bbs_3mf.hpp:268
bool load_bbs_3mf(const char *path, DynamicPrintConfig *config, ConfigSubstitutionContext *config_substitutions, Model *model, PlateDataPtrs *plate_data_list, std::vector< Preset * > *project_presets, bool *is_bbl_3mf, bool *is_orca_3mf, Semver *file_version, Import3mfProgressFn proFn, LoadStrategy strategy, BBLProject *project, int plate_id)
Definition bbs_3mf.cpp:9569

References Model(), _L, add_default_instances(), Slic3r::AddDefaultInstances, Slic3r::PrusaFileParser::check_3mf_from_prusa(), Slic3r::CustomGCode::check_mode_for_custom_gcode_per_print_z(), Slic3r::From_BBS, Slic3r::From_Orca, Slic3r::From_Other, Slic3r::From_Prusa, Slic3r::handle_legacy_sla(), Slic3r::IMPORT_STAGE_ADD_INSTANCE, Slic3r::IMPORT_STAGE_CHECK_MODE_GCODE, Slic3r::IMPORT_STAGE_UPDATE_GCODE, Slic3r::ModelObject::input_file, Slic3r::load_3mf(), Slic3r::load_amf(), Slic3r::load_bbs_3mf(), objects, plates_custom_gcodes, and read_from_archive().

Referenced by Slic3r::GUI::Plater::priv::load_files(), and read_from_archive().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ read_from_file()

Model Slic3r::Model::read_from_file ( const std::string & input_file,
DynamicPrintConfig * config = nullptr,
ConfigSubstitutionContext * config_substitutions = nullptr,
LoadStrategy options = LoadStrategy::AddDefaultInstances,
PlateDataPtrs * plate_data = nullptr,
std::vector< Preset * > * project_presets = nullptr,
bool * is_xxx = nullptr,
Semver * file_version = nullptr,
Import3mfProgressFn proFn = nullptr,
ImportstlProgressFn stlFn = nullptr,
BBLProject * project = nullptr,
int plate_id = 0 )
static
330{
331 Model model;
332
333 DynamicPrintConfig temp_config;
334 ConfigSubstitutionContext temp_config_substitutions_context(ForwardCompatibilitySubstitutionRule::EnableSilent);
335 if (config == nullptr)
336 config = &temp_config;
337 if (config_substitutions == nullptr)
338 config_substitutions = &temp_config_substitutions_context;
339 //BBS: plate_data
340 PlateDataPtrs temp_plate_data;
341 bool temp_is_xxx;
342 Semver temp_version;
343 if (plate_data == nullptr)
344 plate_data = &temp_plate_data;
345 if (is_xxx == nullptr)
346 is_xxx = &temp_is_xxx;
347 if (file_version == nullptr)
348 file_version = &temp_version;
349
350 bool result = false;
351 bool is_cb_cancel = false;
352 std::string message;
353 if (boost::algorithm::iends_with(input_file, ".stl"))
354 result = load_stl(input_file.c_str(), &model, nullptr, stlFn);
355 else if (boost::algorithm::iends_with(input_file, ".oltp"))
356 result = load_stl(input_file.c_str(), &model, nullptr, stlFn,256);
357 else if (boost::algorithm::iends_with(input_file, ".obj")) {
358 ObjInfo obj_info;
359 ObjParser::MtlData mtl_data;
360 result = load_obj(input_file.c_str(), &model, obj_info, message, nullptr, &mtl_data);
361 // Keep the model's own UV channel on the volume, whatever the colour import then does with
362 // the mesh: it is what TextureProjectionMethod::ModelUV maps a texture-displacement layer
363 // through, so a model that arrives with a UV layout is textured on that layout instead of on
364 // a fresh unwrap. load_obj() fills obj_info.uvs per face of the mesh it built, in the same
365 // order (and only when every face named a known material, hence the size check). V is flipped
366 // on the way in, to the convention DecodedHeightTexture samples in - the same flip
367 // obj_to_textured_mesh() does for the colour importer.
368 if (result && !obj_info.uvs.empty() && !model.objects.empty() && !model.objects.back()->volumes.empty()) {
369 ModelVolume &volume = *model.objects.back()->volumes[0];
370 const indexed_triangle_set &its = volume.mesh().its;
371 if (obj_info.uvs.size() == its.indices.size()) {
372 volume.texture_uv.resize(its.indices.size() * 3);
373 for (size_t fi = 0; fi < obj_info.uvs.size(); ++fi)
374 for (int k = 0; k < 3; ++k)
375 volume.texture_uv[fi * 3 + size_t(k)] =
376 Vec2f(obj_info.uvs[fi][size_t(k)].x(), 1.f - obj_info.uvs[fi][size_t(k)].y());
377 }
378 }
379 if (result && obj_info.has_uv_png && !obj_info.uvs.empty() && !model.objects.empty()) {
380 // Textured OBJ: hand the mesh + materials to the texture-to-color importer
381 // instead of the flat per-face colour dialog.
382 auto tex_mesh = std::make_shared<TexturedMesh>();
383 std::string obj_dir = boost::filesystem::path(input_file).parent_path().string();
384 if (obj_to_textured_mesh(obj_info,
385 model.objects.back()->volumes[0]->mesh().its,
386 mtl_data, obj_dir, *tex_mesh)) {
387 model.texture_mesh = tex_mesh;
388 }
389 }
390 else if (result && !model.objects.empty() && !model.objects.back()->volumes.empty()) {
391 // Vertex-colour and MTL face-colour OBJs also go through the texture-to-color
392 // importer (as precomputed per-face colors) instead of the flat
393 // per-face colour dialog, matching the uv_png branch above.
394 auto build_tex_mesh_geometry = [&]() {
395 auto tex_mesh = std::make_shared<TexturedMesh>();
396 const auto& its = model.objects.back()->volumes[0]->mesh().its;
397 tex_mesh->vertices.resize(its.vertices.size());
398 for (size_t i = 0; i < its.vertices.size(); ++i)
399 tex_mesh->vertices[i] = {its.vertices[i].x(), its.vertices[i].y(), its.vertices[i].z()};
400 tex_mesh->indices.resize(its.indices.size());
401 for (size_t i = 0; i < its.indices.size(); ++i)
402 tex_mesh->indices[i] = {its.indices[i][0], its.indices[i][1], its.indices[i][2]};
403 return tex_mesh;
404 };
405 if (obj_info.vertex_colors.size() > 0) {
406 auto tex_mesh = build_tex_mesh_geometry();
407 const auto& its = model.objects.back()->volumes[0]->mesh().its;
408 tex_mesh->precomputed_face_colors.resize(its.indices.size());
409 for (size_t i = 0; i < its.indices.size(); ++i) {
410 const auto& f = its.indices[i];
411 auto avg = [&](int ch) -> std::size_t {
412 float v = (obj_info.vertex_colors[f[0]][ch]
413 + obj_info.vertex_colors[f[1]][ch]
414 + obj_info.vertex_colors[f[2]][ch]) / 3.0f * 255.0f;
415 return (std::size_t) std::clamp(v, 0.0f, 255.0f);
416 };
417 tex_mesh->precomputed_face_colors[i] = {avg(0), avg(1), avg(2)};
418 }
419 tex_mesh->precomputed_vertex_colors = obj_info.vertex_colors;
420 model.texture_mesh = tex_mesh;
421 } else if (obj_info.face_colors.size() > 0 && obj_info.has_uv_png == false) {
422 auto tex_mesh = build_tex_mesh_geometry();
423 const size_t nf = tex_mesh->indices.size();
424 tex_mesh->precomputed_face_colors.resize(nf);
425 for (size_t i = 0; i < nf; ++i) {
426 if (i < obj_info.face_colors.size()) {
427 const auto& c = obj_info.face_colors[i];
428 tex_mesh->precomputed_face_colors[i] = {
429 (std::size_t) std::clamp(c[0] * 255.0f, 0.0f, 255.0f),
430 (std::size_t) std::clamp(c[1] * 255.0f, 0.0f, 255.0f),
431 (std::size_t) std::clamp(c[2] * 255.0f, 0.0f, 255.0f)
432 };
433 } else {
434 tex_mesh->precomputed_face_colors[i] = {128, 128, 128};
435 }
436 }
437 model.texture_mesh = tex_mesh;
438 }
439 }
440 }
441 else if (boost::algorithm::iends_with(input_file, ".glb") ||
442 boost::algorithm::iends_with(input_file, ".gltf") ||
443 boost::algorithm::iends_with(input_file, ".fbx")) {
444 // These formats can carry material/texture data, so they go through the textured
445 // import path: the geometry becomes a normal object and the texture is handed to the
446 // texture-to-color dialog via Model::texture_mesh.
447 auto tex_mesh = std::make_shared<TexturedMesh>();
448 result = load_assimp_textured_model(input_file, *tex_mesh, &message);
449 if (result) {
450 model.texture_mesh = tex_mesh;
451 add_textured_mesh_to_model(model, *tex_mesh, input_file);
452 } else if (!message.empty()) {
453 BOOST_LOG_TRIVIAL(error) << "Assimp: failed to load model: " << message
454 << ", path=" << input_file;
455 message = _L("The file format is incompatible and cannot be parsed.");
456 }
457 }
458 else if (boost::algorithm::iends_with(input_file, ".svg"))
459 result = load_svg(input_file.c_str(), &model, message);
460 //BBS: remove the old .amf.xml files
461 //else if (boost::algorithm::iends_with(input_file, ".amf") || boost::algorithm::iends_with(input_file, ".amf.xml"))
462 else if (boost::algorithm::iends_with(input_file, ".drc"))
463 result = load_drc(input_file.c_str(), &model);
464 else if (boost::algorithm::iends_with(input_file, ".amf"))
465 //BBS: is_xxx is used for is_inches when load amf
466 result = load_amf(input_file.c_str(), config, config_substitutions, &model, is_xxx);
467 else if (boost::algorithm::iends_with(input_file, ".3mf"))
468 //BBS: add part plate related logic
469 // BBS: backup & restore
470 //FIXME options & LoadStrategy::CheckVersion ?
471 //BBS: is_xxx is used for is_bbs_3mf when load 3mf
472 result = load_bbs_3mf(input_file.c_str(), config, config_substitutions, &model, plate_data, project_presets, is_xxx, nullptr, file_version, proFn, options, project, plate_id);
473#ifdef __APPLE__
474 else if (boost::algorithm::iends_with(input_file, ".usd") || boost::algorithm::iends_with(input_file, ".usda") ||
475 boost::algorithm::iends_with(input_file, ".usdc") || boost::algorithm::iends_with(input_file, ".usdz") ||
476 boost::algorithm::iends_with(input_file, ".abc") || boost::algorithm::iends_with(input_file, ".ply")) {
477 std::string temp_stl = make_temp_stl_with_modelio(input_file);
478 if (temp_stl.empty()) {
479 throw Slic3r::RuntimeError(_L("Failed to convert asset to STL via ModelIO."));
480 }
481 result = load_stl(temp_stl.c_str(), &model);
482 delete_temp_file(temp_stl);
483 }
484#endif
485 else
486 throw Slic3r::RuntimeError(_L("Unknown file format: input file must have .stl, .obj, or .amf(.xml) extension."));
487
488 if (is_cb_cancel) {
489 Model empty_model;
490 return empty_model;
491 }
492
493 if (!result) {
494 if (message.empty())
495 throw Slic3r::RuntimeError(_L("Loading of a model file failed."));
496 else
497 throw Slic3r::RuntimeError(message);
498 }
499
500 if (model.objects.empty())
501 throw Slic3r::RuntimeError(_L("The supplied file couldn\'t be read because it\'s empty."));
502
503 for (ModelObject *o : model.objects)
504 o->input_file = input_file;
505
507 model.add_default_instances();
508
509 //BBS
510 //CustomGCode::update_custom_gcode_per_print_z_from_config(model.custom_gcode_per_print_z, config);
511 //BBS
512 for (auto& plate_gcodes : model.plates_custom_gcodes)
514
515 sort_remove_duplicates(config_substitutions->substitutions);
516 return model;
517}
std::vector< PlateData * > PlateDataPtrs
Definition bbs_3mf.hpp:278
@ EnableSilent
Definition Config.hpp:247
bool load_svg(const char *path, Model *model, std::string &message)
Definition svg.cpp:309
std::string make_temp_stl_with_modelio(const std::string &input_file)
Definition ModelIO.mm:6
static void add_textured_mesh_to_model(Model &model, const TexturedMesh &tex_mesh, const std::string &input_file)
Definition Model.cpp:299
bool load_obj(const char *path, TriangleMesh *meshptr, ObjInfo &obj_info, std::string &message, ObjParser::MtlData *out_mtl)
Definition OBJ.cpp:38
bool load_drc(const char *path, TriangleMesh *meshptr)
Definition DRC.cpp:39
bool load_assimp_textured_model(const std::string &path, TexturedMesh &out, std::string *error_message)
Definition AssimpImport.cpp:281
static double f(double x, double z_sin, double z_cos, bool vertical, bool flip)
Definition FillGyroid.cpp:124
void sort_remove_duplicates(std::vector< T > &vec)
Definition libslic3r.h:231
bool obj_to_textured_mesh(const ObjInfo &obj_info, const indexed_triangle_set &its, const ObjParser::MtlData &mtl_data, const std::string &obj_directory, TexturedMesh &out)
Definition OBJ.cpp:262
Eigen::Matrix< float, 2, 1, Eigen::DontAlign > Vec2f
Definition Point.hpp:64
void delete_temp_file(const std::string &temp_file)
Definition ModelIO.mm:21
bool load_stl(const char *path, Model *model, const char *object_name_in, ImportstlProgressFn stlFn, int custom_header_length)
Definition STL.cpp:18

References Model(), Slic3r::EnableSilent, Slic3r::f(), Slic3r::ObjInfo::has_uv_png, Slic3r::TriangleMesh::its, Slic3r::load_obj(), Slic3r::load_stl(), Slic3r::ModelVolume::mesh(), Slic3r::obj_to_textured_mesh(), objects, texture_mesh, Slic3r::ModelVolume::texture_uv, and Slic3r::ObjInfo::uvs.

Referenced by Slic3r::GUI::GLModel::init_from_file(), Slic3r::GUI::Plater::priv::load_files(), Slic3r::GUI::ObjectList::load_modifier(), Slic3r::GUI::BedShapePanel::load_stl(), Slic3r::GUI::read_model_from_file(), Slic3r::GUI::Plater::priv::reload_from_disk(), Slic3r::GUI::Plater::priv::replace_volume_with_stl(), and Slic3r::CLI::run().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ read_from_step()

Model Slic3r::Model::read_from_step ( const std::string & input_file,
LoadStrategy options,
ImportStepProgressFn stepFn,
StepIsUtf8Fn stepIsUtf8Fn,
std::function< int(Slic3r::Step &, double &, double &, bool &)> step_mesh_fn,
double linear_deflection,
double angle_deflection,
bool is_split_compound )
static
248{
249 Model model;
250 bool result = false;
251 bool is_cb_cancel = false;
252 Step::Step_Status status;
253 Step step_file(input_file, stepFn);
254 status = step_file.load();
255 if(status != Step::Step_Status::LOAD_SUCCESS) {
256 goto _finished;
257 }
258 if (step_mesh_fn) {
259 if (step_mesh_fn(step_file, linear_deflection, angle_deflection, is_split_compound) == -1) {
261 goto _finished;
262 }
263 }
264
265 status = step_file.mesh(&model, is_cb_cancel, is_split_compound, linear_deflection, angle_deflection);
266
267_finished:
268
269 switch (status){
271 Model empty_model;
272 return empty_model;
273 }
275 throw Slic3r::RuntimeError(_L("Loading of a model file failed."));
277 throw Slic3r::RuntimeError(_L("Meshing of a model file failed or no valid shape."));
278 default:
279 break;
280 }
281
282 if (model.objects.empty())
283 throw Slic3r::RuntimeError(_L("The supplied file couldn\'t be read because it\'s empty."));
284
285 for (ModelObject *o : model.objects)
286 o->input_file = input_file;
287
289 model.add_default_instances();
290
291 return model;
292}
Step_Status
Definition STEP.hpp:99
@ CANCEL
Definition STEP.hpp:102
@ MESH_ERROR
Definition STEP.hpp:104
@ LOAD_SUCCESS
Definition STEP.hpp:100
@ LOAD_ERROR
Definition STEP.hpp:101

References Model(), _L, add_default_instances(), Slic3r::AddDefaultInstances, Slic3r::Step::CANCEL, Slic3r::ModelObject::input_file, Slic3r::Step::load(), Slic3r::Step::LOAD_ERROR, Slic3r::Step::LOAD_SUCCESS, Slic3r::Step::mesh(), Slic3r::Step::MESH_ERROR, and objects.

Referenced by Slic3r::GUI::Plater::priv::load_files(), Slic3r::GUI::ObjectList::load_modifier(), Slic3r::GUI::Plater::priv::reload_from_disk(), and Slic3r::GUI::Plater::priv::replace_volume_with_stl().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ remove_backup_path_if_exist()

void Slic3r::Model::remove_backup_path_if_exist ( )
1148{
1149 if (!backup_path.empty()) {
1150 boost::filesystem::path temp_path(backup_path);
1151 if (boost::filesystem::exists(temp_path))
1152 {
1153 BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format("model %1%, id %2% remove backup_path %3%")%this%this->id().id%backup_path;
1154 boost::filesystem::remove_all(temp_path);
1155 }
1156 backup_path.clear();
1157 }
1158}

References backup_path, Slic3r::ObjectBase::id(), and remove_backup_path_if_exist().

Referenced by remove_backup_path_if_exist().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ removed_objects_with_zero_volume()

int Slic3r::Model::removed_objects_with_zero_volume ( )
1046{
1047 if (objects.size() == 0)
1048 return 0;
1049
1050 int removed = 0;
1051 for (int i = int(objects.size()) - 1; i >= 0; i--)
1052 if (objects[i]->get_object_stl_stats().volume < zero_volume) {
1053 delete_object(size_t(i));
1054 removed++;
1055 }
1056 return removed;
1057}
void delete_object(size_t idx)
Definition Model.cpp:672
static constexpr const double zero_volume
Definition Model.cpp:1043

References delete_object(), objects, removed_objects_with_zero_volume(), and Slic3r::zero_volume.

Referenced by removed_objects_with_zero_volume().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ save()

template<class Archive>
void Slic3r::Model::save ( Archive & ar) const
inlineprivate
1901 {
1902 Internal::StaticSerializationWrapper<ModelWipeTower const> wipe_tower_wrapper(wipe_tower);
1903 ar(materials, objects, wipe_tower_wrapper);
1904 }

References materials, objects, and wipe_tower.

◆ serialize()

template<class Archive>
void Slic3r::ObjectBase::serialize ( Archive & ar)
inlineprivateinherited
108{ ar(m_id); }

References m_id.

◆ set_backup_path()

void Slic3r::Model::set_backup_path ( const std::string & path)
1175{
1176 if (backup_path == path)
1177 return;
1178 if ("detach" == path) {
1179 backup_path.clear();
1180 return;
1181 }
1182 if (!backup_path.empty()) {
1183 BOOST_LOG_TRIVIAL(info) << __FUNCTION__<<boost::format(", model %1%, id %2%, remove previous backup %3%")%this%this->id().id%backup_path;
1184 Slic3r::remove_backup(*this, true);
1185 }
1186 backup_path = path;
1187 BOOST_LOG_TRIVIAL(info) << __FUNCTION__<<boost::format(", model %1%, id %2%, set backup to %3%")%this%this->id().id%backup_path;
1188}

References backup_path, Slic3r::ObjectBase::id(), Slic3r::remove_backup(), and set_backup_path().

Referenced by load_from(), Slic3r::_BBS_3MF_Importer::load_model_from_file(), Slic3r::CLI::run(), and set_backup_path().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ set_invalid_id()

void Slic3r::ObjectBase::set_invalid_id ( )
inlineprotectedinherited
90{ m_id = 0; }

References m_id.

Referenced by Slic3r::CutObjectBase::invalidate().

Here is the caller graph for this function:

◆ set_need_backup()

void Slic3r::Model::set_need_backup ( )
1213{
1214 need_backup = true;
1215}

References need_backup, and set_need_backup().

Referenced by set_need_backup().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ set_new_unique_id()

void Slic3r::ObjectBase::set_new_unique_id ( )
inlineprotectedinherited
89{ m_id = generate_new_id(); }
static ObjectID generate_new_id()
Definition ObjectID.hpp:100

References generate_new_id(), and m_id.

Referenced by Slic3r::ModelVolume::ModelVolume(), Slic3r::Model::assign_new_unique_ids_recursive(), Slic3r::ModelVolume::assign_new_unique_ids_recursive(), assign_new_unique_ids_recursive(), Slic3r::CutObjectBase::init(), Slic3r::ModelMaterial::set_new_unique_id(), Slic3r::ModelObject::set_new_unique_id(), and Slic3r::ModelVolume::set_new_unique_id().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ set_object_backup_id()

void Slic3r::Model::set_object_backup_id ( ModelObject const & object,
int uuid )
748{
749 object_backup_id_map[object.id().id] = uuid;
750 if (uuid >= next_object_backup_id) next_object_backup_id = uuid + 1;
751}

References next_object_backup_id, object_backup_id_map, and set_object_backup_id().

Referenced by set_object_backup_id().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SetDesigner()

void Slic3r::Model::SetDesigner ( std::string designer,
std::string designer_user_id )
inline
1730 {
1731 if (design_info == nullptr) {
1732 design_info = std::make_shared<ModelDesignInfo>();
1733 }
1734 design_info->Designer = designer;
1735 //BBS tips: clean design user id when set designer
1736 design_info->DesignerUserId = designer_user_id;
1737 }

References design_info.

◆ setExtruderParams()

void Slic3r::Model::setExtruderParams ( const DynamicPrintConfig & config,
int extruders_count )
static
3267 {
3268 extruderParamsMap.clear();
3269 //Slic3r::DynamicPrintConfig config = wxGetApp().preset_bundle->full_config();
3270 // BBS
3271 //int numExtruders = wxGetApp().preset_bundle->filament_presets.size();
3272 for (unsigned int i = 0; i != extruders_count; ++i) {
3273 std::string matName = "";
3274 // BBS
3275 int bedTemp = 35;
3276 double endTemp = 0.f;
3277 if (config.has("filament_type")) {
3278 matName = config.opt_string("filament_type", i);
3279 }
3280 if (config.has("nozzle_temperature")) {
3281 endTemp = config.opt_int("nozzle_temperature", i);
3282 }
3283
3284 // FIXME: curr_bed_type is now a plate config rather than a global config.
3285 // Currently bed temp is not used for brim generation, so just comment it for now.
3286#if 0
3287 if (config.has("curr_bed_type")) {
3288 BedType curr_bed_type = config.opt_enum<BedType>("curr_bed_type");
3289 bedTemp = config.opt_int(get_bed_temp_key(curr_bed_type), i);
3290 }
3291#endif
3292 if (i == 0) extruderParamsMap.insert({ i,{matName, bedTemp, endTemp} });
3293 extruderParamsMap.insert({ i + 1,{matName, bedTemp, endTemp} });
3294 }
3295}
static std::string get_bed_temp_key(const BedType type)
Definition PrintConfig.hpp:732
BedType
Definition PrintConfig.hpp:507
zaa_minimize_perimeter_height curr_bed_type((ConfigOptionInts, cool_plate_temp))((ConfigOptionInts

References Slic3r::curr_bed_type(), extruderParamsMap, Slic3r::get_bed_temp_key(), Slic3r::ConfigOptionResolver::has(), Slic3r::DynamicConfig::opt_enum(), Slic3r::DynamicConfig::opt_int(), Slic3r::DynamicConfig::opt_string(), and setExtruderParams().

Referenced by Slic3r::GUI::has_filaments(), Slic3r::GUI::Plater::priv::on_action_slice_all(), Slic3r::GUI::Plater::priv::on_action_slice_plate(), Slic3r::GUI::ArrangeJob::prepare(), Slic3r::CLI::run(), Slic3r::GUI::Plater::priv::select_view_3D(), and setExtruderParams().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setPrintSpeedTable()

void Slic3r::Model::setPrintSpeedTable ( const DynamicPrintConfig & config,
const PrintConfig & print_config )
static
3209 {
3210 //Slic3r::DynamicPrintConfig config = wxGetApp().preset_bundle->full_config();
3211 printSpeedMap.maxSpeed = 0;
3212 if (config.has("inner_wall_speed")) {
3213 printSpeedMap.perimeterSpeed = config.opt_float_nullable("inner_wall_speed", 0);
3214 if (printSpeedMap.perimeterSpeed > printSpeedMap.maxSpeed)
3215 printSpeedMap.maxSpeed = printSpeedMap.perimeterSpeed;
3216 }
3217 if (config.has("outer_wall_speed")) {
3218 printSpeedMap.externalPerimeterSpeed = config.opt_float_nullable("outer_wall_speed", 0);
3219 printSpeedMap.maxSpeed = std::max(printSpeedMap.maxSpeed, printSpeedMap.externalPerimeterSpeed);
3220 }
3221 if (config.has("sparse_infill_speed")) {
3222 printSpeedMap.infillSpeed = config.opt_float_nullable("sparse_infill_speed", 0);
3223 if (printSpeedMap.infillSpeed > printSpeedMap.maxSpeed)
3224 printSpeedMap.maxSpeed = printSpeedMap.infillSpeed;
3225 }
3226 if (config.has("internal_solid_infill_speed")) {
3227 printSpeedMap.solidInfillSpeed = config.opt_float_nullable("internal_solid_infill_speed", 0);
3228 if (printSpeedMap.solidInfillSpeed > printSpeedMap.maxSpeed)
3229 printSpeedMap.maxSpeed = printSpeedMap.solidInfillSpeed;
3230 }
3231 if (config.has("top_surface_speed")) {
3232 printSpeedMap.topSolidInfillSpeed = config.opt_float_nullable("top_surface_speed", 0);
3233 if (printSpeedMap.topSolidInfillSpeed > printSpeedMap.maxSpeed)
3234 printSpeedMap.maxSpeed = printSpeedMap.topSolidInfillSpeed;
3235 }
3236 if (config.has("support_speed")) {
3237 printSpeedMap.supportSpeed = config.opt_float_nullable("support_speed", 0);
3238
3239 if (printSpeedMap.supportSpeed > printSpeedMap.maxSpeed)
3240 printSpeedMap.maxSpeed = printSpeedMap.supportSpeed;
3241 }
3242
3243
3244 //auto& print = wxGetApp().plater()->get_partplate_list().get_current_fff_print();
3245 //auto print_config = print.config();
3246 //printSpeedMap.bed_poly.points = get_bed_shape(*(wxGetApp().plater()->config()));
3247 printSpeedMap.bed_poly.points = get_bed_shape(config);
3248 // Collision volumes are additive to the legacy bed keep-out. Preserve the
3249 // established printable-bed polygon so bed-edge and legacy-area brim
3250 // clipping continue to work when collision volumes are also configured.
3251 Pointfs excluse_area_points = print_config.bed_exclude_area.values;
3252 Polygons exclude_polys;
3253 Polygon exclude_poly;
3254 for (int i = 0; i < excluse_area_points.size(); i++) {
3255 auto pt = excluse_area_points[i];
3256 exclude_poly.points.emplace_back(scale_(pt.x()), scale_(pt.y()));
3257 if (i % 4 == 3) { // exclude areas are always rectangle
3258 exclude_polys.push_back(exclude_poly);
3259 exclude_poly.points.clear();
3260 }
3261 }
3262 if (!exclude_polys.empty())
3263 printSpeedMap.bed_poly = diff({ printSpeedMap.bed_poly }, exclude_polys)[0];
3264}
#define scale_(val)
Definition libslic3r.h:106
std::vector< Vec2d > Pointfs
Definition Point.hpp:77
std::vector< Polygon, PointsAllocator< Polygon > > Polygons
Definition Polygon.hpp:22
Slic3r::Polygons diff(const Slic3r::Polygon &subject, const Slic3r::Polygon &clip, ApplySafetyOffset do_safety_offset)
Definition ClipperUtils.cpp:731
Points get_bed_shape(const DynamicPrintConfig &config, bool use_share)
Definition PrintConfig.cpp:13837
Slic3r::Polygon Polygon
Definition Emboss.cpp:101

References Slic3r::diff(), Slic3r::get_bed_shape(), Slic3r::ConfigOptionResolver::has(), Slic3r::DynamicConfig::opt_float_nullable(), Slic3r::MultiPoint::points, printSpeedMap, scale_, and setPrintSpeedTable().

Referenced by Slic3r::GUI::Plater::priv::on_action_slice_all(), Slic3r::GUI::Plater::priv::on_action_slice_plate(), Slic3r::GUI::ArrangeJob::prepare(), Slic3r::CLI::run(), Slic3r::GUI::Plater::priv::select_view_3D(), and setPrintSpeedTable().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ timestamp()

virtual Timestamp Slic3r::ObjectBase::timestamp ( ) const
inlinevirtualinherited

Reimplemented in Slic3r::ModelConfigObject, and Slic3r::ObjectWithTimestamp.

74{ return 0; }

◆ translate()

void Slic3r::Model::translate ( coordf_t x,
coordf_t y,
coordf_t z )
inline
1841{ for (ModelObject *o : this->objects) o->translate(x, y, z); }

◆ update_links_bottom_up_recursive()

void Slic3r::Model::update_links_bottom_up_recursive ( )
private
219{
220 for (std::pair<const t_model_material_id, ModelMaterial*> &kvp : this->materials)
221 kvp.second->set_model(this);
222 for (ModelObject *model_object : this->objects) {
223 model_object->set_model(this);
224 for (ModelInstance *model_instance : model_object->instances)
225 model_instance->set_model_object(model_object);
226 for (ModelVolume *model_volume : model_object->volumes)
227 model_volume->set_model_object(model_object);
228 }
229}

References Slic3r::ModelInstance::set_model_object(), and Slic3r::ModelVolume::set_model_object().

Referenced by Slic3r::UndoRedo::StackImpl::load_snapshot().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ update_print_volume_state()

unsigned int Slic3r::Model::update_print_volume_state ( const BuildVolume & build_volume)
840{
841 unsigned int num_printable = 0;
842 for (ModelObject* model_object : this->objects)
843 num_printable += model_object->update_instances_print_volume_state(build_volume);
844 //BBS: add logs for build_volume
845 const BoundingBoxf3& print_volume = build_volume.bounding_volume();
846 BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(", print_volume {%1%, %2%, %3%} to {%4%, %5%, %6%}, got %7% printable istances") %print_volume.min.x() %print_volume.min.y() %print_volume.min.z()%print_volume.max.x() %print_volume.max.y() %print_volume.max.z() %num_printable;
847 return num_printable;
848}

References Slic3r::BuildVolume::bounding_volume(), Slic3r::BoundingBoxBase< PointType, std::vector< PointType > >::max, Slic3r::BoundingBoxBase< PointType, std::vector< PointType > >::min, and update_print_volume_state().

Referenced by Slic3r::GUI::CalibUtils::process_and_store_3mf(), Slic3r::CLI::run(), and update_print_volume_state().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ cereal::access

friend class cereal::access
friend

References cereal::access.

Referenced by cereal::access.

◆ UndoRedo::StackImpl

friend class UndoRedo::StackImpl
friend

Member Data Documentation

◆ backup_path

std::string Slic3r::Model::backup_path
private

◆ cad_recipe

std::string Slic3r::Model::cad_recipe

◆ calib_pa_pattern

◆ curr_plate_index

◆ design_info

◆ extruderParamsMap

◆ m_id

ObjectID Slic3r::ObjectBase::m_id
privateinherited

◆ materials

◆ md_name

std::vector<std::string> Slic3r::Model::md_name

◆ md_value

std::vector<std::string> Slic3r::Model::md_value

◆ mk_name

std::string Slic3r::Model::mk_name

◆ mk_version

std::string Slic3r::Model::mk_version

◆ model_info

◆ need_backup

bool Slic3r::Model::need_backup = false
private

◆ next_object_backup_id

int Slic3r::Model::next_object_backup_id = 1
private

◆ object_backup_id_map

std::map<int, int> Slic3r::Model::object_backup_id_map
private

◆ objects

ModelObjectPtrs Slic3r::Model::objects

Referenced by Slic3r::GUI::anonymous_namespace{Plater.cpp}::SvgArchivePathsRestorer::SvgArchivePathsRestorer(), Slic3r::_BBS_3MF_Exporter::_add_brim_ear_points_file_to_archive(), Slic3r::_BBS_3MF_Exporter::_add_cut_information_file_to_archive(), Slic3r::_3MF_Exporter::_add_layer_config_ranges_file_to_archive(), Slic3r::_BBS_3MF_Exporter::_add_layer_config_ranges_file_to_archive(), Slic3r::_3MF_Exporter::_add_layer_height_profile_file_to_archive(), Slic3r::_BBS_3MF_Exporter::_add_layer_height_profile_file_to_archive(), Slic3r::_BBS_3MF_Exporter::_add_model_config_file_to_archive(), Slic3r::_3MF_Exporter::_add_model_file_to_archive(), Slic3r::_BBS_3MF_Exporter::_add_model_file_to_archive(), Slic3r::_3MF_Exporter::_add_sla_drain_holes_file_to_archive(), Slic3r::_3MF_Exporter::_add_sla_support_points_file_to_archive(), Slic3r::_BBS_3MF_Exporter::_add_slice_info_config_file_to_archive(), Slic3r::GUI::Plater::_calib_apply_belt_mode(), Slic3r::GUI::Plater::_calib_pa_pattern(), Slic3r::GUI::Plater::_calib_pa_tower(), Slic3r::GUI::Plater::_calib_temp_belt_sectioned(), Slic3r::_3MF_Importer::_load_model_from_file(), Slic3r::GUI::Plater::priv::actualize_object_warnings(), adjust_min_z(), Slic3r::GUI::MenuFactory::append_menu_item_edit_svg(), Slic3r::GUI::MenuFactory::append_menu_item_edit_text(), Slic3r::GUI::Plater::priv::apply_textured_mesh_import_result(), Slic3r::GUI::belt_calib_flip_ringing_tower(), Slic3r::GUI::calc_angle(), Slic3r::GUI::calc_distance(), Slic3r::GUI::calc_surface_offset(), Slic3r::GUI::GLGizmoSVG::calculate_scale(), Slic3r::GUI::Plater::Calib_Cornering(), Slic3r::GUI::CalibUtils::calib_flowrate(), Slic3r::GUI::Plater::calib_input_shaping_damp(), Slic3r::GUI::Plater::calib_input_shaping_freq(), Slic3r::GUI::CalibUtils::calib_max_vol_speed(), Slic3r::GUI::Plater::calib_max_vol_speed(), Slic3r::GUI::CalibUtils::calib_pa_pattern(), Slic3r::GUI::CalibUtils::calib_retraction(), Slic3r::GUI::Plater::calib_retraction(), Slic3r::GUI::Plater::calib_temp(), Slic3r::GUI::CalibUtils::calib_temptue(), Slic3r::GUI::CalibUtils::calib_VFA(), Slic3r::GUI::Plater::calib_VFA(), Slic3r::GUI::Plater::changed_mesh(), Slic3r::check_model_ids_equal(), Slic3r::check_model_ids_validity(), Slic3r::GLVolumeCollection::check_outside_state(), Slic3r::GUI::Plater::clear_before_change_mesh(), Slic3r::GUI::ArrangeJob::clear_input(), Slic3r::GUI::OrientJob::clear_input(), collect_reusable_objects(), construct_assemble_list(), Slic3r::_BBS_3MF_Exporter::convert_instance_id_to_resource_id(), Slic3r::GUI::create_meshes(), Slic3r::GUI::cut_model(), Slic3r::GUI::GLGizmoFlatten::data_changed(), delete_object(), delete_object(), Slic3r::GUI::do_local_z_rotate(), anonymous_namespace{SurfaceDrag.cpp}::dragging(), Slic3r::duplicate(), Slic3r::duplicate_objects(), Slic3r::GUI::PartPlateList::duplicate_plate(), Slic3r::GUI::ensure_belt_purge_tower(), Slic3r::GUI::face_selected_volume_to_camera(), anonymous_namespace{EmbossJob.cpp}::CreateObjectJob::finalize(), Slic3r::get_arrange_poly(), Slic3r::get_arrange_polys(), Slic3r::GUI::GLGizmoCut3D::get_cut_matrix(), anonymous_namespace{SurfaceDrag.cpp}::get_fix_transformation(), Slic3r::GUI::GLGizmoAlignment::get_items_count(), Slic3r::GUI::get_model_instance(), Slic3r::GUI::get_model_object(), Slic3r::GUI::get_model_volume(), Slic3r::GUI::get_model_volume(), Slic3r::GUI::GLGizmoAlignment::get_parent_box(), Slic3r::GUI::GLGizmoAlignment::get_selected_objects_info(), Slic3r::GUI::GLGizmoAlignment::get_selected_part_volumes(), Slic3r::GUI::Selection::get_selected_single_object(), Slic3r::GUI::Selection::get_selected_single_volume(), Slic3r::GUI::get_selected_volume(), Slic3r::GUI::get_selected_volume(), Slic3r::GUI::get_volume(), Slic3r::GUI::GLGizmoMeasure::init_plane_glmodel(), anonymous_namespace{GLGizmoEmboss.cpp}::init_text_lines(), Slic3r::MeshInspect::inspect_to_json(), Slic3r::PaintCLI::inspect_to_json(), Slic3r::GUI::Plater::is_empty_project(), load(), Slic3r::load_amf_archive(), Slic3r::load_amf_file(), Slic3r::GUI::Tab::load_current_preset(), Slic3r::GUI::ObjectList::load_mesh_object(), Slic3r::GUI::ObjectList::load_modifier(), Slic3r::GUI::GLCanvas3D::load_object(), Slic3r::load_svg(), main(), Slic3r::Step::mesh(), Slic3r::model_has_advanced_features(), Slic3r::model_has_multi_part_objects(), Slic3r::GUI::GLCanvas3D::CenterOfMass::model_markers(), Slic3r::model_object_list_equal(), Slic3r::model_object_list_extended(), obj_import_face_color_deal(), obj_import_vertex_color_deal(), Slic3r::GUI::Plater::priv::on_process_completed(), Slic3r::GUI::GLGizmoBrimEars::on_render(), Slic3r::GUI::GLGizmoEmboss::on_render(), Slic3r::GUI::Plater::priv::on_right_click(), Slic3r::GUI::CommonGizmosDataObjects::SelectionInfo::on_update(), Slic3r::GUI::Plater::open_3mf_file(), Slic3r::Cut::perform_with_groove(), Slic3r::GUI::FillBedJob::prepare(), Slic3r::GUI::ArrangeJob::prepare_all(), Slic3r::GUI::ArrangeJob::prepare_partplate(), Slic3r::GUI::OrientJob::prepare_partplate(), Slic3r::GUI::ArrangeJob::prepare_selected(), Slic3r::GUI::OrientJob::prepare_selected(), Slic3r::GUI::OrientJob::prepare_selection(), Slic3r::GUI::CalibUtils::process_and_store_3mf(), Slic3r::GUI::GLGizmoCut3D::process_contours(), Slic3r::GUI::anonymous_namespace{PublishSettingsDialog.cpp}::project_used_filament_slots(), Slic3r::GUI::anonymous_namespace{Plater.cpp}::publish(), read_from_archive(), read_from_file(), read_from_step(), Slic3r::GUI::read_model_from_file(), Slic3r::GUI::GLGizmoMeasure::register_single_mesh_pick(), Slic3r::GUI::Plater::priv::reload_from_disk(), Slic3r::remap_model_filament_slots(), removed_objects_with_zero_volume(), Slic3r::GUI::GLCanvas3D::Labels::render(), Slic3r::GUI::Plater::priv::replace_volume_with_stl(), Slic3r::CLI::run(), Slic3r::GUI::Plater::priv::run_textured_mesh_import_dialog(), save(), Slic3r::GUI::GLCanvas3D::LayersEditing::select_object(), Slic3r::GUI::Plater::priv::set_current_panel(), Slic3r::GUI::CalibUtils::set_for_auto_pa_model_and_config(), Slic3r::GUI::GLGizmoSVG::set_volume_by_selection(), Slic3r::GUI::ObjectList::set_volume_type(), Slic3r::GUI::Plater::show_object_info(), Slic3r::sort_object_instances_by_model_order(), Slic3r::GUI::Plater::priv::split_object(), anonymous_namespace{EmbossJob.cpp}::start_create_volume_on_surface_job(), Slic3r::GUI::Emboss::start_create_volume_without_position(), anonymous_namespace{SurfaceDrag.cpp}::start_dragging(), Slic3r::GUI::synchronize_model_after_cut(), Slic3r::GUI::GLGizmoCut3D::toggle_model_objects_visibility(), Slic3r::GUI::ObjectGridTable::update_value_to_object(), Slic3r::GUI::verify_instances_rotation_synchronized(), and Slic3r::GUI::world_matrix_fixed().

◆ plates_custom_gcodes

◆ printSpeedMap

GlobalSpeedMap Slic3r::Model::printSpeedMap {}
static

◆ profile_info

std::shared_ptr<ModelProfileInfo> Slic3r::Model::profile_info = nullptr

◆ s_last_id

size_t Slic3r::ObjectBase::s_last_id = 0
staticprivateinherited

Referenced by generate_new_id().

◆ stl_design_country

std::string Slic3r::Model::stl_design_country

Referenced by load_from().

◆ stl_design_id

std::string Slic3r::Model::stl_design_id

Referenced by load_from().

◆ texture_mesh

◆ wipe_tower

ModelWipeTower Slic3r::Model::wipe_tower

Referenced by load(), and save().


The documentation for this class was generated from the following files:
  • /home/runner/work/OrcaSlicer/OrcaSlicer/src/libslic3r/Model.hpp
  • /home/runner/work/OrcaSlicer/OrcaSlicer/src/libslic3r/Model.cpp