CGAL:继承和内核

3

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”,则可以编译,但我想我会错过来自扩展的属性吗?因为我得到错误

  • “Constructor not available for this kernel”

    当我运行程序时

2个回答

2

定义自己的内核的正确方法在以下页面中描述。

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


我已根据手册中的方法编辑了我的代码,感谢您的参考。不幸的是,它仍然无法正常工作。我对手册示例中使用的“K_Base :: template Base <K_> :: Type”有点困惑。 - Johannes

0

Ben,你能详细说明一下你的答案吗?如果你向OP解释链接内容并概述要点,你的答案会更好。 - Dave Alperovich
即使链接包含完整答案,您也应该至少添加简短的解释。 - IvanH

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接