f3d icon indicating copy to clipboard operation
f3d copied to clipboard

Rework libf3d options to use strong typing

Open mwestphal opened this issue 1 year ago • 2 comments

Context libf3d rely on options which are a string based framework that let libf3d user set many options however this frame is too flexible and it is very hard to recover informations about the type of the option, default values and so on.

This framework require a smart rework

Suggested solution

  • Declare options as a .json file
  • Generate C++ code based on the json file with a strong typed API that also support default values
  • Generate python code bindings based on the json file

mwestphal avatar Jan 31 '24 07:01 mwestphal

First json draft:

{
  "options": [
    {   
      "name": "render.line-width",
      "type": "double",
      "default_value": "1.0"
    },  
    {   
      "name": "scene.up-direction",
      "type": "string",
      "default_value": "+Y"
    },  
    {   
      "name": "model.scivis.colormap",
      "type": "double_vector",
      "default_value": "0.0, 0.0, 0.0, 0.0, 0.4, 0.9, 0.0, 0.0, 0.8, 0.9, 0.9, 0.0, 1.0, 1.0, 1.0, 1.0"
    }   
  ]
}

mwestphal avatar Jun 04 '24 05:06 mwestphal

Iterating on json:

{
  "render.line-width":
  {
    "type": "double",
    "default_value": "1.0"
  },  
  "scene.up-direction":
  {
    "type": "direction",
    "default_value": "+Y"
  },  
  "model.scivis.colormap":
  {
    "type": "colormap",
    "default_value": "0.0, 0.0, 0.0, 0.0, 0.4, 0.9, 0.0, 0.0, 0.8, 0.9, 0.9, 0.0, 1.0, 1.0, 1.0, 1.0"
  }
}

mwestphal avatar Jun 04 '24 06:06 mwestphal