From 8c7f07d797128b97393c9d07a9b7e4469c497fba Mon Sep 17 00:00:00 2001 From: gered Date: Sat, 22 Dec 2012 16:04:01 -0500 Subject: [PATCH] clean up main() processing a bit in preparation for metadata loading --- src/main.cpp | 35 ++++++++++++++++++++++++++++------- 1 file changed, 28 insertions(+), 7 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index e2d8081..b29eb17 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -47,8 +47,10 @@ int main(int argc, char **argv) } } + // find file extension part of the string in the input filename + // we will use this to make an appropriate output mesh filename *and* + // to make an XML metadata filename std::string extension; - try { extension = file.substr(file.find_last_of('.'), std::string::npos); @@ -59,21 +61,40 @@ int main(int argc, char **argv) { extension = ""; } - - std::string meshFile = ""; - if (extension.length() > 0) + + // make sure the ms3d file didn't have some other extension for some reason + // which might conflict with our automatic mesh and metadata filename + // creation ... + if (extension == ".mesh" || extension == ".xml") { - meshFile = file; - meshFile.erase(meshFile.find_last_of('.'), std::string::npos); - meshFile.append(".mesh"); + printf("Bad input filename extension.\n\n"); + return 1; } + // create mesh filename based on ms3d filename + std::string meshFile = file; + if (extension.length() > 0) + meshFile.erase(meshFile.find_last_of('.'), std::string::npos); + meshFile.append(".mesh"); + + std::string metadataFile = file; + if (extension.length() > 0) + metadataFile.erase(metadataFile.find_last_of('.'), std::string::npos); + metadataFile.append((".xml")); + + // load the MS3D ... Ms3d *ms3d = new Ms3d(); if (!ms3d->Load(file)) { printf("Error loading MS3D file.\n\n"); return 1; } + + // attempt to load a metadata file + // TODO: write this + + // convert to a mesh file + // TODO: pass in loaded metadata object if (!ConvertToMeshFile(meshFile, ms3d, scaleFactor)) { printf("Error converting MS3D to MESH.\n\n");