mirror of
https://git.mirrors.martin98.com/https://github.com/slic3r/Slic3r.git
synced 2025-10-04 01:36:46 +08:00
change / rewrite volume and object function
This commit is contained in:
parent
4e148608eb
commit
8928678085
@ -801,6 +801,14 @@ ModelObject::mirror(const Axis &axis)
|
|||||||
this->invalidate_bounding_box();
|
this->invalidate_bounding_box();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
ModelObject::apply_transformation(const TransformationMatrix & trafo)
|
||||||
|
{
|
||||||
|
for (ModelVolumePtrs::const_iterator v = this->volumes.begin(); v != this->volumes.end(); ++v) {
|
||||||
|
(*v)->apply_transformation(trafo);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ModelObject::transform_by_instance(ModelInstance instance, bool dont_translate)
|
ModelObject::transform_by_instance(ModelInstance instance, bool dont_translate)
|
||||||
{
|
{
|
||||||
@ -1023,39 +1031,27 @@ ModelVolume::swap(ModelVolume &other)
|
|||||||
}
|
}
|
||||||
|
|
||||||
TriangleMesh
|
TriangleMesh
|
||||||
ModelVolume::get_transformed_mesh(TransformationMatrix const * additional_trafo) const
|
ModelVolume::get_transformed_mesh(TransformationMatrix const & trafo) const
|
||||||
{
|
{
|
||||||
TransformationMatrix trafo = this->trafo;
|
|
||||||
if(additional_trafo)
|
|
||||||
{
|
|
||||||
trafo.applyLeft(*(additional_trafo));
|
|
||||||
}
|
|
||||||
return this->mesh.get_transformed_mesh(trafo);
|
return this->mesh.get_transformed_mesh(trafo);
|
||||||
}
|
}
|
||||||
|
|
||||||
BoundingBoxf3
|
BoundingBoxf3
|
||||||
ModelVolume::get_transformed_bounding_box(TransformationMatrix const * additional_trafo) const
|
ModelVolume::get_transformed_bounding_box(TransformationMatrix const & trafo) const
|
||||||
{
|
{
|
||||||
TransformationMatrix trafo = this->trafo;
|
return this->mesh.get_transformed_bounding_box(trafo);
|
||||||
if(additional_trafo)
|
}
|
||||||
{
|
|
||||||
trafo.applyLeft(*(additional_trafo));
|
BoundingBoxf3
|
||||||
}
|
ModelVolume::bounding_box() const
|
||||||
BoundingBoxf3 bbox;
|
{
|
||||||
for (int i = 0; i < this->mesh.stl.stats.number_of_facets; ++ i) {
|
return this->mesh.bounding_box();
|
||||||
const stl_facet &facet = this->mesh.stl.facet_start[i];
|
}
|
||||||
for (int j = 0; j < 3; ++ j) {
|
|
||||||
double v_x = facet.vertex[j].x;
|
void ModelVolume::apply_transformation(TransformationMatrix const & trafo)
|
||||||
double v_y = facet.vertex[j].y;
|
{
|
||||||
double v_z = facet.vertex[j].z;
|
this->mesh.transform(trafo);
|
||||||
Pointf3 poi;
|
this->trafo.applyLeft(trafo);
|
||||||
poi.x = float(trafo.m11*v_x + trafo.m12*v_y + trafo.m13*v_z + trafo.m14);
|
|
||||||
poi.y = float(trafo.m21*v_x + trafo.m22*v_y + trafo.m23*v_z + trafo.m24);
|
|
||||||
poi.z = float(trafo.m31*v_x + trafo.m32*v_y + trafo.m33*v_z + trafo.m34);
|
|
||||||
bbox.merge(poi);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return bbox;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
t_model_material_id
|
t_model_material_id
|
||||||
|
@ -444,6 +444,9 @@ class ModelObject
|
|||||||
/// \param copy_volumes bool whether to also copy its volumes or not, by default = true
|
/// \param copy_volumes bool whether to also copy its volumes or not, by default = true
|
||||||
ModelObject(Model *model, const ModelObject &other, bool copy_volumes = true);
|
ModelObject(Model *model, const ModelObject &other, bool copy_volumes = true);
|
||||||
|
|
||||||
|
/// Apply transformation to all volumes
|
||||||
|
void apply_transformation(const TransformationMatrix & trafo);
|
||||||
|
|
||||||
/// = Operator overloading
|
/// = Operator overloading
|
||||||
/// \param other ModelObject the other ModelObject to be copied
|
/// \param other ModelObject the other ModelObject to be copied
|
||||||
/// \return ModelObject& the current ModelObject to enable operator cascading
|
/// \return ModelObject& the current ModelObject to enable operator cascading
|
||||||
@ -485,9 +488,10 @@ class ModelVolume
|
|||||||
/// Get the ModelVolume's mesh, transformed by the ModelVolume's TransformationMatrix
|
/// Get the ModelVolume's mesh, transformed by the ModelVolume's TransformationMatrix
|
||||||
/// \param additional_trafo additional transformation
|
/// \param additional_trafo additional transformation
|
||||||
/// \return TriangleMesh the transformed mesh
|
/// \return TriangleMesh the transformed mesh
|
||||||
TriangleMesh get_transformed_mesh(TransformationMatrix const * additional_trafo = nullptr) const;
|
TriangleMesh get_transformed_mesh(TransformationMatrix const & trafo) const;
|
||||||
|
|
||||||
BoundingBoxf3 get_transformed_bounding_box(TransformationMatrix const * additional_trafo = nullptr) const;
|
BoundingBoxf3 get_transformed_bounding_box(TransformationMatrix const & trafo) const;
|
||||||
|
BoundingBoxf3 bounding_box() const;
|
||||||
|
|
||||||
//Transformation matrix manipulators
|
//Transformation matrix manipulators
|
||||||
|
|
||||||
@ -515,7 +519,7 @@ class ModelVolume
|
|||||||
void rotate(double angle_rad, const Axis &axis) { this->trafo.rotate(angle_rad,axis); };
|
void rotate(double angle_rad, const Axis &axis) { this->trafo.rotate(angle_rad,axis); };
|
||||||
|
|
||||||
/// apply whichever matrix is supplied, multiplied from the left
|
/// apply whichever matrix is supplied, multiplied from the left
|
||||||
void apply(TransformationMatrix const &trafo) { this->trafo.applyLeft(trafo); };
|
void apply_transformation(TransformationMatrix const &trafo);
|
||||||
|
|
||||||
/// Get the material id of this ModelVolume object
|
/// Get the material id of this ModelVolume object
|
||||||
/// \return t_model_material_id the material id string
|
/// \return t_model_material_id the material id string
|
||||||
|
Loading…
x
Reference in New Issue
Block a user