How to use IO file formats

This page explains how to be able to use OpenGeode file formats in your code.

What to do?

You just have to add in your executable/code depending on your needs:

geode::detail::initialize_mesh_io();

and/or

geode::detail::initialize_model_io();

These functions are declared in the files include/geode/io/mesh/detail/common.h and include/geode/io/model/detail/common.h.

Do not forget to include the right file in your code. You have examples in the OpenGeode-IO tests.

Why I have to do that?

The reason is quite simple. Have a quick look at the file OpenGeode-IO/src/geode/mesh/common.cpp.

In this file you can see that supported file formats for meshes are registered when the OpenGeode_IO_mesh library is loaded. But the I/O code is not directly called in executable (see tests for examples), and as a consequence the OpenGeode_IO_mesh library is not loaded. This is called the lazy loading of dependencies. If you call the function detail::initialize_mesh_io(), the library is loaded, the file formats are registered and you are able to use our supported file formats.