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
3 changes: 3 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ jobs:
- name: Pack NuGet Packages
run: dotnet pack IfcIO.slnx -c Release --no-build -o artifacts

- name: Build the scene adapter against the native engine
run: dotnet build src/IfcIO.Scene/IfcIO.Scene.csproj -c Release -p:BuildNativeCoreOnly=true --artifacts-path native-core-check

- name: Upload Artifacts
uses: actions/upload-artifact@v7
with:
Expand Down
12 changes: 12 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,18 @@ Do not put personal data in code, documentation, test data or commit metadata. U

## Scene adapter

The frozen viewer, non-IFC exporters and coordination implementations live in
`src/IfcIO/Compatibility`. The regular build keeps their public namespaces,
signatures and assembly identity. Native IFC validation, including IDS, stays
with the engine. BCF reporting uses the compatibility implementation.

CI also builds the native engine and its scene adapter with the compatibility
sources excluded. This check is non-packable and uses a separate artifact path.

```sh
dotnet build src/IfcIO.Scene/IfcIO.Scene.csproj -c Release -p:BuildNativeCoreOnly=true --artifacts-path ./artifacts/native-core-check
```

`src/IfcIO.Scene` converts IfcIO models into `IOScene` documents and uses only the public API of `IfcIO`; the `IfcIO`
package itself keeps no dependencies. `IOScene` is referenced with the range `[0.1.0, 0.2.0-0.0)`, and restore takes the
lowest version in it, 0.1.0 from NuGet.org. To build against an `IOScene` version that is not on NuGet.org yet, start
Expand Down
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -150,12 +150,13 @@ Reads and writes ISO 10303-21 STEP physical files conforming to **IFC2x3 Coordin

IfcIO reads and writes IFC. The following extras are frozen: they get bug fixes only, no new features or options.

