Search code examples
c++cgal

Syntax error for CGAL Affine Transformation


I'm trying to do a simple 3D translation using the CGAL library, and I'm evidently confused by the syntax because I keep getting the same compile-time error no matter what I try. Here is a minimal "non-working" example:

#include <CGAL/Simple_cartesian.h>
#include <CGAL/Polyhedron_3.h>
#include <CGAL/Vector_3.h>
#include <CGAL/Aff_transformation_3.h>
#include <CGAL/Aff_transformation_tags.h>

typedef CGAL::Simple_cartesian<double>     Kernel;
typedef CGAL::Polyhedron_3<Kernel>         Polyhedron;
typedef Kernel::Vector_3                   Vector_3;
typedef CGAL::Aff_transformation_3<Kernel> Aff_transformation_3;

int main(void)
{
    Polyhedron P;
    P.make_tetrahedron();

    const Vector_3 transvec(-1,0,2);

    Aff_transformation_3 transl(CGAL::Translation, transvec);
    transform(P.points_begin(),P.points_end(),P.points_begin(),transl);
}

I try to compile with

g++ -O2 -frounding-math -I/usr/local/include -I/opt/local/include mwe.cc -Wl, -lCGAL -lCGAL_Core -lCGAL_ImageIO -lmpfr -lgmp -lm -o mwe

upon which I invariably receive this error:

mwe.cc:19:52: error: unknown type name 'transvec'
Aff_transformation_3 transl(CGAL::Translation, transvec);

Solution

  • CGAL::Translation is the name of a class -- you want CGAL::TRANSLATION, which is the name of an instance of that class.