14 #include <boost/graph/graph_traits.hpp>
15 #include <boost/graph/properties.hpp>
19 #include "CGAL/boost/graph/Euler_operations.h"
74 template<
typename HalfedgeGraph,
76 typename VertexColorMap >
85 typename boost::graph_traits< HalfedgeGraph >::halfedge_descriptor;
87 typename boost::graph_traits< HalfedgeGraph >::face_descriptor;
131 std::list< std::pair< Point, Point > > &new_points)
136 for(
typename std::list< halfedge_descriptor >::const_iterator h_it =
138 h_it != h_extent.end();
148 if(
_vkept->get_type() == VKEPT_POSITION::HALFEDGE)
156 std::pair< Point, Point > resulting_points =
157 _predictor->place_points(*pos_it, vkept, h1, h2);
159 new_points.push_back(std::move(resulting_points));
169 std::ofstream file_encode;
170 file_encode.open(
"decodingspanning" + std::to_string(
_batch_id) +
".txt");
171 auto span = spanningtree.get_spanning_tree_vertices();
172 typename std::list< vertex_descriptor >::const_iterator it = span.begin();
174 for( ; it != span.end(); it++)
177 std::list< vertex_descriptor > list_v_around =
179 file_encode <<
_gt.get_x(pt) <<
" " <<
_gt.get_y(pt) <<
" "
180 <<
_gt.get_z(pt) <<
" " << list_v_around.size() << std::endl;
218 if (
_vkept->get_type() == FEVV::Filters::VKEPT_POSITION::HALFEDGE)
232 Spanning_tree_vertex_edge_comparator< HalfedgeGraph, PointMap, Geometry >
233 spanningtree(
_g,
_pm,
true);
239 std::list< halfedge_descriptor > h_extent;
246 std::cout <<
"batch " << std::to_string(
_batch_id) <<
" done" << std::endl;
262 Predictor< HalfedgeGraph, PointMap >
283 std::list< std::pair< Point, Point > > new_points;
291 auto new_points_it = new_points.begin();
292 for(
typename std::list< halfedge_descriptor >::const_iterator h_it =
294 h_it != h_extent.end();
304 bool reverse =
false;
305 if(
_vkept->get_type() == VKEPT_POSITION::HALFEDGE)
314 std::pair< Point, Point > resulting_points = *new_points_it;
323 if(current_case == TOPOLOGY_CASE::CASE211 ||
324 current_case == TOPOLOGY_CASE::CASE212 ||
325 current_case == TOPOLOGY_CASE::CASE221 ||
326 current_case == TOPOLOGY_CASE::CASE222)
328 hnew =
cases_2(h1, h2, current_case);
333 hnew =
cases_1(h1, current_case);
354 Spanning_tree_vertex_edge_comparator< HalfedgeGraph, PointMap, Geometry >
356 std::list< halfedge_descriptor > &h_extent)
359 const std::list< vertex_descriptor >& spanning_vertices =
360 spanningtree.get_spanning_tree_vertices();
365 std::list< bool >::iterator bit_it =
_bitmask.begin();
366 std::list< bool >::iterator bit_it_end =
_bitmask.end();
370 std::list< bool >::iterator edge_bit_it =
_edge_bitmask.begin();
371 std::list< bool >::iterator edge_bit_it_end =
_edge_bitmask.end();
373 typename std::list< vertex_descriptor >::const_iterator spanning_it =
374 spanning_vertices.begin();
375 std::list< vertex_descriptor > vsplit_neighbours_list;
378 bool last_was_1 =
false;
379 std::list< vertex_descriptor > remaining_adjacent_vertices_of_last_v, tmp;
380 std::map<vertex_descriptor, bool> processed_vertices;
383 for(; bit_it != bit_it_end; spanning_it++)
386 processed_vertices[*spanning_it] =
true;
387 bool is_adjacent_to_former_1 =
false;
390 auto it_to_remove = std::find(remaining_adjacent_vertices_of_last_v.begin(),
391 remaining_adjacent_vertices_of_last_v.end(), *spanning_it) ;
392 is_adjacent_to_former_1 = (it_to_remove != remaining_adjacent_vertices_of_last_v.end());
393 if(is_adjacent_to_former_1)
394 remaining_adjacent_vertices_of_last_v.erase(it_to_remove);
395 if(remaining_adjacent_vertices_of_last_v.empty())
400 if((*bit_it ==
true) && !is_adjacent_to_former_1)
405 remaining_adjacent_vertices_of_last_v.insert(remaining_adjacent_vertices_of_last_v.end(), tmp.begin(), tmp.end());
408 std::vector< bool > current_edge_bit;
409 auto e_min_tree = spanningtree.get_spanning_tree_min_incident_edge(*spanning_it);
411 if(
target(h_min_tree,
_g) != *spanning_it)
419 current_edge_bit.push_back(
false);
422 current_edge_bit.push_back(*edge_bit_it);
423 if(*edge_bit_it ==
true)
426 h_extent.push_back(current_edge);
433 }
while(current_edge != h_min_tree &&
434 edge_bit_it != edge_bit_it_end);
438 h_extent.push_back(h_extent.back());
441 if(nb_edges != 1 && nb_edges != 2)
443 std::cerr <<
"fill_h_extent_list_no_sort: error. No halfedge to extent." << std::endl;
446 vsplit_neighbours_list.clear();
450 else if(!is_adjacent_to_former_1)
462 if(!(CGAL::is_border(h,
_g)) &&
467 return TOPOLOGY_CASE::CASE11;
471 if(!CGAL::is_border(h,
_g) &&
472 CGAL::is_border(opp_h,
_g))
474 return TOPOLOGY_CASE::CASE12;
478 return TOPOLOGY_CASE::CASE13;
484 if((
face(h1,
_g) != boost::graph_traits< HalfedgeGraph >::null_face()) &&
487 HalfedgeGraph >::null_face()))
493 if(
face(h1,
_g) == boost::graph_traits< HalfedgeGraph >::null_face())
496 boost::graph_traits< HalfedgeGraph >::null_face())
498 return TOPOLOGY_CASE::CASE211;
502 return TOPOLOGY_CASE::CASE221;
508 boost::graph_traits< HalfedgeGraph >::null_face())
510 return TOPOLOGY_CASE::CASE212;
514 return TOPOLOGY_CASE::CASE222;
526 if((
face(h1,
_g) != boost::graph_traits< HalfedgeGraph >::null_face()) &&
527 (
face(h2,
_g) != boost::graph_traits< HalfedgeGraph >::null_face()))
530 CGAL::Euler::split_vertex< HalfedgeGraph >(h1, h2,
_g);
531 CGAL::Euler::split_face(
549 if(CGAL::is_border(hb,
_g))
562 }
while((hb != h) && !ok);
564 return std::make_pair(hb, ok);
567 std::pair< halfedge_descriptor, halfedge_descriptor >
571 if(cas == TOPOLOGY_CASE::CASE11)
577 if(paire.second ==
false)
585 typename boost::property_traits< VertexColorMap >::value_type(
589 std::cerr <<
"find_good_halfedges_for_split: error, there is no good border found " << std::endl;
596 else if(cas == TOPOLOGY_CASE::CASE12)
602 if(paire.second ==
false)
610 typename boost::property_traits< VertexColorMap >::value_type(
614 std::cerr <<
"find_good_halfedges_for_split: error, there is no good border found " << std::endl;
621 else if(cas == TOPOLOGY_CASE::CASE13)
627 if(paire.second ==
false)
635 typename boost::property_traits< VertexColorMap >::value_type(
642 typename boost::property_traits< VertexColorMap >::value_type(
646 std::cerr <<
"find_good_halfedges_for_split: error, there is no good border found " << std::endl;
655 std::cerr <<
"find_good_halfedges_for_split: error , wrong case " << std::endl;
659 return std::make_pair(h1, h2);
667 if(f == boost::graph_traits< HalfedgeGraph >::null_face())
669 std::cerr <<
"get_face_degree: null face " << std::endl;
674 boost::iterator_range<
675 CGAL::Vertex_around_face_iterator< HalfedgeGraph > >
676 iterator_range_v = CGAL::vertices_around_face(h,
_g);
677 int nb_face_vertices = 0;
680 #pragma GCC diagnostic push
681 #pragma GCC diagnostic ignored "-Wunused-but-set-variable"
683 for(
auto v : iterator_range_v)
685 nb_face_vertices += 1;
688 #pragma GCC diagnostic pop
691 if(nb_face_vertices == 1 || nb_face_vertices == 2)
693 std::cerr <<
"get_face_degree: error, there are not enough vertices to make a face "
699 return nb_face_vertices;
705 std::pair< halfedge_descriptor, halfedge_descriptor > pair_of_h;
708 case FEVV::Filters::TOPOLOGY_CASE::CASE11:
710 h1 = pair_of_h.first;
711 h2 = pair_of_h.second;
713 hnew = CGAL::Euler::split_vertex(h1, h2,
_g);
718 case FEVV::Filters::TOPOLOGY_CASE::CASE12:
720 h1 = pair_of_h.first;
721 h2 = pair_of_h.second;
722 hnew = CGAL::Euler::split_vertex(h1, h2,
_g);
729 case FEVV::Filters::TOPOLOGY_CASE::CASE13:
732 h1 = pair_of_h.first;
733 h2 = pair_of_h.second;
737 hnew = CGAL::Euler::split_vertex(h1, h2,
_g);
750 typename boost::property_traits< VertexColorMap >::value_type(
771 std::vector< vertex_descriptor > face_vertices;
772 face_vertices.reserve(3);
777 case FEVV::Filters::TOPOLOGY_CASE::CASE211:
778 first_to_split = hnew;
785 case FEVV::Filters::TOPOLOGY_CASE::CASE221:
786 first_to_split = hnew;
795 case FEVV::Filters::TOPOLOGY_CASE::CASE212:
803 case FEVV::Filters::TOPOLOGY_CASE::CASE222:
814 CGAL::Euler::split_face(first_to_split, second_to_split,
_g);
816 face_vertices.push_back(first);
817 face_vertices.push_back(second);
818 face_vertices.push_back(third);