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: "Qianqian Fang" <>
  • To:
  • Subject: Re: [cgal-discuss] fix border edges for mesh simplification
  • Date: Mon, 31 Mar 2008 15:33:10 -0400
  • Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=message-id:date:from:to:subject:in-reply-to:mime-version:content-type:references; b=EwYQPKPVXWrFOEDDMMoTacB9kboxU6VjT73FFllAoxeIOTCXsku6nuWAMBx+e+Hqs5K/HnZyomeQJhQhnSjTsgjclB2Ja7p50AQ2OUYMG3pBwlf4HAR2JZhmgVu1INcQf61W1C7UZ147ml0mkws2vjtcyllWGlXAoloSYPyqu4I=

hi Fernando

thank you very much for the code. I have played with for a little while, now I stuck at
the definition of "const_in_edge_iterator" used in is_border_vertex().

the error message is:

edge_collapse_enriched_polyhedron.cpp:126: error: no type named 'const_in_edge_iterator' in 'class CGAL::Surface_mesh_simplification::Edge_profile<CGAL::Polyhedron_3<CGAL::Simple_cartesian<double>, CGAL::Polyhedron_items_with_id_3, CGAL::HalfedgeDS_default, std::allocator<int> > >'

indeed, I inserted a typedef line for this iterator type inside the class, however, it does not seems
to match the required types.

My modified class is listed below, and the full unit is also attached. Do I need to
include other units in order to get the proper namespace path for this type?

I really appreciate your time for helping me on this and apologize for all the
troubles, I have not seriously done programming with templates.
it does take a while for me to fully digest the structure of the library.


Qianqian




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::const_in_edge_iterator const_in_edge_iterator ;

  result_type operator()( Profile const& aProfile ) const
  {
     if ( is_border_vertex(aProfile,aProfile.v0()) || is_border_vertex(aProfile,aProfile.v1()) )
           return boost::none ;
     else{
      return this->GetPlacement::operator()(aProfile);
     }
  }

  bool is_border_vertex( Profile const& aProfile, const_vertex_descriptor v ) const
  {

    bool rR = false ;

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

On Mon, Mar 31, 2008 at 8:47 AM, Fernando Cacciola <> wrote:
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
--
You are currently subscribed to cgal-discuss.
To unsubscribe or access the archives, go to
https://lists-sop.inria.fr/wws/info/cgal-discuss

Attachment: edge_collapse_enriched_polyhedron.cpp
Description: Binary data




Archive powered by MHonArc 2.6.16.

Top of Page