2013-02-08 53 views
0

我想從CGAL :: Parabola_segment_2類派生。因爲我想訪問兩個 受保護的數據成員,這些成員不能通過公共成員函數訪問。從與CGAL兼容的CGAL類派生:: assign

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()函數兼容?

回答

0

不要使用模板演繹,並明確預期的類型。那就是:

如果(CGAL ::分配>(PS,O)){ ... }