Skip to content

Commit 1f258bc

Browse files
committed
Fix initialization failing if the ray's source is on the domain
This is a band aid fix, a proper fix is to rework the full initilization pipeline. This is the purpose of the following pull request: #7606
1 parent 0d34585 commit 1f258bc

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

Mesh_3/include/CGAL/Polyhedral_mesh_domain_3.h

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -692,13 +692,14 @@ Construct_initial_points::operator()(OutputIterator pts,
692692
typename IGT::Construct_vector_3 vector = IGT().construct_vector_3_object();
693693

694694
const Bounding_box bbox = r_domain_.tree_.bbox();
695-
const Point_3 center( FT( (bbox.xmin() + bbox.xmax()) / 2),
696-
FT( (bbox.ymin() + bbox.ymax()) / 2),
697-
FT( (bbox.zmin() + bbox.zmax()) / 2) );
695+
Point_3 center( FT( (bbox.xmin() + bbox.xmax()) / 2),
696+
FT( (bbox.ymin() + bbox.ymax()) / 2),
697+
FT( (bbox.zmin() + bbox.zmax()) / 2) );
698698

699699
CGAL::Random& rng = *(r_domain_.p_rng_ != 0 ?
700700
r_domain_.p_rng_ :
701701
new Random(0));
702+
702703
Random_points_on_sphere_3<Point_3> random_point(1., rng);
703704

704705
int i = n;
@@ -728,6 +729,15 @@ Construct_initial_points::operator()(OutputIterator pts,
728729
% (n - i)
729730
% n;
730731
# endif
732+
733+
// If the source of the ray is on the surface, every ray will return its source
734+
// so change the source to a random point in the bounding box
735+
if(std::get<0>(intersection) == ray_shot.source())
736+
{
737+
center = Point_3(rng.get_double(bbox.xmin(), bbox.xmax()),
738+
rng.get_double(bbox.ymin(), bbox.ymax()),
739+
rng.get_double(bbox.zmin(), bbox.zmax()));
740+
}
731741
}
732742
++random_point;
733743
}

0 commit comments

Comments
 (0)