move transform function to volume class

This commit is contained in:
Michael Kirsch 2019-04-07 00:04:01 +02:00 committed by Joseph Lenox
parent 25f3df624d
commit 44d6a7ff2b
4 changed files with 20 additions and 11 deletions

View File

@ -1010,6 +1010,21 @@ ModelVolume::swap(ModelVolume &other)
std::swap(this->input_file_vol_idx, other.input_file_vol_idx);
}
TriangleMesh
ModelVolume::get_transformed_mesh(TransformationMatrix const * additional_trafo = nullptr) const
{
TransformationMatrix trafo = this->trafo;
if(additional_trafo)
{
trafo.applyLeft(*(additional_trafo));
}
TriangleMesh mesh = TriangleMesh::TriangleMesh();
std::vector<float> trafo_arr = trafo.matrix3x4f();
stl_transform(&(this->mesh.stl), &(mesh.stl), trafo_arr.data());
stl_invalidate_shared_vertices(&(mesh.stl));
return mesh;
}
t_model_material_id
ModelVolume::material_id() const
{

View File

@ -477,6 +477,11 @@ class ModelVolume
/// \return ModelObject* pointer to the owner ModelObject
ModelObject* get_object() const { return this->object; };
/// Get the ModelVolume's mesh, transformed by the ModelVolume's TransformationMatrix
/// \param additional_trafo optional additional transformation
/// \return TriangleMesh the transformed mesh
TriangleMesh get_transformed_mesh(TransformationMatrix const * additional_trafo = nullptr) const;
/// Get the material id of this ModelVolume object
/// \return t_model_material_id the material id string
t_model_material_id material_id() const;

View File

@ -280,15 +280,6 @@ TriangleMesh::WriteOBJFile(const std::string &output_file) const {
#endif
}
TriangleMesh TriangleMesh::transform(const TransformationMatrix &trafo) const
{
TriangleMesh mesh = TriangleMesh::TriangleMesh();
std::vector<float> trafo_arr = trafo.matrix3x4f();
stl_transform(&this->stl, &(mesh.stl), trafo_arr.data());
stl_invalidate_shared_vertices(&(mesh.stl));
return mesh;
}
void TriangleMesh::scale(float factor)
{
stl_scale(&(this->stl), factor);

View File

@ -63,8 +63,6 @@ class TriangleMesh
bool is_manifold() const;
void WriteOBJFile(const std::string &output_file) const;
TriangleMesh transform(const TransformationMatrix &trafo) const;
void scale(float factor);
void scale(const Pointf3 &versor);