mirror of https://github.com/CGAL/cgal
Merge pull request #7552 from MaelRL/Mesh_3-PMD_init_bug_fixes-GF
Fix initialisation issues in Mesh_3
This commit is contained in:
commit
a746283359
|
|
@ -584,7 +584,7 @@ insert_corners()
|
||||||
Index p_index = domain_.index_from_corner_index(cit->first);
|
Index p_index = domain_.index_from_corner_index(cit->first);
|
||||||
|
|
||||||
#if CGAL_MESH_3_PROTECTION_DEBUG & 1
|
#if CGAL_MESH_3_PROTECTION_DEBUG & 1
|
||||||
std::cerr << "** treat corner #" << CGAL::IO::oformat(p_index) << std::endl;
|
std::cerr << "\n** treat corner #" << CGAL::IO::oformat(p_index) << std::endl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Get weight (the ball radius is given by the 'query_size' function)
|
// Get weight (the ball radius is given by the 'query_size' function)
|
||||||
|
|
@ -639,6 +639,13 @@ insert_point(const Bare_point& p, const Weight& w, int dim, const Index& index,
|
||||||
{
|
{
|
||||||
using CGAL::Mesh_3::internal::weight_modifier;
|
using CGAL::Mesh_3::internal::weight_modifier;
|
||||||
|
|
||||||
|
#if CGAL_MESH_3_PROTECTION_DEBUG & 1
|
||||||
|
std::cerr << "insert_point( (" << p
|
||||||
|
<< "), w=" << w
|
||||||
|
<< ", dim=" << dim
|
||||||
|
<< ", index=" << CGAL::IO::oformat(index) << ")\n";
|
||||||
|
#endif
|
||||||
|
|
||||||
// Convert the dimension if it was set to a negative value (marker for special balls).
|
// Convert the dimension if it was set to a negative value (marker for special balls).
|
||||||
if(dim < 0)
|
if(dim < 0)
|
||||||
dim = -1 - dim;
|
dim = -1 - dim;
|
||||||
|
|
@ -715,6 +722,7 @@ smart_insert_point(const Bare_point& p, Weight w, int dim, const Index& index,
|
||||||
<< "), w=" << w
|
<< "), w=" << w
|
||||||
<< ", dim=" << dim
|
<< ", dim=" << dim
|
||||||
<< ", index=" << CGAL::IO::oformat(index) << ")\n";
|
<< ", index=" << CGAL::IO::oformat(index) << ")\n";
|
||||||
|
std::cerr << "triangulation dimension is " << c3t3_.triangulation().dimension() << std::endl;
|
||||||
#endif
|
#endif
|
||||||
const Tr& tr = c3t3_.triangulation();
|
const Tr& tr = c3t3_.triangulation();
|
||||||
|
|
||||||
|
|
@ -749,8 +757,8 @@ smart_insert_point(const Bare_point& p, Weight w, int dim, const Index& index,
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// if sq_d < nearest_vh's weight
|
// if sq_d < nearest_vh's weight
|
||||||
while ( cwsr(c3t3_.triangulation().point(nearest_vh), - sq_d) == CGAL::SMALLER &&
|
while ( ! is_special(nearest_vh) &&
|
||||||
! is_special(nearest_vh) )
|
cwsr(c3t3_.triangulation().point(nearest_vh), - sq_d) == CGAL::SMALLER )
|
||||||
{
|
{
|
||||||
CGAL_assertion( minimal_size_ > 0 || sq_d > 0 );
|
CGAL_assertion( minimal_size_ > 0 || sq_d > 0 );
|
||||||
|
|
||||||
|
|
@ -839,7 +847,7 @@ smart_insert_point(const Bare_point& p, Weight w, int dim, const Index& index,
|
||||||
#if CGAL_MESH_3_PROTECTION_DEBUG & 1
|
#if CGAL_MESH_3_PROTECTION_DEBUG & 1
|
||||||
std::cerr << "smart_insert_point: weight " << w
|
std::cerr << "smart_insert_point: weight " << w
|
||||||
<< " reduced to " << min_sq_d
|
<< " reduced to " << min_sq_d
|
||||||
<< "\n (near existing point: " << nearest_point << " )\n";
|
<< " (near existing point: " << nearest_point << " )\n";
|
||||||
#endif
|
#endif
|
||||||
w = min_sq_d;
|
w = min_sq_d;
|
||||||
add_handle_to_unchecked = true;
|
add_handle_to_unchecked = true;
|
||||||
|
|
@ -860,38 +868,35 @@ smart_insert_point(const Bare_point& p, Weight w, int dim, const Index& index,
|
||||||
else // tr.dimension() <= 2
|
else // tr.dimension() <= 2
|
||||||
{
|
{
|
||||||
// change size of existing balls which include p
|
// change size of existing balls which include p
|
||||||
bool restart = true;
|
for ( typename Tr::Finite_vertices_iterator it = tr.finite_vertices_begin(),
|
||||||
while ( restart )
|
end = tr.finite_vertices_end() ; it != end ; ++it )
|
||||||
{
|
{
|
||||||
restart = false;
|
const Weighted_point& it_wp = tr.point(it);
|
||||||
for ( typename Tr::Finite_vertices_iterator it = tr.finite_vertices_begin(),
|
FT sq_d = tr.min_squared_distance(p, cp(it_wp));
|
||||||
end = tr.finite_vertices_end() ; it != end ; ++it )
|
if ( cwsr(it_wp, - sq_d) == CGAL::SMALLER )
|
||||||
{
|
{
|
||||||
const Weighted_point& it_wp = tr.point(it);
|
bool special_ball = false;
|
||||||
FT sq_d = tr.min_squared_distance(p, cp(it_wp));
|
if(minimal_weight_ != Weight() && sq_d < minimal_weight_)
|
||||||
if ( cwsr(it_wp, - sq_d) == CGAL::SMALLER )
|
|
||||||
{
|
{
|
||||||
bool special_ball = false;
|
sq_d = minimal_weight_;
|
||||||
if(minimal_weight_ != Weight() && sq_d > minimal_weight_) {
|
w = minimal_weight_;
|
||||||
sq_d = minimal_weight_;
|
special_ball = true;
|
||||||
w = minimal_weight_;
|
insert_a_special_ball = true;
|
||||||
special_ball = true;
|
}
|
||||||
insert_a_special_ball = true;
|
|
||||||
}
|
if( ! is_special(it) ) {
|
||||||
if( ! is_special(it) ) {
|
*out++ = it;
|
||||||
*out++ = it;
|
change_ball_size(it, sq_d, special_ball);
|
||||||
change_ball_size(it, sq_d, special_ball);
|
|
||||||
restart = true;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Change w in order to be sure that no existing point will be included in (p,w)
|
||||||
FT min_sq_d = w;
|
FT min_sq_d = w;
|
||||||
|
#if CGAL_MESH_3_PROTECTION_DEBUG & 1
|
||||||
typename Tr::Point nearest_point;
|
typename Tr::Point nearest_point;
|
||||||
// Change w in order to be sure that no existing point will be included
|
#endif
|
||||||
// in (p,w)
|
|
||||||
for ( typename Tr::Finite_vertices_iterator it = tr.finite_vertices_begin(),
|
for ( typename Tr::Finite_vertices_iterator it = tr.finite_vertices_begin(),
|
||||||
end = tr.finite_vertices_end() ; it != end ; ++it )
|
end = tr.finite_vertices_end() ; it != end ; ++it )
|
||||||
{
|
{
|
||||||
|
|
@ -899,7 +904,9 @@ smart_insert_point(const Bare_point& p, Weight w, int dim, const Index& index,
|
||||||
FT sq_d = tr.min_squared_distance(p, cp(it_wp));
|
FT sq_d = tr.min_squared_distance(p, cp(it_wp));
|
||||||
if(sq_d < min_sq_d) {
|
if(sq_d < min_sq_d) {
|
||||||
min_sq_d = sq_d;
|
min_sq_d = sq_d;
|
||||||
|
#if CGAL_MESH_3_PROTECTION_DEBUG & 1
|
||||||
nearest_point = c3t3_.triangulation().point(it);
|
nearest_point = c3t3_.triangulation().point(it);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -908,7 +915,7 @@ smart_insert_point(const Bare_point& p, Weight w, int dim, const Index& index,
|
||||||
#if CGAL_MESH_3_PROTECTION_DEBUG & 1
|
#if CGAL_MESH_3_PROTECTION_DEBUG & 1
|
||||||
std::cerr << "smart_insert_point: weight " << w
|
std::cerr << "smart_insert_point: weight " << w
|
||||||
<< " reduced to " << min_sq_d
|
<< " reduced to " << min_sq_d
|
||||||
<< "\n (near existing point: " << nearest_point << " )\n";
|
<< " (near existing point: " << nearest_point << " )\n";
|
||||||
#endif
|
#endif
|
||||||
w = min_sq_d;
|
w = min_sq_d;
|
||||||
add_handle_to_unchecked = true;
|
add_handle_to_unchecked = true;
|
||||||
|
|
@ -927,6 +934,11 @@ smart_insert_point(const Bare_point& p, Weight w, int dim, const Index& index,
|
||||||
}
|
}
|
||||||
|
|
||||||
if( w < minimal_weight_) {
|
if( w < minimal_weight_) {
|
||||||
|
#if CGAL_MESH_3_PROTECTION_DEBUG & 1
|
||||||
|
std::cerr << "smart_insert_point: weight " << w
|
||||||
|
<< " was smaller than minimal weight (" << minimal_weight_ << ")\n";
|
||||||
|
#endif
|
||||||
|
|
||||||
w = minimal_weight_;
|
w = minimal_weight_;
|
||||||
insert_a_special_ball = true;
|
insert_a_special_ball = true;
|
||||||
}
|
}
|
||||||
|
|
@ -962,7 +974,7 @@ insert_balls_on_edges()
|
||||||
if ( ! is_treated(curve_index) )
|
if ( ! is_treated(curve_index) )
|
||||||
{
|
{
|
||||||
#if CGAL_MESH_3_PROTECTION_DEBUG & 1
|
#if CGAL_MESH_3_PROTECTION_DEBUG & 1
|
||||||
std::cerr << "** treat curve #" << curve_index << std::endl;
|
std::cerr << "\n** treat curve #" << curve_index << std::endl;
|
||||||
#endif
|
#endif
|
||||||
const Bare_point& p = std::get<1>(*fit).first;
|
const Bare_point& p = std::get<1>(*fit).first;
|
||||||
const Bare_point& q = std::get<2>(*fit).first;
|
const Bare_point& q = std::get<2>(*fit).first;
|
||||||
|
|
|
||||||
|
|
@ -418,14 +418,14 @@ tr_intersection(const typename K::Triangle_3 &t,
|
||||||
|
|
||||||
typedef typename K::Point_3 Point_3;
|
typedef typename K::Point_3 Point_3;
|
||||||
|
|
||||||
typename K::Construct_vertex_3 vertex_on =
|
typename K::Do_intersect_3 do_intersect =
|
||||||
k.construct_vertex_3_object();
|
k.do_intersect_3_object();
|
||||||
|
|
||||||
typename K::Orientation_3 orientation =
|
typename K::Orientation_3 orientation =
|
||||||
k.orientation_3_object();
|
k.orientation_3_object();
|
||||||
|
|
||||||
typename K::Construct_point_on_3 point_on =
|
typename K::Construct_point_on_3 point_on =
|
||||||
k.construct_point_on_3_object();
|
k.construct_point_on_3_object();
|
||||||
|
typename K::Construct_vertex_3 vertex_on =
|
||||||
|
k.construct_vertex_3_object();
|
||||||
|
|
||||||
typename Mesh_3::Vector_plane_orientation_3_static_filter<K> vector_plane_orient;
|
typename Mesh_3::Vector_plane_orientation_3_static_filter<K> vector_plane_orient;
|
||||||
|
|
||||||
|
|
@ -439,17 +439,24 @@ tr_intersection(const typename K::Triangle_3 &t,
|
||||||
const Point_3& q = point_on(r,1);
|
const Point_3& q = point_on(r,1);
|
||||||
|
|
||||||
const Orientation ray_direction = vector_plane_orient(p, q, a, b, c);
|
const Orientation ray_direction = vector_plane_orient(p, q, a, b, c);
|
||||||
|
if(ray_direction == COPLANAR)
|
||||||
if(ray_direction == COPLANAR) return result_type();
|
return result_type();
|
||||||
|
|
||||||
const Orientation abcp = orientation(a,b,c,p);
|
const Orientation abcp = orientation(a,b,c,p);
|
||||||
|
if(abcp == COPLANAR) // p belongs to the triangle's supporting plane
|
||||||
|
{
|
||||||
|
if(do_intersect(t, p))
|
||||||
|
return result_type(p);
|
||||||
|
else
|
||||||
|
return result_type();
|
||||||
|
}
|
||||||
|
|
||||||
if(abcp == COPLANAR) return result_type(); // p belongs to the triangle's
|
if(ray_direction == abcp)
|
||||||
// supporting plane
|
{
|
||||||
|
// The ray lies entirely in one of the two open halfspaces defined by the
|
||||||
if(ray_direction == abcp) return result_type();
|
// triangle's supporting plane.
|
||||||
// The ray lies entirely in one of the two open halfspaces defined by the
|
return result_type();
|
||||||
// triangle's supporting plane.
|
}
|
||||||
|
|
||||||
// Here we know that the ray crosses the plane (abc)
|
// Here we know that the ray crosses the plane (abc)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -691,13 +691,14 @@ Construct_initial_points::operator()(OutputIterator pts,
|
||||||
typename IGT::Construct_vector_3 vector = IGT().construct_vector_3_object();
|
typename IGT::Construct_vector_3 vector = IGT().construct_vector_3_object();
|
||||||
|
|
||||||
const Bounding_box bbox = r_domain_.tree_.bbox();
|
const Bounding_box bbox = r_domain_.tree_.bbox();
|
||||||
const Point_3 center( FT( (bbox.xmin() + bbox.xmax()) / 2),
|
Point_3 center( FT( (bbox.xmin() + bbox.xmax()) / 2),
|
||||||
FT( (bbox.ymin() + bbox.ymax()) / 2),
|
FT( (bbox.ymin() + bbox.ymax()) / 2),
|
||||||
FT( (bbox.zmin() + bbox.zmax()) / 2) );
|
FT( (bbox.zmin() + bbox.zmax()) / 2) );
|
||||||
|
|
||||||
CGAL::Random& rng = *(r_domain_.p_rng_ != 0 ?
|
CGAL::Random& rng = *(r_domain_.p_rng_ != 0 ?
|
||||||
r_domain_.p_rng_ :
|
r_domain_.p_rng_ :
|
||||||
new Random(0));
|
new Random(0));
|
||||||
|
|
||||||
Random_points_on_sphere_3<Point_3> random_point(1., rng);
|
Random_points_on_sphere_3<Point_3> random_point(1., rng);
|
||||||
|
|
||||||
int i = n;
|
int i = n;
|
||||||
|
|
@ -727,6 +728,15 @@ Construct_initial_points::operator()(OutputIterator pts,
|
||||||
% (n - i)
|
% (n - i)
|
||||||
% n;
|
% n;
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
|
// If the source of the ray is on the surface, every ray will return its source
|
||||||
|
// so change the source to a random point in the bounding box
|
||||||
|
if(std::get<0>(intersection) == ray_shot.source())
|
||||||
|
{
|
||||||
|
center = Point_3(rng.get_double(bbox.xmin(), bbox.xmax()),
|
||||||
|
rng.get_double(bbox.ymin(), bbox.ymax()),
|
||||||
|
rng.get_double(bbox.zmin(), bbox.zmax()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
++random_point;
|
++random_point;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1690,8 +1690,8 @@ smart_insert_point(const Bare_point& p, Weight w, int dim, const Index& index,
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// This will never happen for a dummy point
|
// This will never happen for a dummy point
|
||||||
while(cwsr(c3t3_.triangulation().point(nearest_vh), - sq_d) == CGAL::SMALLER &&
|
while(! is_special(nearest_vh) &&
|
||||||
! is_special(nearest_vh))
|
cwsr(c3t3_.triangulation().point(nearest_vh), - sq_d) == CGAL::SMALLER)
|
||||||
{
|
{
|
||||||
CGAL_assertion(minimal_size_ > 0 || sq_d > 0);
|
CGAL_assertion(minimal_size_ > 0 || sq_d > 0);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue