remove the version using the edge simplification package

on the elephant subdivided 3 times with loop, it required 60s.
vs 40s. with the linear alternative
This commit is contained in:
Sébastien Loriot 2015-07-02 14:20:23 +02:00
parent 8efbac78cd
commit 2f890ac711
3 changed files with 1 additions and 302 deletions

View File

@ -46,15 +46,6 @@
// Simplification function
#include <CGAL/Surface_mesh_simplification/edge_collapse.h>
// Stop-condition policy
#include <CGAL/internal/Mean_curvature_skeleton/Edge_minimum_length_stop_predicate.h>
// Non-default cost and placement policies
#include <CGAL/Surface_mesh_simplification/Policies/Edge_collapse/Midpoint_and_length.h>
// Skip the geometric test
#include <CGAL/Surface_mesh_simplification/Policies/Edge_collapse/Geometric_test_skipper.h>
// Curve skeleton data structure
#include <CGAL/internal/Mean_curvature_skeleton/Curve_skeleton.h>
@ -69,9 +60,6 @@
// Some helper functions
#include <CGAL/internal/Mean_curvature_skeleton/Utility.h>
// For correspondence tracking
#include <CGAL/internal/Mean_curvature_skeleton/Track_correspondence_visitor.h>
// For Fixed_edge_map
#include <CGAL/internal/Mean_curvature_skeleton/Fixed_edge_map.h>
@ -94,8 +82,6 @@
#include <CGAL/Eigen_solver_traits.h> // for sparse linear system solver
#endif
namespace SMS = CGAL::Surface_mesh_simplification;
namespace CGAL {
namespace parameters {
@ -127,14 +113,6 @@ struct Skel_polyhedron_items_3: CGAL::Polyhedron_items_with_id_3 {
} //end of namespace internal
/// \ingroup PkgMeanCurvatureSkeleton3
///@brief Edge collapse algorithm tag.
enum Collapse_algorithm_tag
{
SIMPLIFICATION, /**< algorithm from simplification package */
LINEAR /**< iterative linear search */
};
/// \ingroup PkgMeanCurvatureSkeleton3
///@brief Degeneracy detection algorithm tag.
enum Degeneracy_algorithm_tag
@ -190,8 +168,6 @@ enum Degeneracy_algorithm_tag
/// \endcode
///
/// @cond CGAL_DOCUMENT_INTERNAL
/// @tparam Collapse_algorithm_tag
/// tag for selecting the edge collapse algorithm
/// @tparam Degeneracy_algorithm_tag
/// tag for selecting the degeneracy detection algorithm
/// @endcond
@ -205,7 +181,6 @@ template <class TriangleMesh,
class Traits_ = Default,
class VertexPointMap_ = Default,
class SparseLinearAlgebraTraits_d_ = Default,
Collapse_algorithm_tag Collapse_tag = LINEAR,
Degeneracy_algorithm_tag Degeneracy_tag = EULER>
#endif
class Mean_curvature_flow_skeletonization
@ -286,9 +261,6 @@ public:
HalfedgeIndexMap,
mVertexPointMap> Curve_skeleton;
// Mesh simplification types
typedef SMS::Edge_profile<mTriangleMesh> Profile;
// Repeat Triangulation types
typedef CGAL::Exact_predicates_exact_constructions_kernel Exact_kernel;
typedef CGAL::Triangulation_vertex_base_with_info_3
@ -717,12 +689,7 @@ public:
std::size_t num_collapses = 0;
while (true)
{
std::size_t cnt;
if (Collapse_tag == SIMPLIFICATION)
cnt = collapse_edges_simplification();
else
if (Collapse_tag == LINEAR)
cnt = collapse_edges_linear(fixed_edge_map);
std::size_t cnt = collapse_edges_linear(fixed_edge_map);
if (cnt == 0) break;
num_collapses += cnt;
@ -1098,45 +1065,6 @@ private:
// Edge collapse
// --------------------------------------------------------------------------
/// Collapse short edges using simplification package.
std::size_t collapse_edges_simplification()
{
internal::Fixed_edge_map<mTriangleMesh> fixed_edge_map(m_tmesh);
init_fixed_edge_map(fixed_edge_map);
int edge_id = -1;
BOOST_FOREACH(halfedge_descriptor hd, halfedges(m_tmesh))
{
put(m_hedge_id_pmap, hd, ++edge_id);
}
// This is a stop predicate (defines when the algorithm terminates).
// The simplification stops when the length of all edges is greater
// than the minimum threshold.
CGAL::internal::Minimum_length_predicate<mTriangleMesh> stop(m_min_edge_length);
// midpoint placement without geometric test
SMS::Geometric_test_skipper< SMS::Midpoint_placement<mTriangleMesh> > placement;
internal::Track_correspondence_visitor<mTriangleMesh, mVertexPointMap, Input_vertex_descriptor> vis
(&m_tmesh_point_pmap, m_max_id, m_is_medially_centered);
// Workaround, as PMP has get_cost in a sub namespace
using namespace CGAL::parameters;
std::size_t r = SMS::edge_collapse
(m_tmesh
,stop
,get_cost(SMS::Edge_length_cost<mTriangleMesh>())
.get_placement(placement)
.visitor(vis)
.edge_is_constrained_map(fixed_edge_map)
);
return r;
}
/// Track correspondent original surface points during collapse.
/// \todo remove this function and use a data member of the vertex instead for the poles
void track_correspondence(vertex_descriptor v0, vertex_descriptor v1,

View File

@ -1,92 +0,0 @@
// Copyright (c) 2013 GeometryFactory (France). All rights reserved.
//
// This file is part of CGAL (www.cgal.org).
// You can redistribute it and/or modify it under the terms of the GNU
// General Public License as published by the Free Software Foundation,
// either version 3 of the License, or (at your option) any later version.
//
// 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$
// $Id$
//
// Author(s) : Xiang Gao <gaox@ethz.ch>
//
#ifndef CGAL_SURFACE_MESH_SIMPLIFICATION_POLICIES_EDGE_COLLAPSE_MINIMUM_LENGTH_PREDICATE_H
#define CGAL_SURFACE_MESH_SIMPLIFICATION_POLICIES_EDGE_COLLAPSE_MINIMUM_LENGTH_PREDICATE_H 1
/// @cond CGAL_DOCUMENT_INTERNAL
#include <CGAL/Surface_mesh_simplification/Detail/Common.h>
#include <CGAL/Surface_mesh_simplification/Policies/Edge_collapse/Edge_profile.h>
namespace SMS = CGAL::Surface_mesh_simplification;
namespace CGAL {
namespace internal {
//*******************************************************************************************************************
// -= stopping condition predicate =-
//
// Determines whether the simplification has finished.
// The arguments are (current_cost,vertex,vertex,is_edge,initial_pair_count,current_pair_count,surface) and the result is bool
//
//*******************************************************************************************************************
//
// Stops when all the edges have length greater than the minimum required edge length
//
template<class ECM_>
class Minimum_length_predicate
{
public:
typedef ECM_ ECM ;
typedef SMS::Edge_profile<ECM> Profile ;
private :
typedef typename ECM::Traits::Point_3 Point ; //temporary it should be a point property map
typedef typename Kernel_traits<Point>::Kernel Kernel ;
public :
typedef typename boost::graph_traits<ECM>::halfedge_descriptor halfedge_descriptor ;
typedef typename boost::graph_traits<ECM>::edges_size_type size_type ;
typedef typename Kernel::FT FT ;
public :
Minimum_length_predicate( FT aThres ) : mThres(aThres * aThres) {}
bool operator()( FT const& aCurrentCost
, Profile const& //aEdgeProfile
, size_type //aInitialCount
, size_type //aCurrentCount
) const
{
return aCurrentCost > mThres ;
}
private:
FT mThres ;
};
} //namespace internal
} //namespace CGAL
/// @endcond
#endif // CGAL_SURFACE_MESH_SIMPLIFICATION_POLICIES_EDGE_COLLAPSE_MINIMUM_LENGTH_PREDICATE_H //
// EOF //

View File

@ -1,137 +0,0 @@
// Copyright (c) 2013 GeometryFactory (France). All rights reserved.
//
// This file is part of CGAL (www.cgal.org).
// You can redistribute it and/or modify it under the terms of the GNU
// General Public License as published by the Free Software Foundation,
// either version 3 of the License, or (at your option) any later version.
//
// 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$
// $Id$
//
// Author(s) : Xiang Gao <gaox@ethz.ch>
//
#ifndef CGAL_MCFSKEL_TRACK_CORRESPONDENCE_H
#define CGAL_MCFSKEL_TRACK_CORRESPONDENCE_H
/// @cond CGAL_DOCUMENT_INTERNAL
/**
* @file Track_correspondence_visitor.h
* @brief This file contains the visitor class to track the correspondent vertices
* during edge collapse.
*
* The visitor class track vertices that are collapsed onto the given vertex.
* It is needed when using simplification package to do the edge collapse.
*
*/
// Visitor base
#include <CGAL/Surface_mesh_simplification/Edge_collapse_visitor_base.h>
#include <cmath>
namespace SMS = CGAL::Surface_mesh_simplification;
namespace CGAL {
namespace internal {
template<class TriangleMesh, class TriangleMeshPointPMap, class Input_vertex_descriptor>
struct Track_correspondence_visitor : SMS::Edge_collapse_visitor_base<TriangleMesh>
{
// TriangleMesh types
typedef typename TriangleMesh::Traits Kernel;
typedef typename Kernel::Point_3 Point;
typedef typename TriangleMesh::Vertex_handle Vertex_handle;
// Mesh simplification types
typedef SMS::Edge_profile<TriangleMesh> Profile;
Track_correspondence_visitor(){}
Track_correspondence_visitor(TriangleMeshPointPMap* point_pmap,
int max_id,
bool is_medially_centered) :
hg_point_pmap(point_pmap),
max_id(max_id),
is_medially_centered(is_medially_centered)
{}
void OnCollapsing (Profile const &profile, boost::optional< Point >)
{
// the mesh is closed, v0 is always removed
std::vector<Input_vertex_descriptor>& vec_kept = profile.v1()->vertices;
std::vector<Input_vertex_descriptor>& vec_removed = profile.v0()->vertices;
vec_kept.insert(vec_kept.end(), vec_removed.begin(), vec_removed.end());
}
// Called AFTER each edge has been collapsed
void OnCollapsed(Profile const& edge, Vertex_handle /* v */)
{
Vertex_handle v0 = edge.v0();
Vertex_handle v1 = edge.v1();
//~ int id0 = v0->id();
//~ int id1 = v1->id();
//~ int vid = v->id();
//~ int from, to;
//~ if (id0 == vid)
//~ {
//~ from = id1;
//~ to = id0;
//~ }
//~ else if (id1 == vid)
//~ {
//~ from = id0;
//~ to = id1;
//~ }
//~ if ((*corr).find(to) == (*corr).end())
//~ {
//~ (*corr)[to] = std::vector<int>();
//~ }
//~ // only track vertex in the original mesh
//~ if (from < max_id)
//~ {
//~ (*corr)[to].push_back(from);
//~ }
//~ std::map<int, std::vector<int> >::iterator iter = (*corr).find(from);
//~ if (iter != (*corr).end())
//~ {
//~ for (size_t i = 0; i < (iter->second).size(); ++i)
//~ {
//~ (*corr)[to].push_back((iter->second)[i]);
//~ }
//~ (iter->second).clear();
//~ (*corr).erase(iter);
//~ }
// also track the poles
if (is_medially_centered)
{
Point pole0 = v0->pole;
Point pole1 = v1->pole;
Point p1 = boost::get(*hg_point_pmap, v1);
double dis_to_pole0 = std::sqrt(squared_distance(pole0, p1));
double dis_to_pole1 = std::sqrt(squared_distance(pole1, p1));
if (dis_to_pole0 < dis_to_pole1)
v1->pole=v0->pole;
}
}
TriangleMeshPointPMap* hg_point_pmap;
int max_id;
bool is_medially_centered;
};
} //namespace internal
} //namespace CGAL
/// @endcond
#endif //CGAL_MCFSKEL_TRACK_CORRESPONDENCE_H