Various changes to reflect submmitted manual

This commit is contained in:
Fernando Cacciola 2006-10-03 18:31:33 +00:00
parent 7f4701c167
commit 9ce65f363e
9 changed files with 103 additions and 78 deletions

View File

@ -5,7 +5,7 @@
#include <CGAL/Polyhedron_3.h>
#include <CGAL/IO/Polyhedron_iostream.h>
#include <CGAL/Surface_mesh_simplification/polyhedron.h>
#include <CGAL/Surface_mesh_simplification/HalfedgeGraph_Polyhedron_3.h>
#include <CGAL/Surface_mesh_simplification/edge_collapse.h>
// === EXAMPLE SPECIFIC HEADERS BEGINS HERE ===

View File

@ -28,7 +28,6 @@
#include <boost/graph/adjacency_list.hpp>
#include <CGAL/Surface_mesh_simplification/Detail/Common.h>
#include <CGAL/Surface_mesh_simplification/Collapse_operator.h>
CGAL_BEGIN_NAMESPACE
@ -72,19 +71,20 @@ public:
typedef boost::graph_traits <ECM> GraphTraits ;
typedef boost::graph_traits <ECM const> ConstGraphTraits ;
typedef Halfedge_graph_traits<ECM> HalfedgeGraphTraits ;
typedef halfedge_graph_traits<ECM> HalfedgeGraphTraits ;
typedef typename GraphTraits::vertex_descriptor vertex_descriptor ;
typedef typename GraphTraits::vertex_iterator vertex_iterator ;
typedef typename GraphTraits::edge_descriptor edge_descriptor ;
typedef typename GraphTraits::edge_iterator edge_iterator ;
typedef typename GraphTraits::out_edge_iterator out_edge_iterator ;
typedef typename GraphTraits::in_edge_iterator in_edge_iterator ;
typedef typename GraphTraits::traversal_category traversal_category ;
typedef typename GraphTraits::edges_size_type size_type ;
typedef typename GraphTraits::vertex_descriptor vertex_descriptor ;
typedef typename GraphTraits::vertex_iterator vertex_iterator ;
typedef typename GraphTraits::edge_descriptor edge_descriptor ;
typedef typename GraphTraits::edge_iterator edge_iterator ;
typedef typename GraphTraits::out_edge_iterator out_edge_iterator ;
typedef typename GraphTraits::in_edge_iterator in_edge_iterator ;
typedef typename GraphTraits::traversal_category traversal_category ;
typedef typename GraphTraits::edges_size_type size_type ;
typedef typename ConstGraphTraits::vertex_descriptor const_vertex_descriptor ;
typedef typename ConstGraphTraits::edge_descriptor const_edge_descriptor ;
typedef typename ConstGraphTraits::in_edge_iterator const_in_edge_iterator ;
typedef typename HalfedgeGraphTraits::undirected_edge_iterator undirected_edge_iterator ;
typedef typename HalfedgeGraphTraits::Point Point ;
@ -131,7 +131,7 @@ public:
{
public :
Edge_cache() : mPQHandle() {}
Edge_data() : mPQHandle() {}
Cache const& cache() const { return mCache ; }
Cache & cache() { return mCache ; }
@ -159,7 +159,7 @@ public:
, ShouldStop const& aShouldStop
, VertexPointMap const& aVertex_point_map
, VertexIsFixedMap const& aVertex_is_fixed_map
, EdgeIndxMap const& aEdge_index_map
, EdgeIndexMap const& aEdge_index_map
, EdgeIsBorderMap const& aEdge_is_border_map
, SetCache const& aSetCache
, GetCost const& aGetCost
@ -179,11 +179,11 @@ private:
void Collapse( edge_descriptor const& aEdge ) ;
void Update_neighbors( vertex_descriptor const& aKeptV ) ;
size_type get_id ( edge_descriptor const& aEdge ) const { return get(Edge_index_map,aEdge); }
size_type get_id ( const_edge_descriptor const& aEdge ) const { return Edge_index_map[aEdge]; }
bool is_vertex_fixed ( const_vertex_descriptor const& aV ) const { return get(Vertex_is_fixed_map,aV) ; }
bool is_vertex_fixed ( const_vertex_descriptor const& aV ) const { return Vertex_is_fixed_map[aV] ; }
bool is_border ( const_edge_descriptor const& aEdge ) const { return get(Edge_is_border_map,aEdge) ; }
bool is_border ( const_edge_descriptor const& aEdge ) const { return Edge_is_border_map[aEdge] ; }
bool is_undirected_edge_a_border ( const_edge_descriptor const& aEdge ) const
{
@ -250,25 +250,22 @@ private:
return get_id(aEdgeA) < get_id(aEdgeB);
}
void insert_in_PQ( edge_descriptor const& aEdge, Edge_data_ptr aData )
void insert_in_PQ( edge_descriptor const& aEdge, Edge_data& aData )
{
CGAL_precondition(aData);
CGAL_precondition(!aData->is_in_PQ());
aData->set_PQ_handle(mPQ->push(aEdge));
CGAL_precondition(!aData.is_in_PQ());
aData.set_PQ_handle(mPQ->push(aEdge));
}
void update_in_PQ( edge_descriptor const& aEdge, Edge_data_ptr aData )
void update_in_PQ( edge_descriptor const& aEdge, Edge_data& aData )
{
CGAL_precondition(aData);
CGAL_precondition(aData->is_in_PQ());
aData->set_PQ_handle(mPQ->update(aEdge,aData->PQ_handle())) ;
CGAL_precondition(aData.is_in_PQ());
aData.set_PQ_handle(mPQ->update(aEdge,aData.PQ_handle())) ;
}
void remove_from_PQ( edge_descriptor const& aEdge, Edge_data_ptr aData )
void remove_from_PQ( edge_descriptor const& aEdge, Edge_data& aData )
{
CGAL_precondition(aData);
CGAL_precondition(aData->is_in_PQ());
aData->set_PQ_handle(mPQ->erase(aEdge,aData->PQ_handle()));
CGAL_precondition(aData.is_in_PQ());
aData.set_PQ_handle(mPQ->erase(aEdge,aData.PQ_handle()));
}
optional<edge_descriptor> pop_from_PQ()
@ -296,8 +293,6 @@ private:
private:
Collapse_triangulation_edge<ECM> Collapse_triangulation_edge ;
Edge_data_array mEdgeDataArray ;
boost::scoped_ptr<PQ> mPQ ;
@ -308,7 +303,7 @@ private:
CGAL_ECMS_DEBUG_CODE ( unsigned mStep ; )
} ;
} // namespace Triangulated_surface_mesh::Simplification::edge_collapse
} // namespace Surface_mesh_simplification
CGAL_END_NAMESPACE

View File

@ -26,7 +26,7 @@ namespace Surface_mesh_simplification
template<class M,class SP,class VPM, class VFM, class EIM,class EBM, class SC, class CF,class PF,class CP, class PP,class V>
EdgeCollapse<M,SP,VPM,VFM,EIM,EBM,SC,CF,PF,CP,PP,V>::EdgeCollapse( ECM& aSurface
, ShouldStop const& aShould_stop
, VertexPoinntMap const& aVertex_point_map
, VertexPointMap const& aVertex_point_map
, VertexIsFixedMap const& aVertex_is_fixed_map
, EdgeIndexMap const& aEdge_index_map
, EdgeIsBorderMap const& aEdge_is_border_map
@ -52,9 +52,7 @@ EdgeCollapse<M,SP,VPM,VFM,EIM,EBM,SC,CF,PF,CP,PP,V>::EdgeCollapse( ECM&
,Visitor (aVisitor)
{
CGAL_ECMS_TRACE(0,"EdgeCollapse of ECM with " << num_undirected_edges(aSurface) << " edges" );
CGAL_assertion( num_undirected_edges(aSurface) * 2 == num_edges(aSurface) ) ;
CGAL_ECMS_TRACE(0,"EdgeCollapse of ECM with " << (num_edges(aSurface)/2) << " edges" );
CGAL_ECMS_DEBUG_CODE ( mStep = 0 ; )
@ -104,7 +102,7 @@ void EdgeCollapse<M,SP,VPM,VFM,EIM,EBM,SC,CF,PF,CP,PP,V>::Collect()
Equal_3 equal_points = Kernel().equal_3_object();
size_type lSize = num_undirected_edges(mSurface) ;
size_type lSize = num_edges(mSurface) / 2 ;
mInitialEdgeCount = mCurrentEdgeCount = lSize;
@ -122,7 +120,7 @@ void EdgeCollapse<M,SP,VPM,VFM,EIM,EBM,SC,CF,PF,CP,PP,V>::Collect()
bool lIsFixed = is_vertex_fixed(p) || is_vertex_fixed(q) ;
if ( p == q || equal_points( get_point(p,mSurface), get_point(q,mSurface)) )
if ( p == q || equal_points( get_point(p), get_point(q)) )
lIsFixed = true ;
// But in the case of fixed edges the edge data is left default constructed
@ -195,14 +193,14 @@ void EdgeCollapse<M,SP,VPM,VFM,EIM,EBM,SC,CF,PF,CP,PP,V>::Loop()
}
template<class M,class SP,class VPM, class VFM, class EIM,class EBM, class SC, class CF,class PF,class CP, class PP,class V>
bool EdgeCollapse<M,SP,VPM,VFM,EIM,EBM,SC,CF,PF,CP,PP,V>::is_border( const_vertex_descriptor const& aV )
bool EdgeCollapse<M,SP,VPM,VFM,EIM,EBM,SC,CF,PF,CP,PP,V>::is_border( const_vertex_descriptor const& aV ) const
{
bool rR = false ;
in_edge_iterator eb, ee ;
const_in_edge_iterator eb, ee ;
for ( tie(eb,ee) = in_edges(aV,mSurface) ; eb != ee ; ++ eb )
{
edge_descriptor lEdge = *eb ;
const_edge_descriptor lEdge = *eb ;
if ( is_undirected_edge_a_border(lEdge) )
{
rR = true ;
@ -330,7 +328,7 @@ void EdgeCollapse<M,SP,VPM,VFM,EIM,EBM,SC,CF,PF,CP,PP,V>::Collapse( edge_descrip
Optional_placement_type lPlacement = get_placement(aEdgePQ);
if ( Visitor )
Visitor->OnCollapsing(*lEdge,mSurface,lPlacement);
Visitor->OnCollapsing(aEdgePQ,mSurface,lPlacement);
if ( lPlacement )
{
@ -404,7 +402,7 @@ void EdgeCollapse<M,SP,VPM,VFM,EIM,EBM,SC,CF,PF,CP,PP,V>::Collapse( edge_descrip
// It's REQUIRED to remove ONLY 1 vertex (P or Q) and edges PQ,PT and QB (PT and QB are removed if they are not null).
// All other edges must be kept.
// All directed edges incident to vertex removed are relink to the vertex kept.
rResult = Collapse_triangulation_edge(aEdgePQ,mSurface);
rResult = collapse_triangulation_edge(aEdgePQ,mSurface);
CGAL_ECMS_TRACE(1,"V" << rResult->ID << " kept." ) ;
@ -414,7 +412,7 @@ void EdgeCollapse<M,SP,VPM,VFM,EIM,EBM,SC,CF,PF,CP,PP,V>::Collapse( edge_descrip
CGAL_ECMS_TRACE(2, edge_to_string(*eb1) ) ;
#endif
set_point(rResult,mSurface,*lPlacement) ;
put(vertex_point,mSurface,rResult,*lPlacement) ;
Update_neighbors(rResult) ;
}
@ -424,8 +422,6 @@ void EdgeCollapse<M,SP,VPM,VFM,EIM,EBM,SC,CF,PF,CP,PP,V>::Collapse( edge_descrip
}
CGAL_ECMS_DEBUG_CODE ( ++mStep ; )
return rResult ;
}
template<class M,class SP,class VPM, class VFM, class EIM,class EBM, class SC, class CF,class PF,class CP, class PP,class V>

View File

@ -22,7 +22,7 @@
#include <CGAL/boost/graph/graph_traits_Polyhedron_3.h>
#include <CGAL/boost/graph/halfedge_graph_traits_Polyhedron_3.h>
#include <CGAL/boost/graph/properties_Polyhedron_3.h>
#include <CGAL/Surface_mesh_simplification/collapse_triangulation_operator_Polyhedron_3.h>
#include <CGAL/Surface_mesh_simplification/collapse_triangulation_edge_Polyhedron_3.h>
#endif // CGAL_SURFACE_MESH_SIMPLIFICATION_HALFEDGEGRAPH_POLYHEDRON_3_H
// EOF //

View File

@ -52,7 +52,7 @@ public:
typedef LindstromTurk_params Params ;
typedef typename halfedge_graph_traits<ECM>::Point Point ;
typedef typename halfedge_graph_traits<ECM>::Point Point ;
typedef typename Kernel_traits<Point>::Kernel Kernel ;
@ -143,7 +143,7 @@ private :
return is_border(edge) || is_border(opposite_edge(edge,mSurface)) ;
}
Point const& get_point ( const_vertex_descriptor const& v ) const
Point const& get_point ( vertex_descriptor const& v ) const
{
return get(vertex_point,mSurface,v);
}

View File

@ -78,8 +78,8 @@ typename LindstromTurkCore<ECM>::result_type LindstromTurkCore<ECM>::compute()
Extract_boundary_edges(lBdry);
Point const& lP = get_point(mP,mSurface) ;
Point const& lQ = get_point(mQ,mSurface) ;
Point const& lP = get_point(mP) ;
Point const& lQ = get_point(mQ) ;
Optional_vector lOptionalV ;
@ -182,8 +182,8 @@ void LindstromTurkCore<ECM>::Extract_boundary_edge( edge_descriptor edge, Bounda
vertex_descriptor sv = source(face_edge,mSurface);
vertex_descriptor tv = target(face_edge,mSurface);
Point const& sp = get_point(sv,mSurface);
Point const& tp = get_point(tv,mSurface);
Point const& sp = get_point(sv);
Point const& tp = get_point(tv);
Vector v = tp - sp ;
Vector n = Point_cross_product(tp,sp) ;
@ -233,9 +233,9 @@ typename LindstromTurkCore<ECM>::Triangle LindstromTurkCore<ECM>::Get_triangle(
, vertex_descriptor const& v2
)
{
Point const& p0 = get_point(v0,mSurface);
Point const& p1 = get_point(v1,mSurface);
Point const& p2 = get_point(v2,mSurface);
Point const& p0 = get_point(v0);
Point const& p1 = get_point(v1);
Point const& p2 = get_point(v2);
Vector v01 = p1 - p0 ;
Vector v02 = p2 - p0 ;
@ -440,7 +440,7 @@ void LindstromTurkCore<ECM>::Add_boundary_and_volume_optimization_constrians( Bo
//
// Weighted average
//
FT lScaledBoundaryWeight = FT(9) * mParams.BoundaryWeight * squared_distance ( get_point(mP,mSurface), get_point(mQ,mSurface) ) ;
FT lScaledBoundaryWeight = FT(9) * mParams.BoundaryWeight * squared_distance ( get_point(mP), get_point(mQ) ) ;
H *= mParams.VolumeWeight ;
c = c * mParams.VolumeWeight ;
@ -468,7 +468,7 @@ void LindstromTurkCore<ECM>::Add_shape_optimization_constrians( Link const& aLin
Vector c = NULL_VECTOR ;
for( typename Link::const_iterator it = aLink.begin(), eit = aLink.end() ; it != eit ; ++it )
c = c + (ORIGIN - get_point(*it,mSurface)) ;
c = c + (ORIGIN - get_point(*it)) ;
CGAL_ECMS_LT_TRACE(2,"Adding shape optimization constrians: Shape vector: " << xyz_to_string(c) );
@ -515,7 +515,7 @@ LindstromTurkCore<ECM>::Compute_shape_cost( Point const& p, Link const& aLink )
FT rCost(0);
for( typename Link::const_iterator it = aLink.begin(), eit = aLink.end() ; it != eit ; ++it )
rCost += squared_distance(p,get_point(*it,mSurface)) ;
rCost += squared_distance(p,get_point(*it)) ;
return rCost ;
}

View File

@ -60,8 +60,8 @@ public:
LindstromTurkCore<ECM> core(*aParams,aEdge,aSurface,false);
optional<FT> lCost ;
optional<Point_3> lPlacement ;
optional<FT> lCost ;
optional<Point> lPlacement ;
tie(lCost,lPlacement) = core.compute();
return lPlacement ;

View File

@ -38,16 +38,20 @@ collapse_triangulation_edge( typename boost::graph_traits< Polyhedron_3<Gt,I,HDS
, Polyhedron_3<Gt,I,HDS,A>& aSurface
)
{
typedef Polyhedron_3<Gt,I,HDS,A> Surface ;
typedef typename boost::graph_traits<Surface>::vertex_descriptor vertex_descriptor ;
typedef typename boost::graph_traits<Surface>::edge_descriptor edge_descriptor ;
edge_descriptor qp = opposite_edge(pq,aSurface);
edge_descriptor pt = opposite_edge(prev_edge(pq,aSurface),aSurface);
edge_descriptor qb = opposite_edge(prev_edge(qp,aSurface),aSurface);
bool lTopFaceExists = !pq->is_border() ;
bool lBottomFaceExists = !qp->is_border() ;
bool lTopLeftFaceExists = lTopFaceExists && !pt->is_border() ;
bool lBottomRightFaceExists = lBottomFaceExists && !qb->is_border() ;
edge_descriptor pq = opposite_edge(prev_edge(pq,aSurface),aSurface);
edge_descriptor qb = opposite_edge(prev_edge(qp,aSurface),aSurface);
CGAL_precondition( !lTopFaceExists || (lTopFaceExists && ( pt->vertex()->vertex_degree() > 2 ) ) ) ;
CGAL_precondition( !lBottomFaceExists || (lBottomFaceExists && ( qb->vertex()->vertex_degree() > 2 ) ) ) ;
@ -115,7 +119,7 @@ collapse_triangulation_edge( typename boost::graph_traits< Polyhedron_3<Gt,I,HDS
return lP_Erased ? q : p ;
}
} // namespace Triangulated_surface_mesh::Simplification
} // namespace Surface_mesh_simplification
CGAL_END_NAMESPACE

View File

@ -156,30 +156,60 @@ struct Dummy_visitor
void OnNonCollapsable(Edge const&, ECM& ) {}
} ;
template<class ECM, class ShouldStop, class P, class T, class R>
int edge_collapse ( ECM& aSurface, ShouldStop const& aShould_stop, cgal_bgl_named_params<P,T,R> const& aParams )
namespace detail
{
using boost::choose_pmap ;
template <class PropertyMap>
inline
boost::put_get_helper<std::size_t, PropertyMap> const&
choose_index_pmap( boost::put_get_helper<std::size_t, PropertyMap> const& imap) { return imap; }
template<class Surface>
inline
typename boost::property_map<Surface,edge_external_index_t>::const_type
choose_index_pmap( Surface const& s) { return boost::get(edge_external_index,s); }
}
template<class ECM, class ShouldStop, class P, class T, class R>
int edge_collapse ( ECM& aSurface
, ShouldStop const& aShould_stop
, cgal_bgl_named_params<P,T,R> const& aParams
)
{
using boost::choose_param ;
using boost::choose_const_pmap ;
using boost::get_param ;
using detail::choose_index_pmap ;
LindstromTurk_params lPolicyParams ;
boost::graph_visitor_t visitor ;
return edge_collapse(aSurface
,aShould_stop
,choose_pmap (get_param(aParams,vertex_point),aSurface,vertex_point)
,choose_pmap (get_param(aParams,vertex_point),aSurface,vertex_is_fixed)
,choose_pmap (get_param(aParams,vertex_point),aSurface,boost::edge_index)
,choose_pmap (get_param(aParams,vertex_point),aSurface,edge_is_border)
,choose_param(get_param(aParams,set_cache_policy), LindstromTurk_set_cost_cache<ECM>())
,choose_param(get_param(aParams,get_cost_policy), Cached_cost<ECM>())
,choose_param(get_param(aParams,get_placement_policy), LindstromTurk_placement<ECM>())
,choose_param(get_param(aParams,get_cost_policy_params), &PolicyParmas)
,choose_param(get_param(aParams,get_placement_policy_params), &PolicyParams)
,choose_param(get_param(aParams,graph_visitor), ((Dummy_visitor*)0))
,choose_const_pmap (get_param(aParams,vertex_point),aSurface,vertex_point)
,choose_param (get_param(aParams,vertex_is_fixed),Vertex_is_fixed_property_map_always_false<ECM>())
,choose_index_pmap (get_param(aParams,boost::edge_index))
,choose_const_pmap (get_param(aParams,edge_is_border),aSurface,edge_is_border)
,choose_param (get_param(aParams,set_cache_policy), LindstromTurk_set_cost_cache<ECM>())
,choose_param (get_param(aParams,get_cost_policy), Cached_cost<ECM>())
,choose_param (get_param(aParams,get_placement_policy), LindstromTurk_placement<ECM>())
,choose_param (get_param(aParams,get_cost_policy_params), &lPolicyParams)
,choose_param (get_param(aParams,get_placement_policy_params), &lPolicyParams)
,choose_param (get_param(aParams,visitor), ((Dummy_visitor*)0))
) ;
} // namespace Surface_mesh_simplification
}
template<class ECM, class ShouldStop>
int edge_collapse ( ECM& aSurface, ShouldStop const& aShould_stop )
{
return edge_collapse(aSurface,aShould_stop, edge_index_map(get(boost::edge_index,aSurface)));
}
} // namespace Surface_mesh_simplification
CGAL_END_NAMESPACE