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

import typing
import pathlib
from styxdefs import *

SURFACE_FLIP_NORMALS_METADATA = Metadata(
    id="8c4d88c8e5e251d057b6e23e7ae572f3f1462cc3.boutiques",
    name="surface-flip-normals",
    package="workbench",
    container_image_tag="brainlife/connectome_workbench:1.5.0-freesurfer-update",
)


SurfaceFlipNormalsParameters = typing.TypedDict('SurfaceFlipNormalsParameters', {
    "@type": typing.NotRequired[typing.Literal["workbench/surface-flip-normals"]],
    "surface": InputPathType,
    "surface_out": str,
})
SurfaceFlipNormalsParametersTagged = typing.TypedDict('SurfaceFlipNormalsParametersTagged', {
    "@type": typing.Literal["workbench/surface-flip-normals"],
    "surface": InputPathType,
    "surface_out": str,
})


class SurfaceFlipNormalsOutputs(typing.NamedTuple):
    """
    Output object returned when calling `SurfaceFlipNormalsParameters(...)`.
    """
    root: OutputPathType
    """Output root folder. This is the root folder for all outputs."""
    surface_out: OutputPathType
    """the output surface"""


def surface_flip_normals_params(
    surface: InputPathType,
    surface_out: str,
) -> SurfaceFlipNormalsParametersTagged:
    """
    Build parameters.
    
    Args:
        surface: the surface to flip the normals of.
        surface_out: the output surface.
    Returns:
        Parameter dictionary
    """
    params = {
        "@type": "workbench/surface-flip-normals",
        "surface": surface,
        "surface_out": surface_out,
    }
    return params


def surface_flip_normals_cargs(
    params: SurfaceFlipNormalsParameters,
    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.append("wb_command")
    cargs.append("-surface-flip-normals")
    cargs.append(execution.input_file(params.get("surface", None)))
    cargs.append(params.get("surface_out", None))
    return cargs


def surface_flip_normals_outputs(
    params: SurfaceFlipNormalsParameters,
    execution: Execution,
) -> SurfaceFlipNormalsOutputs:
    """
    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 = SurfaceFlipNormalsOutputs(
        root=execution.output_file("."),
        surface_out=execution.output_file(params.get("surface_out", None)),
    )
    return ret


def surface_flip_normals_execute(
    params: SurfaceFlipNormalsParameters,
    runner: Runner | None = None,
) -> SurfaceFlipNormalsOutputs:
    """
    surface-flip-normals
    
    Flip all tiles on a surface.
    
    Flips all triangles on a surface, resulting in surface normals being flipped
    the other direction (inward vs outward). If you transform a surface with an
    affine that has negative determinant, or a warpfield that similarly flips
    the surface, you may end up with a surface that has normals pointing
    inwards, which may have display problems. Using this command will solve that
    problem.
    
    Author: Connectome Workbench Developers
    
    URL: https://github.com/Washington-University/workbench
    
    Args:
        params: The parameters.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `SurfaceFlipNormalsOutputs`).
    """
    runner = runner or get_global_runner()
    execution = runner.start_execution(SURFACE_FLIP_NORMALS_METADATA)
    params = execution.params(params)
    cargs = surface_flip_normals_cargs(params, execution)
    ret = surface_flip_normals_outputs(params, execution)
    execution.run(cargs)
    return ret


def surface_flip_normals(
    surface: InputPathType,
    surface_out: str,
    runner: Runner | None = None,
) -> SurfaceFlipNormalsOutputs:
    """
    surface-flip-normals
    
    Flip all tiles on a surface.
    
    Flips all triangles on a surface, resulting in surface normals being flipped
    the other direction (inward vs outward). If you transform a surface with an
    affine that has negative determinant, or a warpfield that similarly flips
    the surface, you may end up with a surface that has normals pointing
    inwards, which may have display problems. Using this command will solve that
    problem.
    
    Author: Connectome Workbench Developers
    
    URL: https://github.com/Washington-University/workbench
    
    Args:
        surface: the surface to flip the normals of.
        surface_out: the output surface.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `SurfaceFlipNormalsOutputs`).
    """
    params = surface_flip_normals_params(
        surface=surface,
        surface_out=surface_out,
    )
    return surface_flip_normals_execute(params, runner)


__all__ = [
    "SURFACE_FLIP_NORMALS_METADATA",
    "SurfaceFlipNormalsOutputs",
    "surface_flip_normals",
    "surface_flip_normals_execute",
    "surface_flip_normals_params",
]
