Skip to content

Commit

Permalink
update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
alavenant committed Oct 15, 2024
1 parent e9cc40f commit 36bf012
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 15 deletions.
4 changes: 2 additions & 2 deletions src/filter_radius_assign/RadiusAssignFilter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,14 @@ void RadiusAssignFilter::doOneNoDomain(PointRef &pointSrc)
PointIdList iNeighbors;
if (m_args->search3d) iNeighbors = refView->build3dIndex().radius(pointSrc, m_args->m_radius);
else iNeighbors = refView->build2dIndex().radius(pointSrc, m_args->m_radius);

if (iNeighbors.size() == 0)
return;

if (!m_args->search3d && (m_args->m_max2d_below>=0 || m_args->m_max2d_above>=0))
{
double Zsrc = pointSrc.getFieldAs<double>(Dimension::Id::Z);

std::set<double> ZNeib;
for (PointId ptId : iNeighbors)
{
Expand Down
31 changes: 18 additions & 13 deletions test/test_radius_assign.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
pt_ini = (pt_x, pt_y, pt_z, 1)

numeric_precision = 4
numeric_precision_z = 2
distance_radius = 1


Expand All @@ -28,6 +29,10 @@ def distance3d(pt1, pt2):
)


def distanceZ(pt1, pt2):
return round(pt1[2] - pt2[2], numeric_precision_z)


def run_filter(arrays_las, distance_radius, search_3d, limit_z_above=-1, limit_w_below=-1):

filter = "filters.radius_assign"
Expand Down Expand Up @@ -154,7 +159,7 @@ def test_radius_assign_2d_cylinder_below():

def func_test(pt):
distance_i = distance2d(pt_ini, pt)
distance_z = pt[2] - pt_ini[2]
distance_z = distanceZ(pt, pt_ini)
if distance_i < distance_radius and distance_z < limit_z_below:
return 1
return 0
Expand All @@ -177,7 +182,7 @@ def test_radius_assign_2d_cylinder_above():

def func_test(pt):
distance_i = distance2d(pt_ini, pt)
distance_z = pt_ini[2] - pt[2]
distance_z = distanceZ(pt_ini, pt)
if distance_i < distance_radius and distance_z < limit_z_above:
return 1
return 0
Expand All @@ -197,7 +202,7 @@ def test_radius_assign_2d_cylinder_above_below_null():

def func_test(pt):
distance_i = distance2d(pt_ini, pt)
distance_z = pt_ini[2] - pt[2]
distance_z = distanceZ(pt_ini, pt)
if distance_i < distance_radius and distance_z == 0:
return 1
return 0
Expand All @@ -217,7 +222,7 @@ def test_radius_assign_2d_cylinder_above_null_bellow_all():

def func_test(pt):
distance_i = distance2d(pt_ini, pt)
distance_z = pt[2] - pt_ini[2]
distance_z = distanceZ(pt, pt_ini)
if distance_i < distance_radius and distance_z <= 0:
return 1
return 0
Expand Down Expand Up @@ -261,13 +266,12 @@ def test_radius_assign_2d_cylinder_above_and_bellow(execution_number):

def func_test(pt):
distance_i = distance2d(pt_ini, pt)
distance_z = pt_ini[2] - pt[2]
if (
distance_i < distance_radius
and distance_z <= limit_z_above
and (-distance_z) <= limit_z_below
):
return 1
distance_z = distanceZ(pt, pt_ini) # src - ref
if distance_i < distance_radius:
if distance_z <= 0 and (-distance_z) <= limit_z_above: # src est sur ref
return 1
if distance_z >= 0 and distance_z <= limit_z_below: # src est sous ref
return 1
return 0

arrays_las, nb_points_take_2d = build_random_points_around_one_point(func_test, points)
Expand Down Expand Up @@ -298,9 +302,10 @@ def test_radius_assign_2d_cylinder(limit_z_above, limit_z_below):
def func_test(pt):
distance_i = distance2d(pt_ini, pt)
if distance_i < distance_radius:
if (limit_z_above >= 0) and ((pt_ini[2] - pt[2]) > limit_z_above):
distance_z = distanceZ(pt, pt_ini) # src - ref
if limit_z_above >= 0 and distance_z <= 0 and (-distance_z) > limit_z_above:
return 0
if (limit_z_below >= 0) and ((pt[2] - pt_ini[2]) > limit_z_below):
if limit_z_below >= 0 and distance_z >= 0 and distance_z > limit_z_below:
return 0
return 1
else:
Expand Down

0 comments on commit 36bf012

Please sign in to comment.