diff --git a/.gitattributes b/.gitattributes index 030262e279f..b1d447d0c8f 100644 --- a/.gitattributes +++ b/.gitattributes @@ -2075,7 +2075,6 @@ Surface_mesh_simplification/examples/Surface_mesh_simplification/LT_edge_collaps Surface_mesh_simplification/examples/Surface_mesh_simplification/MP_edge_collapse_polyhedron.cpp -text Surface_mesh_simplification/examples/Surface_mesh_simplification/general_form.cpp -text Surface_mesh_simplification/examples/Surface_mesh_simplification/makefile -text -Surface_mesh_simplification/include/CGAL/Surface_mesh_simplification/Edge_extra_pointer_map_stored.h -text Surface_mesh_simplification/include/CGAL/Surface_mesh_simplification/Policies/Edge_collapse/Cached_cost.h -text Surface_mesh_simplification/include/CGAL/Surface_mesh_simplification/Policies/Edge_collapse/Cached_placement.h -text Surface_mesh_simplification/include/CGAL/Surface_mesh_simplification/Policies/Edge_collapse/Cost_and_placement_cache.h -text diff --git a/Surface_mesh_simplification/examples/Surface_mesh_simplification/LT_edge_collapse_polyhedron.cpp b/Surface_mesh_simplification/examples/Surface_mesh_simplification/LT_edge_collapse_polyhedron.cpp index eb6da708f6f..6dca6e1aaed 100644 --- a/Surface_mesh_simplification/examples/Surface_mesh_simplification/LT_edge_collapse_polyhedron.cpp +++ b/Surface_mesh_simplification/examples/Surface_mesh_simplification/LT_edge_collapse_polyhedron.cpp @@ -11,7 +11,7 @@ // === EXAMPLE SPECIFIC HEADERS BEGINS HERE === // Stop-condition policy -#include +#include // === EXAMPLE SPECIFIC HEADERS ENDS HERE === @@ -31,7 +31,7 @@ int main( int argc, char** argv ) // This is a stop-condition policy (defines when the algorithm terminates). // In this example, the simplification stops when the number of undirected edges // left in the surface drops below the specified number (1000) - SMS::Count_stop_condition stop_policy(1000); + SMS::Count_stop_predicate stop_policy(1000); // This the actual call to the simplification algorithm. // The surface and stop conditions are mandatory arguments. diff --git a/Surface_mesh_simplification/include/CGAL/Surface_mesh_simplification/Collapse_operator.h b/Surface_mesh_simplification/include/CGAL/Surface_mesh_simplification/Collapse_operator.h index 70afe4f67e0..f84407c5a4e 100644 --- a/Surface_mesh_simplification/include/CGAL/Surface_mesh_simplification/Collapse_operator.h +++ b/Surface_mesh_simplification/include/CGAL/Surface_mesh_simplification/Collapse_operator.h @@ -31,48 +31,7 @@ namespace Surface_mesh_simplification // // The net effect of the operator is equivalent to removing one of the vertices and re-triangulating the resulting hole. // -// The actual collapse operation only removes up to 2 faces, 3 edges and 1 vertex, as follows. -// -// The top face, p-q-t, to the left of p->q, if any, is removed. -// The bottom face, q-p-b, to the left of q->p (right of p->q), if any, is removed. -// -// If there is a top-left face, that is, if the edge p->t is NOT a border edge, the top face is removed by joining it -// with the top-left face (this creates a 4 sided face: p-q-t-l). -// If p->t IS a border edge then the top face is simply erased. -// -// If there is a bottom-right face, that is, if the edge q->b is NOT a border edge, the bottom face is removed by joining it -// with the bottom-right face (this creates a 4 sided face: q-p-b-r) -// If q->b IS a border edge then the bottom face is simply erased. -// -// If there is a top face edge p->t is removed. -// If there is a bottom face edge q->b is removed. -// -// One of the vertices (p or q) is removed. -// If there is no top-left face so the top face is directly erased AND there is no bottom face, -// that face erasure automatically removes vertex p. Likewise, if there is no bottom-right face -// so the bottom face is directly erased AND there is no top face, that erasure automatically -// removes vertex q. -// Directly erasing the top/bottom faces when the opposite face exists does not removes any vertex -// automatically, in which case vertex p is removed by joining p->q -// -// NOTES: -// -// This operator can only be called by collapsable edges (which satisfy the link condition), hence, -// there must exist at least the top face or a bottom face, and, if there is no top-left face there is a top-right face -// and likewise, if there is no bottom-right face there is a bottom-left face. (IOW vertices t/b must have degree >=3 -// unless the top/bottom faces do not exists) -// -// The operator doesn't join the top face with the top-left face and the bottom-face with the bottom-left face -// (or both to the right) because if the top-left and bottom-left (or both right) faces are themselve adjacent, -// the first joint would introduce a degree 2 vertex. -// That is why the operator alternates left and right to join the top and bottom faces. -// -// PARAMETERS: -// pq : the edge to collapse -// pt : the edge shared between the top face and the top-left face (if any). If there is no top face this parameter is a null handle. -// qb : the edge shared between the bottom face and the bottom-right face. If there is no bottom face this parameter is a null handle. -// -// RETURN VALUE: A handle to the vertex that IS NOT removed. +// Returns a handle to the vertex that IS NOT removed. // template struct Collapse_triangulation_edge ; diff --git a/Surface_mesh_simplification/include/CGAL/Surface_mesh_simplification/Detail/TSMS_common.h b/Surface_mesh_simplification/include/CGAL/Surface_mesh_simplification/Detail/Common.h similarity index 91% rename from Surface_mesh_simplification/include/CGAL/Surface_mesh_simplification/Detail/TSMS_common.h rename to Surface_mesh_simplification/include/CGAL/Surface_mesh_simplification/Detail/Common.h index b3665949fe5..330c82178c1 100644 --- a/Surface_mesh_simplification/include/CGAL/Surface_mesh_simplification/Detail/TSMS_common.h +++ b/Surface_mesh_simplification/include/CGAL/Surface_mesh_simplification/Detail/Common.h @@ -15,8 +15,8 @@ // // Author(s) : Fernando Cacciola // -#ifndef CGAL_SURFACE_MESH_SIMPLIFICATION_DETAIL_ECMS_COMMON_H -#define CGAL_SURFACE_MESH_SIMPLIFICATION_DETAIL_ECMS_COMMON_H 1 +#ifndef CGAL_SURFACE_MESH_SIMPLIFICATION_DETAIL_COMMON_H +#define CGAL_SURFACE_MESH_SIMPLIFICATION_DETAIL_COMMON_H 1 #include #include @@ -34,7 +34,6 @@ #include #include #include -#include CGAL_BEGIN_NAMESPACE @@ -102,12 +101,6 @@ struct ExtractPlacementParamsType } // namespace Surface_mesh_simplification -// -// Valid surface predicate -// -template -inline bool is_valid_triangulated_surface_mesh ( ECM const& aECM ) { return aECM.is_pure_triangle() ; } - template inline std::string xyz_to_string( XYZ const& xyz ) { @@ -171,6 +164,6 @@ CGAL_END_NAMESPACE #undef CGAL_ECMS_ENABLE_TRACE -#endif // CGAL_SURFACE_MESH_SIMPLIFICATION_DETAIL_ECMS_COMMON_H // +#endif // CGAL_SURFACE_MESH_SIMPLIFICATION_DETAIL_COMMON_H // // EOF // diff --git a/Surface_mesh_simplification/include/CGAL/Surface_mesh_simplification/Detail/Edge_collapse.h b/Surface_mesh_simplification/include/CGAL/Surface_mesh_simplification/Detail/Edge_collapse.h index 24e0f943f25..1c44030a4dc 100644 --- a/Surface_mesh_simplification/include/CGAL/Surface_mesh_simplification/Detail/Edge_collapse.h +++ b/Surface_mesh_simplification/include/CGAL/Surface_mesh_simplification/Detail/Edge_collapse.h @@ -27,7 +27,7 @@ #include #include -#include +#include #include CGAL_BEGIN_NAMESPACE @@ -40,8 +40,10 @@ namespace Surface_mesh_simplification // template - { - ID_map( Self const* aAlgorithm ) : mAlgorithm(aAlgorithm) {} - - typedef boost::readable_property_map_tag category; - typedef size_type value_type; - typedef size_type reference; - typedef edge_descriptor key_type; - - size_type operator[]( edge_descriptor const& e ) const { return mAlgorithm->get_id(e); } - - Self const* mAlgorithm ; - }; - typedef Modifiable_priority_queue PQ ; + typedef Modifiable_priority_queue PQ ; typedef typename PQ::handle pq_handle ; // An Edge_data is associated with EVERY _undirected_ edge in the mesh (collapsable or not). @@ -140,7 +131,7 @@ public: { public : - Edge_cache() : mPQHandle(), mID(0) {} + Edge_cache() : mPQHandle() {} Cache const& cache() const { return mCache ; } Cache & cache() { return mCache ; } @@ -153,15 +144,10 @@ public: void reset_PQ_handle() { mPQHandle = PQ::null_handle() ; } - size_type id() const { return mID ; } - size_type& id() { return mID ; } - private: Cache mCache ; pq_handle mPQHandle ; - size_type mID ; - } ; typedef Edge_data* Edge_data_ptr ; typedef boost::scoped_array Edge_data_array ; @@ -171,8 +157,10 @@ public: EdgeCollapse( ECM& aSurface , ShouldStop const& aShouldStop - , EdgeExtraPtrMap const& aEdge_extra_ptr_map + , VertexPointMap const& aVertex_point_map , VertexIsFixedMap const& aVertex_is_fixed_map + , EdgeIndxMap const& aEdge_index_map + , EdgeIsBorderMap const& aEdge_is_border_map , SetCache const& aSetCache , GetCost const& aGetCost , GetPlacement const& aGetPlacement @@ -191,36 +179,26 @@ private: void Collapse( edge_descriptor const& aEdge ) ; void Update_neighbors( vertex_descriptor const& aKeptV ) ; - bool is_vertex_fixed ( const_vertex_descriptor const& v ) const { return get(Vertex_is_fixed_map,v) ; } + size_type get_id ( edge_descriptor const& aEdge ) const { return get(Edge_index_map,aEdge); } - bool is_border ( const_vertex_descriptor const& v ) const - { - vertex_is_border_t is_border_vertex_property ; - return get(is_border_vertex_property,mSurface,v) ; - } + bool is_vertex_fixed ( const_vertex_descriptor const& aV ) const { return get(Vertex_is_fixed_map,aV) ; } - bool is_border ( const_edge_descriptor const& aEdge ) const - { - edge_is_border_t is_border_edge_property ; - return get(is_border_edge_property,mSurface,aEdge) ; - } + bool is_border ( const_edge_descriptor const& aEdge ) const { return get(Edge_is_border_map,aEdge) ; } bool is_undirected_edge_a_border ( const_edge_descriptor const& aEdge ) const { return is_border(aEdge) || is_border(opposite_edge(aEdge,mSurface)) ; } - Edge_data_ptr get_data ( edge_descriptor const& aEdge ) const { return static_cast(get(Edge_extra_ptr_map,aEdge)) ; } + bool is_border ( const_vertex_descriptor const& aV ) const ; - void set_data ( edge_descriptor const& aEdge, Edge_data_ptr aData ) { put(Edge_extra_ptr_map,aEdge,static_cast(aData)) ; } - - size_type get_id ( edge_descriptor const& aEdge ) const - { - Edge_data_ptr lData = get_data(aEdge); - CGAL_assertion(lData); - return lData->id(); + Edge_data& get_data ( edge_descriptor const& aEdge ) const + { + return mEdgeDataArray[get_id(aEdge)/2]; } - + + Point get_point ( const_vertex_descriptor const aV ) const { return get(Vertex_point_map,aV); } + tuple get_vertices( const_edge_descriptor const& aEdge ) const { const_vertex_descriptor p,q ; @@ -251,16 +229,12 @@ private: Optional_cost_type get_cost ( edge_descriptor const& aEdge ) const { - Edge_data_ptr lData = get_data(aEdge); - CGAL_assertion(lData); - return Get_cost(aEdge,mSurface,lData->cache(),mCostParams); + return Get_cost(aEdge,mSurface,get_data(aEdge).cache(),mCostParams); } Optional_placement_type get_placement( edge_descriptor const& aEdge ) const { - Edge_data_ptr lData = get_data(aEdge); - CGAL_assertion(lData); - return Get_placement(aEdge,mSurface,lData->cache(),mPlacementParams); + return Get_placement(aEdge,mSurface,get_data(aEdge).cache(),mPlacementParams); } bool compare_cost( edge_descriptor const& aEdgeA, edge_descriptor const& aEdgeB ) const @@ -301,7 +275,7 @@ private: { optional rEdge = mPQ->extract_top(); if ( rEdge ) - get_data(*rEdge)->reset_PQ_handle(); + get_data(*rEdge).reset_PQ_handle(); return rEdge ; } @@ -309,8 +283,10 @@ private: ECM& mSurface ; ShouldStop const& Should_stop ; - EdgeExtraPtrMap const& Edge_extra_ptr_map ; + VertexPointMap const& Vertex_point_map ; VertexIsFixedMap const& Vertex_is_fixed_map ; + EdgeIndexMap const& Edge_index_map ; + EdgeIsBorderMap const& Edge_is_border_map ; SetCache const& Set_cache; GetCost const& Get_cost ; GetPlacement const& Get_placement ; diff --git a/Surface_mesh_simplification/include/CGAL/Surface_mesh_simplification/Detail/Edge_collapse_impl.h b/Surface_mesh_simplification/include/CGAL/Surface_mesh_simplification/Detail/Edge_collapse_impl.h index 4f228c0aa89..1bcdf48cfbd 100644 --- a/Surface_mesh_simplification/include/CGAL/Surface_mesh_simplification/Detail/Edge_collapse_impl.h +++ b/Surface_mesh_simplification/include/CGAL/Surface_mesh_simplification/Detail/Edge_collapse_impl.h @@ -23,24 +23,28 @@ CGAL_BEGIN_NAMESPACE namespace Surface_mesh_simplification { -template -EdgeCollapse::EdgeCollapse( ECM& aSurface - , ShouldStop const& aShould_stop - , EdgeExtraPtrMap const& aEdge_extra_ptr_map - , VertexIsFixedMap const& aVertex_is_fixed_map - , SetCache const& aSet_cache - , GetCost const& aGet_cost - , GetPlacement const& aGet_placement - , CostParams const* aCostParams - , PlacementParams const* aPlacementParams - , VisitorT* aVisitor - ) +template +EdgeCollapse::EdgeCollapse( ECM& aSurface + , ShouldStop const& aShould_stop + , VertexPoinntMap const& aVertex_point_map + , VertexIsFixedMap const& aVertex_is_fixed_map + , EdgeIndexMap const& aEdge_index_map + , EdgeIsBorderMap const& aEdge_is_border_map + , SetCache const& aSet_cache + , GetCost const& aGet_cost + , GetPlacement const& aGet_placement + , CostParams const* aCostParams + , PlacementParams const* aPlacementParams + , VisitorT* aVisitor + ) : mSurface (aSurface) ,Should_stop (aShould_stop) - ,Edge_extra_ptr_map (aEdge_extra_ptr_map) + ,Vertex_point_map (aVertex_point_map) ,Vertex_is_fixed_map(aVertex_is_fixed_map) - ,Set_cache (aSet_cache) + ,Edge_index_map (aEdge_index_map) + ,Edge_is_border_map (aEdge_is_border_map) + ,Set_cache (aSet_cache) ,Get_cost (aGet_cost) ,Get_placement (aGet_placement) ,mCostParams (aCostParams) @@ -48,10 +52,10 @@ EdgeCollapse::EdgeCollapse( ECM& aSu ,Visitor (aVisitor) { - CGAL_expensive_precondition( is_valid_triangulated_surface_mesh(mSurface) ); - 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_DEBUG_CODE ( mStep = 0 ; ) #ifdef CGAL_SURFACE_SIMPLIFICATION_ENABLE_TRACE @@ -65,8 +69,8 @@ EdgeCollapse::EdgeCollapse( ECM& aSu #endif } -template -int EdgeCollapse::run() +template +int EdgeCollapse::run() { if ( Visitor ) Visitor->OnStarted(mSurface); @@ -89,8 +93,8 @@ int EdgeCollapse::run() return r ; } -template -void EdgeCollapse::Collect() +template +void EdgeCollapse::Collect() { CGAL_ECMS_TRACE(0,"Collecting edges..."); @@ -100,27 +104,17 @@ void EdgeCollapse::Collect() Equal_3 equal_points = Kernel().equal_3_object(); - size_type lSize = num_edges(mSurface) / 2 ; + size_type lSize = num_undirected_edges(mSurface) ; mInitialEdgeCount = mCurrentEdgeCount = lSize; mEdgeDataArray.reset( new Edge_data[lSize] ) ; - mPQ.reset( new PQ (lSize, Compare_cost(this), ID_map(this) ) ) ; - - Edge_data_ptr lData = mEdgeDataArray.get(); - - Edge_data_ptr lData_End = lData + lSize ; - - size_type lID = 0 ; + mPQ.reset( new PQ (lSize, Compare_cost(this), Edge_index_map ) ) ; undirected_edge_iterator eb, ee ; for ( tie(eb,ee) = undirected_edges(mSurface); eb!=ee; ++eb ) { - CGAL_assertion( lData < lData_End ) ; - - lData->id() = lID ++ ; - edge_descriptor lEdge = *eb ; vertex_descriptor p,q ; @@ -131,13 +125,11 @@ void EdgeCollapse::Collect() if ( p == q || equal_points( get_point(p,mSurface), get_point(q,mSurface)) ) lIsFixed = true ; - // For simplicity, ALL edges, fixed or not, are associated with an edge data. - set_data(lEdge,lData); - // But in the case of fixed edges the edge data is left default constructed if ( !lIsFixed ) { - Set_cache(lData->cache(),lEdge,mSurface,mCostParams,mPlacementParams) ; + Edge_data& lData = get_data(lEdge); + Set_cache(lData.cache(),lEdge,mSurface,mCostParams,mPlacementParams) ; insert_in_PQ(lEdge,lData); } @@ -145,15 +137,13 @@ void EdgeCollapse::Collect() Visitor->OnCollected(lEdge,lIsFixed,mSurface); CGAL_ECMS_TRACE(2,edge_to_string(lEdge)); - - ++ lData ; } CGAL_ECMS_TRACE(0,"Initial edge count: " << mInitialEdgeCount ) ; } -template -void EdgeCollapse::Loop() +template +void EdgeCollapse::Loop() { CGAL_ECMS_TRACE(0,"Collapsing edges...") ; @@ -204,6 +194,25 @@ void EdgeCollapse::Loop() } } +template +bool EdgeCollapse::is_border( const_vertex_descriptor const& aV ) +{ + bool rR = false ; + + in_edge_iterator eb, ee ; + for ( tie(eb,ee) = in_edges(aV,mSurface) ; eb != ee ; ++ eb ) + { + edge_descriptor lEdge = *eb ; + if ( is_undirected_edge_a_border(lEdge) ) + { + rR = true ; + break ; + } + } + + return rR ; +} + // Some edges are NOT collapsable: doing so would break the topological consistency of the mesh. // This function returns true if a edge 'p->q' can be collapsed. // @@ -212,8 +221,8 @@ void EdgeCollapse::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. // -template -bool EdgeCollapse::Is_collapsable( edge_descriptor const& aEdgePQ ) +template +bool EdgeCollapse::Is_collapsable( edge_descriptor const& aEdgePQ ) { bool rR = true ; @@ -305,8 +314,8 @@ bool EdgeCollapse::Is_collapsable( edge_descriptor cons return rR ; } -template -void EdgeCollapse::Collapse( edge_descriptor const& aEdgePQ ) +template +void EdgeCollapse::Collapse( edge_descriptor const& aEdgePQ ) { CGAL_ECMS_TRACE(1,"S" << mStep << ". Collapsig " << edge_to_string(aEdgePQ) ) ; @@ -360,19 +369,11 @@ void EdgeCollapse::Collapse( edge_descriptor const& aEd << ") EdgeTP E" << lEdgePT->opposite()->ID ) ; - edge_descriptor lUndirectedEdgePT = lEdgePT ; - Edge_data_ptr lDataPT = get_data(lUndirectedEdgePT) ; - if ( !lDataPT ) + Edge_data& lDataPT = get_data(lEdgePT) ; + if ( lDataPT.is_in_PQ() ) { - lUndirectedEdgePT = opposite_edge(lUndirectedEdgePT,mSurface); - lDataPT = get_data(lUndirectedEdgePT); - CGAL_assertion(lDataPT); - } - - if ( lDataPT->is_in_PQ() ) - { - CGAL_ECMS_TRACE(2,"Removing E" << lUndirectedEdgePT->ID << " from PQ" ) ; - remove_from_PQ(lUndirectedEdgePT,lDataPT) ; + CGAL_ECMS_TRACE(2,"Removing E" << lEdgePT->ID << " from PQ" ) ; + remove_from_PQ(lEdgePT,lDataPT) ; -- mCurrentEdgeCount ; } } @@ -384,19 +385,11 @@ void EdgeCollapse::Collapse( edge_descriptor const& aEd << ") EdgeBQ E" << lEdgeQB->opposite()->ID ) ; - edge_descriptor lUndirectedEdgeQB = lEdgeQB ; - - Edge_data_ptr lDataQB = get_data(lUndirectedEdgeQB) ; - if ( !lDataQB ) + Edge_data& lDataQB = get_data(lEdgeQB) ; + if ( lDataQB.is_in_PQ() ) { - lUndirectedEdgeQB = opposite_edge(lUndirectedEdgeQB,mSurface); - lDataQB = get_data(lUndirectedEdgeQB); - CGAL_assertion(lDataQB); - } - if ( lDataQB->is_in_PQ() ) - { - CGAL_ECMS_TRACE(2,"Removing E" << lUndirectedEdgeQB->ID << " from PQ") ; - remove_from_PQ(lUndirectedEdgeQB,lDataQB) ; + CGAL_ECMS_TRACE(2,"Removing E" << lEdgeQB->ID << " from PQ") ; + remove_from_PQ(lEdgeQB,lDataQB) ; -- mCurrentEdgeCount ; } } @@ -411,7 +404,7 @@ void EdgeCollapse::Collapse( edge_descriptor const& aEd // 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,lEdgePT,lEdgeQB,mSurface); + rResult = Collapse_triangulation_edge(aEdgePQ,mSurface); CGAL_ECMS_TRACE(1,"V" << rResult->ID << " kept." ) ; @@ -435,8 +428,8 @@ void EdgeCollapse::Collapse( edge_descriptor const& aEd return rResult ; } -template -void EdgeCollapse::Update_neighbors( vertex_descriptor const& aKeptV ) +template +void EdgeCollapse::Update_neighbors( vertex_descriptor const& aKeptV ) { CGAL_ECMS_TRACE(3,"Updating cost of neighboring edges..." ) ; @@ -462,18 +455,11 @@ void EdgeCollapse::Update_neighbors( vertex_descriptor { edge_descriptor lEdge2 = *eb2 ; - Edge_data_ptr lData2 = get_data(lEdge2); - if ( !lData2 ) - { - lEdge2 = opposite_edge(lEdge2,mSurface); - lData2 = get_data(lEdge2); - CGAL_assertion(lData2); - } - + Edge_data& lData2 = get_data(lEdge2); CGAL_ECMS_TRACE(4,"Inedge around V" << lAdj_k->ID << edge_to_string(lEdge2) ) ; // Only those edges still in the PQ _and_ not already collected are updated. - if ( lData2->is_in_PQ() && lToUpdate.find(lEdge2) == lToUpdate.end() ) + if ( lData2.is_in_PQ() && lToUpdate.find(lEdge2) == lToUpdate.end() ) lToUpdate.insert(lEdge2) ; } } @@ -486,11 +472,9 @@ void EdgeCollapse::Update_neighbors( vertex_descriptor { edge_descriptor lEdge = *it; - Edge_data_ptr lData = get_data(lEdge); + Edge_data& lData = get_data(lEdge); - CGAL_assertion(lData); - - Set_cache(lData->cache(),lEdge,mSurface,mCostParams,mPlacementParams) ; + Set_cache(lData.cache(),lEdge,mSurface,mCostParams,mPlacementParams) ; CGAL_ECMS_TRACE(3, edge_to_string(lEdge) << " updated in the PQ") ; diff --git a/Surface_mesh_simplification/include/CGAL/Surface_mesh_simplification/Edge_extra_pointer_map_stored.h b/Surface_mesh_simplification/include/CGAL/Surface_mesh_simplification/Edge_extra_pointer_map_stored.h deleted file mode 100644 index dd2d9ecc0d0..00000000000 --- a/Surface_mesh_simplification/include/CGAL/Surface_mesh_simplification/Edge_extra_pointer_map_stored.h +++ /dev/null @@ -1,47 +0,0 @@ -// Copyright (c) 2006 Geometry Factory (France). -// All rights reserved. -// -// This file is part of CGAL (www.cgal.org); you may redistribute it under -// the terms of the Q Public License version 1.0. -// See the file LICENSE.QPL distributed with CGAL. -// -// Licensees holding a valid commercial license may use this file in -// accordance with the commercial license agreement provided with the software. -// -// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE -// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. -// -// $URL: svn+ssh://fcacciola@scm.gforge.inria.fr/svn/cgal/trunk/Surface_mesh_simplification/include/CGAL/Surface_mesh_simplification/Edge_extra_pointer_map_stored.h $ -// $Id: Edge_extra_pointer_map_stored.h 32048 2006-06-23 13:59:36Z lsaboret $ -// -// -// Author(s): Fernando Cacciola - -#ifndef CGAL_SURFACE_MESH_SIMPLIFICATION_EDGE_EXTRA_POINTER_MAP_STORED_H -#define CGAL_SURFACE_MESH_SIMPLIFICATION_EDGE_EXTRA_POINTER_MAP_STORED_H - -#include -#include - -CGAL_BEGIN_NAMESPACE - -template -class Edge_extra_pointer_map_stored : public boost::put_get_helper > -{ -private: - - typedef Graph_ Graph ; - -public: - - typedef boost::lvalue_property_map_tag category; - typedef void* value_type; - typedef void*& reference; - typedef typename boost::graph_traits::edge_descriptor key_type; - - reference operator[](key_type const& e) const { return e->extra_pointer() ; } -}; - -CGAL_END_NAMESPACE - -#endif // CGAL_SURFACE_MESH_SIMPLIFICATION_EDGE_EXTRA_POINTER_MAP_STORED_H diff --git a/Surface_mesh_simplification/include/CGAL/Surface_mesh_simplification/Policies/Edge_collapse/Cached_cost.h b/Surface_mesh_simplification/include/CGAL/Surface_mesh_simplification/Policies/Edge_collapse/Cached_cost.h index ceeb32a2d51..a146110cae8 100644 --- a/Surface_mesh_simplification/include/CGAL/Surface_mesh_simplification/Policies/Edge_collapse/Cached_cost.h +++ b/Surface_mesh_simplification/include/CGAL/Surface_mesh_simplification/Policies/Edge_collapse/Cached_cost.h @@ -18,7 +18,7 @@ #ifndef CGAL_SURFACE_MESH_SIMPLIFICATION_POLICIES_EDGE_COLLAPSE_CACHED_COST_H #define CGAL_SURFACE_MESH_SIMPLIFICATION_POLICIES_EDGE_COLLAPSE_CACHED_COST_H -#include +#include CGAL_BEGIN_NAMESPACE diff --git a/Surface_mesh_simplification/include/CGAL/Surface_mesh_simplification/Policies/Edge_collapse/Cached_placement.h b/Surface_mesh_simplification/include/CGAL/Surface_mesh_simplification/Policies/Edge_collapse/Cached_placement.h index 242b59fcd42..3ef91d2aeff 100644 --- a/Surface_mesh_simplification/include/CGAL/Surface_mesh_simplification/Policies/Edge_collapse/Cached_placement.h +++ b/Surface_mesh_simplification/include/CGAL/Surface_mesh_simplification/Policies/Edge_collapse/Cached_placement.h @@ -18,7 +18,7 @@ #ifndef CGAL_SURFACE_MESH_SIMPLIFICATION_POLICIES_EDGE_COLLAPSE_CACHED_PLACEMENT_H #define CGAL_SURFACE_MESH_SIMPLIFICATION_POLICIES_EDGE_COLLAPSE_CACHED_PLACEMENT_H -#include +#include CGAL_BEGIN_NAMESPACE diff --git a/Surface_mesh_simplification/include/CGAL/Surface_mesh_simplification/Policies/Edge_collapse/Cost_and_placement_cache.h b/Surface_mesh_simplification/include/CGAL/Surface_mesh_simplification/Policies/Edge_collapse/Cost_and_placement_cache.h index 5459e5bcbfb..226283e7bd8 100644 --- a/Surface_mesh_simplification/include/CGAL/Surface_mesh_simplification/Policies/Edge_collapse/Cost_and_placement_cache.h +++ b/Surface_mesh_simplification/include/CGAL/Surface_mesh_simplification/Policies/Edge_collapse/Cost_and_placement_cache.h @@ -15,10 +15,10 @@ // // Author(s) : Fernando Cacciola // -#ifndef CGAL_SURFACE_MESH_SIMPLIFICATION_POLICIES_EDGE_COLLAPSE_FULL_COLLAPSE_DATA_H -#define CGAL_SURFACE_MESH_SIMPLIFICATION_POLICIES_EDGE_COLLAPSE_FULL_COLLAPSE_DATA_H +#ifndef CGAL_SURFACE_MESH_SIMPLIFICATION_POLICIES_EDGE_COLLAPSE_COST_AND_PLACEMENT_CACHE_H +#define CGAL_SURFACE_MESH_SIMPLIFICATION_POLICIES_EDGE_COLLAPSE_COST_AND_PLACEMENT_CACHE_H -#include +#include CGAL_BEGIN_NAMESPACE @@ -36,8 +36,8 @@ public: typedef typename Kernel_traits::Kernel Kernel ; typedef typename Kernel::FT FT ; - typedef optional Optional_cost_type ; - typedef optional Optional_placement_type ; + typedef optional Optional_cost_type ; + typedef optional Optional_placement_type ; public : @@ -63,6 +63,6 @@ private : CGAL_END_NAMESPACE -#endif // CGAL_SURFACE_MESH_SIMPLIFICATION_POLICIES_EDGE_COLLAPSE_FULL_COLLAPSE_DATA_H +#endif // CGAL_SURFACE_MESH_SIMPLIFICATION_POLICIES_EDGE_COLLAPSE_COST_AND_PLACEMENT_CACHE_H // EOF // diff --git a/Surface_mesh_simplification/include/CGAL/Surface_mesh_simplification/Policies/Edge_collapse/Cost_cache.h b/Surface_mesh_simplification/include/CGAL/Surface_mesh_simplification/Policies/Edge_collapse/Cost_cache.h index cb13d3e0c80..1671f98dc6b 100644 --- a/Surface_mesh_simplification/include/CGAL/Surface_mesh_simplification/Policies/Edge_collapse/Cost_cache.h +++ b/Surface_mesh_simplification/include/CGAL/Surface_mesh_simplification/Policies/Edge_collapse/Cost_cache.h @@ -15,10 +15,10 @@ // // Author(s) : Fernando Cacciola // -#ifndef CGAL_SURFACE_MESH_SIMPLIFICATION_POLICIES_EDGE_COLLAPSE_PARTIAL_COLLAPSE_DATA_H -#define CGAL_SURFACE_MESH_SIMPLIFICATION_POLICIES_EDGE_COLLAPSE_PARTIAL_COLLAPSE_DATA_H +#ifndef CGAL_SURFACE_MESH_SIMPLIFICATION_POLICIES_EDGE_COLLAPSE_COST_CACHE_H +#define CGAL_SURFACE_MESH_SIMPLIFICATION_POLICIES_EDGE_COLLAPSE_COST_CACHE_H -#include +#include CGAL_BEGIN_NAMESPACE @@ -42,10 +42,7 @@ public : Cost_cache() {} - Cost_cache( Optional_cost_type aCost ) - : - mCost (aCost) - {} + Cost_cache( Optional_cost_type aCost ) : mCost(aCost) {} Optional_cost_type cost() const { return mCost ; } @@ -58,6 +55,6 @@ private : CGAL_END_NAMESPACE -#endif // CGAL_SURFACE_MESH_SIMPLIFICATION_POLICIES_EDGE_COLLAPSE_PARTIAL_COLLAPSE_DATA_H +#endif // CGAL_SURFACE_MESH_SIMPLIFICATION_POLICIES_EDGE_COLLAPSE_COST_CACHE_H // EOF // diff --git a/Surface_mesh_simplification/include/CGAL/Surface_mesh_simplification/Policies/Edge_collapse/Count_ratio_stop_predicate.h b/Surface_mesh_simplification/include/CGAL/Surface_mesh_simplification/Policies/Edge_collapse/Count_ratio_stop_predicate.h index 278a474cede..acf0564f62a 100644 --- a/Surface_mesh_simplification/include/CGAL/Surface_mesh_simplification/Policies/Edge_collapse/Count_ratio_stop_predicate.h +++ b/Surface_mesh_simplification/include/CGAL/Surface_mesh_simplification/Policies/Edge_collapse/Count_ratio_stop_predicate.h @@ -15,10 +15,10 @@ // // Author(s) : Fernando Cacciola // -#ifndef CGAL_SURFACE_MESH_SIMPLIFICATION_POLICIES_EDGE_COLLAPSE_COUNT_RATIO_STOP_PRED_H -#define CGAL_SURFACE_MESH_SIMPLIFICATION_POLICIES_EDGE_COLLAPSE_COUNT_RATIO_STOP_PRED_H 1 +#ifndef CGAL_SURFACE_MESH_SIMPLIFICATION_POLICIES_EDGE_COLLAPSE_COUNT_RATIO_STOP_PREDICATE_H +#define CGAL_SURFACE_MESH_SIMPLIFICATION_POLICIES_EDGE_COLLAPSE_COUNT_RATIO_STOP_PREDICATE_H 1 -#include +#include CGAL_BEGIN_NAMESPACE @@ -72,6 +72,6 @@ private: CGAL_END_NAMESPACE -#endif // CGAL_SURFACE_MESH_SIMPLIFICATION_POLICIES_EDGE_COLLAPSE_COUNT_RATIO_STOP_PRED_H // +#endif // CGAL_SURFACE_MESH_SIMPLIFICATION_POLICIES_EDGE_COLLAPSE_COUNT_RATIO_STOP_PREDICATE_H // // EOF // diff --git a/Surface_mesh_simplification/include/CGAL/Surface_mesh_simplification/Policies/Edge_collapse/Count_stop_predicate.h b/Surface_mesh_simplification/include/CGAL/Surface_mesh_simplification/Policies/Edge_collapse/Count_stop_predicate.h index 3909f2b300b..46e10c3f4b5 100644 --- a/Surface_mesh_simplification/include/CGAL/Surface_mesh_simplification/Policies/Edge_collapse/Count_stop_predicate.h +++ b/Surface_mesh_simplification/include/CGAL/Surface_mesh_simplification/Policies/Edge_collapse/Count_stop_predicate.h @@ -15,10 +15,10 @@ // // Author(s) : Fernando Cacciola // -#ifndef CGAL_SURFACE_MESH_SIMPLIFICATION_POLICIES_EDGE_COLLAPSE_COUNT_STOP_PRED_H -#define CGAL_SURFACE_MESH_SIMPLIFICATION_POLICIES_EDGE_COLLAPSE_COUNT_STOP_PRED_H 1 +#ifndef CGAL_SURFACE_MESH_SIMPLIFICATION_POLICIES_EDGE_COLLAPSE_COUNT_STOP_PREDICATE_H +#define CGAL_SURFACE_MESH_SIMPLIFICATION_POLICIES_EDGE_COLLAPSE_COUNT_STOP_PREDICATE_H 1 -#include +#include CGAL_BEGIN_NAMESPACE @@ -77,6 +77,6 @@ private: CGAL_END_NAMESPACE -#endif // CGAL_SURFACE_MESH_SIMPLIFICATION_POLICIES_EDGE_COLLAPSE_COUNT_STOP_PRED_H // +#endif // CGAL_SURFACE_MESH_SIMPLIFICATION_POLICIES_EDGE_COLLAPSE_COUNT_STOP_PREDICATE_H // // EOF // diff --git a/Surface_mesh_simplification/include/CGAL/Surface_mesh_simplification/Policies/Edge_collapse/Detail/Lindstrom_Turk_core.h b/Surface_mesh_simplification/include/CGAL/Surface_mesh_simplification/Policies/Edge_collapse/Detail/Lindstrom_Turk_core.h index df08bafc0cc..6dfcf213571 100644 --- a/Surface_mesh_simplification/include/CGAL/Surface_mesh_simplification/Policies/Edge_collapse/Detail/Lindstrom_Turk_core.h +++ b/Surface_mesh_simplification/include/CGAL/Surface_mesh_simplification/Policies/Edge_collapse/Detail/Lindstrom_Turk_core.h @@ -20,7 +20,7 @@ #include -#include +#include #include CGAL_BEGIN_NAMESPACE @@ -136,14 +136,18 @@ private : bool is_border ( edge_descriptor const& edge ) const { - edge_is_border_t is_border_property ; - return get(is_border_property,mSurface,edge) ; + return get(edge_is_border,mSurface,edge) ; } bool is_undirected_edge_a_border ( edge_descriptor const& edge ) const { return is_border(edge) || is_border(opposite_edge(edge,mSurface)) ; } + Point const& get_point ( const_vertex_descriptor const& v ) const + { + return get(vertex_point,mSurface,v); + } + static Vector Point_cross_product ( Point const& a, Point const& b ) { return cross_product(a-ORIGIN,b-ORIGIN); diff --git a/Surface_mesh_simplification/include/CGAL/Surface_mesh_simplification/Policies/Edge_collapse/Edge_length_cost.h b/Surface_mesh_simplification/include/CGAL/Surface_mesh_simplification/Policies/Edge_collapse/Edge_length_cost.h index bf999a534c8..0892479bfcd 100644 --- a/Surface_mesh_simplification/include/CGAL/Surface_mesh_simplification/Policies/Edge_collapse/Edge_length_cost.h +++ b/Surface_mesh_simplification/include/CGAL/Surface_mesh_simplification/Policies/Edge_collapse/Edge_length_cost.h @@ -18,7 +18,7 @@ #ifndef CGAL_SURFACE_MESH_SIMPLIFICATION_POLICIES_EDGE_COLLAPSE_EDGE_LENGHT_COST_H #define CGAL_SURFACE_MESH_SIMPLIFICATION_POLICIES_EDGE_COLLAPSE_EDGE_LENGHT_COST_H -#include +#include CGAL_BEGIN_NAMESPACE @@ -40,9 +40,9 @@ private : typedef typename boost::graph_traits::vertex_descriptor vertex_descriptor ; - typedef typename halfedge_graph_traits::Point Point_3 ; + typedef typename halfedge_graph_traits::Point Point ; - typedef typename Kernel_traits::Kernel Kernel ; + typedef typename Kernel_traits::Kernel Kernel ; public: @@ -68,8 +68,8 @@ public: { vertex_descriptor vs,vt ; tie(vs,vt) = this->get_vertices(aEdge,aSurface); - Point_3 const& ps = get_point(vs,aSurface); - Point_3 const& pt = get_point(vt,aSurface); + Point_3 const& ps = get(vertex_point,aSurface,vs); + Point_3 const& pt = get(vertex_point,aSurface,vt); return result_type(squared_distance(ps,pt)); } diff --git a/Surface_mesh_simplification/include/CGAL/Surface_mesh_simplification/Policies/Edge_collapse/LindstromTurk.h b/Surface_mesh_simplification/include/CGAL/Surface_mesh_simplification/Policies/Edge_collapse/LindstromTurk.h index d9fea698f3d..e4a172298cb 100644 --- a/Surface_mesh_simplification/include/CGAL/Surface_mesh_simplification/Policies/Edge_collapse/LindstromTurk.h +++ b/Surface_mesh_simplification/include/CGAL/Surface_mesh_simplification/Policies/Edge_collapse/LindstromTurk.h @@ -19,11 +19,11 @@ #define CGAL_SURFACE_MESH_SIMPLIFICATION_POLICIES_EDGE_COLLAPSE_LINDSTROMTURK_H 1 #include -#include +#include #include #include -#include -#include +#include +#include #include #include diff --git a/Surface_mesh_simplification/include/CGAL/Surface_mesh_simplification/Policies/Edge_collapse/LindstromTurk_cost.h b/Surface_mesh_simplification/include/CGAL/Surface_mesh_simplification/Policies/Edge_collapse/LindstromTurk_cost.h index 7194bbe77d8..e5aabe05b71 100644 --- a/Surface_mesh_simplification/include/CGAL/Surface_mesh_simplification/Policies/Edge_collapse/LindstromTurk_cost.h +++ b/Surface_mesh_simplification/include/CGAL/Surface_mesh_simplification/Policies/Edge_collapse/LindstromTurk_cost.h @@ -18,7 +18,7 @@ #ifndef CGAL_SURFACE_MESH_SIMPLIFICATION_POLICIES_EDGE_COLLAPSE_LINDSTROMTURK_COST_H #define CGAL_SURFACE_MESH_SIMPLIFICATION_POLICIES_EDGE_COLLAPSE_LINDSTROMTURK_COST_H 1 -#include +#include CGAL_BEGIN_NAMESPACE @@ -35,9 +35,9 @@ public: typedef typename boost::graph_traits::vertex_descriptor vertex_descriptor ; typedef typename boost::graph_traits::edge_descriptor edge_descriptor ; - typedef typename halfedge_graph_traits::Point Point_3 ; - typedef typename Kernel_traits::Kernel Kernel ; - typedef typename Kernel::FT FT ; + typedef typename halfedge_graph_traits::Point Point ; + typedef typename Kernel_traits::Kernel Kernel ; + typedef typename Kernel::FT FT ; typedef LindstromTurk_params Params ; @@ -59,8 +59,8 @@ public: LindstromTurkCore core(*aParams,aEdge,aSurface,true); - optional lCost ; - optional lPlacement ; + optional lCost ; + optional lPlacement ; tie(lCost,lPlacement) = core.compute(); return lCost ; diff --git a/Surface_mesh_simplification/include/CGAL/Surface_mesh_simplification/Policies/Edge_collapse/LindstromTurk_placement.h b/Surface_mesh_simplification/include/CGAL/Surface_mesh_simplification/Policies/Edge_collapse/LindstromTurk_placement.h index a81cc7e78d0..44d1abf8a76 100644 --- a/Surface_mesh_simplification/include/CGAL/Surface_mesh_simplification/Policies/Edge_collapse/LindstromTurk_placement.h +++ b/Surface_mesh_simplification/include/CGAL/Surface_mesh_simplification/Policies/Edge_collapse/LindstromTurk_placement.h @@ -18,7 +18,7 @@ #ifndef CGAL_SURFACE_MESH_SIMPLIFICATION_POLICIES_EDGE_COLLAPSE_LINDSTROMTURK_PLACEMENT_H #define CGAL_SURFACE_MESH_SIMPLIFICATION_POLICIES_EDGE_COLLAPSE_LINDSTROMTURK_PLACEMENT_H 1 -#include +#include CGAL_BEGIN_NAMESPACE @@ -35,13 +35,13 @@ public: typedef typename boost::graph_traits::vertex_descriptor vertex_descriptor ; typedef typename boost::graph_traits::edge_descriptor edge_descriptor ; - typedef typename halfedge_graph_traits::Point Point_3 ; - typedef typename Kernel_traits::Kernel Kernel ; - typedef typename Kernel::FT FT ; + typedef typename halfedge_graph_traits::Point Point ; + typedef typename Kernel_traits::Kernel Kernel ; + typedef typename Kernel::FT FT ; typedef LindstromTurk_params Params ; - typedef optional result_type ; + typedef optional result_type ; public: diff --git a/Surface_mesh_simplification/include/CGAL/Surface_mesh_simplification/Policies/Edge_collapse/LindstromTurk_set_cost_and_placement_cache.h b/Surface_mesh_simplification/include/CGAL/Surface_mesh_simplification/Policies/Edge_collapse/LindstromTurk_set_cost_and_placement_cache.h index 55135282f75..6e37434855c 100644 --- a/Surface_mesh_simplification/include/CGAL/Surface_mesh_simplification/Policies/Edge_collapse/LindstromTurk_set_cost_and_placement_cache.h +++ b/Surface_mesh_simplification/include/CGAL/Surface_mesh_simplification/Policies/Edge_collapse/LindstromTurk_set_cost_and_placement_cache.h @@ -15,11 +15,11 @@ // // Author(s) : Fernando Cacciola // -#ifndef CGAL_SURFACE_MESH_SIMPLIFICATION_POLICIES_EDGE_COLLAPSE_LINDSTROMTURK_SET_FULL_COLLAPSE_DATA_H -#define CGAL_SURFACE_MESH_SIMPLIFICATION_POLICIES_EDGE_COLLAPSE_LINDSTROMTURK_SET_FULL_COLLAPSE_DATA_H 1 +#ifndef CGAL_SURFACE_MESH_SIMPLIFICATION_POLICIES_EDGE_COLLAPSE_LINDSTROMTURK_SET_COST_AND_PLACEMENT_CACHE_H +#define CGAL_SURFACE_MESH_SIMPLIFICATION_POLICIES_EDGE_COLLAPSE_LINDSTROMTURK_SET_COST_AND_PLACEMENT_CACHE_H 1 -#include -#include +#include +#include #include #include @@ -41,14 +41,14 @@ public: typedef typename boost::graph_traits::vertex_descriptor vertex_descriptor ; typedef typename boost::graph_traits::edge_descriptor edge_descriptor ; - typedef typename halfedge_graph_traits::Point Point_3 ; - typedef typename Kernel_traits::Kernel Kernel ; - typedef typename Kernel::FT FT ; + typedef typename halfedge_graph_traits::Point Point ; + typedef typename Kernel_traits::Kernel Kernel ; + typedef typename Kernel::FT FT ; typedef Cost_and_placement_cache Cache ; - typedef optional Optional_cost_type ; - typedef optional Optional_placement_type ; + typedef optional Optional_cost_type ; + typedef optional Optional_placement_type ; typedef LindstromTurk_params CostParams ; typedef LindstromTurk_params PlacementParams ; @@ -83,6 +83,6 @@ public : CGAL_END_NAMESPACE -#endif // CGAL_SURFACE_MESH_SIMPLIFICATION_POLICIES_EDGE_COLLAPSE_LINDSTROMTURK_SET_FULL_COLLAPSE_DATA_H // +#endif // CGAL_SURFACE_MESH_SIMPLIFICATION_POLICIES_EDGE_COLLAPSE_LINDSTROMTURK_SET_COST_AND_PLACEMENT_CACHE_H // // EOF // diff --git a/Surface_mesh_simplification/include/CGAL/Surface_mesh_simplification/Policies/Edge_collapse/LindstromTurk_set_cost_cache.h b/Surface_mesh_simplification/include/CGAL/Surface_mesh_simplification/Policies/Edge_collapse/LindstromTurk_set_cost_cache.h index b71eaf1cb58..5f238c8b9d7 100644 --- a/Surface_mesh_simplification/include/CGAL/Surface_mesh_simplification/Policies/Edge_collapse/LindstromTurk_set_cost_cache.h +++ b/Surface_mesh_simplification/include/CGAL/Surface_mesh_simplification/Policies/Edge_collapse/LindstromTurk_set_cost_cache.h @@ -15,11 +15,11 @@ // // Author(s) : Fernando Cacciola // -#ifndef CGAL_SURFACE_MESH_SIMPLIFICATION_POLICIES_EDGE_COLLAPSE_LINDSTROMTURK_SET_PARTIAL_COLLAPSE_DATA_H -#define CGAL_SURFACE_MESH_SIMPLIFICATION_POLICIES_EDGE_COLLAPSE_LINDSTROMTURK_SET_PARTIAL_COLLAPSE_DATA_H 1 +#ifndef CGAL_SURFACE_MESH_SIMPLIFICATION_POLICIES_EDGE_COLLAPSE_LINDSTROMTURK_SET_COST_CACHE_H +#define CGAL_SURFACE_MESH_SIMPLIFICATION_POLICIES_EDGE_COLLAPSE_LINDSTROMTURK_SET_COST_CACHE_H 1 -#include -#include +#include +#include #include #include @@ -42,12 +42,12 @@ public: typedef Cost_cache Cache ; - typedef typename halfedge_graph_traits::Point Point_3 ; - typedef typename Kernel_traits::Kernel Kernel ; - typedef typename Kernel::FT FT ; + typedef typename halfedge_graph_traits::Point Point ; + typedef typename Kernel_traits::Kernel Kernel ; + typedef typename Kernel::FT FT ; - typedef optional Optional_cost_type ; - typedef optional Optional_placement_type ; + typedef optional Optional_cost_type ; + typedef optional Optional_placement_type ; typedef LindstromTurk_params CostParams ; typedef void PlacementParams ; @@ -80,6 +80,6 @@ public : CGAL_END_NAMESPACE -#endif // CGAL_SURFACE_MESH_SIMPLIFICATION_POLICIES_EDGE_COLLAPSE_LINDSTROMTURK_SET_PARTIAL_COLLAPSE_DATA_H // +#endif // CGAL_SURFACE_MESH_SIMPLIFICATION_POLICIES_EDGE_COLLAPSE_LINDSTROMTURK_SET_COST_CACHE_H // // EOF // diff --git a/Surface_mesh_simplification/include/CGAL/Surface_mesh_simplification/Policies/Edge_collapse/Midpoint_placement.h b/Surface_mesh_simplification/include/CGAL/Surface_mesh_simplification/Policies/Edge_collapse/Midpoint_placement.h index b08da9b5112..5c423dc621b 100644 --- a/Surface_mesh_simplification/include/CGAL/Surface_mesh_simplification/Policies/Edge_collapse/Midpoint_placement.h +++ b/Surface_mesh_simplification/include/CGAL/Surface_mesh_simplification/Policies/Edge_collapse/Midpoint_placement.h @@ -18,7 +18,7 @@ #ifndef CGAL_SURFACE_MESH_SIMPLIFICATION_POLICIES_EDGE_COLLAPSE_MIDPOINT_PLACEMENT_H #define CGAL_SURFACE_MESH_SIMPLIFICATION_POLICIES_EDGE_COLLAPSE_MIDPOINT_PLACEMENT_H 1 -#include +#include CGAL_BEGIN_NAMESPACE @@ -35,11 +35,11 @@ public: typedef typename boost::graph_traits::edge_descriptor edge_descriptor ; typedef typename boost::graph_traits::vertex_descriptor vertex_descriptor ; - typedef typename halfedge_graph_traits::Point Point_3 ; - typedef typename Kernel_traits::Kernel Kernel ; - typedef typename Kernel::FT FT ; + typedef typename halfedge_graph_traits::Point Point ; + typedef typename Kernel_traits::Kernel Kernel ; + typedef typename Kernel::FT FT ; - typedef optional result_type ; + typedef optional result_type ; typedef char Params ; @@ -54,10 +54,10 @@ public: , Params const* aParams ) const { - vertex_descriptor vs,vt ; tie(vs,vt) = this->get_vertices(aEdge,aSurface); + vertex_descriptor vs,vt ; tie(vs,vt) = get_vertices(aEdge,aSurface); - Point_3 const& ps = get_point(vs,aSurface); - Point_3 const& pt = get_point(vt,aSurface); + Point const& ps = get(vertex_point,aSurface,vs); + Point const& pt = get(vertex_point,aSurface,vt); return result_type(midpoint(ps,pt)); } diff --git a/Surface_mesh_simplification/include/CGAL/Surface_mesh_simplification/Policies/Edge_collapse/No_cache.h b/Surface_mesh_simplification/include/CGAL/Surface_mesh_simplification/Policies/Edge_collapse/No_cache.h index d14422d57fd..541cc8fcd49 100644 --- a/Surface_mesh_simplification/include/CGAL/Surface_mesh_simplification/Policies/Edge_collapse/No_cache.h +++ b/Surface_mesh_simplification/include/CGAL/Surface_mesh_simplification/Policies/Edge_collapse/No_cache.h @@ -15,10 +15,8 @@ // // Author(s) : Fernando Cacciola // -#ifndef CGAL_SURFACE_MESH_SIMPLIFICATION_POLICIES_EDGE_COLLAPSE_EMPTY_COLLAPSE_DATA_H -#define CGAL_SURFACE_MESH_SIMPLIFICATION_POLICIES_EDGE_COLLAPSE_EMPTY_COLLAPSE_DATA_H - -#include +#ifndef CGAL_SURFACE_MESH_SIMPLIFICATION_POLICIES_EDGE_COLLAPSE_NO_CACHE_H +#define CGAL_SURFACE_MESH_SIMPLIFICATION_POLICIES_EDGE_COLLAPSE_NO_CACHE_H CGAL_BEGIN_NAMESPACE @@ -32,6 +30,6 @@ struct No_cache {}; CGAL_END_NAMESPACE -#endif // CGAL_SURFACE_MESH_SIMPLIFICATION_POLICIES_EDGE_COLLAPSE_EMPTY_COLLAPSE_DATA_H +#endif // CGAL_SURFACE_MESH_SIMPLIFICATION_POLICIES_EDGE_COLLAPSE_NO_CACHE_H // EOF // diff --git a/Surface_mesh_simplification/include/CGAL/Surface_mesh_simplification/Policies/Edge_collapse/Set_cost_and_placement_cache.h b/Surface_mesh_simplification/include/CGAL/Surface_mesh_simplification/Policies/Edge_collapse/Set_cost_and_placement_cache.h index 17e5c703f0f..6f58ab27a1f 100644 --- a/Surface_mesh_simplification/include/CGAL/Surface_mesh_simplification/Policies/Edge_collapse/Set_cost_and_placement_cache.h +++ b/Surface_mesh_simplification/include/CGAL/Surface_mesh_simplification/Policies/Edge_collapse/Set_cost_and_placement_cache.h @@ -15,11 +15,11 @@ // // Author(s) : Fernando Cacciola // -#ifndef CGAL_SURFACE_MESH_SIMPLIFICATION_POLICIES_EDGE_COLLAPSE_SET_FULL_COLLAPSE_DATA_H -#define CGAL_SURFACE_MESH_SIMPLIFICATION_POLICIES_EDGE_COLLAPSE_SET_FULL_COLLAPSE_DATA_H 1 +#ifndef CGAL_SURFACE_MESH_SIMPLIFICATION_POLICIES_EDGE_COLLAPSE_SET_COST_AND_PLACEMET_CACHE_H +#define CGAL_SURFACE_MESH_SIMPLIFICATION_POLICIES_EDGE_COLLAPSE_SET_COST_AND_PLACEMET_CACHE_H -#include -#include +#include +#include CGAL_BEGIN_NAMESPACE @@ -76,6 +76,6 @@ public : CGAL_END_NAMESPACE -#endif // CGAL_SURFACE_MESH_SIMPLIFICATION_POLICIES_EDGE_COLLAPSE_SET_FULL_COLLAPSE_DATA_H // +#endif // CGAL_SURFACE_MESH_SIMPLIFICATION_POLICIES_EDGE_COLLAPSE_COST_AND_PLACEMET_CACHE_H // EOF // diff --git a/Surface_mesh_simplification/include/CGAL/Surface_mesh_simplification/Policies/Edge_collapse/Set_cost_cache.h b/Surface_mesh_simplification/include/CGAL/Surface_mesh_simplification/Policies/Edge_collapse/Set_cost_cache.h index ee1df46966c..dc1600faa09 100644 --- a/Surface_mesh_simplification/include/CGAL/Surface_mesh_simplification/Policies/Edge_collapse/Set_cost_cache.h +++ b/Surface_mesh_simplification/include/CGAL/Surface_mesh_simplification/Policies/Edge_collapse/Set_cost_cache.h @@ -15,10 +15,10 @@ // // Author(s) : Fernando Cacciola // -#ifndef CGAL_SURFACE_MESH_SIMPLIFICATION_POLICIES_EDGE_COLLAPSE_SET_PARTIAL_COLLAPSE_DATA_H -#define CGAL_SURFACE_MESH_SIMPLIFICATION_POLICIES_EDGE_COLLAPSE_SET_PARTIAL_COLLAPSE_DATA_H 1 +#ifndef CGAL_SURFACE_MESH_SIMPLIFICATION_POLICIES_EDGE_COLLAPSE_SET_COST_CACHE_H +#define CGAL_SURFACE_MESH_SIMPLIFICATION_POLICIES_EDGE_COLLAPSE_SET_COST_CACHE_H -#include +#include #include CGAL_BEGIN_NAMESPACE @@ -70,6 +70,6 @@ public : CGAL_END_NAMESPACE -#endif // CGAL_SURFACE_MESH_SIMPLIFICATION_POLICIES_EDGE_COLLAPSE_SET_FULL_COLLAPSE_DATA_H // +#endif // CGAL_SURFACE_MESH_SIMPLIFICATION_POLICIES_EDGE_COLLAPSE_SET_COST_CACHE_H // EOF // diff --git a/Surface_mesh_simplification/include/CGAL/Surface_mesh_simplification/Policies/Edge_collapse/Set_no_cache.h b/Surface_mesh_simplification/include/CGAL/Surface_mesh_simplification/Policies/Edge_collapse/Set_no_cache.h index f7d4cb5a997..083eaf75a3f 100644 --- a/Surface_mesh_simplification/include/CGAL/Surface_mesh_simplification/Policies/Edge_collapse/Set_no_cache.h +++ b/Surface_mesh_simplification/include/CGAL/Surface_mesh_simplification/Policies/Edge_collapse/Set_no_cache.h @@ -15,10 +15,10 @@ // // Author(s) : Fernando Cacciola // -#ifndef CGAL_SURFACE_MESH_SIMPLIFICATION_POLICIES_EDGE_COLLAPSE_SET_EMPTY_COLLAPSE_DATA_H -#define CGAL_SURFACE_MESH_SIMPLIFICATION_POLICIES_EDGE_COLLAPSE_SET_EMPTY_COLLAPSE_DATA_H +#ifndef CGAL_SURFACE_MESH_SIMPLIFICATION_POLICIES_EDGE_COLLAPSE_SET_NO_CACHE_H +#define CGAL_SURFACE_MESH_SIMPLIFICATION_POLICIES_EDGE_COLLAPSE_SET_NO_CACHE_H -#include +#include #include CGAL_BEGIN_NAMESPACE @@ -59,6 +59,6 @@ public : CGAL_END_NAMESPACE -#endif // CGAL_SURFACE_MESH_SIMPLIFICATION_POLICIES_EDGE_COLLAPSE_SET_EMPTY_COLLAPSE_DATA_H +#endif // CGAL_SURFACE_MESH_SIMPLIFICATION_POLICIES_EDGE_COLLAPSE_SET_NO_CACHE_H // EOF // diff --git a/Surface_mesh_simplification/include/CGAL/Surface_mesh_simplification/Polyhedron.h b/Surface_mesh_simplification/include/CGAL/Surface_mesh_simplification/Polyhedron.h index 132b9582a7d..f3be216b250 100644 --- a/Surface_mesh_simplification/include/CGAL/Surface_mesh_simplification/Polyhedron.h +++ b/Surface_mesh_simplification/include/CGAL/Surface_mesh_simplification/Polyhedron.h @@ -20,10 +20,9 @@ #include -#include -#include -#include -#include +#include +#include +#include #include diff --git a/Surface_mesh_simplification/include/CGAL/Surface_mesh_simplification/Polyhedron_collapse_operator.h b/Surface_mesh_simplification/include/CGAL/Surface_mesh_simplification/Polyhedron_collapse_operator.h index 8c707fc949a..0b9d68f36ce 100644 --- a/Surface_mesh_simplification/include/CGAL/Surface_mesh_simplification/Polyhedron_collapse_operator.h +++ b/Surface_mesh_simplification/include/CGAL/Surface_mesh_simplification/Polyhedron_collapse_operator.h @@ -18,7 +18,7 @@ #ifndef CGAL_SURFACE_MESH_SIMPLIFICATION_POLYHEDRON_COLLAPSE_OPERATOR_H #define CGAL_SURFACE_MESH_SIMPLIFICATION_POLYHEDRON_COLLAPSE_OPERATOR_H 1 -#include +#include #include #include @@ -41,19 +41,18 @@ struct Collapse_triangulation_edge< Polyhedron_3 > typedef typename boost::graph_traits::edge_descriptor edge_descriptor ; typedef typename boost::graph_traits::vertex_descriptor vertex_descriptor ; - vertex_descriptor operator() ( edge_descriptor const& pq - , edge_descriptor const& pt - , edge_descriptor const& qb - , ECM& aSurface - ) const + vertex_descriptor operator() ( edge_descriptor const& pq, ECM& aSurface ) const { - edge_descriptor null ; + edge_descriptor qp = opposite_edge(pq,aSurface); - bool lTopFaceExists = pt != null ; - bool lBottomFaceExists = qb != null ; + 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 ) ) ) ; diff --git a/Surface_mesh_simplification/include/CGAL/Surface_mesh_simplification/Vertex_is_fixed_property_map_always_false.h b/Surface_mesh_simplification/include/CGAL/Surface_mesh_simplification/Vertex_is_fixed_property_map_always_false.h index de8884ccc02..bab2292f73c 100644 --- a/Surface_mesh_simplification/include/CGAL/Surface_mesh_simplification/Vertex_is_fixed_property_map_always_false.h +++ b/Surface_mesh_simplification/include/CGAL/Surface_mesh_simplification/Vertex_is_fixed_property_map_always_false.h @@ -17,8 +17,8 @@ // // Author(s): Fernando Cacciola -#ifndef CGAL_SURFACE_MESH_SIMPLIFICATION_IS_VERTEX_FIXED_MAP_ALWAYS_FALSE_H -#define CGAL_SURFACE_MESH_SIMPLIFICATION_IS_VERTEX_FIXED_MAP_ALWAYS_FALSE_H +#ifndef CGAL_SURFACE_MESH_SIMPLIFICATION_VERTEX_IS_FIXED_PROPERTY_MAP_ALWAYS_FALSE_H +#define CGAL_SURFACE_MESH_SIMPLIFICATION_VERTEX_IS_FIXED_PROPERTY_MAP_ALWAYS_FALSE_H #include #include @@ -26,7 +26,7 @@ CGAL_BEGIN_NAMESPACE template -class Vertex_is_fixed_map_always_false : public boost::put_get_helper > +class Vertex_is_fixed_property_map_always_false : public boost::put_get_helper > { private: @@ -45,4 +45,4 @@ public: CGAL_END_NAMESPACE -#endif // CGAL_SURFACE_MESH_SIMPLIFICATION_IS_VERTEX_FIXED_MAP_ALWAYS_FALSE_H +#endif // CGAL_SURFACE_MESH_SIMPLIFICATION_VERTEX_IS_FIXED_PROPERTY_MAP_ALWAYS_FALSE_H diff --git a/Surface_mesh_simplification/include/CGAL/Surface_mesh_simplification/Vertex_is_fixed_property_map_stored.h b/Surface_mesh_simplification/include/CGAL/Surface_mesh_simplification/Vertex_is_fixed_property_map_stored.h index 93177e58ec8..94cc936def5 100644 --- a/Surface_mesh_simplification/include/CGAL/Surface_mesh_simplification/Vertex_is_fixed_property_map_stored.h +++ b/Surface_mesh_simplification/include/CGAL/Surface_mesh_simplification/Vertex_is_fixed_property_map_stored.h @@ -17,8 +17,8 @@ // // Author(s): Fernando Cacciola -#ifndef CGAL_SURFACE_MESH_SIMPLIFICATION_IS_VERTEX_FIXED_MAP_STORED_H -#define CGAL_SURFACE_MESH_SIMPLIFICATION_IS_VERTEX_FIXED_MAP_STORED_H +#ifndef CGAL_SURFACE_MESH_SIMPLIFICATION_IS_VERTEX_FIXED_PROPERTY_MAP_STORED_H +#define CGAL_SURFACE_MESH_SIMPLIFICATION_IS_VERTEX_FIXED_PROPERTY_MAP_STORED_H #include #include @@ -26,7 +26,7 @@ CGAL_BEGIN_NAMESPACE template -class Vertex_is_fixed_map_stored : public boost::put_get_helper > +class Vertex_is_fixed_property_map_stored : public boost::put_get_helper > { private: @@ -45,4 +45,4 @@ public: CGAL_END_NAMESPACE -#endif // CGAL_SURFACE_MESH_SIMPLIFICATION_IS_VERTEX_FIXED_MAP_STORED_H +#endif // CGAL_SURFACE_MESH_SIMPLIFICATION_IS_VERTEX_FIXED_PROPERTY_MAP_STORED_H diff --git a/Surface_mesh_simplification/include/CGAL/Surface_mesh_simplification/edge_collapse.h b/Surface_mesh_simplification/include/CGAL/Surface_mesh_simplification/edge_collapse.h index 8436b05be29..65a70d4725d 100644 --- a/Surface_mesh_simplification/include/CGAL/Surface_mesh_simplification/edge_collapse.h +++ b/Surface_mesh_simplification/include/CGAL/Surface_mesh_simplification/edge_collapse.h @@ -18,13 +18,13 @@ #ifndef CGAL_SURFACE_MESH_SIMPLIFICATION_EDGE_COLLAPSE_H #define CGAL_SURFACE_MESH_SIMPLIFICATION_EDGE_COLLAPSE_H 1 -#include +#include +#include #include -#include -#include +#include #include -#include +#include #include #include @@ -33,6 +33,7 @@ CGAL_BEGIN_NAMESPACE namespace Surface_mesh_simplification { + // // Edge-collapse method: // @@ -67,9 +68,11 @@ namespace Surface_mesh_simplification // template - , VertexIsFixedMap const& aVertex_is_fixed_map // defaults to Vertex_is_fixed_map_always_false + , VertexPointMap const& aVertex_point_map // defaults to get(Vertex_point,aSurface) + , VertexIsFixedMap const& aVertex_is_fixed_map // defaults to Vertex_is_fixed_map_always_false() + , EdgeIndexMap const& aEdge_index_map // defaults to get(Edge_index,aSurface) + , EdgeIsBorderMap const& aEdge_is_border_map // defaults to get(Edge_is_border,aSurface) // optional strategy policies - defaults to LindstomTurk - , SetCollapseData const& aSet_collapse_data + , SetCache const& aSet_cache , GetCost const& aGet_cost , GetPlacement const& aGet_placement , CostParams const* aCostParams // Can be NULL @@ -93,30 +98,34 @@ int edge_collapse ( ECM& aSurface , Visitor* aVisitor // Can be NULL ) { - typedef EdgeCollapse Algorithm ; - Algorithm algorithm(aSurface - ,aShould_stop - ,aEdge_extra_ptr_map - ,aVertex_is_fixed_map - ,aSet_collapse_data - ,aGet_cost - ,aGet_placement - ,aCostParams - ,aPlacementParams - ,aVisitor + Algorithm algorithm( aSurface + , aShould_stop + , aVertex_point_map + , aVertex_is_fixed_map + , aEdge_index_map + , aEdge_is_border_map + , aSet_cache + , aGet_cost + , aGet_placement + , aCostParams + , aPlacementParams + , aVisitor ) ; return algorithm.run(); @@ -147,130 +156,13 @@ struct Dummy_visitor void OnNonCollapsable(Edge const&, ECM& ) {} } ; -template -int edge_collapse ( ECM& aSurface - , ShouldStop const& aShould_stop - , EdgeExtraPtrMap const& aEdge_extra_ptr_map - , VertexIsFixedMap const& aVertex_is_fixed_map - , SetCollapseData const& aSet_collapse_data - , GetCost const& aGet_cost - , GetPlacement const& aGet_placement - , CostParams const* aCostParams - , PlacementParams const* aPlacementParams - ) -{ - return edge_collapse(aSurface - ,aShould_stop - ,aEdge_extra_ptr_map - ,aVertex_is_fixed_map - ,aSet_collapse_data - ,aGet_cost - ,aGet_placement - ,aCostParams - ,aPlacementParams - ,((Dummy_visitor*)0) - ); -} template -int edge_collapse ( ECM& aSurface - , ShouldStop const& aShould_stop - , EdgeExtraPtrMap const& aEdge_extra_ptr_map - , VertexIsFixedMap const& aVertex_is_fixed_map - , SetCollapseData const& aSet_collapse_data - , GetCost const& aGet_cost - , GetPlacement const& aGet_placement - ) +int edge_collapse ( ECM& aSurface, ShouldStop const& aShould_stop, NamedParams const& aNamed_params ) { - typename ExtractCostParamsType ::type cost_params ; - typename ExtractPlacementParamsType::type placement_params ; - - return edge_collapse(aSurface - ,aShould_stop - ,aEdge_extra_ptr_map - ,aVertex_is_fixed_map - ,aSet_collapse_data - ,aGet_cost - ,aGet_placement - ,&cost_params - ,&placement_params - ,((Dummy_visitor*)0) - ); -} - -template -int edge_collapse ( ECM& aSurface - , ShouldStop const& aShould_stop - , EdgeExtraPtrMap const& aEdge_extra_ptr_map - , VertexIsFixedMap const& aVertex_is_fixed_map - ) -{ - LindstromTurk_params params ; - - return edge_collapse(aSurface - ,aShould_stop - ,aEdge_extra_ptr_map - ,aVertex_is_fixed_map - ,Set_partial_collapse_data_LindstromTurk() - ,Cached_cost() - ,LindstromTurk_placement() - ,¶ms - ,¶ms - ,((Dummy_visitor*)0) - ); -} - -template -int edge_collapse ( ECM& aSurface, ShouldStop const& aShould_stop, EdgeExtraPtrMap const& aEdge_extra_ptr_map ) -{ - LindstromTurk_params params ; - - return edge_collapse(aSurface - ,aShould_stop - ,aEdge_extra_ptr_map - ,Vertex_is_fixed_map_always_false() - ,Set_partial_collapse_data_LindstromTurk() - ,Cached_cost() - ,LindstromTurk_placement() - ,¶ms - ,¶ms - ,((Dummy_visitor*)0) - ); -} - -template -int edge_collapse ( ECM& aSurface, ShouldStop const& aShould_stop ) -{ - LindstromTurk_params params ; - - return edge_collapse(aSurface - ,aShould_stop - ,Edge_extra_pointer_map_stored() - ,Vertex_is_fixed_map_always_false() - ,Set_partial_collapse_data_LindstromTurk() - ,Cached_cost() - ,LindstromTurk_placement() - ,¶ms - ,¶ms - ,((Dummy_visitor*)0) - ); -} } // namespace Surface_mesh_simplification