libslic3r
Library for generating gcode from 3d models
Public Member Functions | Public Attributes | Friends | List of all members
Slic3r::ModelObject Class Reference

#include <Model.hpp>

Public Member Functions

Modelget_model () const
 
ModelVolumeadd_volume (const TriangleMesh &mesh)
 
ModelVolumeadd_volume (const ModelVolume &volume)
 
void delete_volume (size_t idx)
 
void clear_volumes ()
 Delete all ModelVolumes in the. More...
 
ModelInstanceadd_instance ()
 
ModelInstanceadd_instance (const ModelInstance &instance)
 
void delete_instance (size_t idx)
 
void delete_last_instance ()
 Delete the last created ModelInstance object. More...
 
void clear_instances ()
 Delete all ModelInstance objects found in the current ModelObject. More...
 
BoundingBoxf3 bounding_box ()
 Get the bounding box of the transformed instances. More...
 
void invalidate_bounding_box ()
 Invalidate the bounding box in the current ModelObject. More...
 
void repair ()
 Repair all TriangleMesh objects found in each ModelVolume. More...
 
TriangleMesh mesh () const
 Flatten all volumes and instances into a single mesh and applying all the ModelInstances transformations. More...
 
TriangleMesh raw_mesh () const
 Flatten all volumes into a single mesh. More...
 
BoundingBoxf3 raw_bounding_box () const
 
BoundingBoxf3 instance_bounding_box (size_t instance_idx) const
 
void align_to_ground ()
 Align the current ModelObject to ground by translating the ModelVolumes in the z axis the needed units. More...
 
void center_around_origin ()
 Center the current ModelObject to origin by translating the ModelVolumes. More...
 
void translate (const Vectorf3 &vector)
 
void translate (coordf_t x, coordf_t y, coordf_t z)
 
void scale (float factor)
 
void scale (const Pointf3 &versor)
 
void scale_to_fit (const Sizef3 &size)
 
void rotate (float angle, const Axis &axis)
 
void mirror (const Axis &axis)
 
void transform_by_instance (ModelInstance instance, bool dont_translate=false)
 
size_t materials_count () const
 
size_t facets_count () const
 
bool needed_repair () const
 
void cut (Axis axis, coordf_t z, Model *model) const
 
void split (ModelObjectPtrs *new_objects)
 
void update_bounding_box ()
 Update the bounding box in this ModelObject. More...
 
void print_info () const
 Print the current info of this ModelObject. More...
 

Public Attributes

std::string name
 This ModelObject name. More...
 
std::string input_file
 Input file path. More...
 
ModelInstancePtrs instances
 
ModelVolumePtrs volumes
 
DynamicPrintConfig config
 Configuration parameters specific to a single ModelObject, overriding the global Slic3r settings. More...
 
t_layer_height_ranges layer_height_ranges
 Variation of a layer thickness for spans of Z coordinates. More...
 
int part_number
 It's used for the 3MF items part numbers in the build element. More...
 
LayerHeightSpline layer_height_spline
 Spline based variations of layer thickness for interactive user manipulation. More...
 
Pointf3 origin_translation
 
BoundingBoxf3 _bounding_box
 
bool _bounding_box_valid
 

Friends

class Model
 

Detailed Description

Model Object class A printable object, possibly having multiple print volumes (each with its own set of parameters and materials), and possibly having multiple modifier volumes, each modifier volume with its set of parameters and materials. Each ModelObject may be instantiated multiple times, each instance having different placement on the print bed, different rotation and different uniform scaling.

Member Function Documentation

◆ add_instance() [1/2]

ModelInstance * Slic3r::ModelObject::add_instance ( )

Add a new ModelInstance to the current ModelObject.

Returns
ModelInstance* a pointer to the new instance

◆ add_instance() [2/2]

ModelInstance * Slic3r::ModelObject::add_instance ( const ModelInstance instance)

Add a new ModelInstance to the current ModelObject.

Parameters
instancethe ModelInstance to be copied
Returns
ModelInstance* a pointer to the new instance

◆ add_volume() [1/2]

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

Add a new ModelVolume to the current ModelObject. The mesh is copied into the newly created ModelVolume.

