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

[QUESTION] How to create IFCBuildingElements by a Mesh? #117

Open
lucasaue opened this issue Jun 26, 2018 · 1 comment
Open

[QUESTION] How to create IFCBuildingElements by a Mesh? #117

lucasaue opened this issue Jun 26, 2018 · 1 comment

Comments

@lucasaue
Copy link

Hi,

I'm working with XBim a few months and in my software project, the user can build your Architetural Project. To creates entities like walls, doors, windows, stairs every thing works so fine, but I have a problem with some families from a imported IFC files.

The imported file work so well, but I need to recreate this model from some 3D data, with Mesh (vertex, TriangleIndices...) when the user edit this model. I'm working with IFC2x3, because has more interoperability with the third softwares and I know that the IFC 2x3 there aren't IfcTriangulatedFaceSet, so I need to create my model using IFCClosedShells or IfcFaceBasedSurfaceModels.

I've been studing and I know there are some hard implementation rules to create this geometries, like for example to create a ClosedShell, you have these rules:

  • Every edge shall be referenced exactly twice by the loops of the face.
  • Each oriented edge shall be unique.
  • No edge shall be referenced by more than two faces.
  • Distinct faces of the shell do not intersect, but may share edges or vertices.
  • Distinct edges do not intersect but may share vertices.
  • Each face reference shall be unique.
  • The loops of the shell shall not be a mixture of poly loop and other loop types. Note: this is given, since only poly loop is defined as face bound definition.
  • The closed shell shall be an oriented arcwise connected 2-manifold.
  • The Euler equation shall be satisfied.

My question is? Is there some simple way to convert a mesh to a IFC2x3 Geometry? Is there something the I'm missing?

@bekraft
Copy link
Contributor

bekraft commented Dec 14, 2018

Hi,
indeed the use of Ifc2x3 and already triangulated surfaces is a worst-case scenario. But Ifc2x3 provides several alternative approaches to declare the boundaries of faces (edge-wise or point-vertex-wise). The basic question is: Is the given mesh (triangles) topologically correct? Means: Are all triangles oriented in the same direction (normals pointing in/out) and does the mesh have no gaps (open edges/faces)?

If you're not sure about this, you'll have to check it by yourself. Otherwise you're able to transform the triangulation into a connected face set directly.

Create a list of IfcCartesianPoint (having some 3D points as IEnumerable<double[]>:

var list = new List<IfcCartesianPoint>();
foreach (var coordinates in points.Select(p => p.Select(x => new IfcLengthMeasure(x))))
{
    var point = ifcStore.Instances.New<IfcCartesianPoint>();
    point.Coordinates.AddRange(coordinates);
    list.Add(point);
}

and generate a connected faceset out of this list with the help of the triangle-face indexes:

var faceSet = ifcStore.Instances.New<IfcConnectedFaceSet>();
var points = ... // list of IfcCartesianPoint
var indexes = ... // IEnumerable<int[]> 

foreach (var t in indexes)
{
    // Create face loop by given boundary points
    var polyLoop = ifcStore.Instances.New<IfcPolyLoop>();
    polyLoop.Polygon.AddRange(t.Select(k => points[k]));

    // Create bounds
    var bound = ifcStore.Instances.New<IfcFaceOuterBound>();
    bound.Bound = polyLoop;
    // Create face
    var face = ifcStore.Instances.New<IfcFace>();
    face.Bounds.Add(bound);
    // Add face to outer shell
    faceSet.CfsFaces.Add(face);
}

Finally you can plug this set into a new IfcFaceBasedSurfaceModel.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants