From ad95dc8901ff75eb547fce3cc4aac49d0c8207c2 Mon Sep 17 00:00:00 2001 From: Fernando Cacciola Date: Wed, 22 Nov 2006 15:22:24 +0000 Subject: [PATCH] Testsuite fixes --- .gitattributes | 5 +- .../Surface_mesh_simplification.tex | 42 ++-- .../Count_ratio_stop_predicate.tex | 2 +- .../Count_stop_predicate.tex | 2 +- .../edge_collapse.tex | 36 ++-- .../Edge_profile.h => Policies/Edge_collaps} | 0 .../Policies/Edge_collapse/Edge_profile.h | 190 ++++++++++++++++++ .../Edge_collapse/Edge_profile_impl.h.h} | 0 8 files changed, 233 insertions(+), 44 deletions(-) rename Surface_mesh_simplification/include/CGAL/Surface_mesh_simplification/{Detail/Edge_profile.h => Policies/Edge_collaps} (100%) create mode 100644 Surface_mesh_simplification/include/CGAL/Surface_mesh_simplification/Policies/Edge_collapse/Edge_profile.h rename Surface_mesh_simplification/include/CGAL/Surface_mesh_simplification/{Detail/Edge_profile_impl.h => Policies/Edge_collapse/Edge_profile_impl.h.h} (100%) diff --git a/.gitattributes b/.gitattributes index 32c70eba753..245b82a87fa 100644 --- a/.gitattributes +++ b/.gitattributes @@ -2307,9 +2307,10 @@ Surface_mesh_simplification/examples/Surface_mesh_simplification/edge_collapse_e Surface_mesh_simplification/examples/Surface_mesh_simplification/edge_collapse_polyhedron.cmd -text Surface_mesh_simplification/examples/Surface_mesh_simplification/edge_collapse_polyhedron.cpp -text Surface_mesh_simplification/examples/Surface_mesh_simplification/makefile -text -Surface_mesh_simplification/include/CGAL/Surface_mesh_simplification/Detail/Edge_profile.h -text -Surface_mesh_simplification/include/CGAL/Surface_mesh_simplification/Detail/Edge_profile_impl.h -text Surface_mesh_simplification/include/CGAL/Surface_mesh_simplification/HalfedgeGraph_Polyhedron_3.h -text +Surface_mesh_simplification/include/CGAL/Surface_mesh_simplification/Policies/Edge_collaps -text +Surface_mesh_simplification/include/CGAL/Surface_mesh_simplification/Policies/Edge_collapse/Edge_profile.h -text +Surface_mesh_simplification/include/CGAL/Surface_mesh_simplification/Policies/Edge_collapse/Edge_profile_impl.h.h -text Surface_mesh_simplification/include/CGAL/Surface_mesh_simplification/Policies/Edge_collapse/LindstromTurk_params.h -text Surface_mesh_simplification/include/CGAL/Surface_mesh_simplification/Policies/Edge_collapse/Midpoint_and_length.h -text Surface_mesh_simplification/include/CGAL/Surface_mesh_simplification/collapse_triangulation_edge_Polyhedron_3.h -text diff --git a/Surface_mesh_simplification/doc_tex/Surface_mesh_simplification/Surface_mesh_simplification.tex b/Surface_mesh_simplification/doc_tex/Surface_mesh_simplification/Surface_mesh_simplification.tex index e9b4ce23c43..a637921ef0a 100644 --- a/Surface_mesh_simplification/doc_tex/Surface_mesh_simplification/Surface_mesh_simplification.tex +++ b/Surface_mesh_simplification/doc_tex/Surface_mesh_simplification/Surface_mesh_simplification.tex @@ -280,30 +280,24 @@ And you can just ommit any named parameter that has a default value. \subsubsection{Sample call} \begin{cprog} -int r = edge_collapse(surface, - stop_predicate, // policy indicating when the simplification must finish - - // - // named parameters below - // - - // property-map providing access to the point for each vertex - vertex_point_map(vpmap) - - // property-map given each edge a unique integer index - .edge_index_map(eimap) - - // property-map specifying whether an edge is a border edge or not - .edge_is_border_map(ebmap) - - // function object computing the cost of a collapse - .get_cost(cf) - - // function object computing the placement for the remaining vertex - .get_placement(pf) - - // function object tracking the simplification process - .visitor(vis) +/* +surface : the surface to simplify +stop_predicate : policy indicating when the simplification must finish +vertex_index_map(vimap) : property-map giving each vertex a unique integer index +edge_index_map(eimap) : property-map giving each edge a unique integer index +edge_is_border_map(ebmap): property-map specifying whether an edge is a border edge or not +get_cost(cf) : function object computing the cost of a collapse +get_placement(pf) : function object computing the placement for the remaining vertex +visitor(vis) : function object tracking the simplification process +*/ +int r = edge_collapse(surface + ,stop_predicate + ,vertex_index_map(vimap) + .edge_index_map(eimap) + .edge_is_border_map(ebmap) + .get_cost(cf) + .get_placement(pf) + .visitor(vis) ); \end{cprog} diff --git a/Surface_mesh_simplification/doc_tex/Surface_mesh_simplification_ref/Count_ratio_stop_predicate.tex b/Surface_mesh_simplification/doc_tex/Surface_mesh_simplification_ref/Count_ratio_stop_predicate.tex index ddab38f5b25..21298b03988 100644 --- a/Surface_mesh_simplification/doc_tex/Surface_mesh_simplification_ref/Count_ratio_stop_predicate.tex +++ b/Surface_mesh_simplification/doc_tex/Surface_mesh_simplification_ref/Count_ratio_stop_predicate.tex @@ -29,7 +29,7 @@ which must be a model of the \ccc{EdgeCollapsableMesh} concept. It returns \ccc{true} when the relation between the initial and current number of edges drops below a certain ratio. -\ccInclude{CGAL/Surface_mesh_simplification/Policies/Edge_collapse/Count_ratio_stop_pred.h} +\ccInclude{CGAL/Surface_mesh_simplification/Policies/Edge_collapse/Count_ratio_stop_predicate.h} \ccIsModel \ccc{StopPredicate} diff --git a/Surface_mesh_simplification/doc_tex/Surface_mesh_simplification_ref/Count_stop_predicate.tex b/Surface_mesh_simplification/doc_tex/Surface_mesh_simplification_ref/Count_stop_predicate.tex index c2bdadeea74..5653b79d63e 100644 --- a/Surface_mesh_simplification/doc_tex/Surface_mesh_simplification_ref/Count_stop_predicate.tex +++ b/Surface_mesh_simplification/doc_tex/Surface_mesh_simplification_ref/Count_stop_predicate.tex @@ -28,7 +28,7 @@ It has one template argument: the type of surface being simplified, which must be a model of the \ccc{EdgeCollapsableMesh} concept. It returns \ccc{true} when the number of current edges drops below a certain threshold. -\ccInclude{CGAL/Surface_mesh_simplification/Policies/Edge_collapse/Count_stop_pred.h} +\ccInclude{CGAL/Surface_mesh_simplification/Policies/Edge_collapse/Count_stop_predicate.h} \ccIsModel \ccc{StopPredicate} diff --git a/Surface_mesh_simplification/doc_tex/Surface_mesh_simplification_ref/edge_collapse.tex b/Surface_mesh_simplification/doc_tex/Surface_mesh_simplification_ref/edge_collapse.tex index 801192298b3..f40edf1537e 100644 --- a/Surface_mesh_simplification/doc_tex/Surface_mesh_simplification_ref/edge_collapse.tex +++ b/Surface_mesh_simplification/doc_tex/Surface_mesh_simplification_ref/edge_collapse.tex @@ -61,17 +61,17 @@ This is an example with 2 arguments: \ccc{vertex_index_map(the_actual_vertex_index_map).edge_index_map(the_actual_edge_index_map)} \ccc{the_actual_vertex_index_map} and \ccc{the_actual_edge_index_map} are -the actual parameters, while \ccc{vertex_index_map()} and \ccc{the_actual_edge_index_map()} +the actual parameters, while \ccc{vertex_index_map()} and \ccc{edge_index_map()} are wrapper functions used to designate each formal argument. -Each named parameter is documeted as a helper function. The argument to each helper -function is the actual parameter to \ccc{edge_collapse()}, while the name of the helper -function designates which formal argument is it. - All named parameters have default values so you only need to compose those for which the default -is inappropriate. Furthermore, since each actual parameter is wrapper in a function whose name +is inappropriate. Furthermore, since each actual parameter is wrapped in a function whose name designates the formal argument, the order of named parameters in the list is totally irrelevant. +In the following subsections, each named parameter is documeted as a helper function. The argument to each helper +function is the actual parameter to \ccc{edge_collapse()}, while the name of the helper +function designates which formal argument it is. + \subsubsection*{vertex\_index\_map(VertexIndexMap vpm)} Maps each vertex in the surface into an unsigned integer number @@ -87,9 +87,10 @@ and whose \ccc{value_type} is \textbf{Default}: the property map obtained by calling \ccc{get(vertex_index,surface)}, which requires the surface vertices to have an \ccc{id()} member properly initialized to the required value.\\ -If the verices don't have such id(), you must pass a map explicitely, such as -the property map obtained by calling \ccc{get(vertex_external_index,surface)}, -which constructs an internal map which non-intrusively associates a proper id with each vertex. +If the verices don't have such an \ccc{id()}, you must pass some property map explicitely. +An external property map can be easily obtained by calling +\ccc{get(vertex_external_index,surface)}. This constructs on the fly, and returns, +a property map which non-intrusively associates a proper id with each vertex. \subsubsection*{edge\_index\_map(EdgeIndexMap eim)} @@ -106,9 +107,10 @@ and whose \ccc{value_type} is \textbf{Default}: the property map obtained by calling \ccc{get(edge_index,surface)}, which requires the surface edges to have an \ccc{id()} member properly initialized to the require value.\\ -If the edges don't have such id(), you must pass a map explicitely, such as -the property map obtained by calling \ccc{get(edge_external_index,surface)}, -which constructs an internal map which non-intrusively associates a proper id with each edge. +If the edges don't have such an \ccc{id()}, you must pass some property map explicitely. +An external property map can be easily obtained by calling +\ccc{get(edge_external_index,surface)}. This constructs on the fly, and returns, +a property map which non-intrusively associates a proper id with each edge. \subsubsection*{edge\_is\_border\_map(EdgeIsBorderMap ebm)} @@ -150,9 +152,10 @@ The type of object pointed to by \ccc{v} must be a model of the \ccc{EdgeCollaps All these functions naming parameters are defined in \ccc{namespace CGAL}. Being non-member functions, they could clash -with equally named functions in some other namespace. If that happens -simply qualify the named parameter with \ccc{CGAL::} as shown in the -examples in the user manual. +with equally named functions in some other namespace. If that happens, +simply qualify the {\em first} +\footnoote{The second and subsequent named parameters shall not be qualified as they are member functions} +named parameter with \ccc{CGAL::}, as shown in the examples in the user manual. \ccHeading{Semantics} @@ -164,7 +167,8 @@ the {\em cost-strategy}, that is, the order in which edges are collapsed and the remaining vertex is re-positioned. \ccc{visitor} is an optional object (can be null) which can be used -to keep track of the simplification process. +to keep track of the simplification process. It has several member functions which +are called at certain points in the simplification code. \end{ccRefFunction} diff --git a/Surface_mesh_simplification/include/CGAL/Surface_mesh_simplification/Detail/Edge_profile.h b/Surface_mesh_simplification/include/CGAL/Surface_mesh_simplification/Policies/Edge_collaps similarity index 100% rename from Surface_mesh_simplification/include/CGAL/Surface_mesh_simplification/Detail/Edge_profile.h rename to Surface_mesh_simplification/include/CGAL/Surface_mesh_simplification/Policies/Edge_collaps diff --git a/Surface_mesh_simplification/include/CGAL/Surface_mesh_simplification/Policies/Edge_collapse/Edge_profile.h b/Surface_mesh_simplification/include/CGAL/Surface_mesh_simplification/Policies/Edge_collapse/Edge_profile.h new file mode 100644 index 00000000000..d70380afdbd --- /dev/null +++ b/Surface_mesh_simplification/include/CGAL/Surface_mesh_simplification/Policies/Edge_collapse/Edge_profile.h @@ -0,0 +1,190 @@ +// Copyright (c) 2005, 2006 Fernando Luis Cacciola Carballal. 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/Detail/Edge_collapse.h $ +// $Id: Edge_collapse.h 35189 2006-11-15 22:03:13Z fcacciola $ +// +// Author(s) : Fernando Cacciola +// +#ifndef CGAL_SURFACE_MESH_SIMPLIFICATION_DETAIL_EDGE_PROFILE_H +#define CGAL_SURFACE_MESH_SIMPLIFICATION_DETAIL_EDGE_PROFILE_H 1 + +#include +#include + +#include + +CGAL_BEGIN_NAMESPACE + +namespace Surface_mesh_simplification +{ + +template +class Edge_profile +{ +public: + + typedef ECM_ ECM ; + + typedef boost::graph_traits ConstGraphTraits ; + typedef boost::graph_traits GraphTraits ; + + typedef typename ConstGraphTraits::vertex_descriptor const_vertex_descriptor ; + typedef typename ConstGraphTraits::edge_descriptor const_edge_descriptor ; + + typedef typename GraphTraits::vertex_descriptor vertex_descriptor ; + typedef typename GraphTraits::edge_descriptor edge_descriptor ; + + typedef typename halfedge_graph_traits::Point Point ; + +public: + + struct Triangle + { + Triangle() {} + + Triangle( vertex_descriptor const& a_v0 + , vertex_descriptor const& a_v1 + , vertex_descriptor const& a_v2 + ) + : v0(a_v0), v1(a_v1), v2(a_v2) {} + + vertex_descriptor v0 ; + vertex_descriptor v1 ; + vertex_descriptor v2 ; + } ; + + typedef std::vector vertex_descriptor_vector ; + typedef std::vector edge_descriptor_vector ; + + typedef std::vector Triangle_vector ; + +public : + + template + Edge_profile ( edge_descriptor const& aV0V1 + , ECM& aSurface + , VertexIdxMap const& aVertex_index_map + , EdgeIdxMap const& aEdge_index_map + , EdgeIsBorderMap const& aEdge_is_border_map + ) ; + +public : + + edge_descriptor const& v0v1() const { return mV0V1; } + edge_descriptor const& v1v0() const { return mV1V0; } + + vertex_descriptor const& v0() const { return mV0; } + vertex_descriptor const& v1() const { return mV1; } + + // These are null if v0v1 is a border (thius there is no face to its left) + vertex_descriptor const& vl() const { return mVL; } + edge_descriptor const& v1vl() const { return mV1VL; } + edge_descriptor const& vlv0() const { return mVLV0; } + + // These are null if v1v0 is a border (thius there is no face to its left) + vertex_descriptor const& vr() const { return mVR; } + edge_descriptor const& v0vr() const { return mV0VR; } + edge_descriptor const& vrv1() const { return mVRV1; } + + Triangle_vector const& triangles() const { return mTriangles ; } + + // The cycle of vertices around the edge + vertex_descriptor_vector const& link() const { return mLink ; } + + edge_descriptor_vector const& border_edges() const { return mBorderEdges ; } + + ECM& surface() const { return *mSurface ; } + + +public : + + Point const& p0() const { return mP0; } + Point const& p1() const { return mP1; } + + bool is_v0v1_a_border() const { return mIsBorderV0V1 ; } + bool is_v1v0_a_border() const { return mIsBorderV1V0 ; } + + bool left_face_exists () const { return !mIsBorderV0V1 ; } + bool right_face_exists() const { return !mIsBorderV1V0 ; } + +private: + + typedef typename GraphTraits::in_edge_iterator in_edge_iterator ; + + typedef std::set IdxSet; + +private: + + template + void Extract_borders( vertex_descriptor const& v + , IdxSet& rCollected + , EdgeIdxMap const& edge_idx + , EdgeIsBorderMap const& is_border + ) ; + + template + void Extract_borders( EdgeIdxMap const& edge_idx, EdgeIsBorderMap const& is_border) ; + + template + void Extract_triangle( vertex_descriptor const& v0 + , vertex_descriptor const& v1 + , vertex_descriptor const& v2 + , edge_descriptor const& e02 + , EdgeIsBorderMap const& is_border + ) ; + + template + void Extract_triangles_and_link( VertexIdxMap const& vertex_idx, EdgeIsBorderMap const& is_border ) ; + +private: + + edge_descriptor mV0V1; + edge_descriptor mV1V0; + + bool mIsBorderV0V1 ; + bool mIsBorderV1V0 ; + + vertex_descriptor mV0; + vertex_descriptor mV1; + + Point mP0 ; + Point mP1 ; + + vertex_descriptor mVL; + vertex_descriptor mVR; + + edge_descriptor mV1VL; + edge_descriptor mVLV0; + edge_descriptor mV0VR; + edge_descriptor mVRV1; + + vertex_descriptor_vector mLink ; + edge_descriptor_vector mBorderEdges ; + Triangle_vector mTriangles ; + + ECM* mSurface ; + +} ; + +} // namespace Surface_mesh_simplification + +CGAL_END_NAMESPACE + +#include + +#endif // CGAL_SURFACE_MESH_SIMPLIFICATION_DETAIL_EDGE_PROFILE_H +// EOF // + diff --git a/Surface_mesh_simplification/include/CGAL/Surface_mesh_simplification/Detail/Edge_profile_impl.h b/Surface_mesh_simplification/include/CGAL/Surface_mesh_simplification/Policies/Edge_collapse/Edge_profile_impl.h.h similarity index 100% rename from Surface_mesh_simplification/include/CGAL/Surface_mesh_simplification/Detail/Edge_profile_impl.h rename to Surface_mesh_simplification/include/CGAL/Surface_mesh_simplification/Policies/Edge_collapse/Edge_profile_impl.h.h