mirror of
https://git.mirrors.martin98.com/https://github.com/google/draco
synced 2025-08-13 02:48:59 +08:00
Fix handling short filenames (less than 4 characters)
- fixes https://github.com/google/draco/issues/108
This commit is contained in:
parent
e2de4f8f43
commit
64c045bdae
@ -31,7 +31,8 @@ std::unique_ptr<Mesh> ReadMeshFromFile(const std::string &file_name,
|
|||||||
std::unique_ptr<Mesh> mesh(new Mesh());
|
std::unique_ptr<Mesh> mesh(new Mesh());
|
||||||
// Analyze file extension.
|
// Analyze file extension.
|
||||||
const std::string extension =
|
const std::string extension =
|
||||||
parser::ToLower(file_name.substr(file_name.size() - 4));
|
parser::ToLower(file_name.size() >= 4 ?
|
||||||
|
file_name.substr(file_name.size() - 4) : file_name);
|
||||||
if (extension == ".obj") {
|
if (extension == ".obj") {
|
||||||
// Wavefront OBJ file format.
|
// Wavefront OBJ file format.
|
||||||
ObjDecoder obj_decoder;
|
ObjDecoder obj_decoder;
|
||||||
|
@ -25,7 +25,8 @@ std::unique_ptr<PointCloud> ReadPointCloudFromFile(
|
|||||||
const std::string &file_name) {
|
const std::string &file_name) {
|
||||||
std::unique_ptr<PointCloud> pc(new PointCloud());
|
std::unique_ptr<PointCloud> pc(new PointCloud());
|
||||||
// Analyze file extension.
|
// Analyze file extension.
|
||||||
const std::string extension = file_name.substr(file_name.size() - 4);
|
const std::string extension = file_name.size() >= 4 ?
|
||||||
|
file_name.substr(file_name.size() - 4) : file_name;
|
||||||
if (extension == ".obj") {
|
if (extension == ".obj") {
|
||||||
// Wavefront OBJ file format.
|
// Wavefront OBJ file format.
|
||||||
ObjDecoder obj_decoder;
|
ObjDecoder obj_decoder;
|
||||||
|
@ -134,8 +134,8 @@ int main(int argc, char **argv) {
|
|||||||
|
|
||||||
// Save the decoded geometry into a file.
|
// Save the decoded geometry into a file.
|
||||||
// TODO(ostava): Currently only .ply and .obj are supported.
|
// TODO(ostava): Currently only .ply and .obj are supported.
|
||||||
const std::string extension =
|
const std::string extension = options.output.size() >= 4 ?
|
||||||
options.output.substr(options.output.size() - 4);
|
options.output.substr(options.output.size() - 4) : options.output;
|
||||||
if (extension == ".obj") {
|
if (extension == ".obj") {
|
||||||
draco::ObjEncoder obj_encoder;
|
draco::ObjEncoder obj_encoder;
|
||||||
if (mesh) {
|
if (mesh) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user