CGAL:继承和内核 [英] CGAL: Inheritance and the kernel

查看:125
本文介绍了CGAL:继承和内核的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

CGAL问题:

我正在尝试将一个属性添加到点类。我想的第一步是继承一个内核,并用我从CGAL继承的我的Point类替换Point类。但是,只是试图迈出这一小小的第一步,我就遇到了麻烦。

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.

编辑:基于以下注释,我将继承方式更改为《手册》中所述的方式。下面的代码给出以下编译错误:

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'名称'CGAL :: Extended_homogeneous :: Base ',这不是课程模板|

#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



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;
}

如果将继承关系更改为 public K_Base :: Base :: template B :: Type,它将进行编译,但是我想念扩展的特性了吗?因为出现错误

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"

当我运行程序时

推荐答案

定义正确的方法以下
中描述了您自己的内核 page

由于类型相等包装器使
Kernel :: Point_2等于Point_2,所以事情看起来很复杂。

The things look complicated because of the type equality wrapper which makes Kernel::Point_2 equal to Point_2.

这篇关于CGAL:继承和内核的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