Skip to content

Linear kernel documentation vs Minkowski sum code #2010

Open
@chgans

Description

@chgans

Issue Details

In it's section "Extensive Example", the Linear Kernel documentation claims that one doesn't need a custom point with a CGAL::Origin ctor, this is not true, at least when using minkowski sum as Point_2 Minkowski_sum_by_reduced_convolution_2::get_point(...) calls directly Point_2(Origin)

Which means that when using minkowski, you cannot use your custom Point class without explicitely depending on CGAL headers.

Not sure if the documentation needs an update or if minkowski sum needs a fix, or if actually there is no point in trying to use your own Point class with polygons?

Fixing the above isn't enough to use minkowski with the 'Extensive Example' code, one has to fix MyConstruct_coord_iterator. eg. from:

class MyConstruct_coord_iterator {
public:
  const double* operator()(const MyPointC2& p)
  {
    return &p.x();
  }
  const double* operator()(const MyPointC2& p, int)
  {
    const double* pyptr = &p.y();
    pyptr++;
    return pyptr;
  }
};

to

class MyConstruct_coord_iterator {
public:
    typedef const double *result_type;

  result_type operator()(const MyPointC2& p) const
  {
    return &p.x();
  }

  result_type operator()(const MyPointC2& p, int) const
  {
    result_type pyptr = &p.y();
    pyptr++;
    return pyptr;
  }
};

result_type was missing, and the operators were not const-correct.

Source Code

I took the files from Kernel_23/examples/Kernel_23/, and started to poke around with polygons and minkowski sums, didn't modify anything else than the above changes to MyConstruct_coord_iterator.

#include "MyKernel.h"

#include <CGAL/Polygon_2.h>
#include <CGAL/minkowski_sum_2.h>

typedef MyKernel<double> Kernel;
typedef Kernel::Point_2 Point;
typedef CGAL::Polygon_2<Kernel> Polygon;
typedef CGAL::Polygon_with_holes_2 <Kernel> Polygon_with_holes;

int main(int /*argc*/, char **/*argv*/)
{
    Polygon polygon1;
    polygon1.push_back(MyPointC2(0, 0));
    polygon1.push_back(MyPointC2(10, 0));
    polygon1.push_back(MyPointC2(10, 10));
    polygon1.push_back(MyPointC2(0, 10));

    Polygon polygon2;
    polygon2.push_back(MyPointC2(-1, 1));
    polygon2.push_back(MyPointC2(-1, -1));
    polygon2.push_back(MyPointC2(1, -1));
    polygon2.push_back(MyPointC2(1, 1));

    // This fails to compile 
    Polygon_with_holes polygon3 = CGAL::minkowski_sum_2(polygon1, polygon2);

    return 0;
}

Environment

KUbuntu 64 bits, defaults packages.

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions