Skip to content

Commit

Permalink
Minor adaptor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
attcs committed Mar 6, 2024
1 parent cdfda3f commit a070356
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 38 deletions.
34 changes: 21 additions & 13 deletions adaptor.eigen.h
Original file line number Diff line number Diff line change
Expand Up @@ -246,12 +246,11 @@ namespace OrthoTree

namespace Eigen
{
using namespace OrthoTree;
using namespace OrthoTree::EigenAdaptor;

// Basic OrthoTree types
template<typename Scalar_, int AmbientDim_>
using EigenOrthoTreePoint = OrthoTreePoint<
using EigenOrthoTreePoint = OrthoTree::OrthoTreePoint<
AmbientDim_,
Matrix<Scalar_, AmbientDim_, 1>,
AlignedBox<Scalar_, AmbientDim_>,
Expand All @@ -261,7 +260,7 @@ namespace Eigen
EigenAdaptorGeneralBase<Scalar_, AmbientDim_>>;

template<typename Scalar_, int AmbientDim_, uint32_t SPLIT_DEPTH_INCREASEMENT = 2>
using EigenOrthoTreeBox = OrthoTreeBoundingBox<
using EigenOrthoTreeBox = OrthoTree::OrthoTreeBoundingBox<
AmbientDim_,
Matrix<Scalar_, AmbientDim_, 1>,
AlignedBox<Scalar_, AmbientDim_>,
Expand All @@ -272,11 +271,11 @@ namespace Eigen
EigenAdaptorGeneralBase<Scalar_, AmbientDim_>>;

template<typename Scalar_, int AmbientDim_>
using OrthoTreeContainerPointC = OrthoTreeContainerPoint<EigenOrthoTreePoint<Scalar_, AmbientDim_>, Matrix<Scalar_, AmbientDim_, 1>>;
using OrthoTreeContainerPointC = OrthoTree::OrthoTreeContainerPoint<EigenOrthoTreePoint<Scalar_, AmbientDim_>, Matrix<Scalar_, AmbientDim_, 1>>;

template<typename Scalar_, int AmbientDim_, uint32_t SPLIT_DEPTH_INCREASEMENT = 2>
using OrthoTreeContainerBoxC =
OrthoTreeContainerBox<EigenOrthoTreeBox<Scalar_, AmbientDim_, SPLIT_DEPTH_INCREASEMENT>, AlignedBox<Scalar_, AmbientDim_>>;
OrthoTree::OrthoTreeContainerBox<EigenOrthoTreeBox<Scalar_, AmbientDim_, SPLIT_DEPTH_INCREASEMENT>, AlignedBox<Scalar_, AmbientDim_>>;

// Non-owning types
using QuadtreePoint2f = EigenOrthoTreePoint<float, 2>;
Expand All @@ -288,16 +287,20 @@ namespace Eigen
using OctreePoint3d = EigenOrthoTreePoint<double, 3>;

template<uint32_t SPLIT_DEPTH_INCREASEMENT = 2>
using QuadtreeBox2f = EigenOrthoTreeBox<float, 2, SPLIT_DEPTH_INCREASEMENT>;
using QuadtreeBox2fs = EigenOrthoTreeBox<float, 2, SPLIT_DEPTH_INCREASEMENT>;
using QuadtreeBox2f = QuadtreeBox2fs<2>;

template<uint32_t SPLIT_DEPTH_INCREASEMENT = 2>
using QuadtreeBox2d = EigenOrthoTreeBox<double, 2, SPLIT_DEPTH_INCREASEMENT>;
using QuadtreeBox2ds = EigenOrthoTreeBox<double, 2, SPLIT_DEPTH_INCREASEMENT>;
using QuadtreeBox2d = QuadtreeBox2ds<2>;

template<uint32_t SPLIT_DEPTH_INCREASEMENT = 2>
using OctreeBox3f = EigenOrthoTreeBox<float, 3, SPLIT_DEPTH_INCREASEMENT>;
using OctreeBox3fs = EigenOrthoTreeBox<float, 3, SPLIT_DEPTH_INCREASEMENT>;
using OctreeBox3f = OctreeBox3fs<2>;

template<uint32_t SPLIT_DEPTH_INCREASEMENT = 2>
using OctreeBox3d = EigenOrthoTreeBox<double, 3, SPLIT_DEPTH_INCREASEMENT>;
using OctreeBox3ds = EigenOrthoTreeBox<double, 3, SPLIT_DEPTH_INCREASEMENT>;
using OctreeBox3d = OctreeBox3ds<2>;

// Container types
using QuadtreePointC2f = OrthoTreeContainerPointC<float, 2>;
Expand All @@ -309,14 +312,19 @@ namespace Eigen
using OctreePointC3d = OrthoTreeContainerPointC<double, 3>;

template<uint32_t SPLIT_DEPTH_INCREASEMENT = 2>
using QuadtreeBoxC2f = OrthoTreeContainerBoxC<float, 2, SPLIT_DEPTH_INCREASEMENT>;
using QuadtreeBoxC2fs = OrthoTreeContainerBoxC<float, 2, SPLIT_DEPTH_INCREASEMENT>;
using QuadtreeBoxC2f = QuadtreeBoxC2fs<2>;

template<uint32_t SPLIT_DEPTH_INCREASEMENT = 2>
using QuadtreeBoxC2d = OrthoTreeContainerBoxC<double, 2, SPLIT_DEPTH_INCREASEMENT>;
using QuadtreeBoxC2ds = OrthoTreeContainerBoxC<double, 2, SPLIT_DEPTH_INCREASEMENT>;
using QuadtreeBoxC2d = QuadtreeBoxC2ds<2>;

template<uint32_t SPLIT_DEPTH_INCREASEMENT = 2>
using OctreeBoxC3f = OrthoTreeContainerBoxC<float, 3, SPLIT_DEPTH_INCREASEMENT>;
using OctreeBoxC3fs = OrthoTreeContainerBoxC<float, 3, SPLIT_DEPTH_INCREASEMENT>;
using OctreeBoxC3f = OctreeBoxC3fs<2>;

template<uint32_t SPLIT_DEPTH_INCREASEMENT = 2>
using OctreeBoxC3d = OrthoTreeContainerBoxC<double, 3, SPLIT_DEPTH_INCREASEMENT>;
using OctreeBoxC3ds = OrthoTreeContainerBoxC<double, 3, SPLIT_DEPTH_INCREASEMENT>;
using OctreeBoxC3d = OctreeBoxC3ds<2>;

} // namespace Eigen
8 changes: 5 additions & 3 deletions adaptor.xyz.h
Original file line number Diff line number Diff line change
Expand Up @@ -195,8 +195,8 @@ namespace XYZ
using QuadtreePointC = OrthoTreeContainerPoint<QuadtreePoint, XYPoint2D>;

template<uint32_t SPLIT_DEPTH_INCREASEMENT = 2>
using QuadtreeBoxC = OrthoTreeContainerBox<QuadtreeBox<SPLIT_DEPTH_INCREASEMENT>, XYBoundingBox2D>;

using QuadtreeBoxCs = OrthoTreeContainerBox<QuadtreeBox<SPLIT_DEPTH_INCREASEMENT>, XYBoundingBox2D>;
using QuadtreeBoxC = QuadtreeBoxCs<2>;

using OctreePoint = OrthoTreePoint<3, XYZPoint3D, XYZBoundingBox3D, XYZRay3D, XYZPlane3D, xyz_geometry_type, XYZAdaptorGeneral>;

Expand All @@ -208,5 +208,7 @@ namespace XYZ
using OcreePointC = OrthoTreeContainerPoint<OctreePoint, XYZPoint3D>;

template<uint32_t SPLIT_DEPTH_INCREASEMENT = 2>
using OctreeBoxC = OrthoTreeContainerBox<QuadtreeBox<SPLIT_DEPTH_INCREASEMENT>, XYZBoundingBox3D>;
using OctreeBoxCs = OrthoTreeContainerBox<QuadtreeBox<SPLIT_DEPTH_INCREASEMENT>, XYZBoundingBox3D>;
using OctreeBoxC = OctreeBoxCs<2>;

} // namespace XYZ
46 changes: 29 additions & 17 deletions octree.h
Original file line number Diff line number Diff line change
Expand Up @@ -773,7 +773,7 @@ namespace OrthoTree
using TBox = TBox_;
using TRay = TRay_;
using TPlane = TPlane_;

using AD = TAdapter;
static_assert(AdaptorConcept<AD, TVector, TBox, TRay, TPlane, TGeometry>);
static_assert(0 < DIMENSION_NO && DIMENSION_NO < 64);
Expand Down Expand Up @@ -1813,16 +1813,16 @@ namespace OrthoTree
// OrthoTreePoint: Non-owning container which spatially organize point ids in N dimension space into a hash-table by Morton Z order.
template<
dim_t DIMENSION_NO,
typename TVector,
typename TBox,
typename TRay,
typename TPlane,
typename TGeometry = double,
typename TAdapter = AdaptorGeneral<DIMENSION_NO, TVector, TBox, TRay, TPlane, TGeometry>>
class OrthoTreePoint final : public OrthoTreeBase<DIMENSION_NO, TVector, TBox, TRay, TPlane, TGeometry, TAdapter>
typename TVector_,
typename TBox_,
typename TRay_,
typename TPlane_,
typename TGeometry_ = double,
typename TAdapter = AdaptorGeneral<DIMENSION_NO, TVector_, TBox_, TRay_, TPlane_, TGeometry_>>
class OrthoTreePoint final : public OrthoTreeBase<DIMENSION_NO, TVector_, TBox_, TRay_, TPlane_, TGeometry_, TAdapter>
{
protected:
using Base = OrthoTreeBase<DIMENSION_NO, TVector, TBox, TRay, TPlane, TGeometry, TAdapter>;
using Base = OrthoTreeBase<DIMENSION_NO, TVector_, TBox_, TRay_, TPlane_, TGeometry_, TAdapter>;
using EntityDistance = typename Base::EntityDistance;
using BoxDistance = typename Base::BoxDistance;

Expand All @@ -1836,6 +1836,12 @@ namespace OrthoTree

using Node = typename Base::Node;

using TGeometry = typename TGeometry_;
using TVector = typename TVector_;
using TBox = typename TBox_;
using TRay = typename TRay_;
using TPlane = typename TPlane_;

static constexpr std::size_t DEFAULT_MAX_ELEMENT = 21;

private: // Aid functions
Expand Down Expand Up @@ -2190,17 +2196,17 @@ namespace OrthoTree
// SPLIT_DEPTH_INCREASEMENT: if (SPLIT_DEPTH_INCREASEMENT > 0) Those items which are not fit in the child nodes may be stored in the children/grand-children instead of the parent.
template<
dim_t DIMENSION_NO,
typename TVector,
typename TBox,
typename TRay,
typename TPlane,
typename TGeometry = double,
typename TVector_,
typename TBox_,
typename TRay_,
typename TPlane_,
typename TGeometry_ = double,
depth_t SPLIT_DEPTH_INCREASEMENT = 2,
typename TAdapter = AdaptorGeneral<DIMENSION_NO, TVector, TBox, TRay, TPlane, TGeometry>>
class OrthoTreeBoundingBox final : public OrthoTreeBase<DIMENSION_NO, TVector, TBox, TRay, TPlane, TGeometry, TAdapter>
typename TAdapter = AdaptorGeneral<DIMENSION_NO, TVector_, TBox_, TRay_, TPlane_, TGeometry_>>
class OrthoTreeBoundingBox final : public OrthoTreeBase<DIMENSION_NO, TVector_, TBox_, TRay_, TPlane_, TGeometry_, TAdapter>
{
protected:
using Base = OrthoTreeBase<DIMENSION_NO, TVector, TBox, TRay, TPlane, TGeometry, TAdapter>;
using Base = OrthoTreeBase<DIMENSION_NO, TVector_, TBox_, TRay_, TPlane_, TGeometry_, TAdapter>;
using EntityDistance = typename Base::EntityDistance;
using BoxDistance = typename Base::BoxDistance;
using GridBoundary = typename Base::GridBoundary;
Expand All @@ -2217,6 +2223,12 @@ namespace OrthoTree

using Node = typename Base::Node;

using TGeometry = typename TGeometry_;
using TVector = typename TVector_;
using TBox = typename TBox_;
using TRay = typename TRay_;
using TPlane = typename TPlane_;

static constexpr std::size_t DEFAULT_MAX_ELEMENT = 21;

private: // Aid functions
Expand Down
5 changes: 4 additions & 1 deletion octree_container.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,10 @@ namespace OrthoTree
{
public:
using AD = typename OrthoTreeCore::AD;

using TGeometry = typename OrthoTreeCore::TGeometry;
using TVector = typename OrthoTreeCore::TVector;
using TBox = typename OrthoTreeCore::TBox;
using TGeometry = typename OrthoTreeCore::TGeometry;
using TRay = typename OrthoTreeCore::TRay;
using TPlane = typename OrthoTreeCore::TPlane;

Expand Down Expand Up @@ -176,6 +177,7 @@ namespace OrthoTree
public:
using base = OrthoTreeContainerBase<OrthoTreeCore, TData>;
using AD = typename base::AD;

using TGeometry = typename base::TGeometry;
using TVector = typename base::TVector;
using TBox = typename base::TBox;
Expand Down Expand Up @@ -256,6 +258,7 @@ namespace OrthoTree
public:
using base = OrthoTreeContainerBase<OrthoTreeCore, TData>;
using AD = typename base::AD;

using TGeometry = typename base::TGeometry;
using TVector = typename base::TVector;
using TBox = typename base::TBox;
Expand Down
7 changes: 3 additions & 4 deletions unittests/adaptor.tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ namespace AdaptorTest
Eigen::AlignedBox2d( Eigen::Vector2d( 1.2, 1.2 ), Eigen::Vector2d( 2.8, 2.8 ) )
};

auto quadtree = Eigen::QuadtreeBoxC2d<2>(boxes
auto quadtree = Eigen::QuadtreeBoxC2d(boxes
, 3 // max depth
, std::nullopt // user-provided bounding Box for all
, 2 // max element in a node
Expand Down Expand Up @@ -363,7 +363,7 @@ namespace AdaptorTest
BasicTypesXYZ::BoundingBox2D{ BasicTypesXYZ::Point2D{ 1.2f, 1.2f }, BasicTypesXYZ::Point2D{ 2.8f, 2.8f } }
};

auto quadtree = XYZ::QuadtreeBoxC<2>(boxes
auto quadtree = XYZ::QuadtreeBoxC(boxes
, 3 // max depth
, std::nullopt // user-provided bounding Box for all
, 2 // max element in a node
Expand Down Expand Up @@ -560,8 +560,7 @@ namespace AdaptorTest
auto entityIDsInBFS = tree.CollectAllIdInBFS(tree.GetRootKey());
auto entityIDsInDFS = tree.CollectAllIdInDFS(tree.GetRootKey());

auto searchBox = box_t(point_t(0.0, 0.0, 0.0), point_t(2.0, 2.0, 2.0)
);
auto searchBox = box_t(point_t(0.0, 0.0, 0.0), point_t(2.0, 2.0, 2.0));
auto pointsInSearchBox = tree.RangeSearch(searchBox, vpt);

auto sqrt3Reciproc = 1.0 / sqrt(3.0);
Expand Down

0 comments on commit a070356

Please sign in to comment.