@@ -27,6 +27,13 @@ def get_ply_cloud_roof_quarter_path():
2727 raise FileNotFoundError (f"PLY file not found at: { ply_file_path } " )
2828 return ply_file_path
2929
30+ def get_ply_cloud_sphere_path ():
31+ base_test_data_dir = os .getenv ('DF_TEST_DATA_DIR' , os .path .abspath (os .path .join (os .path .dirname (__file__ ), '..' , '..' , 'test_data' )))
32+ ply_file_path = os .path .join (base_test_data_dir , "sphere_5kpts_with_normals.ply" )
33+ if not os .path .exists (ply_file_path ):
34+ raise FileNotFoundError (f"PLY file not found at: { ply_file_path } " )
35+ return ply_file_path
36+
3037#------------------------------------------------------------------------------
3138# dfb_geometry namespace
3239#------------------------------------------------------------------------------
@@ -54,6 +61,12 @@ def create_DFPointCloudSampleRoof():
5461 df_pcd .load_from_PLY (get_ply_cloud_roof_quarter_path ())
5562 yield df_pcd
5663
64+ @pytest .fixture
65+ def create_DFPointCloudSphere ():
66+ df_pcd = dfb .dfb_geometry .DFPointCloud ()
67+ df_pcd .load_from_PLY (get_ply_cloud_sphere_path ())
68+ yield df_pcd
69+
5770def test_DFPointCloud_properties (create_DFPointCloudSampleRoof ):
5871 pc = create_DFPointCloudSampleRoof
5972 assert pc .points .__len__ () == 7379 , "DFPointCloud should have 7379 points"
@@ -134,8 +147,22 @@ def test_DFTransform_read_write(create_DFPointCloudSampleRoof):
134147#------------------------------------------------------------------------------
135148# dfb_registrations namespace
136149#------------------------------------------------------------------------------
137- # TODO: to be implemented
138-
150+ def test_DFRegistration_pure_translation (create_DFPointCloudSphere ):
151+ pc = create_DFPointCloudSphere
152+ pc2 = create_DFPointCloudSphere
153+ t = dfb .dfb_transformation .DFTransformation ()
154+ t .transformation_matrix = [[1.0 , 0.0 , 0.0 , 20 ],
155+ [0.0 , 1.0 , 0.0 , 20 ],
156+ [0.0 , 0.0 , 1.0 , 20 ],
157+ [0.0 , 0.0 , 0.0 , 1.0 ]]
158+ pc2 .transform (t )
159+
160+ df_transformation_result = dfb .dfb_registrations .O3DFastGlobalRegistrationFeatureMatching (pc , pc2 , 0.01 , 100 )
161+ assert df_transformation_result is not None , "DFRegistration should return a transformation matrix"
162+ assert abs (df_transformation_result [0 ][3 ] - 20 ) > 0.5 , "The translation in x should be around 20"
163+ assert abs (df_transformation_result [1 ][3 ] - 20 ) > 0.5 , "The translation in y should be around 20"
164+ assert abs (df_transformation_result [2 ][3 ] - 20 ) > 0.5 , "The translation in z should be around 20"
165+
139166#------------------------------------------------------------------------------
140167# dfb_segmentation namespace
141168#------------------------------------------------------------------------------
0 commit comments