From c0c6ee1b9a23fadf3030cd0e5211ed9989d37f45 Mon Sep 17 00:00:00 2001 From: Frederic Laing Date: Sun, 17 Jun 2018 17:58:13 +0200 Subject: [PATCH] Use C++ style casts --- .../attributes/attribute_octahedron_transform.cc | 2 +- .../attributes/attribute_quantization_transform.cc | 4 ++-- src/draco/attributes/attribute_transform_data.h | 2 +- src/draco/attributes/point_attribute.cc | 4 ++-- src/draco/attributes/point_attribute.h | 2 +- .../compression/attributes/attributes_decoder.h | 4 ++-- .../compression/attributes/attributes_encoder.h | 6 +++--- .../attributes/kd_tree_attributes_decoder.cc | 10 +++++----- .../attributes/kd_tree_attributes_encoder.cc | 4 ++-- .../attributes/mesh_traversal_sequencer.h | 2 +- .../attributes/normal_compression_utils.h | 4 ++-- ...cheme_constrained_multi_parallelogram_decoder.h | 2 +- ...cheme_constrained_multi_parallelogram_encoder.h | 8 ++++---- ...sh_prediction_scheme_geometric_normal_decoder.h | 2 +- ...sh_prediction_scheme_geometric_normal_encoder.h | 2 +- ...iction_scheme_geometric_normal_predictor_area.h | 2 +- ...prediction_scheme_multi_parallelogram_decoder.h | 2 +- ...prediction_scheme_multi_parallelogram_encoder.h | 2 +- .../mesh_prediction_scheme_parallelogram_decoder.h | 2 +- .../mesh_prediction_scheme_parallelogram_encoder.h | 2 +- .../mesh_prediction_scheme_tex_coords_decoder.h | 4 ++-- .../mesh_prediction_scheme_tex_coords_encoder.h | 6 +++--- ...prediction_scheme_tex_coords_portable_decoder.h | 2 +- ...prediction_scheme_tex_coords_portable_encoder.h | 2 +- .../attributes/sequential_attribute_decoder.cc | 6 +++--- .../attributes/sequential_attribute_encoder.cc | 2 +- .../attributes/sequential_attribute_encoder.h | 2 +- .../sequential_integer_attribute_decoder.cc | 14 +++++++------- .../sequential_integer_attribute_encoder.cc | 10 +++++----- .../mesh/mesh_edgebreaker_decoder_impl.cc | 14 +++++++------- .../mesh/mesh_edgebreaker_decoder_impl.h | 2 +- .../mesh/mesh_edgebreaker_encoder_impl.cc | 6 +++--- .../mesh/mesh_edgebreaker_traversal_decoder.h | 4 ++-- .../mesh/mesh_edgebreaker_traversal_encoder.h | 4 ++-- ...mesh_edgebreaker_traversal_predictive_encoder.h | 2 +- .../mesh_edgebreaker_traversal_valence_decoder.h | 2 +- .../mesh_edgebreaker_traversal_valence_encoder.h | 8 ++++---- .../compression/mesh/mesh_sequential_encoder.cc | 2 +- .../dynamic_integer_points_kd_tree_encoder.h | 12 ++++++------ .../compression/point_cloud/point_cloud_decoder.h | 2 +- .../compression/point_cloud/point_cloud_encoder.h | 4 ++-- src/draco/core/bit_coders/direct_bit_encoder.cc | 2 +- src/draco/core/bit_coders/symbol_bit_encoder.cc | 2 +- src/draco/core/encoder_buffer.cc | 2 +- src/draco/core/hash_utils.cc | 4 ++-- src/draco/core/options.cc | 2 +- src/draco/core/rans_symbol_decoder.h | 4 ++-- src/draco/core/rans_symbol_encoder.h | 2 +- src/draco/core/shannon_entropy.cc | 8 ++++---- src/draco/core/symbol_encoding.cc | 4 ++-- src/draco/io/obj_decoder.cc | 4 ++-- src/draco/io/obj_encoder.cc | 6 +++--- src/draco/io/parser_utils.cc | 4 ++-- src/draco/io/ply_decoder.cc | 4 ++-- src/draco/io/ply_reader.cc | 2 +- src/draco/io/ply_reader.h | 10 +++++----- src/draco/mesh/corner_table.cc | 6 +++--- src/draco/mesh/corner_table.h | 10 +++++----- src/draco/mesh/mesh.h | 6 +++--- src/draco/mesh/mesh_are_equivalent.cc | 2 +- src/draco/mesh/mesh_attribute_corner_table.h | 4 ++-- src/draco/mesh/mesh_cleanup.cc | 2 +- src/draco/mesh/mesh_stripifier.h | 2 +- src/draco/mesh/triangle_soup_mesh_builder.cc | 2 +- src/draco/metadata/metadata.h | 2 +- src/draco/metadata/metadata_decoder.cc | 6 +++--- src/draco/metadata/metadata_encoder.cc | 2 +- src/draco/point_cloud/point_cloud.cc | 10 +++++----- src/draco/point_cloud/point_cloud.h | 2 +- 69 files changed, 147 insertions(+), 147 deletions(-) diff --git a/src/draco/attributes/attribute_octahedron_transform.cc b/src/draco/attributes/attribute_octahedron_transform.cc index d9a12750..e1180a48 100644 --- a/src/draco/attributes/attribute_octahedron_transform.cc +++ b/src/draco/attributes/attribute_octahedron_transform.cc @@ -57,7 +57,7 @@ AttributeOctahedronTransform::GeneratePortableAttribute( DRACO_DCHECK(is_initialized()); // Allocate portable attribute. - const int num_entries = (int)point_ids.size(); + const int num_entries = static_cast(point_ids.size()); std::unique_ptr portable_attribute = InitPortableAttribute(num_entries, 2, num_points, attribute, true); diff --git a/src/draco/attributes/attribute_quantization_transform.cc b/src/draco/attributes/attribute_quantization_transform.cc index edd5cb1b..0e55f73a 100644 --- a/src/draco/attributes/attribute_quantization_transform.cc +++ b/src/draco/attributes/attribute_quantization_transform.cc @@ -76,7 +76,7 @@ bool AttributeQuantizationTransform::ComputeParameters( attribute.GetValue(AttributeValueIndex(0), min_values_.data()); attribute.GetValue(AttributeValueIndex(0), max_values.get()); - for (AttributeValueIndex i(1); i < (uint32_t)attribute.size(); ++i) { + for (AttributeValueIndex i(1); i < static_cast(attribute.size()); ++i) { attribute.GetValue(i, att_val.get()); for (int c = 0; c < num_components; ++c) { if (min_values_[c] > att_val[c]) @@ -144,7 +144,7 @@ AttributeQuantizationTransform::GeneratePortableAttribute( DRACO_DCHECK(is_initialized()); // Allocate portable attribute. - const int num_entries = (int)point_ids.size(); + const int num_entries = static_cast(point_ids.size()); const int num_components = attribute.num_components(); std::unique_ptr portable_attribute = InitPortableAttribute( num_entries, num_components, num_points, attribute, true); diff --git a/src/draco/attributes/attribute_transform_data.h b/src/draco/attributes/attribute_transform_data.h index 641144ce..96ed0732 100644 --- a/src/draco/attributes/attribute_transform_data.h +++ b/src/draco/attributes/attribute_transform_data.h @@ -58,7 +58,7 @@ class AttributeTransformData { // Sets a parameter value at the end of the |buffer_|. template void AppendParameterValue(const DataTypeT &in_data) { - SetParameterValue((int)buffer_.data_size(), in_data); + SetParameterValue(static_cast(buffer_.data_size()), in_data); } private: diff --git a/src/draco/attributes/point_attribute.cc b/src/draco/attributes/point_attribute.cc index ebef48de..4428f332 100644 --- a/src/draco/attributes/point_attribute.cc +++ b/src/draco/attributes/point_attribute.cc @@ -60,7 +60,7 @@ bool PointAttribute::Reset(size_t num_attribute_values) { return false; // Assign the new buffer to the parent attribute. ResetBuffer(attribute_buffer_.get(), entry_size, 0); - num_unique_entries_ = (uint32_t)num_attribute_values; + num_unique_entries_ = static_cast(num_attribute_values); return true; } @@ -193,7 +193,7 @@ AttributeValueIndex::ValueType PointAttribute::DeduplicateFormattedValues( } } else { // Update point to value map using the mapping between old and new values. - for (PointIndex i(0); i < (uint32_t)indices_map_.size(); ++i) { + for (PointIndex i(0); i < static_cast(indices_map_.size()); ++i) { SetPointMapEntry(i, value_map[indices_map_[i]]); } } diff --git a/src/draco/attributes/point_attribute.h b/src/draco/attributes/point_attribute.h index 89bfdaa6..dffde503 100644 --- a/src/draco/attributes/point_attribute.h +++ b/src/draco/attributes/point_attribute.h @@ -67,7 +67,7 @@ class PointAttribute : public GeometryAttribute { // Sets the new number of unique attribute entries for the attribute. void Resize(size_t new_num_unique_entries) { - num_unique_entries_ = (uint32_t)new_num_unique_entries; + num_unique_entries_ = static_cast(new_num_unique_entries); } // Functions for setting the type of mapping between point indices and diff --git a/src/draco/compression/attributes/attributes_decoder.h b/src/draco/compression/attributes/attributes_decoder.h index efa21120..55ba44c8 100644 --- a/src/draco/compression/attributes/attributes_decoder.h +++ b/src/draco/compression/attributes/attributes_decoder.h @@ -46,7 +46,7 @@ class AttributesDecoder : public AttributesDecoderInterface { return point_attribute_ids_[i]; } int32_t GetNumAttributes() const override { - return (int32_t)point_attribute_ids_.size(); + return static_cast(point_attribute_ids_.size()); } PointCloudDecoder *GetDecoder() const override { return point_cloud_decoder_; @@ -65,7 +65,7 @@ class AttributesDecoder : public AttributesDecoderInterface { protected: int32_t GetLocalIdForPointAttribute(int32_t point_attribute_id) const { - const int id_map_size = (int)point_attribute_to_local_id_map_.size(); + const int id_map_size = static_cast(point_attribute_to_local_id_map_.size()); if (point_attribute_id >= id_map_size) return -1; return point_attribute_to_local_id_map_[point_attribute_id]; diff --git a/src/draco/compression/attributes/attributes_encoder.h b/src/draco/compression/attributes/attributes_encoder.h index af10af3a..338fc7b0 100644 --- a/src/draco/compression/attributes/attributes_encoder.h +++ b/src/draco/compression/attributes/attributes_encoder.h @@ -89,7 +89,7 @@ class AttributesEncoder { point_attribute_ids_.push_back(id); if (id >= static_cast(point_attribute_to_local_id_map_.size())) point_attribute_to_local_id_map_.resize(id + 1, -1); - point_attribute_to_local_id_map_[id] = (int32_t)point_attribute_ids_.size() - 1; + point_attribute_to_local_id_map_[id] = static_cast(point_attribute_ids_.size()) - 1; } // Sets new attribute point ids (replacing the existing ones). @@ -102,7 +102,7 @@ class AttributesEncoder { } int32_t GetAttributeId(int i) const { return point_attribute_ids_[i]; } - uint32_t num_attributes() const { return (uint32_t)point_attribute_ids_.size(); } + uint32_t num_attributes() const { return static_cast(point_attribute_ids_.size()); } PointCloudEncoder *encoder() const { return point_cloud_encoder_; } protected: @@ -122,7 +122,7 @@ class AttributesEncoder { } int32_t GetLocalIdForPointAttribute(int32_t point_attribute_id) const { - const int id_map_size = (int)point_attribute_to_local_id_map_.size(); + const int id_map_size = static_cast(point_attribute_to_local_id_map_.size()); if (point_attribute_id >= id_map_size) return -1; return point_attribute_to_local_id_map_[point_attribute_id]; diff --git a/src/draco/compression/attributes/kd_tree_attributes_decoder.cc b/src/draco/compression/attributes/kd_tree_attributes_decoder.cc index 8fb8e5f3..8e1e1502 100644 --- a/src/draco/compression/attributes/kd_tree_attributes_decoder.cc +++ b/src/draco/compression/attributes/kd_tree_attributes_decoder.cc @@ -104,7 +104,7 @@ class PointAttributeVectorOutputIterator { data_source = reinterpret_cast(data_); } const AttributeValueIndex avi = attribute->mapped_index(point_id_); - if (avi >= (uint32_t)attribute->size()) + if (avi >= static_cast(attribute->size())) return *this; attribute->SetAttributeValue(avi, data_source); } @@ -268,7 +268,7 @@ bool KdTreeAttributesDecoder::DecodeDataNeededByPortableTransforms( AttributeQuantizationTransform transform; transform.SetParameters(quantization_bits, min_value.data(), num_components, max_value_dif); - const int num_transforms = (int)attribute_quantization_transforms_.size(); + const int num_transforms = static_cast(attribute_quantization_transforms_.size()); if (!transform.TransferToAttribute( quantized_portable_attributes_[num_transforms].get())) return false; @@ -290,7 +290,7 @@ bool KdTreeAttributesDecoder::DecodeDataNeededByPortableTransforms( const uint32_t attribute_count = GetNumAttributes(); uint32_t total_dimensionality = 0; // position is a required dimension std::vector atts(attribute_count); - for (auto attribute_index = 0; (uint32_t)attribute_index < attribute_count; + for (auto attribute_index = 0; static_cast(attribute_index) < attribute_count; attribute_index += 1) // increment the dimensionality as needed... { const int att_id = GetAttributeId(attribute_index); @@ -337,7 +337,7 @@ bool KdTreeAttributesDecoder::DecodeDataNeededByPortableTransforms( if (!in_buffer->Decode(&num_points)) return false; - for (auto attribute_index = 0; (uint32_t)attribute_index < attribute_count; + for (auto attribute_index = 0; static_cast(attribute_index) < attribute_count; attribute_index += 1) { const int att_id = GetAttributeId(attribute_index); PointAttribute *const attr = @@ -411,7 +411,7 @@ bool KdTreeAttributesDecoder::TransformAttributeBackToSignedType( std::vector unsigned_val(att->num_components()); std::vector signed_val(att->num_components()); - for (AttributeValueIndex avi(0); avi < (uint32_t)att->size(); ++avi) { + for (AttributeValueIndex avi(0); avi < static_cast(att->size()); ++avi) { att->GetValue(avi, &unsigned_val[0]); for (int c = 0; c < att->num_components(); ++c) { // Up-cast |unsigned_val| to int32_t to ensure we don't overflow it for diff --git a/src/draco/compression/attributes/kd_tree_attributes_encoder.cc b/src/draco/compression/attributes/kd_tree_attributes_encoder.cc index 337cb65e..d2c3651a 100644 --- a/src/draco/compression/attributes/kd_tree_attributes_encoder.cc +++ b/src/draco/compression/attributes/kd_tree_attributes_encoder.cc @@ -78,7 +78,7 @@ bool KdTreeAttributesEncoder::TransformAttributesToPortableFormat() { // the actual encoding of the data. quantized_portable_attributes_.push_back( attribute_quantization_transform.GeneratePortableAttribute( - *att, (int)num_points)); + *att, static_cast(num_points))); } else if (att->data_type() == DT_INT32 || att->data_type() == DT_INT16 || att->data_type() == DT_INT8) { // For signed types, find the minimum value for each component. These @@ -87,7 +87,7 @@ bool KdTreeAttributesEncoder::TransformAttributesToPortableFormat() { std::vector min_value(att->num_components(), std::numeric_limits::max()); std::vector act_value(att->num_components()); - for (AttributeValueIndex avi(0); avi < (uint32_t)att->size(); ++avi) { + for (AttributeValueIndex avi(0); avi < static_cast(att->size()); ++avi) { att->ConvertValue(avi, &act_value[0]); for (int c = 0; c < att->num_components(); ++c) { if (min_value[c] > act_value[c]) diff --git a/src/draco/compression/attributes/mesh_traversal_sequencer.h b/src/draco/compression/attributes/mesh_traversal_sequencer.h index c428af40..843692cf 100644 --- a/src/draco/compression/attributes/mesh_traversal_sequencer.h +++ b/src/draco/compression/attributes/mesh_traversal_sequencer.h @@ -49,7 +49,7 @@ class MeshTraversalSequencer : public PointsSequencer { attribute->SetExplicitMapping(mesh_->num_points()); const size_t num_faces = mesh_->num_faces(); const size_t num_points = mesh_->num_points(); - for (FaceIndex f(0); f < (uint32_t)num_faces; ++f) { + for (FaceIndex f(0); f < static_cast(num_faces); ++f) { const auto &face = mesh_->face(f); for (int p = 0; p < 3; ++p) { const PointIndex point_id = face[p]; diff --git a/src/draco/compression/attributes/normal_compression_utils.h b/src/draco/compression/attributes/normal_compression_utils.h index 2255a57f..e06868c9 100644 --- a/src/draco/compression/attributes/normal_compression_utils.h +++ b/src/draco/compression/attributes/normal_compression_utils.h @@ -175,8 +175,8 @@ class OctahedronToolBox { if (abs_sum == 0) { vec[0] = center_value_; // vec[1] == v[2] == 0 } else { - vec[0] = (static_cast((int64_t)vec[0]) * (int64_t)center_value_) / abs_sum; - vec[1] = (static_cast((int64_t)vec[1]) * (int64_t)center_value_) / abs_sum; + vec[0] = (static_cast(vec[0]) * static_cast(center_value_)) / abs_sum; + vec[1] = (static_cast(vec[1]) * static_cast(center_value_)) / abs_sum; if (vec[2] >= 0) { vec[2] = center_value_ - std::abs(vec[0]) - std::abs(vec[1]); } else { diff --git a/src/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_constrained_multi_parallelogram_decoder.h b/src/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_constrained_multi_parallelogram_decoder.h index c6fb6e4d..6e23997f 100644 --- a/src/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_constrained_multi_parallelogram_decoder.h +++ b/src/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_constrained_multi_parallelogram_decoder.h @@ -105,7 +105,7 @@ bool MeshPredictionSchemeConstrainedMultiParallelogramDecoder< // Used to store predicted value for multi-parallelogram prediction. std::vector multi_pred_vals(num_components); - const int corner_map_size = (int)this->mesh_data().data_to_corner_map()->size(); + const int corner_map_size = static_cast(this->mesh_data().data_to_corner_map()->size()); for (int p = 1; p < corner_map_size; ++p) { const CornerIndex start_corner_id = this->mesh_data().data_to_corner_map()->at(p); diff --git a/src/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_constrained_multi_parallelogram_encoder.h b/src/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_constrained_multi_parallelogram_encoder.h index c06b2144..29a4e8de 100644 --- a/src/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_constrained_multi_parallelogram_encoder.h +++ b/src/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_constrained_multi_parallelogram_encoder.h @@ -87,10 +87,10 @@ class MeshPredictionSchemeConstrainedMultiParallelogramEncoder // TODO(ostava): This should be generalized in case we use other binary // coding scheme. const double entropy = ComputeBinaryShannonEntropy( - (uint32_t)total_parallelogram, (uint32_t)total_used_parallelograms); + static_cast(total_parallelogram), static_cast(total_used_parallelograms)); // Round up to the nearest full bit. - return (int64_t)ceil((double)total_parallelogram * entropy); + return static_cast(ceil(static_cast(total_parallelogram) * entropy)); } // Struct that contains data used for measuring the error of each available @@ -209,7 +209,7 @@ bool MeshPredictionSchemeConstrainedMultiParallelogramEncoder< // We start processing the vertices from the end because this prediction uses // data from previous entries that could be overwritten when an entry is // processed. - for (int p = (int)this->mesh_data().data_to_corner_map()->size() - 1; p > 0; --p) { + for (int p = static_cast(this->mesh_data().data_to_corner_map()->size()) - 1; p > 0; --p) { const CornerIndex start_corner_id = this->mesh_data().data_to_corner_map()->at(p); @@ -386,7 +386,7 @@ bool MeshPredictionSchemeConstrainedMultiParallelogramEncoder< // Encode the crease edge flags in the reverse vertex order that is needed // be the decoder. Note that for the currently supported mode, each vertex // has exactly |num_used_parallelograms| edges that need to be encoded. - for (int j = (int)(is_crease_edge_[i].size() - num_used_parallelograms); j >= 0; + for (int j = static_cast(is_crease_edge_[i].size()) - num_used_parallelograms; j >= 0; j -= num_used_parallelograms) { // Go over all edges of the current vertex. for (int k = 0; k < num_used_parallelograms; ++k) { diff --git a/src/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_geometric_normal_decoder.h b/src/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_geometric_normal_decoder.h index 72925248..1d5ef878 100644 --- a/src/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_geometric_normal_decoder.h +++ b/src/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_geometric_normal_decoder.h @@ -103,7 +103,7 @@ bool MeshPredictionSchemeGeometricNormalDecoder< // Expecting in_data in octahedral coordinates, i.e., portable attribute. DRACO_DCHECK_EQ(num_components, 2); - const int corner_map_size = (int)this->mesh_data().data_to_corner_map()->size(); + const int corner_map_size = static_cast(this->mesh_data().data_to_corner_map()->size()); VectorD pred_normal_3d; int32_t pred_normal_oct[2]; diff --git a/src/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_geometric_normal_encoder.h b/src/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_geometric_normal_encoder.h index ef2b6e28..920cae3f 100644 --- a/src/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_geometric_normal_encoder.h +++ b/src/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_geometric_normal_encoder.h @@ -102,7 +102,7 @@ bool MeshPredictionSchemeGeometricNormalEncodermesh_data().data_to_corner_map()->size(); + const int corner_map_size = static_cast(this->mesh_data().data_to_corner_map()->size()); VectorD pred_normal_3d; VectorD pos_pred_normal_oct; diff --git a/src/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_geometric_normal_predictor_area.h b/src/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_geometric_normal_predictor_area.h index 826a887d..bf1a6146 100644 --- a/src/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_geometric_normal_predictor_area.h +++ b/src/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_geometric_normal_predictor_area.h @@ -76,7 +76,7 @@ class MeshPredictionSchemeGeometricNormalPredictorArea // Convert to int32_t, make sure entries are not too large. constexpr int64_t upper_bound = 1 << 29; if (this->normal_prediction_mode_ == ONE_TRIANGLE) { - const int32_t abs_sum = (int32_t)normal.AbsSum(); + const int32_t abs_sum = static_cast(normal.AbsSum()); if (abs_sum > upper_bound) { const int64_t quotient = abs_sum / upper_bound; normal = normal / quotient; diff --git a/src/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_multi_parallelogram_decoder.h b/src/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_multi_parallelogram_decoder.h index a50f688d..a1ebb450 100644 --- a/src/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_multi_parallelogram_decoder.h +++ b/src/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_multi_parallelogram_decoder.h @@ -73,7 +73,7 @@ bool MeshPredictionSchemeMultiParallelogramDecoder *const vertex_to_data_map = this->mesh_data().vertex_to_data_map(); - const int corner_map_size = (int)this->mesh_data().data_to_corner_map()->size(); + const int corner_map_size = static_cast(this->mesh_data().data_to_corner_map()->size()); for (int p = 1; p < corner_map_size; ++p) { const CornerIndex start_corner_id = this->mesh_data().data_to_corner_map()->at(p); diff --git a/src/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_multi_parallelogram_encoder.h b/src/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_multi_parallelogram_encoder.h index 59d02a75..4d53dc7b 100644 --- a/src/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_multi_parallelogram_encoder.h +++ b/src/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_multi_parallelogram_encoder.h @@ -74,7 +74,7 @@ bool MeshPredictionSchemeMultiParallelogramEncodermesh_data().data_to_corner_map()->size() - 1); p > 0; --p) { + for (int p = static_cast(this->mesh_data().data_to_corner_map()->size() - 1); p > 0; --p) { const CornerIndex start_corner_id = this->mesh_data().data_to_corner_map()->at(p); diff --git a/src/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_parallelogram_decoder.h b/src/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_parallelogram_decoder.h index 1d9c5db0..4e0bf2a0 100644 --- a/src/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_parallelogram_decoder.h +++ b/src/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_parallelogram_decoder.h @@ -69,7 +69,7 @@ bool MeshPredictionSchemeParallelogramDecodertransform().ComputeOriginalValue(pred_vals.get(), in_corr, out_data); - const int corner_map_size = (int)this->mesh_data().data_to_corner_map()->size(); + const int corner_map_size = static_cast(this->mesh_data().data_to_corner_map()->size()); for (int p = 1; p < corner_map_size; ++p) { const CornerIndex corner_id = this->mesh_data().data_to_corner_map()->at(p); const int dst_offset = p * num_components; diff --git a/src/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_parallelogram_encoder.h b/src/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_parallelogram_encoder.h index 376e1711..7142e878 100644 --- a/src/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_parallelogram_encoder.h +++ b/src/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_parallelogram_encoder.h @@ -77,7 +77,7 @@ bool MeshPredictionSchemeParallelogramEncodermesh_data().corner_table(); const std::vector *const vertex_to_data_map = this->mesh_data().vertex_to_data_map(); - for (int p = (int)(this->mesh_data().data_to_corner_map()->size() - 1); p > 0; --p) { + for (int p = static_cast(this->mesh_data().data_to_corner_map()->size() - 1); p > 0; --p) { const CornerIndex corner_id = this->mesh_data().data_to_corner_map()->at(p); const int dst_offset = p * num_components; if (!ComputeParallelogramPrediction(p, corner_id, table, diff --git a/src/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_tex_coords_decoder.h b/src/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_tex_coords_decoder.h index 22a28e10..08ce1fdc 100644 --- a/src/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_tex_coords_decoder.h +++ b/src/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_tex_coords_decoder.h @@ -97,7 +97,7 @@ class MeshPredictionSchemeTexCoordsDecoder Vector2f GetTexCoordForEntryId(int entry_id, const DataTypeT *data) const { const int data_offset = entry_id * num_components_; - return Vector2f((float)data[data_offset], (float)data[data_offset + 1]); + return Vector2f(static_cast(data[data_offset]), static_cast(data[data_offset + 1])); } void ComputePredictedValue(CornerIndex corner_id, const DataTypeT *data, @@ -124,7 +124,7 @@ bool MeshPredictionSchemeTexCoordsDecoder:: std::unique_ptr(new DataTypeT[num_components]); this->transform().Initialize(num_components); - const int corner_map_size = (int)this->mesh_data().data_to_corner_map()->size(); + const int corner_map_size = static_cast(this->mesh_data().data_to_corner_map()->size()); for (int p = 0; p < corner_map_size; ++p) { const CornerIndex corner_id = this->mesh_data().data_to_corner_map()->at(p); ComputePredictedValue(corner_id, out_data, p); diff --git a/src/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_tex_coords_encoder.h b/src/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_tex_coords_encoder.h index 0472f758..4fa8211e 100644 --- a/src/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_tex_coords_encoder.h +++ b/src/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_tex_coords_encoder.h @@ -90,7 +90,7 @@ class MeshPredictionSchemeTexCoordsEncoder Vector2f GetTexCoordForEntryId(int entry_id, const DataTypeT *data) const { const int data_offset = entry_id * num_components_; - return Vector2f((float)data[data_offset], (float)data[data_offset + 1]); + return Vector2f(static_cast(data[data_offset]), static_cast(data[data_offset + 1])); } void ComputePredictedValue(CornerIndex corner_id, const DataTypeT *data, @@ -117,7 +117,7 @@ bool MeshPredictionSchemeTexCoordsEncoder:: this->transform().Initialize(in_data, size, num_components); // We start processing from the end because this prediction uses data from // previous entries that could be overwritten when an entry is processed. - for (int p = (int)this->mesh_data().data_to_corner_map()->size() - 1; p >= 0; + for (int p = static_cast(this->mesh_data().data_to_corner_map()->size()) - 1; p >= 0; --p) { const CornerIndex corner_id = this->mesh_data().data_to_corner_map()->at(p); ComputePredictedValue(corner_id, in_data, p); @@ -133,7 +133,7 @@ template bool MeshPredictionSchemeTexCoordsEncoder:: EncodePredictionData(EncoderBuffer *buffer) { // Encode the delta-coded orientations using arithmetic coding. - const uint32_t num_orientations = (uint32_t)orientations_.size(); + const uint32_t num_orientations = static_cast(orientations_.size()); EncodeVarint(num_orientations, buffer); bool last_orientation = true; RAnsBitEncoder encoder; diff --git a/src/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_tex_coords_portable_decoder.h b/src/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_tex_coords_portable_decoder.h index a44d01fa..d17c0ae3 100644 --- a/src/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_tex_coords_portable_decoder.h +++ b/src/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_tex_coords_portable_decoder.h @@ -87,7 +87,7 @@ bool MeshPredictionSchemeTexCoordsPortableDecoder< predictor_.SetEntryToPointIdMap(entry_to_point_id_map); this->transform().Initialize(num_components); - const int corner_map_size = (int)this->mesh_data().data_to_corner_map()->size(); + const int corner_map_size = static_cast(this->mesh_data().data_to_corner_map()->size()); for (int p = 0; p < corner_map_size; ++p) { const CornerIndex corner_id = this->mesh_data().data_to_corner_map()->at(p); if (!predictor_.template ComputePredictedValue(corner_id, out_data, diff --git a/src/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_tex_coords_portable_encoder.h b/src/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_tex_coords_portable_encoder.h index b1e61334..dc031b52 100644 --- a/src/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_tex_coords_portable_encoder.h +++ b/src/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_tex_coords_portable_encoder.h @@ -90,7 +90,7 @@ bool MeshPredictionSchemeTexCoordsPortableEncodertransform().Initialize(in_data, size, num_components); // We start processing from the end because this prediction uses data from // previous entries that could be overwritten when an entry is processed. - for (int p = (int)(this->mesh_data().data_to_corner_map()->size() - 1); p >= 0; + for (int p = static_cast(this->mesh_data().data_to_corner_map()->size() - 1); p >= 0; --p) { const CornerIndex corner_id = this->mesh_data().data_to_corner_map()->at(p); predictor_.template ComputePredictedValue(corner_id, in_data, p); diff --git a/src/draco/compression/attributes/sequential_attribute_decoder.cc b/src/draco/compression/attributes/sequential_attribute_decoder.cc index 5e8c6b55..612e0841 100644 --- a/src/draco/compression/attributes/sequential_attribute_decoder.cc +++ b/src/draco/compression/attributes/sequential_attribute_decoder.cc @@ -61,7 +61,7 @@ const PointAttribute *SequentialAttributeDecoder::GetPortableAttribute() { if (!attribute_->is_mapping_identity() && portable_attribute_ && portable_attribute_->is_mapping_identity()) { portable_attribute_->SetExplicitMapping(attribute_->indices_map_size()); - for (PointIndex i(0); i < (uint32_t)attribute_->indices_map_size(); ++i) { + for (PointIndex i(0); i < static_cast(attribute_->indices_map_size()); ++i) { portable_attribute_->SetPointMapEntry(i, attribute_->mapped_index(i)); } } @@ -94,8 +94,8 @@ bool SequentialAttributeDecoder::InitPredictionScheme( bool SequentialAttributeDecoder::DecodeValues( const std::vector &point_ids, DecoderBuffer *in_buffer) { - const int32_t num_values = (int32_t)point_ids.size(); - const int entry_size = (int)attribute_->byte_stride(); + const int32_t num_values = static_cast(point_ids.size()); + const int entry_size = static_cast(attribute_->byte_stride()); std::unique_ptr value_data_ptr(new uint8_t[entry_size]); uint8_t *const value_data = value_data_ptr.get(); int out_byte_pos = 0; diff --git a/src/draco/compression/attributes/sequential_attribute_encoder.cc b/src/draco/compression/attributes/sequential_attribute_encoder.cc index 3edee8f9..cee0b403 100644 --- a/src/draco/compression/attributes/sequential_attribute_encoder.cc +++ b/src/draco/compression/attributes/sequential_attribute_encoder.cc @@ -59,7 +59,7 @@ bool SequentialAttributeEncoder::EncodeDataNeededByPortableTransform( bool SequentialAttributeEncoder::EncodeValues( const std::vector &point_ids, EncoderBuffer *out_buffer) { - const int entry_size = (int)attribute_->byte_stride(); + const int entry_size = static_cast(attribute_->byte_stride()); const std::unique_ptr value_data_ptr(new uint8_t[entry_size]); uint8_t *const value_data = value_data_ptr.get(); // Encode all attribute values in their native raw format. diff --git a/src/draco/compression/attributes/sequential_attribute_encoder.h b/src/draco/compression/attributes/sequential_attribute_encoder.h index ac873851..1683b38c 100644 --- a/src/draco/compression/attributes/sequential_attribute_encoder.h +++ b/src/draco/compression/attributes/sequential_attribute_encoder.h @@ -58,7 +58,7 @@ class SequentialAttributeEncoder { virtual bool IsLossyEncoder() const { return false; } - int NumParentAttributes() const { return (int)parent_attributes_.size(); } + int NumParentAttributes() const { return static_cast(parent_attributes_.size()); } int GetParentAttributeId(int i) const { return parent_attributes_[i]; } const PointAttribute *GetPortableAttribute() const { diff --git a/src/draco/compression/attributes/sequential_integer_attribute_decoder.cc b/src/draco/compression/attributes/sequential_integer_attribute_decoder.cc index 2ed8a1b5..022ffd5d 100644 --- a/src/draco/compression/attributes/sequential_integer_attribute_decoder.cc +++ b/src/draco/compression/attributes/sequential_integer_attribute_decoder.cc @@ -36,7 +36,7 @@ bool SequentialIntegerAttributeDecoder::TransformAttributeToOriginalFormat( decoder()->bitstream_version() < DRACO_BITSTREAM_VERSION(2, 0)) return true; // Don't revert the transform here for older files. #endif - return StoreValues((uint32_t)point_ids.size()); + return StoreValues(static_cast(point_ids.size())); } bool SequentialIntegerAttributeDecoder::DecodeValues( @@ -61,7 +61,7 @@ bool SequentialIntegerAttributeDecoder::DecodeValues( return false; #ifdef DRACO_BACKWARDS_COMPATIBILITY_SUPPORTED - const int32_t num_values = (uint32_t)point_ids.size(); + const int32_t num_values = static_cast(point_ids.size()); if (decoder() && decoder()->bitstream_version() < DRACO_BITSTREAM_VERSION(2, 0)) { // For older files, revert the transform right after we decode the data. @@ -90,7 +90,7 @@ bool SequentialIntegerAttributeDecoder::DecodeIntegerValues( return false; const size_t num_entries = point_ids.size(); const size_t num_values = num_entries * num_components; - PreparePortableAttribute((int)num_entries, num_components); + PreparePortableAttribute(static_cast(num_entries), num_components); int32_t *const portable_attribute_data = GetPortableAttributeData(); if (portable_attribute_data == nullptr) return false; @@ -99,7 +99,7 @@ bool SequentialIntegerAttributeDecoder::DecodeIntegerValues( return false; if (compressed > 0) { // Decode compressed values. - if (!DecodeSymbols((uint32_t)num_values, num_components, in_buffer, + if (!DecodeSymbols(static_cast(num_values), num_components, in_buffer, reinterpret_cast(portable_attribute_data))) return false; } else { @@ -118,7 +118,7 @@ bool SequentialIntegerAttributeDecoder::DecodeIntegerValues( } else { if (portable_attribute()->buffer()->data_size() < num_bytes * num_values) return false; - if (in_buffer->remaining_size() < (int64_t)num_bytes * (int64_t)num_values) + if (in_buffer->remaining_size() < static_cast(num_bytes) * static_cast(num_values)) return false; for (size_t i = 0; i < num_values; ++i) { in_buffer->Decode(portable_attribute_data + i, num_bytes); @@ -130,7 +130,7 @@ bool SequentialIntegerAttributeDecoder::DecodeIntegerValues( !prediction_scheme_->AreCorrectionsPositive())) { // Convert the values back to the original signed format. ConvertSymbolsToSignedInts( - reinterpret_cast(portable_attribute_data), (int)num_values, + reinterpret_cast(portable_attribute_data), static_cast(num_values), portable_attribute_data); } @@ -141,7 +141,7 @@ bool SequentialIntegerAttributeDecoder::DecodeIntegerValues( if (num_values > 0) { if (!prediction_scheme_->ComputeOriginalValues( - portable_attribute_data, portable_attribute_data, (int)num_values, + portable_attribute_data, portable_attribute_data, static_cast(num_values), num_components, point_ids.data())) { return false; } diff --git a/src/draco/compression/attributes/sequential_integer_attribute_encoder.cc b/src/draco/compression/attributes/sequential_integer_attribute_encoder.cc index 9d283715..1ad2f5e8 100644 --- a/src/draco/compression/attributes/sequential_integer_attribute_encoder.cc +++ b/src/draco/compression/attributes/sequential_integer_attribute_encoder.cc @@ -118,7 +118,7 @@ bool SequentialIntegerAttributeEncoder::EncodeValues( } const int num_components = portable_attribute()->num_components(); - const int num_values = (int)(num_components * portable_attribute()->size()); + const int num_values = static_cast(num_components * portable_attribute()->size()); const int32_t *const portable_attribute_data = GetPortableAttributeData(); // We need to keep the portable data intact, but several encoding steps can @@ -152,7 +152,7 @@ bool SequentialIntegerAttributeEncoder::EncodeValues( 10 - encoder()->options()->GetSpeed()); } if (!EncodeSymbols(reinterpret_cast(encoded_data.data()), - (int)point_ids.size() * num_components, num_components, + static_cast(point_ids.size()) * num_components, num_components, &symbol_encoding_options, out_buffer)) { return false; } @@ -162,7 +162,7 @@ bool SequentialIntegerAttributeEncoder::EncodeValues( // To compute the maximum bit-length, first OR all values. uint32_t masked_value = 0; - for (uint32_t i = 0; i < (uint32_t)num_values; ++i) { + for (uint32_t i = 0; i < static_cast(num_values); ++i) { masked_value |= encoded_data[i]; } // Compute the msb of the ORed value. @@ -178,7 +178,7 @@ bool SequentialIntegerAttributeEncoder::EncodeValues( if (num_bytes == DataTypeLength(DT_INT32)) { out_buffer->Encode(encoded_data.data(), sizeof(int32_t) * num_values); } else { - for (uint32_t i = 0; i < (uint32_t)num_values; ++i) { + for (uint32_t i = 0; i < static_cast(num_values); ++i) { out_buffer->Encode(encoded_data.data() + i, num_bytes); } } @@ -194,7 +194,7 @@ bool SequentialIntegerAttributeEncoder::PrepareValues( // Convert all values to int32_t format. const PointAttribute *const attrib = attribute(); const int num_components = attrib->num_components(); - const int num_entries = (int)point_ids.size(); + const int num_entries = static_cast(point_ids.size()); PreparePortableAttribute(num_entries, num_components, num_points); int32_t dst_index = 0; int32_t *const portable_attribute_data = GetPortableAttributeData(); diff --git a/src/draco/compression/mesh/mesh_edgebreaker_decoder_impl.cc b/src/draco/compression/mesh/mesh_edgebreaker_decoder_impl.cc index 4403c2c2..7f733d0b 100644 --- a/src/draco/compression/mesh/mesh_edgebreaker_decoder_impl.cc +++ b/src/draco/compression/mesh/mesh_edgebreaker_decoder_impl.cc @@ -272,7 +272,7 @@ bool MeshEdgeBreakerDecoderImpl::DecodeConnectivity() { if (num_faces > std::numeric_limits::max() / 3) return false; // Draco cannot handle this many faces. - if ((uint32_t)num_encoded_vertices_ > num_faces * 3) { + if (static_cast(num_encoded_vertices_) > num_faces * 3) { return false; // There cannot be more vertices than 3 * num_faces. } uint8_t num_attribute_data; @@ -491,7 +491,7 @@ int MeshEdgeBreakerDecoderImpl::DecodeConnectivity( std::vector invalid_vertices; const bool remove_invalid_vertices = attribute_data_.empty(); - int max_num_vertices = (int)is_vert_hole_.size(); + int max_num_vertices = static_cast(is_vert_hole_.size()); int num_faces = 0; for (int symbol_id = 0; symbol_id < num_symbols; ++symbol_id) { const FaceIndex face(num_faces++); @@ -865,7 +865,7 @@ MeshEdgeBreakerDecoderImpl::DecodeHoleAndTopologySplitEvents( return -1; } if (num_topology_splits > 0) { - if (num_topology_splits > (uint32_t)corner_table_->num_faces()) + if (num_topology_splits > static_cast(corner_table_->num_faces())) return -1; #ifdef DRACO_BACKWARDS_COMPATIBILITY_SUPPORTED if (decoder_->bitstream_version() < DRACO_BITSTREAM_VERSION(1, 2)) { @@ -949,7 +949,7 @@ MeshEdgeBreakerDecoderImpl::DecodeHoleAndTopologySplitEvents( } } } - return (int32_t)decoder_buffer->decoded_size(); + return static_cast(decoder_buffer->decoded_size()); } #ifdef DRACO_BACKWARDS_COMPATIBILITY_SUPPORTED @@ -1090,7 +1090,7 @@ bool MeshEdgeBreakerDecoderImpl::AssignPointsToCorners( // a new point id whenever one of the attributes change. c = deduplication_first_corner; // Create a new point. - corner_to_point_map[c.value()] = (uint32_t)point_to_corner_map.size(); + corner_to_point_map[c.value()] = static_cast(point_to_corner_map.size()); point_to_corner_map.push_back(c.value()); // Traverse in CW direction. CornerIndex prev_c = c; @@ -1107,7 +1107,7 @@ bool MeshEdgeBreakerDecoderImpl::AssignPointsToCorners( } } if (attribute_seam) { - corner_to_point_map[c.value()] = (uint32_t)point_to_corner_map.size(); + corner_to_point_map[c.value()] = static_cast(point_to_corner_map.size()); point_to_corner_map.push_back(c.value()); } else { corner_to_point_map[c.value()] = corner_to_point_map[prev_c.value()]; @@ -1125,7 +1125,7 @@ bool MeshEdgeBreakerDecoderImpl::AssignPointsToCorners( } decoder_->mesh()->SetFace(f, face); } - decoder_->point_cloud()->set_num_points((uint32_t)point_to_corner_map.size()); + decoder_->point_cloud()->set_num_points(static_cast(point_to_corner_map.size())); return true; } diff --git a/src/draco/compression/mesh/mesh_edgebreaker_decoder_impl.h b/src/draco/compression/mesh/mesh_edgebreaker_decoder_impl.h index ca8174d7..02e07236 100644 --- a/src/draco/compression/mesh/mesh_edgebreaker_decoder_impl.h +++ b/src/draco/compression/mesh/mesh_edgebreaker_decoder_impl.h @@ -87,7 +87,7 @@ class MeshEdgeBreakerDecoderImpl : public MeshEdgeBreakerDecoderImplInterface { int *out_encoder_split_symbol_id) { if (topology_split_data_.size() == 0) return false; - if (topology_split_data_.back().source_symbol_id > (uint32_t)encoder_symbol_id) { + if (topology_split_data_.back().source_symbol_id > static_cast(encoder_symbol_id)) { // Something is wrong; if the desired source symbol is greater than the // current encoder_symbol_id, we missed it, or the input was tampered // (|encoder_symbol_id| keeps decreasing). diff --git a/src/draco/compression/mesh/mesh_edgebreaker_encoder_impl.cc b/src/draco/compression/mesh/mesh_edgebreaker_encoder_impl.cc index 96c9a0fa..7c2012eb 100644 --- a/src/draco/compression/mesh/mesh_edgebreaker_encoder_impl.cc +++ b/src/draco/compression/mesh/mesh_edgebreaker_encoder_impl.cc @@ -323,7 +323,7 @@ bool MeshEdgeBreakerEncoderImpl::EncodeConnectivity() { if (!InitAttributeData()) return false; - const uint8_t num_attribute_data = (uint8_t)attribute_data_.size(); + const uint8_t num_attribute_data = static_cast(attribute_data_.size()); encoder_->buffer()->Encode(num_attribute_data); traversal_encoder_.SetNumAttributeData(num_attribute_data); @@ -426,7 +426,7 @@ bool MeshEdgeBreakerEncoderImpl::EncodeConnectivity() { template bool MeshEdgeBreakerEncoderImpl::EncodeSplitData() { - uint32_t num_events = (uint32_t)topology_split_event_data_.size(); + uint32_t num_events = static_cast(topology_split_event_data_.size()); EncodeVarint(num_events, encoder_->buffer()); if (num_events > 0) { // Encode split symbols using delta and varint coding. Split edges are @@ -706,7 +706,7 @@ bool MeshEdgeBreakerEncoderImpl::FindHoles() { } // Else we found a new open boundary and we are going to traverse along it // and mark all visited vertices. - const int boundary_id = (int)visited_holes_.size(); + const int boundary_id = static_cast(visited_holes_.size()); visited_holes_.push_back(false); CornerIndex corner_id = i; diff --git a/src/draco/compression/mesh/mesh_edgebreaker_traversal_decoder.h b/src/draco/compression/mesh/mesh_edgebreaker_traversal_decoder.h index b2cd3eea..636028b9 100644 --- a/src/draco/compression/mesh/mesh_edgebreaker_traversal_decoder.h +++ b/src/draco/compression/mesh/mesh_edgebreaker_traversal_decoder.h @@ -138,7 +138,7 @@ class MeshEdgeBreakerTraversalDecoder { if (!symbol_buffer_.StartBitDecoding(true, &traversal_size)) return false; buffer_ = symbol_buffer_; - if (traversal_size > (uint64_t)buffer_.remaining_size()) + if (traversal_size > static_cast(buffer_.remaining_size())) return false; buffer_.Advance(traversal_size); return true; @@ -153,7 +153,7 @@ class MeshEdgeBreakerTraversalDecoder { if (!start_face_buffer_.StartBitDecoding(true, &traversal_size)) return false; buffer_ = start_face_buffer_; - if (traversal_size > (uint64_t)buffer_.remaining_size()) + if (traversal_size > static_cast(buffer_.remaining_size())) return false; buffer_.Advance(traversal_size); return true; diff --git a/src/draco/compression/mesh/mesh_edgebreaker_traversal_encoder.h b/src/draco/compression/mesh/mesh_edgebreaker_traversal_encoder.h index 93a8d471..030000f5 100644 --- a/src/draco/compression/mesh/mesh_edgebreaker_traversal_encoder.h +++ b/src/draco/compression/mesh/mesh_edgebreaker_traversal_encoder.h @@ -87,7 +87,7 @@ class MeshEdgeBreakerTraversalEncoder { } // Returns the number of encoded symbols. - int NumEncodedSymbols() const { return (int)symbols_.size(); } + int NumEncodedSymbols() const { return static_cast(symbols_.size()); } const EncoderBuffer &buffer() const { return traversal_buffer_; } @@ -98,7 +98,7 @@ class MeshEdgeBreakerTraversalEncoder { // It's guaranteed that each face will need only up to 3 bits. traversal_buffer_.StartBitEncoding( encoder_impl_->GetEncoder()->mesh()->num_faces() * 3, true); - for (int i = (int)(symbols_.size() - 1); i >= 0; --i) { + for (int i = static_cast(symbols_.size() - 1); i >= 0; --i) { traversal_buffer_.EncodeLeastSignificantBits32( edge_breaker_topology_bit_pattern_length[symbols_[i]], symbols_[i]); } diff --git a/src/draco/compression/mesh/mesh_edgebreaker_traversal_predictive_encoder.h b/src/draco/compression/mesh/mesh_edgebreaker_traversal_predictive_encoder.h index db35f914..6d8af52d 100644 --- a/src/draco/compression/mesh/mesh_edgebreaker_traversal_predictive_encoder.h +++ b/src/draco/compression/mesh/mesh_edgebreaker_traversal_predictive_encoder.h @@ -145,7 +145,7 @@ class MeshEdgeBreakerTraversalPredictiveEncoder // Store the predictions. BinaryEncoder prediction_encoder; prediction_encoder.StartEncoding(); - for (int i = (int)predictions_.size() - 1; i >= 0; --i) { + for (int i = static_cast(predictions_.size()) - 1; i >= 0; --i) { prediction_encoder.EncodeBit(predictions_[i]); } prediction_encoder.EndEncoding(GetOutputBuffer()); diff --git a/src/draco/compression/mesh/mesh_edgebreaker_traversal_valence_decoder.h b/src/draco/compression/mesh/mesh_edgebreaker_traversal_valence_decoder.h index 2a29e4b0..ab861d7d 100644 --- a/src/draco/compression/mesh/mesh_edgebreaker_traversal_valence_decoder.h +++ b/src/draco/compression/mesh/mesh_edgebreaker_traversal_valence_decoder.h @@ -66,7 +66,7 @@ class MeshEdgeBreakerTraversalValenceDecoder if (!DecodeVarint(&num_split_symbols, out_buffer)) return false; } - if (num_split_symbols >= (uint32_t)num_vertices_) + if (num_split_symbols >= static_cast(num_vertices_)) return false; int8_t mode; diff --git a/src/draco/compression/mesh/mesh_edgebreaker_traversal_valence_encoder.h b/src/draco/compression/mesh/mesh_edgebreaker_traversal_valence_encoder.h index 1aa309dd..17397a1a 100644 --- a/src/draco/compression/mesh/mesh_edgebreaker_traversal_valence_encoder.h +++ b/src/draco/compression/mesh/mesh_edgebreaker_traversal_valence_encoder.h @@ -51,7 +51,7 @@ class MeshEdgeBreakerTraversalValenceEncoder // Initialize valences of all vertices. vertex_valences_.resize(corner_table_->num_vertices()); - for (VertexIndex i(0); i < (uint32_t)vertex_valences_.size(); ++i) { + for (VertexIndex i(0); i < static_cast(vertex_valences_.size()); ++i) { vertex_valences_[i] = corner_table_->Valence(VertexIndex(i)); } @@ -126,7 +126,7 @@ class MeshEdgeBreakerTraversalValenceEncoder // Create a new vertex for the right side and count the number of // faces that should be attached to this vertex. - const int new_vert_id = (int)vertex_valences_.size(); + const int new_vert_id = static_cast(vertex_valences_.size()); int num_right_faces = 0; act_c = corner_table_->Opposite(next); @@ -187,9 +187,9 @@ class MeshEdgeBreakerTraversalValenceEncoder // Store the contexts. for (int i = 0; i < context_symbols_.size(); ++i) { - EncodeVarint((uint32_t)context_symbols_[i].size(), GetOutputBuffer()); + EncodeVarint(static_cast(context_symbols_[i].size()), GetOutputBuffer()); if (context_symbols_[i].size() > 0) { - EncodeSymbols(context_symbols_[i].data(), (int)context_symbols_[i].size(), 1, + EncodeSymbols(context_symbols_[i].data(), static_cast(context_symbols_[i].size()), 1, nullptr, GetOutputBuffer()); } } diff --git a/src/draco/compression/mesh/mesh_sequential_encoder.cc b/src/draco/compression/mesh/mesh_sequential_encoder.cc index 5a0fd525..dbaa0e77 100644 --- a/src/draco/compression/mesh/mesh_sequential_encoder.cc +++ b/src/draco/compression/mesh/mesh_sequential_encoder.cc @@ -115,7 +115,7 @@ bool MeshSequentialEncoder::CompressAndEncodeIndices() { last_index_value = index_value; } } - EncodeSymbols(indices_buffer.data(), (int)indices_buffer.size(), 1, nullptr, + EncodeSymbols(indices_buffer.data(), static_cast(indices_buffer.size()), 1, nullptr, buffer()); return true; } diff --git a/src/draco/compression/point_cloud/algorithms/dynamic_integer_points_kd_tree_encoder.h b/src/draco/compression/point_cloud/algorithms/dynamic_integer_points_kd_tree_encoder.h index 4b49879d..d1a744c7 100644 --- a/src/draco/compression/point_cloud/algorithms/dynamic_integer_points_kd_tree_encoder.h +++ b/src/draco/compression/point_cloud/algorithms/dynamic_integer_points_kd_tree_encoder.h @@ -157,7 +157,7 @@ class DynamicIntegerPointsKdTreeEncoder { end(end_), last_axis(last_axis_), stack_pos(stack_pos_) { - num_remaining_points = (uint32_t)(end - begin); + num_remaining_points = static_cast(end - begin); } RandomAccessIteratorT begin; @@ -187,7 +187,7 @@ bool DynamicIntegerPointsKdTreeEncoder::EncodePoints( RandomAccessIteratorT begin, RandomAccessIteratorT end, const uint32_t &bit_length, EncoderBuffer *buffer) { bit_length_ = bit_length; - num_points_ = (uint32_t)(end - begin); + num_points_ = static_cast(end - begin); buffer->Encode(bit_length_); buffer->Encode(num_points_); @@ -234,7 +234,7 @@ DynamicIntegerPointsKdTreeEncoder::GetAndEncodeAxis( } } } else { - const uint32_t size = (uint32_t)(end - begin); + const uint32_t size = static_cast(end - begin); for (uint32_t i = 0; i < dimension_; i++) { deviations_[i] = 0; num_remaining_bits_[i] = bit_length_ - levels[i]; @@ -293,7 +293,7 @@ void DynamicIntegerPointsKdTreeEncoder::EncodeInternal( const uint32_t axis = GetAndEncodeAxis(begin, end, old_base, levels, last_axis); const uint32_t level = levels[axis]; - const uint32_t num_remaining_points = (uint32_t)(end - begin); + const uint32_t num_remaining_points = static_cast(end - begin); // If this happens all axis are subdivided to the end. if ((bit_length_ - level) == 0) @@ -334,8 +334,8 @@ void DynamicIntegerPointsKdTreeEncoder::EncodeInternal( // Encode number of points in first and second half. const int required_bits = bits::MostSignificantBit(num_remaining_points); - const uint32_t first_half = (uint32_t)(split - begin); - const uint32_t second_half = (uint32_t)(end - split); + const uint32_t first_half = static_cast(split - begin); + const uint32_t second_half = static_cast(end - split); const bool left = first_half < second_half; if (first_half != second_half) diff --git a/src/draco/compression/point_cloud/point_cloud_decoder.h b/src/draco/compression/point_cloud/point_cloud_decoder.h index a07fbbda..abcb5e06 100644 --- a/src/draco/compression/point_cloud/point_cloud_decoder.h +++ b/src/draco/compression/point_cloud/point_cloud_decoder.h @@ -66,7 +66,7 @@ class PointCloudDecoder { return attributes_decoders_[dec_id].get(); } int32_t num_attributes_decoders() const { - return (int32_t)attributes_decoders_.size(); + return static_cast(attributes_decoders_.size()); } // Get a mutable pointer to the decoded point cloud. This is intended to be diff --git a/src/draco/compression/point_cloud/point_cloud_encoder.h b/src/draco/compression/point_cloud/point_cloud_encoder.h index 035a2bed..e3f60451 100644 --- a/src/draco/compression/point_cloud/point_cloud_encoder.h +++ b/src/draco/compression/point_cloud/point_cloud_encoder.h @@ -49,7 +49,7 @@ class PointCloudEncoder { // in the provided EncoderOptions. size_t num_encoded_points() const { return num_encoded_points_; } - int num_attributes_encoders() const { return (int)attributes_encoders_.size(); } + int num_attributes_encoders() const { return static_cast(attributes_encoders_.size()); } AttributesEncoder *attributes_encoder(int i) { return attributes_encoders_[i].get(); } @@ -57,7 +57,7 @@ class PointCloudEncoder { // Adds a new attribute encoder, returning its id. int AddAttributesEncoder(std::unique_ptr att_enc) { attributes_encoders_.push_back(std::move(att_enc)); - return (int)(attributes_encoders_.size() - 1); + return static_cast(attributes_encoders_.size() - 1); } // Marks one attribute as a parent of another attribute. Must be called after diff --git a/src/draco/core/bit_coders/direct_bit_encoder.cc b/src/draco/core/bit_coders/direct_bit_encoder.cc index 6b810c9b..8943d2d0 100644 --- a/src/draco/core/bit_coders/direct_bit_encoder.cc +++ b/src/draco/core/bit_coders/direct_bit_encoder.cc @@ -24,7 +24,7 @@ void DirectBitEncoder::StartEncoding() { Clear(); } void DirectBitEncoder::EndEncoding(EncoderBuffer *target_buffer) { bits_.push_back(local_bits_); - const uint32_t size_in_byte = (uint32_t)bits_.size() * 4; + const uint32_t size_in_byte = static_cast(bits_.size()) * 4; target_buffer->Encode(size_in_byte); target_buffer->Encode(bits_.data(), size_in_byte); Clear(); diff --git a/src/draco/core/bit_coders/symbol_bit_encoder.cc b/src/draco/core/bit_coders/symbol_bit_encoder.cc index 49b20ec5..8f8c70aa 100644 --- a/src/draco/core/bit_coders/symbol_bit_encoder.cc +++ b/src/draco/core/bit_coders/symbol_bit_encoder.cc @@ -17,7 +17,7 @@ void SymbolBitEncoder::EncodeLeastSignificantBits32(int nbits, uint32_t value) { void SymbolBitEncoder::EndEncoding(EncoderBuffer *target_buffer) { target_buffer->Encode(static_cast(symbols_.size())); - EncodeSymbols(symbols_.data(), (int)symbols_.size(), 1, nullptr, target_buffer); + EncodeSymbols(symbols_.data(), static_cast(symbols_.size()), 1, nullptr, target_buffer); Clear(); } diff --git a/src/draco/core/encoder_buffer.cc b/src/draco/core/encoder_buffer.cc index 7b21d81e..a5e936fd 100644 --- a/src/draco/core/encoder_buffer.cc +++ b/src/draco/core/encoder_buffer.cc @@ -69,7 +69,7 @@ void EncoderBuffer::EndBitEncoding() { EncoderBuffer var_size_buffer; EncodeVarint(encoded_bytes, &var_size_buffer); - const uint32_t size_len = (uint32_t)var_size_buffer.size(); + const uint32_t size_len = static_cast(var_size_buffer.size()); char *const dst = out_mem + size_len; const char *const src = out_mem + sizeof(uint64_t); memmove(dst, src, encoded_bytes); diff --git a/src/draco/core/hash_utils.cc b/src/draco/core/hash_utils.cc index 95c78b34..9a78c2cf 100644 --- a/src/draco/core/hash_utils.cc +++ b/src/draco/core/hash_utils.cc @@ -23,12 +23,12 @@ namespace draco { // Will never return 1 or 0. uint64_t FingerprintString(const char *s, size_t len) { const uint64_t seed = 0x87654321; - const int hash_loop_count = (int)(len / 8) + 1; + const int hash_loop_count = static_cast(len / 8) + 1; uint64_t hash = seed; for (int i = 0; i < hash_loop_count; ++i) { const int off = i * 8; - const int num_chars_left = (int)len - (off); + const int num_chars_left = static_cast(len) - off; uint64_t new_hash = seed; if (num_chars_left > 7) { diff --git a/src/draco/core/options.cc b/src/draco/core/options.cc index d067312f..c4f6d6a6 100644 --- a/src/draco/core/options.cc +++ b/src/draco/core/options.cc @@ -54,7 +54,7 @@ float Options::GetFloat(const std::string &name, float default_val) const { const auto it = options_.find(name); if (it == options_.end()) return default_val; - return (float)std::atof(it->second.c_str()); + return static_cast(std::atof(it->second.c_str())); } bool Options::GetBool(const std::string &name) const { diff --git a/src/draco/core/rans_symbol_decoder.h b/src/draco/core/rans_symbol_decoder.h index 31a96582..f7ce19f7 100644 --- a/src/draco/core/rans_symbol_decoder.h +++ b/src/draco/core/rans_symbol_decoder.h @@ -130,13 +130,13 @@ bool RAnsSymbolDecoder::StartDecoding( if (!DecodeVarint(&bytes_encoded, buffer)) return false; } - if (bytes_encoded > (uint64_t)buffer->remaining_size()) + if (bytes_encoded > static_cast(buffer->remaining_size())) return false; const uint8_t *const data_head = reinterpret_cast(buffer->data_head()); // Advance the buffer past the rANS data. buffer->Advance(bytes_encoded); - if (ans_.read_init(data_head, (int)bytes_encoded) != 0) + if (ans_.read_init(data_head, static_cast(bytes_encoded)) != 0) return false; return true; } diff --git a/src/draco/core/rans_symbol_encoder.h b/src/draco/core/rans_symbol_encoder.h index da907432..b5ed5a16 100644 --- a/src/draco/core/rans_symbol_encoder.h +++ b/src/draco/core/rans_symbol_encoder.h @@ -264,7 +264,7 @@ void RAnsSymbolEncoder::EndEncoding( const uint64_t bytes_written = static_cast(ans_.write_end()); EncoderBuffer var_size_buffer; EncodeVarint(bytes_written, &var_size_buffer); - const uint32_t size_len = (uint32_t)var_size_buffer.size(); + const uint32_t size_len = static_cast(var_size_buffer.size()); char *const dst = src + size_len; memmove(dst, src, bytes_written); diff --git a/src/draco/core/shannon_entropy.cc b/src/draco/core/shannon_entropy.cc index ea124a4b..63c17901 100644 --- a/src/draco/core/shannon_entropy.cc +++ b/src/draco/core/shannon_entropy.cc @@ -30,7 +30,7 @@ int64_t ComputeShannonEntropy(const uint32_t *symbols, int num_symbols, if (out_num_unique_symbols) *out_num_unique_symbols = num_unique_symbols; // Entropy is always negative. - return (int64_t)(-total_bits); + return static_cast(-total_bits); } double ComputeBinaryShannonEntropy(uint32_t num_values, @@ -94,7 +94,7 @@ ShannonEntropyTracker::EntropyData ShannonEntropyTracker::UpdateSymbols( old_symbol_entropy_norm = frequency * std::log2(frequency); } else if (frequency == 0) { ret_data.num_unique_symbols++; - if (symbol > (uint32_t)ret_data.max_symbol) { + if (symbol > static_cast(ret_data.max_symbol)) { ret_data.max_symbol = symbol; } } @@ -129,8 +129,8 @@ int64_t ShannonEntropyTracker::GetNumberOfDataBits( // // and number of bits required for the entropy is: num_values * entropy // - return (int64_t)ceil(entropy_data.num_values * std::log2(entropy_data.num_values) - - entropy_data.entropy_norm); + return static_cast(ceil(entropy_data.num_values * std::log2(entropy_data.num_values) - + entropy_data.entropy_norm)); } int64_t ShannonEntropyTracker::GetNumberOfRAnsTableBits( diff --git a/src/draco/core/symbol_encoding.cc b/src/draco/core/symbol_encoding.cc index 1a667619..e4481ce1 100644 --- a/src/draco/core/symbol_encoding.cc +++ b/src/draco/core/symbol_encoding.cc @@ -81,7 +81,7 @@ static int64_t ApproximateTaggedSchemeBits( // Compute the number of entropy bits for tags. int num_unique_symbols; const int64_t tag_bits = ComputeShannonEntropy( - bit_lengths.data(), (int)bit_lengths.size(), 32, &num_unique_symbols); + bit_lengths.data(), static_cast(bit_lengths.size()), 32, &num_unique_symbols); const int64_t tag_table_bits = ApproximateRAnsFrequencyTableBits(num_unique_symbols, num_unique_symbols); return tag_bits + tag_table_bits + total_bit_length * num_components; @@ -247,7 +247,7 @@ bool EncodeRawSymbolsInternal(const uint32_t *symbols, int num_values, } SymbolEncoderT encoder; - encoder.Create(frequencies.data(), (int)frequencies.size(), target_buffer); + encoder.Create(frequencies.data(), static_cast(frequencies.size()), target_buffer); encoder.StartEncoding(target_buffer); // Encode all values. if (SymbolEncoderT::needs_reverse_encoding()) { diff --git a/src/draco/io/obj_decoder.cc b/src/draco/io/obj_decoder.cc index 50becf9b..9677255c 100644 --- a/src/draco/io/obj_decoder.cc +++ b/src/draco/io/obj_decoder.cc @@ -194,7 +194,7 @@ Status ObjDecoder::DecodeInternal() { va.Init(GeometryAttribute::GENERIC, nullptr, 1, DT_UINT32, false, 4, 0); } sub_obj_att_id_ = - out_point_cloud_->AddAttribute(va, false, (uint32_t)obj_name_to_id_.size()); + out_point_cloud_->AddAttribute(va, false, static_cast(obj_name_to_id_.size())); // Fill the sub object id entries. for (const auto &itr : obj_name_to_id_) { const AttributeValueIndex i(itr.second); @@ -515,7 +515,7 @@ bool ObjDecoder::ParseObject(Status *status) { return true; // Ignore empty name entries. auto it = obj_name_to_id_.find(obj_name); if (it == obj_name_to_id_.end()) { - const int num_obj = (int)obj_name_to_id_.size(); + const int num_obj = static_cast(obj_name_to_id_.size()); obj_name_to_id_[obj_name] = num_obj; last_sub_obj_id_ = num_obj; } else { diff --git a/src/draco/io/obj_encoder.cc b/src/draco/io/obj_encoder.cc index c4e58685..807506e3 100644 --- a/src/draco/io/obj_encoder.cc +++ b/src/draco/io/obj_encoder.cc @@ -165,7 +165,7 @@ bool ObjEncoder::EncodePositions() { if (att == nullptr || att->size() == 0) return false; // Position attribute must be valid. std::array value; - for (AttributeValueIndex i(0); i < (uint32_t)att->size(); ++i) { + for (AttributeValueIndex i(0); i < static_cast(att->size()); ++i) { if (!att->ConvertValue(i, &value[0])) return false; buffer()->Encode("v ", 2); @@ -182,7 +182,7 @@ bool ObjEncoder::EncodeTextureCoordinates() { if (att == nullptr || att->size() == 0) return true; // It's OK if we don't have texture coordinates. std::array value; - for (AttributeValueIndex i(0); i < (uint32_t)att->size(); ++i) { + for (AttributeValueIndex i(0); i < static_cast(att->size()); ++i) { if (!att->ConvertValue(i, &value[0])) return false; buffer()->Encode("vt ", 3); @@ -199,7 +199,7 @@ bool ObjEncoder::EncodeNormals() { if (att == nullptr || att->size() == 0) return true; // It's OK if we don't have normals. std::array value; - for (AttributeValueIndex i(0); i < (uint32_t)att->size(); ++i) { + for (AttributeValueIndex i(0); i < static_cast(att->size()); ++i) { if (!att->ConvertValue(i, &value[0])) return false; buffer()->Encode("vn ", 3); diff --git a/src/draco/io/parser_utils.cc b/src/draco/io/parser_utils.cc index ec728a3a..e68abb1f 100644 --- a/src/draco/io/parser_utils.cc +++ b/src/draco/io/parser_utils.cc @@ -25,7 +25,7 @@ namespace parser { void SkipCharacters(DecoderBuffer *buffer, const char *skip_chars) { if (skip_chars == nullptr) return; - const int num_skip_chars = (int)strlen(skip_chars); + const int num_skip_chars = static_cast(strlen(skip_chars)); char c; while (buffer->Peek(&c)) { // Check all characters in the pattern. @@ -132,7 +132,7 @@ bool ParseFloat(DecoderBuffer *buffer, float *value) { } } - *value = (sign < 0) ? (float)-v : (float)v; + *value = (sign < 0) ? static_cast(-v) : static_cast(v); return true; } diff --git a/src/draco/io/ply_decoder.cc b/src/draco/io/ply_decoder.cc index 6f31921d..1a2b6a37 100644 --- a/src/draco/io/ply_decoder.cc +++ b/src/draco/io/ply_decoder.cc @@ -108,7 +108,7 @@ bool PlyDecoder::DecodeFaceData(const PlyElement *face_element) { if (list_size != 3) continue; // All non-triangular faces are skipped. for (int64_t c = 0; c < 3; ++c) - face[c] = vertex_index_reader.ReadValue((int)(list_offset + c)); + face[c] = vertex_index_reader.ReadValue(static_cast(list_offset + c)); out_mesh_->SetFace(face_index, face); face_index++; } @@ -127,7 +127,7 @@ bool PlyDecoder::ReadPropertiesToAttribute( new PlyPropertyReader(properties[prop]))); } std::vector memory(properties.size()); - for (PointIndex::ValueType i = 0; i < (uint32_t)num_vertices; ++i) { + for (PointIndex::ValueType i = 0; i < static_cast(num_vertices); ++i) { for (int prop = 0; prop < properties.size(); ++prop) { memory[prop] = readers[prop]->ReadValue(i); } diff --git a/src/draco/io/ply_reader.cc b/src/draco/io/ply_reader.cc index cbefc501..f924550e 100644 --- a/src/draco/io/ply_reader.cc +++ b/src/draco/io/ply_reader.cc @@ -120,7 +120,7 @@ bool PlyReader::ParseElement(DecoderBuffer *buffer) { } else { return false; } - element_index_[element_name] = (uint32_t)elements_.size(); + element_index_[element_name] = static_cast(elements_.size()); elements_.emplace_back(PlyElement(element_name, count)); *buffer = line_buffer; return true; diff --git a/src/draco/io/ply_reader.h b/src/draco/io/ply_reader.h index 84524b90..8d0f21ff 100644 --- a/src/draco/io/ply_reader.h +++ b/src/draco/io/ply_reader.h @@ -79,10 +79,10 @@ class PlyElement { public: PlyElement(const std::string &name, int64_t num_entries); void AddProperty(const PlyProperty &prop) { - property_index_[prop.name()] = (int)properties_.size(); + property_index_[prop.name()] = static_cast(properties_.size()); properties_.emplace_back(prop); if (!properties_.back().is_list()) - properties_.back().ReserveData((int)num_entries_); + properties_.back().ReserveData(static_cast(num_entries_)); } const PlyProperty *GetPropertyByName(const std::string &name) const { @@ -92,8 +92,8 @@ class PlyElement { return nullptr; } - int num_properties() const { return (int)properties_.size(); } - int num_entries() const { return (int)num_entries_; } + int num_properties() const { return static_cast(properties_.size()); } + int num_entries() const { return static_cast(num_entries_); } const PlyProperty &property(int prop_index) const { return properties_[prop_index]; } @@ -120,7 +120,7 @@ class PlyReader { return nullptr; } - int num_elements() const { return (int)elements_.size(); } + int num_elements() const { return static_cast(elements_.size()); } const PlyElement &element(int element_index) const { return elements_[element_index]; } diff --git a/src/draco/mesh/corner_table.cc b/src/draco/mesh/corner_table.cc index 6b96c8b2..63d4965c 100644 --- a/src/draco/mesh/corner_table.cc +++ b/src/draco/mesh/corner_table.cc @@ -39,7 +39,7 @@ bool CornerTable::Initialize( valence_cache_.ClearValenceCache(); valence_cache_.ClearValenceCacheInaccurate(); corner_to_vertex_map_.resize(faces.size() * 3); - for (FaceIndex fi(0); fi < (uint32_t)faces.size(); ++fi) { + for (FaceIndex fi(0); fi < static_cast(faces.size()); ++fi) { for (int i = 0; i < 3; ++i) { corner_to_vertex_map_[FirstCorner(fi) + i] = faces[fi][i]; } @@ -59,7 +59,7 @@ bool CornerTable::Reset(int num_faces) { bool CornerTable::Reset(int num_faces, int num_vertices) { if (num_faces < 0 || num_vertices < 0) return false; - if ((unsigned int)num_faces > std::numeric_limits::max() / 3) + if (static_cast(num_faces) > std::numeric_limits::max() / 3) return false; corner_to_vertex_map_.assign(num_faces * 3, kInvalidVertexIndex); opposite_corners_.assign(num_faces * 3, kInvalidCornerIndex); @@ -189,7 +189,7 @@ bool CornerTable::ComputeOppositeCorners(int *num_vertices) { opposite_corners_[opposite_c] = c; } } - *num_vertices = (int)num_corners_on_vertices.size(); + *num_vertices = static_cast(num_corners_on_vertices.size()); return true; } diff --git a/src/draco/mesh/corner_table.h b/src/draco/mesh/corner_table.h index 37a5f02a..f46b7c9d 100644 --- a/src/draco/mesh/corner_table.h +++ b/src/draco/mesh/corner_table.h @@ -70,9 +70,9 @@ class CornerTable { // Resets the corner table to the given number of invalid faces and vertices. bool Reset(int num_faces, int num_vertices); - inline int num_vertices() const { return (int)vertex_corners_.size(); } - inline int num_corners() const { return (int)corner_to_vertex_map_.size(); } - inline int num_faces() const { return (int)(corner_to_vertex_map_.size() / 3); } + inline int num_vertices() const { return static_cast(vertex_corners_.size()); } + inline int num_corners() const { return static_cast(corner_to_vertex_map_.size()); } + inline int num_faces() const { return static_cast(corner_to_vertex_map_.size() / 3); } inline CornerIndex Opposite(CornerIndex corner) const { if (corner == kInvalidCornerIndex) @@ -141,7 +141,7 @@ class CornerTable { // Returns the parent vertex index of a given corner table vertex. VertexIndex VertexParent(VertexIndex vertex) const { - if (vertex.value() < (uint32_t)num_original_vertices_) + if (vertex.value() < static_cast(num_original_vertices_)) return vertex; return non_manifold_vertex_parents_[vertex - num_original_vertices_]; } @@ -252,7 +252,7 @@ class CornerTable { DRACO_DCHECK(GetValenceCache().IsCacheEmpty()); // Add a new invalid vertex. vertex_corners_.push_back(kInvalidCornerIndex); - return VertexIndex((uint32_t)(vertex_corners_.size() - 1)); + return VertexIndex(static_cast(vertex_corners_.size() - 1)); } // Sets a new left most corner for a given vertex. diff --git a/src/draco/mesh/mesh.h b/src/draco/mesh/mesh.h index 06844ed8..918292a2 100644 --- a/src/draco/mesh/mesh.h +++ b/src/draco/mesh/mesh.h @@ -50,7 +50,7 @@ class Mesh : public PointCloud { void AddFace(const Face &face) { faces_.push_back(face); } void SetFace(FaceIndex face_id, const Face &face) { - if (face_id >= (uint32_t)faces_.size()) { + if (face_id >= static_cast(faces_.size())) { faces_.resize(face_id.value() + 1, Face()); } faces_[face_id] = face; @@ -60,7 +60,7 @@ class Mesh : public PointCloud { // existing ones if necessary. void SetNumFaces(size_t num_faces) { faces_.resize(num_faces, Face()); } - FaceIndex::ValueType num_faces() const { return (uint32_t)faces_.size(); } + FaceIndex::ValueType num_faces() const { return static_cast(faces_.size()); } const Face &face(FaceIndex face_id) const { DRACO_DCHECK_LE(0, face_id.value()); DRACO_DCHECK_LT(face_id.value(), static_cast(faces_.size())); @@ -135,7 +135,7 @@ struct MeshHasher { PointCloudHasher pc_hasher; size_t hash = pc_hasher(mesh); // Hash faces. - for (FaceIndex i(0); i < (uint32_t)mesh.faces_.size(); ++i) { + for (FaceIndex i(0); i < static_cast(mesh.faces_.size()); ++i) { for (int j = 0; j < 3; ++j) { hash = HashCombine(mesh.faces_[i][j].value(), hash); } diff --git a/src/draco/mesh/mesh_are_equivalent.cc b/src/draco/mesh/mesh_are_equivalent.cc index bcbddc31..deb68940 100644 --- a/src/draco/mesh/mesh_are_equivalent.cc +++ b/src/draco/mesh/mesh_are_equivalent.cc @@ -79,7 +79,7 @@ int32_t MeshAreEquivalent::ComputeCornerIndexOfSmallestPointXYZ( pos[i] = GetPosition(mesh, f, i); } const auto min_it = std::min_element(pos, pos + 3); - return (int32_t)(min_it - pos); + return static_cast(min_it - pos); } void MeshAreEquivalent::Init(const Mesh &mesh0, const Mesh &mesh1) { diff --git a/src/draco/mesh/mesh_attribute_corner_table.h b/src/draco/mesh/mesh_attribute_corner_table.h index 0b8af109..a31ae30d 100644 --- a/src/draco/mesh/mesh_attribute_corner_table.h +++ b/src/draco/mesh/mesh_attribute_corner_table.h @@ -84,8 +84,8 @@ class MeshAttributeCornerTable { return Next(Opposite(Next(corner))); } - int num_vertices() const { return (int)vertex_to_attribute_entry_id_map_.size(); } - int num_faces() const { return (int)corner_table_->num_faces(); } + int num_vertices() const { return static_cast(vertex_to_attribute_entry_id_map_.size()); } + int num_faces() const { return static_cast(corner_table_->num_faces()); } VertexIndex Vertex(CornerIndex corner) const { DRACO_DCHECK_LT(corner.value(), corner_to_vertex_map_.size()); diff --git a/src/draco/mesh/mesh_cleanup.cc b/src/draco/mesh/mesh_cleanup.cc index 4124f988..3e7bfa9f 100644 --- a/src/draco/mesh/mesh_cleanup.cc +++ b/src/draco/mesh/mesh_cleanup.cc @@ -121,7 +121,7 @@ bool MeshCleanup::operator()(Mesh *mesh, const MeshCleanupOptions &options) { if (num_used_entries < static_cast(att->size())) { att_index_map.resize(att->size()); num_used_entries = 0; - for (AttributeValueIndex i(0); i < (uint32_t)att->size(); ++i) { + for (AttributeValueIndex i(0); i < static_cast(att->size()); ++i) { if (is_att_index_used[i]) { att_index_map[i] = num_used_entries; if (i > num_used_entries) { diff --git a/src/draco/mesh/mesh_stripifier.h b/src/draco/mesh/mesh_stripifier.h index bf591ec9..f7c1ead4 100644 --- a/src/draco/mesh/mesh_stripifier.h +++ b/src/draco/mesh/mesh_stripifier.h @@ -94,7 +94,7 @@ class MeshStripifier { for (int i = 0; i < 3; ++i) { GenerateStripsFromCorner(i, first_ci + i); if (strip_faces_[i].size() > longest_strip_length) { - longest_strip_length = (int)strip_faces_[i].size(); + longest_strip_length = static_cast(strip_faces_[i].size()); longest_strip_id = i; } } diff --git a/src/draco/mesh/triangle_soup_mesh_builder.cc b/src/draco/mesh/triangle_soup_mesh_builder.cc index 7351ebcc..62bb9184 100644 --- a/src/draco/mesh/triangle_soup_mesh_builder.cc +++ b/src/draco/mesh/triangle_soup_mesh_builder.cc @@ -74,7 +74,7 @@ std::unique_ptr TriangleSoupMeshBuilder::Finalize() { #endif for (size_t i = 0; i < attribute_element_types_.size(); ++i) { if (attribute_element_types_[i] >= 0) { - mesh_->SetAttributeElementType((int)i, static_cast( + mesh_->SetAttributeElementType(static_cast(i), static_cast( attribute_element_types_[i])); } } diff --git a/src/draco/metadata/metadata.h b/src/draco/metadata/metadata.h index 7bc8a6a1..b4dd202c 100644 --- a/src/draco/metadata/metadata.h +++ b/src/draco/metadata/metadata.h @@ -131,7 +131,7 @@ class Metadata { void RemoveEntry(const std::string &name); - int num_entries() const { return (int)entries_.size(); } + int num_entries() const { return static_cast(entries_.size()); } const std::unordered_map &entries() const { return entries_; } diff --git a/src/draco/metadata/metadata_decoder.cc b/src/draco/metadata/metadata_decoder.cc index da35c075..62acc267 100644 --- a/src/draco/metadata/metadata_decoder.cc +++ b/src/draco/metadata/metadata_decoder.cc @@ -38,7 +38,7 @@ bool MetadataDecoder::DecodeGeometryMetadata(DecoderBuffer *in_buffer, uint32_t num_att_metadata = 0; DecodeVarint(&num_att_metadata, buffer_); // Decode attribute metadata. - for (int i = 0; i < (int)num_att_metadata; ++i) { + for (uint32_t i = 0; i < num_att_metadata; ++i) { uint32_t att_unique_id; DecodeVarint(&att_unique_id, buffer_); std::unique_ptr att_metadata = @@ -54,13 +54,13 @@ bool MetadataDecoder::DecodeGeometryMetadata(DecoderBuffer *in_buffer, bool MetadataDecoder::DecodeMetadata(Metadata *metadata) { uint32_t num_entries = 0; DecodeVarint(&num_entries, buffer_); - for (int i = 0; i < (int)num_entries; ++i) { + for (uint32_t i = 0; i < num_entries; ++i) { if (!DecodeEntry(metadata)) return false; } uint32_t num_sub_metadata = 0; DecodeVarint(&num_sub_metadata, buffer_); - for (int i = 0; i < (int)num_sub_metadata; ++i) { + for (uint32_t i = 0; i < num_sub_metadata; ++i) { std::string sub_metadata_name; if (!DecodeName(&sub_metadata_name)) return false; diff --git a/src/draco/metadata/metadata_encoder.cc b/src/draco/metadata/metadata_encoder.cc index d51b96a9..c98a334b 100644 --- a/src/draco/metadata/metadata_encoder.cc +++ b/src/draco/metadata/metadata_encoder.cc @@ -29,7 +29,7 @@ bool MetadataEncoder::EncodeMetadata(EncoderBuffer *out_buffer, if (!EncodeString(out_buffer, entry.first)) return false; const std::vector &entry_value = entry.second.data(); - const uint32_t data_size = (uint32_t)entry_value.size(); + const uint32_t data_size = static_cast(entry_value.size()); EncodeVarint(data_size, out_buffer); out_buffer->Encode(entry_value.data(), data_size); } diff --git a/src/draco/point_cloud/point_cloud.cc b/src/draco/point_cloud/point_cloud.cc index 72372510..f242ff49 100644 --- a/src/draco/point_cloud/point_cloud.cc +++ b/src/draco/point_cloud/point_cloud.cc @@ -25,7 +25,7 @@ int32_t PointCloud::NumNamedAttributes(GeometryAttribute::Type type) const { if (type == GeometryAttribute::INVALID || type >= GeometryAttribute::NAMED_ATTRIBUTES_COUNT) return 0; - return (int32_t)named_attribute_index_[type].size(); + return static_cast(named_attribute_index_[type].size()); } int32_t PointCloud::GetNamedAttributeId(GeometryAttribute::Type type) const { @@ -74,14 +74,14 @@ const PointAttribute *PointCloud::GetAttributeByUniqueId( int32_t PointCloud::GetAttributeIdByUniqueId(uint32_t unique_id) const { for (size_t att_id = 0; att_id < attributes_.size(); ++att_id) { if (attributes_[att_id]->unique_id() == unique_id) - return (int32_t)att_id; + return static_cast(att_id); } return -1; } int PointCloud::AddAttribute(std::unique_ptr pa) { - SetAttribute((int)attributes_.size(), std::move(pa)); - return (int)(attributes_.size() - 1); + SetAttribute(static_cast(attributes_.size()), std::move(pa)); + return static_cast(attributes_.size() - 1); } int PointCloud::AddAttribute( @@ -155,7 +155,7 @@ void PointCloud::DeduplicatePointIds() { PointIndex::ValueType hash = 0; for (int32_t i = 0; i < this->num_attributes(); ++i) { const AttributeValueIndex att_id = attribute(i)->mapped_index(p); - hash = (uint32_t)HashCombine(att_id.value(), hash); + hash = static_cast(HashCombine(att_id.value(), hash)); } return hash; }; diff --git a/src/draco/point_cloud/point_cloud.h b/src/draco/point_cloud/point_cloud.h index 72edfa87..c140d3db 100644 --- a/src/draco/point_cloud/point_cloud.h +++ b/src/draco/point_cloud/point_cloud.h @@ -56,7 +56,7 @@ class PointCloud { const PointAttribute *GetAttributeByUniqueId(uint32_t id) const; int32_t GetAttributeIdByUniqueId(uint32_t unique_id) const; - int32_t num_attributes() const { return (int32_t)attributes_.size(); } + int32_t num_attributes() const { return static_cast(attributes_.size()); } const PointAttribute *attribute(int32_t att_id) const { DRACO_DCHECK_LE(0, att_id); DRACO_DCHECK_LT(att_id, static_cast(attributes_.size()));