Prusa Slicer 2.6.0
Loading...
Searching...
No Matches
Slic3r::ModelObject Class Referencefinal

#include <src/libslic3r/Model.hpp>

+ Inheritance diagram for Slic3r::ModelObject:
+ Collaboration diagram for Slic3r::ModelObject:

Public Types

using Timestamp = uint64_t
 

Public Member Functions

Modelget_model ()
 
const Modelget_model () const
 
ModelVolumeadd_volume (const TriangleMesh &mesh)
 
ModelVolumeadd_volume (TriangleMesh &&mesh, ModelVolumeType type=ModelVolumeType::MODEL_PART)
 
ModelVolumeadd_volume (const ModelVolume &volume, ModelVolumeType type=ModelVolumeType::INVALID)
 
ModelVolumeadd_volume (const ModelVolume &volume, TriangleMesh &&mesh)
 
void delete_volume (size_t idx)
 
void clear_volumes ()
 
void sort_volumes (bool full_sort)
 
bool is_multiparts () const
 
bool is_fdm_support_painted () const
 
bool is_seam_painted () const
 
bool is_mm_painted () const
 
bool is_text () const
 
bool has_custom_layering () const
 
ModelInstanceadd_instance ()
 
ModelInstanceadd_instance (const ModelInstance &instance)
 
ModelInstanceadd_instance (const Geometry::Transformation &trafo)
 
void delete_instance (size_t idx)
 
void delete_last_instance ()
 
void clear_instances ()
 
const BoundingBoxf3bounding_box_approx () const
 
const BoundingBoxf3bounding_box_exact () const
 
double min_z () const
 
double max_z () const
 
void invalidate_bounding_box ()
 
TriangleMesh mesh () const
 
TriangleMesh raw_mesh () const
 
indexed_triangle_set raw_indexed_triangle_set () const
 
const BoundingBoxf3raw_bounding_box () const
 
BoundingBoxf3 instance_bounding_box (size_t instance_idx, bool dont_translate=false) const
 
const BoundingBoxf3raw_mesh_bounding_box () const
 
BoundingBoxf3 full_raw_mesh_bounding_box () const
 
Polygon convex_hull_2d (const Transform3d &trafo_instance) const
 
void center_around_origin (bool include_modifiers=true)
 
void ensure_on_bed (bool allow_negative_z=false)
 
void translate_instances (const Vec3d &vector)
 
void translate_instance (size_t instance_idx, const Vec3d &vector)
 
void translate (const Vec3d &vector)
 
void translate (double x, double y, double z)
 
void scale (const Vec3d &versor)
 
void scale (const double s)
 
void scale (double x, double y, double z)
 
void scale_to_fit (const Vec3d &size)
 Scale the current ModelObject to fit by altering the scaling factor of ModelInstances. It operates on the total size by duplicating the object according to all the instances.
 
void rotate (double angle, Axis axis)
 
void rotate (double angle, const Vec3d &axis)
 
void mirror (Axis axis)
 
void scale_mesh_after_creation (const float scale)
 
void convert_units (ModelObjectPtrs &new_objects, ConversionType conv_type, std::vector< int > volume_idxs)
 
size_t materials_count () const
 
size_t facets_count () const
 
size_t parts_count () const
 
void apply_cut_connectors (const std::string &name)
 
void invalidate_cut ()
 
void delete_connectors ()
 
void clone_for_cut (ModelObject **obj)
 
ModelObjectPtrs cut (size_t instance, const Transform3d &cut_matrix, ModelObjectCutAttributes attributes)
 
void split (ModelObjectPtrs *new_objects)
 
void merge ()
 
void bake_xy_rotation_into_meshes (size_t instance_idx)
 
double get_instance_min_z (size_t instance_idx) const
 
double get_instance_max_z (size_t instance_idx) const
 
void print_info () const
 
std::string get_export_filename () const
 
TriangleMeshStats get_object_stl_stats () const
 
int get_repaired_errors_count (const int vol_idx=-1) const
 
bool has_solid_mesh () const
 
bool has_negative_volume_mesh () const
 
bool has_sla_drain_holes () const
 
bool is_cut () const
 
bool has_connectors () const
 
ObjectID id () const
 
virtual Timestamp timestamp () const
 

Static Public Member Functions

static indexed_triangle_set get_connector_mesh (CutConnectorAttributes connector_attributes)
 
static void reset_instance_transformation (ModelObject *object, size_t src_instance_idx, const Transform3d &cut_matrix, bool place_on_cut=false, bool flip=false)
 

Public Attributes

std::string name
 
std::string input_file
 
ModelInstancePtrs instances
 
ModelVolumePtrs volumes
 
ModelConfigObject config
 
t_layer_config_ranges layer_config_ranges
 
LayerHeightProfile layer_height_profile
 
bool printable { true }
 
sla::SupportPoints sla_support_points
 
sla::PointsStatus sla_points_status = sla::PointsStatus::NoPoints
 
sla::DrainHoles sla_drain_holes
 
CutConnectors cut_connectors
 
CutObjectBase cut_id
 
Vec3d origin_translation
 

Protected Member Functions

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

Private Member Functions

void process_connector_cut (ModelVolume *volume, const Transform3d &instance_matrix, const Transform3d &cut_matrix, ModelObjectCutAttributes attributes, ModelObject *upper, ModelObject *lower, std::vector< ModelObject * > &dowels)
 
void process_modifier_cut (ModelVolume *volume, const Transform3d &instance_matrix, const Transform3d &inverse_cut_matrix, ModelObjectCutAttributes attributes, ModelObject *upper, ModelObject *lower)
 
void process_volume_cut (ModelVolume *volume, const Transform3d &instance_matrix, const Transform3d &cut_matrix, ModelObjectCutAttributes attributes, TriangleMesh &upper_mesh, TriangleMesh &lower_mesh)
 
void process_solid_part_cut (ModelVolume *volume, const Transform3d &instance_matrix, const Transform3d &cut_matrix, ModelObjectCutAttributes attributes, ModelObject *upper, ModelObject *lower)
 
 ModelObject (Model *model)
 
 ModelObject (int)
 
 ~ModelObject ()
 
void assign_new_unique_ids_recursive () override
 
 ModelObject (const ModelObject &rhs)
 
 ModelObject (ModelObject &&rhs)
 
ModelObjectoperator= (const ModelObject &rhs)
 
ModelObjectoperator= (ModelObject &&rhs)
 
void set_new_unique_id ()
 
void copy_transformation_caches (const ModelObject &src)
 
void set_model (Model *model)
 
 ModelObject ()
 
template<class Archive >
void serialize (Archive &ar)
 
unsigned int update_instances_print_volume_state (const BuildVolume &build_volume)
 
void update_min_max_z ()
 

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

Modelm_model { nullptr }
 
BoundingBoxf3 m_bounding_box_approx
 
bool m_bounding_box_approx_valid { false }
 
BoundingBoxf3 m_bounding_box_exact
 
bool m_bounding_box_exact_valid { false }
 
bool m_min_max_z_valid { false }
 
BoundingBoxf3 m_raw_bounding_box
 
bool m_raw_bounding_box_valid { false }
 
BoundingBoxf3 m_raw_mesh_bounding_box
 
bool m_raw_mesh_bounding_box_valid { false }
 
ObjectID m_id
 

Static Private Attributes

static size_t s_last_id = 0
 

Friends

class Model
 
class Print
 
class SLAPrint
 
class cereal::access
 
class UndoRedo::StackImpl
 

Detailed Description

Member Typedef Documentation

◆ Timestamp

Constructor & Destructor Documentation

◆ ModelObject() [1/5]

Slic3r::ModelObject::ModelObject ( Model model)
inlineexplicitprivate
520 : m_model(model), origin_translation(Vec3d::Zero())
521 {
522 assert(this->id().valid());
523 assert(this->config.id().valid());
524 assert(this->layer_height_profile.id().valid());
525 }
ModelConfigObject config
Definition Model.hpp:339
Model * m_model
Definition Model.hpp:604
Vec3d origin_translation
Definition Model.hpp:367
LayerHeightProfile layer_height_profile
Definition Model.hpp:344
ObjectID id() const
Definition ObjectID.hpp:55
bool valid() const
Definition ObjectID.hpp:34

References Slic3r::ObjectBase::id(), and Slic3r::ObjectID::valid().

+ Here is the call graph for this function:

◆ ModelObject() [2/5]

Slic3r::ModelObject::ModelObject ( int  )
inlineexplicitprivate
526 : ObjectBase(-1), config(-1), layer_height_profile(-1), origin_translation(Vec3d::Zero())
527 {
528 assert(this->id().invalid());
529 assert(this->config.id().invalid());
530 assert(this->layer_height_profile.id().invalid());
531 }
ObjectBase()
Definition ObjectID.hpp:65
bool invalid() const
Definition ObjectID.hpp:35

References Slic3r::ObjectBase::id(), and Slic3r::ObjectID::invalid().

+ Here is the call graph for this function:

◆ ~ModelObject()

Slic3r::ModelObject::~ModelObject ( )
private
623{
624 this->clear_volumes();
625 this->clear_instances();
626}
void clear_volumes()
Definition Model.cpp:782
void clear_instances()
Definition Model.cpp:862

References clear_instances(), and clear_volumes().

+ Here is the call graph for this function:

◆ ModelObject() [3/5]

Slic3r::ModelObject::ModelObject ( const ModelObject rhs)
inlineprivate
537 : ObjectBase(-1), config(-1), layer_height_profile(-1), m_model(rhs.m_model) {
538 assert(this->id().invalid());
539 assert(this->config.id().invalid());
540 assert(this->layer_height_profile.id().invalid());
541 assert(rhs.id() != rhs.config.id());
542 assert(rhs.id() != rhs.layer_height_profile.id());
543 this->assign_copy(rhs);
544 assert(this->id().valid());
545 assert(this->config.id().valid());
546 assert(this->layer_height_profile.id().valid());
547 assert(this->id() != this->config.id());
548 assert(this->id() != this->layer_height_profile.id());
549 assert(this->id() == rhs.id());
550 assert(this->config.id() == rhs.config.id());
551 assert(this->layer_height_profile.id() == rhs.layer_height_profile.id());
552 }
size_t id
Definition ObjectID.hpp:37

References config, Slic3r::ObjectBase::id(), Slic3r::ObjectID::invalid(), layer_height_profile, and Slic3r::ObjectID::valid().

+ Here is the call graph for this function:

◆ ModelObject() [4/5]

Slic3r::ModelObject::ModelObject ( ModelObject &&  rhs)
inlineexplicitprivate
553 : ObjectBase(-1), config(-1), layer_height_profile(-1) {
554 assert(this->id().invalid());
555 assert(this->config.id().invalid());
556 assert(this->layer_height_profile.id().invalid());
557 assert(rhs.id() != rhs.config.id());
558 assert(rhs.id() != rhs.layer_height_profile.id());
559 this->assign_copy(std::move(rhs));
560 assert(this->id().valid());
561 assert(this->config.id().valid());
562 assert(this->layer_height_profile.id().valid());
563 assert(this->id() != this->config.id());
564 assert(this->id() != this->layer_height_profile.id());
565 assert(this->id() == rhs.id());
566 assert(this->config.id() == rhs.config.id());
567 assert(this->layer_height_profile.id() == rhs.layer_height_profile.id());
568 }

References Slic3r::ObjectID::id, Slic3r::ObjectBase::id(), Slic3r::ObjectID::invalid(), and Slic3r::ObjectID::valid().

+ Here is the call graph for this function:

◆ ModelObject() [5/5]

Slic3r::ModelObject::ModelObject ( )
inlineprivate
639 :
641 assert(this->id().invalid());
642 assert(this->config.id().invalid());
643 assert(this->layer_height_profile.id().invalid());
644 }

References Slic3r::ObjectBase::id(), and Slic3r::ObjectID::invalid().

+ Here is the call graph for this function:

Member Function Documentation

◆ add_instance() [1/3]

ModelInstance * Slic3r::ModelObject::add_instance ( )
827{
828 ModelInstance* i = new ModelInstance(this);
829 this->instances.push_back(i);
831 return i;
832}
ModelInstancePtrs instances
Definition Model.hpp:334
void invalidate_bounding_box()
Definition Model.hpp:409

References instances, and invalidate_bounding_box().

Referenced by Slic3r::_3MF_Importer::_load_model_from_file(), add_instance(), Slic3r::GUI::Selection::copy_to_clipboard(), Slic3r::GUI::Plater::increase_instances(), Slic3r::GUI::ObjectList::load_mesh_object(), Slic3r::GUI::ObjectList::merge(), Slic3r::GUI::FillBedJob::prepare(), and split().

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

◆ add_instance() [2/3]

ModelInstance * Slic3r::ModelObject::add_instance ( const Geometry::Transformation trafo)
843{
844 ModelInstance* instance = add_instance();
845 instance->set_transformation(trafo);
846 return instance;
847}
ModelInstance * add_instance()
Definition Model.cpp:826

References add_instance(), and Slic3r::ModelInstance::set_transformation().

+ Here is the call graph for this function:

◆ add_instance() [3/3]

ModelInstance * Slic3r::ModelObject::add_instance ( const ModelInstance instance)
835{
836 ModelInstance* i = new ModelInstance(this, other);
837 this->instances.push_back(i);
839 return i;
840}

References instances, and invalidate_bounding_box().

+ Here is the call graph for this function:

◆ add_volume() [1/4]

ModelVolume * Slic3r::ModelObject::add_volume ( const ModelVolume volume,
ModelVolumeType  type = ModelVolumeType::INVALID 
)
736{
737 ModelVolume* v = new ModelVolume(this, other);
738 if (type != ModelVolumeType::INVALID && v->type() != type)
739 v->set_type(type);
740 v->cut_info = other.cut_info;
741 this->volumes.push_back(v);
742 // The volume should already be centered at this point of time when copying shared pointers of the triangle mesh and convex hull.
743// v->center_geometry_after_creation();
744// this->invalidate_bounding_box();
745 return v;
746}
ModelVolumePtrs volumes
Definition Model.hpp:337

References Slic3r::ModelVolume::cut_info, Slic3r::INVALID, Slic3r::ModelVolume::set_type(), Slic3r::ModelVolume::type(), and volumes.

+ Here is the call graph for this function:

◆ add_volume() [2/4]

