[mxcad_2d API documentation] (../README. md)/[2d] (../modules/2d. md)/McGeBound
Class: McGeBound
2d.McGeBound
McGeBound represents a three-dimensional spatial boundary object.
Description
This class is used to describe the minimum/maximum boundary enclosed by a set of points and is commonly used to calculate bounding boxes Determine the scope of the object, perform view scaling or geometric analysis. By using addPoint/addPoints, the boundary range can be continuously expanded.
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); //Obtain the minimum point
console.log(bound.maxPoint.x, bound.maxPoint.y, bound.maxPoint.z); //Obtain the maximum pointTable of contents
Constructors
Properties
Methods
Constructors
constructor
• new McGeBound(pts?)
Constructor.
Parameters
| Name | Type | Description |
|---|---|---|
pts? | McGePoint3dArray (2d. McGePoint3dArray. md) \ | McGePoint3d (2d. McGePoint3d. md) [] |
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
Is it effective
___
### maxPoint
• **maxPoint**: [`McGePoint3d`](2d.McGePoint3d.md)
Maximum point
___
### minPoint
• **minPoint**: [`McGePoint3d`](2d.McGePoint3d.md)
Minimum point
## Methods
### addPoint
▸ **addPoint**(`pt`): `void`
Add a point
#### Parameters
| Name | Type | Description |
| :------ | :------ | :------ |
|Pt | McGePoint3d (2d. McGePoint3d. md) | 3D point object|
#### Returns
`void`
**`Example`**
```ts
import { McGeBound, McGePoint3d } from "mxcad"
//Create a McGeBound instance
const bound = new McGeBound();
//Add a point to the boundary
const point = new McGePoint3d(3, 4, 5);
bound.addPoint(point);addPoints
▸ addPoints(pts): void
Add a set of points
Parameters
| Name | Type | Description |
|---|---|---|
| Pts | McGePoint3dArray (2d. McGePoint3dArray. md) \ | McGePoint3d (2d. McGePoint3d. md) [] |
Returns
void
Example
ts
import { McGeBound } from "mxcad"
//Create a McGeBound instance
const bound = new McGeBound();
//Create a set of points
const points = [new McGePoint3d(1, 2, 3), new McGePoint3d(4, 5, 6), new McGePoint3d(7, 8, 9)];
//Add a set of points to the boundary
bound.addPoints(points);