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

Geometry Store is empty on latest XbimEssentials 6.0.443-develop #549

Open
CCT-Mukund-Thakare opened this issue Mar 6, 2024 · 10 comments
Open

Comments

@CCT-Mukund-Thakare
Copy link

CCT-Mukund-Thakare commented Mar 6, 2024

Hello Team,
I have couple of IFC files for which models GeometryStore is empty.

When I open model in xbim viewer, we are not able to see anything.
image

This is the log from xbim explorer -
image

But whenever I open the IFC model in other viewers I am able to see the objects\geometry.
OCCT's CAD Assistant -
image

BIM Vision -
image

Assemblies and versions affected:

I have test this particular file on latest development release of essentials as well.
Xbim.Essentials 6.0.443-develop.
The issue is there in this latest and all previous versions.

Steps (or code) to reproduce the issue:

using (var model = IfcStore.Open(inputIfcFilePath, editor))
{
    var context = new Xbim3DModelContext(model);
    context.CreateContext(null, false);
    if (model.GeometryStore.IsEmpty)
    {
        throw new Exception(message: "geometry is empty");
    }
}

Minimal file to reproduce the issue:

E-BVT-RWB-Geelen-Beton 10 10e verdieping.zip

Expected behavior:

Geometry should not be empty and we should be able to see the objects like we are able to see in any other viewer.

What actually is happening
since model.GeometryStore.IsEmpty is true it is throwing an exception.

Additional Details

I have setup of latest xbim geometry version 6 as well with netcore branch.
The bug is there with the latest version6 on netcore branch.
I am still debugging the root cause for the same.

@andyward
Copy link
Member

andyward commented Mar 6, 2024

In the Xplorer screenshot I can't tell what versions of xbim you're using. The assemblies tab on About is useful for this.

