Skip to content

Introduction

Justin edited this page Jan 20, 2022 · 7 revisions

CGAL stands for computational geometric algorithm library and offers a range of algorithms from Triangulations, Voronoi diagrams, Boolean operations on polygons and polyhedra, point set processing, arrangements of curves, surface and volume mesh generation, geometry processing, alpha shapes, convex hull algorithms, shape reconstruction and much more.

Computation geometry algorithm's often suffer from precision issues which can produce invalid results. CGAL offers a solution to this by providing numbers with exact representation which can represent any number with no loss in precision. This exact representation is highly optimized but there is a trade off in performance. CGAL also offers a inexact number representation using double precision when performance is need over exact results.

CGALDotNet is a C# wrapper around the C++ CGAL and provides convenient access to CGAL but does have some limitations. CGALDotNet provides a range of geometric structs such as points, vectors, boxes, circles and more to pass data to CGAL. These C# structs are limited to double precision so some precision maybe loss when parsing data back and forth to CGAL's exact representation.

Below is a example of creating a polygon using a exact representation.

//create some points.
var points = new Point2d[count];

//create a polygon using the exact predicates exact construction kernel.
var polygon = new Polygon2<EEK>();

//set the polygons points.
polygon.SetPoints(points);

Below is a example of creating a polygon using a inexact representation.

//create some points.
var points = new Point2d[count];

//create a polygon using the exact predicates inexact construction kernel.
var polygon = new Polygon2<EIK>();

//set the polygons points.
polygon.SetPoints(points);

See the CGAL home page on the exact computation paradigm.

Clone this wiki locally