#include#include #include #include int main(){ Open3D::PointCloud point_cloud; point_cloud.LoadFromFile("test.ply"); Open3D::AxisAlignedBoundingBox bbox = point_cloud.GetAxisAlignedBoundingBox(); Open3D::Vector3d center = bbox.GetCenter(); std::cout << "Center: (" << center[0] << "," << center[1] << "," << center[2] << ")" << std::endl; return 0; }
#includeBoth examples use different packages and libraries to manipulate the BBox Bounds of an object. Example 1 uses the Open3D library and Example 2 uses the CGAL library.#include #include #include #include #include typedef CGAL::Simple_cartesian K; typedef K::Point_3 Point_3; typedef CGAL::Polyhedron_3 Polyhedron; typedef CGAL::AABB_polyhedron_triangle_primitive Primitive; typedef CGAL::AABB_traits Traits; typedef CGAL::AABB_tree Tree; int main(){ Polyhedron mesh; std::ifstream input("test.off"); input >> mesh; Tree tree(faces(mesh).first, faces(mesh).second, mesh); double scale_factor = 2.0; CGAL::Bbox_3 bbox = tree.root_bbox(); bbox = bbox * scale_factor; tree.refit(); std::cout << "New BBox Bounds: (" << bbox.xmin() << "," << bbox.ymin() << "," << bbox.zmin() << ") - (" << bbox.xmax() << "," << bbox.ymax() << "," << bbox.zmax() << ")" << std::endl; return 0; }