diff --git a/CHANGELOG.md b/CHANGELOG.md index cbe28d5..ce1cf72 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,7 +6,11 @@ and the project follows [Semantic Versioning](https://semver.org/spec/v2.0.0.htm ## [Unreleased] +## [0.1.2] - 2026-11-19 + ### Added +- `SceneGridSystem.Paths` carries curved or multi-segment axes as ordered points with one label per axis. + Paths are optional in format 1. The validation checks that each path has at least two finite points. - Optional preview projects for reading GLB and OBJ, writing GLB, measuring geometry, checking triangle surface intersections, comparing revisions, querying grids and exporting BCF. ### Changed diff --git a/Directory.Build.props b/Directory.Build.props index 95974cf..873db5f 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -14,7 +14,7 @@ - 0.1.1 + 0.1.2 mahach666 Copyright (c) 2026 mahach666 IOScene diff --git a/docs/contract.md b/docs/contract.md index 86c7cf8..dbe5beb 100644 --- a/docs/contract.md +++ b/docs/contract.md @@ -78,7 +78,9 @@ SceneValueKind Text = 0, Boolean = 1, Integer = 2, Number = 3 // open en SceneUnits constants ("m", "m2", "m3", "rad", "kg", "s", "K") and IsValid(unit) SceneLevel int Id; int ModelId; string Name; double? Elevation -SceneGridSystem int ModelId; string Name; List Lines SceneGridLine Name, Start, End, Elevation +SceneGridSystem int ModelId; string Name; List Lines; List? Paths +SceneGridLine Name, Start, End, Elevation +SceneGridPath Name, Points SceneViewpoint string? Id; string Name; SceneCamera Camera SceneCamera Position, Target, Up, FieldOfView (vertical, radians), AspectRatio, NearDistance, FarDistance, SceneProjection Projection (Perspective = 0, Orthographic = 1) // open enum @@ -139,7 +141,7 @@ the right member. Each takes the display string; the library never invents one. | Texture coordinates | `v = 0` is the bottom row of the image. The texture is sampled at `(u / ScaleX, v / ScaleY)` with repeat wrapping. Texture offset and rotation are baked into the UVs; they never become members. | | Coordinate frame, georeference | Not in 0.1.0. `SceneModel.Frame`, `ToShared` and a geo reference are additive members. They are a precondition of any consumer that tests two models against each other. | | Links, federation | The `Models` table plus `ModelId` on elements, levels, grids and schedules. `Models[0]` is the model of the file the producer was given; the others are its links or files federated with it. A merge helper that renumbers ids is added with the first federation consumer. No nested scenes. | -| Grids | `SceneGridLine.Elevation` is the Z, in scene coordinates, of the level the line is drawn on. `Start` and `End` are authoritative for drawing. | +| Grids | `SceneGridLine.Elevation` is the Z, in scene coordinates, of the level the line is drawn on. `Start` and `End` are authoritative for drawing. `SceneGridPath.Points` gives at least two ordered points in metres. Draw between consecutive points and label only the first and last points. Producers keep a straight axis in `Lines` and write each curved or multi-segment axis once in `Paths`. Older readers ignore the optional `Paths` member. | | Viewpoints | In the scene: optional `Id` (a saved-viewpoint GUID or a BCF viewpoint GUID), name, camera. For an orthographic camera the visible height is `2 * |Target - Position| * tan(FieldOfView / 2)`. Clip planes and visibility lists are additive. | | 4D | `SceneSchedule` in the scene. `SceneTask.Progress` is a fraction from 0 to 1. A `PlannedStart` or `PlannedEnd` at its default `0001-01-01T00:00:00+00:00` means "not given": a consumer leaves such a task out of time-based views. | | Clash results | `SceneClashTest`, `SceneClashResult` and `SceneClashStatus` in the scene: results only. Rules, tolerances, the engine and the store of statuses across runs belong to the coordination tool. Further fields of a source (assignee, comments, dates) are additive. `Distance` is in metres: below 0 it is the penetration depth, from 0 up it is the clearance (the Navisworks convention). Null means the source did not report it. | @@ -371,7 +373,8 @@ stable strings. Later versions may add codes. | `index-range` | error | A geometry has an index outside its vertices. | | `normal-count` | error | A geometry has normals, but not one per vertex. | | `uv-count` | error | A geometry has texture coordinates, but not one per vertex. | -| `not-finite` | error | A number of the scene is NaN or infinite: in a geometry, an instance transform, a property value, a material, a texture scale, a level, a grid line, a camera, a task or a clash. | +| `not-finite` | error | A number of the scene is NaN or infinite: in a geometry, an instance transform, a property value, a material, a texture scale, a level, a grid axis, a camera, a task or a clash. | +| `grid-path-points` | error | A grid path has fewer than two points. | | `value-payload` | error | A property value of kind `Number` has no `Number`, of kind `Integer` has no `Integer`, or of kind `Boolean` has an `Integer` other than 0 or 1. | | `task-tree` | error | A schedule lists one task twice, or a task is inside its own sub-tasks. | | `task-depth` | error | A schedule nests tasks deeper than 30 levels. Reported once per schedule. | diff --git a/src/IOScene/SceneDocument.Validate.cs b/src/IOScene/SceneDocument.Validate.cs index 6cdacd9..52085e9 100644 --- a/src/IOScene/SceneDocument.Validate.cs +++ b/src/IOScene/SceneDocument.Validate.cs @@ -136,6 +136,11 @@ HashSet Ids(IEnumerable ids, string what) where T : notnull if (!models.Contains(g.ModelId)) Error("dangling-model", $"Grid system '{g.Name}' names model {g.ModelId}."); if (!g.Lines.All(line => IsFinite(line.Start) && IsFinite(line.End) && double.IsFinite(line.Elevation))) Error("not-finite", $"Grid system '{g.Name}' has a line with a number that is not finite."); + foreach (var path in g.Paths ?? []) + { + if (path.Points.Count < 2) Error("grid-path-points", $"Grid path '{path.Name}' has fewer than two points."); + if (!path.Points.All(IsFinite)) Error("not-finite", $"Grid path '{path.Name}' has a point that is not finite."); + } } foreach (var v in Viewpoints) { diff --git a/src/IOScene/SceneJson.cs b/src/IOScene/SceneJson.cs index 0afba45..7c36da8 100644 --- a/src/IOScene/SceneJson.cs +++ b/src/IOScene/SceneJson.cs @@ -164,6 +164,8 @@ private static void Harden(JsonTypeInfo info) var lists = new List(); foreach (var property in info.Properties) { + if (info.Type == typeof(SceneGridSystem) && property.Name == nameof(SceneGridSystem.Paths)) + property.ShouldSerialize = static (_, value) => value is List { Count: > 0 }; // Kind and Format keep their values, null included: their setters reject a wrong one. A member that a // holder marks required follows the rules below like any other. if (info.Type == typeof(SceneDocument) && property.IsRequired) diff --git a/src/IOScene/SceneLevel.cs b/src/IOScene/SceneLevel.cs index bb09c97..6bb24c2 100644 --- a/src/IOScene/SceneLevel.cs +++ b/src/IOScene/SceneLevel.cs @@ -31,6 +31,19 @@ public sealed class SceneGridSystem /// The grid lines. public List Lines { get; set; } = []; + + /// Curved and multi-segment axes. A path has one label at its two ends. + public List? Paths { get; set; } +} + +/// One grid axis drawn as a connected sequence of straight segments. +public sealed class SceneGridPath +{ + /// Label of the axis. + public string Name { get; set; } = string.Empty; + + /// At least two ordered points in scene coordinates, in metres. + public List Points { get; set; } = []; } /// diff --git a/tests/IOScene.Tests/SceneJsonTests.cs b/tests/IOScene.Tests/SceneJsonTests.cs index 7608c09..b789856 100644 --- a/tests/IOScene.Tests/SceneJsonTests.cs +++ b/tests/IOScene.Tests/SceneJsonTests.cs @@ -8,6 +8,27 @@ public class SceneJsonTests { private const string Head = "{\"Kind\":\"ioscene\",\"Format\":1"; + [Fact] + public void GridPathsRoundTripAsOrderedPoints() + { + var scene = new SceneDocument(); + scene.Models.Add(new SceneModel { Id = 1, Key = "test" }); + var system = new SceneGridSystem { ModelId = 1 }; + scene.Grids.Add(system); + string baseline = SceneJson.Write(scene); + Assert.DoesNotContain("\"Paths\"", baseline); + system.Paths = []; + Assert.Equal(baseline, SceneJson.Write(scene)); + system.Paths.Add(new SceneGridPath { Name = "A", Points = [new(0, 0, 0), new(2, 1, 0), new(3, 3, 0)] }); + var copy = SceneJson.Read(SceneJson.Write(scene)); + var path = Assert.Single(Assert.Single(copy.Grids).Paths!); + Assert.Equal("A", path.Name); + Assert.Equal(system.Paths[0].Points, path.Points); + Assert.DoesNotContain(copy.Validate(), diagnostic => diagnostic.Code is "grid-path-points" or "not-finite"); + path.Points.RemoveRange(1, 2); + Assert.Contains(copy.Validate(), diagnostic => diagnostic.Code == "grid-path-points"); + } + [Theory] [InlineData("{\"Title\":\"old\",\"Elements\":[]}")] // no Kind: a legacy viewer snapshot [InlineData("{\"Kind\":\"ioscene\"}")] // no Format