114 lines
4.8 KiB
TypeScript
114 lines
4.8 KiB
TypeScript
|
|
import type { FdiToothId } from '@/types/treatment';
|
||
|
|
import type { ToothShapeKind } from '@/components/treatment/fdiToothMeta';
|
||
|
|
|
||
|
|
export interface ToothPathModel {
|
||
|
|
crown: string;
|
||
|
|
roots: string[];
|
||
|
|
/** Occlusal groove etc. — open path, stroke only */
|
||
|
|
detailStroke?: { d: string; widthScale: number };
|
||
|
|
}
|
||
|
|
|
||
|
|
/** FDI-specific closed paths for the clinical (gradient) chart. Wireframe uses `getTextbookToothPathModel`. */
|
||
|
|
export function getToothPathModel(fdi: FdiToothId, kind: ToothShapeKind, upper?: boolean): ToothPathModel | null {
|
||
|
|
const lastDigit = Number(fdi[1]);
|
||
|
|
const isThirdMolar = lastDigit === 8;
|
||
|
|
const isSecondMolar = lastDigit === 7;
|
||
|
|
const isFirstMolar = lastDigit === 6;
|
||
|
|
const isCentralIncisor = lastDigit === 1;
|
||
|
|
const isLateralIncisor = lastDigit === 2;
|
||
|
|
|
||
|
|
switch (kind) {
|
||
|
|
case 'incisor':
|
||
|
|
if (isLateralIncisor) {
|
||
|
|
return {
|
||
|
|
crown: 'M12 9 C14 6, 22 6, 24 9 C26 12, 26 25, 23 30 C21 32, 15 32, 13 30 C10 25, 10 12, 12 9 Z',
|
||
|
|
roots: ['M15.5 30 C14.5 40, 14.5 51, 16 60 C17 65, 19 65, 20 60 C21.5 51, 21.5 40, 20.5 30 Z'],
|
||
|
|
};
|
||
|
|
}
|
||
|
|
return {
|
||
|
|
crown: 'M11 8 C13 5, 23 5, 25 8 C27 12, 27 26, 24 31 C22 33, 14 33, 12 31 C9 26, 9 12, 11 8 Z',
|
||
|
|
roots: ['M15 31 C14 42, 14 53, 16 63 C17 68, 19 68, 20 63 C22 53, 22 42, 21 31 Z'],
|
||
|
|
};
|
||
|
|
case 'canine':
|
||
|
|
return {
|
||
|
|
crown: 'M18 6 C22 6, 25 10, 26 15 C26 20, 24 30, 22 33 C20 35, 16 35, 14 33 C12 30, 10 20, 10 15 C11 10, 14 6, 18 6 Z',
|
||
|
|
roots: ['M16 33 C14 44, 13 55, 14 66 C15 72, 18 75, 20 66 C21 55, 20 44, 20 33 Z'],
|
||
|
|
};
|
||
|
|
case 'premolar':
|
||
|
|
if (upper && lastDigit === 4) {
|
||
|
|
return {
|
||
|
|
crown: 'M9 12 C11 8, 15 7, 18 9 C21 7, 25 8, 27 12 C29 16, 29 25, 26 31 C24 34, 12 34, 10 31 C7 25, 7 16, 9 12 Z',
|
||
|
|
roots: [
|
||
|
|
'M13 31 C12 39, 12 48, 13 56 C14 62, 16 64, 17 58 C18 54, 18 48, 18 41 Z',
|
||
|
|
'M23 31 C24 39, 24 48, 23 56 C22 62, 20 64, 19 58 C18 54, 18 48, 18 41 Z',
|
||
|
|
],
|
||
|
|
};
|
||
|
|
}
|
||
|
|
return {
|
||
|
|
crown: 'M9 12 C11 8, 15 7, 18 9 C21 7, 25 8, 27 12 C29 16, 29 26, 26 31 C24 34, 12 34, 10 31 C7 26, 7 16, 9 12 Z',
|
||
|
|
roots: ['M16 31 C15 42, 15 53, 16 62 C17 67, 19 67, 20 62 C21 53, 21 42, 20 31 Z'],
|
||
|
|
};
|
||
|
|
case 'molar':
|
||
|
|
if (isThirdMolar) {
|
||
|
|
const crown =
|
||
|
|
'M9 15 C11 11, 14 10, 17 11 C20 9, 24 10, 26 14 C28 18, 28 26, 25 31 C23 33, 11 33, 9 31 C6 26, 6 19, 9 15 Z';
|
||
|
|
if (upper) {
|
||
|
|
return {
|
||
|
|
crown,
|
||
|
|
roots: [
|
||
|
|
'M14 32 C13 39, 13 47, 14 54 C15 59, 17 61, 18 55 C19 50, 19 41, 18 33 Z',
|
||
|
|
'M22 32 C23 39, 23 47, 22 54 C21 59, 19 61, 18 55 C17 50, 17 41, 18 33 Z',
|
||
|
|
],
|
||
|
|
};
|
||
|
|
}
|
||
|
|
return {
|
||
|
|
crown,
|
||
|
|
roots: [
|
||
|
|
'M14 32 C12 39, 12 47, 13 55 C14 61, 16 64, 18 57 C19 52, 19 44, 18 36 Z',
|
||
|
|
'M22 32 C24 39, 24 47, 23 55 C22 61, 20 64, 18 57 C17 52, 17 44, 18 36 Z',
|
||
|
|
],
|
||
|
|
};
|
||
|
|
}
|
||
|
|
if (isSecondMolar && upper) {
|
||
|
|
return {
|
||
|
|
crown: 'M8 14 C10 9, 13 8, 16 10 C18 8, 21 8, 23 10 C26 8, 29 9, 30 14 C31 18, 31 27, 28 32 C26 35, 10 35, 8 32 C5 27, 5 18, 8 14 Z',
|
||
|
|
roots: [
|
||
|
|
'M11 35 C9 43, 9 50, 10 57 C11 62, 13 64, 14 58 C15 52, 15 44, 14 36 Z',
|
||
|
|
'M18 35 C17 44, 17 52, 18 60 C19 66, 20 66, 21 60 C22 52, 22 44, 21 35 Z',
|
||
|
|
'M25 35 C27 43, 27 50, 26 57 C25 62, 23 64, 22 58 C21 52, 21 44, 22 36 Z',
|
||
|
|
],
|
||
|
|
};
|
||
|
|
}
|
||
|
|
if (isFirstMolar && !upper) {
|
||
|
|
return {
|
||
|
|
crown: 'M7 14 C9 9, 13 8, 16 10 C18 8, 21 8, 23 10 C26 8, 30 9, 31 14 C32 18, 32 27, 29 32 C27 35, 9 35, 7 32 C4 27, 4 18, 7 14 Z',
|
||
|
|
roots: [
|
||
|
|
'M11 35 C9 43, 9 50, 10 58 C11 64, 14 67, 16 60 C17 56, 17 50, 17 44 Z',
|
||
|
|
'M25 35 C27 43, 27 50, 26 58 C25 64, 22 67, 20 60 C19 56, 19 50, 19 44 Z',
|
||
|
|
],
|
||
|
|
detailStroke: { d: 'M15 61 Q18 66 21 61', widthScale: 0.85 },
|
||
|
|
};
|
||
|
|
}
|
||
|
|
if (upper) {
|
||
|
|
return {
|
||
|
|
crown: 'M7 14 C9 9, 13 8, 16 10 C18 8, 21 8, 23 10 C26 8, 30 9, 31 14 C32 18, 32 27, 29 32 C27 35, 9 35, 7 32 C4 27, 4 18, 7 14 Z',
|
||
|
|
roots: [
|
||
|
|
'M11 35 C9 43, 9 50, 10 57 C11 62, 13 64, 14 58 C15 52, 15 44, 14 36 Z',
|
||
|
|
'M18 35 C17 44, 17 52, 18 60 C19 66, 20 66, 21 60 C22 52, 22 44, 21 35 Z',
|
||
|
|
'M25 35 C27 43, 27 50, 26 57 C25 62, 23 64, 22 58 C21 52, 21 44, 22 36 Z',
|
||
|
|
],
|
||
|
|
};
|
||
|
|
}
|
||
|
|
return {
|
||
|
|
crown: 'M7 14 C9 9, 13 8, 16 10 C18 8, 21 8, 23 10 C26 8, 30 9, 31 14 C32 18, 32 27, 29 32 C27 35, 9 35, 7 32 C4 27, 4 18, 7 14 Z',
|
||
|
|
roots: [
|
||
|
|
'M11 35 C9 43, 9 50, 10 58 C11 64, 14 67, 16 60 C17 56, 17 50, 17 44 Z',
|
||
|
|
'M25 35 C27 43, 27 50, 26 58 C25 64, 22 67, 20 60 C19 56, 19 50, 19 44 Z',
|
||
|
|
],
|
||
|
|
detailStroke: { d: 'M15 61 Q18 66 21 61', widthScale: 0.85 },
|
||
|
|
};
|
||
|
|
default:
|
||
|
|
return null;
|
||
|
|
}
|
||
|
|
}
|