mirror of https://github.com/CGAL/cgal
Separate regularization functions
This commit is contained in:
parent
1c5bc70b7b
commit
dc54b326f4
|
|
@ -20,8 +20,7 @@
|
|||
#include <boost/graph/filtered_graph.hpp>
|
||||
#include <boost/iterator/filter_iterator.hpp>
|
||||
|
||||
#define CGAL_DO_NOT_USE_BOYKOV_KOLMOGOROV_MAXFLOW_SOFTWARE
|
||||
#include <CGAL/internal/Surface_mesh_segmentation/Alpha_expansion_graph_cut.h>
|
||||
#include <CGAL/boost/graph/alpha_expansion_graphcut.h>
|
||||
|
||||
namespace CGAL {
|
||||
|
||||
|
|
@ -413,8 +412,7 @@ regularize_face_selection_borders(
|
|||
FaceIndexMap face_index_map,
|
||||
VertexPointMap vertex_point_map,
|
||||
double weight = 0.5,
|
||||
bool prevent_deselection = true,
|
||||
bool global_regularization = true)
|
||||
bool prevent_deselection = true)
|
||||
{
|
||||
CGAL_precondition (0.0 <= weight && weight < 1.0);
|
||||
|
||||
|
|
@ -424,8 +422,6 @@ regularize_face_selection_borders(
|
|||
typedef typename GT::edge_descriptor fg_edge_descriptor;
|
||||
typedef typename GT::vertex_descriptor fg_vertex_descriptor;
|
||||
|
||||
if (global_regularization) // Use graphcut
|
||||
{
|
||||
// Compute normalization factor
|
||||
double normalization_factor = 0.;
|
||||
std::size_t nb_edges = 0;
|
||||
|
|
@ -454,18 +450,30 @@ regularize_face_selection_borders(
|
|||
normalization_factor,
|
||||
prevent_deselection);
|
||||
|
||||
alpha_expansion_graph_cut (graph,
|
||||
alpha_expansion_graphcut (graph,
|
||||
graph.edge_weight_map(),
|
||||
face_index_map,
|
||||
graph.vertex_label_map(),
|
||||
graph.vertex_label_probability_map());
|
||||
graph.vertex_label_probability_map(),
|
||||
graph.vertex_label_map());
|
||||
|
||||
for (fg_face_descriptor fd : faces(fg))
|
||||
put(is_selected, fd, graph.labels[get(face_index_map,fd)]);
|
||||
}
|
||||
|
||||
// TODO: document me
|
||||
template <class FaceGraph, class IsSelectedMap, class VertexPointMap>
|
||||
void
|
||||
regularize_face_selection_borders(
|
||||
FaceGraph& fg,
|
||||
IsSelectedMap is_selected,
|
||||
VertexPointMap vertex_point_map)
|
||||
{
|
||||
typedef boost::graph_traits<FaceGraph> GT;
|
||||
typedef typename GT::face_descriptor fg_face_descriptor;
|
||||
typedef typename GT::halfedge_descriptor fg_halfedge_descriptor;
|
||||
typedef typename GT::edge_descriptor fg_edge_descriptor;
|
||||
typedef typename GT::vertex_descriptor fg_vertex_descriptor;
|
||||
|
||||
}
|
||||
else // No graphcut, use direct solve
|
||||
{
|
||||
// TODO: this is a quick and dirty version, the complexity is
|
||||
// crazy and it should be easy to do better (with priority queues,
|
||||
// for example)
|
||||
|
|
@ -589,8 +597,6 @@ regularize_face_selection_borders(
|
|||
for (fg_face_descriptor fd : faces_around_target (hd, fg))
|
||||
put(is_selected, fd, true);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -433,11 +433,16 @@ public Q_SLOTS:
|
|||
|
||||
std::cerr << "Length of border before regularization = " << border_length() << std::endl;
|
||||
|
||||
if (weight == 1.0)
|
||||
CGAL::regularize_face_selection_borders (*selection_item->polyhedron(),
|
||||
boost::make_assoc_property_map(is_selected_map),
|
||||
get(CGAL::vertex_point,*selection_item->polyhedron()));
|
||||
else
|
||||
CGAL::regularize_face_selection_borders (*selection_item->polyhedron(),
|
||||
boost::make_assoc_property_map(is_selected_map),
|
||||
boost::make_assoc_property_map(face_index_map),
|
||||
get(CGAL::vertex_point,*selection_item->polyhedron()),
|
||||
weight, true, (weight != 1.0));
|
||||
weight, true);
|
||||
|
||||
std::cerr << "Length of border after regularization = " << border_length() << std::endl;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue