Skip to Content.
Sympa Menu

cgal-discuss - Re: [cgal-discuss] fix border edges for mesh simplification

Subject: CGAL users discussion list

List archive

Re: [cgal-discuss] fix border edges for mesh simplification


Chronological Thread 
  • From: "Fernando Cacciola" <>
  • To: <>
  • Subject: Re: [cgal-discuss] fix border edges for mesh simplification
  • Date: Mon, 31 Mar 2008 09:47:36 -0300
  • Organization: Geometry Factory

Hi Qianqian,

hi Fernando

thank you very much for the quick response. The explanations make sense to
me.

Now I am trying to hook the Placement_with_fixed_border_vertices policy to
the edge_collapse() call. I have some difficulty to figure out where to
insert
the code.

The original edge_collapse() in
example/Surface_mesh_simplification/edge_collapse_enriched_polyhedron.cpp
looks like the following:

int r = SMS::edge_collapse
(surface
,stop
,CGAL::get_cost (SMS::Edge_length_cost <Surface>())
.get_placement(SMS::Midpoint_placement<Surface>())
.visitor(&vis)
);

I assumed the 3rd parameter sets cost policy, sets the placement policy and
sets a visitor.

That's correct.

Can you enlighten me what the 3rd parameter should look like
if I want to use the Placement_with_fixed_border_vertices policy instead?

OK.

First add this typedef before main():

typedef Placement_with_fixed_border_vertices< SMS::Midpoint_placement<Surface> > My_placement ;

then use it like this:

int r = SMS::edge_collapse
(surface
,stop
,CGAL::get_cost (SMS::Edge_length_cost <Surface>())
.get_placement( My_placement() )
.visitor(&vis)
);



in addition, I found in
"include/CGAL/Surface_mesh_simplification/Detail/Edge_collapse.h"
a function called is_border( const_vertex_descriptor const& aV), is it
correct to
write

return is_border(v);

inside your is_border_vertex().

Unfortunately that function is a private method of the EdgeCollapse class so you cannot call that it from within the policy.
OTOH, you can "borrow" it's implementation, as in the attached file (NOTE: That's is off the top of my head, I haven't compiled nor tested it)

HTH

Fernando Cacciola
GeometryFactory template<class GetPlacement_>
struct Placement_with_fixed_border_vertices : GetPlacement_
{
typedef GetPlacement_ GetPlacement ;

typedef typename GetPlacement::Profile Profile ;

typedef typename GetPlacement::result_type result_type ;

typedef typename Profile::const_vertex_descriptor const_vertex_descriptor ;
typedef typename Profile::const_edge_descriptor const_edge_descriptor ;
typedef typename Profile::ConstGraphTraits::const_in_edge_iterator const_in_edge_iterator ;
result_type operator()( Profile const& aProfile ) const
{
if ( is_border_vertex(aProfile.v0()) || is_border_vertex(aProfile.v1()) )
return boost::none ;
else
return this->GetPlacement::operator()(aProfile);
}

bool is_border_vertex( const_vertex_descriptor v ) const
{
bool rR = false ;

const_in_edge_iterator eb, ee ; for ( boost::tie(eb,ee) = in_edges(aV,aProfile.surface()) ; eb != ee ; ++ eb )
{
const_edge_descriptor lEdge = *eb ;
if ( lEdge->is_border() || lEdge->opposite()->is_border() )
{
rR = true ;
break ;
}
}
return rR ; }
} ;



Archive powered by MHonArc 2.6.16.

Top of Page