Skip to content

feat: add IfcIO.Scene adapter from IFC models to IOScene documents - #36

Merged
mahach666 merged 10 commits into
mainfrom
feat/ifcio-scene
Nov 12, 2026
Merged

mahach666 merged 10 commits into
mainfrom
feat/ifcio-scene

Conversation

@mahach666

@mahach666 mahach666 commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

What changes and why

  • New IfcIO.Scene project and package. IfcSceneReader.Read(path | IfcModel, IfcSceneOptions) converts an IFC model into an IOScene SceneDocument in metres with Z up, so viewers and coordination tools read IFC through the shared scene contract. It is ported from the IOViewer IFC adapter and uses only the public IfcIO API; the IfcIO package gains no dependency.
  • Mapping: one SceneModel per file (Key = ModelKey, else the file name); SourceId and IfcGuid = GlobalId; storeys become levels and tree nodes; property and quantity sets are keyed ifc:<Set> / ifc:<Set>.<Name>; surface style colours become materials; work schedules become scene schedules. Elements without geometry and invalid meshes are reported as diagnostics. An empty ModelKey throws ArgumentException in both overloads.
  • Dimensioned quantities are written as text: a scene Number with a null Unit means dimensionless, and the adapter converts no quantity to SI, so length, area, volume and weight quantities are Kind = Text in file units. Counts stay numbers with a null unit; property values are text.
  • Golden identity test: placement.identity.txt freezes the model key, SourceId, IfcGuid, the ifc: key format and the value form (Text, Kind, Unit) of each key. Changing any of them is a breaking release (CONTRIBUTING, scene adapter page).
  • Exact engine pin: IfcIO.Scene ships on the IfcIO tag and depends on exactly the same IfcIO version ([X.Y.Z], PinProjectReferencesExactly target). IOScene is referenced as [0.1.0-preview.2, 0.2.0-0), with NU5104 suppressed for that range.
  • tools/pack-release.ps1 reads the packed IfcIO.Scene nuspec and fails the release when (a) the IfcIO dependency is not exactly [version], which guards the target hooked into a private NuGet target, or (b) the IOScene lower bound is a prerelease, which replaces the NU5104 protection.
  • release.yml: release notes are extracted before anything is published, the NuGet push runs before the GitHub release so a refused first publication of a new package id can be fixed and the job rerun, and a tag with a hyphen creates a prerelease.
  • Docs: new docs/scene-adapter.md (usage, mapping, value rule, coordinates, limits); docfx metadata and the docs workflow cover src/IfcIO.Scene; README, CHANGELOG [Unreleased] and CONTRIBUTING updated.
  • IfcModel.ParseSweptSolid documents all its parameters (CS1573).

Tests

Restored with IOScene 0.1.0-preview.2 from a local package folder; the version published on nuget.org has the same public API and method bodies.

  • New tests/IfcIO.Scene.Tests (net8.0, net10.0): golden identity on placement.ifc (now with valid GlobalIds, a property set and a quantity set), world placement and unit scaling, storeys, skipped type objects, properties/quantities/GlobalIds of a saved model, shared property sets, hostile strings through SceneJson, material alpha, spaces, duplicate ids, invalid meshes, work schedules, the IFC4 IfcTriangulatedFaceSet limit, missing and empty ModelKey. Every converted fixture must pass Validate() with no entries.
  • Read_ConfiguredIfcFile_ConvertsEveryElement runs only when IFCIO_SCENE_IFC_FILE names an IFC file; it allows Validate() warnings (a real file may carry a malformed GlobalId) and fails on any error.
  • dotnet test IfcIO.slnx -c Release: IfcIO.Tests 149/149; IfcIO.Scene.Tests 19 passed, 1 skipped (the configured-file test) on each of net8.0 and net10.0.
  • dotnet build IfcIO.slnx -c Release: 0 warnings, 0 errors.
  • Real IFC files (not committed, up to about 10,000 elements) converted to scenes and opened in IOViewer: Validate() reported nothing.
  • tools/pack-release.ps1 under Windows PowerShell 5.1: it built all artifacts and packages, assertion (a) passed, and it stopped at assertion (b) as intended while IOScene is a preview. The assertion was also run on edited copies of the nuspec: a bare IfcIO version fails, a stable IOScene lower bound passes. Not run under pwsh, which the release workflow uses.
  • docfx build: not run.

