mirror of
https://git.mirrors.martin98.com/https://github.com/google/draco
synced 2025-08-12 02:29:00 +08:00
Merge pull request #535 from google/draco_error
Rename Status::ERROR to Status::DRACO_ERROR.
This commit is contained in:
commit
7e3a61d46d
@ -37,7 +37,7 @@ StatusOr<std::unique_ptr<PointCloudDecoder>> CreatePointCloudDecoder(
|
|||||||
} else if (method == POINT_CLOUD_KD_TREE_ENCODING) {
|
} else if (method == POINT_CLOUD_KD_TREE_ENCODING) {
|
||||||
return std::unique_ptr<PointCloudDecoder>(new PointCloudKdTreeDecoder());
|
return std::unique_ptr<PointCloudDecoder>(new PointCloudKdTreeDecoder());
|
||||||
}
|
}
|
||||||
return Status(Status::ERROR, "Unsupported encoding method.");
|
return Status(Status::DRACO_ERROR, "Unsupported encoding method.");
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -48,7 +48,7 @@ StatusOr<std::unique_ptr<MeshDecoder>> CreateMeshDecoder(uint8_t method) {
|
|||||||
} else if (method == MESH_EDGEBREAKER_ENCODING) {
|
} else if (method == MESH_EDGEBREAKER_ENCODING) {
|
||||||
return std::unique_ptr<MeshDecoder>(new MeshEdgebreakerDecoder());
|
return std::unique_ptr<MeshDecoder>(new MeshEdgebreakerDecoder());
|
||||||
}
|
}
|
||||||
return Status(Status::ERROR, "Unsupported encoding method.");
|
return Status(Status::DRACO_ERROR, "Unsupported encoding method.");
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -77,7 +77,7 @@ StatusOr<std::unique_ptr<PointCloud>> Decoder::DecodePointCloudFromBuffer(
|
|||||||
return static_cast<std::unique_ptr<PointCloud>>(std::move(mesh));
|
return static_cast<std::unique_ptr<PointCloud>>(std::move(mesh));
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
return Status(Status::ERROR, "Unsupported geometry type.");
|
return Status(Status::DRACO_ERROR, "Unsupported geometry type.");
|
||||||
}
|
}
|
||||||
|
|
||||||
StatusOr<std::unique_ptr<Mesh>> Decoder::DecodeMeshFromBuffer(
|
StatusOr<std::unique_ptr<Mesh>> Decoder::DecodeMeshFromBuffer(
|
||||||
@ -94,7 +94,7 @@ Status Decoder::DecodeBufferToGeometry(DecoderBuffer *in_buffer,
|
|||||||
DracoHeader header;
|
DracoHeader header;
|
||||||
DRACO_RETURN_IF_ERROR(PointCloudDecoder::DecodeHeader(&temp_buffer, &header))
|
DRACO_RETURN_IF_ERROR(PointCloudDecoder::DecodeHeader(&temp_buffer, &header))
|
||||||
if (header.encoder_type != POINT_CLOUD) {
|
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<PointCloudDecoder> decoder,
|
DRACO_ASSIGN_OR_RETURN(std::unique_ptr<PointCloudDecoder> decoder,
|
||||||
CreatePointCloudDecoder(header.encoder_method))
|
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))
|
DRACO_RETURN_IF_ERROR(decoder->Decode(options_, in_buffer, out_geometry))
|
||||||
return OkStatus();
|
return OkStatus();
|
||||||
#else
|
#else
|
||||||
return Status(Status::ERROR, "Unsupported geometry type.");
|
return Status(Status::DRACO_ERROR, "Unsupported geometry type.");
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -113,7 +113,7 @@ Status Decoder::DecodeBufferToGeometry(DecoderBuffer *in_buffer,
|
|||||||
DracoHeader header;
|
DracoHeader header;
|
||||||
DRACO_RETURN_IF_ERROR(PointCloudDecoder::DecodeHeader(&temp_buffer, &header))
|
DRACO_RETURN_IF_ERROR(PointCloudDecoder::DecodeHeader(&temp_buffer, &header))
|
||||||
if (header.encoder_type != TRIANGULAR_MESH) {
|
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<MeshDecoder> decoder,
|
DRACO_ASSIGN_OR_RETURN(std::unique_ptr<MeshDecoder> decoder,
|
||||||
CreateMeshDecoder(header.encoder_method))
|
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))
|
DRACO_RETURN_IF_ERROR(decoder->Decode(options_, in_buffer, out_geometry))
|
||||||
return OkStatus();
|
return OkStatus();
|
||||||
#else
|
#else
|
||||||
return Status(Status::ERROR, "Unsupported geometry type.");
|
return Status(Status::DRACO_ERROR, "Unsupported geometry type.");
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -69,25 +69,27 @@ class EncoderBase {
|
|||||||
int prediction_scheme) const {
|
int prediction_scheme) const {
|
||||||
// Out of bound checks:
|
// Out of bound checks:
|
||||||
if (prediction_scheme < PREDICTION_NONE)
|
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)
|
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:
|
// Deprecated prediction schemes:
|
||||||
if (prediction_scheme == MESH_PREDICTION_TEX_COORDS_DEPRECATED)
|
if (prediction_scheme == MESH_PREDICTION_TEX_COORDS_DEPRECATED)
|
||||||
return Status(Status::ERROR,
|
return Status(Status::DRACO_ERROR,
|
||||||
"MESH_PREDICTION_TEX_COORDS_DEPRECATED is deprecated.");
|
"MESH_PREDICTION_TEX_COORDS_DEPRECATED is deprecated.");
|
||||||
if (prediction_scheme == MESH_PREDICTION_MULTI_PARALLELOGRAM)
|
if (prediction_scheme == MESH_PREDICTION_MULTI_PARALLELOGRAM)
|
||||||
return Status(Status::ERROR,
|
return Status(Status::DRACO_ERROR,
|
||||||
"MESH_PREDICTION_MULTI_PARALLELOGRAM is deprecated.");
|
"MESH_PREDICTION_MULTI_PARALLELOGRAM is deprecated.");
|
||||||
// Attribute specific checks:
|
// Attribute specific checks:
|
||||||
if (prediction_scheme == MESH_PREDICTION_TEX_COORDS_PORTABLE) {
|
if (prediction_scheme == MESH_PREDICTION_TEX_COORDS_PORTABLE) {
|
||||||
if (att_type != GeometryAttribute::TEX_COORD)
|
if (att_type != GeometryAttribute::TEX_COORD)
|
||||||
return Status(Status::ERROR,
|
return Status(Status::DRACO_ERROR,
|
||||||
"Invalid prediction scheme for attribute type.");
|
"Invalid prediction scheme for attribute type.");
|
||||||
}
|
}
|
||||||
if (prediction_scheme == MESH_PREDICTION_GEOMETRIC_NORMAL) {
|
if (prediction_scheme == MESH_PREDICTION_GEOMETRIC_NORMAL) {
|
||||||
if (att_type != GeometryAttribute::NORMAL) {
|
if (att_type != GeometryAttribute::NORMAL) {
|
||||||
return Status(Status::ERROR,
|
return Status(Status::DRACO_ERROR,
|
||||||
"Invalid prediction scheme for attribute type.");
|
"Invalid prediction scheme for attribute type.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -95,7 +97,7 @@ class EncoderBase {
|
|||||||
if (att_type == GeometryAttribute::NORMAL) {
|
if (att_type == GeometryAttribute::NORMAL) {
|
||||||
if (!(prediction_scheme == PREDICTION_DIFFERENCE ||
|
if (!(prediction_scheme == PREDICTION_DIFFERENCE ||
|
||||||
prediction_scheme == MESH_PREDICTION_GEOMETRIC_NORMAL)) {
|
prediction_scheme == MESH_PREDICTION_GEOMETRIC_NORMAL)) {
|
||||||
return Status(Status::ERROR,
|
return Status(Status::DRACO_ERROR,
|
||||||
"Invalid prediction scheme for attribute type.");
|
"Invalid prediction scheme for attribute type.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,7 @@ ExpertEncoder::ExpertEncoder(const Mesh &mesh)
|
|||||||
|
|
||||||
Status ExpertEncoder::EncodeToBuffer(EncoderBuffer *out_buffer) {
|
Status ExpertEncoder::EncodeToBuffer(EncoderBuffer *out_buffer) {
|
||||||
if (point_cloud_ == nullptr)
|
if (point_cloud_ == nullptr)
|
||||||
return Status(Status::ERROR, "Invalid input geometry.");
|
return Status(Status::DRACO_ERROR, "Invalid input geometry.");
|
||||||
if (mesh_ == nullptr) {
|
if (mesh_ == nullptr) {
|
||||||
return EncodePointCloudToBuffer(*point_cloud_, out_buffer);
|
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) {
|
} else if (encoding_method == POINT_CLOUD_KD_TREE_ENCODING) {
|
||||||
// Encoding method was explicitly specified but we cannot use it for
|
// Encoding method was explicitly specified but we cannot use it for
|
||||||
// the given input (some of the checks above failed).
|
// 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) {
|
if (!encoder) {
|
||||||
@ -91,7 +91,7 @@ Status ExpertEncoder::EncodePointCloudToBuffer(const PointCloud &pc,
|
|||||||
set_num_encoded_faces(0);
|
set_num_encoded_faces(0);
|
||||||
return OkStatus();
|
return OkStatus();
|
||||||
#else
|
#else
|
||||||
return Status(Status::ERROR, "Point cloud encoding is not enabled.");
|
return Status(Status::DRACO_ERROR, "Point cloud encoding is not enabled.");
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -279,7 +279,7 @@ Status MeshEdgebreakerEncoderImpl<TraversalEncoder>::EncodeConnectivity() {
|
|||||||
corner_table_->num_faces() == corner_table_->NumDegeneratedFaces()) {
|
corner_table_->num_faces() == corner_table_->NumDegeneratedFaces()) {
|
||||||
// Failed to construct the corner table.
|
// Failed to construct the corner table.
|
||||||
// TODO(ostava): Add better error reporting.
|
// 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);
|
traversal_encoder_.Init(this);
|
||||||
@ -317,10 +317,10 @@ Status MeshEdgebreakerEncoderImpl<TraversalEncoder>::EncodeConnectivity() {
|
|||||||
pos_encoding_data_.num_values = 0;
|
pos_encoding_data_.num_values = 0;
|
||||||
|
|
||||||
if (!FindHoles())
|
if (!FindHoles())
|
||||||
return Status(Status::ERROR, "Failed to process mesh holes.");
|
return Status(Status::DRACO_ERROR, "Failed to process mesh holes.");
|
||||||
|
|
||||||
if (!InitAttributeData())
|
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 =
|
const uint8_t num_attribute_data =
|
||||||
static_cast<uint8_t>(attribute_data_.size());
|
static_cast<uint8_t>(attribute_data_.size());
|
||||||
@ -376,7 +376,7 @@ Status MeshEdgebreakerEncoderImpl<TraversalEncoder>::EncodeConnectivity() {
|
|||||||
if (opp_face_id != kInvalidFaceIndex &&
|
if (opp_face_id != kInvalidFaceIndex &&
|
||||||
!visited_faces_[opp_face_id.value()]) {
|
!visited_faces_[opp_face_id.value()]) {
|
||||||
if (!EncodeConnectivityFromCorner(opp_id))
|
if (!EncodeConnectivityFromCorner(opp_id))
|
||||||
return Status(Status::ERROR, "Failed to encode mesh component.");
|
return Status(Status::DRACO_ERROR, "Failed to encode mesh component.");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Boundary configuration. We start on a boundary rather than on a face.
|
// Boundary configuration. We start on a boundary rather than on a face.
|
||||||
@ -385,7 +385,7 @@ Status MeshEdgebreakerEncoderImpl<TraversalEncoder>::EncodeConnectivity() {
|
|||||||
// Start processing the face opposite to the boundary edge (the face
|
// Start processing the face opposite to the boundary edge (the face
|
||||||
// containing the start_corner).
|
// containing the start_corner).
|
||||||
if (!EncodeConnectivityFromCorner(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
|
// Reverse the order of connectivity corners to match the order in which
|
||||||
@ -417,7 +417,7 @@ Status MeshEdgebreakerEncoderImpl<TraversalEncoder>::EncodeConnectivity() {
|
|||||||
|
|
||||||
// Append the traversal buffer.
|
// Append the traversal buffer.
|
||||||
if (!EncodeSplitData())
|
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(),
|
encoder_->buffer()->Encode(traversal_encoder_.buffer().data(),
|
||||||
traversal_encoder_.buffer().size());
|
traversal_encoder_.buffer().size());
|
||||||
|
|
||||||
|
@ -38,7 +38,7 @@ Status MeshSequentialEncoder::EncodeConnectivity() {
|
|||||||
// 0 = Encode compressed indices.
|
// 0 = Encode compressed indices.
|
||||||
buffer()->Encode(static_cast<uint8_t>(0));
|
buffer()->Encode(static_cast<uint8_t>(0));
|
||||||
if (!CompressAndEncodeIndices())
|
if (!CompressAndEncodeIndices())
|
||||||
return Status(Status::ERROR, "Failed to compress connectivity.");
|
return Status(Status::DRACO_ERROR, "Failed to compress connectivity.");
|
||||||
} else {
|
} else {
|
||||||
// 1 = Encode indices directly.
|
// 1 = Encode indices directly.
|
||||||
buffer()->Encode(static_cast<uint8_t>(1));
|
buffer()->Encode(static_cast<uint8_t>(1));
|
||||||
|
@ -31,7 +31,7 @@ Status PointCloudDecoder::DecodeHeader(DecoderBuffer *buffer,
|
|||||||
if (!buffer->Decode(out_header->draco_string, 5))
|
if (!buffer->Decode(out_header->draco_string, 5))
|
||||||
return Status(Status::IO_ERROR, kIoErrorMsg);
|
return Status(Status::IO_ERROR, kIoErrorMsg);
|
||||||
if (memcmp(out_header->draco_string, "DRACO", 5) != 0)
|
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)))
|
if (!buffer->Decode(&(out_header->version_major)))
|
||||||
return Status(Status::IO_ERROR, kIoErrorMsg);
|
return Status(Status::IO_ERROR, kIoErrorMsg);
|
||||||
if (!buffer->Decode(&(out_header->version_minor)))
|
if (!buffer->Decode(&(out_header->version_minor)))
|
||||||
@ -50,7 +50,7 @@ Status PointCloudDecoder::DecodeMetadata() {
|
|||||||
std::unique_ptr<GeometryMetadata>(new GeometryMetadata());
|
std::unique_ptr<GeometryMetadata>(new GeometryMetadata());
|
||||||
MetadataDecoder metadata_decoder;
|
MetadataDecoder metadata_decoder;
|
||||||
if (!metadata_decoder.DecodeGeometryMetadata(buffer_, metadata.get()))
|
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));
|
point_cloud_->AddMetadata(std::move(metadata));
|
||||||
return OkStatus();
|
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
|
// 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.
|
// where the Decode method was called manually outside of our main API.
|
||||||
if (header.encoder_type != GetGeometryType())
|
if (header.encoder_type != GetGeometryType())
|
||||||
return Status(Status::ERROR,
|
return Status(Status::DRACO_ERROR,
|
||||||
"Using incompatible decoder for the input geometry.");
|
"Using incompatible decoder for the input geometry.");
|
||||||
// TODO(ostava): We should check the method as well, but currently decoders
|
// TODO(ostava): We should check the method as well, but currently decoders
|
||||||
// don't expose the decoding method id.
|
// don't expose the decoding method id.
|
||||||
@ -93,11 +93,11 @@ Status PointCloudDecoder::Decode(const DecoderOptions &options,
|
|||||||
DRACO_RETURN_IF_ERROR(DecodeMetadata())
|
DRACO_RETURN_IF_ERROR(DecodeMetadata())
|
||||||
}
|
}
|
||||||
if (!InitializeDecoder())
|
if (!InitializeDecoder())
|
||||||
return Status(Status::ERROR, "Failed to initialize the decoder.");
|
return Status(Status::DRACO_ERROR, "Failed to initialize the decoder.");
|
||||||
if (!DecodeGeometryData())
|
if (!DecodeGeometryData())
|
||||||
return Status(Status::ERROR, "Failed to decode geometry data.");
|
return Status(Status::DRACO_ERROR, "Failed to decode geometry data.");
|
||||||
if (!DecodePointAttributes())
|
if (!DecodePointAttributes())
|
||||||
return Status(Status::ERROR, "Failed to decode point attributes.");
|
return Status(Status::DRACO_ERROR, "Failed to decode point attributes.");
|
||||||
return OkStatus();
|
return OkStatus();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,16 +36,16 @@ Status PointCloudEncoder::Encode(const EncoderOptions &options,
|
|||||||
attributes_encoder_ids_order_.clear();
|
attributes_encoder_ids_order_.clear();
|
||||||
|
|
||||||
if (!point_cloud_)
|
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(EncodeHeader())
|
||||||
DRACO_RETURN_IF_ERROR(EncodeMetadata())
|
DRACO_RETURN_IF_ERROR(EncodeMetadata())
|
||||||
if (!InitializeEncoder())
|
if (!InitializeEncoder())
|
||||||
return Status(Status::ERROR, "Failed to initialize encoder.");
|
return Status(Status::DRACO_ERROR, "Failed to initialize encoder.");
|
||||||
if (!EncodeEncoderData())
|
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());
|
DRACO_RETURN_IF_ERROR(EncodeGeometryData());
|
||||||
if (!EncodePointAttributes())
|
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))
|
if (options.GetGlobalBool("store_number_of_encoded_points", false))
|
||||||
ComputeNumberOfEncodedPoints();
|
ComputeNumberOfEncodedPoints();
|
||||||
return OkStatus();
|
return OkStatus();
|
||||||
@ -86,7 +86,7 @@ Status PointCloudEncoder::EncodeMetadata() {
|
|||||||
MetadataEncoder metadata_encoder;
|
MetadataEncoder metadata_encoder;
|
||||||
if (!metadata_encoder.EncodeGeometryMetadata(buffer_,
|
if (!metadata_encoder.EncodeGeometryMetadata(buffer_,
|
||||||
point_cloud_->GetMetadata())) {
|
point_cloud_->GetMetadata())) {
|
||||||
return Status(Status::ERROR, "Failed to encode metadata.");
|
return Status(Status::DRACO_ERROR, "Failed to encode metadata.");
|
||||||
}
|
}
|
||||||
return OkStatus();
|
return OkStatus();
|
||||||
}
|
}
|
||||||
|
@ -25,7 +25,7 @@ class Status {
|
|||||||
public:
|
public:
|
||||||
enum Code {
|
enum Code {
|
||||||
OK = 0,
|
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.
|
IO_ERROR = -2, // Error when handling input or output stream.
|
||||||
INVALID_PARAMETER = -3, // Invalid parameter passed to a function.
|
INVALID_PARAMETER = -3, // Invalid parameter passed to a function.
|
||||||
UNSUPPORTED_VERSION = -4, // Input not compatible with the current version.
|
UNSUPPORTED_VERSION = -4, // Input not compatible with the current version.
|
||||||
|
@ -27,8 +27,8 @@ class StatusTest : public ::testing::Test {
|
|||||||
|
|
||||||
TEST_F(StatusTest, TestStatusOutput) {
|
TEST_F(StatusTest, TestStatusOutput) {
|
||||||
// Tests that the Status can be stored in a provided std::ostream.
|
// Tests that the Status can be stored in a provided std::ostream.
|
||||||
const draco::Status status(draco::Status::ERROR, "Error msg.");
|
const draco::Status status(draco::Status::DRACO_ERROR, "Error msg.");
|
||||||
ASSERT_EQ(status.code(), draco::Status::ERROR);
|
ASSERT_EQ(status.code(), draco::Status::DRACO_ERROR);
|
||||||
|
|
||||||
std::stringstream str;
|
std::stringstream str;
|
||||||
str << status;
|
str << status;
|
||||||
|
@ -59,9 +59,9 @@ StatusOr<std::unique_ptr<Mesh>> ReadMeshFromFile(const std::string &file_name,
|
|||||||
// draco encoding methods.
|
// draco encoding methods.
|
||||||
std::ifstream is(file_name.c_str(), std::ios::binary);
|
std::ifstream is(file_name.c_str(), std::ios::binary);
|
||||||
if (!is)
|
if (!is)
|
||||||
return Status(Status::ERROR, "Invalid input stream.");
|
return Status(Status::DRACO_ERROR, "Invalid input stream.");
|
||||||
if (!ReadMeshFromStream(&mesh, is).good())
|
if (!ReadMeshFromStream(&mesh, is).good())
|
||||||
return Status(Status::ERROR,
|
return Status(Status::DRACO_ERROR,
|
||||||
"Unknown error."); // Error reading the stream.
|
"Unknown error."); // Error reading the stream.
|
||||||
return std::move(mesh);
|
return std::move(mesh);
|
||||||
}
|
}
|
||||||
|
@ -104,12 +104,12 @@ Status ObjDecoder::DecodeInternal() {
|
|||||||
|
|
||||||
// Ensure the number of all entries is same for all attributes.
|
// Ensure the number of all entries is same for all attributes.
|
||||||
if (num_positions_ == 0)
|
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_)
|
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");
|
"Invalid number of texture coordinates for a point cloud");
|
||||||
if (num_normals_ > 0 && num_normals_ != num_positions_)
|
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");
|
"Invalid number of normals for a point cloud");
|
||||||
|
|
||||||
out_mesh_ = nullptr; // Treat the output geometry as 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) {
|
for (int i = 0; i < 3; ++i) {
|
||||||
parser::SkipWhitespace(buffer());
|
parser::SkipWhitespace(buffer());
|
||||||
if (!parser::ParseFloat(buffer(), val + i)) {
|
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.
|
// The definition is processed so return true.
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -331,7 +331,7 @@ bool ObjDecoder::ParseNormal(Status *status) {
|
|||||||
for (int i = 0; i < 3; ++i) {
|
for (int i = 0; i < 3; ++i) {
|
||||||
parser::SkipWhitespace(buffer());
|
parser::SkipWhitespace(buffer());
|
||||||
if (!parser::ParseFloat(buffer(), val + i)) {
|
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.
|
// The definition is processed so return true.
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -359,7 +359,7 @@ bool ObjDecoder::ParseTexCoord(Status *status) {
|
|||||||
for (int i = 0; i < 2; ++i) {
|
for (int i = 0; i < 2; ++i) {
|
||||||
parser::SkipWhitespace(buffer());
|
parser::SkipWhitespace(buffer());
|
||||||
if (!parser::ParseFloat(buffer(), val + i)) {
|
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.
|
// The definition is processed so return true.
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -390,7 +390,7 @@ bool ObjDecoder::ParseFace(Status *status) {
|
|||||||
if (i == 3) {
|
if (i == 3) {
|
||||||
break; // It's OK if there is no fourth vertex index.
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
++num_valid_indices;
|
++num_valid_indices;
|
||||||
@ -435,7 +435,8 @@ bool ObjDecoder::ParseFace(Status *status) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (num_indices < 3 || num_indices > 4) {
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
// Either one or two new triangles.
|
// Either one or two new triangles.
|
||||||
@ -460,7 +461,7 @@ bool ObjDecoder::ParseMaterialLib(Status *status) {
|
|||||||
parser::SkipWhitespace(&line_buffer);
|
parser::SkipWhitespace(&line_buffer);
|
||||||
material_file_name_.clear();
|
material_file_name_.clear();
|
||||||
if (!parser::ParseString(&line_buffer, &material_file_name_)) {
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
parser::SkipLine(&line_buffer);
|
parser::SkipLine(&line_buffer);
|
||||||
|
@ -75,7 +75,8 @@ Status PlyDecoder::DecodeInternal() {
|
|||||||
if (out_mesh_ && out_mesh_->num_faces() != 0) {
|
if (out_mesh_ && out_mesh_->num_faces() != 0) {
|
||||||
#ifdef DRACO_ATTRIBUTE_VALUES_DEDUPLICATION_SUPPORTED
|
#ifdef DRACO_ATTRIBUTE_VALUES_DEDUPLICATION_SUPPORTED
|
||||||
if (!out_point_cloud_->DeduplicateAttributeValues())
|
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
|
#endif
|
||||||
#ifdef DRACO_ATTRIBUTE_INDICES_DEDUPLICATION_SUPPORTED
|
#ifdef DRACO_ATTRIBUTE_INDICES_DEDUPLICATION_SUPPORTED
|
||||||
out_point_cloud_->DeduplicatePointIds();
|
out_point_cloud_->DeduplicatePointIds();
|
||||||
@ -98,7 +99,7 @@ Status PlyDecoder::DecodeFaceData(const PlyElement *face_element) {
|
|||||||
vertex_indices = face_element->GetPropertyByName("vertex_index");
|
vertex_indices = face_element->GetPropertyByName("vertex_index");
|
||||||
}
|
}
|
||||||
if (vertex_indices == nullptr || !vertex_indices->is_list()) {
|
if (vertex_indices == nullptr || !vertex_indices->is_list()) {
|
||||||
return Status(Status::ERROR, "No faces defined");
|
return Status(Status::DRACO_ERROR, "No faces defined");
|
||||||
}
|
}
|
||||||
|
|
||||||
PlyPropertyReader<PointIndex::ValueType> vertex_index_reader(vertex_indices);
|
PlyPropertyReader<PointIndex::ValueType> vertex_index_reader(vertex_indices);
|
||||||
|
@ -28,7 +28,7 @@ class PlyDecoderTest : public ::testing::Test {
|
|||||||
std::unique_ptr<Geometry> geometry(new Geometry());
|
std::unique_ptr<Geometry> geometry(new Geometry());
|
||||||
Status status = decoder.DecodeFromFile(path, geometry.get());
|
Status status = decoder.DecodeFromFile(path, geometry.get());
|
||||||
if (!status.ok()) {
|
if (!status.ok()) {
|
||||||
LOG(ERROR) << "Failed to decode " << file_name << ": " << status;
|
LOG(DRACO_ERROR) << "Failed to decode " << file_name << ": " << status;
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
return geometry;
|
return geometry;
|
||||||
|
@ -48,9 +48,9 @@ StatusOr<std::unique_ptr<PointCloud>> ReadPointCloudFromFile(
|
|||||||
// draco encoding methods.
|
// draco encoding methods.
|
||||||
std::ifstream is(file_name.c_str(), std::ios::binary);
|
std::ifstream is(file_name.c_str(), std::ios::binary);
|
||||||
if (!is)
|
if (!is)
|
||||||
return Status(Status::ERROR, "Invalid input stream.");
|
return Status(Status::DRACO_ERROR, "Invalid input stream.");
|
||||||
if (!ReadPointCloudFromStream(&pc, is).good())
|
if (!ReadPointCloudFromStream(&pc, is).good())
|
||||||
return Status(Status::ERROR,
|
return Status(Status::DRACO_ERROR,
|
||||||
"Unknown error."); // Error reading the stream.
|
"Unknown error."); // Error reading the stream.
|
||||||
return std::move(pc);
|
return std::move(pc);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user