@@ -578,7 +578,7 @@ insert_corners()
578578 Index p_index = domain_.index_from_corner_index (cit->first );
579579
580580#if CGAL_MESH_3_PROTECTION_DEBUG & 1
581- std::cerr << " ** treat corner #" << CGAL::IO::oformat (p_index) << std::endl;
581+ std::cerr << " \n ** treat corner #" << CGAL::IO::oformat (p_index) << std::endl;
582582#endif
583583
584584 // Get weight (the ball radius is given by the 'query_size' function)
@@ -633,6 +633,13 @@ insert_point(const Bare_point& p, const Weight& w, int dim, const Index& index,
633633{
634634 using CGAL::Mesh_3::internal::weight_modifier;
635635
636+ #if CGAL_MESH_3_PROTECTION_DEBUG & 1
637+ std::cerr << " insert_point( (" << p
638+ << " ), w=" << w
639+ << " , dim=" << dim
640+ << " , index=" << CGAL::IO::oformat (index) << " )\n " ;
641+ #endif
642+
636643 // Convert the dimension if it was set to a negative value (marker for special balls).
637644 if (dim < 0 )
638645 dim = -1 - dim;
@@ -709,6 +716,7 @@ smart_insert_point(const Bare_point& p, Weight w, int dim, const Index& index,
709716 << " ), w=" << w
710717 << " , dim=" << dim
711718 << " , index=" << CGAL::IO::oformat (index) << " )\n " ;
719+ std::cerr << " triangulation dimension is " << c3t3_.triangulation ().dimension () << std::endl;
712720#endif
713721 const Tr& tr = c3t3_.triangulation ();
714722
@@ -743,8 +751,8 @@ smart_insert_point(const Bare_point& p, Weight w, int dim, const Index& index,
743751#endif
744752
745753 // if sq_d < nearest_vh's weight
746- while ( cwsr (c3t3_. triangulation (). point ( nearest_vh), - sq_d) == CGAL::SMALLER &&
747- ! is_special ( nearest_vh) )
754+ while ( ! is_special ( nearest_vh) &&
755+ cwsr (c3t3_. triangulation (). point ( nearest_vh), - sq_d) == CGAL::SMALLER )
748756 {
749757 CGAL_assertion ( minimal_size_ > 0 || sq_d > 0 );
750758
@@ -833,7 +841,7 @@ smart_insert_point(const Bare_point& p, Weight w, int dim, const Index& index,
833841#if CGAL_MESH_3_PROTECTION_DEBUG & 1
834842 std::cerr << " smart_insert_point: weight " << w
835843 << " reduced to " << min_sq_d
836- << " \n (near existing point: " << nearest_point << " )\n " ;
844+ << " (near existing point: " << nearest_point << " )\n " ;
837845#endif
838846 w = min_sq_d;
839847 add_handle_to_unchecked = true ;
@@ -854,46 +862,45 @@ smart_insert_point(const Bare_point& p, Weight w, int dim, const Index& index,
854862 else // tr.dimension() <= 2
855863 {
856864 // change size of existing balls which include p
857- bool restart = true ;
858- while ( restart )
865+ for ( typename Tr::Finite_vertices_iterator it = tr. finite_vertices_begin (),
866+ end = tr. finite_vertices_end () ; it != end ; ++it )
859867 {
860- restart = false ;
861- for ( typename Tr::Finite_vertices_iterator it = tr.finite_vertices_begin (),
862- end = tr. finite_vertices_end () ; it != end ; ++it )
868+ const Weighted_point& it_wp = tr. point (it) ;
869+ FT sq_d = tr.min_squared_distance (p, cp (it_wp));
870+ if ( cwsr (it_wp, - sq_d) == CGAL::SMALLER )
863871 {
864- const Weighted_point& it_wp = tr.point (it);
865- FT sq_d = tr.min_squared_distance (p, cp (it_wp));
866- if ( cwsr (it_wp, - sq_d) == CGAL::SMALLER )
872+ bool special_ball = false ;
873+ if (minimal_weight_ != Weight () && sq_d < minimal_weight_)
867874 {
868- bool special_ball = false ;
869- if (minimal_weight_ != Weight () && sq_d > minimal_weight_) {
870- sq_d = minimal_weight_;
871- w = minimal_weight_;
872- special_ball = true ;
873- insert_a_special_ball = true ;
874- }
875- if ( ! is_special (it) ) {
876- *out++ = it;
877- change_ball_size (it, sq_d, special_ball);
878- restart = true ;
879- }
880- break ;
875+ sq_d = minimal_weight_;
876+ w = minimal_weight_;
877+ special_ball = true ;
878+ insert_a_special_ball = true ;
879+ }
880+
881+ if ( ! is_special (it) ) {
882+ *out++ = it;
883+ change_ball_size (it, sq_d, special_ball);
881884 }
882885 }
883886 }
884887
888+ // Change w in order to be sure that no existing point will be included in (p,w)
885889 FT min_sq_d = w;
890+ #if CGAL_MESH_3_PROTECTION_DEBUG & 1
886891 typename Tr::Point nearest_point;
887- // Change w in order to be sure that no existing point will be included
888- // in (p,w)
892+ # endif
893+
889894 for ( typename Tr::Finite_vertices_iterator it = tr.finite_vertices_begin (),
890895 end = tr.finite_vertices_end () ; it != end ; ++it )
891896 {
892897 const Weighted_point& it_wp = tr.point (it);
893898 FT sq_d = tr.min_squared_distance (p, cp (it_wp));
894899 if (sq_d < min_sq_d) {
895900 min_sq_d = sq_d;
901+ #if CGAL_MESH_3_PROTECTION_DEBUG & 1
896902 nearest_point = c3t3_.triangulation ().point (it);
903+ #endif
897904 }
898905 }
899906
@@ -902,7 +909,7 @@ smart_insert_point(const Bare_point& p, Weight w, int dim, const Index& index,
902909#if CGAL_MESH_3_PROTECTION_DEBUG & 1
903910 std::cerr << " smart_insert_point: weight " << w
904911 << " reduced to " << min_sq_d
905- << " \n (near existing point: " << nearest_point << " )\n " ;
912+ << " (near existing point: " << nearest_point << " )\n " ;
906913#endif
907914 w = min_sq_d;
908915 add_handle_to_unchecked = true ;
@@ -921,6 +928,11 @@ smart_insert_point(const Bare_point& p, Weight w, int dim, const Index& index,
921928 }
922929
923930 if ( w < minimal_weight_) {
931+ #if CGAL_MESH_3_PROTECTION_DEBUG & 1
932+ std::cerr << " smart_insert_point: weight " << w
933+ << " was smaller than minimal weight (" << minimal_weight_ << " )\n " ;
934+ #endif
935+
924936 w = minimal_weight_;
925937 insert_a_special_ball = true ;
926938 }
@@ -956,7 +968,7 @@ insert_balls_on_edges()
956968 if ( ! is_treated (curve_index) )
957969 {
958970#if CGAL_MESH_3_PROTECTION_DEBUG & 1
959- std::cerr << " ** treat curve #" << curve_index << std::endl;
971+ std::cerr << " \n ** treat curve #" << curve_index << std::endl;
960972#endif
961973 const Bare_point& p = std::get<1 >(*fit).first ;
962974 const Bare_point& q = std::get<2 >(*fit).first ;
0 commit comments