Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into esri
Browse files Browse the repository at this point in the history
  • Loading branch information
abellgithub committed Aug 4, 2020
2 parents 6927b88 + f25e34d commit e306c09
Show file tree
Hide file tree
Showing 2 changed files with 127 additions and 0 deletions.
47 changes: 47 additions & 0 deletions plugins/i3s/io/Obb.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,53 @@

#pragma once

#include <list>
#include <memory>
#include <mutex>
#include <condition_variable>

#include <pdal/JsonFwd.hpp>
#include <pdal/util/ThreadPool.hpp>

namespace pdal
{
namespace i3s
{

using Page = NL::json;
using PagePtr = std::shared_ptr<NL::json>;
using FetchFunction = std::function<std::string(std::string)>;

class PageManager
{
struct PageEntry
{
int index;
PagePtr page;
};

public:
PageManager(int cacheSize, int threads, int indexFactor, FetchFunction fetch);

void fetchPage(int index);
PagePtr getPage(int index);

private:
ThreadPool m_pool;
size_t m_cacheSize;
int m_indexFactor;
FetchFunction m_fetch;
std::list<PageEntry> m_cache;
std::mutex m_mutex;
std::condition_variable m_cv;

PagePtr getPageLocked(int index);
void evict();
};

} //namespace i3s
=======
>>>>>>> origin/master
#include <Eigen/Geometry>
#include <pdal/JsonFwd.hpp>
#include <pdal/util/Utils.hpp>
Expand Down
80 changes: 80 additions & 0 deletions plugins/i3s/io/PageManager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@

#pragma once

<<<<<<< HEAD:plugins/i3s/io/PageManager.hpp
#include <list>
#include <memory>
#include <mutex>
Expand Down Expand Up @@ -79,4 +80,83 @@ class PageManager
};

} //namespace i3s
=======
#include <Eigen/Geometry>
#include <pdal/JsonFwd.hpp>
#include <pdal/util/Utils.hpp>

#include "EsriUtil.hpp"

namespace pdal
{
class SrsTransform;

namespace i3s
{
using Segment = std::pair<Eigen::Vector3d, Eigen::Vector3d>;

class Obb
{
FRIEND_TEST(ObbTest, obb);
public:
// Can throw EsriError.
Obb();
Obb(const NL::json& spec);
void parse(NL::json spec);
bool intersect(Obb clip);
void transform(const SrsTransform& xform);
bool valid() const;
Eigen::Vector3d center() const;
Eigen::Quaterniond quat() const;
BOX3D bounds() const;

private:
void verifyArray(const NL::json& spec, const std::string& name, size_t cnt);
bool intersectNormalized(const Segment& seg);
Eigen::Vector3d corner(size_t pos);
Segment segment(size_t pos);
// Test support
void setCenter(const Eigen::Vector3d& center);

bool m_valid;
Eigen::Vector3d m_p;
double m_hx;
double m_hy;
double m_hz;
Eigen::Quaterniond m_quat;

friend std::ostream& operator<<(std::ostream&, const Obb&);
};

} //namespace i3s

namespace Utils
{

template<>
inline StatusWithReason fromString(const std::string& from,
pdal::i3s::Obb& obb)
{
NL::json spec;
try
{
spec = NL::json::parse(from);
}
catch (const NL::json::exception& ex)
{
return { -1, ex.what() };
}
try
{
obb.parse(spec);
}
catch (const i3s::EsriError& err)
{
return { -1, err.what() };
}
return true;
}

} // namespace Utils
>>>>>>> origin/master:plugins/i3s/io/Obb.hpp
} // namespace pdal

0 comments on commit e306c09

Please sign in to comment.