Skip to content

Commit

Permalink
Merge pull request #577 from norlab-ulaval/fix-boost-filesystem
Browse files Browse the repository at this point in the history
  • Loading branch information
boxanm authored Jul 2, 2024
2 parents 34ae751 + 74435b8 commit 9a9d969
Showing 1 changed file with 42 additions and 27 deletions.
69 changes: 42 additions & 27 deletions pointmatcher/IO.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ void PointMatcherSupport::validateFile(const std::string& fileName)
if (!ifs.good() || !boost::filesystem::is_regular_file(fullPath))
#if BOOST_FILESYSTEM_VERSION >= 3
#if BOOST_VERSION >= 105000
throw runtime_error(string("Cannot open file ") + boost::filesystem::complete(fullPath).generic_string());
throw runtime_error(string("Cannot open file ") + boost::filesystem::absolute(fullPath).generic_string());
#else
throw runtime_error(string("Cannot open file ") + boost::filesystem3::complete(fullPath).generic_string());
#endif
Expand All @@ -375,17 +375,24 @@ template<typename T>
typename PointMatcher<T>::DataPoints PointMatcher<T>::DataPoints::load(const std::string& fileName)
{
const boost::filesystem::path path(fileName);
const string& ext(boost::filesystem::extension(path));
if (boost::iequals(ext, ".vtk"))
return PointMatcherIO<T>::loadVTK(fileName);
else if (boost::iequals(ext, ".csv"))
return PointMatcherIO<T>::loadCSV(fileName);
else if (boost::iequals(ext, ".ply"))
return PointMatcherIO<T>::loadPLY(fileName);
else if (boost::iequals(ext, ".pcd"))
return PointMatcherIO<T>::loadPCD(fileName);
else
throw runtime_error("loadAnyFormat(): Unknown extension \"" + ext + "\" for file \"" + fileName + "\", extension must be either \".vtk\" or \".csv\"");
if (path.has_extension())
{
const string& ext(path.extension().string());
if(boost::iequals(ext, ".vtk"))
return PointMatcherIO<T>::loadVTK(fileName);
else if(boost::iequals(ext, ".csv"))
return PointMatcherIO<T>::loadCSV(fileName);
else if(boost::iequals(ext, ".ply"))
return PointMatcherIO<T>::loadPLY(fileName);
else if(boost::iequals(ext, ".pcd"))
return PointMatcherIO<T>::loadPCD(fileName);
else
throw runtime_error("loadAnyFormat(): Unknown extension \"" + ext + "\" for file \"" + fileName + "\", extension must be either \".vtk\", \".ply\", \".pcd\" or \".csv\"");
}
else
{
throw runtime_error("loadAnyFormat(): Missing extension for file \"" + fileName + "\", extension must be either \".vtk\" or \".csv\"");
}
}

template
Expand Down Expand Up @@ -809,21 +816,29 @@ template<typename T>
void PointMatcher<T>::DataPoints::save(const std::string& fileName, bool binary, unsigned precision) const
{
const boost::filesystem::path path(fileName);
const string& ext(boost::filesystem::extension(path));
if (boost::iequals(ext, ".vtk"))
return PointMatcherIO<T>::saveVTK(*this, fileName, binary, precision);

if (binary)
throw runtime_error("save(): Binary writing is not supported together with extension \"" + ext + "\". Currently binary writing is only supported with \".vtk\".");

if (boost::iequals(ext, ".csv"))
return PointMatcherIO<T>::saveCSV(*this, fileName, precision);
else if (boost::iequals(ext, ".ply"))
return PointMatcherIO<T>::savePLY(*this, fileName, precision);
else if (boost::iequals(ext, ".pcd"))
return PointMatcherIO<T>::savePCD(*this, fileName, precision);
else
throw runtime_error("save(): Unknown extension \"" + ext + "\" for file \"" + fileName + "\", extension must be either \".vtk\", \".ply\", \".pcd\" or \".csv\"");
if (path.has_extension())
{
const string& ext(path.extension().string());
if (boost::iequals(ext, ".vtk"))
return PointMatcherIO<T>::saveVTK(*this, fileName, binary, precision);

if (binary)
throw runtime_error("save(): Binary writing is not supported together with extension \"" + ext + "\". Currently binary writing is only supported with \".vtk\".");

if (boost::iequals(ext, ".csv"))
return PointMatcherIO<T>::saveCSV(*this, fileName, precision);
else if (boost::iequals(ext, ".ply"))
return PointMatcherIO<T>::savePLY(*this, fileName, precision);
else if (boost::iequals(ext, ".pcd"))
return PointMatcherIO<T>::savePCD(*this, fileName, precision);
else
throw runtime_error("save(): Unknown extension \"" + ext + "\" for file \"" + fileName + "\", extension must be either \".vtk\", \".ply\", \".pcd\" or \".csv\"");

}
else
{
throw runtime_error("save(): Missing extension for file \"" + fileName + "\", extension must be either \".vtk\", \".ply\", \".pcd\" or \".csv\"");
}
}

template
Expand Down

0 comments on commit 9a9d969

Please sign in to comment.