Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions src/draco/compression/decode.cc
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ StatusOr<std::unique_ptr<PointCloudDecoder>> CreatePointCloudDecoder(
} else if (method == POINT_CLOUD_KD_TREE_ENCODING) {
return std::unique_ptr<PointCloudDecoder>(new PointCloudKdTreeDecoder());
}
return Status(Status::ERROR, "Unsupported encoding method.");
return Status(Status::DRACO_ERROR, "Unsupported encoding method.");
}
#endif

Expand All @@ -48,7 +48,7 @@ StatusOr<std::unique_ptr<MeshDecoder>> CreateMeshDecoder(uint8_t method) {
} else if (method == MESH_EDGEBREAKER_ENCODING) {
return std::unique_ptr<MeshDecoder>(new MeshEdgebreakerDecoder());
}
return Status(Status::ERROR, "Unsupported encoding method.");
return Status(Status::DRACO_ERROR, "Unsupported encoding method.");
}
#endif

Expand Down Expand Up @@ -77,7 +77,7 @@ StatusOr<std::unique_ptr<PointCloud>> Decoder::DecodePointCloudFromBuffer(
return static_cast<std::unique_ptr<PointCloud>>(std::move(mesh));
#endif
}
return Status(Status::ERROR, "Unsupported geometry type.");
return Status(Status::DRACO_ERROR, "Unsupported geometry type.");
}

StatusOr<std::unique_ptr<Mesh>> Decoder::DecodeMeshFromBuffer(
Expand All @@ -94,15 +94,15 @@ 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<PointCloudDecoder> decoder,
CreatePointCloudDecoder(header.encoder_method))

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
}

Expand All @@ -113,15 +113,15 @@ 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<MeshDecoder> decoder,
CreateMeshDecoder(header.encoder_method))

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
}

Expand Down
16 changes: 9 additions & 7 deletions src/draco/compression/encode_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,33 +69,35 @@ 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.");
}
}
// TODO(hemmer): Try to enable more prediction schemes for normals.
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.");
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/draco/compression/expert_encode.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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) {
Expand All @@ -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
}

Expand Down
12 changes: 6 additions & 6 deletions src/draco/compression/mesh/mesh_edgebreaker_encoder_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ Status MeshEdgebreakerEncoderImpl<TraversalEncoder>::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);
Expand Down Expand Up @@ -317,10 +317,10 @@ Status MeshEdgebreakerEncoderImpl<TraversalEncoder>::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<uint8_t>(attribute_data_.size());
Expand Down Expand Up @@ -376,7 +376,7 @@ Status MeshEdgebreakerEncoderImpl<TraversalEncoder>::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.
Expand All @@ -385,7 +385,7 @@ Status MeshEdgebreakerEncoderImpl<TraversalEncoder>::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
Expand Down Expand Up @@ -417,7 +417,7 @@ Status MeshEdgebreakerEncoderImpl<TraversalEncoder>::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());

Expand Down
2 changes: 1 addition & 1 deletion src/draco/compression/mesh/mesh_sequential_encoder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ Status MeshSequentialEncoder::EncodeConnectivity() {
// 0 = Encode compressed indices.
buffer()->Encode(static_cast<uint8_t>(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<uint8_t>(1));
Expand Down
12 changes: 6 additions & 6 deletions src/draco/compression/point_cloud/point_cloud_decoder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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)))
Expand All @@ -50,7 +50,7 @@ Status PointCloudDecoder::DecodeMetadata() {
std::unique_ptr<GeometryMetadata>(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();
}
Expand All @@ -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.
Expand All @@ -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();
}

Expand Down
10 changes: 5 additions & 5 deletions src/draco/compression/point_cloud/point_cloud_encoder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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();
}
Expand Down
2 changes: 1 addition & 1 deletion src/draco/core/status.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions src/draco/core/status_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/draco/io/mesh_io.cc
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ StatusOr<std::unique_ptr<Mesh>> 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);
}
Expand Down
19 changes: 10 additions & 9 deletions src/draco/io/obj_decoder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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.
Expand All @@ -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);
Expand Down
5 changes: 3 additions & 2 deletions src/draco/io/ply_decoder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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<PointIndex::ValueType> vertex_index_reader(vertex_indices);
Expand Down
2 changes: 1 addition & 1 deletion src/draco/io/ply_decoder_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class PlyDecoderTest : public ::testing::Test {
std::unique_ptr<Geometry> 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;
Expand Down
Loading