Access the indices of vertices, edges and facets from power diagram

classic Classic list List threaded Threaded
15 messages Options
Reply | Threaded
Open this post in threaded view
|

Access the indices of vertices, edges and facets from power diagram

BRYang
Hi, I am trying to compute the power diagram of some spheres, and access the
indices of the vertices.
For now, I access the vertices, edges and facets with the
Finite_vertices_iterator fvi, Finite_edges_iterator fei and
Finite_facets_iterator ffi, and access the vertices as follows:
//vertex:
   fvi->point()
//two vertices of edge:
   fei->first->vertex(fei->second)->point()
   fei->first->vertex(fei->third)->point()
//three vertices of facet:
   ffi->first->vertex(0)->point()
   ffi->first->vertex(1)->point()
   ffi->first->vertex(2)->point()

Am I doing it right?

The other problem is that is there a way to access the indices of vertices
of the edges and faces? Thank you!



--
Sent from: http://cgal-discuss.949826.n4.nabble.com/

--
You are currently subscribed to cgal-discuss.
To unsubscribe or access the archives, go to
https://sympa.inria.fr/sympa/info/cgal-discuss


Reply | Threaded
Open this post in threaded view
|

Re: Access the indices of vertices, edges and facets from power diagram

MaelRL
Hello,

Your way to access geometric points is correct.

By default there is no index associated to vertices (internally,
everything is done with pointers). However, you can use vertices with
info (see e.g. this documentation example
https://doc.cgal.org/latest/Triangulation_3/Triangulation_3_2regular_with_info_3_8cpp-example.html)
and associate a unique ID to each of your vertex. Then you can simply
get the ID with fvi->info().

Best,
Mael

On 18/06/2019 04:32, BRYang wrote:

> Hi, I am trying to compute the power diagram of some spheres, and access the
> indices of the vertices.
> For now, I access the vertices, edges and facets with the
> Finite_vertices_iterator fvi, Finite_edges_iterator fei and
> Finite_facets_iterator ffi, and access the vertices as follows:
> //vertex:
>     fvi->point()
> //two vertices of edge:
>     fei->first->vertex(fei->second)->point()
>     fei->first->vertex(fei->third)->point()
> //three vertices of facet:
>     ffi->first->vertex(0)->point()
>     ffi->first->vertex(1)->point()
>     ffi->first->vertex(2)->point()
>
> Am I doing it right?
>
> The other problem is that is there a way to access the indices of vertices
> of the edges and faces? Thank you!
>
>
>
> --
> Sent from: http://cgal-discuss.949826.n4.nabble.com/
>

--
You are currently subscribed to cgal-discuss.
To unsubscribe or access the archives, go to
https://sympa.inria.fr/sympa/info/cgal-discuss


Reply | Threaded
Open this post in threaded view
|

Re: Access the indices of vertices, edges and facets from power diagram

BRYang
Thank you, Mael. That's what exactly I want.

Best,
Baorong Yang



--
Sent from: http://cgal-discuss.949826.n4.nabble.com/

--
You are currently subscribed to cgal-discuss.
To unsubscribe or access the archives, go to
https://sympa.inria.fr/sympa/info/cgal-discuss


Reply | Threaded
Open this post in threaded view
|

Re: Access the indices of vertices, edges and facets from power diagram

BRYang
In reply to this post by MaelRL
Hi, Mael.

I am now using CGAL with version  4.8.2, and I find that Weighted_point_3 is
not a member of 'CGAL::Epick', but a member of
'CGAL::Regular_triangulation_euclidean_traits_3'.

Is there still an index associated to each of the vertices in the 4.8.2
version of CGAL? Or we can only fix this with a higher version of CGAL?

Thank you!

Best,
Baorong Yang



--
Sent from: http://cgal-discuss.949826.n4.nabble.com/

--
You are currently subscribed to cgal-discuss.
To unsubscribe or access the archives, go to
https://sympa.inria.fr/sympa/info/cgal-discuss


Reply | Threaded
Open this post in threaded view
|

Re: Access the indices of vertices, edges and facets from power diagram

MaelRL

This doesn't change much: although at that point in time, weighted_point_3 was indeed not part of the kernel, the regular triangulation had the same parameters as it still does:

template < class Gt, class Tds_ = Default, class Lock_data_structure_ = Default >
class Regular_triangulation_3

Thus it would similarly be:

typedef CGAL::Regular_triangulation_euclidean_traits_3<K>  Traits;
typedef Traits::Weighted_point                              Weighted_point;

typedef CGAL::Regular_triangulation_3<Traits, Tds>               Rt;

Rt rt;
Rt::Vertex_handle vh = rt.insert(..)
vh->info() = my_id;
Weighted_point wp = vh->point();

etc.

Nevertheless, I can only advise you to switch to a much more recent version so that you can benefit from the various improvements.

Best,
Mael

On 18/06/2019 14:54, BRYang wrote:

Hi, Mael.

I am now using CGAL with version  4.8.2, and I find that Weighted_point_3 is
not a member of 'CGAL::Epick', but a member of
'CGAL::Regular_triangulation_euclidean_traits_3'. 

Is there still an index associated to each of the vertices in the 4.8.2
version of CGAL? Or we can only fix this with a higher version of CGAL?

Thank you!

Best,
Baorong Yang



--
Sent from: http://cgal-discuss.949826.n4.nabble.com/

Reply | Threaded
Open this post in threaded view
|

Re: Access the indices of vertices, edges and facets from power diagram

BRYang
Hi, Mael. I have tried to varify my code as follows:

//////////////////////////////////////

#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Regular_triangulation_3.h>
#include <CGAL/Regular_triangulation_euclidean_traits_3.h>
#include <CGAL/Regular_triangulation_cell_base_3.h>
#include <CGAL/Triangulation_vertex_base_3.h>
#include <CGAL/Triangulation_vertex_base_with_info_3.h>

typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
typedef CGAL::Regular_triangulation_euclidean_traits_3<K> Traits;
typedef Traits::Bare_point RTPoint;
typedef Traits::Weighted_point_3 Weighted_point;
typedef CGAL::Triangulation_vertex_base_3<K> Vb0;
typedef CGAL::Triangulation_vertex_base_with_info_3<Vb0, K> Vb;
typedef CGAL::Regular_triangulation_cell_base_3<K> Cb;
typedef CGAL::Triangulation_data_structure_3<Vb,Cb> Tds;
typedef CGAL::Regular_triangulation_3<Traits,Tds>
Regular_Triangulation;

//////////////////////

However, it is still reported that  'Weighted_point_3' is not a member of
'CGAL::Epick'. Could you please help to check if there is something wrong
with my code?

Thank you!

Best,
Baorong Yang



--
Sent from: http://cgal-discuss.949826.n4.nabble.com/

--
You are currently subscribed to cgal-discuss.
To unsubscribe or access the archives, go to
https://sympa.inria.fr/sympa/info/cgal-discuss


Reply | Threaded
Open this post in threaded view
|

Re: Access the indices of vertices, edges and facets from power diagram

MaelRL
"K" must be "Traits" everywhere (except in the definition of "Traits")

On 18/06/2019 16:05, BRYang wrote:

> Hi, Mael. I have tried to varify my code as follows:
>
> //////////////////////////////////////
>
> #include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
> #include <CGAL/Regular_triangulation_3.h>
> #include <CGAL/Regular_triangulation_euclidean_traits_3.h>
> #include <CGAL/Regular_triangulation_cell_base_3.h>
> #include <CGAL/Triangulation_vertex_base_3.h>
> #include <CGAL/Triangulation_vertex_base_with_info_3.h>
>
> typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
> typedef CGAL::Regular_triangulation_euclidean_traits_3<K> Traits;
> typedef Traits::Bare_point RTPoint;
> typedef Traits::Weighted_point_3 Weighted_point;
> typedef CGAL::Triangulation_vertex_base_3<K> Vb0;
> typedef CGAL::Triangulation_vertex_base_with_info_3<Vb0, K> Vb;
> typedef CGAL::Regular_triangulation_cell_base_3<K> Cb;
> typedef CGAL::Triangulation_data_structure_3<Vb,Cb> Tds;
> typedef CGAL::Regular_triangulation_3<Traits,Tds>
> Regular_Triangulation;
>
> //////////////////////
>
> However, it is still reported that  'Weighted_point_3' is not a member of
> 'CGAL::Epick'. Could you please help to check if there is something wrong
> with my code?
>
> Thank you!
>
> Best,
> Baorong Yang
>
>
>
> --
> Sent from: http://cgal-discuss.949826.n4.nabble.com/
>

--
You are currently subscribed to cgal-discuss.
To unsubscribe or access the archives, go to
https://sympa.inria.fr/sympa/info/cgal-discuss


Reply | Threaded
Open this post in threaded view
|

Re: Access the indices of vertices, edges and facets from power diagram

BRYang
Thank you, Mael. It works now.

Best,
Baorong Yang



--
Sent from: http://cgal-discuss.949826.n4.nabble.com/

--
You are currently subscribed to cgal-discuss.
To unsubscribe or access the archives, go to
https://sympa.inria.fr/sympa/info/cgal-discuss


Reply | Threaded
Open this post in threaded view
|

Re: Access the indices of vertices, edges and facets from power diagram

BRYang
In reply to this post by MaelRL
Hi, Mael.

I have now encountered another problem. That is, we can access the vertex of
regular triangulation with a vertex handle vh by vh->point(), however, since
the vertex isn't defined as a weighted point, we could not get the weight of
the vertex by vh->weight().

A way for solving this is get the nearest vertex handle vh of a weighted
point wp by the "nearest_power_vertex", but I believe that it could be
redundant when the number of weighted points is large. Is there an easy way
for accessing the corresponding weighted point of a vertex?

Thank you!

Best,
Baorong Yang




--
Sent from: http://cgal-discuss.949826.n4.nabble.com/

--
You are currently subscribed to cgal-discuss.
To unsubscribe or access the archives, go to
https://sympa.inria.fr/sympa/info/cgal-discuss


Reply | Threaded
Open this post in threaded view
|

Re: Access the indices of vertices, edges and facets from power diagram

Sebastien Loriot (GeometryFactory)
Should be vh->point()->weight().

Sebastien.

On 6/20/19 10:49 AM, BRYang wrote:

> Hi, Mael.
>
> I have now encountered another problem. That is, we can access the vertex of
> regular triangulation with a vertex handle vh by vh->point(), however, since
> the vertex isn't defined as a weighted point, we could not get the weight of
> the vertex by vh->weight().
>
> A way for solving this is get the nearest vertex handle vh of a weighted
> point wp by the "nearest_power_vertex", but I believe that it could be
> redundant when the number of weighted points is large. Is there an easy way
> for accessing the corresponding weighted point of a vertex?
>
> Thank you!
>
> Best,
> Baorong Yang
>
>
>
>
> --
> Sent from: http://cgal-discuss.949826.n4.nabble.com/
>

--
You are currently subscribed to cgal-discuss.
To unsubscribe or access the archives, go to
https://sympa.inria.fr/sympa/info/cgal-discuss


Reply | Threaded
Open this post in threaded view
|

Re: Access the indices of vertices, edges and facets from power diagram

Sebastien Loriot (GeometryFactory)
Sorry, I meant:
vh->point().weight()

Sebastien.

On 6/20/19 10:54 AM, Sebastien Loriot (GeometryFactory) wrote:

> Should be vh->point()->weight().
>
> Sebastien.
>
> On 6/20/19 10:49 AM, BRYang wrote:
>> Hi, Mael.
>>
>> I have now encountered another problem. That is, we can access the
>> vertex of
>> regular triangulation with a vertex handle vh by vh->point(), however,
>> since
>> the vertex isn't defined as a weighted point, we could not get the
>> weight of
>> the vertex by vh->weight().
>>
>> A way for solving this is get the nearest vertex handle vh of a weighted
>> point wp by the "nearest_power_vertex", but I believe that it could be
>> redundant when the number of weighted points is large. Is there an
>> easy way
>> for accessing the corresponding weighted point of a vertex?
>>
>> Thank you!
>>
>> Best,
>> Baorong Yang
>>
>>
>>
>>
>> --
>> Sent from: http://cgal-discuss.949826.n4.nabble.com/
>>

--
You are currently subscribed to cgal-discuss.
To unsubscribe or access the archives, go to
https://sympa.inria.fr/sympa/info/cgal-discuss


Reply | Threaded
Open this post in threaded view
|

Re: Access the indices of vertices, edges and facets from power diagram

BRYang
Thank you, Sebastien.



--
Sent from: http://cgal-discuss.949826.n4.nabble.com/

--
You are currently subscribed to cgal-discuss.
To unsubscribe or access the archives, go to
https://sympa.inria.fr/sympa/info/cgal-discuss


Reply | Threaded
Open this post in threaded view
|

Re: Access the indices of vertices, edges and facets from power diagram

BRYang
In reply to this post by MaelRL
Hi, Mael.

I am trying to access all the facets of the power diagram with
Finite_facets_iterator ffi, and I think that there are only three vertices
of each facet, that is, I can access the vertices of the facet by:
ffi->first->vertex(i)->point(), where i \in {0, 1, 2},

However, I can also access the fourth vertex of the facet by:
ffi->first->vertex(3)->point()

Am I doing it wrong? Does that mean there are four vertices for each facet,
and any three of them could shape a triangle?

Thank you!

Best,

Baorong Yang



--
Sent from: http://cgal-discuss.949826.n4.nabble.com/

--
You are currently subscribed to cgal-discuss.
To unsubscribe or access the archives, go to
https://sympa.inria.fr/sympa/info/cgal-discuss


Reply | Threaded
Open this post in threaded view
|

Re: Access the indices of vertices, edges and facets from power diagram

MaelRL

Hello,

You are manipulating the regular triangulation and its faces, not the Voronoi diagram. It is thus normal that the faces are triangles. To manipulate the power diagram, you can look at the dual() functions in your triangulation class, or use the 2D Voronoi adapter.

Best,
Mael

On 02/07/2019 10:35, BRYang wrote:
Hi, Mael.

I am trying to access all the facets of the power diagram with
Finite_facets_iterator ffi, and I think that there are only three vertices
of each facet, that is, I can access the vertices of the facet by: 
ffi->first->vertex(i)->point(), where i \in {0, 1, 2}, 

However, I can also access the fourth vertex of the facet by: 
ffi->first->vertex(3)->point()

Am I doing it wrong? Does that mean there are four vertices for each facet,
and any three of them could shape a triangle?

Thank you!

Best,

Baorong Yang



--
Sent from: http://cgal-discuss.949826.n4.nabble.com/

Reply | Threaded
Open this post in threaded view
|

Re: Access the indices of vertices, edges and facets from power diagram

BRYang
Thank you, Mael.

I will have a try.

Best,
Baorong



--
Sent from: http://cgal-discuss.949826.n4.nabble.com/

--
You are currently subscribed to cgal-discuss.
To unsubscribe or access the archives, go to
https://sympa.inria.fr/sympa/info/cgal-discuss