ModelVolume * Slic3r::ModelObject::add_volume ( const ModelVolume volume,
TriangleMesh &&  mesh 
)
749{
750 ModelVolume* v = new ModelVolume(this, other, std::move(mesh));
751 this->volumes.push_back(v);
752 v->center_geometry_after_creation();
754 return v;
755}
TriangleMesh mesh() const
Definition Model.cpp:941

References Slic3r::ModelVolume::center_geometry_after_creation(), invalidate_bounding_box(), mesh(), and volumes.

+ Here is the call graph for this function:

◆ add_volume() [3/4]

ModelVolume * Slic3r::ModelObject::add_volume ( const TriangleMesh mesh)

◆ add_volume() [4/4]

ModelVolume * Slic3r::ModelObject::add_volume ( TriangleMesh &&  mesh,
ModelVolumeType  type = ModelVolumeType::MODEL_PART 
)
727{
728 ModelVolume* v = new ModelVolume(this, std::move(mesh), type);
729 this->volumes.push_back(v);
730 v->center_geometry_after_creation();
732 return v;
733}

References Slic3r::ModelVolume::center_geometry_after_creation(), invalidate_bounding_box(), mesh(), and volumes.

+ Here is the call graph for this function:

◆ apply_cut_connectors()

void Slic3r::ModelObject::apply_cut_connectors ( const std::string &  name)
1316{
1317 if (cut_connectors.empty())
1318 return;
1319
1320 using namespace Geometry;
1321
1322 size_t connector_id = cut_id.connectors_cnt();
1323 for (const CutConnector& connector : cut_connectors) {
1324 TriangleMesh mesh = TriangleMesh(get_connector_mesh(connector.attribs));
1325 // Mesh will be centered when loading.
1326 ModelVolume* new_volume = add_volume(std::move(mesh), ModelVolumeType::NEGATIVE_VOLUME);
1327
1328 // Transform the new modifier to be aligned inside the instance
1329 new_volume->set_transformation(translation_transform(connector.pos) * connector.rotation_m *
1330 scale_transform(Vec3f(connector.radius, connector.radius, connector.height).cast<double>()));
1331
1332 new_volume->cut_info = { connector.attribs.type, connector.radius_tolerance, connector.height_tolerance };
1333 new_volume->name = new_name + "-" + std::to_string(++connector_id);
1334 }
1336
1337 // delete all connectors
1338 cut_connectors.clear();
1339}
void increase_connectors_cnt(size_t connectors_cnt)
Definition ObjectID.hpp:182
size_t connectors_cnt() const
Definition ObjectID.hpp:181
CutObjectBase cut_id
Definition Model.hpp:361
CutConnectors cut_connectors
Definition Model.hpp:360
ModelVolume * add_volume(const TriangleMesh &mesh)
Definition Model.cpp:717
static indexed_triangle_set get_connector_mesh(CutConnectorAttributes connector_attributes)
Definition Model.cpp:1283
void translation_transform(Transform3d &transform, const Vec3d &translation)
Definition Geometry.cpp:328
void scale_transform(Transform3d &transform, double scale)
Definition Geometry.cpp:354
Eigen::Matrix< float, 3, 1, Eigen::DontAlign > Vec3f
Definition Point.hpp:49

References Slic3r::ModelVolume::cut_info, Slic3r::ModelVolume::name, Slic3r::ModelVolume::CutInfo::radius_tolerance, and Slic3r::ModelVolume::set_transformation().

Referenced by Slic3r::GUI::GLGizmoCut3D::apply_connectors_in_model().

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

◆ assign_new_unique_ids_recursive()

void Slic3r::ModelObject::assign_new_unique_ids_recursive ( )
overrideprivatevirtual

Reimplemented from Slic3r::ObjectBase.

701{
702 this->set_new_unique_id();
703 for (ModelVolume *model_volume : this->volumes)
704 model_volume->assign_new_unique_ids_recursive();
705 for (ModelInstance *model_instance : this->instances)
706 model_instance->assign_new_unique_ids_recursive();
708}
void set_new_unique_id()
Definition Model.hpp:595
void assign_new_unique_ids_recursive() override
Definition Model.cpp:700
void set_new_unique_id()
Definition ObjectID.hpp:73

References instances, layer_height_profile, set_new_unique_id(), Slic3r::ObjectBase::set_new_unique_id(), and volumes.

+ Here is the call graph for this function:

◆ bake_xy_rotation_into_meshes()

void Slic3r::ModelObject::bake_xy_rotation_into_meshes ( size_t  instance_idx)
1792{
1793 assert(instance_idx < this->instances.size());
1794
1795 const Geometry::Transformation reference_trafo = this->instances[instance_idx]->get_transformation();
1796 bool left_handed = reference_trafo.is_left_handed();
1797 bool has_mirrorring = ! reference_trafo.get_mirror().isApprox(Vec3d(1., 1., 1.));
1798 bool uniform_scaling = std::abs(reference_trafo.get_scaling_factor().x() - reference_trafo.get_scaling_factor().y()) < EPSILON &&
1799 std::abs(reference_trafo.get_scaling_factor().x() - reference_trafo.get_scaling_factor().z()) < EPSILON;
1800 double new_scaling_factor = uniform_scaling ? reference_trafo.get_scaling_factor().x() : 1.;
1801
1802 // Adjust the instances.
1803 for (size_t i = 0; i < this->instances.size(); ++ i) {
1804 ModelInstance &model_instance = *this->instances[i];
1805 model_instance.set_rotation(Vec3d(0., 0., Geometry::rotation_diff_z(reference_trafo.get_matrix(), model_instance.get_matrix())));
1806 model_instance.set_scaling_factor(Vec3d(new_scaling_factor, new_scaling_factor, new_scaling_factor));
1807 model_instance.set_mirror(Vec3d(1., 1., 1.));
1808 }
1809
1810 // Adjust the meshes.
1811 // Transformation to be applied to the meshes.
1812 Geometry::Transformation reference_trafo_mod = reference_trafo;
1813 reference_trafo_mod.reset_offset();
1814 if (uniform_scaling)
1815 reference_trafo_mod.reset_scaling_factor();
1816 if (!has_mirrorring)
1817 reference_trafo_mod.reset_mirror();
1818 Eigen::Matrix3d mesh_trafo_3x3 = reference_trafo_mod.get_matrix().matrix().block<3, 3>(0, 0);
1819 Transform3d volume_offset_correction = this->instances[instance_idx]->get_transformation().get_matrix().inverse() * reference_trafo.get_matrix();
1820 for (ModelVolume *model_volume : this->volumes) {
1821 const Geometry::Transformation volume_trafo = model_volume->get_transformation();
1822 bool volume_left_handed = volume_trafo.is_left_handed();
1823 bool volume_has_mirrorring = ! volume_trafo.get_mirror().isApprox(Vec3d(1., 1., 1.));
1824 bool volume_uniform_scaling = std::abs(volume_trafo.get_scaling_factor().x() - volume_trafo.get_scaling_factor().y()) < EPSILON &&
1825 std::abs(volume_trafo.get_scaling_factor().x() - volume_trafo.get_scaling_factor().z()) < EPSILON;
1826 double volume_new_scaling_factor = volume_uniform_scaling ? volume_trafo.get_scaling_factor().x() : 1.;
1827 // Transform the mesh.
1828 Geometry::Transformation volume_trafo_mod = volume_trafo;
1829 volume_trafo_mod.reset_offset();
1830 if (volume_uniform_scaling)
1831 volume_trafo_mod.reset_scaling_factor();
1832 if (!volume_has_mirrorring)
1833 volume_trafo_mod.reset_mirror();
1834 Eigen::Matrix3d volume_trafo_3x3 = volume_trafo_mod.get_matrix().matrix().block<3, 3>(0, 0);
1835 // Following method creates a new shared_ptr<TriangleMesh>
1836 model_volume->transform_this_mesh(mesh_trafo_3x3 * volume_trafo_3x3, left_handed != volume_left_handed);
1837 // Reset the rotation, scaling and mirroring.
1838 model_volume->set_rotation(Vec3d(0., 0., 0.));
1839 model_volume->set_scaling_factor(Vec3d(volume_new_scaling_factor, volume_new_scaling_factor, volume_new_scaling_factor));
1840 model_volume->set_mirror(Vec3d(1., 1., 1.));
1841 // Move the reference point of the volume to compensate for the change of the instance trafo.
1842 model_volume->set_offset(volume_offset_correction * volume_trafo.get_offset());
1843 // reset the source to disable reload from disk
1844 model_volume->source = ModelVolume::Source();
1845 }
1846
1848}
static constexpr double EPSILON
Definition libslic3r.h:51
double rotation_diff_z(const Transform3d &trafo_from, const Transform3d &trafo_to)
Definition Geometry.cpp:712
Eigen::Transform< double, 3, Eigen::Affine, Eigen::DontAlign > Transform3d
Definition Point.hpp:81
Eigen::Matrix< double, 3, 1, Eigen::DontAlign > Vec3d
Definition Point.hpp:52

References EPSILON, Slic3r::Geometry::Transformation::get_matrix(), Slic3r::ModelInstance::get_matrix(), Slic3r::Geometry::Transformation::get_mirror(), Slic3r::Geometry::Transformation::get_offset(), Slic3r::Geometry::Transformation::get_scaling_factor(), Eigen::Transform< _Scalar, _Dim, _Mode, _Options >::inverse(), Slic3r::Geometry::Transformation::is_left_handed(), Eigen::Transform< _Scalar, _Dim, _Mode, _Options >::matrix(), Slic3r::Geometry::Transformation::reset_mirror(), Slic3r::Geometry::Transformation::reset_offset(), Slic3r::Geometry::Transformation::reset_scaling_factor(), Slic3r::ModelInstance::set_mirror(), Slic3r::ModelInstance::set_rotation(), and Slic3r::ModelInstance::set_scaling_factor().

+ Here is the call graph for this function:

◆ bounding_box_approx()

const BoundingBoxf3 & Slic3r::ModelObject::bounding_box_approx ( ) const
873{
876 BoundingBoxf3 raw_bbox = this->raw_mesh_bounding_box();
878 for (const ModelInstance *i : this->instances)
879 m_bounding_box_approx.merge(i->transform_bounding_box(raw_bbox));
880 }
882}
void reset()
Definition BoundingBox.hpp:34
BoundingBoxf3 m_bounding_box_approx
Definition Model.hpp:607
bool m_bounding_box_approx_valid
Definition Model.hpp:608
void merge()
Definition Model.cpp:1767
const BoundingBoxf3 & raw_mesh_bounding_box() const
Definition Model.cpp:1002

References instances, m_bounding_box_approx, m_bounding_box_approx_valid, Slic3r::BoundingBox3Base< PointType >::merge(), raw_mesh_bounding_box(), and Slic3r::BoundingBoxBase< PointType, APointsType >::reset().

+ Here is the call graph for this function:

◆ bounding_box_exact()

const BoundingBoxf3 & Slic3r::ModelObject::bounding_box_exact ( ) const
887{
890 m_min_max_z_valid = true;
892 for (size_t i = 0; i < this->instances.size(); ++ i)
893 m_bounding_box_exact.merge(this->instance_bounding_box(i));
894 }
896}
void merge(const PointType &point)
Definition BoundingBox.cpp:105
bool m_bounding_box_exact_valid
Definition Model.hpp:610
bool m_min_max_z_valid
Definition Model.hpp:611
BoundingBoxf3 m_bounding_box_exact
Definition Model.hpp:609

References instances, m_bounding_box_exact, m_bounding_box_exact_valid, m_min_max_z_valid, Slic3r::BoundingBox3Base< PointType >::merge(), and Slic3r::BoundingBoxBase< PointType, APointsType >::reset().

+ Here is the call graph for this function:

◆ center_around_origin()

void Slic3r::ModelObject::center_around_origin ( bool  include_modifiers = true)
1075{
1076 // calculate the displacements needed to
1077 // center this object around the origin
1078 const BoundingBoxf3 bb = include_modifiers ? full_raw_mesh_bounding_box() : raw_mesh_bounding_box();
1079
1080 // Shift is the vector from the center of the bounding box to the origin
1081 const Vec3d shift = -bb.center();
1082
1083 this->translate(shift);
1084 this->origin_translation += shift;
1085}
void translate(const Vec3d &vector)
Definition Model.hpp:444
BoundingBoxf3 full_raw_mesh_bounding_box() const
Definition Model.cpp:1014

References Slic3r::BoundingBox3Base< PointType >::center().

Referenced by Slic3r::GUI::ObjectList::merge().

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

◆ clear_instances()

void Slic3r::ModelObject::clear_instances ( )
863{
864 for (ModelInstance *i : this->instances)
865 delete i;
866 this->instances.clear();
868}

References instances, and invalidate_bounding_box().

Referenced by ~ModelObject(), Slic3r::_3MF_Importer::_load_model_from_file(), Slic3r::Print::apply(), and Slic3r::SLAPrint::apply().

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

◆ clear_volumes()

void Slic3r::ModelObject::clear_volumes ( )
783{
784 for (ModelVolume *v : this->volumes)
785 delete v;
786 this->volumes.clear();
788}

References invalidate_bounding_box(), and volumes.

Referenced by ~ModelObject(), and convert_units().

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

◆ clone_for_cut()

void Slic3r::ModelObject::clone_for_cut ( ModelObject **  obj)
1357{
1358 (*obj) = ModelObject::new_clone(*this);
1359 (*obj)->set_model(this->get_model());
1360 (*obj)->sla_support_points.clear();
1361 (*obj)->sla_drain_holes.clear();
1362 (*obj)->sla_points_status = sla::PointsStatus::NoPoints;
1363 (*obj)->clear_volumes();
1364 (*obj)->input_file.clear();
1365}
Model * get_model()
Definition Model.hpp:369

Referenced by Slic3r::GUI::GLGizmoCut3D::perform_cut().

+ Here is the caller graph for this function:

◆ convert_units()

