# This file was auto generated by Styx.
# Do not edit this file directly.

import typing
import pathlib
from styxdefs import *

SURFACE_WEDGE_VOLUME_METADATA = Metadata(
    id="836d42477cc472d35639defeb9265c3084b789a0.workbench",
    name="surface-wedge-volume",
    package="workbench",
    container_image_tag="nx10x/workbench:2.1.0",
)


_SurfaceWedgeVolumeParamsDictNoTag = typing.TypedDict('_SurfaceWedgeVolumeParamsDictNoTag', {
    "inner-surface": InputPathType,
    "outer-surface": InputPathType,
    "metric": str,
})
SurfaceWedgeVolumeParamsDictTagged = typing.TypedDict('SurfaceWedgeVolumeParamsDictTagged', {
    "@type": typing.Literal["workbench/surface-wedge-volume"],
    "inner-surface": InputPathType,
    "outer-surface": InputPathType,
    "metric": str,
})
SurfaceWedgeVolumeParamsDict = _SurfaceWedgeVolumeParamsDictNoTag | SurfaceWedgeVolumeParamsDictTagged


class SurfaceWedgeVolumeOutputs(typing.NamedTuple):
    """
    Output object returned when calling `SurfaceWedgeVolumeParamsDict(...)`.
    """
    root: OutputPathType
    """Output root folder. This is the root folder for all outputs."""
    metric: OutputPathType
    """the output metric"""


def surface_wedge_volume_params(
    inner_surface: InputPathType,
    outer_surface: InputPathType,
    metric: str,
) -> SurfaceWedgeVolumeParamsDictTagged:
    """
    Build parameters.
    
    Args:
        inner_surface: the inner surface.
        outer_surface: the outer surface.
        metric: the output metric.
    Returns:
        Parameter dictionary
    """
    params = {
        "@type": "workbench/surface-wedge-volume",
        "inner-surface": inner_surface,
        "outer-surface": outer_surface,
        "metric": metric,
    }
    return params


def surface_wedge_volume_validate(
    params: typing.Any,
) -> None:
    """
    Validate parameters. Throws an error if `params` is not a valid
    `SurfaceWedgeVolumeParamsDict` object.
    
    Args:
        params: The parameters object to validate.
    """
    if params is None or not isinstance(params, dict):
        raise StyxValidationError(f'Params object has the wrong type \'{type(params)}\'')
    if params.get("inner-surface", None) is None:
        raise StyxValidationError("`inner-surface` must not be None")
    if not isinstance(params["inner-surface"], (pathlib.Path, str)):
        raise StyxValidationError(f'`inner-surface` has the wrong type: Received `{type(params.get("inner-surface", None))}` expected `InputPathType`')
    if params.get("outer-surface", None) is None:
        raise StyxValidationError("`outer-surface` must not be None")
    if not isinstance(params["outer-surface"], (pathlib.Path, str)):
        raise StyxValidationError(f'`outer-surface` has the wrong type: Received `{type(params.get("outer-surface", None))}` expected `InputPathType`')
    if params.get("metric", None) is None:
        raise StyxValidationError("`metric` must not be None")
    if not isinstance(params["metric"], str):
        raise StyxValidationError(f'`metric` has the wrong type: Received `{type(params.get("metric", None))}` expected `str`')


def surface_wedge_volume_cargs(
    params: SurfaceWedgeVolumeParamsDict,
    execution: Execution,
) -> list[str]:
    """
    Build command-line arguments from parameters.
    
    Args:
        params: The parameters.
        execution: The execution object for resolving input paths.
    Returns:
        Command-line arguments.
    """
    cargs = []
    cargs.extend([
        "wb_command",
        "-surface-wedge-volume"
    ])
    cargs.append(execution.input_file(params.get("inner-surface", None)))
    cargs.append(execution.input_file(params.get("outer-surface", None)))
    cargs.append(params.get("metric", None))
    return cargs


def surface_wedge_volume_outputs(
    params: SurfaceWedgeVolumeParamsDict,
    execution: Execution,
) -> SurfaceWedgeVolumeOutputs:
    """
    Build outputs object containing output file paths and possibly stdout/stderr.
    
    Args:
        params: The parameters.
        execution: The execution object for resolving input paths.
    Returns:
        Outputs object.
    """
    ret = SurfaceWedgeVolumeOutputs(
        root=execution.output_file("."),
        metric=execution.output_file(params.get("metric", None)),
    )
    return ret


def surface_wedge_volume_execute(
    params: SurfaceWedgeVolumeParamsDict,
    runner: Runner | None = None,
) -> SurfaceWedgeVolumeOutputs:
    """
    MEASURE PER-VERTEX VOLUME BETWEEN SURFACES.
    
    Compute the volume of each vertex's area from one surface to another. The
    surfaces must have vertex correspondence, and have consistent triangle
    orientation.
    
    Args:
        params: The parameters.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `SurfaceWedgeVolumeOutputs`).
    """
    surface_wedge_volume_validate(params)
    runner = runner or get_global_runner()
    execution = runner.start_execution(SURFACE_WEDGE_VOLUME_METADATA)
    params = execution.params(params)
    cargs = surface_wedge_volume_cargs(params, execution)
    ret = surface_wedge_volume_outputs(params, execution)
    execution.run(cargs)
    return ret


def surface_wedge_volume(
    inner_surface: InputPathType,
    outer_surface: InputPathType,
    metric: str,
    runner: Runner | None = None,
) -> SurfaceWedgeVolumeOutputs:
    """
    MEASURE PER-VERTEX VOLUME BETWEEN SURFACES.
    
    Compute the volume of each vertex's area from one surface to another. The
    surfaces must have vertex correspondence, and have consistent triangle
    orientation.
    
    Args:
        inner_surface: the inner surface.
        outer_surface: the outer surface.
        metric: the output metric.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `SurfaceWedgeVolumeOutputs`).
    """
    params = surface_wedge_volume_params(
        inner_surface=inner_surface,
        outer_surface=outer_surface,
        metric=metric,
    )
    return surface_wedge_volume_execute(params, runner)


__all__ = [
    "SURFACE_WEDGE_VOLUME_METADATA",
    "SurfaceWedgeVolumeOutputs",
    "SurfaceWedgeVolumeParamsDict",
    "SurfaceWedgeVolumeParamsDictTagged",
    "surface_wedge_volume",
    "surface_wedge_volume_execute",
    "surface_wedge_volume_params",
]
