Skip to content

Commit 3fb136b

Browse files
UPDATE: missing python unit tests added for pointclouds and meshes
1 parent e20ef0d commit 3fb136b

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed

tests/integration_tests/pybinds_tests/test_pybind_units.py

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,27 @@ def test_DFPointCloud_get_tight_bounding_box(create_DFPointCloudSampleRoof):
152152
# round to the 3 decimal places
153153
assert round(obb[0][0], 3) == 0.196, "The min x of the OBB should be 0.196"
154154

155+
def test_DFPointCloud_get_axis_aligned_bounding_box(create_DFPointCloudSampleRoof):
156+
pc = create_DFPointCloudSampleRoof
157+
aabb = pc.get_axis_aligned_bounding_box()
158+
# round to the 3 decimal places
159+
assert round(aabb[0][0], 3) == -2.339, "The min x of the AABB should be 0.196"
160+
161+
def test_DFPointCloud_compute_distance():
162+
point_pc_1 = [(0, 0, 0)]
163+
point_pc_2 = [(1, 0, 0)]
164+
normal_pc_1 = [(0, 0, 1)]
165+
normal_pc_2 = [(0, 0, 1)]
166+
color_pc_1 = [(0, 0, 0)]
167+
color_pc_2 = [(0, 0, 0)]
168+
169+
pc_1 = dfb.dfb_geometry.DFPointCloud(point_pc_1, normal_pc_1, color_pc_1)
170+
pc_2 = dfb.dfb_geometry.DFPointCloud(point_pc_2, normal_pc_2, color_pc_2)
171+
172+
distance = pc_1.compute_distance(pc_2)[0]
173+
174+
assert distance == 1. , "The distance between the two points should be 1."
175+
155176
# mesh tests
156177

157178
def test_DFMesh_init():
@@ -163,6 +184,32 @@ def test_DFMesh_load_from_PLY(create_DFMeshCube):
163184
assert mesh.vertices.__len__() == 726, "DFMesh should have 726 vertices"
164185
assert mesh.faces.__len__() == 1200, "DFMesh should have 800 faces"
165186

187+
def test_DFMesh_properties():
188+
vertices = [[0, 0, 0], [1, 0, 0], [1, 1, 0], [0, 1, 0], [0, 1, -1], [0, 0, -1]]
189+
faces = [[0, 1, 2], [0, 2, 3], [0, 3, 4], [0, 4, 5]]
190+
mesh = dfb.dfb_geometry.DFMesh(vertices, faces, [], [], [])
191+
assert mesh.get_num_vertices() == 6, "get_num_vertices() should return 6"
192+
assert mesh.get_num_faces() == 4, "get_num_faces() should return 4"
193+
assert isinstance(mesh.vertices, list), "vertices should be a list"
194+
assert isinstance(mesh.faces, list), "faces should be a list"
195+
assert isinstance(mesh.normals_face, list), "normals_faces should be a list"
196+
assert isinstance(mesh.normals_vertex, list), "normals_vertex should be a list"
197+
assert isinstance(mesh.colors_face, list), "colors_faces should be a list"
198+
assert isinstance(mesh.colors_vertex, list), "colors_vertex should be a list"
199+
assert len(mesh.vertices[0]) == 3, "vertices should be a list of 3 coordinates"
200+
assert len(mesh.faces[0]) == 3, "faces should be a list of 3 indexes"
201+
202+
def test_DFMesh_compute_distance():
203+
vertices = [[0, 0, 0], [1, 0, 0], [0, 1, 0]]
204+
faces = [[0, 1, 2]]
205+
mesh = dfb.dfb_geometry.DFMesh(vertices, faces, [], [], [])
206+
point = [(0, 0, 1)]
207+
normal = [(0, 0, 1)]
208+
color = [(0, 0, 0)]
209+
pc = dfb.dfb_geometry.DFPointCloud(point, normal, color)
210+
distance = mesh.compute_distance(pc)[0]
211+
assert distance == 1.0, "The distance between the point and the mesh should be 1.0"
212+
166213
def test_DFMesh_sample_points(create_DFMeshCube):
167214
mesh = create_DFMeshCube
168215
pc = mesh.sample_points_uniformly(1000)

0 commit comments

Comments
 (0)