Skip to content

Ambiguous mesh triangulation #299

Open

Description

@mezlondr

I have found out in certain cases MeshOps::retriangulateMeshSetForExport produces different (and wrong) result in each run.

While I am not certain if that is a bug in the triangulation or perhaps in loading in CSG (as the bugs are wall openings), as iterating one single face (result of geometry converter without invoking triangulation) produces non-planar 3D representation, which has ambiguous surface, therefore the triangulation can't be properly done.

Consider this mesh consisting of single face which produces incorrect result:

Image

There is no way of telling which part of the mesh should be filled, which I believe causes the bugs:

Image

These are the points:

startX =[12         ,12         ,12   ,12   ,10   ,10         ,10         ,10   ,10   ,12]
startY =[-0.12      ,1.73472e-18,0.15 ,0.15 ,0.15 ,0.15       ,1.73472e-18,-0.12,-0.12,-0.12]
startZ =[3          ,3          ,3    ,-0.05,-0.05,3          ,3          ,3    ,-0.05,-0.05]
endX   =[12         ,12         ,12   ,10   ,10   ,10         ,10         ,10   ,12   ,12]
endY   =[1.73472e-18,0.15       ,0.15 ,0.15 ,0.15 ,1.73472e-18,-0.12      ,-0.12,-0.12,-0.12]
endZ   =[3          ,3          ,-0.05,-0.05,3    ,3          ,3          ,-0.05,-0.05,3]

Or is there a proper way to determine the orientation of the face?

In case it helps I can send the ifc file in question.

Activity

  1. mezlondr commented on Jun 23, 2025

    @mezlondr
    Author

    Possible Workaround just in case anyone has the same issue and needs quick fix, it helps if you disable MeshSimplifier.

    Go to MeshOps.cpp, find MeshOps::simplifyMeshSet (line ~890) and change these lines:

            ...
    	if (!meshset)
    	{
    		infoMeshOut.meshSetValid = false;
    		return;
    	}
    	MeshOps::checkMeshSetValidAndClosed(meshset, infoMeshOut, params); // I Changed this
    	return; // I Changed this
    
    	bool useDefaultSimplifier = true;
            ...
  2. ifcquery commented on Jun 24, 2025

    @ifcquery
    Owner

    This repository is more or less archived.
    If you need support or customization for existing projects, it is still available (please contact info at ifcquery.com)
    For new projects, I recommend Web-ifc, since it fulfills the same purpose, plus the ability to run in WASM, see (https://github.com/ifcquery/ifcplusplus).

  3. mezlondr commented on Jun 25, 2025

    @mezlondr
    Author

    @ifcquery Thanks for the response, I'll give it a try and rewrite the current code into the webifc library, I was at first concerned that I will have to deal with JavaScript and such, but it seems like the "web" part is just a scarecrow and it can be used as a standalone C++ library, and the issues I have mentioned seem to be fixed there.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions