Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mesh 3 - avoid tuples in internal code #8242

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
37 changes: 24 additions & 13 deletions Mesh_3/include/CGAL/Mesh_3/Mesh_global_optimizer.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
#include <CGAL/Time_stamper.h>

#include <CGAL/iterator.h>
#include <CGAL/tuple.h>

#include <CGAL/Mesh_3/Concurrent_mesher_config.h>

Expand Down Expand Up @@ -74,8 +73,13 @@ class Mesh_global_optimizer_base
// The sizing field info is stored inside the move vector because it is computed
// when the move is computed. This is because the parallel version uses the threadsafe
// version of incident_cells (which thus requires points to not be moving yet)
typedef std::vector<std::tuple<typename Tr::Vertex_handle, Vector_3, FT> >
Moves_vector;
struct Move
{
typename Tr::Vertex_handle vertex_;
Vector_3 move_;
FT size_;
};
typedef std::vector<Move> Moves_vector;
typedef unsigned int Nb_frozen_points_type;

Mesh_global_optimizer_base(const Bbox_3 &, int)
Expand Down Expand Up @@ -129,8 +133,14 @@ class Mesh_global_optimizer_base<Tr, Parallel_tag>
typedef typename GT::FT FT;
typedef typename GT::Vector_3 Vector_3;
typedef typename Tr::Lock_data_structure Lock_data_structure;
typedef tbb::concurrent_vector<std::tuple<typename Tr::Vertex_handle, Vector_3, FT> >
Moves_vector;

struct Move
{
typename Tr::Vertex_handle vertex_;
Vector_3 move_;
FT size_;
};
typedef tbb::concurrent_vector<Move> Moves_vector;
typedef std::atomic<unsigned int> Nb_frozen_points_type ;

Mesh_global_optimizer_base(const Bbox_3 &bbox, int num_grid_cells_per_axis)
Expand Down Expand Up @@ -411,6 +421,7 @@ class Mesh_global_optimizer
{
typename GT::Construct_point_3 cp = m_gt.construct_point_3_object();
typename GT::Construct_translated_point_3 translate = m_gt.construct_translated_point_3_object();
typedef typename Moves_vector_::value_type Move;

Vector_3 move = m_mgo.compute_move(oldv);
if ( CGAL::NULL_VECTOR != move )
Expand All @@ -429,7 +440,7 @@ class Mesh_global_optimizer
//note : this is not happening for Lloyd and ODT so it's commented
// maybe for a new global optimizer it should be de-commented

m_moves.push_back(std::make_tuple(oldv, move, size));
m_moves.push_back(Move{oldv, move, size});
}
else // CGAL::NULL_VECTOR == move
{
Expand Down Expand Up @@ -517,13 +528,13 @@ class Mesh_global_optimizer
{
for( size_t i = r.begin() ; i != r.end() ; ++i)
{
const Vertex_handle& v = std::get<0>(m_moves[i]);
const Vector_3& move = std::get<1>(m_moves[i]);
const Vertex_handle& v = m_moves[i].vertex_;
const Vector_3& move = m_moves[i].move_;

// Get size at new position
if ( MGO::Sizing_field::is_vertex_update_needed )
{
FT size = std::get<2>(m_moves[i]);
const FT size = m_moves[i].size_;

// Move point
bool could_lock_zone;
Expand Down Expand Up @@ -846,7 +857,7 @@ compute_moves(Moving_vertices_set& moving_vertices)
size = sizing_field_(new_position, oldv);
}

moves.push_back(std::make_tuple(oldv, move, size));
moves.push_back({oldv, move, size});
}
else // CGAL::NULL_VECTOR == move
{
Expand Down Expand Up @@ -965,12 +976,12 @@ update_mesh(const Moves_vector& moves,
it != moves.end() ;
++it )
{
const Vertex_handle& v = std::get<0>(*it);
const Vector_3& move = std::get<1>(*it);
const Vertex_handle& v = it->vertex_;
const Vector_3& move = it->move_;
// Get size at new position
if ( Sizing_field::is_vertex_update_needed )
{
FT size = std::get<2>(*it);
const FT size = it->size_;

#ifdef CGAL_MESH_3_OPTIMIZER_VERY_VERBOSE
std::cerr << "Moving #" << it - moves.begin()
Expand Down
24 changes: 12 additions & 12 deletions Mesh_3/include/CGAL/Mesh_3/Protect_edges_sizing_field.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@
# include <boost/math/special_functions/next.hpp> // for float_prior
#endif
#include <optional>
#include <boost/tuple/tuple.hpp>
#include <boost/unordered_map.hpp>
#include <boost/unordered_set.hpp>

Expand Down Expand Up @@ -1019,29 +1018,30 @@ Protect_edges_sizing_field<C3T3, MD, Sf, Df>::
insert_balls_on_edges()
{
// Get features
typedef std::tuple<Curve_index,
std::pair<Bare_point,Index>,
std::pair<Bare_point,Index> > Feature_tuple;
typedef std::vector<Feature_tuple> Input_features;

Input_features input_features;
struct Feature_tuple
{
Curve_index curve_index_;
std::pair<Bare_point, Index> point_s_;
std::pair<Bare_point, Index> point_t_;
};
std::vector<Feature_tuple> input_features;
domain_.get_curves(std::back_inserter(input_features));

// Iterate on edges
for (const Feature_tuple& ft : input_features)
{
if(forced_stop()) break;
const Curve_index& curve_index = std::get<0>(ft);
const Curve_index& curve_index = ft.curve_index_;
if ( ! is_treated(curve_index) )
{
#if CGAL_MESH_3_PROTECTION_DEBUG & 1
std::cerr << "\n** treat curve #" << curve_index << std::endl;
#endif
const Bare_point& p = std::get<1>(ft).first;
const Bare_point& q = std::get<2>(ft).first;
const Bare_point& p = ft.point_s_.first;
const Bare_point& q = ft.point_t_.first;

const Index& p_index = std::get<1>(ft).second;
const Index& q_index = std::get<2>(ft).second;
const Index& p_index = ft.point_s_.second;
const Index& q_index = ft.point_t_.second;

Vertex_handle vp,vq;
if ( ! domain_.is_loop(curve_index) )
Expand Down
Loading