# `Fun_GetCalcMaterialsKs1` (function) - **Type:** FUNCTION - **Returns:** `int` - **Deterministic:** NO - **SQL data access:** CONTAINS SQL ## Parameters | # | Mode | Name | Type | |---|---|---|---| | 1 | IN | `dMatLength` | `decimal(18,6)` | | 2 | IN | `dMatWidth` | `decimal(18,6)` | | 3 | IN | `dLength` | `decimal(18,6)` | | 4 | IN | `dWidth` | `decimal(18,6)` | | 5 | IN | `iMinusL` | `int` | | 6 | IN | `iMinusW` | `int` | ## Body _Body is not pre-cached. To inspect: `mysql --defaults-file=~/.my.cnf -e 'SHOW CREATE FUNCTION `Fun_GetCalcMaterialsKs1`'`._ ## Narrative **Business context:** Mixed-orientation `Ks` (开数, ups count) variant of `Fun_GetCalcMaterialsKs`. Computes how many finished pieces can be cut from a parent sheet using a vertical-then-horizontal hybrid layout, with optional row/column deductions (`iMinusL`, `iMinusW`) to reserve gripper/trim margins. **What it does:** normalizes long/short sides of both parent and piece. Computes two candidate tile counts: vertical-row (`(L div pL - iMinusL) * (W div pW)`) and horizontal-row (`(L div pW) * (W div pL - iMinusW)`), each augmented with a "leftover strip" rotated-piece bonus when the residual width fits. Returns the larger of the two, clamped at 0. **Invocation:** referenced by `Fun_GetCalcMaterialsKs` — but only inside commented-out lines (variant comparison was disabled). With those branches dormant, this function has no live caller in any channel — candidate for maintainer audit.