GeometryGym / GeometryGymIFC

C# classes to generate and parse OpenBIM IFC files
Other
269 stars 97 forks source link

Precision lost when saving as STEP file #44

Open bschorno opened 3 years ago

bschorno commented 3 years ago

When generating a step file the precision of e.g. IfcCartesianPoint gets lost. To build the STEP string the SerializeCoordinates are used which are rounded on the basis of IfcGeometricRepresentationContext. I think this precision should only affect the context on which the ifc is used. Wouldn't it be better to export the original values? Would there be any disadvantage?

grafik

jmirtsch commented 3 years ago

Thanks for posting this. It's an interesting suggestion and it's certainly up for discussion.

If I refer to the documentation of the Precision attribute (taken from here : https://standards.buildingsmart.org/IFC/DEV/IFC4_3/RC2/HTML/link/ifcgeometricrepresentationcontext.htm)

Value of the model precision for geometric models. It is a double value (REAL), typically in 1E-5 to 1E-8 range, that indicates the tolerance under which two given points are still assumed to be identical. The value can be used e.g. to sets the maximum distance from an edge curve to the underlying face surface in brep models.

The application or process being presented with the IFC file can assume that this is a tolerance for coincident points. So serializing the file with 12 decimal points can be expected to be "rounded" if the precision is nominated as 4.

I found in some files, very tiny values serialized (such as 0.000000000923) and the number of digits does impact the resultant file size.

I'd suggest first and foremost, that it if you want lengths serialized with a fine precision, that you can set the precision attribute on the context concept to control this. If this isn't acceptable, I would consider suggestions on other changes to the toolkit (such as an opt-in toggle to ignore the precision).

Look forward to discussing further,

Jon

bschorno commented 3 years ago

Thanks for your reply. I thougt about setting the DatabaseIfc.Tolerance for exporting, but when you import this file again, two points who sould be coincident, are no longer. So this would defeat the purpose of the Precision attribute of the IfcGeometricRepresentationContext.

As you mentioned, this attribute tells the application that two given points are coincident, but only in the context of the application and when you export as an ifc file you maybe want to keep the precision. Otherwise there wouldn't be ifc files which hold high precision values and have set the Precision attribute to lower value.

Since STEP-files aren't very size optimized, large numbers shouldn't be the biggest issue 😝. But nevertheless I like your idea of an option to ignore the precision or something like that. But as default I think the precision should be kept. Maybe an overall optimization option which can do multiple kinds of small optimizations. What I often see in ifc-files is that they cut the decimal places when it's zero to save one character. This could for example also be included in an overall optimization option.

grafik

Let me know what you think and if you need help in any implementations.