-
-
Notifications
You must be signed in to change notification settings - Fork 828
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[sfmData] manage features/matches folders internally
* handle conversions to relative and absolute paths when _absolutePath is defined * update internal relative folder paths when absolutePath is modified * ensure features/matches folders contains no duplicates * [tests] add 'sfmData_test' module + test internal folders management * [software] update global/incrementalSfm
- Loading branch information
Showing
6 changed files
with
176 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
|
||
#include <boost/filesystem.hpp> | ||
#include <aliceVision/sfmData/SfMData.hpp> | ||
|
||
#define BOOST_TEST_MODULE sfmData | ||
#include <boost/test/included/unit_test.hpp> | ||
|
||
using namespace aliceVision; | ||
namespace fs = boost::filesystem; | ||
|
||
BOOST_AUTO_TEST_CASE(SfMData_InternalFolders) | ||
{ | ||
const std::string filename = "InternalFolders.sfm"; | ||
sfmData::SfMData sfmData; | ||
|
||
// add relative features/matches folders with duplicates | ||
std::string refFolder(".."); | ||
sfmData.addFeaturesFolders({refFolder, refFolder}); | ||
sfmData.addMatchesFolders({refFolder, refFolder}); | ||
auto featuresFolders = sfmData.getFeaturesFolders(); | ||
auto matchesFolders = sfmData.getMatchesFolders(); | ||
// ensure duplicates were removed | ||
BOOST_CHECK_EQUAL(featuresFolders.size(), 1); | ||
BOOST_CHECK_EQUAL(matchesFolders.size(), 1); | ||
// sfmData has no absolute path set, folders are still in relative form | ||
BOOST_CHECK_EQUAL(featuresFolders[0], refFolder); | ||
BOOST_CHECK_EQUAL(matchesFolders[0], refFolder); | ||
|
||
// set absolutePath to current filename | ||
sfmData.setAbsolutePath(fs::absolute(filename).string()); | ||
featuresFolders = sfmData.getFeaturesFolders(); | ||
matchesFolders = sfmData.getMatchesFolders(); | ||
// internal folders were kept... | ||
BOOST_CHECK_EQUAL(featuresFolders.size(), 1); | ||
BOOST_CHECK_EQUAL(matchesFolders.size(), 1); | ||
// ... and are now absolute paths | ||
BOOST_CHECK(fs::path(featuresFolders[0]).is_absolute()); | ||
BOOST_CHECK(fs::equivalent(featuresFolders[0], refFolder)); | ||
BOOST_CHECK(fs::path(matchesFolders[0]).is_absolute()); | ||
BOOST_CHECK(fs::equivalent(matchesFolders[0], refFolder)); | ||
|
||
// update sfm absolute path to be in parent/parent folder | ||
fs::path otherFolder = fs::path("../.."); | ||
std::string updatedFilename = ( otherFolder / filename).string(); | ||
sfmData.setAbsolutePath(updatedFilename); | ||
// internal folders still reference the same folder as before | ||
BOOST_CHECK(fs::equivalent(featuresFolders[0], refFolder)); | ||
BOOST_CHECK(fs::equivalent(matchesFolders[0], refFolder)); | ||
BOOST_CHECK_EQUAL(sfmData.getRelativeFeaturesFolders()[0], fs::relative(refFolder, otherFolder)); | ||
BOOST_CHECK_EQUAL(sfmData.getRelativeMatchesFolders()[0], fs::relative(refFolder, otherFolder)); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters