Repository navigation
feat: add IfcIO.Scene adapter from IFC models to IOScene documents - #36
Merged
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changes and why
IfcIO.Sceneproject and package.IfcSceneReader.Read(path | IfcModel, IfcSceneOptions)converts an IFC model into anIOSceneSceneDocumentin 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 publicIfcIOAPI; theIfcIOpackage gains no dependency.SceneModelper file (Key=ModelKey, else the file name);SourceIdandIfcGuid= GlobalId; storeys become levels and tree nodes; property and quantity sets are keyedifc:<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 emptyModelKeythrowsArgumentExceptionin both overloads.Numberwith a nullUnitmeans dimensionless, and the adapter converts no quantity to SI, so length, area, volume and weight quantities areKind = Textin file units. Counts stay numbers with a null unit; property values are text.placement.identity.txtfreezes the model key,SourceId,IfcGuid, theifc:key format and the value form (Text,Kind,Unit) of each key. Changing any of them is a breaking release (CONTRIBUTING, scene adapter page).IfcIO.Sceneships on theIfcIOtag and depends on exactly the sameIfcIOversion ([X.Y.Z],PinProjectReferencesExactlytarget).IOSceneis referenced as[0.1.0-preview.2, 0.2.0-0), with NU5104 suppressed for that range.tools/pack-release.ps1reads the packedIfcIO.Scenenuspec and fails the release when (a) theIfcIOdependency is not exactly[version], which guards the target hooked into a private NuGet target, or (b) theIOScenelower 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/scene-adapter.md(usage, mapping, value rule, coordinates, limits); docfx metadata and the docs workflow coversrc/IfcIO.Scene; README, CHANGELOG[Unreleased]and CONTRIBUTING updated.IfcModel.ParseSweptSoliddocuments 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.
tests/IfcIO.Scene.Tests(net8.0, net10.0): golden identity onplacement.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 throughSceneJson, material alpha, spaces, duplicate ids, invalid meshes, work schedules, the IFC4IfcTriangulatedFaceSetlimit, missing and emptyModelKey. Every converted fixture must passValidate()with no entries.Read_ConfiguredIfcFile_ConvertsEveryElementruns only whenIFCIO_SCENE_IFC_FILEnames an IFC file; it allowsValidate()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.Validate()reported nothing.tools/pack-release.ps1under 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.Notes
IOScene0.1.0-preview.2 is published there, and CI and the docs build restore it and pass (re-run after its publication).IOScene0.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.IfcIOrelease fails at theIOScenelower-bound assertion inpack-release.ps1, including one that would ship only the[Unreleased]fixes, untilIOScene0.1.0 is published and the range inDirectory.Packages.propsmoves to[0.1.0, 0.2.0-0)(CONTRIBUTING and the scene adapter page quote the range too).IfcIO.Scenepush is a new package id; the NuGet trusted publishing policy patternIfcIO*covers it.IfcTriangulatedFaceSet(pinned by a test), and type property sets are not read yet. Both are listed under Limits on the scene adapter page.