Skip to content

Commit

Permalink
add TODOs for parallelism
Browse files Browse the repository at this point in the history
  • Loading branch information
sloriot committed May 25, 2023
1 parent a15956d commit 5d73a7a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ if(TARGET CGAL::TBB_support)
target_link_libraries(self_intersections_example PUBLIC CGAL::TBB_support)
target_link_libraries(hausdorff_distance_remeshing_example PUBLIC CGAL::TBB_support)
target_link_libraries(hausdorff_bounded_error_distance_example PUBLIC CGAL::TBB_support)
target_link_libraries(soup_autorefinement PUBLIC CGAL::TBB_support)

create_single_source_cgal_program("corefinement_parallel_union_meshes.cpp")
target_link_libraries(corefinement_parallel_union_meshes PUBLIC CGAL::TBB_support)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1116,7 +1116,7 @@ void autorefine_soup_output(const PointRange& input_points,
typedef std::size_t Input_TID;
typedef std::pair<Input_TID, Input_TID> Pair_of_triangle_ids;

std::vector<Pair_of_triangle_ids> si_pairs;
std::vector<Pair_of_triangle_ids> si_pairs; // TODO: check std::vector is fine with Parallel_tag

// collect intersecting pairs of triangles
CGAL_PMP_AUTOREFINE_VERBOSE("collect intersecting pairs");
Expand Down Expand Up @@ -1170,6 +1170,7 @@ void autorefine_soup_output(const PointRange& input_points,
CGAL_PMP_AUTOREFINE_VERBOSE("compute intersections");

std::set<std::pair<std::size_t, std::size_t> > intersecting_triangles;
//TODO: PARALLEL_FOR #2
for (const Pair_of_triangle_ids& p : si_pairs)
{
int i1 = tri_inter_ids[p.first],
Expand Down Expand Up @@ -1217,6 +1218,7 @@ void autorefine_soup_output(const PointRange& input_points,

#ifdef DEDUPLICATE_SEGMENTS
// deduplicate inserted segments
//TODO: PARALLEL_FOR #3
std::vector<std::vector<std::pair<std::size_t, std::size_t>>> all_segments_ids(all_segments.size());
for(std::size_t ti=0; ti<triangles.size(); ++ti)
{
Expand Down Expand Up @@ -1264,12 +1266,13 @@ void autorefine_soup_output(const PointRange& input_points,

CGAL_PMP_AUTOREFINE_VERBOSE("triangulate faces");
// now refine triangles
std::vector<std::array<EK::Point_3,3>> new_triangles;
std::vector<std::array<EK::Point_3,3>> new_triangles; // Need to be threadsafe

#ifdef USE_PROGRESS_DISPLAY
boost::timer::progress_display pd(triangles.size());
#endif

//TODO: PARALLEL_FOR #1
for(std::size_t ti=0; ti<triangles.size(); ++ti)
{
if (all_segments[ti].empty() && all_points[ti].empty())
Expand Down Expand Up @@ -1308,6 +1311,7 @@ void autorefine_soup_output(const PointRange& input_points,
CGAL_PMP_AUTOREFINE_VERBOSE("create output soup");

Cartesian_converter<EK, GT> to_input;
// TODO: reuse the fact that maps per triangle are already sorted
std::map<EK::Point_3, std::size_t> point_id_map;
#if ! defined(CGAL_NDEBUG) || defined(CGAL_DEBUG_PMP_AUTOREFINE)
std::vector<EK::Point_3> exact_soup_points;
Expand Down Expand Up @@ -1348,18 +1352,19 @@ void autorefine_soup_output(const PointRange& input_points,
}

// import refined triangles
//TODO: PARALLEL_FOR #4
for (const std::array<EK::Point_3,3>& t : new_triangles)
{
soup_triangles.emplace_back(CGAL::make_array(get_point_id(t[0]), get_point_id(t[1]), get_point_id(t[2])));
}

#ifndef CGAL_NDEBUG
CGAL_PMP_AUTOREFINE_VERBOSE("check soup");
CGAL_assertion( !does_triangle_soup_self_intersect(exact_soup_points, soup_triangles) );
CGAL_assertion( !does_triangle_soup_self_intersect<Concurrency_tag>(exact_soup_points, soup_triangles) );
#else
#ifdef CGAL_DEBUG_PMP_AUTOREFINE
CGAL_PMP_AUTOREFINE_VERBOSE("check soup");
if (does_triangle_soup_self_intersect(exact_soup_points, soup_triangles))
if (does_triangle_soup_self_intersect<Concurrency_tag>(exact_soup_points, soup_triangles))
throw std::runtime_error("ERROR: invalid output, there is most probably a bug");
#endif
#endif
Expand Down

0 comments on commit 5d73a7a

Please sign in to comment.