Subject: CGAL users discussion list
List archive
- From: "Sebastien Loriot (GeometryFactory)" <>
- To:
- Subject: Re: [cgal-discuss] Inheriting from Extended_homogeneous
- Date: Tue, 24 Apr 2012 11:27:42 +0200
Have a look at the attached file where vertex and halffacet have an extra data member.
Sebastien.
On 04/24/2012 09:14 AM, Johannes Ulén wrote:
Thank you for the reply.
Is there a way to change the point construct?
Let me very breifly explain what I want to do and my problem might
become clearer.
1) I want to create a polytope where each vertex starts with boolean
value set to false.
2) For each vertex which is false I do some calculations and perform
an intersection with a halfspace. The polytope is now reshaped and has
more vertices.
3) A certain opertaion will mark a vertex as "true" and I then dont
need to bother with it anymore.
My programing instict tells me that the easiet way to to do this would
be to change point class, but I might be wrong?
-- Johannes
Den 24 april 2012 08:37 skrev Sebastien Loriot (GeometryFactory)
<>:
On 04/23/2012 02:55 PM,
wrote:
I'm trying the add one property to the point class.
By help from StackOverflow I was directed to Manual Chapter 11.5
Extensible
Kernel using this I wrote the code below.
The code will not compile and I get the error:
‘typename CGAL::Extended_homogeneous::Base’ names
'CGAL::Extended_homogeneous::Base’, which is not a class template|
== CODE ==
#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_> >
{};
#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;
}
====
If the inhertiance is changed to "public K_Base::Base::template
B<K_>::Type" it
will compile but Then I miss the propeties from Extentensions I guess?
Because
I get the error "Constructor not available for this kernel" when I run the
program.
The point constructors are not changed by this mechanism. This means that
only those documented are available. If you want to initialize your extra
data, you need to first create an object of type My_point and then init a
point of type MyKernel::Point_3 with it.
The class in the kernel is a kind of interface while My_point is the
representation.
Sebastien.
--
You are currently subscribed to cgal-discuss.
To unsubscribe or access the archives, go to
https://lists-sop.inria.fr/wws/info/cgal-discuss
#include <CGAL/Exact_predicates_exact_constructions_kernel.h> #include <CGAL/Polyhedron_3.h> #include <CGAL/IO/Polyhedron_iostream.h> #include <CGAL/Nef_polyhedron_3.h> #include <CGAL/IO/Nef_polyhedron_iostream_3.h> #include <CGAL/OFF_to_nef_3.h> #include <iostream> #include <fstream> /////////// Defining an item class with data in Vertex and Halffacets /////////// template <class Kernel,class Refs,class T> class Vertex_base_with_data: public CGAL::Default_items<Kernel>::Items:: template Vertex<Refs>{ mutable T m_data; public: T& data() const {return m_data;} }; template <class Kernel,class Refs,class T> class Halffacet_base_with_data: public CGAL::Default_items<Kernel>::Items:: template Halffacet<Refs>{ mutable T m_data; public: T& data() const {return m_data;} }; //Kernel is the type used as Kernel for the Nef polyhedron T is the tyep of extra data that //need to be stored template<class Kernel,class T> struct SNC_item_with_data : public CGAL::Default_items<Kernel>::Items{ template <class Refs> class Vertex : public Vertex_base_with_data<Kernel,Refs,T> {}; template <class Refs> class Halffacet : public Halffacet_base_with_data<Kernel,Refs,T>{}; }; /////////// DONE /////////// //Test this is working typedef CGAL::Exact_predicates_exact_constructions_kernel Kernel; typedef CGAL::Polyhedron_3<Kernel> Polyhedron; typedef CGAL::Nef_polyhedron_3<Kernel,SNC_item_with_data<Kernel,int> > Nef_polyhedron; typedef Nef_polyhedron::Vertex_iterator Vertex_iterator; typedef Nef_polyhedron::Vertex_const_iterator Vertex_const_iterator; typedef Nef_polyhedron::Halffacet_const_iterator Halffacet_const_iterator; int main(int argc, char *argv[]) { if (argc<2){std::cerr <<"Please provided an input off file\n"; return 1;} std::ifstream off(argv[1]); if (!off){ std::cerr<<"Cannot open file " << argv[1] <<"\n"; return 1; } Polyhedron P; off >> P; Nef_polyhedron N(P); for (Vertex_const_iterator vit=N.vertices_begin(), vit_end=N.vertices_end(); vit!=vit_end;++vit) { vit->data()=1; std::cout << vit->data() << std::endl; } for (Halffacet_const_iterator hfit=N.halffacets_begin(), hfit_end=N.halffacets_end(); hfit!=hfit_end;++hfit) { hfit->data()=2; std::cout << hfit->data() << std::endl; } }
- [cgal-discuss] Inheriting from Extended_homogeneous, ulen, 04/23/2012
- Re: [cgal-discuss] Inheriting from Extended_homogeneous, Sebastien Loriot (GeometryFactory), 04/24/2012
- Re: [cgal-discuss] Inheriting from Extended_homogeneous, Johannes Ulén, 04/24/2012
- Re: [cgal-discuss] Inheriting from Extended_homogeneous, Sebastien Loriot (GeometryFactory), 04/24/2012
- Re: [cgal-discuss] Inheriting from Extended_homogeneous, Johannes Ulen, 04/24/2012
- Re: [cgal-discuss] Inheriting from Extended_homogeneous, Sebastien Loriot (GeometryFactory), 04/25/2012
- Re: [cgal-discuss] Inheriting from Extended_homogeneous, Johannes Ulen, 04/25/2012
- Re: [cgal-discuss] Inheriting from Extended_homogeneous, Sebastien Loriot (GeometryFactory), 04/25/2012
- Re: [cgal-discuss] Inheriting from Extended_homogeneous, Johannes Ulen, 04/25/2012
- Re: [cgal-discuss] Inheriting from Extended_homogeneous, Sebastien Loriot (GeometryFactory), 04/25/2012
- Re: [cgal-discuss] Inheriting from Extended_homogeneous, Johannes Ulén, 04/24/2012
- <Possible follow-up(s)>
- Re: [cgal-discuss] Inheriting from Extended_homogeneous, Tomislav Maric, 04/24/2012
- Re: [cgal-discuss] Inheriting from Extended_homogeneous, Sebastien Loriot (GeometryFactory), 04/24/2012
Archive powered by MHonArc 2.6.16.