diff --git a/src/draco/attributes/attribute_octahedron_transform.cc b/src/draco/attributes/attribute_octahedron_transform.cc index 80665781..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 = 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 4b831b26..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 < 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 = 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 4e8fa652..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(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 a37628df..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_ = num_attribute_values; + num_unique_entries_ = static_cast(num_attribute_values); return true; } @@ -188,12 +188,12 @@ AttributeValueIndex::ValueType PointAttribute::DeduplicateFormattedValues( // The number of points is equal to the number of old unique values. SetExplicitMapping(num_unique_entries_); // Update the explicit map. - for (int i = 0; i < num_unique_entries_; ++i) { + for (uint32_t i = 0; i < num_unique_entries_; ++i) { SetPointMapEntry(PointIndex(i), value_map[AttributeValueIndex(i)]); } } else { // Update point to value map using the mapping between old and new values. - for (PointIndex i(0); i < 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 174ca0da..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_ = 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.cc b/src/draco/compression/attributes/attributes_decoder.cc index da76e92b..986d761e 100644 --- a/src/draco/compression/attributes/attributes_decoder.cc +++ b/src/draco/compression/attributes/attributes_decoder.cc @@ -45,7 +45,7 @@ bool AttributesDecoder::DecodeAttributesDecoderData(DecoderBuffer *in_buffer) { return false; point_attribute_ids_.resize(num_attributes); PointCloud *pc = point_cloud_; - for (int i = 0; i < num_attributes; ++i) { + for (uint32_t i = 0; i < num_attributes; ++i) { // Decode attribute descriptor data. uint8_t att_type, data_type, num_components, normalized; if (!in_buffer->Decode(&att_type)) diff --git a/src/draco/compression/attributes/attributes_decoder.h b/src/draco/compression/attributes/attributes_decoder.h index 330d0af8..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 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 = 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.cc b/src/draco/compression/attributes/attributes_encoder.cc index 76c663c8..12b3803b 100644 --- a/src/draco/compression/attributes/attributes_encoder.cc +++ b/src/draco/compression/attributes/attributes_encoder.cc @@ -35,7 +35,7 @@ bool AttributesEncoder::Initialize(PointCloudEncoder *encoder, bool AttributesEncoder::EncodeAttributesEncoderData(EncoderBuffer *out_buffer) { // Encode data about all attributes. EncodeVarint(num_attributes(), out_buffer); - for (int i = 0; i < num_attributes(); ++i) { + for (uint32_t i = 0; i < num_attributes(); ++i) { const int32_t att_id = point_attribute_ids_[i]; const PointAttribute *const pa = point_cloud_->attribute(att_id); out_buffer->Encode(static_cast(pa->attribute_type())); diff --git a/src/draco/compression/attributes/attributes_encoder.h b/src/draco/compression/attributes/attributes_encoder.h index 12300b47..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] = 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 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 = 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 5d660679..8e1e1502 100644 --- a/src/draco/compression/attributes/kd_tree_attributes_decoder.cc +++ b/src/draco/compression/attributes/kd_tree_attributes_decoder.cc @@ -96,7 +96,7 @@ class PointAttributeVectorOutputIterator { if (data_size != 4) { // handle uint16_t, uint8_t // selectively copy data bytes uint8_t *data_counter = data_; - for (auto index = 0; index < num_components; + for (uint32_t index = 0; index < num_components; index += 1, data_counter += data_size) { std::memcpy(data_counter, data_source + index, data_size); } @@ -104,7 +104,7 @@ class PointAttributeVectorOutputIterator { data_source = reinterpret_cast(data_); } const AttributeValueIndex avi = attribute->mapped_index(point_id_); - if (avi >= 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 = 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; 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; 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 < 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 1c6782dc..d2c3651a 100644 --- a/src/draco/compression/attributes/kd_tree_attributes_encoder.cc +++ b/src/draco/compression/attributes/kd_tree_attributes_encoder.cc @@ -32,7 +32,7 @@ bool KdTreeAttributesEncoder::TransformAttributesToPortableFormat() { // the kd tree encoder (quantization of floating attributes for now). const size_t num_points = encoder()->point_cloud()->num_points(); int num_components = 0; - for (int i = 0; i < num_attributes(); ++i) { + for (uint32_t i = 0; i < num_attributes(); ++i) { const int att_id = GetAttributeId(i); const PointAttribute *const att = encoder()->point_cloud()->attribute(att_id); @@ -41,7 +41,7 @@ bool KdTreeAttributesEncoder::TransformAttributesToPortableFormat() { num_components_ = num_components; // Go over all attributes and quantize them if needed. - for (int i = 0; i < num_attributes(); ++i) { + for (uint32_t i = 0; i < num_attributes(); ++i) { const int att_id = GetAttributeId(i); const PointAttribute *const att = encoder()->point_cloud()->attribute(att_id); @@ -78,7 +78,7 @@ bool KdTreeAttributesEncoder::TransformAttributesToPortableFormat() { // the actual encoding of the data. quantized_portable_attributes_.push_back( attribute_quantization_transform.GeneratePortableAttribute( - *att, 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 < 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]) @@ -145,7 +145,7 @@ bool KdTreeAttributesEncoder::EncodePortableAttributes( int num_processed_quantized_attributes = 0; int num_processed_signed_components = 0; // Copy data to the point vector. - for (int i = 0; i < num_attributes(); ++i) { + for (uint32_t i = 0; i < num_attributes(); ++i) { const int att_id = GetAttributeId(i); const PointAttribute *const att = encoder()->point_cloud()->attribute(att_id); diff --git a/src/draco/compression/attributes/mesh_traversal_sequencer.h b/src/draco/compression/attributes/mesh_traversal_sequencer.h index 21827a88..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 < 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 dd1f96f0..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(vec[0]) * center_value_) / abs_sum; - vec[1] = (static_cast(vec[1]) * 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 a0ee713c..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 = 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); @@ -211,7 +211,7 @@ bool MeshPredictionSchemeConstrainedMultiParallelogramDecoder< RAnsBitDecoder decoder; if (!decoder.StartDecoding(buffer)) return false; - for (int j = 0; j < num_flags; ++j) { + for (uint32_t j = 0; j < num_flags; ++j) { is_crease_edge_[i][j] = decoder.DecodeNextBit(); } decoder.EndDecoding(); 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 2194a3c9..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( - total_parallelogram, total_used_parallelograms); + static_cast(total_parallelogram), static_cast(total_used_parallelograms)); // Round up to the nearest full bit. - return 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 = 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 = 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 d4c0def0..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 = 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 11a907b0..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 f848d583..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 = 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 fb3ffbad..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 = 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 4c602615..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 bc89a3b1..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 = 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 4284384c..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 = 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 43a29004..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(data[data_offset], 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 = 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); @@ -155,7 +155,7 @@ bool MeshPredictionSchemeTexCoordsDecoder:: RAnsBitDecoder decoder; if (!decoder.StartDecoding(buffer)) return false; - for (int i = 0; i < num_orientations; ++i) { + for (uint32_t i = 0; i < num_orientations; ++i) { if (!decoder.DecodeNextBit()) last_orientation = !last_orientation; orientations_[i] = last_orientation; 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 76dd5b45..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(data[data_offset], 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 = 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 = 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 ec97f9fc..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 = 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 4600ce52..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 = 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 a632c9f0..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 < 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 = point_ids.size(); - const int entry_size = 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 158f0f43..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 = 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 325a7cda..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 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_attribute_encoders_controller.cc b/src/draco/compression/attributes/sequential_attribute_encoders_controller.cc index d01d70d0..8b1ac175 100644 --- a/src/draco/compression/attributes/sequential_attribute_encoders_controller.cc +++ b/src/draco/compression/attributes/sequential_attribute_encoders_controller.cc @@ -34,7 +34,7 @@ bool SequentialAttributeEncodersController::Initialize( if (!CreateSequentialEncoders()) return false; // Initialize all value encoders. - for (int i = 0; i < num_attributes(); ++i) { + for (uint32_t i = 0; i < num_attributes(); ++i) { const int32_t att_id = GetAttributeId(i); if (!sequential_encoders_[i]->Initialize(encoder, att_id)) return false; @@ -92,7 +92,7 @@ bool SequentialAttributeEncodersController:: bool SequentialAttributeEncodersController::CreateSequentialEncoders() { sequential_encoders_.resize(num_attributes()); - for (int i = 0; i < num_attributes(); ++i) { + for (uint32_t i = 0; i < num_attributes(); ++i) { sequential_encoders_[i] = CreateSequentialEncoder(i); if (sequential_encoders_[i] == nullptr) return false; diff --git a/src/draco/compression/attributes/sequential_integer_attribute_decoder.cc b/src/draco/compression/attributes/sequential_integer_attribute_decoder.cc index cf449c0a..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(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 = 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(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(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() < num_bytes * 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), 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, 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 e7cafb62..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 = 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()), - 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 < 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 < 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 = 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 e74bdb4e..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 (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 = 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 > 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 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()] = 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()] = 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(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 5e468b7a..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 > 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 0770bd9b..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 = 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 = 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 = 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 828cab61..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 > 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 > 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 32f0c287..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 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 = 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 5d0d3549..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 = 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 ff1f37a2..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 >= 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 aa3cdb3d..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 < 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 = 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(context_symbols_[i].size(), GetOutputBuffer()); + EncodeVarint(static_cast(context_symbols_[i].size()), GetOutputBuffer()); if (context_symbols_[i].size() > 0) { - EncodeSymbols(context_symbols_[i].data(), 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_decoder.cc b/src/draco/compression/mesh/mesh_sequential_decoder.cc index 71bb0cd0..2d7600ea 100644 --- a/src/draco/compression/mesh/mesh_sequential_decoder.cc +++ b/src/draco/compression/mesh/mesh_sequential_decoder.cc @@ -58,7 +58,7 @@ bool MeshSequentialDecoder::DecodeConnectivity() { } else { if (num_points < 256) { // Decode indices as uint8_t. - for (int i = 0; i < num_faces; ++i) { + for (uint32_t i = 0; i < num_faces; ++i) { Mesh::Face face; for (int j = 0; j < 3; ++j) { uint8_t val; @@ -70,7 +70,7 @@ bool MeshSequentialDecoder::DecodeConnectivity() { } } else if (num_points < (1 << 16)) { // Decode indices as uint16_t. - for (int i = 0; i < num_faces; ++i) { + for (uint32_t i = 0; i < num_faces; ++i) { Mesh::Face face; for (int j = 0; j < 3; ++j) { uint16_t val; @@ -83,7 +83,7 @@ bool MeshSequentialDecoder::DecodeConnectivity() { } else if (mesh()->num_points() < (1 << 21) && bitstream_version() >= DRACO_BITSTREAM_VERSION(2, 2)) { // Decode indices as uint32_t. - for (int i = 0; i < num_faces; ++i) { + for (uint32_t i = 0; i < num_faces; ++i) { Mesh::Face face; for (int j = 0; j < 3; ++j) { uint32_t val; @@ -95,7 +95,7 @@ bool MeshSequentialDecoder::DecodeConnectivity() { } } else { // Decode faces as uint32_t (default). - for (int i = 0; i < num_faces; ++i) { + for (uint32_t i = 0; i < num_faces; ++i) { Mesh::Face face; for (int j = 0; j < 3; ++j) { uint32_t val; @@ -130,7 +130,7 @@ bool MeshSequentialDecoder::DecodeAndDecompressIndices(uint32_t num_faces) { // See MeshSequentialEncoder::CompressAndEncodeIndices() for more details. int32_t last_index_value = 0; int vertex_index = 0; - for (int i = 0; i < num_faces; ++i) { + for (uint32_t i = 0; i < num_faces; ++i) { Mesh::Face face; for (int j = 0; j < 3; ++j) { const uint32_t encoded_val = indices_buffer[vertex_index++]; diff --git a/src/draco/compression/mesh/mesh_sequential_encoder.cc b/src/draco/compression/mesh/mesh_sequential_encoder.cc index 8c6ae7ea..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(), 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_decoder.h b/src/draco/compression/point_cloud/algorithms/dynamic_integer_points_kd_tree_decoder.h index 5568d00d..cf970e2d 100644 --- a/src/draco/compression/point_cloud/algorithms/dynamic_integer_points_kd_tree_decoder.h +++ b/src/draco/compression/point_cloud/algorithms/dynamic_integer_points_kd_tree_decoder.h @@ -246,11 +246,11 @@ bool DynamicIntegerPointsKdTreeDecoder::DecodeInternal( if (num_remaining_points <= 2) { // TODO(hemmer): axes_ not necessary, remove would change bitstream! axes_[0] = axis; - for (int i = 1; i < dimension_; i++) { + for (uint32_t i = 1; i < dimension_; i++) { axes_[i] = DRACO_INCREMENT_MOD(axes_[i - 1], dimension_); } for (uint32_t i = 0; i < num_remaining_points; ++i) { - for (int j = 0; j < dimension_; j++) { + for (uint32_t j = 0; j < dimension_; j++) { p_[axes_[j]] = 0; const uint32_t num_remaining_bits = bit_length_ - levels[axes_[j]]; if (num_remaining_bits) 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 78b32e30..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 = 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_ = end - begin; + num_points_ = static_cast(end - begin); buffer->Encode(bit_length_); buffer->Encode(num_points_); @@ -234,8 +234,8 @@ DynamicIntegerPointsKdTreeEncoder::GetAndEncodeAxis( } } } else { - const uint32_t size = (end - begin); - for (int i = 0; i < dimension_; i++) { + 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]; if (num_remaining_bits_[i] > 0) { @@ -250,7 +250,7 @@ DynamicIntegerPointsKdTreeEncoder::GetAndEncodeAxis( uint32_t max_value = 0; best_axis = 0; - for (int i = 0; i < dimension_; i++) { + for (uint32_t i = 0; i < dimension_; i++) { // If axis can be subdivided. if (num_remaining_bits_[i]) { // Check if this is the better axis. @@ -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 = 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) @@ -304,12 +304,12 @@ void DynamicIntegerPointsKdTreeEncoder::EncodeInternal( if (num_remaining_points <= 2) { // TODO(hemmer): axes_ not necessary, remove would change bitstream! axes_[0] = axis; - for (int i = 1; i < dimension_; i++) { + for (uint32_t i = 1; i < dimension_; i++) { axes_[i] = DRACO_INCREMENT_MOD(axes_[i - 1], dimension_); } for (uint32_t i = 0; i < num_remaining_points; ++i) { const auto &p = *(begin + i); - for (int j = 0; j < dimension_; j++) { + for (uint32_t j = 0; j < dimension_; j++) { const uint32_t num_remaining_bits = bit_length_ - levels[axes_[j]]; if (num_remaining_bits) { remaining_bits_encoder_.EncodeLeastSignificantBits32( @@ -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 = split - begin; - const uint32_t second_half = 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 f818cabe..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 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.cc b/src/draco/compression/point_cloud/point_cloud_encoder.cc index 3e490f16..c4a21c49 100644 --- a/src/draco/compression/point_cloud/point_cloud_encoder.cc +++ b/src/draco/compression/point_cloud/point_cloud_encoder.cc @@ -138,7 +138,7 @@ bool PointCloudEncoder::GenerateAttributesEncoders() { } attribute_to_encoder_map_.resize(point_cloud_->num_attributes()); for (uint32_t i = 0; i < attributes_encoders_.size(); ++i) { - for (int j = 0; j < attributes_encoders_[i]->num_attributes(); ++j) { + for (uint32_t j = 0; j < attributes_encoders_[i]->num_attributes(); ++j) { attribute_to_encoder_map_[attributes_encoders_[i]->GetAttributeId(j)] = i; } } @@ -198,7 +198,7 @@ bool PointCloudEncoder::RearrangeAttributesEncoders() { continue; // Encoder already processed. // Check if all parent encoders are already processed. bool can_be_processed = true; - for (int p = 0; p < attributes_encoders_[i]->num_attributes(); ++p) { + for (uint32_t p = 0; p < attributes_encoders_[i]->num_attributes(); ++p) { const int32_t att_id = attributes_encoders_[i]->GetAttributeId(p); for (int ap = 0; ap < attributes_encoders_[i]->NumParentAttributes(att_id); ++ap) { diff --git a/src/draco/compression/point_cloud/point_cloud_encoder.h b/src/draco/compression/point_cloud/point_cloud_encoder.h index d4fe2473..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 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 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 c53b46c3..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 = 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 dfc402eb..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(), 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 0f95798f..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 = 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 faa0cbde..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 = (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 = 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 a27d85ae..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 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 5c315dfe..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 > 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, 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 777436ea..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 = 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 e2004564..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 -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 > 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 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_decoding.cc b/src/draco/core/symbol_decoding.cc index d06d5291..e71fe9ee 100644 --- a/src/draco/core/symbol_decoding.cc +++ b/src/draco/core/symbol_decoding.cc @@ -65,7 +65,7 @@ bool DecodeTaggedSymbols(uint32_t num_values, int num_components, // values are encoded). src_buffer->StartBitDecoding(false, nullptr); int value_id = 0; - for (int i = 0; i < num_values; i += num_components) { + for (uint32_t i = 0; i < num_values; i += num_components) { // Decode the tag. const int bit_length = tag_decoder.DecodeSymbol(); // Decode the actual value. diff --git a/src/draco/core/symbol_encoding.cc b/src/draco/core/symbol_encoding.cc index f3195d74..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(), 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(), 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 908b0279..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, 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 = 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 9f952a2f..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 < 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 < 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 < 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 1aa52cc2..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 = 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) ? -v : 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 9b172245..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(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 < 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 fcd01eb3..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] = 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 b3703635..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()] = properties_.size(); + property_index_[prop.name()] = static_cast(properties_.size()); properties_.emplace_back(prop); if (!properties_.back().is_list()) - properties_.back().ReserveData(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 properties_.size(); } - int num_entries() const { return 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 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 21266e11..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 < 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 (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 = 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 2d3fa3cc..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 vertex_corners_.size(); } - inline int num_corners() const { return corner_to_vertex_map_.size(); } - inline int num_faces() const { return 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() < 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(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 b0d11aed..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 >= 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 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 < 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 fe06b5db..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 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 efbe5027..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 vertex_to_attribute_entry_id_map_.size(); } - int num_faces() const { return 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 ebffe555..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 < 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 0a75a64f..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 = 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 664bee6e..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(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 c9cbd753..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 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 49259c85..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 < 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 < 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 < 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 a6b55341..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 = 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 b5f2a8a9..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 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 att_id; + return static_cast(att_id); } return -1; } int PointCloud::AddAttribute(std::unique_ptr pa) { - SetAttribute(attributes_.size(), std::move(pa)); - return 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 = 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 6bc54543..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 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()));