Subject: CGAL users discussion list
List archive
- From: Ben Supnik <>
- To:
- Subject: Re: [cgal-discuss] Inheritance of Polygon_2.
- Date: Sat, 03 Oct 2009 08:53:54 -0400
Hi,
When you sub-class a CGAL type you may have to "copy out" to the sub-class two possible sets of stuff:
1. type-defs...because the template typedefs work off a specific typename and do not know about inheritance. So whatever types are declared inside Polgon_2, you need to "map".
Example I did with GPS2:
class Polygon_set_2 : public CGAL::General_polygon_set_2<Traits_2, Dcel >
{
public:
typedef CGAL::General_polygon_set_2<Traits_2, Dcel > base;
typedef base::Traits_2 Traits_2;
typedef base::Dcel Dcel;
typedef base::Polygon_2 Polygon_2;
typedef base::Polygon_with_holes_2 Polygon_with_holes_2;
typedef base::Arrangement_2 Arrangement_2;
typedef std::size_t Size;
You may also have to wrap the constructors...C++ won't write a ctor taking type X automatically just because your base class has one.
cheers
Ben
wrote:
Hello,
Beware : I might be a silly question !
To be able to add some functionalities (like void draw() or void setName) to
Polygon_2 class, I'm looking for the way to inherit from the class.
To aim that I did the following declaration for my new class :
...
#include <CGAL/Polygon_2.h>
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
typedef K::Point_2 Point;
typedef CGAL::Polygon_2<K> Polygon_2;
class AC_Polygon : public CGAL::Polygon_2<Polygon_2>
{
public:
AC_Polygon();
~AC_Polygon();
void draw() const;
};
...
It compiles well, but when I instantiate my new class AC_Polygon,
I do not have the methods like :
is_simple()
is_convex()
the compiler says :
/usr/include/CGAL/Polygon_2/Polygon_2_simplicity.h:135: erreur: no type named
«Orientation_2» in «class
CGAL::Polygon_2<CGAL::Filtered_kernel<CGAL::Simple_cartesian<double> >,
std::vector<CGAL::Point_2<CGAL::Filtered_kernel<CGAL::Simple_cartesian<double>
std::allocator<CGAL::Point_2<CGAL::Filtered_kernel<CGAL::Simple_cartesian<double>,
»
Any ideas
Gilles-- You are currently subscribed to cgal-discuss.
To unsubscribe or access the archives, go to
https://lists-sop.inria.fr/wws/info/cgal-discuss
--
Scenery Home Page: http://scenery.x-plane.com/
Scenery blog: http://xplanescenery.blogspot.com/
Plugin SDK: http://www.xsquawkbox.net/xpsdk/
X-Plane Wiki: http://wiki.x-plane.com/
Scenery mailing list:
Developer mailing list:
- [cgal-discuss] Inheritance of Polygon_2., gilles.kneuss, 10/03/2009
- Re: [cgal-discuss] Inheritance of Polygon_2., Ben Supnik, 10/03/2009
- Re: [cgal-discuss] Inheritance of Polygon_2., gilles, 10/03/2009
- Re: [cgal-discuss] Inheritance of Polygon_2., gilles, 10/03/2009
- Re: [cgal-discuss] Inheritance of Polygon_2., Ben Supnik, 10/03/2009
- Re: [cgal-discuss] Inheritance of Polygon_2., Ben Supnik, 10/03/2009
- Re: [cgal-discuss] Inheritance of Polygon_2., Ben Supnik, 10/03/2009
Archive powered by MHonArc 2.6.16.