Differential D9642 Diff 31360 extern/draco/draco/src/draco/compression/mesh/mesh_edgebreaker_encoder.cc
Changeset View
Changeset View
Standalone View
Standalone View
extern/draco/draco/src/draco/compression/mesh/mesh_edgebreaker_encoder.cc
- This file was moved from extern/draco/dracoenc/src/draco/compression/mesh/mesh_edgebreaker_encoder.cc.
| Show First 20 Lines • Show All 53 Lines • ▼ Show 20 Lines | if (is_standard_edgebreaker_available) { | ||||
| new MeshEdgebreakerEncoderImpl<MeshEdgebreakerTraversalEncoder>()); | new MeshEdgebreakerEncoderImpl<MeshEdgebreakerTraversalEncoder>()); | ||||
| } | } | ||||
| } else if (selected_edgebreaker_method == MESH_EDGEBREAKER_VALENCE_ENCODING) { | } else if (selected_edgebreaker_method == MESH_EDGEBREAKER_VALENCE_ENCODING) { | ||||
| buffer()->Encode(static_cast<uint8_t>(MESH_EDGEBREAKER_VALENCE_ENCODING)); | buffer()->Encode(static_cast<uint8_t>(MESH_EDGEBREAKER_VALENCE_ENCODING)); | ||||
| impl_ = std::unique_ptr<MeshEdgebreakerEncoderImplInterface>( | impl_ = std::unique_ptr<MeshEdgebreakerEncoderImplInterface>( | ||||
| new MeshEdgebreakerEncoderImpl< | new MeshEdgebreakerEncoderImpl< | ||||
| MeshEdgebreakerTraversalValenceEncoder>()); | MeshEdgebreakerTraversalValenceEncoder>()); | ||||
| } | } | ||||
| if (!impl_) | if (!impl_) { | ||||
| return false; | return false; | ||||
| if (!impl_->Init(this)) | } | ||||
| if (!impl_->Init(this)) { | |||||
| return false; | return false; | ||||
| } | |||||
| return true; | return true; | ||||
| } | } | ||||
| bool MeshEdgebreakerEncoder::GenerateAttributesEncoder(int32_t att_id) { | bool MeshEdgebreakerEncoder::GenerateAttributesEncoder(int32_t att_id) { | ||||
| if (!impl_->GenerateAttributesEncoder(att_id)) | if (!impl_->GenerateAttributesEncoder(att_id)) { | ||||
| return false; | return false; | ||||
| } | |||||
| return true; | return true; | ||||
| } | } | ||||
| bool MeshEdgebreakerEncoder::EncodeAttributesEncoderIdentifier( | bool MeshEdgebreakerEncoder::EncodeAttributesEncoderIdentifier( | ||||
| int32_t att_encoder_id) { | int32_t att_encoder_id) { | ||||
| if (!impl_->EncodeAttributesEncoderIdentifier(att_encoder_id)) | if (!impl_->EncodeAttributesEncoderIdentifier(att_encoder_id)) { | ||||
| return false; | return false; | ||||
| } | |||||
| return true; | return true; | ||||
| } | } | ||||
| Status MeshEdgebreakerEncoder::EncodeConnectivity() { | Status MeshEdgebreakerEncoder::EncodeConnectivity() { | ||||
| return impl_->EncodeConnectivity(); | return impl_->EncodeConnectivity(); | ||||
| } | } | ||||
| void MeshEdgebreakerEncoder::ComputeNumberOfEncodedPoints() { | void MeshEdgebreakerEncoder::ComputeNumberOfEncodedPoints() { | ||||
| if (!impl_) | if (!impl_) { | ||||
| return; | return; | ||||
| } | |||||
| const CornerTable *const corner_table = impl_->GetCornerTable(); | const CornerTable *const corner_table = impl_->GetCornerTable(); | ||||
| if (!corner_table) | if (!corner_table) { | ||||
| return; | return; | ||||
| } | |||||
| size_t num_points = | size_t num_points = | ||||
| corner_table->num_vertices() - corner_table->NumIsolatedVertices(); | corner_table->num_vertices() - corner_table->NumIsolatedVertices(); | ||||
| if (mesh()->num_attributes() > 1) { | if (mesh()->num_attributes() > 1) { | ||||
| // Gather all corner tables for all non-position attributes. | // Gather all corner tables for all non-position attributes. | ||||
| std::vector<const MeshAttributeCornerTable *> attribute_corner_tables; | std::vector<const MeshAttributeCornerTable *> attribute_corner_tables; | ||||
| for (int i = 0; i < mesh()->num_attributes(); ++i) { | for (int i = 0; i < mesh()->num_attributes(); ++i) { | ||||
| if (mesh()->attribute(i)->attribute_type() == GeometryAttribute::POSITION) | if (mesh()->attribute(i)->attribute_type() == | ||||
| GeometryAttribute::POSITION) { | |||||
| continue; | continue; | ||||
| } | |||||
| const MeshAttributeCornerTable *const att_corner_table = | const MeshAttributeCornerTable *const att_corner_table = | ||||
| GetAttributeCornerTable(i); | GetAttributeCornerTable(i); | ||||
| // Attribute corner table may not be used in some configurations. For | // Attribute corner table may not be used in some configurations. For | ||||
| // these cases we can assume the attribute connectivity to be the same as | // these cases we can assume the attribute connectivity to be the same as | ||||
| // the connectivity of the position data. | // the connectivity of the position data. | ||||
| if (att_corner_table) | if (att_corner_table) { | ||||
| attribute_corner_tables.push_back(att_corner_table); | attribute_corner_tables.push_back(att_corner_table); | ||||
| } | } | ||||
| } | |||||
| // Add a new point based on the configuration of interior attribute seams | // Add a new point based on the configuration of interior attribute seams | ||||
| // (replicating what the decoder would do). | // (replicating what the decoder would do). | ||||
| for (VertexIndex vi(0); vi < corner_table->num_vertices(); ++vi) { | for (VertexIndex vi(0); vi < corner_table->num_vertices(); ++vi) { | ||||
| if (corner_table->IsVertexIsolated(vi)) | if (corner_table->IsVertexIsolated(vi)) { | ||||
| continue; | continue; | ||||
| } | |||||
| // Go around all corners of the vertex and keep track of the observed | // Go around all corners of the vertex and keep track of the observed | ||||
| // attribute seams. | // attribute seams. | ||||
| const CornerIndex first_corner_index = corner_table->LeftMostCorner(vi); | const CornerIndex first_corner_index = corner_table->LeftMostCorner(vi); | ||||
| const PointIndex first_point_index = | const PointIndex first_point_index = | ||||
| mesh()->CornerToPointId(first_corner_index); | mesh()->CornerToPointId(first_corner_index); | ||||
| PointIndex last_point_index = first_point_index; | PointIndex last_point_index = first_point_index; | ||||
| CornerIndex last_corner_index = first_corner_index; | CornerIndex last_corner_index = first_corner_index; | ||||
| Show All 16 Lines | for (VertexIndex vi(0); vi < corner_table->num_vertices(); ++vi) { | ||||
| break; // No need to process other attributes. | break; // No need to process other attributes. | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| if (seam_found) { | if (seam_found) { | ||||
| ++num_attribute_seams; | ++num_attribute_seams; | ||||
| } | } | ||||
| if (corner_index == first_corner_index) | if (corner_index == first_corner_index) { | ||||
| break; | break; | ||||
| } | |||||
| // Proceed to the next corner | // Proceed to the next corner | ||||
| last_corner_index = corner_index; | last_corner_index = corner_index; | ||||
| corner_index = corner_table->SwingRight(corner_index); | corner_index = corner_table->SwingRight(corner_index); | ||||
| } | } | ||||
| if (!corner_table->IsOnBoundary(vi) && num_attribute_seams > 0) { | if (!corner_table->IsOnBoundary(vi) && num_attribute_seams > 0) { | ||||
| // If the last visited point index is the same as the first point index | // If the last visited point index is the same as the first point index | ||||
| // we traveled all the way around the vertex. In this case the number of | // we traveled all the way around the vertex. In this case the number of | ||||
| // new points should be num_attribute_seams - 1 | // new points should be num_attribute_seams - 1 | ||||
| num_points += num_attribute_seams - 1; | num_points += num_attribute_seams - 1; | ||||
| } else { | } else { | ||||
| // Else the vertex was either on a boundary (i.e. we couldn't travel all | // Else the vertex was either on a boundary (i.e. we couldn't travel all | ||||
| // around the vertex), or we ended up at a different point. In both of | // around the vertex), or we ended up at a different point. In both of | ||||
| // these cases, the number of new points is equal to the number of | // these cases, the number of new points is equal to the number of | ||||
| // attribute seams. | // attribute seams. | ||||
| num_points += num_attribute_seams; | num_points += num_attribute_seams; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| set_num_encoded_points(num_points); | set_num_encoded_points(num_points); | ||||
| } | } | ||||
| void MeshEdgebreakerEncoder::ComputeNumberOfEncodedFaces() { | void MeshEdgebreakerEncoder::ComputeNumberOfEncodedFaces() { | ||||
| if (!impl_) | if (!impl_) { | ||||
| return; | return; | ||||
| } | |||||
| const CornerTable *const corner_table = impl_->GetCornerTable(); | const CornerTable *const corner_table = impl_->GetCornerTable(); | ||||
| if (!corner_table) | if (!corner_table) { | ||||
| return; | return; | ||||
| } | |||||
| set_num_encoded_faces(corner_table->num_faces() - | set_num_encoded_faces(corner_table->num_faces() - | ||||
| corner_table->NumDegeneratedFaces()); | corner_table->NumDegeneratedFaces()); | ||||
| } | } | ||||
| } // namespace draco | } // namespace draco | ||||