Changeset View
Changeset View
Standalone View
Standalone View
extern/draco/dracoenc/src/draco/point_cloud/point_cloud.cc
| Context not available. | |||||
| int PointCloud::AddAttribute( | int PointCloud::AddAttribute( | ||||
| const GeometryAttribute &att, bool identity_mapping, | const GeometryAttribute &att, bool identity_mapping, | ||||
| AttributeValueIndex::ValueType num_attribute_values) { | AttributeValueIndex::ValueType num_attribute_values) { | ||||
| const GeometryAttribute::Type type = att.attribute_type(); | auto pa = CreateAttribute(att, identity_mapping, num_attribute_values); | ||||
| if (type == GeometryAttribute::INVALID) | if (!pa) | ||||
| return -1; | return -1; | ||||
| const int32_t att_id = | const int32_t att_id = AddAttribute(std::move(pa)); | ||||
| AddAttribute(std::unique_ptr<PointAttribute>(new PointAttribute(att))); | return att_id; | ||||
| } | |||||
| std::unique_ptr<PointAttribute> PointCloud::CreateAttribute( | |||||
| const GeometryAttribute &att, bool identity_mapping, | |||||
| AttributeValueIndex::ValueType num_attribute_values) const { | |||||
| if (att.attribute_type() == GeometryAttribute::INVALID) | |||||
| return nullptr; | |||||
| std::unique_ptr<PointAttribute> pa = | |||||
| std::unique_ptr<PointAttribute>(new PointAttribute(att)); | |||||
| // Initialize point cloud specific attribute data. | // Initialize point cloud specific attribute data. | ||||
| if (!identity_mapping) { | if (!identity_mapping) { | ||||
| // First create mapping between indices. | // First create mapping between indices. | ||||
| attribute(att_id)->SetExplicitMapping(num_points_); | pa->SetExplicitMapping(num_points_); | ||||
| } else { | } else { | ||||
| attribute(att_id)->SetIdentityMapping(); | pa->SetIdentityMapping(); | ||||
| attribute(att_id)->Resize(num_points_); | pa->Resize(num_points_); | ||||
| } | } | ||||
| if (num_attribute_values > 0) { | if (num_attribute_values > 0) { | ||||
| attribute(att_id)->Reset(num_attribute_values); | pa->Reset(num_attribute_values); | ||||
| } | } | ||||
| return att_id; | return pa; | ||||
| } | } | ||||
| void PointCloud::SetAttribute(int att_id, std::unique_ptr<PointAttribute> pa) { | void PointCloud::SetAttribute(int att_id, std::unique_ptr<PointAttribute> pa) { | ||||
| Context not available. | |||||
| } | } | ||||
| } | } | ||||
| #ifdef DRACO_ATTRIBUTE_DEDUPLICATION_SUPPORTED | #ifdef DRACO_ATTRIBUTE_INDICES_DEDUPLICATION_SUPPORTED | ||||
| void PointCloud::DeduplicatePointIds() { | void PointCloud::DeduplicatePointIds() { | ||||
| // Hashing function for a single vertex. | // Hashing function for a single vertex. | ||||
| auto point_hash = [this](PointIndex p) { | auto point_hash = [this](PointIndex p) { | ||||
| Context not available. | |||||
| attribute(a)->SetExplicitMapping(num_unique_points); | attribute(a)->SetExplicitMapping(num_unique_points); | ||||
| } | } | ||||
| } | } | ||||
| #endif | |||||
| #ifdef DRACO_ATTRIBUTE_VALUES_DEDUPLICATION_SUPPORTED | |||||
| bool PointCloud::DeduplicateAttributeValues() { | bool PointCloud::DeduplicateAttributeValues() { | ||||
| // Go over all attributes and create mapping between duplicate entries. | // Go over all attributes and create mapping between duplicate entries. | ||||
| if (num_points() == 0) | if (num_points() == 0) | ||||
| Context not available. | |||||