diff --git a/src/draco/compression/decode.cc b/src/draco/compression/decode.cc index a9ac2d5..ab70ef1 100644 --- a/src/draco/compression/decode.cc +++ b/src/draco/compression/decode.cc @@ -37,7 +37,7 @@ StatusOr> CreatePointCloudDecoder( } else if (method == POINT_CLOUD_KD_TREE_ENCODING) { return std::unique_ptr(new PointCloudKdTreeDecoder()); } - return Status(Status::ERROR, "Unsupported encoding method."); + return Status(Status::DRACO_ERROR, "Unsupported encoding method."); } #endif @@ -48,7 +48,7 @@ StatusOr> CreateMeshDecoder(uint8_t method) { } else if (method == MESH_EDGEBREAKER_ENCODING) { return std::unique_ptr(new MeshEdgebreakerDecoder()); } - return Status(Status::ERROR, "Unsupported encoding method."); + return Status(Status::DRACO_ERROR, "Unsupported encoding method."); } #endif @@ -77,7 +77,7 @@ StatusOr> Decoder::DecodePointCloudFromBuffer( return static_cast>(std::move(mesh)); #endif } - return Status(Status::ERROR, "Unsupported geometry type."); + return Status(Status::DRACO_ERROR, "Unsupported geometry type."); } StatusOr> Decoder::DecodeMeshFromBuffer( @@ -94,7 +94,7 @@ Status Decoder::DecodeBufferToGeometry(DecoderBuffer *in_buffer, DracoHeader header; DRACO_RETURN_IF_ERROR(PointCloudDecoder::DecodeHeader(&temp_buffer, &header)) if (header.encoder_type != POINT_CLOUD) { - return Status(Status::ERROR, "Input is not a point cloud."); + return Status(Status::DRACO_ERROR, "Input is not a point cloud."); } DRACO_ASSIGN_OR_RETURN(std::unique_ptr decoder, CreatePointCloudDecoder(header.encoder_method)) @@ -102,7 +102,7 @@ Status Decoder::DecodeBufferToGeometry(DecoderBuffer *in_buffer, DRACO_RETURN_IF_ERROR(decoder->Decode(options_, in_buffer, out_geometry)) return OkStatus(); #else - return Status(Status::ERROR, "Unsupported geometry type."); + return Status(Status::DRACO_ERROR, "Unsupported geometry type."); #endif } @@ -113,7 +113,7 @@ Status Decoder::DecodeBufferToGeometry(DecoderBuffer *in_buffer, DracoHeader header; DRACO_RETURN_IF_ERROR(PointCloudDecoder::DecodeHeader(&temp_buffer, &header)) if (header.encoder_type != TRIANGULAR_MESH) { - return Status(Status::ERROR, "Input is not a mesh."); + return Status(Status::DRACO_ERROR, "Input is not a mesh."); } DRACO_ASSIGN_OR_RETURN(std::unique_ptr decoder, CreateMeshDecoder(header.encoder_method)) @@ -121,7 +121,7 @@ Status Decoder::DecodeBufferToGeometry(DecoderBuffer *in_buffer, DRACO_RETURN_IF_ERROR(decoder->Decode(options_, in_buffer, out_geometry)) return OkStatus(); #else - return Status(Status::ERROR, "Unsupported geometry type."); + return Status(Status::DRACO_ERROR, "Unsupported geometry type."); #endif } diff --git a/src/draco/compression/encode_base.h b/src/draco/compression/encode_base.h index 4b790be..451d970 100644 --- a/src/draco/compression/encode_base.h +++ b/src/draco/compression/encode_base.h @@ -69,25 +69,27 @@ class EncoderBase { int prediction_scheme) const { // Out of bound checks: if (prediction_scheme < PREDICTION_NONE) - return Status(Status::ERROR, "Invalid prediction scheme requested."); + return Status(Status::DRACO_ERROR, + "Invalid prediction scheme requested."); if (prediction_scheme >= NUM_PREDICTION_SCHEMES) - return Status(Status::ERROR, "Invalid prediction scheme requested."); + return Status(Status::DRACO_ERROR, + "Invalid prediction scheme requested."); // Deprecated prediction schemes: if (prediction_scheme == MESH_PREDICTION_TEX_COORDS_DEPRECATED) - return Status(Status::ERROR, + return Status(Status::DRACO_ERROR, "MESH_PREDICTION_TEX_COORDS_DEPRECATED is deprecated."); if (prediction_scheme == MESH_PREDICTION_MULTI_PARALLELOGRAM) - return Status(Status::ERROR, + return Status(Status::DRACO_ERROR, "MESH_PREDICTION_MULTI_PARALLELOGRAM is deprecated."); // Attribute specific checks: if (prediction_scheme == MESH_PREDICTION_TEX_COORDS_PORTABLE) { if (att_type != GeometryAttribute::TEX_COORD) - return Status(Status::ERROR, + return Status(Status::DRACO_ERROR, "Invalid prediction scheme for attribute type."); } if (prediction_scheme == MESH_PREDICTION_GEOMETRIC_NORMAL) { if (att_type != GeometryAttribute::NORMAL) { - return Status(Status::ERROR, + return Status(Status::DRACO_ERROR, "Invalid prediction scheme for attribute type."); } } @@ -95,7 +97,7 @@ class EncoderBase { if (att_type == GeometryAttribute::NORMAL) { if (!(prediction_scheme == PREDICTION_DIFFERENCE || prediction_scheme == MESH_PREDICTION_GEOMETRIC_NORMAL)) { - return Status(Status::ERROR, + return Status(Status::DRACO_ERROR, "Invalid prediction scheme for attribute type."); } } diff --git a/src/draco/compression/expert_encode.cc b/src/draco/compression/expert_encode.cc index 3008645..112e6ae 100644 --- a/src/draco/compression/expert_encode.cc +++ b/src/draco/compression/expert_encode.cc @@ -31,7 +31,7 @@ ExpertEncoder::ExpertEncoder(const Mesh &mesh) Status ExpertEncoder::EncodeToBuffer(EncoderBuffer *out_buffer) { if (point_cloud_ == nullptr) - return Status(Status::ERROR, "Invalid input geometry."); + return Status(Status::DRACO_ERROR, "Invalid input geometry."); if (mesh_ == nullptr) { return EncodePointCloudToBuffer(*point_cloud_, out_buffer); } @@ -77,7 +77,7 @@ Status ExpertEncoder::EncodePointCloudToBuffer(const PointCloud &pc, } else if (encoding_method == POINT_CLOUD_KD_TREE_ENCODING) { // Encoding method was explicitly specified but we cannot use it for // the given input (some of the checks above failed). - return Status(Status::ERROR, "Invalid encoding method."); + return Status(Status::DRACO_ERROR, "Invalid encoding method."); } } if (!encoder) { @@ -91,7 +91,7 @@ Status ExpertEncoder::EncodePointCloudToBuffer(const PointCloud &pc, set_num_encoded_faces(0); return OkStatus(); #else - return Status(Status::ERROR, "Point cloud encoding is not enabled."); + return Status(Status::DRACO_ERROR, "Point cloud encoding is not enabled."); #endif } diff --git a/src/draco/compression/mesh/mesh_edgebreaker_encoder_impl.cc b/src/draco/compression/mesh/mesh_edgebreaker_encoder_impl.cc index a307fa8..f69ec99 100644 --- a/src/draco/compression/mesh/mesh_edgebreaker_encoder_impl.cc +++ b/src/draco/compression/mesh/mesh_edgebreaker_encoder_impl.cc @@ -279,7 +279,7 @@ Status MeshEdgebreakerEncoderImpl::EncodeConnectivity() { corner_table_->num_faces() == corner_table_->NumDegeneratedFaces()) { // Failed to construct the corner table. // TODO(ostava): Add better error reporting. - return Status(Status::ERROR, "All triangles are degenerate."); + return Status(Status::DRACO_ERROR, "All triangles are degenerate."); } traversal_encoder_.Init(this); @@ -317,10 +317,10 @@ Status MeshEdgebreakerEncoderImpl::EncodeConnectivity() { pos_encoding_data_.num_values = 0; if (!FindHoles()) - return Status(Status::ERROR, "Failed to process mesh holes."); + return Status(Status::DRACO_ERROR, "Failed to process mesh holes."); if (!InitAttributeData()) - return Status(Status::ERROR, "Failed to initialize attribute data."); + return Status(Status::DRACO_ERROR, "Failed to initialize attribute data."); const uint8_t num_attribute_data = static_cast(attribute_data_.size()); @@ -376,7 +376,7 @@ Status MeshEdgebreakerEncoderImpl::EncodeConnectivity() { if (opp_face_id != kInvalidFaceIndex && !visited_faces_[opp_face_id.value()]) { if (!EncodeConnectivityFromCorner(opp_id)) - return Status(Status::ERROR, "Failed to encode mesh component."); + return Status(Status::DRACO_ERROR, "Failed to encode mesh component."); } } else { // Boundary configuration. We start on a boundary rather than on a face. @@ -385,7 +385,7 @@ Status MeshEdgebreakerEncoderImpl::EncodeConnectivity() { // Start processing the face opposite to the boundary edge (the face // containing the start_corner). if (!EncodeConnectivityFromCorner(start_corner)) - return Status(Status::ERROR, "Failed to encode mesh component."); + return Status(Status::DRACO_ERROR, "Failed to encode mesh component."); } } // Reverse the order of connectivity corners to match the order in which @@ -417,7 +417,7 @@ Status MeshEdgebreakerEncoderImpl::EncodeConnectivity() { // Append the traversal buffer. if (!EncodeSplitData()) - return Status(Status::ERROR, "Failed to encode split data."); + return Status(Status::DRACO_ERROR, "Failed to encode split data."); encoder_->buffer()->Encode(traversal_encoder_.buffer().data(), traversal_encoder_.buffer().size()); diff --git a/src/draco/compression/mesh/mesh_sequential_encoder.cc b/src/draco/compression/mesh/mesh_sequential_encoder.cc index b7ea9dc..b53ff0c 100644 --- a/src/draco/compression/mesh/mesh_sequential_encoder.cc +++ b/src/draco/compression/mesh/mesh_sequential_encoder.cc @@ -38,7 +38,7 @@ Status MeshSequentialEncoder::EncodeConnectivity() { // 0 = Encode compressed indices. buffer()->Encode(static_cast(0)); if (!CompressAndEncodeIndices()) - return Status(Status::ERROR, "Failed to compress connectivity."); + return Status(Status::DRACO_ERROR, "Failed to compress connectivity."); } else { // 1 = Encode indices directly. buffer()->Encode(static_cast(1)); diff --git a/src/draco/compression/point_cloud/point_cloud_decoder.cc b/src/draco/compression/point_cloud/point_cloud_decoder.cc index 5f3bff4..cf5d997 100644 --- a/src/draco/compression/point_cloud/point_cloud_decoder.cc +++ b/src/draco/compression/point_cloud/point_cloud_decoder.cc @@ -31,7 +31,7 @@ Status PointCloudDecoder::DecodeHeader(DecoderBuffer *buffer, if (!buffer->Decode(out_header->draco_string, 5)) return Status(Status::IO_ERROR, kIoErrorMsg); if (memcmp(out_header->draco_string, "DRACO", 5) != 0) - return Status(Status::ERROR, "Not a Draco file."); + return Status(Status::DRACO_ERROR, "Not a Draco file."); if (!buffer->Decode(&(out_header->version_major))) return Status(Status::IO_ERROR, kIoErrorMsg); if (!buffer->Decode(&(out_header->version_minor))) @@ -50,7 +50,7 @@ Status PointCloudDecoder::DecodeMetadata() { std::unique_ptr(new GeometryMetadata()); MetadataDecoder metadata_decoder; if (!metadata_decoder.DecodeGeometryMetadata(buffer_, metadata.get())) - return Status(Status::ERROR, "Failed to decode metadata."); + return Status(Status::DRACO_ERROR, "Failed to decode metadata."); point_cloud_->AddMetadata(std::move(metadata)); return OkStatus(); } @@ -66,7 +66,7 @@ Status PointCloudDecoder::Decode(const DecoderOptions &options, // Sanity check that we are really using the right decoder (mostly for cases // where the Decode method was called manually outside of our main API. if (header.encoder_type != GetGeometryType()) - return Status(Status::ERROR, + return Status(Status::DRACO_ERROR, "Using incompatible decoder for the input geometry."); // TODO(ostava): We should check the method as well, but currently decoders // don't expose the decoding method id. @@ -93,11 +93,11 @@ Status PointCloudDecoder::Decode(const DecoderOptions &options, DRACO_RETURN_IF_ERROR(DecodeMetadata()) } if (!InitializeDecoder()) - return Status(Status::ERROR, "Failed to initialize the decoder."); + return Status(Status::DRACO_ERROR, "Failed to initialize the decoder."); if (!DecodeGeometryData()) - return Status(Status::ERROR, "Failed to decode geometry data."); + return Status(Status::DRACO_ERROR, "Failed to decode geometry data."); if (!DecodePointAttributes()) - return Status(Status::ERROR, "Failed to decode point attributes."); + return Status(Status::DRACO_ERROR, "Failed to decode point attributes."); return OkStatus(); } diff --git a/src/draco/compression/point_cloud/point_cloud_encoder.cc b/src/draco/compression/point_cloud/point_cloud_encoder.cc index 7b4a4b0..9867065 100644 --- a/src/draco/compression/point_cloud/point_cloud_encoder.cc +++ b/src/draco/compression/point_cloud/point_cloud_encoder.cc @@ -36,16 +36,16 @@ Status PointCloudEncoder::Encode(const EncoderOptions &options, attributes_encoder_ids_order_.clear(); if (!point_cloud_) - return Status(Status::ERROR, "Invalid input geometry."); + return Status(Status::DRACO_ERROR, "Invalid input geometry."); DRACO_RETURN_IF_ERROR(EncodeHeader()) DRACO_RETURN_IF_ERROR(EncodeMetadata()) if (!InitializeEncoder()) - return Status(Status::ERROR, "Failed to initialize encoder."); + return Status(Status::DRACO_ERROR, "Failed to initialize encoder."); if (!EncodeEncoderData()) - return Status(Status::ERROR, "Failed to encode internal data."); + return Status(Status::DRACO_ERROR, "Failed to encode internal data."); DRACO_RETURN_IF_ERROR(EncodeGeometryData()); if (!EncodePointAttributes()) - return Status(Status::ERROR, "Failed to encode point attributes."); + return Status(Status::DRACO_ERROR, "Failed to encode point attributes."); if (options.GetGlobalBool("store_number_of_encoded_points", false)) ComputeNumberOfEncodedPoints(); return OkStatus(); @@ -86,7 +86,7 @@ Status PointCloudEncoder::EncodeMetadata() { MetadataEncoder metadata_encoder; if (!metadata_encoder.EncodeGeometryMetadata(buffer_, point_cloud_->GetMetadata())) { - return Status(Status::ERROR, "Failed to encode metadata."); + return Status(Status::DRACO_ERROR, "Failed to encode metadata."); } return OkStatus(); } diff --git a/src/draco/core/status.h b/src/draco/core/status.h index 0a483f0..9ac3def 100644 --- a/src/draco/core/status.h +++ b/src/draco/core/status.h @@ -25,7 +25,7 @@ class Status { public: enum Code { OK = 0, - ERROR = -1, // Used for general errors. + DRACO_ERROR = -1, // Used for general errors. IO_ERROR = -2, // Error when handling input or output stream. INVALID_PARAMETER = -3, // Invalid parameter passed to a function. UNSUPPORTED_VERSION = -4, // Input not compatible with the current version. diff --git a/src/draco/core/status_test.cc b/src/draco/core/status_test.cc index 451ebe2..c1ad4ab 100644 --- a/src/draco/core/status_test.cc +++ b/src/draco/core/status_test.cc @@ -27,8 +27,8 @@ class StatusTest : public ::testing::Test { TEST_F(StatusTest, TestStatusOutput) { // Tests that the Status can be stored in a provided std::ostream. - const draco::Status status(draco::Status::ERROR, "Error msg."); - ASSERT_EQ(status.code(), draco::Status::ERROR); + const draco::Status status(draco::Status::DRACO_ERROR, "Error msg."); + ASSERT_EQ(status.code(), draco::Status::DRACO_ERROR); std::stringstream str; str << status; diff --git a/src/draco/io/mesh_io.cc b/src/draco/io/mesh_io.cc index 11e90ab..5e2f9f5 100644 --- a/src/draco/io/mesh_io.cc +++ b/src/draco/io/mesh_io.cc @@ -59,9 +59,9 @@ StatusOr> ReadMeshFromFile(const std::string &file_name, // draco encoding methods. std::ifstream is(file_name.c_str(), std::ios::binary); if (!is) - return Status(Status::ERROR, "Invalid input stream."); + return Status(Status::DRACO_ERROR, "Invalid input stream."); if (!ReadMeshFromStream(&mesh, is).good()) - return Status(Status::ERROR, + return Status(Status::DRACO_ERROR, "Unknown error."); // Error reading the stream. return std::move(mesh); } diff --git a/src/draco/io/obj_decoder.cc b/src/draco/io/obj_decoder.cc index c134b94..88f470f 100644 --- a/src/draco/io/obj_decoder.cc +++ b/src/draco/io/obj_decoder.cc @@ -104,12 +104,12 @@ Status ObjDecoder::DecodeInternal() { // Ensure the number of all entries is same for all attributes. if (num_positions_ == 0) - return Status(Status::ERROR, "No position attribute"); + return Status(Status::DRACO_ERROR, "No position attribute"); if (num_tex_coords_ > 0 && num_tex_coords_ != num_positions_) - return Status(Status::ERROR, + return Status(Status::DRACO_ERROR, "Invalid number of texture coordinates for a point cloud"); if (num_normals_ > 0 && num_normals_ != num_positions_) - return Status(Status::ERROR, + return Status(Status::DRACO_ERROR, "Invalid number of normals for a point cloud"); out_mesh_ = nullptr; // Treat the output geometry as a point cloud. @@ -303,7 +303,7 @@ bool ObjDecoder::ParseVertexPosition(Status *status) { for (int i = 0; i < 3; ++i) { parser::SkipWhitespace(buffer()); if (!parser::ParseFloat(buffer(), val + i)) { - *status = Status(Status::ERROR, "Failed to parse a float number"); + *status = Status(Status::DRACO_ERROR, "Failed to parse a float number"); // The definition is processed so return true. return true; } @@ -331,7 +331,7 @@ bool ObjDecoder::ParseNormal(Status *status) { for (int i = 0; i < 3; ++i) { parser::SkipWhitespace(buffer()); if (!parser::ParseFloat(buffer(), val + i)) { - *status = Status(Status::ERROR, "Failed to parse a float number"); + *status = Status(Status::DRACO_ERROR, "Failed to parse a float number"); // The definition is processed so return true. return true; } @@ -359,7 +359,7 @@ bool ObjDecoder::ParseTexCoord(Status *status) { for (int i = 0; i < 2; ++i) { parser::SkipWhitespace(buffer()); if (!parser::ParseFloat(buffer(), val + i)) { - *status = Status(Status::ERROR, "Failed to parse a float number"); + *status = Status(Status::DRACO_ERROR, "Failed to parse a float number"); // The definition is processed so return true. return true; } @@ -390,7 +390,7 @@ bool ObjDecoder::ParseFace(Status *status) { if (i == 3) { break; // It's OK if there is no fourth vertex index. } - *status = Status(Status::ERROR, "Failed to parse vertex indices"); + *status = Status(Status::DRACO_ERROR, "Failed to parse vertex indices"); return true; } ++num_valid_indices; @@ -435,7 +435,8 @@ bool ObjDecoder::ParseFace(Status *status) { } } if (num_indices < 3 || num_indices > 4) { - *status = Status(Status::ERROR, "Invalid number of indices on a face"); + *status = + Status(Status::DRACO_ERROR, "Invalid number of indices on a face"); return false; } // Either one or two new triangles. @@ -460,7 +461,7 @@ bool ObjDecoder::ParseMaterialLib(Status *status) { parser::SkipWhitespace(&line_buffer); material_file_name_.clear(); if (!parser::ParseString(&line_buffer, &material_file_name_)) { - *status = Status(Status::ERROR, "Failed to parse material file name"); + *status = Status(Status::DRACO_ERROR, "Failed to parse material file name"); return true; } parser::SkipLine(&line_buffer); diff --git a/src/draco/io/ply_decoder.cc b/src/draco/io/ply_decoder.cc index 0dde8d1..69a1c54 100644 --- a/src/draco/io/ply_decoder.cc +++ b/src/draco/io/ply_decoder.cc @@ -75,7 +75,8 @@ Status PlyDecoder::DecodeInternal() { if (out_mesh_ && out_mesh_->num_faces() != 0) { #ifdef DRACO_ATTRIBUTE_VALUES_DEDUPLICATION_SUPPORTED if (!out_point_cloud_->DeduplicateAttributeValues()) - return Status(Status::ERROR, "Could not deduplicate attribute values"); + return Status(Status::DRACO_ERROR, + "Could not deduplicate attribute values"); #endif #ifdef DRACO_ATTRIBUTE_INDICES_DEDUPLICATION_SUPPORTED out_point_cloud_->DeduplicatePointIds(); @@ -98,7 +99,7 @@ Status PlyDecoder::DecodeFaceData(const PlyElement *face_element) { vertex_indices = face_element->GetPropertyByName("vertex_index"); } if (vertex_indices == nullptr || !vertex_indices->is_list()) { - return Status(Status::ERROR, "No faces defined"); + return Status(Status::DRACO_ERROR, "No faces defined"); } PlyPropertyReader vertex_index_reader(vertex_indices); diff --git a/src/draco/io/ply_decoder_test.cc b/src/draco/io/ply_decoder_test.cc index 93d0cbd..647324e 100644 --- a/src/draco/io/ply_decoder_test.cc +++ b/src/draco/io/ply_decoder_test.cc @@ -28,7 +28,7 @@ class PlyDecoderTest : public ::testing::Test { std::unique_ptr geometry(new Geometry()); Status status = decoder.DecodeFromFile(path, geometry.get()); if (!status.ok()) { - LOG(ERROR) << "Failed to decode " << file_name << ": " << status; + LOG(DRACO_ERROR) << "Failed to decode " << file_name << ": " << status; return nullptr; } return geometry; diff --git a/src/draco/io/point_cloud_io.cc b/src/draco/io/point_cloud_io.cc index 9720c5d..e91142e 100644 --- a/src/draco/io/point_cloud_io.cc +++ b/src/draco/io/point_cloud_io.cc @@ -48,9 +48,9 @@ StatusOr> ReadPointCloudFromFile( // draco encoding methods. std::ifstream is(file_name.c_str(), std::ios::binary); if (!is) - return Status(Status::ERROR, "Invalid input stream."); + return Status(Status::DRACO_ERROR, "Invalid input stream."); if (!ReadPointCloudFromStream(&pc, is).good()) - return Status(Status::ERROR, + return Status(Status::DRACO_ERROR, "Unknown error."); // Error reading the stream. return std::move(pc); }