Skip to content
Merged
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
32 changes: 9 additions & 23 deletions src/geode/model/helpers/ray_tracing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@

#include <geode/model/helpers/ray_tracing.hpp>

#include <absl/base/call_once.h>

#include <geode/basic/pimpl_impl.hpp>

#include <geode/geometry/aabb.hpp>
Expand All @@ -43,7 +41,7 @@
namespace
{
constexpr geode::index_t NUMBER_2D_DIRECTIONS = 9;
const std::array< geode::Vector2D, NUMBER_2D_DIRECTIONS >& directions_2D()

Check warning on line 44 in src/geode/model/helpers/ray_tracing.cpp

View workflow job for this annotation

GitHub Actions / test / tidy

src/geode/model/helpers/ray_tracing.cpp:44:64 [readability-identifier-naming]

invalid case style for function 'directions_2D'
{
static const std::array< geode::Vector2D, NUMBER_2D_DIRECTIONS >
directions = { {
Expand All @@ -61,7 +59,7 @@
}

constexpr geode::index_t NUMBER_3D_DIRECTIONS = 13;
const std::array< geode::Vector3D, NUMBER_3D_DIRECTIONS >& directions_3D()

Check warning on line 62 in src/geode/model/helpers/ray_tracing.cpp

View workflow job for this annotation

GitHub Actions / test / tidy

src/geode/model/helpers/ray_tracing.cpp:62:64 [readability-identifier-naming]

invalid case style for function 'directions_3D'
{
static const std::array< geode::Vector3D, NUMBER_3D_DIRECTIONS >
directions = { {
Expand Down Expand Up @@ -139,7 +137,7 @@
public:
explicit Impl( const Section& section ) : section_( section ) {}

RayTracingResult is_point_inside_surface(

Check warning on line 140 in src/geode/model/helpers/ray_tracing.cpp

View workflow job for this annotation

GitHub Actions / test / tidy

src/geode/model/helpers/ray_tracing.cpp:140:26 [readability-function-cognitive-complexity]

function 'is_point_inside_surface' has cognitive complexity of 14 (threshold 10)
const Point2D& point, const Surface2D& surface )
{
for( const auto& direction : ::directions_2D() )
Expand Down Expand Up @@ -229,15 +227,7 @@
class BRepRayTracing::Impl
{
public:
explicit Impl( const BRep& brep ) : brep_( brep )
{
aabb_trees_.reserve( brep.nb_surfaces() );
for( const auto& surface : brep.surfaces() )
{
aabb_trees_.emplace(
surface.id(), std::make_unique< CachedTree >() );
}
}
explicit Impl( const BRep& brep ) : brep_( brep ) {}

BoundarySurfaceIntersections find_intersections_with_boundaries(
const InfiniteLine3D& infinite_line, const Block3D& block )
Expand All @@ -255,7 +245,7 @@
return result;
}

RayTracingResult is_point_inside_block(

Check warning on line 248 in src/geode/model/helpers/ray_tracing.cpp

View workflow job for this annotation

GitHub Actions / test / tidy

src/geode/model/helpers/ray_tracing.cpp:248:26 [readability-function-cognitive-complexity]

function 'is_point_inside_block' has cognitive complexity of 14 (threshold 10)
const Point3D& point, const Block3D& block )
{
for( const auto& direction : ::directions_3D() )
Expand Down Expand Up @@ -307,24 +297,20 @@
}

private:
struct CachedTree
{
absl::once_flag built;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove also useless includes

AABBTree3D tree;
};

const AABBTree3D& surface_aabb( const Surface3D& surface )
{
auto& entry = *aabb_trees_.at( surface.id() );
absl::call_once( entry.built, [&surface, &entry] {
entry.tree = create_aabb_tree( surface.mesh() );
} );
return entry.tree;
if( aabb_trees_.contains( surface.id() ) )
{
return aabb_trees_.at( surface.id() );
}
return aabb_trees_
.emplace( surface.id(), create_aabb_tree( surface.mesh() ) )
.first->second;
}

private:
const BRep& brep_;
absl::flat_hash_map< uuid, std::unique_ptr< CachedTree > > aabb_trees_;
absl::flat_hash_map< uuid, AABBTree3D > aabb_trees_;
};

BRepRayTracing::BRepRayTracing( const BRep& brep ) : impl_{ brep } {}
Expand Down
Loading