Skip to Content.
Sympa Menu

cgal-discuss - Re: [cgal-discuss] mark edges with Unique_hash_map

Subject: CGAL users discussion list

List archive

Re: [cgal-discuss] mark edges with Unique_hash_map


Chronological Thread 
  • From: "Sebastien Loriot (GeometryFactory)" <>
  • To:
  • Subject: Re: [cgal-discuss] mark edges with Unique_hash_map
  • Date: Thu, 22 Apr 2010 11:42:59 +0200

Hello,

I know nothing about CGAL::Unique_hash_map but from the documention,
http://www.cgal.org/Manual/last/doc_html/cgal_manual/Miscellany_ref/Concept_UniqueHashFunction.html#Cross_link_anchor_2005
you should also provide a functor model of UniqueHashFunction concept.
The only model listed is CGAL::Handle_hash_function (probably the default one used in your case).
Again from the doc:
http://www.cgal.org/Manual/last/doc_html/cgal_manual/Miscellany_ref/Class_Handle_hash_function.html#Cross_link_anchor_1997
hash(Handle key) member function doc says:
"returns unique hash value for any Handle type for which &*key gives a unique address."

Which in you case will be incorrect as edges are created on the fly (not stored in the Alpha_shape class).

My advice is to either write your own model of UniqueHashFunction for an Edge or you can also use a std::map with your own compare function.

Remember that one way to have a unique representation of an
edge is to use a *sorted* pair of Vertex_handle (Vertex_handle pointing on edge endpoints).


S.


Song Lin wrote:
Hi,

I'm trying to mark the edges of an alpha shape using Unique_hash_map.
Part of my codes are:

typedef Alpha_shape_3::Edge Edge;
typedef CGAL::Unique_hash_map<Edge,int> UhmEdge2int; << this line is ok

list<Weighted_point> lwp;
Alpha_shape_3 as(lwp.begin(), lwp.end(), 0, Alpha_shape_3::GENERAL);

Alpha_shape_3::Finite_edges_iterator eit;
UhmEdge2int uhmedge2int;

for (eit = as.finite_edges_begin(); eit != as.finite_edges_end();eit++)
{
if(as.classify(*eit,0)==Alpha_shape_3::REGULAR)
{
uhmedge2int[eit]=1; << there is an error with this line.
error: no
match for ‘operator[]’ in ‘uhmedge2int[eit]’
}
}

I also tried "uhmedge2int[*eit]" and it doesn't work.

But I thought I'm using it as the same way like in the example 51.4.2.

In example 51.4.2: "Example with edges marked as non-removable" a class
was build like this:

class Constrains_map : public boost::put_get_helper<bool,Constrains_map>
{
public:

typedef boost::readable_property_map_tag category;
typedef bool value_type;
typedef bool reference;
typedef boost::graph_traits<Surface const>::edge_descriptor key_type;

Constrains_map() : mConstrains(false) {}

reference operator[](key_type const& e) const { return e->is_border() ||
is_constrained(e) ; }
void set_is_constrained ( key_type const& e, bool is ) { mConstrains[e]=is; }
bool is_constrained( key_type const& e ) const { return mConstrains.is_defined(e) ? mConstrains[e] : false ; }
private:
CGAL::Unique_hash_map<key_type,bool> mConstrains ;
};


Can anyone tell me what's wrong with my codes?

Best regards,

Lin





Archive powered by MHonArc 2.6.16.

Top of Page