Fix -Wconversion warnings (g++-5.3.1 Fedora 23)

This commit is contained in:
Laurent Rineau
2016-04-21 16:41:14 +02:00
parent b8e97aa9ce
commit 683fa43b69
7 changed files with 30 additions and 20 deletions
@@ -79,14 +79,14 @@ public:
void set_facet_visited (const int facet)
{
CGAL_precondition(facet>=0 && facet <4);
bits_ |= (1 << facet);
bits_ |= char(1 << facet);
}
/// Marks \c facet as not visited
void reset_visited (const int facet)
{
CGAL_precondition(facet>=0 && facet<4);
bits_ &= (15 & ~(1 << facet));
bits_ = char(bits_ & (15 & ~(1 << facet)));
}
/// Returns \c true if \c facet is marked as visited
@@ -153,7 +153,7 @@ public:
{
CGAL_precondition(facet>=0 && facet<4);
char current_bits = bits_;
while (bits_.compare_and_swap(current_bits | (1 << facet), current_bits) != current_bits)
while (bits_.compare_and_swap(current_bits | char(1 << facet), current_bits) != current_bits)
{
current_bits = bits_;
}
@@ -164,7 +164,9 @@ public:
{
CGAL_precondition(facet>=0 && facet<4);
char current_bits = bits_;
while (bits_.compare_and_swap(current_bits & (15 & ~(1 << facet)), current_bits) != current_bits)
char mask = char(15 & ~(1 << facet));
char wanted_value = current_bits & mask;
while (bits_.compare_and_swap(wanted_value, current_bits) != current_bits)
{
current_bits = bits_;
}
@@ -174,7 +176,7 @@ public:
bool is_facet_visited (const int facet) const
{
CGAL_precondition(facet>=0 && facet<4);
return ( (bits_ & (1 << facet)) != 0 );
return ( (bits_ & char(1 << facet)) != 0 );
}
/// If the circumcenter is already set (circumcenter_ != NULL),
@@ -118,7 +118,9 @@ private:
Bbox_3 compute_bounding_box(const Image& im) const
{
return Bbox_3(-1,-1,-1,
im.xdim()*im.vx()+1, im.ydim()*im.vy()+1, im.zdim()*im.vz()+1);
double(im.xdim())*im.vx()+1,
double(im.ydim())*im.vy()+1,
double(im.zdim())*im.vz()+1);
}
private:
@@ -133,7 +133,9 @@ private:
Bbox_3 compute_bounding_box(const Image& im) const
{
return Bbox_3(-1,-1,-1,
im.xdim()*im.vx()+1, im.ydim()*im.vy()+1, im.zdim()*im.vz()+1);
double(im.xdim())*im.vx()+1,
double(im.ydim())*im.vy()+1,
double(im.zdim())*im.vz()+1);
}
private:
@@ -109,7 +109,13 @@ public:
/// Constructor
Implicit_vector_to_labeled_function_wrapper(const std::vector<Function_*>& v)
: function_vector_(v) {}
: function_vector_(v)
{
if ( v.size() < 8 )
{
CGAL_error_msg("We support at most 8 functions !");
}
}
// Default copy constructor and assignment operator are ok
@@ -119,18 +125,13 @@ public:
/// Operator ()
return_type operator()(const Point_3& p, const bool = true) const
{
int nb_func = static_cast<int>(function_vector_.size());
if ( nb_func > 8 )
{
CGAL_error_msg("We support at most 8 functions !");
}
const int nb_func = static_cast<int>(function_vector_.size());
char bits = 0;
for ( int i = 0 ; i < nb_func ; ++i )
{
// Insert value into bits : we compute fi(p) and insert result at
// bit i of bits
bits |= ( ((*function_vector_[i])(p) < 0) << i );
bits = char(bits | ( ((*function_vector_[i])(p) < 0) << i ));
}
return ( static_cast<return_type>(bits) );
@@ -733,7 +733,7 @@ operator()(int nb_iterations, Visitor visitor)
//Pb with Freeze : sometimes a few vertices continue moving indefinitely
//if the nb of moving vertices is < 1% of total nb AND does not decrease
if(do_freeze_
&& nb_vertices_moved < 0.005 * initial_vertices_nb
&& nb_vertices_moved < 0.005 * double(initial_vertices_nb)
&& nb_vertices_moved == moving_vertices.size())
{
// we should stop because we are
@@ -1041,7 +1041,7 @@ check_convergence() const
sum += CGAL::sqrt(*it);
}
FT average_move = sum/big_moves_size_;/*even if set is not full, divide*/
FT average_move = sum/FT(big_moves_size_);/*even if set is not full, divide*/
/*by max size so that if only 1 point moves, it goes to 0*/
#ifdef CGAL_MESH_3_OPTIMIZER_VERBOSE
sum_moves_ = average_move;
+1 -1
View File
@@ -530,7 +530,7 @@ initialize()
# endif
Random_points_on_sphere_3<Point> random_point(radius);
const int NUM_PSEUDO_INFINITE_VERTICES = static_cast<int>(
tbb::task_scheduler_init::default_num_threads()
float(tbb::task_scheduler_init::default_num_threads())
* Concurrent_mesher_config::get().num_pseudo_infinite_vertices_per_core);
for (int i = 0 ; i < NUM_PSEUDO_INFINITE_VERTICES ; ++i, ++random_point)
r_c3t3_.add_far_point(*random_point + center);
+5 -2
View File
@@ -147,7 +147,10 @@ public:
// Sets the dimension of the lowest dimensional face of the input 3D complex
// that contains the vertex
void set_dimension(const int dimension) { dimension_ = dimension; }
void set_dimension(const int dimension) {
CGAL_assertion(dimension < 4);
dimension_ = short(dimension);
}
// Tells if the vertex is marked as a special protecting ball
bool is_special() const { return dimension_ < -1; }
@@ -155,7 +158,7 @@ public:
// Marks or unmarks the vertex as a special protecting ball
void set_special(bool special = true) {
if(special != (dimension_ < -1) )
dimension_ = -2-dimension_;
dimension_ = short(-2-dimension_);
}
// Returns the index of the lowest dimensional face of the input 3D complex