我想从CGAL::Parabola_segment_2类派生。因为我想访问两个受保护的数据成员,这两个成员无法通过公共成员函数访问。
typedef CGAL::Exact_predicates_exact_constructions_kernel Kernel;
typedef CGAL::Segment_Delaunay_graph_traits_without_intersections_2< Kernel,
CGAL::Integral_domain_without_division_tag> Gt;
typedef CGAL::Segment_Delaunay_graph_2<Gt> SDG_2;
typedef SDG_2::Vertex_handle Vertex_handle;
typedef SDG_2::Finite_edges_iterator Finite_edges_iterator;
typedef Gt::Line_2 Line_2;
typedef Gt::Ray_2 Ray_2;
typedef Gt::Segment_2 Segment_2;
typedef Gt::Point_2 Point_2;
typedef Gt::Site_2 Site_2;
class Parabola_segment_2 : public CGAL::Parabola_segment_2<Gt> { };我的代码可以编译并运行,但下面给出的代码中的if语句从不返回true。但我确信对于某些值,它必须返回true。
.......
CGAL::Object o = sdg.primal(*eit);
Segment_2 s;
Parabola_segment_2 ps;
if(CGAL::assign(s, o)) {
...
}如果我改变了
class Parabola_segment_2 : public CGAL::Parabola_segment_2<Gt> { };使用
typedef CGAL::Parabola_segment_2<Gt> Parabola_segmet_2;然后程序完全按照我想要的方式执行,但是我不能访问我想要的变量。我的问题是,我应该如何派生CGAL类,使其与CGAL::assign()函数兼容?
发布于 2013-02-11 14:02:51
不要使用模板演绎,并明确预期的类型。这就是:
if( CGAL::assign<CGAL::Parabola_segment_2<Gt> >(ps, o)) {
...
}https://stackoverflow.com/questions/14782563
复制相似问题