Working with .bin and .csv Files in BIM SDK

Alexey Korolev

June 20, 2019

Using the TB_BinGenerator utility

TB_BinGenerator is a utility that updates .bin and .csv files, which are used for large data set storage such as data of objects associated with BuiltInCategories. By default TB_BinGenerator is excluded from the build process. Excluding it can be switched by changing the first line of TB_ROOT/Projects/CMakeLists.txt from SET(ENV{GENERATION_MODE} 0) to SET(ENV{GENERATION_MODE} 1). Using it is simple, just run the utility without arguments.

Changes in TB_ExLabelUtils

TB_ExLabelUtils was completely redesigned while keeping the API mostly the same.

All labels are stored in a separate set of .csv files, which are located in the CSV folder near the TB_ExLabelUtils binary. Their values can be changed anytime, even at runtime. For simplicity and to avoid performance issues in the example, each set of labels is cached on first request. So runtime changes do not take effect during the current session if labels were already requested.

A minor API extension consists of the OdBm::EnumsWithLabels::Enum enumeration, which presents a list of enumerations with associated labels:

  • virtual bool OdBmLabelUtilsPE::isCommon(const OdBm::EnumsWithLabels::Enum) const;
    Returns true if the label value is based on macro definitions in BIM source files; false otherwise.
  • virtual bool OdBmLabelUtilsPE::hasValues(const OdBm::EnumsWithLabels::Enum) const;
    Returns true if PE can return values for a specified enumeration; false otherwise.

In the sample TB_ExLabelUtils, isCommon is evaluated by checking the Checksums.txt file located near the TB_ExLabelUtils binary. The checksum value computed using SHA1 is applied to .csv. SHA1 implementation is located at TB_ROOT/Include/Common/BmSHA1.h.

Regarding built-in object loading: if the TB_ExLabelUtils module hasnʼt been loaded, if labels for an associated enumeration (BmCategoty.h for instance) are common, or if labels canʼt be loaded (TB_ExLabelUtils returns false), then the labels stored in the binaries are used.

The CSV folder in the distribution pack is a copy of the CSV folder located in the BIM root folder.

Consistency of .bin and .csv

On compilation, if the content of a .csv or .bin file isnʼt consistent with the file containing the macro definition (BuiltInCategories.csv and BmBuiltInCategory.h for instance), the build fails. So changes have to be done through macro changes and running TB_BinGenerator.