【问题标题】:CGAL: Inheritance and the kernelCGAL:继承和内核
【发布时间】:2012-04-20 07:25:38
【问题描述】:

CGAL 问题:

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

编辑:根据下面的评论,我将继承更改为手册中描述的方式。下面的代码给出了以下编译错误:

  • ‘typename CGAL::Extended_homogeneous::Base’命名‘CGAL::Extended_homogeneous::Base’,它不是类模板|

等等。

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

如果将继承更改为“public K_Base::Base::template B::Type”,它将编译,但我猜想我错过了扩展的属性?因为我得到了错误

  • “此内核无法使用构造函数”

    当我运行程序时

【问题讨论】:

    标签: cgal


    【解决方案1】:

    定义自己的内核的正确方法如下所述 page.

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

    【讨论】:

    • 我已经按照手册中使用的方法编辑了我的代码,谢谢你的参考。不幸的是,我仍然无法让它工作。我对手册示例中使用的“K_Base::template Base::Type”有点困惑。
    【解决方案2】:

    您应该在此处阅读此主题(请参阅 Sebastien 的第 4 篇文章): http://cgal-discuss.949826.n4.nabble.com/Exact-kernels-and-planes-td4655222.html

    它稍微解释了问题。

    【讨论】:

    • 本,你能扩展你的答案吗?如果您向 OP 解释链接包含的内容并给出要点概要,您的答案会更好。
    • 即使链接包含完整的答案,您也应该至少添加简短的解释。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-12-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-11-11
    相关资源
    最近更新 更多