Using CGAL with Core Library

Using CGAL with Core Library

Here is an example of code to use CORE's Expr class as number type in a CGAL kernel. The necessary interface functions are available in the file CGAL_Expr.h.

#include <iostream>
#include <CGAL_Expr.h> // From CORE 1.4.1
#include <CGAL/Cartesian.h>

typedef Expr                  NT;
typedef CGAL::Cartesian<NT>   Kernel;
typedef Kernel::Point_2       Point_2;

int main()
  Point_2 A(NT("0.1"), NT("0.2")); // We use strings to ensure exact
  Point_2 B(NT("1.1"), NT("3.2")); // decimal representation.
  Point_2 C(NT("3.1"), NT("5.4"));

  // Compute the circumcenter of A, B, C.
  Point_2 D = CGAL::circumcenter(A, B, C);

  // Verify that D is at the same distance from A, B and C.
  NT AD = CGAL::squared_distance(A, D);
  NT BD = CGAL::squared_distance(B, D);
  NT CD = CGAL::squared_distance(C, D);

  if (AD != BD || AD != CD)
    std::cerr << "Not supposed to happen." << std::endl;
    std::cout << "Exact computation." << std::endl;

  return 0;
You can download the file CGAL_Expr.h here.
And here is the above example program core_example.C.