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/graph/filtered_graph.hpp>
|
||||||
#include <boost/iterator/filter_iterator.hpp>
|
#include <boost/iterator/filter_iterator.hpp>
|
||||||
|
|
||||||
#define CGAL_DO_NOT_USE_BOYKOV_KOLMOGOROV_MAXFLOW_SOFTWARE
|
#include <CGAL/boost/graph/alpha_expansion_graphcut.h>
|
||||||
#include <CGAL/internal/Surface_mesh_segmentation/Alpha_expansion_graph_cut.h>
|
|
||||||
|
|
||||||
namespace CGAL {
|
namespace CGAL {
|
||||||
|
|
||||||
|
|
@ -413,8 +412,7 @@ regularize_face_selection_borders(
|
||||||
FaceIndexMap face_index_map,
|
FaceIndexMap face_index_map,
|
||||||
VertexPointMap vertex_point_map,
|
VertexPointMap vertex_point_map,
|
||||||
double weight = 0.5,
|
double weight = 0.5,
|
||||||
bool prevent_deselection = true,
|
bool prevent_deselection = true)
|
||||||
bool global_regularization = true)
|
|
||||||
{
|
{
|
||||||
CGAL_precondition (0.0 <= weight && weight < 1.0);
|
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::edge_descriptor fg_edge_descriptor;
|
||||||
typedef typename GT::vertex_descriptor fg_vertex_descriptor;
|
typedef typename GT::vertex_descriptor fg_vertex_descriptor;
|
||||||
|
|
||||||
if (global_regularization) // Use graphcut
|
|
||||||
{
|
|
||||||
// Compute normalization factor
|
// Compute normalization factor
|
||||||
double normalization_factor = 0.;
|
double normalization_factor = 0.;
|
||||||
std::size_t nb_edges = 0;
|
std::size_t nb_edges = 0;
|
||||||
|
|
@ -454,18 +450,30 @@ regularize_face_selection_borders(
|
||||||
normalization_factor,
|
normalization_factor,
|
||||||
prevent_deselection);
|
prevent_deselection);
|
||||||
|
|
||||||
alpha_expansion_graph_cut (graph,
|
alpha_expansion_graphcut (graph,
|
||||||
graph.edge_weight_map(),
|
graph.edge_weight_map(),
|
||||||
face_index_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))
|
for (fg_face_descriptor fd : faces(fg))
|
||||||
put(is_selected, fd, graph.labels[get(face_index_map,fd)]);
|
put(is_selected, fd, graph.labels[get(face_index_map,fd)]);
|
||||||
|
|
||||||
}
|
}
|
||||||
else // No graphcut, use direct solve
|
|
||||||
|
// 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;
|
||||||
|
|
||||||
// TODO: this is a quick and dirty version, the complexity is
|
// TODO: this is a quick and dirty version, the complexity is
|
||||||
// crazy and it should be easy to do better (with priority queues,
|
// crazy and it should be easy to do better (with priority queues,
|
||||||
// for example)
|
// for example)
|
||||||
|
|
@ -591,8 +599,6 @@ regularize_face_selection_borders(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\ingroup PkgBGLSelectionFct
|
\ingroup PkgBGLSelectionFct
|
||||||
|
|
|
||||||
|
|
@ -433,11 +433,16 @@ public Q_SLOTS:
|
||||||
|
|
||||||
std::cerr << "Length of border before regularization = " << border_length() << std::endl;
|
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(),
|
CGAL::regularize_face_selection_borders (*selection_item->polyhedron(),
|
||||||
boost::make_assoc_property_map(is_selected_map),
|
boost::make_assoc_property_map(is_selected_map),
|
||||||
boost::make_assoc_property_map(face_index_map),
|
boost::make_assoc_property_map(face_index_map),
|
||||||
get(CGAL::vertex_point,*selection_item->polyhedron()),
|
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;
|
std::cerr << "Length of border after regularization = " << border_length() << std::endl;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue