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

Normal vector for IfcBuildingElements #496

Open TanjaCaala opened 1 year ago

TanjaCaala commented 1 year ago

Hello everyone, I'm currently stuck with an engineering question about the IFC. I would like to get the normal vector pointing outwards of IfcBuildingElements (see image below). The normal vector itself should not be much of a problem with the IfcLocalPlacement, but I'm not sure about making sure it points outwards. Is there something within the IFC schema that I'm missing that might help me? Or a convention? E.g. is the coordinate system in the IfcLocalPlacement always pointing outside?

grafik

If possible, I would like to not use IfcSpaces.

I would really appreciate some ideas! Thank you!

martin1cerny commented 1 year ago

This is not as easy as it may seem to be. It is easy to get a normal of any geometry face. But it is non-trivial to identify the faces which are "significant". It is easier for roof slabs where it needs to point upwards. For walls you may say that it is the face with greatest area. But that will still leave you with two opposite directions. Founding out if it points out from the building is the tricky part. You may use a ray intersection algorithm, but you will need to be clever to handle cases of U-shaped buildings and other cases.

andyward commented 1 year ago

Depending on the use cases it may be possible to infer external faces semantically? E.g. via IfcRelSpaceBoundary and its ConnectionGeometry (IfcConnectionGeometry)

i.e. the absence of a Space on a wall surface could be used to infer it is external (of course there may be external spaces as well, but they should be determined via the InternalOrExternalBoundary attribute)

jomijomi commented 1 year ago

First, I assume this is not about correcting "normals" on meshes that are "inverted" (if so, I do have a solution for that...)??

For "finding outside pointing surfaces" I think ray casting/intersection is your best bet. Here, the Jordan Curve Test can be useful to see if a point is "inside" or "outside", which will help you handle U-shapes, etc.: https://sidvind.com/wiki/Point-in-polygon:_Jordan_Curve_Theorem

Maybe you can combine that with this (A Simple Method for Correcting Facet Orientations in Polygon Meshes Based on Ray Casting) to calculate some sort of heuristics: https://jcgt.org/published/0003/04/02/

/Mikael