File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -52,6 +52,8 @@ unsafe fn read_points(py: Python<'_>, filepath: &str) -> PyResult<E57> {
5252 let mut color_vec = Vec :: with_capacity ( pc. records as usize * 3 ) ;
5353 let mut intensity_vec = Vec :: with_capacity ( pc. records as usize ) ;
5454 let mut nrows = 0 ;
55+ let intensity_min = pc. intensity_limits . map ( |limits| limits. min ) . unwrap_or ( 0.0 ) ;
56+ let intensity_max = pc. intensity_limits . map ( |limits| limits. max ) . unwrap_or ( 1.0 ) ;
5557 for pointcloud in file. pointclouds ( ) {
5658 let mut iter = file
5759 . pointcloud_simple ( & pointcloud)
@@ -67,14 +69,12 @@ unsafe fn read_points(py: Python<'_>, filepath: &str) -> PyResult<E57> {
6769 point_vec. extend ( [ x, y, z] ) ;
6870 nrows += 1
6971 }
70- // if let Some(intensity) = p.intensity{
71- // vec.append(intensity as f64)
72- // }
7372 if let Some ( color) = p. color {
7473 color_vec. extend ( [ color. red , color. green , color. blue ] )
7574 }
7675 if let Some ( intensity) = p. intensity {
77- intensity_vec. push ( intensity)
76+ let rescaled_intensity = ( intensity * ( intensity_max - intensity_min) ) + intensity_min;
77+ intensity_vec. push ( rescaled_intensity)
7878 }
7979 }
8080 }
Original file line number Diff line number Diff line change @@ -34,6 +34,15 @@ def test_read_intensity():
3434 intensity = pointcloud .intensity
3535 assert isinstance (intensity , np .ndarray )
3636 assert len (intensity ) == 1_220
37+ assert np .all (intensity >= 0.3935 )
38+ assert np .all (intensity <= 0.5555 )
39+
40+
41+ def test_no_rgb_intensity ():
42+ pointcloud = e57 .read_points (r"testdata/bunnyFloat.e57" )
43+ intensity = pointcloud .intensity
44+ assert isinstance (intensity , np .ndarray )
45+ assert len (intensity ) == 0
3746
3847
3948def test_box_dimensions ():
You can’t perform that action at this time.
0 commit comments