Skip to content

Instantly share code, notes, and snippets.

@sloriot
Created July 9, 2018 07:59
Show Gist options
  • Save sloriot/7093e7e4a77a494f0df8b3389f09e8f7 to your computer and use it in GitHub Desktop.
Save sloriot/7093e7e4a77a494f0df8b3389f09e8f7 to your computer and use it in GitHub Desktop.
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Polygon_mesh_processing/bbox.h>
#include <CGAL/boost/graph/helpers.h>
#include <CGAL/Surface_mesh.h>
typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
typedef CGAL::Surface_mesh<K::Point_3> SM;
template <class Point, class Vector>
struct Translate_point_map
{
typedef Point value_type;
typedef Point reference;
typedef boost::readable_property_map_tag category;
typedef typename CGAL::Surface_mesh<Point>::Vertex_index key_type;
Translate_point_map(const CGAL::Surface_mesh<Point>& sm,
const Vector& v)
: sm(sm)
, v(v)
{}
friend value_type get(const Translate_point_map& m, key_type k)
{
return m.sm.point(k) + m.v;
}
const CGAL::Surface_mesh<Point>& sm;
Vector v;
};
int main()
{
// create a tetrahedron mesh
SM sm;
CGAL::make_tetrahedron(K::Point_3(0,0,0),
K::Point_3(0,1,0),
K::Point_3(1,0,0),
K::Point_3(1,1,0),
sm);
CGAL::Bbox_3 bbox1 = CGAL::Polygon_mesh_processing::bbox(sm);// using the default point map
Translate_point_map<K::Point_3, K::Vector_3> vpm(sm, K::Vector_3(1,1,1));
CGAL::Bbox_3 bbox2 = CGAL::Polygon_mesh_processing::bbox(sm,
CGAL::parameters::vertex_point_map(vpm));// using the default point map
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment