deep-engine-demo/packages/docs/api/manager/ParametricManager.md
2026-04-19 18:46:28 +08:00

397 lines
9.6 KiB
Markdown

---
outline: [2, 3]
---
# ParametricManager
- 源文件:`packages/sdk/src/manager/ParametricManager.ts`
- 文档位置:`packages/docs/api/manager/ParametricManager.md`
## 类:`ParametricManager`
- 作用:参数化对象管理器 管理所有参数化几何体实例,提供统一的查找和管理接口
### 属性
| 属性名 | 可见性 | 类型 | 作用 |
| --- | --- | --- | --- |
| `boxes` | `public` | `ParametricBox[]` | 所有 Box 实例 |
| `cylinders` | `public` | `ParametricCylinder[]` | 所有 Cylinder 实例 |
| `spheres` | `public` | `ParametricSphere[]` | 所有 Sphere 实例 |
| `arches` | `public` | `ParametricArch[]` | 所有 Arch 实例 |
| `pipes` | `public` | `ParametricPipe[]` | 所有 Pipe 实例 |
### 方法
#### `addBox(box: ParametricBox): void`
- 作用:添加 Box 实例
- 入参:
| 参数名 | 类型 | 必填 | 说明 |
| --- | --- | --- | --- |
| `box` | `ParametricBox` | 是 | 参数 `box`,类型为 `ParametricBox`。 |
- 出参:`void`
- 返回说明:无返回值。
#### `removeBox(box: ParametricBox): void`
- 作用:移除 Box 实例
- 入参:
| 参数名 | 类型 | 必填 | 说明 |
| --- | --- | --- | --- |
| `box` | `ParametricBox` | 是 | 参数 `box`,类型为 `ParametricBox`。 |
- 出参:`void`
- 返回说明:无返回值。
#### `addCylinder(cylinder: ParametricCylinder): void`
- 作用:添加 Cylinder 实例
- 入参:
| 参数名 | 类型 | 必填 | 说明 |
| --- | --- | --- | --- |
| `cylinder` | `ParametricCylinder` | 是 | 参数 `cylinder`,类型为 `ParametricCylinder`。 |
- 出参:`void`
- 返回说明:无返回值。
#### `removeCylinder(cylinder: ParametricCylinder): void`
- 作用:移除 Cylinder 实例
- 入参:
| 参数名 | 类型 | 必填 | 说明 |
| --- | --- | --- | --- |
| `cylinder` | `ParametricCylinder` | 是 | 参数 `cylinder`,类型为 `ParametricCylinder`。 |
- 出参:`void`
- 返回说明:无返回值。
#### `addSphere(sphere: ParametricSphere): void`
- 作用:添加 Sphere 实例
- 入参:
| 参数名 | 类型 | 必填 | 说明 |
| --- | --- | --- | --- |
| `sphere` | `ParametricSphere` | 是 | 参数 `sphere`,类型为 `ParametricSphere`。 |
- 出参:`void`
- 返回说明:无返回值。
#### `removeSphere(sphere: ParametricSphere): void`
- 作用:移除 Sphere 实例
- 入参:
| 参数名 | 类型 | 必填 | 说明 |
| --- | --- | --- | --- |
| `sphere` | `ParametricSphere` | 是 | 参数 `sphere`,类型为 `ParametricSphere`。 |
- 出参:`void`
- 返回说明:无返回值。
#### `addArch(arch: ParametricArch): void`
- 作用:添加 Arch 实例
- 入参:
| 参数名 | 类型 | 必填 | 说明 |
| --- | --- | --- | --- |
| `arch` | `ParametricArch` | 是 | 参数 `arch`,类型为 `ParametricArch`。 |
- 出参:`void`
- 返回说明:无返回值。
#### `removeArch(arch: ParametricArch): void`
- 作用:移除 Arch 实例
- 入参:
| 参数名 | 类型 | 必填 | 说明 |
| --- | --- | --- | --- |
| `arch` | `ParametricArch` | 是 | 参数 `arch`,类型为 `ParametricArch`。 |
- 出参:`void`
- 返回说明:无返回值。
#### `addPipe(pipe: ParametricPipe): void`
- 作用:添加 Pipe 实例
- 入参:
| 参数名 | 类型 | 必填 | 说明 |
| --- | --- | --- | --- |
| `pipe` | `ParametricPipe` | 是 | 参数 `pipe`,类型为 `ParametricPipe`。 |
- 出参:`void`
- 返回说明:无返回值。
#### `removePipe(pipe: ParametricPipe): void`
- 作用:移除 Pipe 实例
- 入参:
| 参数名 | 类型 | 必填 | 说明 |
| --- | --- | --- | --- |
| `pipe` | `ParametricPipe` | 是 | 参数 `pipe`,类型为 `ParametricPipe`。 |
- 出参:`void`
- 返回说明:无返回值。
#### `findPipe(predicate: (pipe: ParametricPipe) => boolean): ParametricPipe | null`
- 作用:查找第一个符合条件的 Pipe
- 入参:
| 参数名 | 类型 | 必填 | 说明 |
| --- | --- | --- | --- |
| `predicate` | `(pipe: ParametricPipe) => boolean` | 是 | - 过滤条件函数 |
- 出参:`ParametricPipe \| null`
- 返回说明:找到的 Pipe 实例或 null
#### `findAllPipes(predicate: (pipe: ParametricPipe) => boolean): ParametricPipe[]`
- 作用:查找所有符合条件的 Pipe
- 入参:
| 参数名 | 类型 | 必填 | 说明 |
| --- | --- | --- | --- |
| `predicate` | `(pipe: ParametricPipe) => boolean` | 是 | - 过滤条件函数 |
- 出参:`ParametricPipe[]`
- 返回说明:符合条件的 Pipe 实例数组
#### `findPipeByMetadata(key: string, value: any): ParametricPipe | null`
- 作用:根据 metadata 查找 Pipe
- 入参:
| 参数名 | 类型 | 必填 | 说明 |
| --- | --- | --- | --- |
| `key` | `string` | 是 | - metadata 的键 |
| `value` | `any` | 是 | - metadata 的值 |
- 出参:`ParametricPipe \| null`
- 返回说明:找到的 Pipe 实例或 null
#### `findAllPipesByMetadata(key: string, value: any): ParametricPipe[]`
- 作用:根据 metadata 查找所有 Pipe
- 入参:
| 参数名 | 类型 | 必填 | 说明 |
| --- | --- | --- | --- |
| `key` | `string` | 是 | - metadata 的键 |
| `value` | `any` | 是 | - metadata 的值 |
- 出参:`ParametricPipe[]`
- 返回说明:符合条件的 Pipe 实例数组
#### `findPipeByName(name: string): ParametricPipe | null`
- 作用:根据名称查找 Pipe
- 入参:
| 参数名 | 类型 | 必填 | 说明 |
| --- | --- | --- | --- |
| `name` | `string` | 是 | - mesh 的名称 |
- 出参:`ParametricPipe \| null`
- 返回说明:找到的 Pipe 实例或 null
#### `findBox(predicate: (box: ParametricBox) => boolean): ParametricBox | null`
- 作用:查找第一个符合条件的 Box
- 入参:
| 参数名 | 类型 | 必填 | 说明 |
| --- | --- | --- | --- |
| `predicate` | `(box: ParametricBox) => boolean` | 是 | - 过滤条件函数 |
- 出参:`ParametricBox \| null`
- 返回说明:找到的 Box 实例或 null
#### `findAllBoxes(predicate: (box: ParametricBox) => boolean): ParametricBox[]`
- 作用:查找所有符合条件的 Box
- 入参:
| 参数名 | 类型 | 必填 | 说明 |
| --- | --- | --- | --- |
| `predicate` | `(box: ParametricBox) => boolean` | 是 | - 过滤条件函数 |
- 出参:`ParametricBox[]`
- 返回说明:符合条件的 Box 实例数组
#### `findCylinder(predicate: (cylinder: ParametricCylinder) => boolean): ParametricCylinder | null`
- 作用:查找第一个符合条件的 Cylinder
- 入参:
| 参数名 | 类型 | 必填 | 说明 |
| --- | --- | --- | --- |
| `predicate` | `(cylinder: ParametricCylinder) => boolean` | 是 | - 过滤条件函数 |
- 出参:`ParametricCylinder \| null`
- 返回说明:找到的 Cylinder 实例或 null
#### `findAllCylinders(predicate: (cylinder: ParametricCylinder) => boolean): ParametricCylinder[]`
- 作用:查找所有符合条件的 Cylinder
- 入参:
| 参数名 | 类型 | 必填 | 说明 |
| --- | --- | --- | --- |
| `predicate` | `(cylinder: ParametricCylinder) => boolean` | 是 | - 过滤条件函数 |
- 出参:`ParametricCylinder[]`
- 返回说明:符合条件的 Cylinder 实例数组
#### `findSphere(predicate: (sphere: ParametricSphere) => boolean): ParametricSphere | null`
- 作用:查找第一个符合条件的 Sphere
- 入参:
| 参数名 | 类型 | 必填 | 说明 |
| --- | --- | --- | --- |
| `predicate` | `(sphere: ParametricSphere) => boolean` | 是 | - 过滤条件函数 |
- 出参:`ParametricSphere \| null`
- 返回说明:找到的 Sphere 实例或 null
#### `findAllSpheres(predicate: (sphere: ParametricSphere) => boolean): ParametricSphere[]`
- 作用:查找所有符合条件的 Sphere
- 入参:
| 参数名 | 类型 | 必填 | 说明 |
| --- | --- | --- | --- |
| `predicate` | `(sphere: ParametricSphere) => boolean` | 是 | - 过滤条件函数 |
- 出参:`ParametricSphere[]`
- 返回说明:符合条件的 Sphere 实例数组
#### `findArch(predicate: (arch: ParametricArch) => boolean): ParametricArch | null`
- 作用:查找第一个符合条件的 Arch
- 入参:
| 参数名 | 类型 | 必填 | 说明 |
| --- | --- | --- | --- |
| `predicate` | `(arch: ParametricArch) => boolean` | 是 | - 过滤条件函数 |
- 出参:`ParametricArch \| null`
- 返回说明:找到的 Arch 实例或 null
#### `findAllArches(predicate: (arch: ParametricArch) => boolean): ParametricArch[]`
- 作用:查找所有符合条件的 Arch
- 入参:
| 参数名 | 类型 | 必填 | 说明 |
| --- | --- | --- | --- |
| `predicate` | `(arch: ParametricArch) => boolean` | 是 | - 过滤条件函数 |
- 出参:`ParametricArch[]`
- 返回说明:符合条件的 Arch 实例数组
#### `clearBoxes(): void`
- 作用:清空所有 Box 实例
- 入参:无
- 出参:`void`
- 返回说明:无返回值。
#### `clearCylinders(): void`
- 作用:清空所有 Cylinder 实例
- 入参:无
- 出参:`void`
- 返回说明:无返回值。
#### `clearSpheres(): void`
- 作用:清空所有 Sphere 实例
- 入参:无
- 出参:`void`
- 返回说明:无返回值。
#### `clearArches(): void`
- 作用:清空所有 Arch 实例
- 入参:无
- 出参:`void`
- 返回说明:无返回值。
#### `clearPipes(): void`
- 作用:清空所有 Pipe 实例
- 入参:无
- 出参:`void`
- 返回说明:无返回值。
#### `clearAll(): void`
- 作用:清空所有参数化对象
- 入参:无
- 出参:`void`
- 返回说明:无返回值。
#### `getTotalCount(): number`
- 作用:获取所有参数化对象的总数
- 入参:无
- 出参:`number`
- 返回说明:返回数值结果。
## 构造示例
- 当前 Demo 中没有直接展示 `ParametricManager` 的构造调用。
## 函数示例
- 当前 Demo 中没有直接展示 `ParametricManager` 的公开方法调用。