Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IfcNonNegativeLengthMeasure not is castable to IfcLengthMeasure #591

Open
andyward opened this issue Dec 15, 2024 · 3 comments
Open

IfcNonNegativeLengthMeasure not is castable to IfcLengthMeasure #591

andyward opened this issue Dec 15, 2024 · 3 comments
Assignees

Comments

@andyward
Copy link
Member

andyward commented Dec 15, 2024

IfcNonNegativeLengthMeasure is defined as being of type IfcLengthMeasure which is itself an Express REAL type.

We implement IfcMeasures as value types (i.e. structs not classes). As a struct means they cannot derive from a class, only implement interfaces.

The issue this raises is that for 'derived' measures such as IfcNonNegativeLengthMeasure - which are backed by IfcLengthMeasure in the spec, (rather than a native Real/Double) - we cannot treat the NonNegative measure as a IfcLengthMeasure without special treatment, because IfcNonNegativeLengthMeasure is not a subclass of the base type.

A good example of the problem this creates is in Ifc4.3's IfcCurveSegment, where SegmentStart & SegmentLength are backed by IfcCurveMeasureSelect but have an informal proposition that only IfcLengthMeasure's should be used (not IfcParameterValue). However that will often include IfcNonNegativeLengthMeasure but a naïve type check will not be treat them as equivalent. Consequently implementing that rule will incorrectly treat NonNegative measures as invalid.

A secondary issue is that Selects such as IfcCurveMeasureSelect don't then include derived measures. The result of this is we can't parse an IfcCurveSegment using an IfcNonNegativeLengthMeasure

One solution for the first issue would be to implement a IIfcLengthMeasure that IfcLengthMeasure and all derived measures can implement - similar to how we implement Express Selects.

andyward added a commit that referenced this issue Dec 15, 2024
…cLengthMeasure #591

Issue1: IfcNonNegativeLengthMeasure could not be deserialised on IfcCurveSegment.SegmentLength
Issue2: IfcCurveSegment.SegmentLength as IfcLengthMeasure is null
@andyward
Copy link
Member Author

Have addressed the immediate issue but there may be other scenarios. E.g. 'derived' measures or other Selects that reference sub-classes.

@andyward
Copy link
Member Author

A broader issue is we cannot use Measures in a schema agnostic fashion since we don't provide a cross-schema interface for them. E.g. while this is now addressed for IfcLengthMeasures, IIfc4x3.MeasureResource.IfcLabel cannot be used in place of Ifc4.MeasureResource.IfcLabel.

See xBimTeam/XbimGeometry#521 and https://github.com/xBimTeam/XbimGeometry/blob/2707aeef3ce710314bc4860ea25324761e616e80/Xbim.Geometry.Engine/Factories/SurfaceFactory.cpp#L175

@martin1cerny
Copy link
Member

IfcLabels will convert between the schemas correctly. But I agree, we need to enhance the code generation process to handle Express TYPE inheritance. Best solution will be to introduce new select types which will cover this and will work across schemas.

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

No branches or pull requests

2 participants