Back

VoxelGridLoader

sofa::component::io::mesh::VoxelGridLoader
VoxelLoader
Doc (from source)

Voxel loader based on RAW files.

Abstract (AI generated)

Loads voxel data from RAW files into the SOFA simulation framework, providing functionalities to manage and manipulate 3D voxel grids based on specified parameters such as resolution, region of interest (ROI), header size, background values, active data values, and voxel sizes.

Metadata
module
Sofa.Component.IO.Mesh
namespace
sofa::component::io::mesh
include
sofa/component/io/mesh/VoxelGridLoader.h
inherits
  • VoxelLoader
description

The VoxelGridLoader is an input/output (I/O) component designed to load voxel data from RAW files into the SOFA simulation framework. This component does not directly contribute to the governing equations or operators that are central to the Finite Element Method (FEM) pipeline, such as mass matrix $M$, stiffness matrix $K$, internal force $f_{int}$, residual $R$, etc. Instead, its primary role is to prepare and manage voxel data for further processing by other components that may utilize this data in FEM simulations or other computational mechanics tasks.

Mathematical Description:

The VoxelGridLoader operates on a 3D grid of voxels, where each voxel represents a small volume element within the domain. The primary parameters and operations related to the voxel grid are as follows:

  1. Voxel Size $\mathbf{d}_{voxelSize}$:
  2. Dimension of one voxel in physical units.

  3. Data Resolution $\mathbf{res} = (n_x, n_y, n_z)$:

  4. Number of voxels along each axis of the grid.
  5. The total number of voxels is given by:

    $$ N_{voxel} = n_x \times n_y \times n_z $$
  6. Region Of Interest (ROI) $\mathbf{roi} = (x_{min}, y_{min}, z_{min}, x_{max}, y_{max}, z_{max})$:

  7. Specifies the subset of voxels to be considered for further processing.

  8. Header Sizes:

  9. d_headerSize: Size of the header in bytes for the voxel file.
  10. d_segmentationHeaderSize: Header size for segmentation data, if present.

  11. Background and Active Values $\mathbf{bgVal}, \mathbf{activeVal}$:

  12. Lists of voxel values to be treated as background (to be ignored) or active (of interest).

Physical Description:

The VoxelGridLoader performs the following tasks related to loading and managing 3D voxel data:

  1. Loading Data:
  2. Reads RAW file containing voxel data.
  3. Initializes an internal representation of the voxel grid based on specified resolution, ROI, and header sizes.

  4. Data Manipulation:

  5. Sets up background and active value lists to filter out irrelevant or significant voxels during processing.

  6. Hexahedra Generation (Optional):

  7. If enabled (d_generateHexa), the component generates hexahedral elements based on the voxel data, which can be used for FEM discretization or other geometric operations.

Numerical Methods and Discretization Choices:

The VoxelGridLoader itself does not involve any numerical methods or discretization choices directly related to solving PDEs or performing variational mechanics. Its primary function is to preprocess the voxel data, ensuring that it is in a format suitable for further use by components involved in FEM simulation or other computational tasks.

Role in Global FEM Pipeline:

The VoxelGridLoader fits into the broader SOFA framework as follows:

  1. Modeling Phase:
  2. Loads and prepares voxel data based on user-defined parameters.

  3. Discretization Phase:

  4. Optionally generates hexahedral elements, which can be used for FEM discretization by other components.

  5. Assembly Phase:

  6. Provides voxel data to other components that might need it for assembling global matrices or forces.

  7. Time Integration and Solvers:

  8. Does not directly participate in time integration or solving nonlinear systems, but the loaded data can be used by such components indirectly through the scene graph architecture of SOFA.

Conclusion:

The VoxelGridLoader serves as a preprocessing component within the SOFA framework, handling the loading and management of 3D voxel data. It does not directly contribute to the mathematical or physical operations central to FEM simulations but prepares the input data for further use by other components involved in these processes.

Data Fields
NameTypeDefaultHelp
d_voxelSize type::Vec3 Dimension of one voxel
d_dataResolution Vec3i Resolution of the voxel file
d_roi Vec6i Region of interest (xmin, ymin, zmin, xmax, ymax, zmax)
d_headerSize int Header size in bytes
d_segmentationHeaderSize int Header size in bytes
d_generateHexa bool Interpret voxel as either hexa or points
Methods
void init () virtual
void reinit () virtual
void clear () virtual
bool load () virtual
bool canLoad () virtual
void setVoxelSize (const type::Vec3 vSize)
type::Vec3 getVoxelSize () virtual
void addBackgroundValue (const int value)
int getBackgroundValue (const unsigned int idx)
void addActiveDataValue (const int value)
int getActiveDataValue (const unsigned int idx)
void getResolution (Vec3i & res)
int getDataSize () virtual
unsigned char * getData () virtual
unsigned char * getSegmentID () virtual
int getHexaIndicesInGrid ()
Vec6i getROI () virtual
void createSegmentation3DTexture (unsigned char ** textureData, int & width, int & height, int & depth) virtual
{
  "name": "VoxelGridLoader",
  "namespace": "sofa::component::io::mesh",
  "module": "Sofa.Component.IO.Mesh",
  "include": "sofa/component/io/mesh/VoxelGridLoader.h",
  "doc": "Voxel loader based on RAW files.",
  "inherits": [
    "VoxelLoader"
  ],
  "templates": [],
  "data_fields": [
    {
      "name": "d_voxelSize",
      "type": "type::Vec3",
      "xmlname": "voxelSize",
      "help": "Dimension of one voxel"
    },
    {
      "name": "d_dataResolution",
      "type": "Vec3i",
      "xmlname": "resolution",
      "help": "Resolution of the voxel file"
    },
    {
      "name": "d_roi",
      "type": "Vec6i",
      "xmlname": "ROI",
      "help": "Region of interest (xmin, ymin, zmin, xmax, ymax, zmax)"
    },
    {
      "name": "d_headerSize",
      "type": "int",
      "xmlname": "header",
      "help": "Header size in bytes"
    },
    {
      "name": "d_segmentationHeaderSize",
      "type": "int",
      "xmlname": "segmentationHeader",
      "help": "Header size in bytes"
    },
    {
      "name": "d_generateHexa",
      "type": "bool",
      "xmlname": "generateHexa",
      "help": "Interpret voxel as either hexa or points"
    }
  ],
  "links": [],
  "methods": [
    {
      "name": "init",
      "return_type": "void",
      "params": [],
      "is_virtual": true,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "public"
    },
    {
      "name": "reinit",
      "return_type": "void",
      "params": [],
      "is_virtual": true,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "public"
    },
    {
      "name": "clear",
      "return_type": "void",
      "params": [],
      "is_virtual": true,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "public"
    },
    {
      "name": "load",
      "return_type": "bool",
      "params": [],
      "is_virtual": true,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "public"
    },
    {
      "name": "canLoad",
      "return_type": "bool",
      "params": [],
      "is_virtual": true,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "public"
    },
    {
      "name": "setVoxelSize",
      "return_type": "void",
      "params": [
        {
          "name": "vSize",
          "type": "const type::Vec3"
        }
      ],
      "is_virtual": false,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "public"
    },
    {
      "name": "getVoxelSize",
      "return_type": "type::Vec3",
      "params": [],
      "is_virtual": true,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "public"
    },
    {
      "name": "addBackgroundValue",
      "return_type": "void",
      "params": [
        {
          "name": "value",
          "type": "const int"
        }
      ],
      "is_virtual": false,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "public"
    },
    {
      "name": "getBackgroundValue",
      "return_type": "int",
      "params": [
        {
          "name": "idx",
          "type": "const unsigned int"
        }
      ],
      "is_virtual": false,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "public"
    },
    {
      "name": "addActiveDataValue",
      "return_type": "void",
      "params": [
        {
          "name": "value",
          "type": "const int"
        }
      ],
      "is_virtual": false,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "public"
    },
    {
      "name": "getActiveDataValue",
      "return_type": "int",
      "params": [
        {
          "name": "idx",
          "type": "const unsigned int"
        }
      ],
      "is_virtual": false,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "public"
    },
    {
      "name": "getResolution",
      "return_type": "void",
      "params": [
        {
          "name": "res",
          "type": "Vec3i &"
        }
      ],
      "is_virtual": false,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "public"
    },
    {
      "name": "getDataSize",
      "return_type": "int",
      "params": [],
      "is_virtual": true,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "public"
    },
    {
      "name": "getData",
      "return_type": "unsigned char *",
      "params": [],
      "is_virtual": true,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "public"
    },
    {
      "name": "getSegmentID",
      "return_type": "unsigned char *",
      "params": [],
      "is_virtual": true,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "public"
    },
    {
      "name": "getHexaIndicesInGrid",
      "return_type": "int",
      "params": [],
      "is_virtual": false,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "public"
    },
    {
      "name": "getROI",
      "return_type": "Vec6i",
      "params": [],
      "is_virtual": true,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "public"
    },
    {
      "name": "createSegmentation3DTexture",
      "return_type": "void",
      "params": [
        {
          "name": "textureData",
          "type": "unsigned char **"
        },
        {
          "name": "width",
          "type": "int &"
        },
        {
          "name": "height",
          "type": "int &"
        },
        {
          "name": "depth",
          "type": "int &"
        }
      ],
      "is_virtual": true,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "public"
    }
  ],
  "description": "The `VoxelGridLoader` is part of the SOFA framework's IO module, specifically designed for loading voxel data from RAW files. This loader inherits from `VoxelLoader`, providing functionalities to manage and manipulate 3D voxel grids. The primary role of this component is to handle the initialization, reinitialization, and cleanup of the voxel grid, as well as to load the actual voxel data based on specified parameters such as resolution, ROI (Region Of Interest), header size, background values, active data values, and voxel sizes.\n\n**Interactions with other components:**\n- **Data Fields**: It interacts through its public data fields like `d_voxelSize`, `d_dataResolution`, `d_roi`, etc., which are typically set via XML configuration in SOFA scenes. These parameters define the physical properties of the voxel grid and how it should be loaded or interpreted.\n- **Methods**: Methods such as `init()`, `reinit()`, `clear()`, `load()` provide hooks for integration with other components, especially those that rely on the voxel data for simulation purposes.\n\n**Practical Usage Guidance:**\n- The `d_voxelSize` field specifies the dimensions of each voxel in the grid. This can be set to match the physical scale of the scene being simulated.\n- `d_dataResolution` defines the number of voxels along each axis, thus controlling the overall size and granularity of the grid.\n- Setting a valid Region Of Interest (`d_roi`) allows focusing on specific parts of the voxel data for more efficient processing or visualization.\n- The `d_backgroundValue` and `d_activeDataValue` fields are used to mark certain voxel values as either background (to be ignored) or active, respectively. This can be useful in surgical simulations where some voxels represent non-tissue regions or tissue types of interest.\n\nOverall, `VoxelGridLoader` is a versatile component for handling 3D volumetric data within the SOFA framework.",
  "maths": "The `VoxelGridLoader` is an input/output (I/O) component designed to load voxel data from RAW files into the SOFA simulation framework. This component does not directly contribute to the governing equations or operators that are central to the Finite Element Method (FEM) pipeline, such as mass matrix \\(M\\), stiffness matrix \\(K\\), internal force \\(f_{int}\\), residual \\(R\\), etc. Instead, its primary role is to prepare and manage voxel data for further processing by other components that may utilize this data in FEM simulations or other computational mechanics tasks.\n\n### Mathematical Description:\n\nThe `VoxelGridLoader` operates on a 3D grid of voxels, where each voxel represents a small volume element within the domain. The primary parameters and operations related to the voxel grid are as follows:\n\n1. **Voxel Size** \\(\\mathbf{d}_{voxelSize}\\):\n   - Dimension of one voxel in physical units.\n   \n2. **Data Resolution** \\(\\mathbf{res} = (n_x, n_y, n_z)\\):\n   - Number of voxels along each axis of the grid.\n   - The total number of voxels is given by:\n     \n     \\[\n     N_{voxel} = n_x \\times n_y \\times n_z\n     \\]\n\n3. **Region Of Interest (ROI)** \\(\\mathbf{roi} = (x_{min}, y_{min}, z_{min}, x_{max}, y_{max}, z_{max})\\):\n   - Specifies the subset of voxels to be considered for further processing.\n   \n4. **Header Sizes**:\n   - `d_headerSize`: Size of the header in bytes for the voxel file.\n   - `d_segmentationHeaderSize`: Header size for segmentation data, if present.\n\n5. **Background and Active Values** \\(\\mathbf{bgVal}, \\mathbf{activeVal}\\):\n   - Lists of voxel values to be treated as background (to be ignored) or active (of interest).\n\n### Physical Description:\n\nThe `VoxelGridLoader` performs the following tasks related to loading and managing 3D voxel data:\n\n1. **Loading Data**:\n   - Reads RAW file containing voxel data.\n   - Initializes an internal representation of the voxel grid based on specified resolution, ROI, and header sizes.\n\n2. **Data Manipulation**:\n   - Sets up background and active value lists to filter out irrelevant or significant voxels during processing.\n   \n3. **Hexahedra Generation (Optional)**:\n   - If enabled (`d_generateHexa`), the component generates hexahedral elements based on the voxel data, which can be used for FEM discretization or other geometric operations.\n\n### Numerical Methods and Discretization Choices:\n\nThe `VoxelGridLoader` itself does not involve any numerical methods or discretization choices directly related to solving PDEs or performing variational mechanics. Its primary function is to preprocess the voxel data, ensuring that it is in a format suitable for further use by components involved in FEM simulation or other computational tasks.\n\n### Role in Global FEM Pipeline:\n\nThe `VoxelGridLoader` fits into the broader SOFA framework as follows:\n\n1. **Modeling Phase**:\n   - Loads and prepares voxel data based on user-defined parameters.\n\n2. **Discretization Phase**:\n   - Optionally generates hexahedral elements, which can be used for FEM discretization by other components.\n\n3. **Assembly Phase**:\n   - Provides voxel data to other components that might need it for assembling global matrices or forces.\n\n4. **Time Integration and Solvers**:\n   - Does not directly participate in time integration or solving nonlinear systems, but the loaded data can be used by such components indirectly through the scene graph architecture of SOFA.\n\n### Conclusion:\n\nThe `VoxelGridLoader` serves as a preprocessing component within the SOFA framework, handling the loading and management of 3D voxel data. It does not directly contribute to the mathematical or physical operations central to FEM simulations but prepares the input data for further use by other components involved in these processes.",
  "abstract": "Loads voxel data from RAW files into the SOFA simulation framework, providing functionalities to manage and manipulate 3D voxel grids based on specified parameters such as resolution, region of interest (ROI), header size, background values, active data values, and voxel sizes.",
  "sheet": "# VoxelGridLoader\n\n## Overview\nThe `VoxelGridLoader` is an input/output component designed for loading voxel data from RAW files into the SOFA simulation framework. It inherits from `VoxelLoader`, providing functionalities to manage and manipulate 3D voxel grids based on specified parameters such as resolution, region of interest (ROI), header size, background values, active data values, and voxel sizes.\n\n## Parameters and Data\nThe significant Data fields exposed by the component are:\n- **voxelSize** (`type::Vec3`): Dimension of one voxel in physical units. Default: Not specified.\n- **resolution** (`Vec3i`): Resolution of the voxel file, specifying the number of voxels along each axis (x, y, z). Default: Not specified.\n- **ROI** (`Vec6i`): Region of interest defined by (xmin, ymin, zmin, xmax, ymax, zmax). Default: Not specified.\n- **headerSize** (`int`): Header size in bytes for the voxel file. Default: Not specified.\n- **segmentationHeaderSize** (`int`): Header size in bytes for segmentation data, if present. Default: Not specified.\n- **generateHexa** (`bool`): Interpret voxel as either hexahedra or points. Default: Not specified.\n\n## Dependencies and Connections\nThe `VoxelGridLoader` typically requires other components that rely on the loaded voxel data for further processing, such as FEM solvers or visualization tools. It fits into the scene graph by providing voxel data to downstream components through its methods like `load()`, `getResolution()`, `getDataSize()`, and others."
}