ThatOpen / web-ifc-three

The official IFC Loader for Three.js.
https://ifcjs.github.io/info/
MIT License
506 stars 132 forks source link

Support for IFC file that is compressed in zip #160

Open jespa007 opened 1 year ago

jespa007 commented 1 year ago

Hi, IFC comes with plain text but sometimes IFC file can be compressed as ZIP in order to save space. The idea is detect the signature that ZIP writes at the begin of the file,decompress the file using zip third party utility and give a byte array and finally load the IFC using IFCLoader.parser that expects byte array.

agviegas commented 1 year ago

Hi, the scope of this package is to load IFC into Three.js meshes. Adding zip logic might bloat a package that we already plan to un-bloat soon. Have you tried using a library specific to uncompress zip files? 🤔

jespa007 commented 1 year ago

Hi @agviegas , I was thinking about zip.js or jszip as third party libraries. Maybe I put this issue in the wrong repository. Web-ifc already takes arrayBuffer to load the model using IfcAPI.OpenModel

IfcAPI.openModel(data: Uint8Array,
                 settings: LoaderSettings): number

I think the ifcApi.openModel should be modified to check the begin of uintarray data. If the begin of the array starts with signature \x50\x4b\x01\x02 (PK♥♦ or "PK\3\4")) then can it can try to decompress.

What do you think ? As I told... may be this is issue it is more related with web-ifc rather than web-ifc-three

beachtom commented 1 year ago

So I think if this belongs anywhere it is in web-ifc. However, I am on the fence at the moment web-ifc does not actually have any depdencies (typescript side) and I am not sure if we want to add one. However, most zip libraries are < 100kb so it is not big.

jespa007 commented 1 year ago

So I think if this belongs anywhere it is in web-ifc. However, I am on the fence at the moment web-ifc does not actually have any depdencies (typescript side) and I am not sure if we want to add one. However, most zip libraries are < 100kb so it is not big.

Hi @beachtom, what do you think about including 7zip or similar as dependency of wasm? In the OpenModel (file web-ifc-api.cpp) then it can use zip library to decompress if the incoming pointer char * starts with \x50\x4b\x01\x02.

beachtom commented 1 year ago

technically not an issue at all - I guess the question is more philosophical is do we want web-ifc to do that - or is it the user responisbility? @agviegas

jespa007 commented 1 year ago

technically not an issue at all - I guess the question is more philosophical is do we want web-ifc to do that - or is it the user responisbility? @agviegas

You are right @beachtom . Ifc file could be compressed with many other formats like RAR or 7zip as well as ZIP. The user can be in charge to manage this.