Go to the documentation of this file.
14 #include <boost/graph/graph_traits.hpp>
15 #include <boost/graph/properties.hpp>
19 #include "CGAL/boost/graph/Euler_operations.h"
60 template<
typename HalfedgeGraph,
63 typename EdgeColorMap,
64 typename VertexColorMap >
71 typename boost::graph_traits< HalfedgeGraph >::halfedge_descriptor;
73 typename boost::graph_traits< HalfedgeGraph >::edge_descriptor;
75 typename boost::graph_traits< HalfedgeGraph >::face_descriptor;
124 case BATCH_CONDITION::ALL_EDGES:
125 return _metric->is_queue_empty();
140 return _metric->is_queue_empty();
154 std::ofstream file_encode;
155 file_encode.open(
"encodingspanning" +
157 auto span = spanningtree.get_spanning_tree_vertices();
158 typename std::list< vertex_descriptor >::const_iterator it = span.begin();
160 for( ; it != span.end(); it++)
163 std::list< vertex_descriptor > list_v_around =
165 file_encode <<
_gt.get_x(pt) <<
" " <<
_gt.get_y(pt) <<
" "
166 <<
_gt.get_z(pt) <<
" " << list_v_around.size() << std::endl;
181 std::cout <<
"computing symmetrical L2 (max L2/Hausdorff and RMSE)" << std::endl;
182 HalfedgeGraph current_graph =
_g;
183 PointMap current_pm =
get(boost::vertex_point, current_graph);
192 double geometric_error =
245 bool collapse_possible =
true;
254 if(collapse_possible)
262 double percentage_vertices = (1 - (double)number_current_vertices /
264 std::cout <<
"Percentage vertices removed from start " << percentage_vertices << std::endl;
267 std::cout <<
"Percentage vertices removed from last " << percentage_vertices << std::endl;
273 PointMap > spanningtree(
_g,
_pm,
true);
286 ref_settings.set_bitMask(spanningtree);
290 ref_settings.set_connectivity_topology(spanningtree,
293 ref_settings.set_reverse_bool();
298 ref_settings.set_error_prediction();
303 std::cout <<
"batch nb " <<
_batch_id <<
" done" << std::endl;
313 const Point &pos_vkept)
325 const Point& pos_vkept)
327 assert(vertex ==
source(h_collapse,
_g) ||
332 if(pos_vkept == pvertex)
336 auto iterator_range = CGAL::halfedges_around_target(vertex,
_g);
337 for(
auto h : iterator_range)
340 if(CGAL::is_border(h,
_g))
346 if(f ==
face(h_collapse,
_g))
355 if((p0 == pvertex) || (p1 == pvertex))
357 std::cerr <<
"Warning: is_vertex_position_change_without_normal_flip: "
358 "we should not have dupplicate at this stage ";
364 bool b = FEVV::Math::Vector::are_collinear< Geometry >(
365 _gt.sub_p(p0, p1),
_gt.sub_p(pvertex, p1));
368 _gt.normal(p0, p1, pvertex);
373 HalfedgeGraph >::Scalar >::quiet_NaN(),
375 HalfedgeGraph >::Scalar >::quiet_NaN(),
377 HalfedgeGraph >::Scalar >::quiet_NaN());
384 auto cross =
_gt.cross_product(p0 - p1, p0 - pos_vkept);
385 if(cross !=
Vector(0, 0, 0))
387 face_normal_after_collapse =
_gt.unit_normal(
390 const typename Geometry::Scalar sign =
421 bool mesh_changed =
false;
425 std::tuple< edge_descriptor, double, Point > current_edge =
429 auto current_halfedge =
halfedge(std::get< 0 >(current_edge),
_g);
431 if(
is_forbidden(current_halfedge, std::get< 2 >(current_edge)))
433 if(CGAL::Euler::does_satisfy_link_condition(std::get< 0 >(current_edge),
439 const Point& pvkept = std::get< 2 >(current_edge);
466 CGAL::Euler::collapse_edge(std::get< 0 >(current_edge),
_g);
480 std::cerr <<
"Warning: collapse_top_queue: an collapse did not occur due to a normal flip." << std::endl;
489 mesh_changed =
false;
520 Predictor< HalfedgeGraph, PointMap >
const std::vector< double > & get_init_coord() const
const std::vector< double > & get_RMSE_distortion() const
void sort_list_memory(const FEVV::Comparator::Spanning_tree_vertex_edge_comparator< HalfedgeGraph, PointMap > &spanningtree)
bool is_vertex_position_change_without_normal_flip(halfedge_descriptor h_collapse, vertex_descriptor vertex, const Point &pos_vkept)
typename boost::graph_traits< HalfedgeGraph >::face_descriptor face_descriptor
const std::vector< Refinement_info< HalfedgeGraph, PointMap > > & get_refinements() const
std::list< Collapse_info< HalfedgeGraph, PointMap > > _list_memory
std::list< typename boost::graph_traits< FEVV::DataStructures::AIF::AIFMesh >::vertex_descriptor > get_adjacent_vertices(typename boost::graph_traits< FEVV::DataStructures::AIF::AIFMesh >::vertex_descriptor v, const FEVV::DataStructures::AIF::AIFMesh &)
void record_v3_v4(halfedge_descriptor h)
Batch_collapser(HalfedgeGraph &g, PointMap &pm, Metric *metric, Predictor< HalfedgeGraph, PointMap > *predictor, VertexColorMap &vcm, EdgeColorMap &ecm, BATCH_CONDITION batch_stop)
Batch_collapser.
void compute_distortion_l2(FEVV::Filters::Geometric_metrics< HalfedgeGraph, PointMap > &g_metric, Header_handler &header, double diag, bool skip)
Computes the L2 distorsion between the original mesh and the current LoD.
typename FEVV::Geometry_traits< HalfedgeGraph >::Point Point
int get_quantization() const
typename FEVV::Geometry_traits< HalfedgeGraph >::Vector Vector
const std::vector< double > & get_dimension() const
void setup_prediction(FEVV::Comparator::Spanning_tree_vertex_edge_comparator< HalfedgeGraph, PointMap >)
int _nb_collapse
current batch number
boost::graph_traits< FEVV::DataStructures::AIF::AIFMesh >::halfedge_descriptor opposite(typename boost::graph_traits< FEVV::DataStructures::AIF::AIFMesh >::halfedge_descriptor h, const FEVV::DataStructures::AIF::AIFMesh &sm)
Returns the halfedge with source and target swapped.
Refer to Geometry_traits_documentation_dummy for further documentation on provided types and algorith...
void record_vkept(vertex_descriptor vkept)
const Geometry _gt
Edges that cannot be collapsed in the current batch.
Geometric_metrics is a class dedicated to the geometric distance computation between an original full...
boost::graph_traits< FEVV::DataStructures::AIF::AIFMesh >::vertex_descriptor source(typename boost::graph_traits< FEVV::DataStructures::AIF::AIFMesh >::edge_descriptor e, const FEVV::DataStructures::AIF::AIFMesh &)
Returns the source vertex of e.
bool collapse_top_queue()
collapse_top_queue collapses the edge with the lowest cost, and records the necessary information in ...
boost::graph_traits< FEVV::DataStructures::AIF::AIFMesh >::edge_descriptor edge(typename boost::graph_traits< FEVV::DataStructures::AIF::AIFMesh >::halfedge_descriptor h, const FEVV::DataStructures::AIF::AIFMesh &sm)
Returns the edge corresponding to h and opposite(h).
Abstract class used to predict position.
void save_spanning_tree(const FEVV::Comparator::Spanning_tree_vertex_edge_comparator< HalfedgeGraph, PointMap > &spanningtree)
void record_vt_vs_pos(const Point &v1, const Point &v2)
FEVV::PCLPointCloudPointMap::value_type get(const FEVV::PCLPointCloudPointMap &pm, FEVV::PCLPointCloudPointMap::key_type key)
Specialization of get(point_map, key) for PCLPointCloud.
void record_pos_vkept(vertex_descriptor vkept)
const std::vector< double > & get_hausdorff_distortion() const
Interfaces for plugins These interfaces will be used for different plugins.
std::vector< std::vector< bool > > _list_edge_bitmask
std::vector< Refinement_info< HalfedgeGraph, PointMap > > _refinements
void set_num_collapse(int nb)
bool stop()
stop() : Depending on the chosen Batch condition, will return whether we have to continue collapsing ...
typename boost::graph_traits< HalfedgeGraph >::edge_descriptor edge_descriptor
double compute_symmetric_L2(const HalfedgeGraph &LoD, bool compute_RMSE_instead_of_max)
Proposed RMSE and Hausdorff distances implementation.
boost::graph_traits< FEVV::DataStructures::AIF::AIFMesh >::halfedge_descriptor halfedge(typename boost::graph_traits< FEVV::DataStructures::AIF::AIFMesh >::vertex_descriptor v, const FEVV::DataStructures::AIF::AIFMesh &sm)
Returns a halfedge with target v.
boost::graph_traits< FEVV::DataStructures::AIF::AIFMesh >::vertex_descriptor target(typename boost::graph_traits< FEVV::DataStructures::AIF::AIFMesh >::edge_descriptor e, const FEVV::DataStructures::AIF::AIFMesh &)
Returns the target vertex of e.
typename FEVV::Geometry_traits< HalfedgeGraph > Geometry
typename boost::graph_traits< HalfedgeGraph >::vertex_descriptor vertex_descriptor
int64_t _number_vertices_last
Functor object to sort sequential container of Collapse_info objects. It is based on the Spanning_tre...
VertexColorMap & _vcm
Measuring collapse cost of each edge.
std::vector< double > _RMSE_distortion_per_batch
boost::graph_traits< FEVV::DataStructures::AIF::AIFMesh >::halfedge_descriptor prev(typename boost::graph_traits< FEVV::DataStructures::AIF::AIFMesh >::halfedge_descriptor h, const FEVV::DataStructures::AIF::AIFMesh &sm)
Returns the previous halfedge around its face.
bool is_forbidden(halfedge_descriptor h, Point)
FEVV::Filters::Predictor< HalfedgeGraph, PointMap > * _predictor
boost::graph_traits< MeshT >::vertex_descriptor vertex_descriptor
std::set< halfedge_descriptor > _forbidden_edges
void put(FEVV::PCLPointCloudPointMap &pm, FEVV::PCLPointCloudPointMap::key_type key, const FEVV::PCLPointCloudPointMap::value_type &value)
Specialization of put(point_map, key, value) for PCLPointCloud.
int64_t _number_vertices_original
std::vector< double > _hausdorff_distortion_per_batch
Batch_collapser: Takes an halfedge graph and collapses its edges. A Batch_collapser object can simpli...
boost::graph_traits< FEVV::DataStructures::AIF::AIFMesh >::face_descriptor face(typename boost::graph_traits< FEVV::DataStructures::AIF::AIFMesh >::halfedge_descriptor h, const FEVV::DataStructures::AIF::AIFMesh &)
Returns the face incident to halfedge h.
typename boost::graph_traits< HalfedgeGraph >::halfedge_descriptor halfedge_descriptor
PointMap & _pm
the mesh being simplified
BATCH_CONDITION _batch_stop
void forbid_edges(HalfedgeGraph &g, vertex_descriptor v, std::set< halfedge_descriptor > &forbidden_edges)
boost::graph_traits< MeshT >::vertices_size_type size_of_vertices(const MeshT &g)
Real current number of vertices of the mesh. Generic version.
bool are_halfedge_vertex_positions_change_without_normal_flip(halfedge_descriptor h_collapse, const Point &pos_vkept)
Returns whether the edge collapse causes a normal flip.