Notes

  • Depends on IOScene on NuGet.org: IOScene 0.1.0-preview.2 is published there, and CI and the docs build restore it and pass (re-run after its publication).
  • Merge order: IOScene 0.1.0-preview.2 is on NuGet.org and CI is green, so nothing else has to come first. Builds on fix: place IFC geometry in world coordinates and export GLB in metres, +Y up #35 (merged), which places IFC geometry in world coordinates.
  • Release order, same as RvtIO: after this merge every IfcIO release fails at the IOScene lower-bound assertion in pack-release.ps1, including one that would ship only the [Unreleased] fixes, until IOScene 0.1.0 is published and the range in Directory.Packages.props moves to [0.1.0, 0.2.0-0) (CONTRIBUTING and the scene adapter page quote the range too).
  • The first IfcIO.Scene push is a new package id; the NuGet trusted publishing policy pattern IfcIO* covers it.
  • Not fixed here: IfcIO's reader returns no mesh for IfcTriangulatedFaceSet (pinned by a test), and type property sets are not read yet. Both are listed under Limits on the scene adapter page.

IfcSceneReader reads an IFC file or an IfcModel into a SceneDocument in
metres with Z up, ported from the IOViewer.IfcIO adapter. The model key is
the ModelKey option or the file name; SourceId and IfcGuid are the
GlobalId. Storeys become levels and tree nodes, property and quantity
sets get ifc: keys, quantities are numbers and property values text, and
work schedules become scene schedules. Elements without geometry are
reported as diagnostics.

The project references IOScene with the range [0.1.0-preview.1, 0.2.0-0)
and is not packed until IOScene 0.1.0 is released. Tests include a golden
identity test on a fixture taken from the placement tests.
A scene adapter page gives usage, the mapping and the limits, including
that IfcIO reads no geometry from IfcTriangulatedFaceSet. docfx metadata
and the docs workflow paths cover src/IfcIO.Scene; README, CHANGELOG and
CONTRIBUTING mention the adapter and how to restore an IOScene preview.
The NuGet login and push now run above "Create or update release", so a
refused first publication of a package id can be fixed and the job run
again. The release notes are extracted before anything is published, and
a tag with a hyphen creates a prerelease.
The GlobalIds of placement.ifc started with 4 to D, which is not a valid IFC GlobalId, so the golden identity froze invalid values and Validate() reported ifc-guid warnings. Every converted fixture now has to pass Validate() with no entries; only the test on a configured external file still allows warnings.
Read(path) kept an empty ModelKey as the model key and produced a scene that Validate() rejects, while Read(model) already threw for it. Both overloads now throw ArgumentException; null still falls back to the file name.
A number with a null Unit means dimensionless, and the adapter converts no quantity to SI, so length, area, volume
and weight quantities are now Kind Text with the same text as before; a count stays a number with a null unit.
The scene adapter docs describe the value rule, the order of occurrence and type property sets, and world
coordinates that consumers rebase. The test on a configured IFC file now requires an empty Validate().
A real file may carry a malformed GlobalId, which the adapter copies as it is and Validate() reports as an ifc-guid warning; the test still fails on any error.
placement.ifc gains a property set and a quantity set (a length and a count), and placement.identity.txt records every set key and the key, Kind, Unit and Text of each value. CONTRIBUTING and the scene adapter docs now list IfcGuid, the key format and the value form as frozen by that test.
@mahach666
mahach666 merged commit 7fef259 into main Nov 12, 2026
6 of 8 checks passed
@mahach666
mahach666 deleted the feat/ifcio-scene branch November 12, 2026 21:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant