Geometry Interface

template<IsSpectral TSpectral, IsFloat TFloat, IsFloat TMeshFloat>
class GeometryInterface

Interface for loading and saving 3D geometry data with spectral rendering support.

GeometryInterface provides a unified API for loading 3D geometry from various file formats and integrating them into a spectral rendering scene. It supports automatic format detection, multiple file formats through different backend loaders (Assimp, DSK), and configurable color space conversions between RGB and spectral representations.

The class is templated to support different spectral types and floating-point precisions, with the constraint that mesh data uses higher precision floating-point than general calculations to maintain geometric accuracy.

Key features:

  • Automatic file format detection based on extension

  • Support for multiple 3D file formats via Assimp integration

  • Native DSK (Digital Shape Kernel) format support

  • Configurable RGB-to-spectral color conversion functions

  • Group-based geometry saving functionality

  • DSK-specific albedo configuration for material properties

See also

vira::Scene

See also

LoadedMeshes

Note

The LesserFloat<TFloat, TMeshFloat> constraint ensures that mesh data maintains higher numerical precision than general scene calculations.

Template Parameters:
  • TSpectral – The spectral type used for color representation (must satisfy IsSpectral concept)

  • TFloat – The floating-point type used for general calculations (must satisfy IsFloat concept)

  • TMeshFloat – The floating-point type used for mesh data (must satisfy IsFloat concept and have greater precision than TFloat)

Public Functions

GeometryInterface() = default
~GeometryInterface() = default
LoadedMeshes<TFloat> load(vira::Scene<TSpectral, TFloat, TMeshFloat> &scene, const fs::path &filepath, std::string format = "AUTO")

Loads 3D geometry from a file into the scene.

Automatically detects the file format based on extension unless explicitly specified. Supports various formats through Assimp (OBJ, PLY, GLTF, GLB, FBX, DAE, 3DS, BLEND) and native DSK format for planetary/astronomical data.

See also

loadWithAssimp(), loadDSK(), detectFormat()

Parameters:
  • scene – The scene to load the geometry into

  • filepath – Path to the geometry file to load

  • format – File format override (“AUTO” for automatic detection, or specific format like “OBJ”, “PLY”, “DSK”, etc.)

Returns:

LoadedMeshes<TFloat> Structure containing loaded mesh IDs, transformations, and node hierarchy

Throws:

std::runtime_error – If file doesn’t exist or format is unsupported

void saveGroup(vira::scene::Group<TSpectral, TFloat, TMeshFloat> &group, const fs::path &filepath, std::string format = "AUTO")

Saves a scene group to a file in the specified format.

Exports the complete group hierarchy including meshes, materials, transformations, and node structure. Currently supports OBJ format with plans for additional formats.

Note

Currently limited to OBJ export format

Parameters:
  • group – The scene group to export

  • filepath – Output file path (extension determines format if format is “AUTO”)

  • format – Export format (“AUTO” for automatic detection, or specific format like “OBJ”)

Throws:

std::runtime_error – If format is unsupported or export fails

void setRgbToSpectralFunction(std::function<TSpectral(ColorRGB)> func)

Sets the RGB to spectral conversion function.

This function is used when loading materials with RGB color data to convert them to the spectral domain. Must be a valid, non-null function.

Parameters:

func – Function that converts RGB colors to spectral representation

Throws:

std::runtime_error – If the provided function is null

void setDSKAlbedo(const TSpectral &albedo)

Sets the default albedo for DSK format meshes.

DSK files typically don’t contain material information, so this sets the default Lambertian albedo applied to all DSK geometry.

Parameters:

albedo – The spectral albedo value to use for DSK meshes