Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Added

- Read checksum-verified E57 image blobs and scanner-aligned FARO RGB panoramas.
- Expose retained source point attributes and decoder concurrency through scene adapter options.

### Changed

- Leica LGSX version 22 decodes differential Morton positions, native RGB and intensity, retaining duplicate returns.
- FARO FLS distance mode 26 decodes both range-grid halves with optional Morton RGB and intensity.

## [0.1.1] - 2026-11-25

### Added
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,11 @@ The library targets .NET 8 and .NET 10. It is managed code with no dependencies

| Format | Extensions | Support level |
| --- | --- | --- |
| ASTM E57 | `.e57` | Points decoded for a defined subset: uncompressed bit-packed streams with single or double precision Cartesian coordinates or scaled-integer coordinates (raw value times scale plus offset), or spherical range, azimuth and elevation converted to Cartesian points, with 8-bit colour and 8-bit intensity, or colour with a wider Integer range from zero and intensity as a wider Integer, a Float or a scaled integer. Pose translation and rotation are applied. Only plain bit-packing is decoded: a scan whose codecs vector names another codec lists normally and fails when its points are read, and the message names it. Per-point validity flags skip invalid points and clear invalid channels when their streams hold one flag byte per record; other shapes are not interpreted. Images are not read, so a scan with them still lists and reads its points. Page checksums are verified. |
| ASTM E57 | `.e57` | Points decoded for a defined subset: uncompressed bit-packed streams with single or double precision Cartesian coordinates or scaled-integer coordinates (raw value times scale plus offset), or spherical range, azimuth and elevation converted to Cartesian points, with 8-bit colour and 8-bit intensity, or colour with a wider Integer range from zero and intensity as a wider Integer, a Float or a scaled integer. Pose translation and rotation are applied. Only plain bit-packing is decoded: a scan whose codecs vector names another codec lists normally and fails when its points are read, and the message names it. Per-point validity flags skip invalid points and clear invalid channels when their streams hold one flag byte per record; other shapes are not interpreted. Registered image blobs can be read explicitly through the format API. Page checksums are verified. |
| ReCap scan | `.rcs` | Experimental. The header is read; point decoding covers the node layouts that are described in the code, which is the one of major version 3. A file of another version is listed with its header, but reading its points fails with a message that names the version. A further layout is described only when the files of that version may be used for the tests, so that its offsets can be verified. The channels of the points follow from the size of the payload of the nodes: colour and intensity when the records are long enough, and normals when the node holds the plane of them. A node payload whose byte count is not a whole multiple of a known record size, as in BLK360 exports (container 3.2) whose records are variable-length, is rejected with a message that names the container version instead of being guessed. |
| ReCap project | `.rcp` | Lists the scans of the project manifest and opens the `.rcs` files it finds next to the project. The transform of a scan node places the scan in the project and is applied to its points unless `ApplyTransform` is false; when the manifest states no transform, the transform of the scan file is used. |
| Leica scan container | `.lgsx`, `.lgs` | Experimental. Points are decoded from the compressed point blocks: position, and colour, intensity and normals when the block has them. When the container assigns its points to its setups, there is one scan per setup, named after the setup, with the pose and the bounds of the setup when its record holds them; the pose is applied unless `ApplyTransform` is false. When the container does not assign its points, all points of the container form one scan and a warning says so. The point count is taken from the container when it states one; otherwise it is found by decoding the data, which is slow on large files. `PclReadOptions.Blocks` reads only the blocks of the scan in that file-order range (per scan, so a setup scan ranges over its own blocks); `PclReadOptions.MaxDegreeOfParallelism` above 1 decodes those blocks in parallel and still yields the points in file order with consecutive `Index` values. |
| FARO scan | `.fls`, or a FARO scan folder | Experimental. The scan grid and angles are read from the stored parameters and points are projected from the range grid; a file without them fails to open. The point count is the number of valid returns, which is counted on the first access; `FaroScan.GridSize` is the size of the scan grid. For a scan folder the layout of the samples is derived from the size of the data stream and the size of the grid, and the scale of the intensity from the values that are stored; when the sizes do not fit, the layout is assumed and a warning says so. |
| Leica scan container | `.lgsx`, `.lgs` | Experimental. Version 22 point blocks decode differential Morton coordinates, RGB and intensity. Normals are unavailable for that block version. When the container assigns its points to its setups, there is one scan per setup, named after the setup, with the pose and the bounds of the setup when its record holds them; the pose is applied unless `ApplyTransform` is false. When the container does not assign its points, all points of the container form one scan and a warning says so. The point count is taken from the container when it states one; otherwise it is found by decoding the data, which is slow on large files. `PclReadOptions.Blocks` reads only the blocks of the scan in that file-order range (per scan, so a setup scan ranges over its own blocks); `PclReadOptions.MaxDegreeOfParallelism` above 1 decodes those blocks in parallel and still yields the points in file order with consecutive `Index` values. |
| FARO scan | `.fls`, or a FARO scan folder | Experimental. Single-file containers with distance mode 26 decode both halves of the range grid and their optional RGB and intensity planes. The scan grid and angles are read from the stored parameters and points are projected from the range grid; a file without them fails to open. The point count is the number of valid returns, which is counted on the first access; `FaroScan.GridSize` is the size of the scan grid. For a scan folder the layout of the samples is derived from the size of the data stream and the size of the grid, and the scale of the intensity from the values that are stored; when the sizes do not fit, the layout is assumed and a warning says so. |
| PinPoint project | `.srf`, `.smf`, or a folder with `ScanProject.json` or `.smf`/`.srf` files | Experimental. The manifest (scan names, ids, poses, counts) is read. Points come from the referenced `.bin` files, in either of two layouts: a table of named channels, or numbered sections with a property table and Snappy-compressed channels, which PclIO decodes itself. Colour, intensity and normals are reported only when the file has that channel; in the second layout positions, colours, intensities, normals (`Normals`, three float32 components per point) and the per-point flags (`FilterBits`, one byte per point) are read, while the grid indices stored beside them are not interpreted, so by default every stored point that passes the plausibility rule below is returned. With `PclReadOptions.ExcludeFilteredPoints` the points with a non-zero flag are not returned. A manifest with a scan position list takes the point count from the manifest, else from the data file; a manifest with a data object list takes it from the data file the object refers to, and every location that shares one file reports its full count, because the shares are not recorded. A project shell whose data files are absent lists no scans, and a manifest whose referenced data files are missing reads no points; neither is a readable fixture. |
| EdgeWise | `.c3db`, `.c3ptx` | Experimental. A `.c3db` point database lists the scan clusters and a `.c3ptx` is one cluster file; the cluster files give positions only, as three 16-bit offsets from the cluster centre per point. The scale of the offsets is not stored in the files, so the reader assumes 32768 units = 0.128 m unless the caller states it with `PclReadOptions.EdgeWiseCoordinateScale`. |
| LAS | `.las` | Points decoded from versions 1.0 to 1.4 with point formats 0 to 10: XYZ with scale and offset, intensity, classification and RGB for the colour formats (2, 3, 5, 7, 8, 10). GPS time, return numbers, scan angles, point source ids, near infrared and waveform packet descriptors are not interpreted; extra bytes past a format's base size are skipped. The extended point counts of 1.4 are used when stated. Coordinate system records name an `EPSG:` code from a GeoTIFF key directory when it holds one, else the OGC WKT when one is stored. |
Expand Down Expand Up @@ -119,7 +119,7 @@ These readers drop data without an error or a warning, so a scan can yield fewer
data file in neither layout, or in the sectioned layout with an element type or header value the reader does not support, cannot
be read: the project lists it with a warning and reading its points throws `NotSupportedException`. A compressed stream whose
copies reach back more than 8 MiB is not decoded: reading its points throws `NotSupportedException`, without an earlier warning.
- Leica: padding entries and points that coincide with a block's origin are dropped, a compressed stream above its size limit is
- Leica: the legacy block layout drops padding and points that coincide with a block's origin, a compressed stream above its size limit is
skipped, and a block that is not recognised ends the scan. The reader counts what it dropped or skipped and reports it in the
warnings of the document, so that an incomplete result is visible. With `PclReadOptions.Strict` the read fails instead.
- EdgeWise: a database node whose point count is 0 is skipped.
Expand Down
6 changes: 3 additions & 3 deletions docs/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,11 @@ reading), `NotSupportedException` (unrecognised format or unsupported feature) o

