Specific property maps now passed as arguments

This commit is contained in:
Fernando Cacciola 2006-08-28 16:46:16 +00:00
parent 04cf16bb1d
commit 69d0971c47
6 changed files with 71 additions and 52 deletions

View File

@ -60,7 +60,7 @@ public:
typedef GetPlacement_ GetPlacement ; typedef GetPlacement_ GetPlacement ;
typedef ShouldStop_ ShouldStop ; typedef ShouldStop_ ShouldStop ;
typedef EdgeIdxMap_ EdgeIdxMap ; typedef EdgeIdxMap_ EdgeIdxMap ;
typedef EdgeCachedPtrMap_ EdgeCachedPtrMap ; typedef EdgeCachedPtrMap_ EdgeExtraPtrMap ;
typedef VertexIsFixedMap_ VertexIsFixedMap ; typedef VertexIsFixedMap_ VertexIsFixedMap ;
typedef VisitorT_ VisitorT ; typedef VisitorT_ VisitorT ;
@ -170,7 +170,7 @@ public:
, GetPlacement const& aGetPlacement , GetPlacement const& aGetPlacement
, ShouldStop const& aShouldStop , ShouldStop const& aShouldStop
, EdgeIdxMap const& aEdge_idx_map , EdgeIdxMap const& aEdge_idx_map
, EdgeCachedPtrMap const& aEdge_cached_ptr_map , EdgeExtraPtrMap const& aEdge_extra_ptr_map
, VertexIsFixedMap const& aVertex_is_fixed_map , VertexIsFixedMap const& aVertex_is_fixed_map
, VisitorT* aVisitor , VisitorT* aVisitor
) ; ) ;
@ -212,12 +212,12 @@ private:
return is_border(aEdge) || is_border(opposite_edge(aEdge,mSurface)) ; return is_border(aEdge) || is_border(opposite_edge(aEdge,mSurface)) ;
} }
Edge_data_ptr get_data ( edge_descriptor const& aEdge ) const { return static_cast<Edge_data_ptr>(get(Edge_cached_ptr_map,aEdge)) ; } Edge_data_ptr get_data ( edge_descriptor const& aEdge ) const { return static_cast<Edge_data_ptr>(get(Edge_extra_ptr_map,aEdge)) ; }
void set_data ( edge_descriptor const& aEdge, Edge_data_ptr aData ) void set_data ( edge_descriptor const& aEdge, Edge_data_ptr aData )
{ {
put(Edge_cached_ptr_map,aEdge,aData) ; put(Edge_extra_ptr_map,aEdge,aData) ;
put(Edge_cached_ptr_map,opposite_edge(aEdge,mSurface),aData) ; put(Edge_extra_ptr_map,opposite_edge(aEdge,mSurface),aData) ;
} }
tuple<const_vertex_descriptor,const_vertex_descriptor> get_vertices( const_edge_descriptor const& aEdge ) const tuple<const_vertex_descriptor,const_vertex_descriptor> get_vertices( const_edge_descriptor const& aEdge ) const
@ -326,7 +326,7 @@ private:
GetPlacement const& Get_placement ; GetPlacement const& Get_placement ;
ShouldStop const& Should_stop ; ShouldStop const& Should_stop ;
EdgeIdxMap const& Edge_idx_map ; EdgeIdxMap const& Edge_idx_map ;
EdgeCachedPtrMap const& Edge_cached_ptr_map ; EdgeExtraPtrMap const& Edge_extra_ptr_map ;
VertexIsFixedMap const& Vertex_is_fixed_map ; VertexIsFixedMap const& Vertex_is_fixed_map ;
VisitorT* Visitor ; VisitorT* Visitor ;

View File

@ -23,15 +23,15 @@ CGAL_BEGIN_NAMESPACE
namespace Triangulated_surface_mesh { namespace Simplification { namespace Edge_collapse namespace Triangulated_surface_mesh { namespace Simplification { namespace Edge_collapse
{ {
template<class M,class P,class D,class C,class V,class S, class I, class P, class F, class R> template<class M,class P,class D,class C,class V,class S, class I, class X, class F, class R>
EdgeCollapse<M,P,D,C,V,S,I,P,F,R>::EdgeCollapse( TSM& aSurface EdgeCollapse<M,P,D,C,V,S,I,X,F,R>::EdgeCollapse( TSM& aSurface
, Params const* aParams , Params const* aParams
, SetCollapseData const& aSet_collapse_data , SetCollapseData const& aSet_collapse_data
, GetCost const& aGet_cost , GetCost const& aGet_cost
, GetPlacement const& aGet_placement , GetPlacement const& aGet_placement
, ShouldStop const& aShould_stop , ShouldStop const& aShould_stop
, EdgeIdxMap const& aEdge_idx_map , EdgeIdxMap const& aEdge_idx_map
, EdgeCachedPtrMap const& aEdge_cached_ptr_map , EdgeExtraPtrMap const& aEdge_extra_ptr_map
, VertexIsFixedMap const& aVertex_is_fixed_map , VertexIsFixedMap const& aVertex_is_fixed_map
, VisitorT* aVisitor , VisitorT* aVisitor
) )
@ -44,14 +44,14 @@ EdgeCollapse<M,P,D,C,V,S,I,P,F,R>::EdgeCollapse( TSM& aSurfac
,Get_placement (aGet_placement) ,Get_placement (aGet_placement)
,Should_stop (aShould_stop) ,Should_stop (aShould_stop)
,Edge_idx_map (Edge_idx_map) ,Edge_idx_map (Edge_idx_map)
,Edge_cached_ptr_map(Edge_cached_ptr_map) ,Edge_extra_ptr_map (Edge_extra_ptr_map)
,Vertex_is_fixed_map(Vertex_is_fixed_map) ,Vertex_is_fixed_map(Vertex_is_fixed_map)
,Visitor (aVisitor) ,Visitor (aVisitor)
{ {
CGAL_expensive_precondition( is_valid_triangulated_surface_mesh(mSurface) ); CGAL_expensive_precondition( is_valid_triangulated_surface_mesh(mSurface) );
CGAL_expensive_precondition( check_max_id(mSurface) ); CGAL_expensive_precondition( check_max_id() );
mPQ.reset( new PQ (num_edges(aSurface), Compare_cost(this), Edge_idx_map) ) ; mPQ.reset( new PQ (num_edges(aSurface), Compare_cost(this), Edge_idx_map) ) ;
@ -70,8 +70,8 @@ EdgeCollapse<M,P,D,C,V,S,I,P,F,R>::EdgeCollapse( TSM& aSurfac
#endif #endif
} }
template<class M,class P,class D,class C,class V,class S, class I, class P, class F, class R> template<class M,class P,class D,class C,class V,class S, class I, class X, class F, class R>
int EdgeCollapse<M,P,D,C,V,S,I,P,F,R>::run() int EdgeCollapse<M,P,D,C,V,S,I,X,F,R>::run()
{ {
if ( Visitor ) if ( Visitor )
Visitor->OnStarted(mSurface); Visitor->OnStarted(mSurface);
@ -94,8 +94,8 @@ int EdgeCollapse<M,P,D,C,V,S,I,P,F,R>::run()
return r ; return r ;
} }
template<class M,class P,class D,class C,class V,class S, class I, class P, class F, class R> template<class M,class P,class D,class C,class V,class S, class I, class X, class F, class R>
void EdgeCollapse<M,P,D,C,V,S,I,P,F,R>::Collect() void EdgeCollapse<M,P,D,C,V,S,I,X,F,R>::Collect()
{ {
CGAL_TSMS_TRACE(0,"Collecting edges..."); CGAL_TSMS_TRACE(0,"Collecting edges...");
@ -151,8 +151,8 @@ void EdgeCollapse<M,P,D,C,V,S,I,P,F,R>::Collect()
CGAL_TSMS_TRACE(0,"Initial edge count: " << mInitialEdgeCount ) ; CGAL_TSMS_TRACE(0,"Initial edge count: " << mInitialEdgeCount ) ;
} }
template<class M,class P,class D,class C,class V,class S, class I, class P, class F, class R> template<class M,class P,class D,class C,class V,class S, class I, class X, class F, class R>
void EdgeCollapse<M,P,D,C,V,S,I,P,F,R>::Loop() void EdgeCollapse<M,P,D,C,V,S,I,X,F,R>::Loop()
{ {
CGAL_TSMS_TRACE(0,"Collapsing edges...") ; CGAL_TSMS_TRACE(0,"Collapsing edges...") ;
@ -212,8 +212,8 @@ void EdgeCollapse<M,P,D,C,V,S,I,P,F,R>::Loop()
// //
// The link conidition is as follows: for every vertex 'k' adjacent to both 'p and 'q', "p,k,q" is a facet of the mesh. // The link conidition is as follows: for every vertex 'k' adjacent to both 'p and 'q', "p,k,q" is a facet of the mesh.
// //
template<class M,class P,class D,class C,class V,class S, class I, class P, class F, class R> template<class M,class P,class D,class C,class V,class S, class I, class X, class F, class R>
bool EdgeCollapse<M,P,D,C,V,S,I,P,F,R>::Is_collapsable( edge_descriptor const& aEdgePQ ) bool EdgeCollapse<M,P,D,C,V,S,I,X,F,R>::Is_collapsable( edge_descriptor const& aEdgePQ )
{ {
bool rR = true ; bool rR = true ;
@ -304,8 +304,8 @@ bool EdgeCollapse<M,P,D,C,V,S,I,P,F,R>::Is_collapsable( edge_descriptor const& a
return rR ; return rR ;
} }
template<class M,class P,class D,class C,class V,class S, class I, class P, class F, class R> template<class M,class P,class D,class C,class V,class S, class I, class X, class F, class R>
typename EdgeCollapse<M,P,D,C,V,S,I,P,F,R>::vertex_descriptor EdgeCollapse<M,P,D,C,V,S,I,P,F,R>::Collapse( edge_descriptor const& aEdgePQ ) typename EdgeCollapse<M,P,D,C,V,S,I,X,F,R>::vertex_descriptor EdgeCollapse<M,P,D,C,V,S,I,X,F,R>::Collapse( edge_descriptor const& aEdgePQ )
{ {
CGAL_TSMS_TRACE(1,"S" << mStep << ". Collapsig " << edge_to_string(aEdgePQ) ) ; CGAL_TSMS_TRACE(1,"S" << mStep << ". Collapsig " << edge_to_string(aEdgePQ) ) ;
@ -415,8 +415,8 @@ typename EdgeCollapse<M,P,D,C,V,S,I,P,F,R>::vertex_descriptor EdgeCollapse<M,P,D
return rResult ; return rResult ;
} }
template<class M,class P,class D,class C,class V,class S, class I, class P, class F, class R> template<class M,class P,class D,class C,class V,class S, class I, class X, class F, class R>
void EdgeCollapse<M,P,D,C,V,S,I,P,F,R>::Update_neighbors( vertex_descriptor const& aKeptV ) void EdgeCollapse<M,P,D,C,V,S,I,X,F,R>::Update_neighbors( vertex_descriptor const& aKeptV )
{ {
CGAL_TSMS_TRACE(3,"Updating cost of neighboring edges..." ) ; CGAL_TSMS_TRACE(3,"Updating cost of neighboring edges..." ) ;

View File

@ -39,7 +39,7 @@ namespace Triangulated_surface_mesh { namespace Simplification { namespace Edge_
// //
// For each non-fixed edge in the mesh, a "collapse data" record is constructed by calling the user-supplied function // For each non-fixed edge in the mesh, a "collapse data" record is constructed by calling the user-supplied function
// "SetCollapseData". // "SetCollapseData".
// The edge is then associated with its collapse data via the "EdgeCachedPtrMap" property map. // The edge is then associated with its collapse data via the "EdgeExtraPtrMap" property map.
// //
// The user-supplied function "GetCost" is called, for each non-fixed edge. // The user-supplied function "GetCost" is called, for each non-fixed edge.
// This function returns a value which defines the collapsing cost of the edge. Edges with a lower cost are collapsed first. // This function returns a value which defines the collapsing cost of the edge. Edges with a lower cost are collapsed first.
@ -66,7 +66,7 @@ template<class TSM
,class GetNewVertexPoint ,class GetNewVertexPoint
,class ShouldStop ,class ShouldStop
,class EdgeIdxMap ,class EdgeIdxMap
,class EdgeCachedPtrMap ,class EdgeExtraPtrMap
,class VertexIsFixedMap ,class VertexIsFixedMap
,class Visitor ,class Visitor
> >
@ -77,7 +77,7 @@ int edge_collapse ( TSM& aSurface
, GetNewVertexPoint const& aGet_new_vertex_point , GetNewVertexPoint const& aGet_new_vertex_point
, ShouldStop const& aShould_stop , ShouldStop const& aShould_stop
, EdgeIdxMap const& aEdge_idx_map , EdgeIdxMap const& aEdge_idx_map
, EdgeCachedPtrMap const& aEdge_cached_ptr_map , EdgeExtraPtrMap const& aEdge_extra_ptr_map
, VertexIsFixedMap const& aVertex_is_fixed_map , VertexIsFixedMap const& aVertex_is_fixed_map
, Visitor* aVisitor = 0 , Visitor* aVisitor = 0
) )
@ -89,7 +89,7 @@ int edge_collapse ( TSM& aSurface
,GetNewVertexPoint ,GetNewVertexPoint
,ShouldStop ,ShouldStop
,EdgeIdxMap ,EdgeIdxMap
,EdgeCachedPtrMap ,EdgeExtraPtrMap
,VertexIsFixedMap ,VertexIsFixedMap
,Visitor ,Visitor
> >
@ -103,7 +103,7 @@ int edge_collapse ( TSM& aSurface
,aGet_new_vertex_point ,aGet_new_vertex_point
,aShould_stop ,aShould_stop
,aEdge_idx_map ,aEdge_idx_map
,aEdge_cached_ptr_map ,aEdge_extra_ptr_map
,aVertex_is_fixed_map ,aVertex_is_fixed_map
,aVisitor ,aVisitor
) ; ) ;

View File

@ -23,7 +23,7 @@
namespace boost namespace boost
{ {
template<class Graph> template<class Graph_>
class Edge_stored_index_map : public put_get_helper< typename Graph_::size_type, Edge_stored_index_map<Graph_> > class Edge_stored_index_map : public put_get_helper< typename Graph_::size_type, Edge_stored_index_map<Graph_> >
{ {
private: private:
@ -32,7 +32,7 @@ private:
public: public:
typedef typename G::size_type size_type ; typedef typename Graph::size_type size_type ;
typedef readable_property_map_tag category; typedef readable_property_map_tag category;
typedef size_type value_type; typedef size_type value_type;

View File

@ -37,7 +37,7 @@ public:
typedef bool reference; typedef bool reference;
typedef typename graph_traits<Graph const>::vertex_descriptor key_type; typedef typename graph_traits<Graph const>::vertex_descriptor key_type;
reference operator[](key_type const& v) const { v->is_fixed() ; } reference operator[](key_type const& v) const { return v->is_fixed() ; }
}; };

View File

@ -73,15 +73,15 @@ struct My_vertex : public HalfedgeDS_vertex_base<Refs,Tag_true,Point>
{ {
typedef HalfedgeDS_vertex_base<Refs,Tag_true,Point> Base ; typedef HalfedgeDS_vertex_base<Refs,Tag_true,Point> Base ;
My_vertex() : ID(-1), IsFixed(false) {} My_vertex() : mID(-1), mIsFixed(false) {}
My_vertex( Point p ) : Base(p), ID(-1), IsFixed(false) {} My_vertex( Point p ) : Base(p), mID(-1), mIsFixed(false) {}
int id() const { return ID ; } int id() const { return mID ; }
bool is_fixed() const { return IsFixed ; } bool is_fixed() const { return mIsFixed ; }
int ID; int mID;
bool IsFixed ; bool mIsFixed ;
} ; } ;
template <class Refs, class Traits> template <class Refs, class Traits>
@ -89,17 +89,16 @@ struct My_halfedge : public HalfedgeDS_halfedge_base<Refs>
{ {
My_halfedge() My_halfedge()
: :
ID(-1) mID(-1)
, extra_pointer(0) , mExtraPointer(0)
{} {}
int id() const { return ID ; } int id() const { return mID ; }
void* extra_pointer() { return extra_pointer ; } void*& extra_pointer() { return mExtraPointer ; }
int ID; int mID;
void* mExtraPointer ;
void* extra_pointer ;
}; };
template <class Refs, class Traits> template <class Refs, class Traits>
@ -107,12 +106,12 @@ struct My_face : public HalfedgeDS_face_base<Refs,Tag_true,typename Traits::Plan
{ {
typedef HalfedgeDS_face_base<Refs,Tag_true,typename Traits::Plane_3> Base ; typedef HalfedgeDS_face_base<Refs,Tag_true,typename Traits::Plane_3> Base ;
My_face() : ID(-1) {} My_face() : mID(-1) {}
My_face( typename Traits::Plane_3 plane ) : Base(plane) {} My_face( typename Traits::Plane_3 plane ) : Base(plane), mID(-1) {}
int id() const { return ID ; } int id() const { return mID ; }
int ID; int mID;
}; };
struct My_items : public Polyhedron_items_3 struct My_items : public Polyhedron_items_3
@ -520,15 +519,15 @@ bool Test ( int aStopA, int aStopR, bool aJustPrintSurfaceData, string aName, Me
int lVertexID = 0 ; int lVertexID = 0 ;
for ( Polyhedron::Vertex_iterator vi = lP.vertices_begin(); vi != lP.vertices_end() ; ++ vi ) for ( Polyhedron::Vertex_iterator vi = lP.vertices_begin(); vi != lP.vertices_end() ; ++ vi )
vi->ID = lVertexID ++ ; vi->mID = lVertexID ++ ;
int lHalfedgeID = 0 ; int lHalfedgeID = 0 ;
for ( Polyhedron::Halfedge_iterator hi = lP.halfedges_begin(); hi != lP.halfedges_end() ; ++ hi ) for ( Polyhedron::Halfedge_iterator hi = lP.halfedges_begin(); hi != lP.halfedges_end() ; ++ hi )
hi->ID = lHalfedgeID++ ; hi->mID = lHalfedgeID++ ;
int lFacetID = 0 ; int lFacetID = 0 ;
for ( Polyhedron::Facet_iterator fi = lP.facets_begin(); fi != lP.facets_end() ; ++ fi ) for ( Polyhedron::Facet_iterator fi = lP.facets_begin(); fi != lP.facets_end() ; ++ fi )
fi->ID = lFacetID ++ ; fi->mID = lFacetID ++ ;
#ifdef AUDIT #ifdef AUDIT
sAuditData .clear(); sAuditData .clear();
@ -558,7 +557,9 @@ bool Test ( int aStopA, int aStopR, bool aJustPrintSurfaceData, string aName, Me
Dummy_params lDummy_params; Dummy_params lDummy_params;
LT_params lLT_params ; LT_params lLT_params ;
Edge_index_map<Polyhedron> P_Edge_index_map ; Edge_stored_index_map <Polyhedron> edge_index_map ;
Edge_stored_extra_pointer_map<Polyhedron> edge_extra_pointer_map ;
Vertex_stored_is_fixed_map <Polyhedron> vertex_is_fixed_map ;
Visitor lVisitor(lRequestedEdgeCount) ; Visitor lVisitor(lRequestedEdgeCount) ;
@ -579,6 +580,9 @@ bool Test ( int aStopA, int aStopR, bool aJustPrintSurfaceData, string aName, Me
,get_MP_cost ,get_MP_cost
,get_MP_placement ,get_MP_placement
,should_stop ,should_stop
,edge_index_map
,edge_extra_pointer_map
,vertex_is_fixed_map
,&lVisitor ,&lVisitor
); );
break ; break ;
@ -591,6 +595,9 @@ bool Test ( int aStopA, int aStopR, bool aJustPrintSurfaceData, string aName, Me
,get_cached_cost ,get_cached_cost
,get_MP_placement ,get_MP_placement
,should_stop ,should_stop
,edge_index_map
,edge_extra_pointer_map
,vertex_is_fixed_map
,&lVisitor ,&lVisitor
); );
break ; break ;
@ -603,6 +610,9 @@ bool Test ( int aStopA, int aStopR, bool aJustPrintSurfaceData, string aName, Me
,get_cached_cost ,get_cached_cost
,get_cached_placement ,get_cached_placement
,should_stop ,should_stop
,edge_index_map
,edge_extra_pointer_map
,vertex_is_fixed_map
,&lVisitor ,&lVisitor
); );
break ; break ;
@ -623,6 +633,9 @@ bool Test ( int aStopA, int aStopR, bool aJustPrintSurfaceData, string aName, Me
,get_LT_cost ,get_LT_cost
,get_LT_placement ,get_LT_placement
,should_stop ,should_stop
,edge_index_map
,edge_extra_pointer_map
,vertex_is_fixed_map
,&lVisitor ,&lVisitor
); );
break ; break ;
@ -635,6 +648,9 @@ bool Test ( int aStopA, int aStopR, bool aJustPrintSurfaceData, string aName, Me
,get_cached_cost ,get_cached_cost
,get_LT_placement ,get_LT_placement
,should_stop ,should_stop
,edge_index_map
,edge_extra_pointer_map
,vertex_is_fixed_map
,&lVisitor ,&lVisitor
); );
break ; break ;
@ -647,6 +663,9 @@ bool Test ( int aStopA, int aStopR, bool aJustPrintSurfaceData, string aName, Me
,get_cached_cost ,get_cached_cost
,get_cached_placement ,get_cached_placement
,should_stop ,should_stop
,edge_index_map
,edge_extra_pointer_map
,vertex_is_fixed_map
,&lVisitor ,&lVisitor
); );
break ; break ;