Skip to content

mxcad_2d API 文档 / 2d / McGeBound

Class: McGeBound

2d.McGeBound

McGeBound 表示一个三维空间范围边界对象。

Description

该类用于描述一组点所围成的最小/最大边界,常用于计算包围盒、 判断对象范围、进行视图缩放或几何分析。通过 addPoint / addPoints 可以不断扩展边界范围。

Example

ts
import { McGeBound, McGePoint3d } from "mxcad";

const bound = new McGeBound();
bound.addPoint(new McGePoint3d(0, 0, 0));
bound.addPoint(new McGePoint3d(10, 20, 5));

console.log(bound.minPoint.x, bound.minPoint.y, bound.minPoint.z);//获取最小点
console.log(bound.maxPoint.x, bound.maxPoint.y, bound.maxPoint.z);//获取最大点

Table of contents

Constructors

Properties

Methods

Constructors

constructor

new McGeBound(pts?)

构造函数。

Parameters

NameTypeDescription
pts?McGePoint3dArray | McGePoint3d[]三维点数组

Example

ts
import { McGeBound, McGePoint3d } from "mxcad"

  const points = [new McGePoint3d(1, 2, 3), new McGePoint3d(4, 5, 6)];
  const bound = new McGeBound(points);

Properties

isValid

isValid: boolean

是否有效


___

### maxPoint

• **maxPoint**: [`McGePoint3d`](2d.McGePoint3d.md)

最大点

___

### minPoint

• **minPoint**: [`McGePoint3d`](2d.McGePoint3d.md)

最小点

## Methods

### addPoint

▸ **addPoint**(`pt`): `void`

添加一个点

#### Parameters

| Name | Type | Description |
| :------ | :------ | :------ |
| `pt` | [`McGePoint3d`](2d.McGePoint3d.md) | 三维点对象 |

#### Returns

`void`

**`Example`**

```ts
import { McGeBound, McGePoint3d } from "mxcad"
// 创建 McGeBound 实例
 const bound = new McGeBound();
 // 添加一个点到边界
 const point = new McGePoint3d(3, 4, 5);
 bound.addPoint(point);

addPoints

addPoints(pts): void

添加一组点

Parameters

NameTypeDescription
ptsMcGePoint3dArray | McGePoint3d[]三维点对象数组

Returns

void

Example

ts
import { McGeBound } from "mxcad"

  // 创建 McGeBound 实例
  const bound = new McGeBound();

  // 创建一组点
  const points = [new McGePoint3d(1, 2, 3), new McGePoint3d(4, 5, 6), new McGePoint3d(7, 8, 9)];

  // 添加一组点到边界
  bound.addPoints(points);