use crate::face_varying::{all_linear_via_origin, pack, smooth_modes};
use crate::{
FaceVaryingChannel, FaceVaryingInterpolation, KernelError, SchemeOptions, StencilTable,
};
use super::stencils::{LoopLevelData, vertex_stencils_from_level};
pub(crate) fn fvar_stencils_once(
parent: &LoopLevelData,
child: &LoopLevelData,
channel: &FaceVaryingChannel,
mode: FaceVaryingInterpolation,
options: &SchemeOptions,
) -> Result<StencilTable, KernelError> {
let stencils = match mode {
FaceVaryingInterpolation::Linear => all_linear_via_origin(
&parent.mesh,
&parent.topo.edge_vertices,
&child.mesh,
&child.lineage,
channel,
),
FaceVaryingInterpolation::Smooth
| FaceVaryingInterpolation::SmoothWithLinearCorners
| FaceVaryingInterpolation::SmoothWithLinearBoundaries => {
let pos = vertex_stencils_from_level(parent, options);
smooth_modes(
&parent.mesh,
&parent.topo.edge_vertices,
&child.mesh,
&child.lineage,
&pos,
channel,
mode,
)
}
};
Ok(pack(&stencils))
}