@@ -11,7 +11,7 @@ use crate::{
1111use arrayvec:: ArrayVec ;
1212use log:: info;
1313use nalgebra:: Vector3 ;
14- use octant_helper:: { Octant , OctantAxisDirections , OctantDirectionFlags } ;
14+ use octant_helper:: { Octant , OctantAxisDirections , HalfspaceFlags } ;
1515use rayon:: prelude:: * ;
1616use smallvec:: SmallVec ;
1717use std:: cell:: RefCell ;
@@ -395,33 +395,33 @@ impl<I: Index, R: Real> OctreeNode<I, R> {
395395 . expect ( "Failed to get split point of octree node" ) ;
396396 let split_coordinates = grid. point_coordinates ( & split_point) ;
397397
398- let mut octant_flags = vec ! [ OctantDirectionFlags :: empty( ) ; particles. len( ) ] ;
398+ let mut halfspace_flags = vec ! [ HalfspaceFlags :: empty( ) ; particles. len( ) ] ;
399399 let mut counters: [ usize ; 8 ] = [ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ] ;
400400 let mut non_ghost_counters: [ usize ; 8 ] = [ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ] ;
401401
402- // Classify all particles of this leaf into its octants
403- assert_eq ! ( particles. len( ) , octant_flags . len( ) ) ;
404- for ( particle_idx, particle_octant_flags ) in
405- particles. iter ( ) . copied ( ) . zip ( octant_flags . iter_mut ( ) )
402+ // Classify all particles of this leaf into the halfspaces relative to the split point
403+ assert_eq ! ( particles. len( ) , halfspace_flags . len( ) ) ;
404+ for ( particle_idx, particle_halfspace_flags ) in
405+ particles. iter ( ) . copied ( ) . zip ( halfspace_flags . iter_mut ( ) )
406406 {
407407 let relative_pos = particle_positions[ particle_idx] - split_coordinates;
408408
409- // Check what the main octant of the particle is ( to count ghost particles)
409+ // Check what the main octant (without margin) of the particle is to count ghost particles later
410410 {
411411 let main_octant: Octant = OctantAxisDirections :: classify ( & relative_pos) . into ( ) ;
412412 non_ghost_counters[ main_octant as usize ] += 1 ;
413413 }
414414
415- // Classify into all octants with margin
415+ // Classify into all halfspaces with margin
416416 {
417- * particle_octant_flags =
418- OctantDirectionFlags :: classify_with_margin ( & relative_pos, margin) ;
417+ * particle_halfspace_flags =
418+ HalfspaceFlags :: classify_with_margin ( & relative_pos, margin) ;
419419
420420 // Increase the counter of each octant that contains the current particle
421- OctantDirectionFlags :: all_unique_octants ( )
421+ HalfspaceFlags :: all_unique_octants ( )
422422 . iter ( )
423423 . zip ( counters. iter_mut ( ) )
424- . filter ( |( octant, _) | particle_octant_flags . contains ( * * octant) )
424+ . filter ( |( octant, _) | particle_halfspace_flags . contains ( * * octant) )
425425 . for_each ( |( _, counter) | {
426426 * counter += 1 ;
427427 } ) ;
@@ -436,7 +436,7 @@ impl<I: Index, R: Real> OctreeNode<I, R> {
436436 . zip ( counters. iter ( ) . zip ( non_ghost_counters. iter ( ) ) )
437437 {
438438 let current_octant_dir = OctantAxisDirections :: from ( current_octant) ;
439- let current_octant_flags = OctantDirectionFlags :: from ( current_octant) ;
439+ let current_octant_flags = HalfspaceFlags :: from ( current_octant) ;
440440
441441 let min_corner = current_octant_dir
442442 . combine_point_index ( grid, & self . min_corner , & split_point)
@@ -450,10 +450,10 @@ impl<I: Index, R: Real> OctreeNode<I, R> {
450450 particles
451451 . iter ( )
452452 . copied ( )
453- . zip ( octant_flags . iter ( ) )
453+ . zip ( halfspace_flags . iter ( ) )
454454 // Skip particles from other octants
455- . filter ( |( _, & particle_i_octant ) | {
456- particle_i_octant . contains ( current_octant_flags)
455+ . filter ( |( _, & particle_i_halfspaces ) | {
456+ particle_i_halfspaces . contains ( current_octant_flags)
457457 } )
458458 . map ( |( particle_i, _) | particle_i) ,
459459 ) ;
@@ -495,7 +495,7 @@ impl<I: Index, R: Real> OctreeNode<I, R> {
495495 . expect ( "Failed to get split point of octree node" ) ;
496496 let split_coordinates = grid. point_coordinates ( & split_point) ;
497497
498- let mut octant_flags = vec ! [ OctantDirectionFlags :: empty( ) ; particles. len( ) ] ;
498+ let mut octant_flags = vec ! [ HalfspaceFlags :: empty( ) ; particles. len( ) ] ;
499499
500500 // Initial values for the thread local counters
501501 let zeros = || ( [ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ] , [ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ] ) ;
@@ -532,13 +532,13 @@ impl<I: Index, R: Real> OctreeNode<I, R> {
532532
533533 // Classify into all octants with margin
534534 {
535- * particle_octant_flags = OctantDirectionFlags :: classify_with_margin (
535+ * particle_octant_flags = HalfspaceFlags :: classify_with_margin (
536536 & relative_pos,
537537 margin,
538538 ) ;
539539
540540 // Increase the counter of each octant that contains the current particle
541- OctantDirectionFlags :: all_unique_octants ( )
541+ HalfspaceFlags :: all_unique_octants ( )
542542 . iter ( )
543543 . zip ( counters. iter_mut ( ) )
544544 . filter ( |( octant, _) | particle_octant_flags. contains ( * * octant) )
@@ -572,7 +572,7 @@ impl<I: Index, R: Real> OctreeNode<I, R> {
572572 . map (
573573 |( & current_octant, ( & octant_particle_count, & octant_non_ghost_count) ) | {
574574 let current_octant_dir = OctantAxisDirections :: from ( current_octant) ;
575- let current_octant_flags = OctantDirectionFlags :: from ( current_octant) ;
575+ let current_octant_flags = HalfspaceFlags :: from ( current_octant) ;
576576
577577 let min_corner = current_octant_dir
578578 . combine_point_index ( grid, & self . min_corner , & split_point)
@@ -922,7 +922,7 @@ mod octant_helper {
922922 }
923923
924924 bitflags ! {
925- pub struct OctantDirectionFlags : u8 {
925+ pub struct HalfspaceFlags : u8 {
926926 const X_NEG = 0b00000001 ;
927927 const X_POS = 0b00000010 ;
928928 const Y_NEG = 0b00000100 ;
@@ -941,22 +941,22 @@ mod octant_helper {
941941 }
942942 }
943943
944- impl OctantDirectionFlags {
944+ impl HalfspaceFlags {
945945 #[ inline( always) ]
946- pub const fn all_unique_octants ( ) -> & ' static [ OctantDirectionFlags ] {
946+ pub const fn all_unique_octants ( ) -> & ' static [ HalfspaceFlags ] {
947947 & ALL_UNIQUE_OCTANT_DIRECTION_FLAGS
948948 }
949949
950- /// Classifies a point relative to zero into all octants it belongs including a margin around the octants
950+ /// Classifies a point relative to zero into all halfspaces it belongs including a margin around the halfspace boundary
951951 #[ inline( always) ]
952952 pub fn classify_with_margin < R : Real > ( point : & Vector3 < R > , margin : R ) -> Self {
953- let mut flags = OctantDirectionFlags :: empty ( ) ;
954- flags. set ( OctantDirectionFlags :: X_NEG , point. x < margin) ;
955- flags. set ( OctantDirectionFlags :: X_POS , point. x > -margin) ;
956- flags. set ( OctantDirectionFlags :: Y_NEG , point. y < margin) ;
957- flags. set ( OctantDirectionFlags :: Y_POS , point. y > -margin) ;
958- flags. set ( OctantDirectionFlags :: Z_NEG , point. z < margin) ;
959- flags. set ( OctantDirectionFlags :: Z_POS , point. z > -margin) ;
953+ let mut flags = HalfspaceFlags :: empty ( ) ;
954+ flags. set ( HalfspaceFlags :: X_NEG , point. x < margin) ;
955+ flags. set ( HalfspaceFlags :: X_POS , point. x > -margin) ;
956+ flags. set ( HalfspaceFlags :: Y_NEG , point. y < margin) ;
957+ flags. set ( HalfspaceFlags :: Y_POS , point. y > -margin) ;
958+ flags. set ( HalfspaceFlags :: Z_NEG , point. z < margin) ;
959+ flags. set ( HalfspaceFlags :: Z_POS , point. z > -margin) ;
960960 flags
961961 }
962962
@@ -976,38 +976,38 @@ mod octant_helper {
976976
977977 #[ inline( always) ]
978978 pub fn from_directions ( directions : OctantAxisDirections ) -> Self {
979- let mut flags = OctantDirectionFlags :: empty ( ) ;
980- flags. set ( OctantDirectionFlags :: X_NEG , directions. x_axis . is_negative ( ) ) ;
981- flags. set ( OctantDirectionFlags :: X_POS , directions. x_axis . is_positive ( ) ) ;
982- flags. set ( OctantDirectionFlags :: Y_NEG , directions. y_axis . is_negative ( ) ) ;
983- flags. set ( OctantDirectionFlags :: Y_POS , directions. y_axis . is_positive ( ) ) ;
984- flags. set ( OctantDirectionFlags :: Z_NEG , directions. z_axis . is_negative ( ) ) ;
985- flags. set ( OctantDirectionFlags :: Z_POS , directions. z_axis . is_positive ( ) ) ;
979+ let mut flags = HalfspaceFlags :: empty ( ) ;
980+ flags. set ( HalfspaceFlags :: X_NEG , directions. x_axis . is_negative ( ) ) ;
981+ flags. set ( HalfspaceFlags :: X_POS , directions. x_axis . is_positive ( ) ) ;
982+ flags. set ( HalfspaceFlags :: Y_NEG , directions. y_axis . is_negative ( ) ) ;
983+ flags. set ( HalfspaceFlags :: Y_POS , directions. y_axis . is_positive ( ) ) ;
984+ flags. set ( HalfspaceFlags :: Z_NEG , directions. z_axis . is_negative ( ) ) ;
985+ flags. set ( HalfspaceFlags :: Z_POS , directions. z_axis . is_positive ( ) ) ;
986986 flags
987987 }
988988 }
989989
990- impl From < Octant > for OctantDirectionFlags {
990+ impl From < Octant > for HalfspaceFlags {
991991 fn from ( octant : Octant ) -> Self {
992992 Self :: from_octant ( octant)
993993 }
994994 }
995995
996- impl From < OctantAxisDirections > for OctantDirectionFlags {
996+ impl From < OctantAxisDirections > for HalfspaceFlags {
997997 fn from ( directions : OctantAxisDirections ) -> Self {
998998 Self :: from_directions ( directions)
999999 }
10001000 }
10011001
1002- const ALL_UNIQUE_OCTANT_DIRECTION_FLAGS : [ OctantDirectionFlags ; 8 ] = [
1003- OctantDirectionFlags :: NEG_NEG_NEG ,
1004- OctantDirectionFlags :: POS_NEG_NEG ,
1005- OctantDirectionFlags :: NEG_POS_NEG ,
1006- OctantDirectionFlags :: POS_POS_NEG ,
1007- OctantDirectionFlags :: NEG_NEG_POS ,
1008- OctantDirectionFlags :: POS_NEG_POS ,
1009- OctantDirectionFlags :: NEG_POS_POS ,
1010- OctantDirectionFlags :: POS_POS_POS ,
1002+ const ALL_UNIQUE_OCTANT_DIRECTION_FLAGS : [ HalfspaceFlags ; 8 ] = [
1003+ HalfspaceFlags :: NEG_NEG_NEG ,
1004+ HalfspaceFlags :: POS_NEG_NEG ,
1005+ HalfspaceFlags :: NEG_POS_NEG ,
1006+ HalfspaceFlags :: POS_POS_NEG ,
1007+ HalfspaceFlags :: NEG_NEG_POS ,
1008+ HalfspaceFlags :: POS_NEG_POS ,
1009+ HalfspaceFlags :: NEG_POS_POS ,
1010+ HalfspaceFlags :: POS_POS_POS ,
10111011 ] ;
10121012
10131013 impl OctantAxisDirections {
0 commit comments