xBimTeam / XbimEssentials

A .NET library to work with data in the IFC format. This is the core component of the Xbim Toolkit
https://xbimteam.github.io/
Other
485 stars 172 forks source link

IFC validation error due boolean operations inside 'SolidModel' IfcShapeRepresentation #517

Open MichaelBuehler opened 1 year ago

MichaelBuehler commented 1 year ago

I get an validation error by xBIM on IfcShapeRepresentation with RepresentationIdentifier='SolidModel' containing boolean operations.

Assemblies and versions affected:

Xbim.Essentials 5.1.341 (and earlier)

Steps (or code) to reproduce the issue:

var solidRepresentation = model.Instances.New(); solidRepresentation.ContextOfItems = ..
solidRepresentation.RepresentationType = "SolidModel" solidRepresentation.RepresentationIdentifier = "Body"; ..
solidRepresentation.Items.Add(ifcExtrudedAreaSolid); //OK solidRepresentation.Items.Add(ifcBooleanClippingResult); //Validation error ..
var res = solidRepresentation.Validate(); //res.Count() > 0

Minimal file to reproduce the issue:

TestModel.zip

Expected behavior:

No validation error related to IfcShapeRepresentation.CorrectItemsForType due boolean operations inside solid model

Actual behavior or exception details:

Validation error

Additional Details

The IFC Standard allows by Representation Identifier 'SolidModel':

But on "SolidModel", the xBIM validation counts only objects with IIfcSolidModel interface Functions.cs method ifcShapeRepresentationTypes Line 446 case "SolidModel": Count = Items.Count(x => x is IIfcSolidModel) break;

This excludes IfcBooleanClippingResult since this class has no IIfcSolidModel interface. One way to fix would be that the validation counts the missing items, but in long term maybe it is more secure to adjust/add new interface. Items.Count(x => x is IIfcSolidModel) + Items.Count(x => x is IIfcBooleanClippingResult);

Maybe counting is missing other items, like CSG.

Issue appears in IFC 2.3 and 4.x