问题
CGAL question:
Im trying the add one property to the point class. The first step I guess is to inherit a kernel and replace the point class with my own which I inherit from CGAL's. But just trying to get this small first step I run into trouble.
Edit: Based on the comment below I changed the inheritance to the way it's described in the Manual. The code below gives the following compile error:
- ‘typename CGAL::Extended_homogeneous::Base’ names 'CGAL::Extended_homogeneous::Base’, which is not a class template|
among others.
MyBase.h
#include <CGAL/Extended_homogeneous.h>
template < typename K_, typename K_Base >
class My_base : public K_Base::template Base<K_>::Type
{
typedef typename K_Base::template Base<K_>::Type OldK;
public:
typedef K_ Kernel;
template < typename Kernel2 >
struct Base { typedef My_base<Kernel2, K_Base> Type; };
};
template < typename RT_ >
struct MyKernel : public CGAL::Type_equality_wrapper<My_base<MyKernel<RT_>, CGAL::Homogeneous<RT_> >, MyKernel<RT_> >
{};
Minimal.cpp
#include "MyKernel.h"
#include <CGAL/Nef_polyhedron_3.h>
typedef MyKernel<CGAL::Gmpz> Kernel;
typedef CGAL::Nef_polyhedron_3<Kernel> Nef_Polyhedron;
typedef Nef_Polyhedron::Plane_3 Plane;
int main()
{
Nef_Polyhedron half_space(Plane(1,1,1,1), Nef_Polyhedron::EXCLUDED);
return 0;
}
If the inhertiance is changed to "public K_Base::Base::template B::Type" it will compile but Then I miss the propeties from the Extentensions I guess? Because I get the error
"Constructor not available for this kernel"
when I run the program
回答1:
The correct way to define your own kernel is described on the following page.
The things look complicated because of the type equality wrapper which makes Kernel::Point_2 equal to Point_2.
回答2:
You should read this thread here (see the 4th post by Sebastien): http://cgal-discuss.949826.n4.nabble.com/Exact-kernels-and-planes-td4655222.html
It explains the problem a little bit.
来源:https://stackoverflow.com/questions/10241969/cgal-inheritance-and-the-kernel