- HTML viewer (`IfcHtmlViewerExporter`, `ifcio view`). Viewing will move to [IOViewer](https://github.com/IOExtend/IOViewer) through the `IfcIO.Scene` adapter over the shared `IOScene` model.
- GLB and OBJ export (`IfcGlbExporter`, `IfcObjExporter`). A shared GLB writer is planned in `IOScene.Formats`.
- Clash detection, measure, grids, diff, and BCF archives (`IfcClashDetector`, `IfcClashGrouper`, `IfcMeasureEngine`, `IfcGridSystem`, `IfcDiffEngine`, `BcfArchive`, `BcfZipExporter`). These will move to a planned `IOCoord` package.
- HTML viewer (`IfcHtmlViewerExporter`, `ifcio view`). [IOViewer](https://github.com/IOExtend/IOViewer) can already open IFC files through the `IfcIO.Scene` adapter.
- GLB and OBJ export (`IfcGlbExporter`, `IfcObjExporter`). A shared GLB writer is available in the `IOScene.Formats` source preview.
- Clash detection, measure, grids, diff, and BCF archives (`IfcClashDetector`, `IfcClashGrouper`, `IfcMeasureEngine`, `IfcGridSystem`, `IfcDiffEngine`, `BcfArchive`, `BcfZipExporter`). The `IOCoord` source preview implements coordination queries and BCF export.
- IFC work-schedule (4D) sequence logic. It stays in IfcIO.

None of these replacements is published yet. The frozen features stay available and are removed no earlier than IfcIO 1.0, and only after a published replacement exists.
The [optional IOScene tools](https://github.com/IOExtend/IOScene/blob/main/docs/tools.md) are available from source.
The frozen features stay available and are removed no earlier than IfcIO 1.0, and only after a published replacement exists.

## Build from source and tests

Expand Down
4 changes: 4 additions & 0 deletions src/IfcIO.Scene/IfcIO.Scene.csproj
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup Condition="'$(BuildNativeCoreOnly)' == 'true'">
<IsPackable>false</IsPackable>
</PropertyGroup>

<PropertyGroup>
<Description>Converts IFC models read by IfcIO into IOScene documents in metres with Z up, keeping GlobalIds, storeys, property sets, quantities and 4D schedules.</Description>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
Expand Down
File renamed without changes.
File renamed without changes.
39 changes: 39 additions & 0 deletions src/IfcIO/Compatibility/IfcIdsValidationReport.Compatibility.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
using IfcIO.Bcf;

namespace IfcIO.Validation.Ids;

public sealed partial class IfcIdsValidationReport
{
/// <summary>
/// Exports all IDS compliance failures directly to a buildingSMART BCF 2.1 zip archive (.bcfzip)
/// for issue tracking and resolution in Revit, Solibri, and BIMcollab.
/// </summary>
public void SaveBcf(string path)
{
ArgumentNullException.ThrowIfNull(path);

var topics = new List<BcfTopic>();
foreach (var failure in Failures)
{
var topic = new BcfTopic
{
Title = $"[IDS Violation] {failure.SpecificationName}: {failure.ElementType} #{failure.ElementId}",
Description = $"{failure.Message} (Element: '{failure.ElementName}', GUID: {failure.ElementGuid ?? "N/A"})",
TopicType = "Compliance",
TopicStatus = "Active",
CreationAuthor = Author ?? "IfcIO IDS Validator",
};

if (!string.IsNullOrEmpty(failure.ElementGuid))
{
var vp = new BcfViewpoint();
vp.SelectedElementGuids.Add(failure.ElementGuid);
topic.Viewpoints.Add(vp);
}

topics.Add(topic);
}

BcfZipExporter.Save(path, topics, Title);
}
}
137 changes: 137 additions & 0 deletions src/IfcIO/Compatibility/IfcModel.Compatibility.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
using IfcIO.Exporters;

namespace IfcIO;

public sealed partial class IfcModel
{
/// <summary>Spatial grid system (axes and levels) associated with the IFC model.</summary>
public Grids.IfcGridSystem? GridSystem { get; set; }

/// <summary>Imports a BCF 2.1 archive (.bcfzip) file from disk.</summary>
public static List<Bcf.BcfTopic> ImportBcf(string path)
{
ArgumentNullException.ThrowIfNull(path);
return Bcf.BcfArchive.Open(path).Topics;
}

/// <summary>Exports a collection of BCF topics to a buildingSMART BCF 2.1 zip archive (.bcfzip).</summary>
public void SaveBcf(string path, IEnumerable<Bcf.BcfTopic> topics)
{
Bcf.BcfZipExporter.Save(path, topics, ProjectName);
}

/// <summary>Exports a collection of BCF topics to a stream in BCF 2.1 format.</summary>
public void SaveBcf(Stream stream, IEnumerable<Bcf.BcfTopic> topics)
{
Bcf.BcfZipExporter.Write(stream, topics, ProjectName);
}

/// <summary>
/// Runs model validation and exports any detected errors or warnings as a BCF 2.1 archive (.bcfzip)
/// with affected element GUIDs linked for cross-discipline issue coordination.
/// </summary>
public void ExportValidationBcf(string path)
{
var result = Validate();
var topics = new List<Bcf.BcfTopic>();

foreach (var err in result.Errors)
{
var topic = new Bcf.BcfTopic(
title: $"Validation Error: {err.RuleId}",
description: err.Message,
topicType: "Error",
priority: "High");

string? targetGuid = err.GlobalId;
if (string.IsNullOrEmpty(targetGuid) && err.ElementId.HasValue)
{
var elem = AllElements.FirstOrDefault(e => e.Id == err.ElementId.Value);
if (elem is not null) targetGuid = elem.GlobalId;
else
{
var sp = AllSpaces.FirstOrDefault(s => s.Id == err.ElementId.Value);
if (sp is not null) targetGuid = sp.GlobalId;
}
}

if (!string.IsNullOrEmpty(targetGuid))
{
var vp = new Bcf.BcfViewpoint();
vp.SelectedElementGuids.Add(targetGuid);
topic.Viewpoints.Add(vp);
}
topics.Add(topic);
}

foreach (var warn in result.Warnings)
{
var topic = new Bcf.BcfTopic(
title: $"Validation Warning: {warn.RuleId}",
description: warn.Message,
topicType: "Warning",
priority: "Normal");

string? targetGuid = warn.GlobalId;
if (string.IsNullOrEmpty(targetGuid) && warn.ElementId.HasValue)
{
var elem = AllElements.FirstOrDefault(e => e.Id == warn.ElementId.Value);
if (elem is not null) targetGuid = elem.GlobalId;
else
{
var sp = AllSpaces.FirstOrDefault(s => s.Id == warn.ElementId.Value);
if (sp is not null) targetGuid = sp.GlobalId;
}
}

if (!string.IsNullOrEmpty(targetGuid))
{
var vp = new Bcf.BcfViewpoint();
vp.SelectedElementGuids.Add(targetGuid);
topic.Viewpoints.Add(vp);
}
topics.Add(topic);
}

SaveBcf(path, topics);
}

/// <summary>Loads BCF topics from a BCF 2.1 zip archive (.bcfzip).</summary>
public static List<Bcf.BcfTopic> LoadBcf(string path) => Bcf.BcfZipExporter.Open(path);

/// <summary>Exports the model to binary glTF 2.0 (.glb) format.</summary>
public void SaveGlb(string path) => IfcGlbExporter.Save(this, path);

/// <summary>Exports the model to binary glTF 2.0 (.glb) stream.</summary>
public void SaveGlb(Stream stream) => IfcGlbExporter.Write(this, stream);

/// <summary>Exports the model to Wavefront OBJ format (.obj + .mtl).</summary>
public void SaveObj(string path) => IfcObjExporter.Save(this, path);

/// <summary>Performs geometric clash detection between this model and another IFC model.</summary>
public Clash.IfcClashReport DetectClashes(IfcModel otherModel, Clash.IfcClashOptions? options = null) =>
Clash.IfcClashDetector.DetectClashes(this, otherModel, options);

/// <summary>Performs geometric self-clash detection within this IFC model.</summary>
public Clash.IfcClashReport DetectClashes(Clash.IfcClashOptions? options = null) =>
Clash.IfcClashDetector.DetectClashes(this, options);

/// <summary>Compares this baseline model against a revision model, detecting added, deleted, and modified elements.</summary>
public Diff.IfcDiffReport Compare(IfcModel revisionModel, Diff.IfcDiffOptions? options = null) =>
Diff.IfcDiffEngine.Compare(this, revisionModel, options);

/// <summary>Exports the model to a standalone, interactive 3D WebGL HTML viewer (.html) with zero dependencies.</summary>
public void SaveHtmlViewer(string path, Exporters.IfcHtmlViewerOptions? options = null) =>
Exporters.IfcHtmlViewerExporter.Save(path, this, options);

/// <summary>Populates grid location tags across elements in this model using the attached or extracted grid system.</summary>
public int AssignGridLocations(Grids.IfcGridSystem? gridSystem = null)
{
var grids = gridSystem ?? GridSystem ?? ExtractGridSystem();
GridSystem = grids;
return grids.AssignGridLocations(this);
}

/// <summary>Automatically extracts grid axes from IFCGRID elements or metadata in this model.</summary>
public Grids.IfcGridSystem ExtractGridSystem() => Grids.IfcGridSystem.ExtractFromModel(this);
}
8 changes: 8 additions & 0 deletions src/IfcIO/IfcIO.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,12 @@
<IsPackable>true</IsPackable>
</PropertyGroup>

<PropertyGroup Condition="'$(BuildNativeCoreOnly)' == 'true'">
<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup Condition="'$(BuildNativeCoreOnly)' == 'true'">
<Compile Remove="Compatibility/**/*.cs" />
</ItemGroup>

</Project>
Loading
Loading