Parameters
meshTriangularMesh
Returns
ModelVolume* pointer to the new volume

◆ add_volume() [2/2]

ModelVolume * Slic3r::ModelObject::add_volume ( const ModelVolume volume)

Add a new ModelVolume to the current ModelObject.

Parameters
volumethe ModelVolume object to be copied
Returns
ModelVolume* pointer to the new volume

◆ align_to_ground()

void Slic3r::ModelObject::align_to_ground ( )

Align the current ModelObject to ground by translating the ModelVolumes in the z axis the needed units.

◆ bounding_box()

BoundingBoxf3 Slic3r::ModelObject::bounding_box ( )

Get the bounding box of the transformed instances.

◆ center_around_origin()

void Slic3r::ModelObject::center_around_origin ( )

Center the current ModelObject to origin by translating the ModelVolumes.

◆ clear_instances()

void Slic3r::ModelObject::clear_instances ( )

Delete all ModelInstance objects found in the current ModelObject.

◆ clear_volumes()

void Slic3r::ModelObject::clear_volumes ( )

Delete all ModelVolumes in the.

◆ cut()

void Slic3r::ModelObject::cut ( Axis  axis,
coordf_t  z,
Model model 
) const

Cut (Slice) the current ModelObject along a certain axis at a certain coordinate.

Parameters
axisAxis the axis to slice at (X = 0 or Y or Z)
zcoordf_t the point at the certain axis to cut(slice) the Model at
modelModel* pointer to the Model which will get the resulting objects added

◆ delete_instance()

void Slic3r::ModelObject::delete_instance ( size_t  idx)

Delete a ModelInstance.

Parameters
idxsize_t the index of the ModelInstance to be deleted

◆ delete_last_instance()

void Slic3r::ModelObject::delete_last_instance ( )

Delete the last created ModelInstance object.

◆ delete_volume()

void Slic3r::ModelObject::delete_volume ( size_t  idx)

Delete a ModelVolume object.

Parameters
idxsize_t the index of the ModelVolume to be deleted

◆ facets_count()

size_t Slic3r::ModelObject::facets_count ( ) const

Get the number of the facets found in all ModelVolume objects in this ModelObject which are not modifier volumes.

Returns
size_t the facets count

◆ get_model()

Model* Slic3r::ModelObject::get_model ( ) const
inline

Get the owning parent Model.

Returns
parent Model* pointer to the owner Model

◆ instance_bounding_box()

BoundingBoxf3 Slic3r::ModelObject::instance_bounding_box ( size_t  instance_idx) const

Get the bounding box of the transformed given instance.

Parameters
instance_idxsize_t the index of the ModelInstance in the ModelInstance vector
Returns
BoundingBoxf3 the bounding box at the given index

◆ invalidate_bounding_box()

void Slic3r::ModelObject::invalidate_bounding_box ( )

Invalidate the bounding box in the current ModelObject.

◆ materials_count()

size_t Slic3r::ModelObject::materials_count ( ) const

Get the number of the unique ModelMaterial objects in this ModelObject.

Returns
size_t the materials count

◆ mesh()

TriangleMesh Slic3r::ModelObject::mesh ( ) const

Flatten all volumes and instances into a single mesh and applying all the ModelInstances transformations.

◆ mirror()

void Slic3r::ModelObject::mirror ( const Axis axis)

Mirror the current Model around a certain axis.

Parameters
axisAxis enum member

◆ needed_repair()

bool Slic3r::ModelObject::needed_repair ( ) const

Know whether there exists a TriangleMesh object that needed repair or not.

Returns
bool

◆ print_info()

void Slic3r::ModelObject::print_info ( ) const

Print the current info of this ModelObject.

◆ raw_bounding_box()

BoundingBoxf3 Slic3r::ModelObject::raw_bounding_box ( ) const

Get the raw bounding box. This function croaks when there are no ModelInstances for this ModelObject

Returns
BoundingBoxf3

◆ raw_mesh()

TriangleMesh Slic3r::ModelObject::raw_mesh ( ) const

Flatten all volumes into a single mesh.

◆ repair()

void Slic3r::ModelObject::repair ( )

Repair all TriangleMesh objects found in each ModelVolume.

