/ concept-collection / mesh-studio
Sign in
concept-collection / mesh-studio
mesh-studio / src / sources.ts
67 lines · 1.6 KBBlameHistoryRaw
1/**
2 * Registry of built-in primitive sources. Each entry knows how to build its
3 * OCCT shape; the app hands the shape to `buildModel` (src/occ/extract.ts).
4 */
5import type { OpenCascade, Shape } from './occ/types'
6import {
7 makeBottle,
8 makeBox,
9 makeCone,
10 makeCylinder,
11 makeFilletBox,
12 makeSphere,
13 makeTorus,
14} from './occ/primitives'
16export interface PrimitiveSource {
17 id: string
18 label: string
19 /** One-line note about the kind of faces this produces. */
20 blurb: string
21 build: (oc: OpenCascade) => Shape
24export const primitives: PrimitiveSource[] = [
25 {
26 id: 'sphere',
27 label: 'Sphere',
28 blurb: 'One analytic spherical face — a single rational patch after NURBS conversion.',
29 build: (oc) => makeSphere(oc),
30 },
31 {
32 id: 'torus',
33 label: 'Torus',
34 blurb: 'A toroidal face, periodic in both parameters.',
35 build: (oc) => makeTorus(oc),
36 },
37 {
38 id: 'cylinder',
39 label: 'Cylinder',
40 blurb: 'Cylindrical side face capped by two planar disks.',
41 build: (oc) => makeCylinder(oc),
42 },
43 {
44 id: 'cone',
45 label: 'Cone',
46 blurb: 'A truncated cone — conical face plus caps.',
47 build: (oc) => makeCone(oc),
48 },
49 {
50 id: 'box',
51 label: 'Box',
52 blurb: 'Six planar faces — degree (1,1) NURBS patches.',
53 build: (oc) => makeBox(oc),
54 },
55 {
56 id: 'fillet-box',
57 label: 'Rounded box',
58 blurb: 'Box with rounded edges — introduces free-form NURBS fillet faces.',
59 build: (oc) => makeFilletBox(oc),
60 },
61 {
62 id: 'bottle',
63 label: 'Bottle',
64 blurb: 'The OpenCASCADE tutorial bottle: mixed planar, swept and fused faces.',
65 build: (oc) => makeBottle(oc),
66 },
moveopenescclose