| Format | Extensions | Support level |
| --- | --- | --- |
| ASTM E57 | `.e57` | Points decoded for a defined subset (uncompressed bit-packed streams, single or double precision Cartesian coordinates, 8-bit colour and intensity). Per-point validity flags and images are not read. |
| ASTM E57 | `.e57` | Points decoded for a defined subset (uncompressed bit-packed streams, single or double precision Cartesian coordinates, 8-bit colour and intensity). The format API also reads image blobs with checksum verification. |
| ReCap scan | `.rcs` | Experimental; layout of major version 3 only. |
| ReCap project | `.rcp` | Lists scans; opens the `.rcs` files it finds next to the project. Node transforms are not applied. |
| Leica scan container | `.lgsx`, `.lgs` | Experimental; poses and bounds are not read, and all points of a container form one scan. |
| FARO scan | `.fls`, or a FARO scan folder | Experimental; the scan grid comes from the stored parameters. A folder scan is read with an assumed layout, and a warning says so. |
| Leica scan container | `.lgsx`, `.lgs` | Experimental. Version 22 blocks provide geometry, RGB and intensity. Containers without setup assignments open as one scan in container coordinates. |
| FARO scan | `.fls`, or a FARO scan folder | Experimental. Single-file distance mode 26 reconstructs both halves of the scan grid. A folder scan is read with an assumed layout and carries a warning. |
| PinPoint project | `.srf`, `.smf`, or a folder with `ScanProject.json` or `.smf`/`.srf` files | Experimental; manifest plus point data files in one of two layouts (named channels, or sections with Snappy-compressed channels); a data file in neither layout is not read. |
| EdgeWise | `.c3db`, `.c3ptx` | Experimental; positions only, with a coordinate scale that is an assumption of the reader. |
| LAS | `.las` | Versions 1.0 to 1.4 with point formats 0 to 10; positions, intensity, classification and RGB for the colour formats. |
Expand Down
9 changes: 9 additions & 0 deletions docs/public-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,15 @@ no colour.

## Format documents

For sampling plans, `LgsxDocument.GetEncodedPointCount` reads the declared counts in version 22 point block headers without
decompressing the point data. It returns null when the file uses another block layout or has no point blocks.
`PclSceneOptions.PointObserver` receives retained points in scene geometry order, including their source attributes.
`PclSceneOptions.MaxDegreeOfParallelism` passes the requested concurrency to formats that support block decoding.

The E57 reader exposes checksum-verified image blobs through `E57Document.ReadImageBlob`.
`FaroFlsDocument.ReadColorPanorama` returns the scanner-aligned mode 26 RGB raster in an equirectangular projection.
The image is RGB24 in row-major order and has a height of half the requested width. Pixels outside the recorded angles are black.

`E57Document`/`E57Scan`, `RcsScanDocument`/`RcsScan`, `RcpProjectDocument`/`RcpScan`, `LgsxDocument`/`LgsxScan`/`LgsxEntry`/`LgsxSetup`,
`FaroFlsDocument`/`FaroScan`, `PinPointDocument`/`PinPointScan`, `EdgeWiseDocument`/`EdgeWiseScan`, `LasDocument`/`LasScan`, `LazDocument`/`LazScan`, `CopcDocument`/`CopcScan`, `PcdDocument`/`PcdScan`, `PlyDocument`/`PlyScan`, `PtsDocument`/`PtsScan`, `PtxDocument`/`PtxScan`, `XyzDocument`/`XyzScan`, `SbfDocument`/`SbfScan`, `Tiles3dDocument`/`PntsScan`/`GlbScan`, `PotreeDocument`/`PotreeScan`, `EptDocument`/`EptScan`, `PtgDocument`/`PtgScan` and `CcBinDocument`/`CcBinScan` are the readers behind
`PclFile.Open`. Each has a static `Open` method and format-specific properties (for example the E57 version or the FARO scanner model).
Expand Down
16 changes: 16 additions & 0 deletions src/PclIO.Scene/PclSceneOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,22 @@ public int SubsampleStep
}
}

/// <summary>Receives each retained point in scene order with the id of its geometry, before the scene discards point attributes.</summary>
public Action<int, PclPoint>? PointObserver { get; init; }

private readonly int _maxDegreeOfParallelism = 1;

/// <summary>Maximum degree of parallelism for the source point reader. Formats that do not support it read sequentially.</summary>
public int MaxDegreeOfParallelism
{
get => _maxDegreeOfParallelism;
init
{
ArgumentOutOfRangeException.ThrowIfLessThan(value, 1, nameof(value));
_maxDegreeOfParallelism = value;
}
}

private readonly double _metresPerUnit = 1.0;

/// <summary>
Expand Down
5 changes: 4 additions & 1 deletion src/PclIO.Scene/PclSceneReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -141,17 +141,20 @@ private static PclSceneResult Convert(PclDocument document, string key, string?
{
MaxPoints = remaining,
SubsampleStep = options.SubsampleStep,
MaxDegreeOfParallelism = options.MaxDegreeOfParallelism,
ApplyTransform = true,
};

var vertices = new List<Vector3d>();
var normals = new List<Vector3d>();
bool hasColors = false, hasIntensities = false, hasClassifications = false;
bool anyNormal = false, allNormals = true;
int geometryId = scene.Geometries.Count + 1;

foreach (PclPoint point in scan.ReadPoints(readOptions))
{
vertices.Add(new Vector3d(point.X * scale, point.Y * scale, point.Z * scale));
options.PointObserver?.Invoke(geometryId, point);
if (point.Color.HasValue) hasColors = true;
if (point.Intensity.HasValue) hasIntensities = true;
if (point.Classification.HasValue) hasClassifications = true;
Expand Down Expand Up @@ -181,7 +184,7 @@ private static PclSceneResult Convert(PclDocument document, string key, string?
scansWithPoints++;
var geometry = new SceneGeometry
{
Id = scene.Geometries.Count + 1,
Id = geometryId,
Topology = SceneTopology.Points,
Vertices = vertices,
};
Expand Down
18 changes: 16 additions & 2 deletions src/PclIO/Formats/E57/E57Document.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ namespace PclIO.Formats.E57;
/// Cartesian X/Y/Z are single or double precision floats or scaled integers (raw value times scale plus offset),
/// or spherical range, azimuth and elevation converted to Cartesian points. Colour and intensity are Integer fields
/// with a range from zero (8, 16 or 32 bits), Float fields, or scaled-integer intensity; per-point validity flags
/// skip invalid points and clear invalid channels. Images are not read.
/// skip invalid points and clear invalid channels. Image blobs are available through <see cref="ReadImageBlob"/>.
/// Not supported (reported with <see cref="NotSupportedException"/> when points are read): integer coordinates,
/// other codecs (the scan must use plain bit-packing: an empty codecs vector), and packets whose streams hold
/// different record counts.
/// Per-point validity flags of another shape, images and 2D data are not interpreted.
/// Per-point validity flags of another shape and other 2D data are not interpreted.
/// </summary>
public sealed class E57Document : PclDocument
{
Expand Down Expand Up @@ -154,6 +154,20 @@ public static E57Document Open(string path, PclReadOptions? options = null)
return document;
}

/// <summary>Reads a paged image blob referenced by the E57 XML and validates its section header.</summary>
/// <param name="fileOffset">Physical byte offset of the blob section from the XML.</param>
/// <param name="length">Number of image bytes declared by the XML.</param>
public byte[] ReadImageBlob(ulong fileOffset, int length)
{
if (length is < 4 or > 16 * 1024 * 1024)
throw FormatError.Corrupted("E57 image blob size is outside the supported range.");
using var reader = new E57StreamReader(FilePath, PageSize);
byte[] bytes = reader.ReadLogicalBytes(fileOffset, (ulong)(16 + length));
if (bytes[0] != 0 || Bytes.ReadUInt64LE(bytes.AsSpan(8, 8)) != (ulong)((16 + length + 3) & ~3))
throw FormatError.Corrupted("E57 image blob section header does not match its XML length.");
return bytes.AsSpan(16).ToArray();
}

// DTDs are refused (no entity expansion, no external resolution) and the tree is bounded before it is built.
private static XDocument ParseXml(string xmlText)
{
Expand Down
Loading
Loading