◆ rotate()

void Slic3r::ModelObject::rotate ( float  angle,
const Axis axis 
)

Rotate the current ModelObject by rotating ModelVolumes.

Parameters
anglefloat the angle in radians
axisAxis the axis to be rotated around

◆ scale() [1/2]

void Slic3r::ModelObject::scale ( float  factor)

Scale the current ModelObject by scaling its ModelVolumes. This function calls scale(const Pointf3 &versor) to scale every TriangleMesh in each ModelVolume.

Parameters
factorfloat the scaling factor

◆ scale() [2/2]

void Slic3r::ModelObject::scale ( const Pointf3 versor)

Scale the current ModelObject by scaling its ModelVolumes.

Parameters
versorPointf3 the scaling factor in a 3d vector.

◆ scale_to_fit()

void Slic3r::ModelObject::scale_to_fit ( const Sizef3 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

◆ split()

void Slic3r::ModelObject::split ( ModelObjectPtrs new_objects)

Split the meshes of the ModelVolume in this ModelObject if there exists only one ModelVolume in this ModelObject.

Parameters
new_objectsModelObjectPtrs the generated ModelObjects after the single ModelVolume split

◆ transform_by_instance()

void Slic3r::ModelObject::transform_by_instance ( ModelInstance  instance,
bool  dont_translate = false 
)

Transform the current ModelObject by a certain ModelInstance attributes. Inverse transformation is applied to all the ModelInstances, so that the final size/position/rotation of the transformed objects doesn't change.

Parameters
instanceModelInstance the instance used to transform the current ModelObject
dont_translatebool whether to translate the current ModelObject or not

◆ translate() [1/2]

void Slic3r::ModelObject::translate ( const Vectorf3 vector)

Translate the current ModelObject by translating ModelVolumes with (x,y,z) units. This function calls translate(coordf_t x, coordf_t y, coordf_t z) to translate every TriangleMesh in each ModelVolume.

Parameters
vectorVectorf3 the translation vector

◆ translate() [2/2]

void Slic3r::ModelObject::translate ( coordf_t  x,
coordf_t  y,
coordf_t  z 
)

Translate the current ModelObject by translating ModelVolumes with (x,y,z) units.

Parameters
xcoordf_t the x units
ycoordf_t the y units
zcoordf_t the z units

◆ update_bounding_box()

void Slic3r::ModelObject::update_bounding_box ( )

Update the bounding box in this ModelObject.

Friends And Related Function Documentation

◆ Model

friend class Model
friend

Member Data Documentation

◆ _bounding_box

BoundingBoxf3 Slic3r::ModelObject::_bounding_box

◆ _bounding_box_valid

bool Slic3r::ModelObject::_bounding_box_valid

◆ config

DynamicPrintConfig Slic3r::ModelObject::config

Configuration parameters specific to a single ModelObject, overriding the global Slic3r settings.

◆ input_file

std::string Slic3r::ModelObject::input_file

Input file path.

◆ instances

ModelInstancePtrs Slic3r::ModelObject::instances

Instances of this ModelObject. Each instance defines a shift on the print bed, rotation around the Z axis and a uniform scaling. Instances are owned by this ModelObject.

◆ layer_height_ranges

t_layer_height_ranges Slic3r::ModelObject::layer_height_ranges

Variation of a layer thickness for spans of Z coordinates.

◆ layer_height_spline

LayerHeightSpline Slic3r::ModelObject::layer_height_spline

Spline based variations of layer thickness for interactive user manipulation.

◆ name

std::string Slic3r::ModelObject::name

This ModelObject name.

◆ origin_translation

Pointf3 Slic3r::ModelObject::origin_translation

This vector accumulates the total translation applied to the object by the center_around_origin() method. Callers might want to apply the same translation to new volumes before adding them to this object in order to preserve alignment when user expects that.

◆ part_number

int Slic3r::ModelObject::part_number

It's used for the 3MF items part numbers in the build element.

◆ volumes

ModelVolumePtrs Slic3r::ModelObject::volumes

Printable and modifier volumes, each with its material ID and a set of override parameters. ModelVolumes are owned by this ModelObject.


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