mirror of
https://git.mirrors.martin98.com/https://github.com/google/draco
synced 2025-08-11 14:49:01 +08:00
Use C++ style casts
This commit is contained in:
parent
7cbd882ba0
commit
f348ea0b2f
@ -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<int>(point_ids.size());
|
||||
std::unique_ptr<PointAttribute> portable_attribute =
|
||||
InitPortableAttribute(num_entries, 2, num_points, attribute, true);
|
||||
|
||||
|
@ -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<uint32_t>(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<int>(point_ids.size());
|
||||
const int num_components = attribute.num_components();
|
||||
std::unique_ptr<PointAttribute> portable_attribute = InitPortableAttribute(
|
||||
num_entries, num_components, num_points, attribute, true);
|
||||
|
@ -58,7 +58,7 @@ class AttributeTransformData {
|
||||
// Sets a parameter value at the end of the |buffer_|.
|
||||
template <typename DataTypeT>
|
||||
void AppendParameterValue(const DataTypeT &in_data) {
|
||||
SetParameterValue((int)buffer_.data_size(), in_data);
|
||||
SetParameterValue(static_cast<int>(buffer_.data_size()), in_data);
|
||||
}
|
||||
|
||||
private:
|
||||
|
@ -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<uint32_t>(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<uint32_t>(indices_map_.size()); ++i) {
|
||||
SetPointMapEntry(i, value_map[indices_map_[i]]);
|
||||
}
|
||||
}
|
||||
|
@ -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<uint32_t>(new_num_unique_entries);
|
||||
}
|
||||
|
||||
// Functions for setting the type of mapping between point indices and
|
||||
|
@ -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<int32_t>(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<int>(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];
|
||||
|
@ -89,7 +89,7 @@ class AttributesEncoder {
|
||||
point_attribute_ids_.push_back(id);
|
||||
if (id >= static_cast<int32_t>(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<int32_t>(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<uint32_t>(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<int>(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];
|
||||
|
@ -104,7 +104,7 @@ class PointAttributeVectorOutputIterator {
|
||||
data_source = reinterpret_cast<uint32_t *>(data_);
|
||||
}
|
||||
const AttributeValueIndex avi = attribute->mapped_index(point_id_);
|
||||
if (avi >= (uint32_t)attribute->size())
|
||||
if (avi >= static_cast<uint32_t>(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<int>(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<AttributeTuple> atts(attribute_count);
|
||||
for (auto attribute_index = 0; (uint32_t)attribute_index < attribute_count;
|
||||
for (auto attribute_index = 0; static_cast<uint32_t>(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<uint32_t>(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<UnsignedType> unsigned_val(att->num_components());
|
||||
std::vector<SignedDataTypeT> signed_val(att->num_components());
|
||||
|
||||
for (AttributeValueIndex avi(0); avi < (uint32_t)att->size(); ++avi) {
|
||||
for (AttributeValueIndex avi(0); avi < static_cast<uint32_t>(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
|
||||
|
@ -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<int>(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<int32_t> min_value(att->num_components(),
|
||||
std::numeric_limits<int32_t>::max());
|
||||
std::vector<int32_t> act_value(att->num_components());
|
||||
for (AttributeValueIndex avi(0); avi < (uint32_t)att->size(); ++avi) {
|
||||
for (AttributeValueIndex avi(0); avi < static_cast<uint32_t>(att->size()); ++avi) {
|
||||
att->ConvertValue<int32_t>(avi, &act_value[0]);
|
||||
for (int c = 0; c < att->num_components(); ++c) {
|
||||
if (min_value[c] > act_value[c])
|
||||
|
@ -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<uint32_t>(num_faces); ++f) {
|
||||
const auto &face = mesh_->face(f);
|
||||
for (int p = 0; p < 3; ++p) {
|
||||
const PointIndex point_id = face[p];
|
||||
|
@ -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>((int64_t)vec[0]) * (int64_t)center_value_) / abs_sum;
|
||||
vec[1] = (static_cast<int64_t>((int64_t)vec[1]) * (int64_t)center_value_) / abs_sum;
|
||||
vec[0] = (static_cast<int64_t>(vec[0]) * static_cast<int64_t>(center_value_)) / abs_sum;
|
||||
vec[1] = (static_cast<int64_t>(vec[1]) * static_cast<int64_t>(center_value_)) / abs_sum;
|
||||
if (vec[2] >= 0) {
|
||||
vec[2] = center_value_ - std::abs(vec[0]) - std::abs(vec[1]);
|
||||
} else {
|
||||
|
@ -105,7 +105,7 @@ bool MeshPredictionSchemeConstrainedMultiParallelogramDecoder<
|
||||
// Used to store predicted value for multi-parallelogram prediction.
|
||||
std::vector<DataTypeT> 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<int>(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);
|
||||
|
@ -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<uint32_t>(total_parallelogram), static_cast<uint32_t>(total_used_parallelograms));
|
||||
|
||||
// Round up to the nearest full bit.
|
||||
return (int64_t)ceil((double)total_parallelogram * entropy);
|
||||
return static_cast<int64_t>(ceil(static_cast<double>(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<int>(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<int>(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) {
|
||||
|
@ -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<int>(this->mesh_data().data_to_corner_map()->size());
|
||||
|
||||
VectorD<int32_t, 3> pred_normal_3d;
|
||||
int32_t pred_normal_oct[2];
|
||||
|
@ -102,7 +102,7 @@ bool MeshPredictionSchemeGeometricNormalEncoder<DataTypeT, TransformT,
|
||||
|
||||
flip_normal_bit_encoder_.StartEncoding();
|
||||
|
||||
const int corner_map_size = (int)this->mesh_data().data_to_corner_map()->size();
|
||||
const int corner_map_size = static_cast<int>(this->mesh_data().data_to_corner_map()->size());
|
||||
|
||||
VectorD<int32_t, 3> pred_normal_3d;
|
||||
VectorD<int32_t, 2> pos_pred_normal_oct;
|
||||
|
@ -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<int32_t>(normal.AbsSum());
|
||||
if (abs_sum > upper_bound) {
|
||||
const int64_t quotient = abs_sum / upper_bound;
|
||||
normal = normal / quotient;
|
||||
|
@ -73,7 +73,7 @@ bool MeshPredictionSchemeMultiParallelogramDecoder<DataTypeT, TransformT,
|
||||
const std::vector<int32_t> *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<int>(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);
|
||||
|
@ -74,7 +74,7 @@ bool MeshPredictionSchemeMultiParallelogramEncoder<DataTypeT, TransformT,
|
||||
|
||||
// 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; --p) {
|
||||
for (int p = static_cast<int>(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);
|
||||
|
||||
|
@ -69,7 +69,7 @@ bool MeshPredictionSchemeParallelogramDecoder<DataTypeT, TransformT,
|
||||
// Restore the first value.
|
||||
this->transform().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<int>(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;
|
||||
|
@ -77,7 +77,7 @@ bool MeshPredictionSchemeParallelogramEncoder<DataTypeT, TransformT,
|
||||
const CornerTable *const table = this->mesh_data().corner_table();
|
||||
const std::vector<int32_t> *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<int>(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,
|
||||
|
@ -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<float>(data[data_offset]), static_cast<float>(data[data_offset + 1]));
|
||||
}
|
||||
|
||||
void ComputePredictedValue(CornerIndex corner_id, const DataTypeT *data,
|
||||
@ -124,7 +124,7 @@ bool MeshPredictionSchemeTexCoordsDecoder<DataTypeT, TransformT, MeshDataT>::
|
||||
std::unique_ptr<DataTypeT[]>(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<int>(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);
|
||||
|
@ -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<float>(data[data_offset]), static_cast<float>(data[data_offset + 1]));
|
||||
}
|
||||
|
||||
void ComputePredictedValue(CornerIndex corner_id, const DataTypeT *data,
|
||||
@ -117,7 +117,7 @@ bool MeshPredictionSchemeTexCoordsEncoder<DataTypeT, TransformT, MeshDataT>::
|
||||
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<int>(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 <typename DataTypeT, class TransformT, class MeshDataT>
|
||||
bool MeshPredictionSchemeTexCoordsEncoder<DataTypeT, TransformT, MeshDataT>::
|
||||
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<uint32_t>(orientations_.size());
|
||||
EncodeVarint(num_orientations, buffer);
|
||||
bool last_orientation = true;
|
||||
RAnsBitEncoder encoder;
|
||||
|
@ -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<int>(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<false>(corner_id, out_data,
|
||||
|
@ -90,7 +90,7 @@ bool MeshPredictionSchemeTexCoordsPortableEncoder<DataTypeT, TransformT,
|
||||
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<int>(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<true>(corner_id, in_data, p);
|
||||
|
@ -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<uint32_t>(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<PointIndex> &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<uint32_t>(point_ids.size());
|
||||
const int entry_size = static_cast<int>(attribute_->byte_stride());
|
||||
std::unique_ptr<uint8_t[]> value_data_ptr(new uint8_t[entry_size]);
|
||||
uint8_t *const value_data = value_data_ptr.get();
|
||||
int out_byte_pos = 0;
|
||||
|
@ -59,7 +59,7 @@ bool SequentialAttributeEncoder::EncodeDataNeededByPortableTransform(
|
||||
|
||||
bool SequentialAttributeEncoder::EncodeValues(
|
||||
const std::vector<PointIndex> &point_ids, EncoderBuffer *out_buffer) {
|
||||
const int entry_size = (int)attribute_->byte_stride();
|
||||
const int entry_size = static_cast<int>(attribute_->byte_stride());
|
||||
const std::unique_ptr<uint8_t[]> 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.
|
||||
|
@ -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<int>(parent_attributes_.size()); }
|
||||
int GetParentAttributeId(int i) const { return parent_attributes_[i]; }
|
||||
|
||||
const PointAttribute *GetPortableAttribute() const {
|
||||
|
@ -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<uint32_t>(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<uint32_t>(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<int>(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<uint32_t>(num_values), num_components, in_buffer,
|
||||
reinterpret_cast<uint32_t *>(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<int64_t>(num_bytes) * static_cast<int64_t>(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<const uint32_t *>(portable_attribute_data), (int)num_values,
|
||||
reinterpret_cast<const uint32_t *>(portable_attribute_data), static_cast<int>(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<int>(num_values),
|
||||
num_components, point_ids.data())) {
|
||||
return false;
|
||||
}
|
||||
|
@ -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<int>(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<uint32_t *>(encoded_data.data()),
|
||||
(int)point_ids.size() * num_components, num_components,
|
||||
static_cast<int>(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<uint32_t>(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<uint32_t>(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<int>(point_ids.size());
|
||||
PreparePortableAttribute(num_entries, num_components, num_points);
|
||||
int32_t dst_index = 0;
|
||||
int32_t *const portable_attribute_data = GetPortableAttributeData();
|
||||
|
@ -272,7 +272,7 @@ bool MeshEdgeBreakerDecoderImpl<TraversalDecoder>::DecodeConnectivity() {
|
||||
if (num_faces > std::numeric_limits<CornerIndex::ValueType>::max() / 3)
|
||||
return false; // Draco cannot handle this many faces.
|
||||
|
||||
if ((uint32_t)num_encoded_vertices_ > num_faces * 3) {
|
||||
if (static_cast<uint32_t>(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<TraversalDecoder>::DecodeConnectivity(
|
||||
std::vector<VertexIndex> 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<int>(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<TraversalDecoder>::DecodeHoleAndTopologySplitEvents(
|
||||
return -1;
|
||||
}
|
||||
if (num_topology_splits > 0) {
|
||||
if (num_topology_splits > (uint32_t)corner_table_->num_faces())
|
||||
if (num_topology_splits > static_cast<uint32_t>(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<TraversalDecoder>::DecodeHoleAndTopologySplitEvents(
|
||||
}
|
||||
}
|
||||
}
|
||||
return (int32_t)decoder_buffer->decoded_size();
|
||||
return static_cast<int32_t>(decoder_buffer->decoded_size());
|
||||
}
|
||||
|
||||
#ifdef DRACO_BACKWARDS_COMPATIBILITY_SUPPORTED
|
||||
@ -1090,7 +1090,7 @@ bool MeshEdgeBreakerDecoderImpl<TraversalDecoder>::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<uint32_t>(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<TraversalDecoder>::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<uint32_t>(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<TraversalDecoder>::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<uint32_t>(point_to_corner_map.size()));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -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<uint32_t>(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).
|
||||
|
@ -323,7 +323,7 @@ bool MeshEdgeBreakerEncoderImpl<TraversalEncoder>::EncodeConnectivity() {
|
||||
if (!InitAttributeData())
|
||||
return false;
|
||||
|
||||
const uint8_t num_attribute_data = (uint8_t)attribute_data_.size();
|
||||
const uint8_t num_attribute_data = static_cast<uint8_t>(attribute_data_.size());
|
||||
encoder_->buffer()->Encode(num_attribute_data);
|
||||
traversal_encoder_.SetNumAttributeData(num_attribute_data);
|
||||
|
||||
@ -426,7 +426,7 @@ bool MeshEdgeBreakerEncoderImpl<TraversalEncoder>::EncodeConnectivity() {
|
||||
|
||||
template <class TraversalEncoder>
|
||||
bool MeshEdgeBreakerEncoderImpl<TraversalEncoder>::EncodeSplitData() {
|
||||
uint32_t num_events = (uint32_t)topology_split_event_data_.size();
|
||||
uint32_t num_events = static_cast<uint32_t>(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<TraversalEncoder>::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<int>(visited_holes_.size());
|
||||
visited_holes_.push_back(false);
|
||||
|
||||
CornerIndex corner_id = i;
|
||||
|
@ -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<uint64_t>(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<uint64_t>(buffer_.remaining_size()))
|
||||
return false;
|
||||
buffer_.Advance(traversal_size);
|
||||
return true;
|
||||
|
@ -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<int>(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<int>(symbols_.size() - 1); i >= 0; --i) {
|
||||
traversal_buffer_.EncodeLeastSignificantBits32(
|
||||
edge_breaker_topology_bit_pattern_length[symbols_[i]], symbols_[i]);
|
||||
}
|
||||
|
@ -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<int>(predictions_.size()) - 1; i >= 0; --i) {
|
||||
prediction_encoder.EncodeBit(predictions_[i]);
|
||||
}
|
||||
prediction_encoder.EndEncoding(GetOutputBuffer());
|
||||
|
@ -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<uint32_t>(num_vertices_))
|
||||
return false;
|
||||
|
||||
int8_t mode;
|
||||
|
@ -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<uint32_t>(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<int>(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>((uint32_t)context_symbols_[i].size(), GetOutputBuffer());
|
||||
EncodeVarint<uint32_t>(static_cast<uint32_t>(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<int>(context_symbols_[i].size()), 1,
|
||||
nullptr, GetOutputBuffer());
|
||||
}
|
||||
}
|
||||
|
@ -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<int>(indices_buffer.size()), 1, nullptr,
|
||||
buffer());
|
||||
return true;
|
||||
}
|
||||
|
@ -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<uint32_t>(end - begin);
|
||||
}
|
||||
|
||||
RandomAccessIteratorT begin;
|
||||
@ -187,7 +187,7 @@ bool DynamicIntegerPointsKdTreeEncoder<compression_level_t>::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<uint32_t>(end - begin);
|
||||
|
||||
buffer->Encode(bit_length_);
|
||||
buffer->Encode(num_points_);
|
||||
@ -234,7 +234,7 @@ DynamicIntegerPointsKdTreeEncoder<compression_level_t>::GetAndEncodeAxis(
|
||||
}
|
||||
}
|
||||
} else {
|
||||
const uint32_t size = (uint32_t)(end - begin);
|
||||
const uint32_t size = static_cast<uint32_t>(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<compression_level_t>::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<uint32_t>(end - begin);
|
||||
|
||||
// If this happens all axis are subdivided to the end.
|
||||
if ((bit_length_ - level) == 0)
|
||||
@ -334,8 +334,8 @@ void DynamicIntegerPointsKdTreeEncoder<compression_level_t>::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<uint32_t>(split - begin);
|
||||
const uint32_t second_half = static_cast<uint32_t>(end - split);
|
||||
const bool left = first_half < second_half;
|
||||
|
||||
if (first_half != second_half)
|
||||
|
@ -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<int32_t>(attributes_decoders_.size());
|
||||
}
|
||||
|
||||
// Get a mutable pointer to the decoded point cloud. This is intended to be
|
||||
|
@ -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<int>(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<AttributesEncoder> att_enc) {
|
||||
attributes_encoders_.push_back(std::move(att_enc));
|
||||
return (int)(attributes_encoders_.size() - 1);
|
||||
return static_cast<int>(attributes_encoders_.size() - 1);
|
||||
}
|
||||
|
||||
// Marks one attribute as a parent of another attribute. Must be called after
|
||||
|
@ -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<uint32_t>(bits_.size()) * 4;
|
||||
target_buffer->Encode(size_in_byte);
|
||||
target_buffer->Encode(bits_.data(), size_in_byte);
|
||||
Clear();
|
||||
|
@ -17,7 +17,7 @@ void SymbolBitEncoder::EncodeLeastSignificantBits32(int nbits, uint32_t value) {
|
||||
|
||||
void SymbolBitEncoder::EndEncoding(EncoderBuffer *target_buffer) {
|
||||
target_buffer->Encode(static_cast<uint32_t>(symbols_.size()));
|
||||
EncodeSymbols(symbols_.data(), (int)symbols_.size(), 1, nullptr, target_buffer);
|
||||
EncodeSymbols(symbols_.data(), static_cast<int>(symbols_.size()), 1, nullptr, target_buffer);
|
||||
Clear();
|
||||
}
|
||||
|
||||
|
@ -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<uint32_t>(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);
|
||||
|
@ -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<int>(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<int>(len) - off;
|
||||
uint64_t new_hash = seed;
|
||||
|
||||
if (num_chars_left > 7) {
|
||||
|
@ -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<float>(std::atof(it->second.c_str()));
|
||||
}
|
||||
|
||||
bool Options::GetBool(const std::string &name) const {
|
||||
|
@ -130,13 +130,13 @@ bool RAnsSymbolDecoder<unique_symbols_bit_length_t>::StartDecoding(
|
||||
if (!DecodeVarint<uint64_t>(&bytes_encoded, buffer))
|
||||
return false;
|
||||
}
|
||||
if (bytes_encoded > (uint64_t)buffer->remaining_size())
|
||||
if (bytes_encoded > static_cast<uint64_t>(buffer->remaining_size()))
|
||||
return false;
|
||||
const uint8_t *const data_head =
|
||||
reinterpret_cast<const uint8_t *>(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<int>(bytes_encoded)) != 0)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
@ -264,7 +264,7 @@ void RAnsSymbolEncoder<unique_symbols_bit_length_t>::EndEncoding(
|
||||
const uint64_t bytes_written = static_cast<uint64_t>(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<uint32_t>(var_size_buffer.size());
|
||||
char *const dst = src + size_len;
|
||||
memmove(dst, src, bytes_written);
|
||||
|
||||
|
@ -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<int64_t>(-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<uint32_t>(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<int64_t>(ceil(entropy_data.num_values * std::log2(entropy_data.num_values) -
|
||||
entropy_data.entropy_norm));
|
||||
}
|
||||
|
||||
int64_t ShannonEntropyTracker::GetNumberOfRAnsTableBits(
|
||||
|
@ -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<int>(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<int>(frequencies.size()), target_buffer);
|
||||
encoder.StartEncoding(target_buffer);
|
||||
// Encode all values.
|
||||
if (SymbolEncoderT::needs_reverse_encoding()) {
|
||||
|
@ -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<uint32_t>(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<int>(obj_name_to_id_.size());
|
||||
obj_name_to_id_[obj_name] = num_obj;
|
||||
last_sub_obj_id_ = num_obj;
|
||||
} else {
|
||||
|
@ -165,7 +165,7 @@ bool ObjEncoder::EncodePositions() {
|
||||
if (att == nullptr || att->size() == 0)
|
||||
return false; // Position attribute must be valid.
|
||||
std::array<float, 3> value;
|
||||
for (AttributeValueIndex i(0); i < (uint32_t)att->size(); ++i) {
|
||||
for (AttributeValueIndex i(0); i < static_cast<uint32_t>(att->size()); ++i) {
|
||||
if (!att->ConvertValue<float, 3>(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<float, 2> value;
|
||||
for (AttributeValueIndex i(0); i < (uint32_t)att->size(); ++i) {
|
||||
for (AttributeValueIndex i(0); i < static_cast<uint32_t>(att->size()); ++i) {
|
||||
if (!att->ConvertValue<float, 2>(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<float, 3> value;
|
||||
for (AttributeValueIndex i(0); i < (uint32_t)att->size(); ++i) {
|
||||
for (AttributeValueIndex i(0); i < static_cast<uint32_t>(att->size()); ++i) {
|
||||
if (!att->ConvertValue<float, 3>(i, &value[0]))
|
||||
return false;
|
||||
buffer()->Encode("vn ", 3);
|
||||
|
@ -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<int>(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<float>(-v) : static_cast<float>(v);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -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<int>(list_offset + c));
|
||||
out_mesh_->SetFace(face_index, face);
|
||||
face_index++;
|
||||
}
|
||||
@ -127,7 +127,7 @@ bool PlyDecoder::ReadPropertiesToAttribute(
|
||||
new PlyPropertyReader<DataTypeT>(properties[prop])));
|
||||
}
|
||||
std::vector<DataTypeT> memory(properties.size());
|
||||
for (PointIndex::ValueType i = 0; i < (uint32_t)num_vertices; ++i) {
|
||||
for (PointIndex::ValueType i = 0; i < static_cast<uint32_t>(num_vertices); ++i) {
|
||||
for (int prop = 0; prop < properties.size(); ++prop) {
|
||||
memory[prop] = readers[prop]->ReadValue(i);
|
||||
}
|
||||
|
@ -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<uint32_t>(elements_.size());
|
||||
elements_.emplace_back(PlyElement(element_name, count));
|
||||
*buffer = line_buffer;
|
||||
return true;
|
||||
|
@ -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<int>(properties_.size());
|
||||
properties_.emplace_back(prop);
|
||||
if (!properties_.back().is_list())
|
||||
properties_.back().ReserveData((int)num_entries_);
|
||||
properties_.back().ReserveData(static_cast<int>(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<int>(properties_.size()); }
|
||||
int num_entries() const { return static_cast<int>(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<int>(elements_.size()); }
|
||||
const PlyElement &element(int element_index) const {
|
||||
return elements_[element_index];
|
||||
}
|
||||
|
@ -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<uint32_t>(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<CornerIndex::ValueType>::max() / 3)
|
||||
if (static_cast<unsigned int>(num_faces) > std::numeric_limits<CornerIndex::ValueType>::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<int>(num_corners_on_vertices.size());
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -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<int>(vertex_corners_.size()); }
|
||||
inline int num_corners() const { return static_cast<int>(corner_to_vertex_map_.size()); }
|
||||
inline int num_faces() const { return static_cast<int>(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<uint32_t>(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<uint32_t>(vertex_corners_.size() - 1));
|
||||
}
|
||||
|
||||
// Sets a new left most corner for a given vertex.
|
||||
|
@ -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<uint32_t>(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<uint32_t>(faces_.size()); }
|
||||
const Face &face(FaceIndex face_id) const {
|
||||
DRACO_DCHECK_LE(0, face_id.value());
|
||||
DRACO_DCHECK_LT(face_id.value(), static_cast<int>(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<uint32_t>(mesh.faces_.size()); ++i) {
|
||||
for (int j = 0; j < 3; ++j) {
|
||||
hash = HashCombine(mesh.faces_[i][j].value(), hash);
|
||||
}
|
||||
|
@ -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<int32_t>(min_it - pos);
|
||||
}
|
||||
|
||||
void MeshAreEquivalent::Init(const Mesh &mesh0, const Mesh &mesh1) {
|
||||
|
@ -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<int>(vertex_to_attribute_entry_id_map_.size()); }
|
||||
int num_faces() const { return static_cast<int>(corner_table_->num_faces()); }
|
||||
|
||||
VertexIndex Vertex(CornerIndex corner) const {
|
||||
DRACO_DCHECK_LT(corner.value(), corner_to_vertex_map_.size());
|
||||
|
@ -121,7 +121,7 @@ bool MeshCleanup::operator()(Mesh *mesh, const MeshCleanupOptions &options) {
|
||||
if (num_used_entries < static_cast<int>(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<uint32_t>(att->size()); ++i) {
|
||||
if (is_att_index_used[i]) {
|
||||
att_index_map[i] = num_used_entries;
|
||||
if (i > num_used_entries) {
|
||||
|
@ -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<int>(strip_faces_[i].size());
|
||||
longest_strip_id = i;
|
||||
}
|
||||
}
|
||||
|
@ -74,7 +74,7 @@ std::unique_ptr<Mesh> 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<MeshAttributeElementType>(
|
||||
mesh_->SetAttributeElementType(static_cast<int>(i), static_cast<MeshAttributeElementType>(
|
||||
attribute_element_types_[i]));
|
||||
}
|
||||
}
|
||||
|
@ -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<int>(entries_.size()); }
|
||||
const std::unordered_map<std::string, EntryValue> &entries() const {
|
||||
return entries_;
|
||||
}
|
||||
|
@ -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<AttributeMetadata> 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;
|
||||
|
@ -29,7 +29,7 @@ bool MetadataEncoder::EncodeMetadata(EncoderBuffer *out_buffer,
|
||||
if (!EncodeString(out_buffer, entry.first))
|
||||
return false;
|
||||
const std::vector<uint8_t> &entry_value = entry.second.data();
|
||||
const uint32_t data_size = (uint32_t)entry_value.size();
|
||||
const uint32_t data_size = static_cast<uint32_t>(entry_value.size());
|
||||
EncodeVarint(data_size, out_buffer);
|
||||
out_buffer->Encode(entry_value.data(), data_size);
|
||||
}
|
||||
|
@ -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<int32_t>(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<int32_t>(att_id);
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
int PointCloud::AddAttribute(std::unique_ptr<PointAttribute> pa) {
|
||||
SetAttribute((int)attributes_.size(), std::move(pa));
|
||||
return (int)(attributes_.size() - 1);
|
||||
SetAttribute(static_cast<int>(attributes_.size()), std::move(pa));
|
||||
return static_cast<int>(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<uint32_t>(HashCombine(att_id.value(), hash));
|
||||
}
|
||||
return hash;
|
||||
};
|
||||
|
@ -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<int32_t>(attributes_.size()); }
|
||||
const PointAttribute *attribute(int32_t att_id) const {
|
||||
DRACO_DCHECK_LE(0, att_id);
|
||||
DRACO_DCHECK_LT(att_id, static_cast<int32_t>(attributes_.size()));
|
||||
|
Loading…
x
Reference in New Issue
Block a user