void Slic3r::ModelObject::convert_units ( ModelObjectPtrs new_objects,
ConversionType  conv_type,
std::vector< int >  volume_idxs 
)
1183{
1184 BOOST_LOG_TRIVIAL(trace) << "ModelObject::convert_units - start";
1185
1186 ModelObject* new_object = new_clone(*this);
1187
1188 float koef = conv_type == ConversionType::CONV_FROM_INCH ? 25.4f : conv_type == ConversionType::CONV_TO_INCH ? 0.0393700787f :
1189 conv_type == ConversionType::CONV_FROM_METER ? 1000.f : conv_type == ConversionType::CONV_TO_METER ? 0.001f : 1.f;
1190
1191 new_object->set_model(nullptr);
1192 new_object->sla_support_points.clear();
1193 new_object->sla_drain_holes.clear();
1194 new_object->sla_points_status = sla::PointsStatus::NoPoints;
1195 new_object->clear_volumes();
1196 new_object->input_file.clear();
1197
1198 int vol_idx = 0;
1199 for (ModelVolume* volume : volumes) {
1200 if (!volume->mesh().empty()) {
1201 TriangleMesh mesh(volume->mesh());
1202
1203 ModelVolume* vol = new_object->add_volume(mesh);
1204 vol->name = volume->name;
1205 vol->set_type(volume->type());
1206 // Don't copy the config's ID.
1207 vol->config.assign_config(volume->config);
1208 assert(vol->config.id().valid());
1209 assert(vol->config.id() != volume->config.id());
1210 vol->set_material(volume->material_id(), *volume->material());
1211 vol->source.input_file = volume->source.input_file;
1212 vol->source.object_idx = (int)new_objects.size();
1213 vol->source.volume_idx = vol_idx;
1214 vol->source.is_converted_from_inches = volume->source.is_converted_from_inches;
1215 vol->source.is_converted_from_meters = volume->source.is_converted_from_meters;
1216 vol->source.is_from_builtin_objects = volume->source.is_from_builtin_objects;
1217
1218 vol->supported_facets.assign(volume->supported_facets);
1219 vol->seam_facets.assign(volume->seam_facets);
1220 vol->mmu_segmentation_facets.assign(volume->mmu_segmentation_facets);
1221
1222 // Perform conversion only if the target "imperial" state is different from the current one.
1223 // This check supports conversion of "mixed" set of volumes, each with different "imperial" state.
1224 if (//vol->source.is_converted_from_inches != from_imperial &&
1225 (volume_idxs.empty() ||
1226 std::find(volume_idxs.begin(), volume_idxs.end(), vol_idx) != volume_idxs.end())) {
1227 vol->scale_geometry_after_creation(koef);
1228 vol->set_offset(Vec3d(koef, koef, koef).cwiseProduct(volume->get_offset()));
1229 if (conv_type == ConversionType::CONV_FROM_INCH || conv_type == ConversionType::CONV_TO_INCH)
1230 vol->source.is_converted_from_inches = conv_type == ConversionType::CONV_FROM_INCH;
1231 if (conv_type == ConversionType::CONV_FROM_METER || conv_type == ConversionType::CONV_TO_METER)
1232 vol->source.is_converted_from_meters = conv_type == ConversionType::CONV_FROM_METER;
1233 assert(! vol->source.is_converted_from_inches || ! vol->source.is_converted_from_meters);
1234 }
1235 else
1236 vol->set_offset(volume->get_offset());
1237 }
1238 vol_idx ++;
1239 }
1240 new_object->invalidate_bounding_box();
1241
1242 new_objects.push_back(new_object);
1243
1244 BOOST_LOG_TRIVIAL(trace) << "ModelObject::convert_units - end";
1245}
ModelObject()
Definition Model.hpp:639
IGL_INLINE void volume(const Eigen::MatrixBase< DerivedV > &V, const Eigen::MatrixBase< DerivedT > &T, Eigen::PlainObjectBase< Derivedvol > &vol)
Definition volume.cpp:15

References add_volume(), Slic3r::FacetsAnnotation::assign(), Slic3r::ModelConfig::assign_config(), clear_volumes(), Slic3r::ModelVolume::config, Slic3r::ObjectBase::id(), input_file, Slic3r::ModelVolume::Source::input_file, invalidate_bounding_box(), Slic3r::ModelVolume::Source::is_converted_from_inches, Slic3r::ModelVolume::Source::is_converted_from_meters, Slic3r::ModelVolume::Source::is_from_builtin_objects, Slic3r::ModelVolume::mmu_segmentation_facets, Slic3r::ModelVolume::name, Slic3r::ModelVolume::Source::object_idx, Slic3r::ModelVolume::scale_geometry_after_creation(), Slic3r::ModelVolume::seam_facets, Slic3r::ModelVolume::set_material(), set_model(), Slic3r::ModelVolume::set_offset(), Slic3r::ModelVolume::set_type(), sla_drain_holes, sla_points_status, sla_support_points, Slic3r::ModelVolume::source, Slic3r::ModelVolume::supported_facets, Slic3r::ObjectID::valid(), and Slic3r::ModelVolume::Source::volume_idx.

+ Here is the call graph for this function:

◆ convex_hull_2d()

Polygon Slic3r::ModelObject::convex_hull_2d ( const Transform3d trafo_instance) const
1059{
1060 tbb::concurrent_vector<Polygon> chs;
1061 chs.reserve(volumes.size());
1062 tbb::parallel_for(tbb::blocked_range<size_t>(0, volumes.size()), [&](const tbb::blocked_range<size_t>& range) {
1063 for (size_t i = range.begin(); i < range.end(); ++i) {
1064 const ModelVolume* v = volumes[i];
1065 chs.emplace_back(its_convex_hull_2d_above(v->mesh().its, (trafo_instance * v->get_matrix()).cast<float>(), 0.0f));
1066 }
1067 });
1068
1069 Polygons polygons;
1070 polygons.assign(chs.begin(), chs.end());
1071 return Geometry::convex_hull(polygons);
1072}
Polygon convex_hull(Points pts)
Definition ConvexHull.cpp:11
std::vector< Polygon, PointsAllocator< Polygon > > Polygons
Definition Polygon.hpp:15
auto range(Cont &&cont)
Definition libslic3r.h:356

References Slic3r::range(), and volumes.

Referenced by Slic3r::GUI::RotoptimizeJob::finalize(), and Slic3r::GUI::GLCanvas3D::update_sequential_clearance().

+ 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
76{ m_id = rhs.id(); }
ObjectID m_id
Definition ObjectID.hpp:82

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

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

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

◆ copy_transformation_caches()

void Slic3r::ModelObject::copy_transformation_caches ( const ModelObject src)
inlineprivate
618 {
619 m_bounding_box_approx = src.m_bounding_box_approx;
620 m_bounding_box_approx_valid = src.m_bounding_box_approx_valid;
621 m_bounding_box_exact = src.m_bounding_box_exact;
622 m_bounding_box_exact_valid = src.m_bounding_box_exact_valid;
623 m_min_max_z_valid = src.m_min_max_z_valid;
624 m_raw_bounding_box = src.m_raw_bounding_box;
625 m_raw_bounding_box_valid = src.m_raw_bounding_box_valid;
626 m_raw_mesh_bounding_box = src.m_raw_mesh_bounding_box;
627 m_raw_mesh_bounding_box_valid = src.m_raw_mesh_bounding_box_valid;
628 }
bool m_raw_mesh_bounding_box_valid
Definition Model.hpp:615
BoundingBoxf3 m_raw_bounding_box
Definition Model.hpp:612
BoundingBoxf3 m_raw_mesh_bounding_box
Definition Model.hpp:614
bool m_raw_bounding_box_valid
Definition Model.hpp:613

References m_bounding_box_approx, m_bounding_box_approx_valid, m_bounding_box_exact, m_bounding_box_exact_valid, m_min_max_z_valid, m_raw_bounding_box, m_raw_bounding_box_valid, m_raw_mesh_bounding_box, and m_raw_mesh_bounding_box_valid.

Referenced by Slic3r::Print::apply().

+ Here is the caller graph for this function:

◆ cut()

