add function of transformed bb in mesh

This commit is contained in:
Michael Kirsch 2019-06-02 21:03:23 +02:00 committed by Joseph Lenox
parent 564377e17a
commit 4e148608eb
2 changed files with 21 additions and 0 deletions

View File

@ -576,6 +576,26 @@ TriangleMesh::bounding_box() const
return bb;
}
BoundingBoxf3
TriangleMesh::get_transformed_bounding_box(TransformationMatrix const & trafo) const
{
BoundingBoxf3 bbox;
for (int i = 0; i < this->stl.stats.number_of_facets; ++ i) {
const stl_facet &facet = this->stl.facet_start[i];
for (int j = 0; j < 3; ++ j) {
double v_x = facet.vertex[j].x;
double v_y = facet.vertex[j].y;
double v_z = facet.vertex[j].z;
Pointf3 poi;
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;
}
void
TriangleMesh::require_shared_vertices()
{

View File

@ -75,6 +75,7 @@ class TriangleMesh
ExPolygons horizontal_projection() const;
Polygon convex_hull();
BoundingBoxf3 bounding_box() const;
BoundingBoxf3 get_transformed_bounding_box(TransformationMatrix const & trafo) const;
void reset_repair_stats();
bool needed_repair() const;
size_t facets_count() const;