surfaces.factories.geometry_factory

Geometry Factory Module

This module contains the GeometryFactory class, which is responsible for generating an appropriate geometry instance, given an input configuration. The class interfaces tightly with the surface factory for building surfaces, which are the building blocks of optical systems in Optiland.

Kramer Harrison, 2025

Classes

GeometryFactory()

Factory for creating surface geometry objects based on configuration.

class GeometryFactory[source]

Factory for creating surface geometry objects based on configuration.

static create(surface_type: str, cs: Any, **kwargs: Any) Any[source]

Create and return a geometry object based on the surface type and configuration. :param surface_type: The type of surface (e.g., ‘standard’, ‘even_asphere’). :type surface_type: str :param cs: The coordinate system for the geometry. :param **kwargs: Configuration parameters for the geometry.

Returns:

The constructed geometry object.

Raises:

ValueError – If the surface type is not recognized.

classmethod register(name: str, create_fn: Callable, config_cls: type, *, overwrite: bool = False) None[source]

Register a new geometry type.

Parameters:
  • name – The surface_type string key (e.g. ‘even_asphere’).

  • create_fn – A function (cs, config) -> geometry instance.

  • config_cls – A dataclass whose fields define the accepted kwargs.

  • overwrite – Allow replacing an existing registration.

Raises:

ValueError – If name is already registered and overwrite is False.