ifcplusplus icon indicating copy to clipboard operation
ifcplusplus copied to clipboard

Ambiguous mesh triangulation

Open mezlondr opened this issue 7 months ago • 3 comments

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.

mezlondr avatar Jun 20 '25 12:06 mezlondr

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;
        ...

mezlondr avatar Jun 23 '25 07:06 mezlondr

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).

ifcquery avatar Jun 24 '25 10:06 ifcquery

@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.

mezlondr avatar Jun 25 '25 08:06 mezlondr