Skip to content

Commit

Permalink
Internal Geometry module
Browse files Browse the repository at this point in the history
Abstract classes are enabled for TBox and TVector
  • Loading branch information
attcs committed Dec 23, 2024
1 parent 50e31f1 commit ededa6b
Show file tree
Hide file tree
Showing 8 changed files with 1,110 additions and 451 deletions.
26 changes: 26 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,31 @@
# Changelog

## 2024-12-26
New features
* Support of abstract classes

Refactorizations
* Internal geometry module

Maintenance
* Support compilers w/o std::execution (e.g. Apple Clang)

## 2024-03-26
New features
* New adaptors: glm, boost, CGAL
* Built-in `Ray` and `Plane` types
* Rebalancing insert

Refactorizations
* New, more capable adaptor concept
* Separated Adapator tests
* Support of `Eigen::Hyperplane` and `Eigen::ParametrizedLine`
* Support of Unreal Engine `FRay`, `FPlane`

Maintenance
* GCC compile action
* Fix a bug in `Insert()`

## 2024-03-02
New features
* New adaptors: Eigen, Unreal Engine, XYZ
Expand Down
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ What is the Octree and what is good for? https://en.wikipedia.org/wiki/Octree
## Limitations
* Maximum number of dimensions is 63.
* Maximum depth of octree solutions is 10.
* Abstract classes cannot be used for `TVector` and `TBox`

## Requirements
* Language standard: C++20 or above
Expand Down
69 changes: 63 additions & 6 deletions benchmarks/OrthoTreePointDynamicGeneral.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ template<
typename TBox,
typename TRay,
typename TPlane,
typename TGeonetry = double,
typename adaptor_type = OrthoTree::AdaptorGeneral<DIMENSION_NO, TVector, TBox, TRay, TPlane, TGeonetry>>
typename TGeometry = double,
typename adaptor_type = OrthoTree::AdaptorGeneral<DIMENSION_NO, TVector, TBox, TRay, TPlane, TGeometry>>
class OrthoTreePointDynamicGeneral
{
static size_t constexpr _nChild = 1 << DIMENSION_NO;
Expand Down Expand Up @@ -78,11 +78,39 @@ class OrthoTreePointDynamicGeneral

}

static inline TBox BoxInvertedInit() noexcept
{
auto ext = TBox{};

for (dim_t dimensionID = 0; dimensionID < DIMENSION_NO; ++dimensionID)
{
AD::SetBoxMinC(ext, dimensionID, std::numeric_limits<TGeometry>::max());
AD::SetBoxMaxC(ext, dimensionID, std::numeric_limits<TGeometry>::lowest());
}

return ext;
}

static TBox GetBoxOfPoints(std::span<TVector const> const& points) noexcept
{
auto ext = BoxInvertedInit();
for (autoc& point : points)
for (dim_t dimensionID = 0; dimensionID < DIMENSION_NO; ++dimensionID)
{
if (AD::GetBoxMinC(ext, dimensionID) > AD::GetPointC(point, dimensionID))
AD::SetBoxMinC(ext, dimensionID, AD::GetPointC(point, dimensionID));

if (AD::GetBoxMaxC(ext, dimensionID) < AD::GetPointC(point, dimensionID))
AD::SetBoxMaxC(ext, dimensionID, AD::GetPointC(point, dimensionID));
}

return ext;
}

public:
static OrthoTreePointDynamicGeneral Create(span<TVector const> const& vpt, size_t nDepthMax, std::optional<TBox> const& obox, size_t nElementMax)
{
autoc box = obox.has_value() ? *obox : AD::GetBoxOfPoints(vpt);
autoc box = obox.has_value() ? *obox : GetBoxOfPoints(vpt);

autoc npt = vpt.size();
auto aid = vector<IdEntityNode>(npt, IdEntityNode{});
Expand Down Expand Up @@ -110,8 +138,8 @@ template<
typename TBox,
typename TRay,
typename TPlane,
typename TGeonetry = double,
typename adaptor_type = OrthoTree::AdaptorGeneral<DIMENSION_NO, TVector, TBox, TRay, TPlane, TGeonetry>>
typename TGeometry = double,
typename adaptor_type = OrthoTree::AdaptorGeneral<DIMENSION_NO, TVector, TBox, TRay, TPlane, TGeometry>>
class OrthoTreeBoxDynamicGeneral
{
static size_t constexpr _nChild = 1 << DIMENSION_NO;
Expand Down Expand Up @@ -192,11 +220,40 @@ class OrthoTreeBoxDynamicGeneral

}

static inline TBox BoxInvertedInit() noexcept
{
auto ext = TBox{};

for (dim_t dimensionID = 0; dimensionID < DIMENSION_NO; ++dimensionID)
{
AD::SetBoxMinC(ext, dimensionID, std::numeric_limits<TGeometry>::max());
AD::SetBoxMaxC(ext, dimensionID, std::numeric_limits<TGeometry>::lowest());
}

return ext;
}

static TBox GetBoxOfBoxes(std::span<TBox const> const& boxes) noexcept
{
auto ext = BoxInvertedInit();
for (autoc& e : boxes)
{
for (dim_t dimensionID = 0; dimensionID < DIMENSION_NO; ++dimensionID)
{
if (AD::GetBoxMinC(ext, dimensionID) > AD::GetBoxMinC(e, dimensionID))
AD::SetBoxMinC(ext, dimensionID, AD::GetBoxMinC(e, dimensionID));

if (AD::GetBoxMaxC(ext, dimensionID) < AD::GetBoxMaxC(e, dimensionID))
AD::SetBoxMaxC(ext, dimensionID, AD::GetBoxMaxC(e, dimensionID));
}
}
return ext;
}

public:
static OrthoTreeBoxDynamicGeneral Create(span<TBox const> const& vBox, size_t nDepthMax, std::optional<TBox> const& obox = std::nullopt, size_t nElementMax = 20)
{
autoc box = obox.has_value() ? *obox : AD::GetBoxOfBoxes(vBox);
autoc box = obox.has_value() ? *obox : GetBoxOfBoxes(vBox);

autoc nEnt = vBox.size();
auto aid = vector<IdEntityNode>(nEnt, IdEntityNode{});
Expand Down
4 changes: 2 additions & 2 deletions benchmarks/benchmarks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -772,7 +772,7 @@ int main()
ofstream report;
report.open("report.csv");

autoce nDepth = depth_t{ 5 };
autoce nDepth = depth_t{ 5 };
{
autoc szName = string("Diagonally placed points");
autoc aPointDiag_100M = GenerateGeometry<N, vector<PointND<N>>>([&] { return CreatePoints_Diagonal<N, 100 * N1M>(); }, szName, 100, report);
Expand Down Expand Up @@ -840,7 +840,7 @@ int main()
autoc aBox = GenerateGeometry<N, vector<BoundingBoxND<N>>>([&] { return CreateBoxes_CylindricalSemiRandom<N, static_cast<size_t>(aSizeNonLog.back())>(); }, szName, aSizeNonLog.back(), report);
autoc vTaskBruteForce = SelfConflictBruteForceBoxTasks<N>("Box self conflict by brute force", aBox);
autoc vTaskTreeCollisionDetection = CollisionDetectionBoxTasks<N>(3, "Box self conflict by octree", aBox);
autoc vTaskTreeSearch = SearchTreeBoxTasks<N>(3, "Box search by octree", aBox);
autoc vTaskTreeSearch = SearchTreeBoxTasks<N>(5, "Box search by octree", aBox);

RunTasks(vTaskBruteForce, report);
RunTasks(vTaskTreeCollisionDetection, report);
Expand Down
Loading

0 comments on commit ededa6b

Please sign in to comment.