tumcms / Open-Infra-Platform

This is the official repository of the open-source Open Infra Platform software (as of April 2020).
Other
47 stars 21 forks source link

Trimming of IfcFaceSurface and IfcAdvancedFace #532

Open christophKaiser opened 2 years ago

christophKaiser commented 2 years ago

With pull request #462, the entities IfcFaceSurface and IfcAdvancedFace are supported - at least two special cases which are used in the official ifc example files. These two cases are an IfcPlane as surface geometry, and an IfcBSplineSurfaceWithKnots as surface geometry where the entire B-Spline surface must be used.

For a general support of all cases, the surface geometry has to be trimmed with a closed polyline, which is provided by an IfcFaceBound entity. A corresponding ToDo is left in the function OpenInfraPlatform::Core::IfcGeometryConverter::FaceConverterT::computeIfcFaceSurface(...)

Tthis problem is described in more detail in the next comment. Furthermore, a rough idea of a possible algorithm will be presented there.

christophKaiser commented 2 years ago

Trimming of IfcFaceSurface, respectively IfcAdvancedFace

About IfcFaceSurface and IfcAdvancedFace

According to buildingSmart [1], the IfcFaceSurface is an entity which connects the topology of a face with its geometry. The topology is defined in an IfcFaceBound entity as a bounding loop, which appears like a closed polyline, respectively a polygon but hasn't to lie in a plane. However, the geometry of the bounding loop "shall be consistent with [the] face geometry. This implies that any edge - curves or vertex points used in defining the loops bounding the face surface shall lie on the face geometry." [1]

The geometry of the IfcFaceSurface "is defined by an associated surface. The portion of the surface used by the face shall be embeddable in the plane as an open disk, possibly with holes. However, the union of the face with the edges and vertices of its bounding loops need not be embeddable in the plane. It may, for example, cover an entire sphere or torus." "The topology is used to trim the geometry of the surface." [1] The surface itself is defined as an IfcSurface entity.

Following, a few examples to this explanation:

211120_Grafik

In each of the four examples, there is the original surface (gray) at the left, and the trimmed surface at the right. The boundary loop (red polyline) and its orientation (orange arrow) are displayed in the original surfaces. Example (a) shows a plane which should has an infinite extend. Example (b) shows a B-Spline-Surface with a finite extend, the geometry has a ring which is above the edge and a down peak below the edge. Example (c) is a cylinder with infinite length; the boundary loop goes in one circle around the cylinder, makes a straight connection along the side surface, goes in another circle around, and finally connects via the straight line to the first circle - similar to figure 438 in the documentation of the IfcAdvancedFace [2]. Example (d) is a sphere. All examples are drawn in AutoCAD.

The IfcAdvancedFace is a specialization of the IfcFaceSurface, thus it inherits all from above. Additionally, it has further restrictions on which topological and geometrical items are allowed.

Trimming with Constructive Solid Geometry (CSG)

The current attempt of trimming the surface by the boundary loop was to use a variation of the intersection operation from CSG. The library Carve - which is already included in Open Infra Platform (OIP) - supports CSG operations on open surfaces. This is shown in the screenshot of the archived website [3]:

Carve_open_surfaces

To use this feature, the trimming object has to be a solid geometry, like the cube in the screenshot. However as shown in the description and the examples above, in the current problem the trimming object is just a closed polyline. The first idea would be the extrusion of the boundary loop along the normal vector of its interior area. This would work in case of the plane surface, like in example a. On the other side, this would not work for example d, because some surface mesh would be outside the vertical cylinder. Additionally, the determination of the normal vector is quite difficult in example c.

Gap due to Discretisation

In case of curved surfaces, a discretisation into planar faces, respectively triangles, is necessary to get a visualizable mesh for the GPU. Considering a two-dimensional sectional view through the 3D-mesh, the ideal curved surface would be some kind of smooth curve like an arc, and the discretised surface would be a polyline with straight lines where the points lie on the curve. Thus, segments occur between the ideal curve and the straight discretisation lines. Furthermore, it's expected that the points of the boundary loop will lie precise on the ideal curve; as well, segments between the straight polylines and the ideal curve will occur. In general case, there is no guarantee that the surface points and loop points are coincident, hence somewhere in the segments a distance (or gap) will be between the discretised surface geometry and the loop points. This distance can be an issue in the use of CSG.

Alternative Algorithm

Until now, a web search hasn't led to a solution which fits the described problem. Beside CSG, search keywords like "clip surface", "cut mesh by polyline", or "slice polygon" bring up quit good results. However, most of them cut with a plane in 3D, or with some kind of projection into a 2D plane, which do not fit for this problem in general case.

Following, a few rough thoughts about how an alternative algorithm could look like:

Note: (1) A further web search is necessary to find a fitting approach. Maybe, the minimum orthogonal distance (based on the face normal vector) from considered point to all faces could be an idea.

This proposed algorithm is self developed based on a topological consideration of the problem.
However, a better solution will probably exist somewhere. For example, the Computational Geometry Algorithm Library (CGAL) [4] includes many features - maybe something from there can be useful. Especially the Package Overview [5] in the documentation gives a good summary - at this point, further reading is pending.

References

[1] https://standards.buildingsmart.org/IFC/RELEASE/IFC4_1/FINAL/HTML/link/ifcfacesurface.htm
[2] https://standards.buildingsmart.org/IFC/RELEASE/IFC4_1/FINAL/HTML/link/ifcadvancedface.htm
[3] https://web.archive.org/web/20150203005649/http://carve-csg.com/about
[4] https://www.cgal.org/
[5] https://doc.cgal.org/latest/Manual/packages.html