Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[sfmData] Ensure copies of SfMData are deep instead of shallow #1604

Merged
merged 1 commit into from
Nov 24, 2023
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
35 changes: 35 additions & 0 deletions src/aliceVision/sfmData/HashMapPtr.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,45 @@
namespace aliceVision {
namespace sfmData {

template<class T>
auto cloneT(T * ptr, int val) -> decltype(ptr->clone())
{
if (ptr)
{
return ptr->clone();
}

return nullptr;
}

template<class T>
T * cloneT(T * ptr, long val)
{
if (ptr)
{
return new T(*ptr);
}

return nullptr;
}

template<class T>
class HashMapPtr : public HashMap<IndexT, std::shared_ptr<T>>
{
public:
HashMapPtr<T>() : HashMap<IndexT, std::shared_ptr<T>>()
{

}

HashMapPtr(const HashMapPtr<T> & other)
{
for (const auto & pair : other)
{
this->insert({pair.first, std::shared_ptr<T>(cloneT(pair.second.get(), 0))});
}
}

/**
* We don't want the user to assume the object is created when the index does not exist in the map
*/
Expand Down
3 changes: 0 additions & 3 deletions src/aliceVision/sfmData/SfMData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@ using namespace aliceVision::image;

namespace fs = boost::filesystem;

SfMData::SfMData() {}

SfMData::~SfMData() {}

bool SfMData::operator==(const SfMData& other) const
{
Expand Down
3 changes: 0 additions & 3 deletions src/aliceVision/sfmData/SfMData.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,6 @@ class SfMData
/// Rotation priors
RotationPriors rotationpriors;

SfMData();
~SfMData();

// Operators

bool operator==(const SfMData& other) const;
Expand Down