ModelObjectPtrs Slic3r::ModelObject::cut ( size_t  instance,
const Transform3d cut_matrix,
ModelObjectCutAttributes  attributes 
)
1602{
1603 if (!attributes.has(ModelObjectCutAttribute::KeepUpper) && !attributes.has(ModelObjectCutAttribute::KeepLower))
1604 return {};
1605
1606 BOOST_LOG_TRIVIAL(trace) << "ModelObject::cut - start";
1607
1608 // Clone the object to duplicate instances, materials etc.
1609 ModelObject* upper{ nullptr };
1610 if (attributes.has(ModelObjectCutAttribute::KeepUpper))
1611 clone_for_cut(&upper);
1612
1613 ModelObject* lower{ nullptr };
1614 if (attributes.has(ModelObjectCutAttribute::KeepLower) && !attributes.has(ModelObjectCutAttribute::KeepAsParts))
1615 clone_for_cut(&lower);
1616
1617 std::vector<ModelObject*> dowels;
1618
1619 using namespace Geometry;
1620
1621 // Because transformations are going to be applied to meshes directly,
1622 // we reset transformation of all instances and volumes,
1623 // except for translation and Z-rotation on instances, which are preserved
1624 // in the transformation matrix and not applied to the mesh transform.
1625
1626 // const auto instance_matrix = instances[instance]->get_matrix(true);
1627 const auto instance_matrix = instances[instance]->get_transformation().get_matrix_no_offset();
1628 const Transformation cut_transformation = Transformation(cut_matrix);
1629 const Transform3d inverse_cut_matrix = cut_transformation.get_rotation_matrix().inverse() * translation_transform(-1. * cut_transformation.get_offset());
1630
1631 for (ModelVolume* volume : volumes) {
1632 volume->reset_extra_facets();
1633
1634 if (!volume->is_model_part()) {
1635 if (volume->cut_info.is_processed)
1636 process_modifier_cut(volume, instance_matrix, inverse_cut_matrix, attributes, upper, lower);
1637 else
1638 process_connector_cut(volume, instance_matrix, cut_matrix, attributes, upper, lower, dowels);
1639 }
1640 else if (!volume->mesh().empty())
1641 process_solid_part_cut(volume, instance_matrix, cut_matrix, attributes, upper, lower);
1642 }
1643
1644 // Post-process cut parts
1645
1646 ModelObjectPtrs res;
1647
1648 if (attributes.has(ModelObjectCutAttribute::KeepAsParts) && !upper->volumes.empty()) {
1649 reset_instance_transformation(upper, instance, cut_matrix);
1650 res.push_back(upper);
1651 }
1652 else {
1653 if (attributes.has(ModelObjectCutAttribute::KeepUpper) && !upper->volumes.empty()) {
1654 reset_instance_transformation(upper, instance, cut_matrix,
1656 attributes.has(ModelObjectCutAttribute::FlipUpper));
1657 res.push_back(upper);
1658 }
1659
1660 if (attributes.has(ModelObjectCutAttribute::KeepLower) && !lower->volumes.empty()) {
1661 reset_instance_transformation(lower, instance, cut_matrix,
1664 res.push_back(lower);
1665 }
1666
1667 if (attributes.has(ModelObjectCutAttribute::CreateDowels) && !dowels.empty()) {
1668 for (auto dowel : dowels) {
1670 dowel->name += "-Dowel-" + dowel->volumes[0]->name;
1671 res.push_back(dowel);
1672 }
1673 }
1674 }
1675
1676 BOOST_LOG_TRIVIAL(trace) << "ModelObject::cut - end";
1677
1678 return res;
1679}
void process_modifier_cut(ModelVolume *volume, const Transform3d &instance_matrix, const Transform3d &inverse_cut_matrix, ModelObjectCutAttributes attributes, ModelObject *upper, ModelObject *lower)
Definition Model.cpp:1498
void process_connector_cut(ModelVolume *volume, const Transform3d &instance_matrix, const Transform3d &cut_matrix, ModelObjectCutAttributes attributes, ModelObject *upper, ModelObject *lower, std::vector< ModelObject * > &dowels)
Definition Model.cpp:1440
void clone_for_cut(ModelObject **obj)
Definition Model.cpp:1356
void process_solid_part_cut(ModelVolume *volume, const Transform3d &instance_matrix, const Transform3d &cut_matrix, ModelObjectCutAttributes attributes, ModelObject *upper, ModelObject *lower)
Definition Model.cpp:1543
static void reset_instance_transformation(ModelObject *object, size_t src_instance_idx, const Transform3d &cut_matrix, bool place_on_cut=false, bool flip=false)
Definition Model.cpp:1565
EIGEN_DEVICE_FUNC Transform inverse(TransformTraits traits=(TransformTraits) Mode) const
Definition Transform.h:1202
static EIGEN_DEVICE_FUNC const Transform Identity()
Returns an identity transformation.
Definition Transform.h:539
std::vector< ModelObject * > ModelObjectPtrs
Definition Model.hpp:105

References Slic3r::enum_bitmask< option_type, typename >::has(), and Eigen::Transform< _Scalar, _Dim, _Mode, _Options >::inverse().

Referenced by Slic3r::GUI::GLGizmoCut3D::perform_cut().

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

◆ delete_connectors()

void Slic3r::ModelObject::delete_connectors ( )
1349{
1350 for (int id = int(this->volumes.size()) - 1; id >= 0; id--) {
1351 if (volumes[id]->is_cut_connector())
1352 this->delete_volume(size_t(id));
1353 }
1354}
void delete_volume(size_t idx)
Definition Model.cpp:757

◆ delete_instance()

void Slic3r::ModelObject::delete_instance ( size_t  idx)
850{
851 ModelInstancePtrs::iterator i = this->instances.begin() + idx;
852 delete *i;
853 this->instances.erase(i);
855}

References instances, and invalidate_bounding_box().

Referenced by delete_last_instance(), Slic3r::GUI::ObjectList::instances_to_separated_object(), and Slic3r::GUI::ObjectList::instances_to_separated_objects().

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

◆ delete_last_instance()

void Slic3r::ModelObject::delete_last_instance ( )
858{
859 this->delete_instance(this->instances.size() - 1);
860}
void delete_instance(size_t idx)
Definition Model.cpp:849

References delete_instance(), and instances.

Referenced by Slic3r::_3MF_Importer::_load_model_from_file(), and Slic3r::GUI::Plater::decrease_instances().

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

◆ delete_volume()

void Slic3r::ModelObject::delete_volume ( size_t  idx)
758{
759 ModelVolumePtrs::iterator i = this->volumes.begin() + idx;
760 delete *i;
761 this->volumes.erase(i);
762
763 if (this->volumes.size() == 1)
764 {
765 // only one volume left
766 // we need to collapse the volume transform into the instances transforms because now when selecting this volume
767 // it will be seen as a single full instance ans so its volume transform may be ignored
768 ModelVolume* v = this->volumes.front();
769 Transform3d v_t = v->get_transformation().get_matrix();
770 for (ModelInstance* inst : this->instances)
771 {
772 inst->set_transformation(Geometry::Transformation(inst->get_transformation().get_matrix() * v_t));
773 }
774 Geometry::Transformation t;
775 v->set_transformation(t);
776 v->set_new_unique_id();
777 }
778
780}

References Slic3r::Geometry::Transformation::get_matrix(), Slic3r::ModelVolume::get_transformation(), instances, invalidate_bounding_box(), Slic3r::ModelVolume::set_new_unique_id(), Slic3r::ModelVolume::set_transformation(), and volumes.

Referenced by Slic3r::GUI::GLGizmoCut3D::perform_cut(), 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:

◆ ensure_on_bed()

void Slic3r::ModelObject::ensure_on_bed ( bool  allow_negative_z = false)
1088{
1089 double z_offset = 0.0;
1090
1091 if (allow_negative_z) {
1092 if (parts_count() == 1) {
1093 const double min_z = this->min_z();
1094 const double max_z = this->max_z();
1095 if (min_z >= SINKING_Z_THRESHOLD || max_z < 0.0)
1096 z_offset = -min_z;
1097 }
1098 else {
1099 const double max_z = this->max_z();
1100 if (max_z < SINKING_MIN_Z_THRESHOLD)
1101 z_offset = SINKING_MIN_Z_THRESHOLD - max_z;
1102 }
1103 }
1104 else
1105 z_offset = -this->min_z();
1106
1107 if (z_offset != 0.0)
1108 translate_instances(z_offset * Vec3d::UnitZ());
1109}
double min_z() const
Definition Model.cpp:898
size_t parts_count() const
Definition Model.cpp:1264
double max_z() const
Definition Model.cpp:904
void translate_instances(const Vec3d &vector)
Definition Model.cpp:1111
static const double SINKING_MIN_Z_THRESHOLD
Definition Model.hpp:1410
static const float SINKING_Z_THRESHOLD
Definition Model.hpp:1409

Referenced by Slic3r::GUI::GLGizmoSimplify::apply_simplify(), Slic3r::GUI::RotoptimizeJob::finalize(), Slic3r::GUI::FillBedJob::finalize(), Slic3r::GUI::ObjectList::load_mesh_object(), Slic3r::GUI::Plater::priv::reload_from_disk(), and Slic3r::GUI::Plater::priv::replace_volume_with_stl().

+ Here is the caller graph for this function:

◆ facets_count()

size_t Slic3r::ModelObject::facets_count ( ) const
1256{
1257 size_t num = 0;
1258 for (const ModelVolume *v : this->volumes)
1259 if (v->is_model_part())
1260 num += v->mesh().facets_count();
1261 return num;
1262}
size_t facets_count() const
Definition Model.cpp:1255
if(!(yy_init))
Definition lexer.c:1190

Referenced by Slic3r::GUI::Sidebar::show_info_sizer().

+ Here is the caller graph for this function:

◆ full_raw_mesh_bounding_box()

BoundingBoxf3 Slic3r::ModelObject::full_raw_mesh_bounding_box ( ) const
1015{
1016 BoundingBoxf3 bb;
1017 for (const ModelVolume *v : this->volumes)
1018 bb.merge(v->mesh().transformed_bounding_box(v->get_matrix()));
1019 return bb;
1020}

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

+ Here is the call graph for this function:

◆ generate_new_id()

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

References Slic3r::ObjectBase::s_last_id.

Referenced by Slic3r::ObjectBase::set_new_unique_id().

+ Here is the caller graph for this function:

◆ get_connector_mesh()

indexed_triangle_set Slic3r::ModelObject::get_connector_mesh ( CutConnectorAttributes  connector_attributes)
static
1284{
1285 indexed_triangle_set connector_mesh;
1286
1287 int sectorCount {1};
1288 switch (CutConnectorShape(connector_attributes.shape)) {
1290 sectorCount = 3;
1291 break;
1293 sectorCount = 4;
1294 break;
1296 sectorCount = 360;
1297 break;
1299 sectorCount = 6;
1300 break;
1301 default:
1302 break;
1303 }
1304
1305 if (connector_attributes.style == CutConnectorStyle::Prism)
1306 connector_mesh = its_make_cylinder(1.0, 1.0, (2 * PI / sectorCount));
1307 else if (connector_attributes.type == CutConnectorType::Plug)
1308 connector_mesh = its_make_frustum(1.0, 1.0, (2 * PI / sectorCount));
1309 else
1310 connector_mesh = its_make_frustum_dowel(1.0, 1.0, sectorCount);
1311
1312 return connector_mesh;
1313}
static constexpr double PI
Definition libslic3r.h:58
CutConnectorShape
Definition Model.hpp:237
indexed_triangle_set its_make_frustum_dowel(double radius, double h, int sectorCount)
Definition TriangleMesh.cpp:1212
indexed_triangle_set its_make_frustum(double r, double h, double fa)
Definition TriangleMesh.cpp:997
indexed_triangle_set its_make_cylinder(double r, double h, double fa)
Definition TriangleMesh.cpp:955
Definition stl.h:157

References Slic3r::its_make_cylinder(), Slic3r::its_make_frustum(), Slic3r::its_make_frustum_dowel(), PI, Slic3r::CutConnectorAttributes::shape, Slic3r::CutConnectorAttributes::style, and Slic3r::CutConnectorAttributes::type.

Referenced by Slic3r::GUI::GLGizmoCut3D::init_connector_shapes(), and Slic3r::GUI::GLGizmoCut3D::update_connector_shape().

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

◆ get_export_filename()

std::string Slic3r::ModelObject::get_export_filename ( ) const
1969{
1970 std::string ret = input_file;
1971
1972 if (!name.empty())
1973 {
1974 if (ret.empty())
1975 // input_file was empty, just use name
1976 ret = name;
1977 else
1978 {
1979 // Replace file name in input_file with name, but keep the path and file extension.
1980 ret = (boost::filesystem::path(name).parent_path().empty()) ?
1981 (boost::filesystem::path(ret).parent_path() / name).make_preferred().string() : name;
1982 }
1983 }
1984
1985 return ret;
1986}
std::string name
Definition Model.hpp:330
std::string input_file
Definition Model.hpp:331

◆ get_instance_max_z()

double Slic3r::ModelObject::get_instance_max_z ( size_t  instance_idx) const
1872{
1873 double max_z = -DBL_MAX;
1874
1875 const ModelInstance* inst = instances[instance_idx];
1876 const Transform3d mi = inst->get_matrix_no_offset();
1877
1878 for (const ModelVolume* v : volumes) {
1879 if (!v->is_model_part())
1880 continue;
1881
1882 const Transform3d mv = mi * v->get_matrix();
1883 const TriangleMesh& hull = v->get_convex_hull();
1884 for (const stl_triangle_vertex_indices& facet : hull.its.indices)
1885 for (int i = 0; i < 3; ++i)
1886 max_z = std::max(max_z, (mv * hull.its.vertices[facet[i]].cast<double>()).z());
1887 }
1888
1889 return max_z + inst->get_offset(Z);
1890}
@ Z
Definition libslic3r.h:100

References Slic3r::ModelInstance::get_matrix_no_offset(), Slic3r::ModelInstance::get_offset(), indexed_triangle_set::indices, Slic3r::TriangleMesh::its, indexed_triangle_set::vertices, and Slic3r::Z.

+ Here is the call graph for this function:

◆ get_instance_min_z()

double Slic3r::ModelObject::get_instance_min_z ( size_t  instance_idx) const
1851{
1852 double min_z = DBL_MAX;
1853
1854 const ModelInstance* inst = instances[instance_idx];
1855 const Transform3d mi = inst->get_matrix_no_offset();
1856
1857 for (const ModelVolume* v : volumes) {
1858 if (!v->is_model_part())
1859 continue;
1860
1861 const Transform3d mv = mi * v->get_matrix();
1862 const TriangleMesh& hull = v->get_convex_hull();
1863 for (const stl_triangle_vertex_indices& facet : hull.its.indices)
1864 for (int i = 0; i < 3; ++ i)
1865 min_z = std::min(min_z, (mv * hull.its.vertices[facet[i]].cast<double>()).z());
1866 }
1867
1868 return min_z + inst->get_offset(Z);
1869}

References Slic3r::ModelInstance::get_matrix_no_offset(), Slic3r::ModelInstance::get_offset(), indexed_triangle_set::indices, Slic3r::TriangleMesh::its, indexed_triangle_set::vertices, and Slic3r::Z.

Referenced by Slic3r::GUI::GLCanvas3D::do_mirror(), Slic3r::GUI::GLCanvas3D::do_move(), Slic3r::GUI::GLCanvas3D::do_reset_skew(), Slic3r::GUI::GLCanvas3D::do_rotate(), and Slic3r::GUI::GLCanvas3D::do_scale().

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

◆ get_model() [1/2]

Model * Slic3r::ModelObject::get_model ( )
inline
369{ return m_model; }

References m_model.

Referenced by Slic3r::GUI::ObjectList::instances_to_separated_object(), and Slic3r::GUI::ObjectList::instances_to_separated_objects().

+ Here is the caller graph for this function:

◆ get_model() [2/2]

const Model * Slic3r::ModelObject::get_model ( ) const
inline
370{ return m_model; }

References m_model.

◆ get_object_stl_stats()

TriangleMeshStats Slic3r::ModelObject::get_object_stl_stats ( ) const
1989{
1990 TriangleMeshStats full_stats;
1991 full_stats.volume = 0.f;
1992
1993 // fill full_stats from all objet's meshes
1994 for (ModelVolume* volume : this->volumes)
1995 {
1996 const TriangleMeshStats& stats = volume->mesh().stats();
1997
1998 // initialize full_stats (for repaired errors)
1999 full_stats.open_edges += stats.open_edges;
2000 full_stats.repaired_errors.merge(stats.repaired_errors);
2001
2002 // another used satistics value
2003 if (volume->is_model_part()) {
2004 Transform3d trans = instances.empty() ? volume->get_matrix() : (volume->get_matrix() * instances[0]->get_matrix());
2005 full_stats.volume += stats.volume * std::fabs(trans.matrix().block(0, 0, 3, 3).determinant());
2006 full_stats.number_of_parts += stats.number_of_parts;
2007 }
2008 }
2009
2010 return full_stats;
2011}

References Eigen::Transform< _Scalar, _Dim, _Mode, _Options >::matrix(), Slic3r::RepairedMeshErrors::merge(), Slic3r::TriangleMeshStats::number_of_parts, Slic3r::TriangleMeshStats::open_edges, Slic3r::TriangleMeshStats::repaired_errors, and Slic3r::TriangleMeshStats::volume.

Referenced by Slic3r::GUI::ObjectList::delete_from_model_and_list(), and Slic3r::GUI::Sidebar::show_info_sizer().

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

◆ get_repaired_errors_count()

int Slic3r::ModelObject::get_repaired_errors_count ( const int  vol_idx = -1) const
2014{
2015 if (vol_idx >= 0)
2016 return this->volumes[vol_idx]->get_repaired_errors_count();
2017
2018 const RepairedMeshErrors& stats = get_object_stl_stats().repaired_errors;
2019
2020 return stats.degenerate_facets + stats.edges_fixed + stats.facets_removed +
2021 stats.facets_reversed + stats.backwards_edges;
2022}
TriangleMeshStats get_object_stl_stats() const
Definition Model.cpp:1988
int degenerate_facets
Definition TriangleMesh.hpp:23
RepairedMeshErrors repaired_errors
Definition TriangleMesh.hpp:60

References Slic3r::RepairedMeshErrors::backwards_edges, Slic3r::RepairedMeshErrors::degenerate_facets, Slic3r::RepairedMeshErrors::edges_fixed, Slic3r::RepairedMeshErrors::facets_removed, and Slic3r::RepairedMeshErrors::facets_reversed.

Referenced by Slic3r::GUI::ObjectList::fix_through_netfabb().

+ Here is the caller graph for this function:

◆ has_connectors()

bool Slic3r::ModelObject::has_connectors ( ) const
1274{
1275 assert(is_cut());
1276 for (const ModelVolume* v : this->volumes)
1277 if (v->cut_info.is_connector)
1278 return true;
1279
1280 return false;
1281}
bool is_cut() const
Definition Model.hpp:514

Referenced by Slic3r::GUI::ObjectList::update_info_items().

+ Here is the caller graph for this function:

◆ has_custom_layering()

bool Slic3r::ModelObject::has_custom_layering ( ) const
inline
391 { return ! this->layer_config_ranges.empty() || ! this->layer_height_profile.empty(); }
bool empty() const
Definition Model.hpp:192
t_layer_config_ranges layer_config_ranges
Definition Model.hpp:341

References Slic3r::LayerHeightProfile::empty().

+ Here is the call graph for this function:

◆ has_negative_volume_mesh()

bool Slic3r::ModelObject::has_negative_volume_mesh ( ) const
2033{
2034 for (const ModelVolume* volume : volumes)
2035 if (volume->is_negative_volume())
2036 return true;
2037 return false;
2038}

◆ has_sla_drain_holes()

bool Slic3r::ModelObject::has_sla_drain_holes ( ) const
inline
513{ return !sla_drain_holes.empty(); }
sla::DrainHoles sla_drain_holes
Definition Model.hpp:357

References sla_drain_holes.

◆ has_solid_mesh()

bool Slic3r::ModelObject::has_solid_mesh ( ) const
2025{
2026 for (const ModelVolume* volume : volumes)
2027 if (volume->is_model_part())
2028 return true;
2029 return false;
2030}

◆ id()

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

References Slic3r::ObjectBase::m_id.

Referenced by Slic3r::Model::Model(), Slic3r::ModelInstance::ModelInstance(), Slic3r::ModelMaterial::ModelMaterial(), ModelObject(), ModelObject(), ModelObject(), ModelObject(), ModelObject(), Slic3r::ModelVolume::ModelVolume(), Slic3r::ModelVolume::ModelVolume(), Slic3r::ModelVolume::ModelVolume(), Slic3r::_3MF_Importer::_load_model_from_file(), Slic3r::GUI::Plater::priv::actualize_slicing_warnings(), Slic3r::ModelObjectStatusDB::add(), Slic3r::ModelObjectStatusDB::add_if_new(), Slic3r::Print::apply(), Slic3r::SLAPrint::apply(), Slic3r::GUI::GLGizmoFdmSupports::apply_data_from_backend(), Slic3r::ModelVolume::check(), Slic3r::check_model_ids_equal(), convert_units(), Slic3r::ObjectBase::copy_id(), Slic3r::PrintObjectStatusDB::count(), anonymous_namespace{RaycastManager.cpp}::create_key(), priv::create_volume(), Slic3r::GUI::Emboss::create_volume_sources(), Slic3r::GUI::GLGizmoHollow::data_changed(), Slic3r::GUI::GLGizmoPainterBase::data_changed(), Slic3r::GUI::GLGizmoSlaSupports::data_changed(), Slic3r::Model::delete_object(), Slic3r::GUI::Plater::export_stl_obj(), Slic3r::ModelObjectStatusDB::get(), Slic3r::GUI::get_arrange_poly(), Slic3r::GUI::GLGizmoSlaSupports::get_data_from_backend(), Slic3r::PrintObjectStatusDB::get_range(), Slic3r::GUI::GLGizmoFdmSupports::has_backend_supports(), Slic3r::GUI::GLGizmoSlaSupports::has_backend_supports(), Slic3r::CutObjectBase::has_same_id(), Slic3r::UndoRedo::StackImpl::immutable_object_id_impl(), Slic3r::GUI::GLGizmoSimplify::init_model(), Slic3r::inner_brim_area(), is_cut(), Slic3r::CutObjectBase::is_equal(), Slic3r::ObjectBase::load_and_construct(), Slic3r::UndoRedo::StackImpl::load_snapshot(), Slic3r::GUI::ObjectList::merge(), 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::CommonGizmosDataObjects::SelectionInfo::on_update(), Slic3r::CutObjectBase::operator<(), Slic3r::Model::operator=(), operator=(), operator=(), Slic3r::CutObjectBase::operator==(), Slic3r::GUI::GLGizmoCut3D::perform_cut(), Slic3r::GUI::GLGizmoEmboss::process(), Slic3r::GUI::processed_objects_idxs(), Slic3r::GUI::GLCanvas3D::reload_scene(), Slic3r::GUI::GLCanvas3D::LayersEditing::select_object(), Slic3r::ModelMaterial::serialize(), Slic3r::SLAPrintObject::SliceRecord::set_model_slice_idx(), Slic3r::SLAPrintObject::SliceRecord::set_support_slice_idx(), Slic3r::slices_to_regions(), split(), Slic3r::UndoRedo::StackImpl::take_snapshot(), Slic3r::top_level_outer_brim_area(), Slic3r::GUI::update_object_cut_id(), and anonymous_namespace{EmbossJob.cpp}::update_volume_name().

◆ instance_bounding_box()

BoundingBoxf3 Slic3r::ModelObject::instance_bounding_box ( size_t  instance_idx,
bool  dont_translate = false 
) const
1042{
1043 BoundingBoxf3 bb;
1044 const Transform3d inst_matrix = dont_translate ?
1045 this->instances[instance_idx]->get_transformation().get_matrix_no_offset() :
1046 this->instances[instance_idx]->get_transformation().get_matrix();
1047
1048 for (ModelVolume *v : this->volumes) {
1049 if (v->is_model_part())
1050 bb.merge(v->mesh().transformed_bounding_box(inst_matrix * v->get_matrix()));
1051 }
1052 return bb;
1053}

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

Referenced by Slic3r::GUI::GLGizmoEmboss::create_volume(), Slic3r::GUI::GLCanvas3D::do_mirror(), Slic3r::GUI::GLCanvas3D::do_reset_skew(), Slic3r::GUI::GLCanvas3D::do_rotate(), Slic3r::GUI::GLCanvas3D::do_scale(), Slic3r::GUI::ObjectList::load_generic_subobject(), Slic3r::GUI::ObjectList::load_modifier(), Slic3r::GUI::CommonGizmosDataObjects::ObjectClipper::on_update(), Slic3r::GUI::Selection::paste_volumes_from_clipboard(), and Slic3r::GUI::Sidebar::show_info_sizer().

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

◆ invalidate_bounding_box()

◆ invalidate_cut()

void Slic3r::ModelObject::invalidate_cut ( )
1342{
1343 this->cut_id.invalidate();
1344 for (ModelVolume* volume : this->volumes)
1345 volume->invalidate_cut_info();
1346}
void invalidate()
Definition ObjectID.hpp:165

◆ is_cut()

◆ is_fdm_support_painted()

bool Slic3r::ModelObject::is_fdm_support_painted ( ) const
791{
792 return std::any_of(this->volumes.cbegin(), this->volumes.cend(), [](const ModelVolume *mv) { return mv->is_fdm_support_painted(); });
793}

References volumes.

◆ is_mm_painted()

bool Slic3r::ModelObject::is_mm_painted ( ) const
801{
802 return std::any_of(this->volumes.cbegin(), this->volumes.cend(), [](const ModelVolume *mv) { return mv->is_mm_painted(); });
803}

References volumes.

Referenced by Slic3r::Print::apply(), and Slic3r::PrintObject::is_mm_painted().

+ Here is the caller graph for this function:

◆ is_multiparts()

bool Slic3r::ModelObject::is_multiparts ( ) const
inline
379{ return volumes.size() > 1; }

References volumes.

◆ is_seam_painted()

bool Slic3r::ModelObject::is_seam_painted ( ) const
796{
797 return std::any_of(this->volumes.cbegin(), this->volumes.cend(), [](const ModelVolume *mv) { return mv->is_seam_painted(); });
798}

References volumes.

◆ is_text()

bool Slic3r::ModelObject::is_text ( ) const
806{
807 return this->volumes.size() == 1 && this->volumes[0]->is_text();
808}

References volumes.

Referenced by Slic3r::GUI::ObjectList::update_name_in_list().

+ Here is the caller graph for this function:

◆ load_and_construct()

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

References Slic3r::ObjectBase::id().

+ Here is the call graph for this function:

◆ materials_count()

size_t Slic3r::ModelObject::materials_count ( ) const
1248{
1249 std::set<t_model_material_id> material_ids;
1250 for (const ModelVolume *v : this->volumes)
1251 material_ids.insert(v->material_id());
1252 return material_ids.size();
1253}

◆ max_z()

double Slic3r::ModelObject::max_z ( ) const
905{
906 const_cast<ModelObject*>(this)->update_min_max_z();
907 return m_bounding_box_exact.max.z();
908}
PointType max
Definition BoundingBox.hpp:17
void update_min_max_z()
Definition Model.cpp:910

References m_bounding_box_exact, Slic3r::BoundingBoxBase< PointType, APointsType >::max, and update_min_max_z().

Referenced by Slic3r::PrintObject::PrintObject(), and Slic3r::GUI::GLCanvas3D::LayersEditing::select_object().

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

◆ merge()

void Slic3r::ModelObject::merge ( )
1768{
1769 if (this->volumes.size() == 1) {
1770 // We can't merge meshes if there's just one volume
1771 return;
1772 }
1773
1774 TriangleMesh mesh;
1775
1776 for (ModelVolume* volume : volumes)
1777 if (!volume->mesh().empty())
1778 mesh.merge(volume->mesh());
1779
1780 this->clear_volumes();
1781 ModelVolume* vol = this->add_volume(mesh);
1782
1783 if (!vol)
1784 return;
1785}
bool empty(const BoundingBoxBase< PointType, PointsType > &bb)
Definition BoundingBox.hpp:229

References Slic3r::TriangleMesh::merge().

Referenced by Slic3r::GUI::ObjectList::merge().

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

◆ mesh()

TriangleMesh Slic3r::ModelObject::mesh ( ) const
942{
943 TriangleMesh mesh;
944 TriangleMesh raw_mesh = this->raw_mesh();
945 for (const ModelInstance *i : this->instances) {
946 TriangleMesh m = raw_mesh;
947 i->transform_mesh(&m);
948 mesh.merge(m);
949 }
950 return mesh;
951}
TriangleMesh raw_mesh() const
Definition Model.cpp:956
void merge(const TriangleMesh &mesh)
Definition TriangleMesh.cpp:407

References instances, Slic3r::TriangleMesh::merge(), mesh(), and raw_mesh().

Referenced by add_volume(), add_volume(), add_volume(), mesh(), raw_mesh(), Slic3r::store_obj(), and Slic3r::store_stl().

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

◆ min_z()

double Slic3r::ModelObject::min_z ( ) const
899{
900 const_cast<ModelObject*>(this)->update_min_max_z();
901 return m_bounding_box_exact.min.z();
902}
PointType min
Definition BoundingBox.hpp:16

References m_bounding_box_exact, Slic3r::BoundingBoxBase< PointType, APointsType >::min, and update_min_max_z().

Referenced by 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:

◆ mirror()

void Slic3r::ModelObject::mirror ( Axis  axis)
1165{
1166 for (ModelVolume *v : this->volumes) {
1167 v->mirror(axis);
1168 }
1170}

◆ operator=() [1/2]

ModelObject & Slic3r::ModelObject::operator= ( const ModelObject rhs)
inlineprivate
569 {
570 this->assign_copy(rhs);
571 m_model = rhs.m_model;
572 assert(this->id().valid());
573 assert(this->config.id().valid());
574 assert(this->layer_height_profile.id().valid());
575 assert(this->id() != this->config.id());
576 assert(this->id() != this->layer_height_profile.id());
577 assert(this->id() == rhs.id());
578 assert(this->config.id() == rhs.config.id());
579 assert(this->layer_height_profile.id() == rhs.layer_height_profile.id());
580 return *this;
581 }

References config, Slic3r::ObjectBase::id(), layer_height_profile, m_model, and Slic3r::ObjectID::valid().

+ Here is the call graph for this function:

◆ operator=() [2/2]

ModelObject & Slic3r::ModelObject::operator= ( ModelObject &&  rhs)
inlineprivate
582 {
583 this->assign_copy(std::move(rhs));
584 m_model = rhs.m_model;
585 assert(this->id().valid());
586 assert(this->config.id().valid());
587 assert(this->layer_height_profile.id().valid());
588 assert(this->id() != this->config.id());
589 assert(this->id() != this->layer_height_profile.id());
590 assert(this->id() == rhs.id());
591 assert(this->config.id() == rhs.config.id());
592 assert(this->layer_height_profile.id() == rhs.layer_height_profile.id());
593 return *this;
594 }

References Slic3r::ObjectID::id, Slic3r::ObjectBase::id(), m_model, and Slic3r::ObjectID::valid().

+ Here is the call graph for this function:

◆ parts_count()

size_t Slic3r::ModelObject::parts_count ( ) const
1265{
1266 size_t num = 0;
1267 for (const ModelVolume* v : this->volumes)
1268 if (v->is_model_part())
1269 ++num;
1270 return num;
1271}

◆ print_info()

void Slic3r::ModelObject::print_info ( ) const
1928{
1929 using namespace std;
1930 cout << fixed;
1931 boost::nowide::cout << "[" << boost::filesystem::path(this->input_file).filename().string() << "]" << endl;
1932
1933 TriangleMesh mesh = this->raw_mesh();
1934 BoundingBoxf3 bb = mesh.bounding_box();
1935 Vec3d size = bb.size();
1936 cout << "size_x = " << size(0) << endl;
1937 cout << "size_y = " << size(1) << endl;
1938 cout << "size_z = " << size(2) << endl;
1939 cout << "min_x = " << bb.min(0) << endl;
1940 cout << "min_y = " << bb.min(1) << endl;
1941 cout << "min_z = " << bb.min(2) << endl;
1942 cout << "max_x = " << bb.max(0) << endl;
1943 cout << "max_y = " << bb.max(1) << endl;
1944 cout << "max_z = " << bb.max(2) << endl;
1945 cout << "number_of_facets = " << mesh.facets_count() << endl;
1946
1947 cout << "manifold = " << (mesh.stats().manifold() ? "yes" : "no") << endl;
1948 if (! mesh.stats().manifold())
1949 cout << "open_edges = " << mesh.stats().open_edges << endl;
1950
1951 if (mesh.stats().repaired()) {
1952 const RepairedMeshErrors& stats = mesh.stats().repaired_errors;
1953 if (stats.degenerate_facets > 0)
1954 cout << "degenerate_facets = " << stats.degenerate_facets << endl;
1955 if (stats.edges_fixed > 0)
1956 cout << "edges_fixed = " << stats.edges_fixed << endl;
1957 if (stats.facets_removed > 0)
1958 cout << "facets_removed = " << stats.facets_removed << endl;
1959 if (stats.facets_reversed > 0)
1960 cout << "facets_reversed = " << stats.facets_reversed << endl;
1961 if (stats.backwards_edges > 0)
1962 cout << "backwards_edges = " << stats.backwards_edges << endl;
1963 }
1964 cout << "number_of_parts = " << mesh.stats().number_of_parts << endl;
1965 cout << "volume = " << mesh.volume() << endl;
1966}
float volume()
Definition TriangleMesh.cpp:223
BoundingBoxf3 bounding_box() const
Definition TriangleMesh.cpp:432
const TriangleMeshStats & stats() const
Definition TriangleMesh.hpp:153
size_t facets_count() const
Definition TriangleMesh.hpp:138
constexpr auto size(const C &c) -> decltype(c.size())
Definition span.hpp:183
@ fixed
Definition fast_float.h:46
STL namespace.
bool manifold() const
Definition TriangleMesh.hpp:83
int number_of_parts
Definition TriangleMesh.hpp:54
int open_edges
Definition TriangleMesh.hpp:57
bool repaired() const
Definition TriangleMesh.hpp:84

References Slic3r::RepairedMeshErrors::backwards_edges, Slic3r::TriangleMesh::bounding_box(), Slic3r::RepairedMeshErrors::degenerate_facets, Slic3r::RepairedMeshErrors::edges_fixed, Slic3r::TriangleMesh::facets_count(), Slic3r::RepairedMeshErrors::facets_removed, Slic3r::RepairedMeshErrors::facets_reversed, Slic3r::TriangleMeshStats::manifold(), Slic3r::BoundingBoxBase< PointType, APointsType >::max, Slic3r::BoundingBoxBase< PointType, APointsType >::min, Slic3r::TriangleMeshStats::number_of_parts, Slic3r::TriangleMeshStats::open_edges, Slic3r::TriangleMeshStats::repaired(), Slic3r::TriangleMeshStats::repaired_errors, Slic3r::BoundingBox3Base< PointType >::size(), Slic3r::TriangleMesh::stats(), and Slic3r::TriangleMesh::volume().

+ Here is the call graph for this function:

◆ process_connector_cut()

void Slic3r::ModelObject::process_connector_cut ( ModelVolume volume,
const Transform3d instance_matrix,
const Transform3d cut_matrix,
ModelObjectCutAttributes  attributes,
ModelObject upper,
ModelObject lower,
std::vector< ModelObject * > &  dowels 
)
private
1443{
1444 assert(volume->cut_info.is_connector);
1445 volume->cut_info.set_processed();
1446
1447 const auto volume_matrix = volume->get_matrix();
1448
1449 // ! Don't apply instance transformation for the conntectors.
1450 // This transformation is already there
1451 if (volume->cut_info.connector_type != CutConnectorType::Dowel) {
1452 if (attributes.has(ModelObjectCutAttribute::KeepUpper)) {
1453 ModelVolume* vol = upper->add_volume(*volume);
1454 vol->set_transformation(volume_matrix);
1455 vol->apply_tolerance();
1456 }
1457 if (attributes.has(ModelObjectCutAttribute::KeepLower)) {
1458 ModelVolume* vol = lower->add_volume(*volume);
1459 vol->set_transformation(volume_matrix);
1460 // for lower part change type of connector from NEGATIVE_VOLUME to MODEL_PART if this connector is a plug
1461 vol->set_type(ModelVolumeType::MODEL_PART);
1462 }
1463 }
1464 else {
1465 if (attributes.has(ModelObjectCutAttribute::CreateDowels)) {
1466 ModelObject* dowel{ nullptr };
1467 // Clone the object to duplicate instances, materials etc.
1468 clone_for_cut(&dowel);
1469
1470 // add one more solid part same as connector if this connector is a dowel
1471 ModelVolume* vol = dowel->add_volume(*volume);
1472 vol->set_type(ModelVolumeType::MODEL_PART);
1473
1474 // But discard rotation and Z-offset for this volume
1475 vol->set_rotation(Vec3d::Zero());
1476 vol->set_offset(Z, 0.0);
1477
1478 dowels.push_back(dowel);
1479 }
1480
1481 // Cut the dowel
1482 volume->apply_tolerance();
1483
1484 // Perform cut
1485 TriangleMesh upper_mesh, lower_mesh;
1486 process_volume_cut(volume, Transform3d::Identity(), cut_matrix, attributes, upper_mesh, lower_mesh);
1487
1488 // add small Z offset to better preview
1489 upper_mesh.translate((-0.05 * Vec3d::UnitZ()).cast<float>());
1490 lower_mesh.translate((0.05 * Vec3d::UnitZ()).cast<float>());
1491
1492 // Add cut parts to the related objects
1493 add_cut_volume(upper_mesh, upper, volume, cut_matrix, "_A", volume->type());
1494 add_cut_volume(lower_mesh, lower, volume, cut_matrix, "_B", volume->type());
1495 }
1496}
void process_volume_cut(ModelVolume *volume, const Transform3d &instance_matrix, const Transform3d &cut_matrix, ModelObjectCutAttributes attributes, TriangleMesh &upper_mesh, TriangleMesh &lower_mesh)
Definition Model.cpp:1521
static void add_cut_volume(TriangleMesh &mesh, ModelObject *object, const ModelVolume *src_volume, const Transform3d &cut_matrix, const std::string &suffix={}, ModelVolumeType type=ModelVolumeType::MODEL_PART)
Definition Model.cpp:1422

References Slic3r::add_cut_volume(), add_volume(), Slic3r::ModelVolume::apply_tolerance(), Slic3r::enum_bitmask< option_type, typename >::has(), Slic3r::ModelVolume::set_offset(), Slic3r::ModelVolume::set_rotation(), Slic3r::ModelVolume::set_transformation(), Slic3r::ModelVolume::set_type(), Slic3r::TriangleMesh::translate(), and Slic3r::Z.

+ Here is the call graph for this function:

◆ process_modifier_cut()

void Slic3r::ModelObject::process_modifier_cut ( ModelVolume volume,
const Transform3d instance_matrix,
const Transform3d inverse_cut_matrix,
ModelObjectCutAttributes  attributes,
ModelObject upper,
ModelObject lower 
)
private
1500{
1501 const auto volume_matrix = instance_matrix * volume->get_matrix();
1502
1503 // Modifiers are not cut, but we still need to add the instance transformation
1504 // to the modifier volume transformation to preserve their shape properly.
1505 volume->set_transformation(Geometry::Transformation(volume_matrix));
1506
1507 if (attributes.has(ModelObjectCutAttribute::KeepAsParts)) {
1508 upper->add_volume(*volume);
1509 return;
1510 }
1511
1512 // Some logic for the negative volumes/connectors. Add only needed modifiers
1513 auto bb = volume->mesh().transformed_bounding_box(inverse_cut_matrix * volume_matrix);
1514 bool is_crossed_by_cut = bb.min[Z] <= 0 && bb.max[Z] >= 0;
1515 if (attributes.has(ModelObjectCutAttribute::KeepUpper) && (bb.min[Z] >= 0 || is_crossed_by_cut))
1516 upper->add_volume(*volume);
1517 if (attributes.has(ModelObjectCutAttribute::KeepLower) && (bb.max[Z] <= 0 || is_crossed_by_cut))
1518 lower->add_volume(*volume);
1519}

References add_volume(), Slic3r::enum_bitmask< option_type, typename >::has(), and Slic3r::Z.

+ Here is the call graph for this function:

◆ process_solid_part_cut()

void Slic3r::ModelObject::process_solid_part_cut ( ModelVolume volume,
const Transform3d instance_matrix,
const Transform3d cut_matrix,
ModelObjectCutAttributes  attributes,
ModelObject upper,
ModelObject lower 
)
private
1545{
1546 // Perform cut
1547 TriangleMesh upper_mesh, lower_mesh;
1548 process_volume_cut(volume, instance_matrix, cut_matrix, attributes, upper_mesh, lower_mesh);
1549
1550 // Add required cut parts to the objects
1551
1552 if (attributes.has(ModelObjectCutAttribute::KeepAsParts)) {
1553 add_cut_volume(upper_mesh, upper, volume, cut_matrix, "_A");
1554 add_cut_volume(lower_mesh, upper, volume, cut_matrix, "_B");
1555 return;
1556 }
1557
1558 if (attributes.has(ModelObjectCutAttribute::KeepUpper))
1559 add_cut_volume(upper_mesh, upper, volume, cut_matrix);
1560
1561 if (attributes.has(ModelObjectCutAttribute::KeepLower) && !lower_mesh.empty())
1562 add_cut_volume(lower_mesh, lower, volume, cut_matrix);
1563}

References Slic3r::add_cut_volume(), Slic3r::TriangleMesh::empty(), and Slic3r::enum_bitmask< option_type, typename >::has().

+ Here is the call graph for this function:

◆ process_volume_cut()

void Slic3r::ModelObject::process_volume_cut ( ModelVolume volume,
const Transform3d instance_matrix,
const Transform3d cut_matrix,
ModelObjectCutAttributes  attributes,
TriangleMesh upper_mesh,
TriangleMesh lower_mesh 
)
private
1523{
1524 const auto volume_matrix = volume->get_matrix();
1525
1526 using namespace Geometry;
1527
1528 const Transformation cut_transformation = Transformation(cut_matrix);
1529 const Transform3d invert_cut_matrix = cut_transformation.get_rotation_matrix().inverse() * translation_transform(-1 * cut_transformation.get_offset());
1530
1531 // Transform the mesh by the combined transformation matrix.
1532 // Flip the triangles in case the composite transformation is left handed.
1533 TriangleMesh mesh(volume->mesh());
1534 mesh.transform(invert_cut_matrix * instance_matrix * volume_matrix, true);
1535
1536 indexed_triangle_set upper_its, lower_its;
1537 cut_mesh(mesh.its, 0.0f, &upper_its, &lower_its);
1538 if (attributes.has(ModelObjectCutAttribute::KeepUpper))
1539 upper_mesh = TriangleMesh(upper_its);
1540 if (attributes.has(ModelObjectCutAttribute::KeepLower))
1541 lower_mesh = TriangleMesh(lower_its);
1542}
indexed_triangle_set its
Definition TriangleMesh.hpp:155
void transform(const Transform3d &t, bool fix_left_handed=false)
Definition TriangleMesh.cpp:330
void cut_mesh(const indexed_triangle_set &mesh, float z, indexed_triangle_set *upper, indexed_triangle_set *lower, bool triangulate_caps)
Definition TriangleMeshSlicer.cpp:2220

References Slic3r::enum_bitmask< option_type, typename >::has(), Eigen::Transform< _Scalar, _Dim, _Mode, _Options >::inverse(), Slic3r::TriangleMesh::its, and Slic3r::TriangleMesh::transform().

+ Here is the call graph for this function:

◆ raw_bounding_box()

const BoundingBoxf3 & Slic3r::ModelObject::raw_bounding_box ( ) const
1025{
1029 if (this->instances.empty())
1030 throw Slic3r::InvalidArgument("Can't call raw_bounding_box() with no instances");
1031
1032 const Transform3d inst_matrix = this->instances.front()->get_transformation().get_matrix_no_offset();
1033 for (const ModelVolume *v : this->volumes)
1034 if (v->is_model_part())
1035 m_raw_bounding_box.merge(v->mesh().transformed_bounding_box(inst_matrix * v->get_matrix()));
1036 }
1037 return m_raw_bounding_box;
1038}

References instances, m_raw_bounding_box, m_raw_bounding_box_valid, Slic3r::BoundingBox3Base< PointType >::merge(), Slic3r::BoundingBoxBase< PointType, APointsType >::reset(), and volumes.

Referenced by Slic3r::PrintObject::PrintObject(), and Slic3r::PrintObject::slicing_parameters().

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

◆ raw_indexed_triangle_set()

indexed_triangle_set Slic3r::ModelObject::raw_indexed_triangle_set ( ) const
973{
974 size_t num_vertices = 0;
975 size_t num_faces = 0;
976 for (const ModelVolume *v : this->volumes)
977 if (v->is_model_part()) {
978 num_vertices += v->mesh().its.vertices.size();
979 num_faces += v->mesh().its.indices.size();
980 }
982 out.vertices.reserve(num_vertices);
983 out.indices.reserve(num_faces);
984 for (const ModelVolume *v : this->volumes)
985 if (v->is_model_part()) {
986 size_t i = out.vertices.size();
987 size_t j = out.indices.size();
988 append(out.vertices, v->mesh().its.vertices);
989 append(out.indices, v->mesh().its.indices);
990 const Transform3d& m = v->get_matrix();
991 for (; i < out.vertices.size(); ++ i)
992 out.vertices[i] = (m * out.vertices[i].cast<double>()).cast<float>().eval();
993 if (v->is_left_handed()) {
994 for (; j < out.indices.size(); ++ j)
995 std::swap(out.indices[j][0], out.indices[j][1]);
996 }
997 }
998 return out;
999}
void append(std::vector< T, Alloc > &dest, const std::vector< T, Alloc2 > &src)
Definition libslic3r.h:110
std::vector< stl_vertex > vertices
Definition stl.h:165
std::vector< stl_triangle_vertex_indices > indices
Definition stl.h:164

