diff --git a/Polyhedron/demo/Polyhedron/Polyhedron_demo_remeshing_plugin_cgal_code.cpp b/Polyhedron/demo/Polyhedron/Polyhedron_demo_remeshing_plugin_cgal_code.cpp index ad4f0509329..f7b57829ac2 100644 --- a/Polyhedron/demo/Polyhedron/Polyhedron_demo_remeshing_plugin_cgal_code.cpp +++ b/Polyhedron/demo/Polyhedron/Polyhedron_demo_remeshing_plugin_cgal_code.cpp @@ -68,13 +68,21 @@ public: if(isEmpty()) return Bbox(); else { - CGAL::Bbox_3 result = c2t3().triangulation().vertices_begin()->point().bbox(); + bool first = true; + CGAL::Bbox_3 result; for(Tr::Finite_vertices_iterator vit = ++c2t3().triangulation().finite_vertices_begin(), end = c2t3().triangulation().finite_vertices_end(); vit != end; ++vit) { - result = result + vit->point().bbox(); + if(vit->point().weight() > 0) { + if(first) { + result = vit->point().bbox(); + first = false; + } else { + result = result + vit->point().bbox(); + } + } } return Bbox(result.xmin(), result.ymin(), result.zmin(), result.xmax(), result.ymax(), result.zmax()); @@ -100,10 +108,7 @@ public: } void draw() const { - if(sphere_display_list == 0) { - sphere_display_list = glGenLists(1); - glNewList(sphere_display_list, GL_COMPILE); - } + // draw_sphere(c2t3().triangulation().finite_vertices_begin()->point()); for(Tr::Finite_vertices_iterator vit = c2t3().triangulation().finite_vertices_begin(), end = c2t3().triangulation().finite_vertices_end(); @@ -116,7 +121,6 @@ public: void draw_sphere(const Tr::Point p) const { if(p.weight() > 0) { - std::cerr << "draw_sphere(" << p << ")\n"; if(sphere_display_list == 0) { sphere_display_list = glGenLists(1); if(sphere_display_list == 0) @@ -211,7 +215,7 @@ Scene_item* cgal_code_remesh(Polyhedron* pMesh, std::cerr << "done (" << timer.time() << " ms)" << std::endl; - insert_spheres(c2t3, pMesh, sizing / 3); + insert_spheres(c2t3, pMesh, sizing); std::cerr << c2t3.number_of_facets() << std::endl; return new Scene_c2t3_item(c2t3); // remesh diff --git a/Polyhedron/demo/Polyhedron/Polyhedron_demo_remeshing_plugin_protection_cgal_code.cpp b/Polyhedron/demo/Polyhedron/Polyhedron_demo_remeshing_plugin_protection_cgal_code.cpp index fd14da1e443..fd7b836b1a3 100644 --- a/Polyhedron/demo/Polyhedron/Polyhedron_demo_remeshing_plugin_protection_cgal_code.cpp +++ b/Polyhedron/demo/Polyhedron/Polyhedron_demo_remeshing_plugin_protection_cgal_code.cpp @@ -168,28 +168,37 @@ struct Insert_spheres { const FT local_size = distance / n; std::cerr << n << std::endl; std::cerr << "Local size: " << local_size << std::endl; - CGAL_assertion(local_size < size); - - Point_3 a(begin->point(), local_size/1.5); - Point_3 b(end2->point(), local_size/1.5); + // CGAL_assertion(local_size < size); + const FT r2 = CGAL::square(local_size/1.5); + Point_3 a(begin->point(), r2); + Point_3 b(end2->point(), r2); c2t3.triangulation().insert(a); - Polyline::const_iterator it = begin; - ++it; FT small_distance_to_go = local_size; - while(it != end) { + Polyline::const_iterator it = begin; + while(it != end2) { const Point& a = *it; const Point& b = *++it; - const FT d = CGAL_NTS squared_distance(a, b); - unsigned i = 0; - for(; small_distance_to_go + i * local_size >= d; - ++i) - { - const Point p = a + - (small_distance_to_go + i * local_size) * ( b - a ) / d; - c2t3.triangulation().insert(Point_3(p, local_size / 1.5)); + std::cerr << "segment( " << a << ", " << b << ")\n"; + std::cerr << "small_distance_to_go=" << small_distance_to_go << std::endl; + const FT d = CGAL_NTS sqrt(squared_distance(a, b)); + std::cerr << "d=" << d << std::endl; + FT pos = small_distance_to_go; + if(pos < d) { + for(; pos < d; + pos += local_size) + { + const Point p = a + + pos * ( b - a ) / d; + c2t3.triangulation().insert(Point_3(p, r2)); + std::cerr << "."; + } + // pos -= local_size; + small_distance_to_go = pos - d; } - small_distance_to_go -= d; - small_distance_to_go += i * local_size; + else { + small_distance_to_go -= d; + } + std::cerr << "\n"; } c2t3.triangulation().insert(b); std::cerr << "One polyline is protected!\n";