1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
//! This module contains functionality for working with a compact file format for storing 3D point
//! data taken from a laser profile triangulation scanner. The format is simple and designed to be
//! similar to the intermediate representation produced by sensors in their raw output.
//!
//! The format is identified by the extension `.lptf3` and the header structured as follows:
//!
//! - bytes 0-5: magic number b"LPTF3" to identify the file type
//! - bytes 6-7: version number (currently 1)
//! - byte 8-9: data flags
//! - bit 0: Bytes per point coordinate (0=16 bit, 1=32 bit)
//! - bit 1: Color data present (0=none, 1=single uint8)
//! - byte 10: motion type
//! - 0: fixed y translation
//! - 1-255: not implemented
//!
//! After the header, the next set of bytes will depend on the motion type:
//!
//! - If the motion type is 0, the next four bytes will be a 32 bit uint representing the y
//! translation of the scanner per frame in nanometers.
//!
//! Following the motion type values, the file will contain a repeating sequence consisting of
//! a frame header and a variable number of point entries. The frame header consists of the
//! following 24 bytes:
//!
//! - bytes 0-3: frame number (uint32)
//! - bytes 4-7: number of points in the frame (uint32)
//! - bytes 8-11: x offset for all frame points in micrometers (int32)
//! - bytes 12-15: z offset for all frame points in micrometers (int32)
//! - bytes 16-19: x resolution for all frame points in nanometers (uint32)
//! - bytes 20-23: z resolution for all frame points in nanometers (uint32)
//!
//! Following the frame header, there will be the number of individual point entries specified
//! by the frame header. Each point entry consists of the following:
//!
//! - x coordinate (16 or 32-bit signed integer, depending on the data flags)
//! - z coordinate (16 or 32-bit signed integer, depending on the data flags)
//! - color (optional, 8-bit unsigned integer if color data is present)
//!
//! At the end of the point entries, there will be either another frame header or the end of the
//! file.
use load_lptf3_downfilter;
use crateHalfEdgeMesh;
use crateload_downsample_filter_lptf3;
use crateload_lptf3_mesh_core;
use crate::;
use Path;
pub use *;
pub use Lptf3DsParams;
pub use Lptf3Loader;
pub use *;
/// The Lptf3Load enum defines the different ways to load data from a LPTF3 file, and is used to
/// pass these options to loading functions.
/// This trait defines the interface for uncertainty models that can be used when loading LPTF3
/// data from a file.
/// Quickly get the point distribution for the LPTF3 file, which returns a vector of point counts
/// for bins of the given size. For certain applications this is a quick way to heuristically check
/// if a scan of a known scene roughly matches the expected data.
///
/// # Arguments
///
/// * `file_path`:
/// * `bin_size`:
///
/// returns: Result<Vec<usize, Global>, Box<dyn Error, Global>>
///
/// # Examples
///
/// ```
///
/// ```
/// Read a lptf3 (Laser Profile Triangulation Format 3D) file and return a `PointCloud`.
///
/// This function reads a LPTF3 file, which is a compact file format for storing 3D point data
/// taken from a laser profile triangulation scanner. The format is simple and compact, capable
/// of practically storing about 200k points (with an 8-bit color value each) per MB when using a
/// 16-bit coordinate format, or half that when using a 32-bit coordinate format.
///
/// There are a few different ways to load the data, controlled by the `Lptf3Load` enum:
/// - `Lptf3Load::All`: Load all points from the file.
/// - `Lptf3Load::TakeEveryN(n)`: Load every Nth row from the file. The loader will attempt to
/// roughly match the x spacing of the points to the gap distance between rows, resulting in a
/// grid-like point cloud with an approximately uniform point spacing when viewed from the
/// X-Y plane. This is a very fast method of retrieving a downsampled point cloud.
/// - `Lptf3Load::SmoothSample(params)`: Load the points using a downsampling filter, which
/// downsamples the point cloud similar to the `TakeEveryN` method, but also performs a gaussian
/// smoothing step using the full original cloud. This takes the longest time, but can remove
/// a significant amount of noise from the data by making use of an adjacency structure that
/// will be lost once the points are turned into a cloud.
///
/// # Arguments
///
/// * `file_path`: A path to the LPTF3 file to load.
/// * `load`: An enum specifying how to load the data from the file.
///
/// returns: Result<PointCloud, Box<dyn Error, Global>>
/// Read a lptf3 (Laser Profile Triangulation Format 3D) file and return a `HalfEdgeMesh`.
///
/// This function reads a LPTF3 file, which is a compact file format for storing 3D point data
/// taken from a laser profile triangulation scanner. The format is simple and compact, capable
/// of practically storing about 200k points (with an 8-bit color value each) per MB when using a
/// 16-bit coordinate format, or half that when using a 32-bit coordinate format.
///
/// There are a few different ways to load the data, controlled by the `Lptf3Load` enum:
/// - `Lptf3Load::All`: Load all points from the file.
/// - `Lptf3Load::TakeEveryN(n)`: Load every Nth row from the file. The loader will attempt to
/// roughly match the x spacing of the points to the gap distance between rows, resulting in a
/// grid-like point cloud with an approximately uniform point spacing when viewed from the
/// X-Y plane. This is a very fast method of retrieving a downsampled point cloud.
/// - `Lptf3Load::SmoothSample(params)`: Load the points using a downsampling filter, which
/// downsamples the point cloud similar to the `TakeEveryN` method, but also performs a gaussian
/// smoothing step using the full original cloud. This takes the longest time, but can remove
/// a significant amount of noise from the data by making use of an adjacency structure that
/// will be lost once the points are turned into a cloud.
///
/// Once the points are loaded, they will be converted into a triangle mesh by connecting points in
/// adjacent rows with triangles that meet certain edge length criterial. The result is a fast mesh
/// that can be built using knowledge of the LPTF3's internal structure rather than having to rely
/// on more general techniques that can build meshes from arbitrary point clouds.
///
/// # Arguments
///
/// * `file_path`: A path to the LPTF3 file to load.
/// * `load`: An enum specifying how to load the data from the file.
///
/// returns: Result<PolyMeshT<3, NaAdaptor>, Box<dyn Error, Global>>