youshengCode / IfcToolbox

Simple tools for processing IFC files. Optimize, convert, split, relocate and anonymize IFC files easily.
GNU General Public License v3.0
86 stars 14 forks source link

IFC Optimizer : Layer name (IFCPRESENTATIONLAYERWITHSTYLE) missing after optimization #4

Closed MichaelVictoriano closed 2 years ago

MichaelVictoriano commented 2 years ago

The Layer name of the object was removed after the IFC files has been Optimised. Am I missing some settings prior to running the app by its default settings?

image

youshengCode commented 2 years ago

Hi Michael, thanks for your report.

For the layer info, it's kind of weird... Because the optimizer only takes care of duplicated IFC instances or the points in the geometry. Could you provide a small test file to allow us to test and debug?

And for the second one. It's the name of the parser IFC. Because we need to fill in this information every time we write a new file (IfcOptimizer is rewriting a new IFC actually). So for now, I'm using the product name here. Maybe what I could do is add a new option in configuration, maybe like 'keep the old origination system' and copy the old info and rewrite after the optimization process. I think it will be fine for your case.

youshengCode commented 2 years ago

@MichaelVictoriano I changed using the original OriginatingSystem as default, it seems like this will be more natural for the user. Thanks for your feedback.

It's already modified in this repo, you can process it directly with code from the examples folder. The GUI app in the Microsoft Store will be modified for the next release.

I can't reproduce the layer info missing issue until you provide me with a small simple file. So, I will close this issue for now. Thanks again.

MichaelVictoriano commented 2 years ago

@youshengCode Apologies for the delay as I was a little bit swapped. Files.zip

I have uploaded 2 files; (1) the Original IFC file & the other is the (2) Optimised IFC files.

The file was optimized by 4.5%. image

Below is the setting I used. image

As mentioned, after the optimization. IFCPRESENTATIONLAYERWITHSTYLE was missing.

Thank you for your help and hard work.

youshengCode commented 2 years ago

Hi @MichaelVictoriano, I think I have found the problem, but honestly, I think I could not fix it quickly.

The IfcOptimizer in IfcToolbox is written with an algorithm in Xbim lib called InsertCopy. And as I said earlier, we are creating a new IFC file. Because in the backend, we take each IfcProduct as the main object and copy it one by one in the new IFC file with all its referenced entities. For example, for an IfcWall, we will copy the IfcWall entity, and all its material, properties, color, quantities, all related to this IfcWall entity. In this way, we could leave all information which not been referenced in the old file and create a new one without redundancy information.

In your case, this entity actually is not referenced by any other entity.

image

And I think this is coming from the Xbim lib, cause IfcToolbox is just a higher-level implementation. Maybe I will try to make a pull request in Xbim lib to fix this problem at the lib level. But it could take some time with their next release. Hope you can understand that.

By the way, I highly recommend you to use the Keep old reference label as Off for the configuration. Cause the id of entities will not affect the actual information and it will provide a better optimization result. Here is a result with the same file you provided.

image

I will let you know if we fixed this in the future with maybe a new version of Xbim lib.