Do check for warnings in the logs window (what you've show is not the real log). e.g. you might see something like this

image

Also worth running the built in IFC validation on in Xplorer to see if the models have issues.

image

These kinds of messages are generally bad news.

In the code snippet, you're not calling context.CreateContext(null, false); which creates the Geometry.

@andyward
Copy link
Member

andyward commented Mar 6, 2024

Just tested it in the latest v6 and some older versions and can reproduce the issue. Nothing in the logs and it validates fine.

At a guess it's an unusual combination of RepresentationContexts that we're not supporting. i.e. it's probably an issue in the scene which should be fairly easy to debug, starting at https://github.com/xBimTeam/XbimGeometry/blob/58da50c6749fd59f5a895b3a284141a117aa0678/Xbim.ModelGeometry.Scene/Xbim3DModelContext.cs#L685

@CCT-Mukund-Thakare
Copy link
Author

Hello @andyward
Thank you for your suggestion of inbuilt log window and Ifc Validation feature, I will use them going forward.
Also I have update the code snippet in issue with context.CreateContext(null, false);.

As suggested, I am debugging the CreateContext method from Xbim3DModelContext.cs by adding regression test case in Xbim.Geometry.Regression project with following snippet.

var model = IfcStore.Open(fileInfo.FullName);
if (model != null)
{
    var c = new Xbim3DModelContext(model);
    c.CreateContext();
    if (model.GeometryStore.IsEmpty)
    {
        throw new Exception("Model geometry is empty");
    }
}

There are two IIfcRepresentationContext that I can see, while debugging.
image

Are these context not supported ?

Also why isGeometryV6 is false on netcore branch, since it is version 6 it should be true, right ?
image

@CCT-Mukund-Thakare
Copy link
Author

CCT-Mukund-Thakare commented Mar 7, 2024

Hello @andyward
Thank you for your continuous support,
I was successfully able to debug the CreateContext Method.

And yes your guess is right.
It is unusual combination of all RepresentationContexts that model has with each IfcProduct's IfcRepresenationContext.
Basically,
If IfcProducts RepresentationContext does not fall in the _contexts list then the particular IfcProduct's shape label is not added in contextHelper.ProductShapeIds list for further processing.

For example in here,
This single IfcProduct i.e. IfcReinforcementBar is having IfcRepresentationContext as Plan.
image

But _contexts (all context from model) does not include this IfcRepresentationContext ("Plan"). It has only one RepresentationContext that is Model.
image

Now I know the issues, I am thinking on solution to fix this behavior and contribute.
Do you have any thoughts on an Ideal way to fix this behavior ?

Thank you !!

@CCT-Mukund-Thakare
Copy link
Author

CCT-Mukund-Thakare commented Mar 13, 2024

Hello @andyward
I was able to fix this IfcGeometricRepresentationContext and IfcGeometricRepresentationSubContext issue.
I have this nicely prepared workflow diagram as well, which will help other's to figure out the workflow of these two lines of code.

var c = new Xbim3DModelContext(model);
c.CreateContext();

Which might interest you as well.
Workflow_xBIm3DModel_Context.drawio.zip

So on high level, While creating the Xbim3DModelContext we fill the map of IfcGeometricRepresentationContext and IfcGeometricRepresentationSubContext that are present in the file.
Flow start's with IfcGeometricRepresentationSubContext, if there are no IfcGeometricRepresentationSubContext then we try to obtain, IfcGeometricRepresentationContext.
After obtaining IfcGeometricRepresentationContext we then again filter out only Model && Design.
And in here, The IfcGeometricRepresentationContext Plan is not considered.
image

I am interested knowing why Plan is not considered ? are there any limitations ? challenges ? or any other reason ?

As a fix,
I included Plan in the filtered List.
image

So that IfcProduct's with IfcGeometricRepresentationContext as a Plan are being considered for geometry processing.
And hence my model.GeometryStore is not empty anymore.

I have added Pull Request for the same fix - PR Link.
But I really want to know the reason why Plan is not considered along with model and design contexts.
Is it wrong to consider context Plan ? The solution I have implemented is it ideal ? or is it bad ?

@andyward I will really appreciate your or any team members thoughts and knowledge sharing on this topic and question.

Thank you !!

@andyward
Copy link
Member

Always worth checking the standards and any implementor agreements: e.g. See IfcGeometricRepresentationContext

Technically a ContextType of 'plan' is reserved for 2D annotations - which aren't really supported in the xbim Geometry Engine, hence why we don't pick them up in the scene. This 'plan' context would normally have a CoordinateSpaceDimension value of 2 (for 2D) rather than 3 (3D). But it seems in this model all the 3D representations are linked to the 'plan' ContentType, which has 3D, and not the mandatory 'model' context.

This is not my specialist area (@martin1cerny may be able to help). But rather than explicitly add in incorrect context type of 'plan', I might broaden the fallback logic to search for any IfcGeometricRepresentationContext which has 3 dimensions? ANother approach would be to look at the TargetView enum on any attached SubContexts - We're only interested in MODEL_VIEW contexts

@andyward
Copy link
Member

Also why isGeometryV6 is false on netcore branch, since it is version 6 it should be true, right ?

GE6 contains two geometry engine versions. One is backward compatible with v5.1 (v5 version), while the v6 version is a fairly major overhaul of the way we interface with OpenCascade that also provides additional capabilities (such as accurate QTO from BREPs). You can switch between then for backward compatibility etc.

The value of 'isGeometryV6' is set later here when we know the version. Note it defaults to v5 currently.

@andyward
Copy link
Member

I have this nicely prepared workflow diagram as well, which will help other's to figure out the workflow of these two lines of code.

var c = new Xbim3DModelContext(model);
c.CreateContext();

Which might interest you as well.
Workflow_xBIm3DModel_Context.drawio.zip

@CCT-Mukund-Thakare this is great by the way! Thanks for sharing this. There's a lot that goes on behind those 2 lines of code!

@CCT-Mukund-Thakare
Copy link
Author

@andyward
CC @martin1cerny
After reading your comments in here and the one which is on PR.
Thank you for reply, I do now understand couple of things in here.

please confirm on my below understanding,
So the solution that I have added in fallback logic to include 'plan' Context Type is wrong and we should not add 'plan' because ContextType of 'plan' is reserved for 2D, which aren't really supported in the Xbim.Geometry.Engine and Xbim.Geometry.Engine is only interested in 3D context type like 'MODEL_VIEW'.

And,

The model that I have is not valid as per standards because all the 3D geometry representations are linked with the 'plan' context type.

Thank you !!

@andyward
Copy link
Member

Yes, the model is technically invalid - and I think the logs from xbim will report as much. However it should be possible to fall back to a default context that does display something, rather than silently failing to produce a scene. I think that's what this bit of code is supposed to be doing:

https://github.com/xBimTeam/XbimGeometry/blob/58da50c6749fd59f5a895b3a284141a117aa0678/Xbim.ModelGeometry.Scene/Xbim3DModelContext.cs#L637

i.e. After we've tried the 2x3 conventions, we check for ifc2x2 conventions (which I think is what you changed in your PR), before finally saying we'll look at any RepresenatationContext in the model.

With your example model, at the end of the Xbim3DModelContext constructor _contexts should be filled with all the possible IfcGeometricRepresentationContexts (including the "plan" context). So the issue is maybe downstream? i.e. it's possible the ordering of contexts has some bearing on things. Or it's possible another Context is causing issues. But without debugging it, I'm not clear why your first fix (adding "plan") actually solved things!

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