References Slic3r::append(), indexed_triangle_set::indices, indexed_triangle_set::vertices, and volumes.

+ Here is the call graph for this function:

◆ raw_mesh()

TriangleMesh Slic3r::ModelObject::raw_mesh ( ) const
957{
958 TriangleMesh mesh;
959 for (const ModelVolume *v : this->volumes)
960 if (v->is_model_part())
961 {
962 TriangleMesh vol_mesh(v->mesh());
963 vol_mesh.transform(v->get_matrix());
964 mesh.merge(vol_mesh);
965 }
966 return mesh;
967}

References Slic3r::TriangleMesh::merge(), mesh(), Slic3r::TriangleMesh::transform(), and volumes.

Referenced by Slic3r::sla::RotfinderBoilerplate< MAX_ITER >::get_mesh_to_rotate(), and mesh().

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

◆ raw_mesh_bounding_box()

const BoundingBoxf3 & Slic3r::ModelObject::raw_mesh_bounding_box ( ) const
1003{
1007 for (const ModelVolume *v : this->volumes)
1008 if (v->is_model_part())
1009 m_raw_mesh_bounding_box.merge(v->mesh().transformed_bounding_box(v->get_matrix()));
1010 }
1012}

References m_raw_mesh_bounding_box, m_raw_mesh_bounding_box_valid, Slic3r::BoundingBox3Base< PointType >::merge(), Slic3r::BoundingBoxBase< PointType, APointsType >::reset(), and volumes.

Referenced by bounding_box_approx().

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

◆ reset_instance_transformation()

void Slic3r::ModelObject::reset_instance_transformation ( ModelObject object,
size_t  src_instance_idx,
const Transform3d cut_matrix,
bool  place_on_cut = false,
bool  flip = false 
)
static
1567{
1568 using namespace Geometry;
1569
1570 // Reset instance transformation except offset and Z-rotation
1571
1572 for (size_t i = 0; i < object->instances.size(); ++i) {
1573 auto& obj_instance = object->instances[i];
1574 const double rot_z = obj_instance->get_rotation().z();
1575
1576 obj_instance->set_transformation(Transformation(obj_instance->get_transformation().get_matrix_no_scaling_factor()));
1577
1578 Vec3d rotation = Vec3d::Zero();
1579 if (!flip && !place_on_cut) {
1580 if ( i != src_instance_idx)
1581 rotation[Z] = rot_z;
1582 }
1583 else {
1584 Transform3d rotation_matrix = Transform3d::Identity();
1585 if (flip)
1586 rotation_matrix = rotation_transform(PI * Vec3d::UnitX());
1587
1588 if (place_on_cut)
1589 rotation_matrix = rotation_matrix * Transformation(cut_matrix).get_rotation_matrix().inverse();
1590
1591 if (i != src_instance_idx)
1592 rotation_matrix = rotation_transform(rot_z * Vec3d::UnitZ()) * rotation_matrix;
1593
1594 rotation = Transformation(rotation_matrix).get_rotation();
1595 }
1596
1597 obj_instance->set_rotation(rotation);
1598 }
1599}
void rotation_transform(Transform3d &transform, const Vec3d &rotation)
Definition Geometry.cpp:341

References Eigen::Transform< _Scalar, _Dim, _Mode, _Options >::inverse(), PI, and Slic3r::Z.

Referenced by Slic3r::GUI::GLGizmoCut3D::perform_cut().

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

◆ rotate() [1/2]

void Slic3r::ModelObject::rotate ( double  angle,
Axis  axis 
)
1147{
1148 for (ModelVolume *v : this->volumes) {
1149 v->rotate(angle, axis);
1150 }
1153}
void center_around_origin(bool include_modifiers=true)
Definition Model.cpp:1074
double angle(const Eigen::MatrixBase< Derived > &v1, const Eigen::MatrixBase< Derived2 > &v2)
Definition Point.hpp:112

References Slic3r::angle().

+ Here is the call graph for this function:

◆ rotate() [2/2]

void Slic3r::ModelObject::rotate ( double  angle,
const Vec3d axis 
)
1156{
1157 for (ModelVolume *v : this->volumes) {
1158 v->rotate(angle, axis);
1159 }
1162}

References Slic3r::angle().

+ Here is the call graph for this function:

◆ scale() [1/3]

void Slic3r::ModelObject::scale ( const double  s)
inline
447{ this->scale(Vec3d(s, s, s)); }
void scale(const Vec3d &versor)
Definition Model.cpp:1138

References scale().

Referenced by scale().

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

◆ scale() [2/3]

void Slic3r::ModelObject::scale ( const Vec3d versor)
1139{
1140 for (ModelVolume *v : this->volumes) {
1141 v->scale(versor);
1142 }
1144}

◆ scale() [3/3]

void Slic3r::ModelObject::scale ( double  x,
double  y,
double  z 
)
inline
448{ this->scale(Vec3d(x, y, z)); }

References scale().

Referenced by scale().

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

◆ scale_mesh_after_creation()

void Slic3r::ModelObject::scale_mesh_after_creation ( const float  scale)
1174{
1175 for (ModelVolume *v : this->volumes) {
1176 v->scale_geometry_after_creation(scale);
1177 v->set_offset(Vec3d(scale, scale, scale).cwiseProduct(v->get_offset()));
1178 }
1180}

References scale().

+ Here is the call graph for this function:

◆ scale_to_fit()

void Slic3r::ModelObject::scale_to_fit ( const Vec3d size)

Scale the current ModelObject to fit by altering the scaling factor of ModelInstances. It operates on the total size by duplicating the object according to all the instances.

Parameters
sizeSizef3 the size vector
2225{
2226 Vec3d orig_size = this->bounding_box_exact().size();
2227 double factor = std::min(
2228 size.x() / orig_size.x(),
2229 std::min(
2230 size.y() / orig_size.y(),
2231 size.z() / orig_size.z()
2232 )
2233 );
2234 this->scale(factor);
2235}
PointType size() const
Definition BoundingBox.cpp:153
const BoundingBoxf3 & bounding_box_exact() const
Definition Model.cpp:886

References scale().

+ Here is the call graph for this function:

◆ serialize()

template<class Archive >
void Slic3r::ModelObject::serialize ( Archive &  ar)
inlineprivate

◆ set_invalid_id()

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

References Slic3r::ObjectBase::m_id.

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

+ Here is the caller graph for this function:

◆ set_model()

void Slic3r::ModelObject::set_model ( Model model)
inlineprivate
633{ m_model = model; }

References m_model.

Referenced by Slic3r::Model::add_object(), and convert_units().

+ Here is the caller graph for this function:

◆ set_new_unique_id()

void Slic3r::ModelObject::set_new_unique_id ( )
inlineprivate

References Slic3r::ObjectBase::set_new_unique_id().

Referenced by assign_new_unique_ids_recursive().

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

◆ sort_volumes()

void Slic3r::ModelObject::sort_volumes ( bool  full_sort)
811{
812 // sort volumes inside the object to order "Model Part, Negative Volume, Modifier, Support Blocker and Support Enforcer. "
813 if (full_sort)
814 std::stable_sort(volumes.begin(), volumes.end(), [](ModelVolume* vl, ModelVolume* vr) {
815 return vl->type() < vr->type();
816 });
817 // sort have to controll "place" of the support blockers/enforcers. But one of the model parts have to be on the first place.
818 else
819 std::stable_sort(volumes.begin(), volumes.end(), [](ModelVolume* vl, ModelVolume* vr) {
820 ModelVolumeType vl_type = vl->type() > ModelVolumeType::PARAMETER_MODIFIER ? vl->type() : ModelVolumeType::PARAMETER_MODIFIER;
821 ModelVolumeType vr_type = vr->type() > ModelVolumeType::PARAMETER_MODIFIER ? vr->type() : ModelVolumeType::PARAMETER_MODIFIER;
822 return vl_type < vr_type;
823 });
824}

References volumes.

Referenced by Slic3r::GUI::ObjectList::load_mesh_object(), Slic3r::GUI::Plater::priv::load_model_objects(), Slic3r::GUI::ObjectList::merge(), Slic3r::GUI::Plater::priv::reload_from_disk(), and Slic3r::GUI::Plater::priv::replace_volume_with_stl().

+ Here is the caller graph for this function:

◆ split()

void Slic3r::ModelObject::split ( ModelObjectPtrs new_objects)
1710{
1711 for (ModelVolume* volume : this->volumes) {
1712 if (volume->type() != ModelVolumeType::MODEL_PART)
1713 continue;
1714
1715 // splited volume should not be text object
1716 if (volume->text_configuration.has_value())
1717 volume->text_configuration.reset();
1718
1719 std::vector<TriangleMesh> meshes = volume->mesh().split();
1720 std::sort(meshes.begin(), meshes.end(), is_front_up_left);
1721
1722 size_t counter = 1;
1723 for (TriangleMesh &mesh : meshes) {
1724 // FIXME: crashes if not satisfied
1725 if (mesh.facets_count() < 3 || mesh.has_zero_volume())
1726 continue;
1727
1728 // XXX: this seems to be the only real usage of m_model, maybe refactor this so that it's not needed?
1729 ModelObject* new_object = m_model->add_object();
1730 if (meshes.size() == 1) {
1731 new_object->name = volume->name;
1732 // Don't copy the config's ID.
1733 new_object->config.assign_config(this->config.size() > 0 ? this->config : volume->config);
1734 }
1735 else {
1736 new_object->name = this->name + (meshes.size() > 1 ? "_" + std::to_string(counter++) : "");
1737 // Don't copy the config's ID.
1738 new_object->config.assign_config(this->config);
1739 }
1740 assert(new_object->config.id().valid());
1741 assert(new_object->config.id() != this->config.id());
1742 new_object->instances.reserve(this->instances.size());
1743 for (const ModelInstance* model_instance : this->instances)
1744 new_object->add_instance(*model_instance);
1745 ModelVolume* new_vol = new_object->add_volume(*volume, std::move(mesh));
1746
1747 // Invalidate extruder value in volume's config,
1748 // otherwise there will no way to change extruder for object after splitting,
1749 // because volume's extruder value overrides object's extruder value.
1750 if (new_vol->config.has("extruder"))
1751 new_vol->config.set_key_value("extruder", new ConfigOptionInt(0));
1752
1753 for (ModelInstance* model_instance : new_object->instances) {
1754 const Vec3d shift = model_instance->get_transformation().get_matrix_no_offset() * new_vol->get_offset();
1755 model_instance->set_offset(model_instance->get_offset() + shift);
1756 }
1757
1758 new_vol->set_offset(Vec3d::Zero());
1759 // reset the source to disable reload from disk
1760 new_vol->source = ModelVolume::Source();
1761 new_objects->emplace_back(new_object);
1762 }
1763 }
1764}
size_t size() const
Definition PrintConfig.hpp:1270
ModelObject * add_object()
Definition Model.cpp:189
bool has_zero_volume() const
Definition TriangleMesh.cpp:383
static bool is_front_up_left(const TriangleMesh &trinagle_mesh1, const TriangleMesh &triangle_mesh2)
Compare TriangleMeshes by Bounding boxes (mainly for sort) From Front(Z) Upper(Y) TopLeft(X) corner.
Definition Model.cpp:1691

References add_instance(), add_volume(), Slic3r::ModelConfig::assign_config(), config, Slic3r::ModelVolume::config, Slic3r::TriangleMesh::facets_count(), Slic3r::ModelVolume::get_offset(), Slic3r::ModelConfig::has(), Slic3r::TriangleMesh::has_zero_volume(), Slic3r::ObjectID::id, Slic3r::ObjectBase::id(), instances, Slic3r::is_front_up_left(), name, Slic3r::ModelConfig::set_key_value(), Slic3r::ModelVolume::set_offset(), Slic3r::ModelVolume::source, and Slic3r::ObjectID::valid().

Referenced by Slic3r::GUI::Plater::priv::split_object().

+ 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.

60{ return 0; }

Referenced by Slic3r::GUI::Plater::priv::undo_redo_to().

+ Here is the caller graph for this function:

◆ translate() [1/2]

void Slic3r::ModelObject::translate ( const Vec3d vector)
inline
444{ this->translate(vector(0), vector(1), vector(2)); }

References translate().

Referenced by Slic3r::GUI::ObjectList::load_mesh_object(), and translate().

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

◆ translate() [2/2]

void Slic3r::ModelObject::translate ( double  x,
double  y,
double  z 
)
1127{
1128 for (ModelVolume *v : this->volumes) {
1129 v->translate(x, y, z);
1130 }
1131
1136}
void translate(coordf_t x, coordf_t y, coordf_t z)
Definition BoundingBox.hpp:123

◆ translate_instance()

void Slic3r::ModelObject::translate_instance ( size_t  instance_idx,
const Vec3d vector 
)
1119{
1120 assert(instance_idx < instances.size());
1121 ModelInstance* i = instances[instance_idx];
1122 i->set_offset(i->get_offset() + vector);
1124}

References Slic3r::ModelInstance::get_offset(), and Slic3r::ModelInstance::set_offset().

Referenced by Slic3r::GUI::GLCanvas3D::do_mirror(), Slic3r::GUI::GLCanvas3D::do_move(), Slic3r::GUI::GLCanvas3D::do_reset_skew(), Slic3r::GUI::GLCanvas3D::do_rotate(), and Slic3r::GUI::GLCanvas3D::do_scale().

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

◆ translate_instances()

void Slic3r::ModelObject::translate_instances ( const Vec3d vector)
1112{
1113 for (size_t i = 0; i < instances.size(); ++i) {
1114 translate_instance(i, vector);
1115 }
1116}
void translate_instance(size_t instance_idx, const Vec3d &vector)
Definition Model.cpp:1118

Referenced by Slic3r::GUI::ObjectList::merge().

+ Here is the caller graph for this function:

◆ update_instances_print_volume_state()

unsigned int Slic3r::ModelObject::update_instances_print_volume_state ( const BuildVolume build_volume)
private
1893{
1894 unsigned int num_printable = 0;
1895 enum {
1896 INSIDE = 1,
1897 OUTSIDE = 2
1898 };
1899 for (ModelInstance* model_instance : this->instances) {
1900 unsigned int inside_outside = 0;
1901 for (const ModelVolume* vol : this->volumes)
1902 if (vol->is_model_part()) {
1903 const Transform3d matrix = model_instance->get_matrix() * vol->get_matrix();
1904 BuildVolume::ObjectState state = build_volume.object_state(vol->mesh().its, matrix.cast<float>(), true /* may be below print bed */);
1906 // Volume is completely inside.
1907 inside_outside |= INSIDE;
1908 else if (state == BuildVolume::ObjectState::Outside)
1909 // Volume is completely outside.
1910 inside_outside |= OUTSIDE;
1911 else if (state == BuildVolume::ObjectState::Below) {
1912 // Volume below the print bed, thus it is completely outside, however this does not prevent the object to be printable
1913 // if some of its volumes are still inside the build volume.
1914 } else
1915 // Volume colliding with the build volume.
1916 inside_outside |= INSIDE | OUTSIDE;
1917 }
1918 model_instance->print_volume_state =
1919 inside_outside == (INSIDE | OUTSIDE) ? ModelInstancePVS_Partly_Outside :
1920 inside_outside == INSIDE ? ModelInstancePVS_Inside : ModelInstancePVS_Fully_Outside;
1921 if (inside_outside == INSIDE)
1922 ++num_printable;
1923 }
1924 return num_printable;
1925}
ObjectState
Definition BuildVolume.hpp:65
@ ModelInstancePVS_Inside
Definition Model.hpp:1111
@ ModelInstancePVS_Partly_Outside
Definition Model.hpp:1112
@ ModelInstancePVS_Fully_Outside
Definition Model.hpp:1113

References Eigen::Transform< _Scalar, _Dim, _Mode, _Options >::cast(), Slic3r::ModelInstancePVS_Fully_Outside, Slic3r::ModelInstancePVS_Inside, Slic3r::ModelInstancePVS_Partly_Outside, and Slic3r::BuildVolume::object_state().

+ Here is the call graph for this function:

◆ update_min_max_z()

void Slic3r::ModelObject::update_min_max_z ( )
private
911{
912 assert(! this->instances.empty());
913 if (! m_min_max_z_valid && ! this->instances.empty()) {
914 m_min_max_z_valid = true;
915 const Transform3d mat_instance = this->instances.front()->get_transformation().get_matrix();
916 double global_min_z = std::numeric_limits<double>::max();
917 double global_max_z = - std::numeric_limits<double>::max();
918 for (const ModelVolume *v : this->volumes)
919 if (v->is_model_part()) {
920 const Transform3d m = mat_instance * v->get_matrix();
921 const Vec3d row_z = m.linear().row(2).cast<double>();
922 const double shift_z = m.translation().z();
923 double this_min_z = std::numeric_limits<double>::max();
924 double this_max_z = - std::numeric_limits<double>::max();
925 for (const Vec3f &p : v->mesh().its.vertices) {
926 double z = row_z.dot(p.cast<double>());
927 this_min_z = std::min(this_min_z, z);
928 this_max_z = std::max(this_max_z, z);
929 }
930 this_min_z += shift_z;
931 this_max_z += shift_z;
932 global_min_z = std::min(global_min_z, this_min_z);
933 global_max_z = std::max(global_max_z, this_max_z);
934 }
935 m_bounding_box_exact.min.z() = global_min_z;
936 m_bounding_box_exact.max.z() = global_max_z;
937 }
938}

References instances, Eigen::Transform< _Scalar, _Dim, _Mode, _Options >::linear(), m_bounding_box_exact, m_min_max_z_valid, Slic3r::BoundingBoxBase< PointType, APointsType >::max, Slic3r::BoundingBoxBase< PointType, APointsType >::min, Eigen::Transform< _Scalar, _Dim, _Mode, _Options >::translation(), and volumes.

Referenced by max_z(), and min_z().

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

Friends And Related Symbol Documentation

◆ cereal::access

friend class cereal::access
friend

◆ Model

friend class Model
friend

◆ Print

friend class Print
friend

◆ SLAPrint

friend class SLAPrint
friend

◆ UndoRedo::StackImpl

friend class UndoRedo::StackImpl
friend

Member Data Documentation

◆ config

◆ cut_connectors

◆ cut_id

◆ input_file

◆ instances

ModelInstancePtrs Slic3r::ModelObject::instances

Referenced by Slic3r::GUI::GLGizmoCut3D::PartSelection::PartSelection(), Slic3r::PrintObject::PrintObject(), Slic3r::_3MF_Exporter::_add_model_config_file_to_archive(), Slic3r::_3MF_Importer::_handle_end_model(), Slic3r::_3MF_Importer::_load_model_from_file(), add_instance(), add_instance(), Slic3r::GUI::MenuFactory::append_menu_item_printable(), Slic3r::Print::apply(), Slic3r::SLAPrint::apply(), assign_new_unique_ids_recursive(), Slic3r::GUI::GLGizmoFdmSupports::auto_generate(), bounding_box_approx(), bounding_box_exact(), Slic3r::GUI::GLGizmoCut3D::check_and_update_connectors_state(), Slic3r::check_model_ids_equal(), clear_instances(), Slic3r::GUI::Selection::copy_to_clipboard(), Slic3r::GUI::Plater::decrease_instances(), Slic3r::GUI::ObjectList::del_subobject_from_object(), delete_instance(), delete_last_instance(), delete_volume(), Slic3r::GUI::GLCanvas3D::do_mirror(), Slic3r::GUI::GLCanvas3D::do_move(), Slic3r::GUI::GLCanvas3D::do_reset_skew(), Slic3r::GUI::GLCanvas3D::do_rotate(), Slic3r::GUI::GLCanvas3D::do_scale(), Slic3r::GUI::Plater::export_stl_obj(), Slic3r::GUI::RotoptimizeJob::finalize(), Slic3r::GUI::FillBedJob::finalize(), Slic3r::GUI::GLGizmoCut3D::get_cut_matrix(), Slic3r::sla::RotfinderBoilerplate< MAX_ITER >::get_mesh_to_rotate(), Slic3r::GUI::GLGizmoHollow::gizmo_event(), Slic3r::GUI::GLGizmoPainterBase::gizmo_event(), Slic3r::GUI::GLGizmoSlaSupports::gizmo_event(), Slic3r::GUI::Plater::increase_instances(), instance_bounding_box(), Slic3r::GUI::ObjectList::instances_to_separated_object(), Slic3r::GUI::ObjectList::instances_to_separated_objects(), Slic3r::GUI::GLGizmoFlatten::is_plane_update_necessary(), Slic3r::GUI::ObjectList::load_mesh_object(), Slic3r::GUI::GLCanvas3D::load_object(), Slic3r::GLVolumeCollection::load_object_auxiliary(), Slic3r::GLVolumeCollection::load_object_volume(), Slic3r::GUI::GCodeViewer::load_shells(), Slic3r::GUI::ObjectList::merge(), mesh(), Slic3r::GUI::CommonGizmosDataObjects::SelectionInfo::model_instance(), Slic3r::GUI::Selection::paste_objects_from_clipboard(), Slic3r::GUI::Selection::paste_volumes_from_clipboard(), Slic3r::GUI::GLGizmoCut3D::perform_cut(), Slic3r::GUI::FillBedJob::prepare(), Slic3r::GUI::ArrangeJob::prepare_selected(), Slic3r::print_objects_from_model_object(), Slic3r::GUI::GLGizmoCut3D::process_selection_rectangle(), Slic3r::GUI::processed_objects_idxs(), Slic3r::GUI::GLGizmoCut3D::put_connectors_on_cut_plane(), raw_bounding_box(), Slic3r::GUI::GLCanvas3D::reload_scene(), Slic3r::GUI::GLCanvas3D::Labels::render(), Slic3r::GUI::GLGizmoCut3D::render_connectors(), Slic3r::GUI::GLGizmoPainterBase::render_cursor(), Slic3r::GUI::CommonGizmosDataObjects::InstancesHider::render_cut(), Slic3r::GUI::CommonGizmosDataObjects::SupportsClipper::render_cut(), Slic3r::GUI::CommonGizmosDataObjects::ObjectClipper::render_cut(), Slic3r::GUI::GLGizmoFdmSupports::select_facets_by_angle(), serialize(), Slic3r::GUI::Plater::set_number_of_copies(), Slic3r::GUI::CommonGizmosDataObjects::ObjectClipper::set_position_by_ratio(), Slic3r::GUI::Sidebar::show_info_sizer(), Slic3r::sla_instances(), Slic3r::SLAPrint::sla_trafo(), split(), Slic3r::store_amf(), Slic3r::GUI::ObjectList::toggle_printable_state(), Slic3r::GUI::GLGizmoCut3D::unproject_on_cut_plane(), Slic3r::GUI::GLGizmoMeasure::update_if_needed(), Slic3r::GUI::GLCanvas3D::update_instance_printable_state_for_object(), update_min_max_z(), Slic3r::GUI::GLGizmoFlatten::update_planes(), Slic3r::GUI::ObjectList::update_printable_state(), Slic3r::GUI::GLGizmoCut3D::update_raycasters_for_picking_transform(), Slic3r::GUI::GLCanvas3D::update_sequential_clearance(), Slic3r::GUI::Selection::update_type(), and Slic3r::GUI::GLGizmoSlaBase::update_volumes().

◆ layer_config_ranges

◆ layer_height_profile

◆ m_bounding_box_approx

BoundingBoxf3 Slic3r::ModelObject::m_bounding_box_approx
mutableprivate

◆ m_bounding_box_approx_valid

bool Slic3r::ModelObject::m_bounding_box_approx_valid { false }
mutableprivate

◆ m_bounding_box_exact

BoundingBoxf3 Slic3r::ModelObject::m_bounding_box_exact
mutableprivate

◆ m_bounding_box_exact_valid

bool Slic3r::ModelObject::m_bounding_box_exact_valid { false }
mutableprivate

◆ m_id

◆ m_min_max_z_valid

bool Slic3r::ModelObject::m_min_max_z_valid { false }
mutableprivate

◆ m_model

Model* Slic3r::ModelObject::m_model { nullptr }
private

◆ m_raw_bounding_box

BoundingBoxf3 Slic3r::ModelObject::m_raw_bounding_box
mutableprivate

◆ m_raw_bounding_box_valid

bool Slic3r::ModelObject::m_raw_bounding_box_valid { false }
mutableprivate

◆ m_raw_mesh_bounding_box

BoundingBoxf3 Slic3r::ModelObject::m_raw_mesh_bounding_box
mutableprivate

◆ m_raw_mesh_bounding_box_valid

bool Slic3r::ModelObject::m_raw_mesh_bounding_box_valid { false }
mutableprivate

◆ name

◆ origin_translation

◆ printable

bool Slic3r::ModelObject::printable { true }

Referenced by serialize().

◆ s_last_id

size_t Slic3r::ObjectBase::s_last_id = 0
staticprivateinherited

◆ sla_drain_holes

◆ sla_points_status

◆ sla_support_points

◆ volumes

ModelVolumePtrs Slic3r::ModelObject::volumes

Referenced by Slic3r::GUI::GLGizmoCut3D::PartSelection::PartSelection(), Slic3r::_3MF_Importer::_load_model_from_file(), Slic3r::GUI::RaycastManager::actualize(), Slic3r::Model::add_object(), Slic3r::Model::add_object(), add_volume(), add_volume(), add_volume(), add_volume(), Slic3r::GUI::ObjectList::add_volumes_to_object_in_list(), Slic3r::GUI::MenuFactory::append_menu_items_convert_unit(), Slic3r::Print::apply(), Slic3r::GUI::GLGizmoFdmSupports::apply_data_from_backend(), assign_new_unique_ids_recursive(), Slic3r::Print::auto_assign_extruders(), Slic3r::GUI::GLGizmoFdmSupports::auto_generate(), Slic3r::GUI::ObjectList::change_part_type(), Slic3r::check_model_ids_equal(), Slic3r::GUI::Plater::clear_before_change_mesh(), clear_volumes(), Slic3r::SeamPlacerImpl::compute_global_occlusion(), convex_hull_2d(), Slic3r::GUI::Selection::copy_to_clipboard(), Slic3r::GUI::Emboss::create_volume_sources(), Slic3r::GUI::GLGizmoPainterBase::data_changed(), Slic3r::GUI::ObjectList::del_subobject_from_object(), Slic3r::GUI::ObjectList::delete_from_model_and_list(), delete_volume(), Slic3r::GUI::GLCanvas3D::do_mirror(), Slic3r::GUI::GLCanvas3D::do_move(), Slic3r::GUI::GLCanvas3D::do_reset_skew(), Slic3r::GUI::GLCanvas3D::do_rotate(), Slic3r::GUI::GLCanvas3D::do_scale(), Slic3r::GUI::GLGizmoEmboss::draw_advanced(), Slic3r::GUI::GLGizmoEmboss::draw_window(), Slic3r::GUI::Plater::export_stl_obj(), Slic3r::GUI::ObjectList::fix_through_netfabb(), full_raw_mesh_bounding_box(), Slic3r::SeamPlacerImpl::gather_enforcers_blockers(), Slic3r::GUI::get_extruder_id_for_volumes(), Slic3r::GUI::ObjectList::get_mesh_errors_info(), Slic3r::GUI::GLGizmoEmboss::get_minimal_window_size(), Slic3r::GUI::get_model_volume(), Slic3r::GUI::get_volume(), Slic3r::GUI::get_volume_ids(), Slic3r::GUI::GLGizmoPainterBase::gizmo_event(), Slic3r::GUI::GLGizmoSimplify::init_model(), Slic3r::GUI::GLGizmoMmuSegmentation::init_model_triangle_selectors(), instance_bounding_box(), is_fdm_support_painted(), is_mm_painted(), is_multiparts(), Slic3r::GUI::GLGizmoFlatten::is_plane_update_necessary(), is_seam_painted(), Slic3r::GUI::ObjectList::is_splittable(), is_text(), Slic3r::GUI::ObjectList::load_modifier(), Slic3r::GLVolumeCollection::load_object(), Slic3r::GLVolumeCollection::load_object_volume(), Slic3r::load_step(), Slic3r::GUI::ObjectList::merge(), Slic3r::mmu_segmentation_top_and_bottom_layers(), Slic3r::model_property_changed(), Slic3r::csg::model_to_csgmesh(), Slic3r::model_volume_list_changed(), Slic3r::model_volume_list_copy_configs(), Slic3r::multi_material_segmentation_by_painting(), Slic3r::GUI::GLCanvas3D::on_mouse(), Slic3r::GUI::GLGizmoSimplify::on_render(), Slic3r::GUI::GLGizmoFdmSupports::on_render_input_window(), Slic3r::GUI::GLGizmoMmuSegmentation::on_render_input_window(), Slic3r::GUI::GLGizmoSeam::on_render_input_window(), Slic3r::GUI::CommonGizmosDataObjects::InstancesHider::on_update(), Slic3r::GUI::CommonGizmosDataObjects::Raycaster::on_update(), Slic3r::GUI::CommonGizmosDataObjects::ObjectClipper::on_update(), Slic3r::GUI::Selection::paste_volumes_from_clipboard(), Slic3r::GUI::GLGizmoCut3D::perform_cut(), Slic3r::GUI::GLGizmoEmboss::process(), raw_bounding_box(), raw_indexed_triangle_set(), raw_mesh(), raw_mesh_bounding_box(), Slic3r::GUI::Plater::priv::reload_from_disk(), Slic3r::GUI::GLCanvas3D::reload_scene(), Slic3r::GUI::reloadable_volumes(), Slic3r::GUI::GLGizmoPainterBase::render_cursor(), Slic3r::GUI::CommonGizmosDataObjects::InstancesHider::render_cut(), Slic3r::GUI::Plater::priv::replace_volume_with_stl(), Slic3r::GUI::GLGizmoFdmSupports::select_facets_by_angle(), serialize(), Slic3r::GUI::GLGizmoEmboss::set_volume_by_selection(), Slic3r::GUI::ObjectList::show_context_menu(), Slic3r::GUI::Sidebar::show_info_sizer(), Slic3r::PrintObject::slicing_parameters(), sort_volumes(), Slic3r::ModelVolume::split(), Slic3r::GUI::Plater::priv::split_object(), priv::start_create_volume_job(), priv::start_create_volume_on_surface_job(), Slic3r::SLAPrint::Steps::support_points(), Slic3r::GLVolume::NonManifoldEdges::update(), Slic3r::GUI::ObjectList::update_extruder_values_for_items(), Slic3r::GUI::GLGizmoFdmSupports::update_from_model_object(), Slic3r::GUI::GLGizmoSeam::update_from_model_object(), Slic3r::GUI::GLGizmoMeasure::update_if_needed(), Slic3r::GUI::ObjectList::update_info_items(), update_min_max_z(), Slic3r::GUI::GLGizmoFdmSupports::update_model_object(), Slic3r::GUI::GLGizmoMmuSegmentation::update_model_object(), Slic3r::GUI::GLGizmoSeam::update_model_object(), Slic3r::GUI::ObjectList::update_name_in_list(), Slic3r::GUI::GLGizmoFlatten::update_planes(), Slic3r::GUI::ObjectList::update_selections_on_canvas(), Slic3r::GUI::Selection::update_type(), anonymous_namespace{EmbossJob.cpp}::update_volume_name(), and Slic3r::GUI::GLGizmoSlaBase::update_volumes().


The documentation for this class was generated from the following files: