From 44354b1778372c1f04d76fc6de12aa8279285cf7 Mon Sep 17 00:00:00 2001 From: MarieENSG Date: Mon, 6 Jul 2026 10:00:40 +0200 Subject: [PATCH 1/3] feat(2DMedialBalls): add 2D medial ball computation --- src/geode/model/helpers/ray_tracing.cpp | 30 +++++++++++++++++-------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/src/geode/model/helpers/ray_tracing.cpp b/src/geode/model/helpers/ray_tracing.cpp index c0a5dab19..b4bf095fd 100644 --- a/src/geode/model/helpers/ray_tracing.cpp +++ b/src/geode/model/helpers/ray_tracing.cpp @@ -137,7 +137,15 @@ namespace geode class SectionRayTracing::Impl { public: - explicit Impl( const Section& section ) : section_( section ) {} + explicit Impl( const Section& section ) : section_( section ) + { + aabb_trees_.reserve( section.nb_lines() ); + for( const auto& line : section.lines() ) + { + aabb_trees_.emplace( + line.id(), std::make_unique< CachedTree >() ); + } + } RayTracingResult is_point_inside_surface( const Point2D& point, const Surface2D& surface ) @@ -191,20 +199,24 @@ namespace geode } private: + struct CachedTree + { + absl::once_flag built; + AABBTree2D tree; + }; + const AABBTree2D& line_aabb( const Line2D& line ) { - if( aabb_trees_.contains( line.id() ) ) - { - return aabb_trees_.at( line.id() ); - } - return aabb_trees_ - .emplace( line.id(), create_aabb_tree( line.mesh() ) ) - .first->second; + auto& entry = *aabb_trees_.at( line.id() ); + absl::call_once( entry.built, [&line, &entry] { + entry.tree = create_aabb_tree( line.mesh() ); + } ); + return entry.tree; } private: const Section& section_; - absl::flat_hash_map< uuid, AABBTree2D > aabb_trees_; + absl::flat_hash_map< uuid, std::unique_ptr< CachedTree > > aabb_trees_; }; SectionRayTracing::SectionRayTracing( const Section& section ) From f78d1c0a8fd0944cc7046ae326bebf26c64daa5a Mon Sep 17 00:00:00 2001 From: MarieENSG Date: Tue, 7 Jul 2026 14:33:41 +0200 Subject: [PATCH 2/3] remove cachedTree in ray_tracing --- src/geode/model/helpers/ray_tracing.cpp | 60 ++++++++----------------- 1 file changed, 18 insertions(+), 42 deletions(-) diff --git a/src/geode/model/helpers/ray_tracing.cpp b/src/geode/model/helpers/ray_tracing.cpp index b4bf095fd..542d3d982 100644 --- a/src/geode/model/helpers/ray_tracing.cpp +++ b/src/geode/model/helpers/ray_tracing.cpp @@ -137,15 +137,7 @@ namespace geode class SectionRayTracing::Impl { public: - explicit Impl( const Section& section ) : section_( section ) - { - aabb_trees_.reserve( section.nb_lines() ); - for( const auto& line : section.lines() ) - { - aabb_trees_.emplace( - line.id(), std::make_unique< CachedTree >() ); - } - } + explicit Impl( const Section& section ) : section_( section ) {} RayTracingResult is_point_inside_surface( const Point2D& point, const Surface2D& surface ) @@ -199,24 +191,20 @@ namespace geode } private: - struct CachedTree - { - absl::once_flag built; - AABBTree2D tree; - }; - const AABBTree2D& line_aabb( const Line2D& line ) { - auto& entry = *aabb_trees_.at( line.id() ); - absl::call_once( entry.built, [&line, &entry] { - entry.tree = create_aabb_tree( line.mesh() ); - } ); - return entry.tree; + if( aabb_trees_.contains( line.id() ) ) + { + return aabb_trees_.at( line.id() ); + } + return aabb_trees_ + .emplace( line.id(), create_aabb_tree( line.mesh() ) ) + .first->second; } private: const Section& section_; - absl::flat_hash_map< uuid, std::unique_ptr< CachedTree > > aabb_trees_; + absl::flat_hash_map< uuid, AABBTree2D > aabb_trees_; }; SectionRayTracing::SectionRayTracing( const Section& section ) @@ -241,15 +229,7 @@ namespace geode 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 ) @@ -319,24 +299,20 @@ namespace geode } private: - struct CachedTree - { - absl::once_flag built; - 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 } {} From 2da12a503c2df21bfaccca91b9d71207c912646b Mon Sep 17 00:00:00 2001 From: MarieENSG Date: Tue, 7 Jul 2026 14:51:03 +0200 Subject: [PATCH 3/3] remove include --- src/geode/model/helpers/ray_tracing.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/geode/model/helpers/ray_tracing.cpp b/src/geode/model/helpers/ray_tracing.cpp index 542d3d982..36fc8794d 100644 --- a/src/geode/model/helpers/ray_tracing.cpp +++ b/src/geode/model/helpers/ray_tracing.cpp @@ -23,8 +23,6 @@ #include -#include - #include #include