Skip to content

Instantly share code, notes, and snippets.

@bo0ts
Forked from visorz/gist:a6e1f6a2e3ded3519109
Last active September 23, 2015 09:41
Show Gist options
  • Save bo0ts/eb5c58e138f3e120aeb5 to your computer and use it in GitHub Desktop.
Save bo0ts/eb5c58e138f3e120aeb5 to your computer and use it in GitHub Desktop.
A minimal demonstration of what an point iterator in Surfacemesh should be able to do.
#include <CGAL/Simple_cartesian.h>
typedef CGAL::Simple_cartesian<double> Kernel;
typedef Kernel::FT Scalar;
typedef Kernel::Point_3 Point;
typedef Kernel::Vector_3 Vector;
#include <CGAL/Surface_mesh.h>
typedef CGAL::Surface_mesh<Point> Surfacemesh;
#include <CGAL/centroid.h>
#include <CGAL/bounding_box.h>
// uses boost iterators
#include <boost/ref.hpp>
template <class SM>
struct V2P {
typedef Point result_type;
boost::reference_wrapper<const SM> sm;
V2P( SM& sm ) : sm( sm ) {}
const Point& operator()( typename SM::Vertex_index v ) const { return sm.get().point( v ); }
};
int main( int argc, char* argv[] )
{
Surfacemesh s;
typedef boost::transform_iterator<V2P<Surfacemesh>, Surfacemesh::Vertex_iterator> Point_iterator;
V2P<Surfacemesh> v2p( s );
Point_iterator b = boost::make_transform_iterator( s.vertices().begin(), v2p );
Point_iterator e = boost::make_transform_iterator( s.vertices().end(), v2p );
CGAL::centroid( b, e ); // succeeds
CGAL::bounding_box( b, e ); // fails
return EXIT_SUCCESS;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment