Skip to content
On this page

mxcad_2d API 文档 / 2d / McGePoint3dArray

Class: McGePoint3dArray

2d.McGePoint3dArray

表示三维点的数组

Table of contents

Constructors

Properties

Methods

Constructors

constructor

new McGePoint3dArray(imp?)

构造函数。

Example

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

  // 创建一个新的 McGePoint3dArray 实例
  const myArray = new McGePoint3dArray();

  // 通过传入一个对象初始化 McGePoint3dArray
  const initialValues = [
    new McGePoint3d({ x: 1, y: 2, z: 3 }),
    new McGePoint3d({ x: 4, y: 5, z: 6 }),
  ];
  const myArray2 = new McGePoint3dArray(initialValues);

Parameters

NameTypeDescription
imp?object内部实现对象

Properties

imp

imp: any

内部实现对象

Methods

append

append(val): void

添加一个值

Example

ts
import { McGePoint3d, McGePoint3dArray } from "mxcad"

const array = new McGePoint3dArray();
  array.append(new McGePoint3d({ x: 1, y: 2, z: 3 }));
  array.append(new McGePoint3d({ x: 4, y: 5, z: 6 }));

Parameters

NameTypeDescription
valMcGePoint3d三维点对象

Returns

void


at

at(index): McGePoint3d

根据数组索引值得到数据元素的值

Example

ts
import { McGePoint3dArray, McGePoint3d } from "mxcad"

  const array = new McGePoint3dArray();
  array.append(new McGePoint3d({ x: 1, y: 2, z: 3 }));
  array.append(new McGePoint3d({ x: 4, y: 5, z: 6 }));

  const point = array.at(0);
  console.log(point); // 输出: McGePoint3d { x: 1, y: 2, z: 3 }

Parameters

NameTypeDescription
indexnumber数组索引

Returns

McGePoint3d


clear

clear(): void

清空数组

Example

ts
import { McGePoint3dArray, McGePoint3d } from "mxcad"

  const array = new McGePoint3dArray();
  array.append(new McGePoint3d({ x: 1, y: 2, z: 3 }));
  array.append(new McGePoint3d({ x: 4, y: 5, z: 6 }));

  array.clear();
  console.log(array.length()); // 输出: 0

Returns

void


copy

copy(val): McGePoint3dArray

复制对象的值

Example

ts
import { McGePoint3d, McGePoint3dArray } from "mxcad"

  const array1 = new McGePoint3dArray();
  const array2 = new McGePoint3dArray();
  array2.append(new McGePoint3d({ x: 1, y: 2, z: 3 }));
  array2.append(new McGePoint3d({ x: 4, y: 5, z: 6 }));

  // 复制 array2 的值到 array1
  array1.copy(array2);

Parameters

NameTypeDescription
valMcGePoint3dArray | McGePoint3d[]三维点的数组

Returns

McGePoint3dArray


forEach

forEach(call): void

遍历数组

Example

ts
import { McGePoint3dArray, McGePoint3d } from "mxcad"

  const array = new McGePoint3dArray();
  array.append(new McGePoint3d({ x: 1, y: 2, z: 3 }));
  array.append(new McGePoint3d({ x: 4, y: 5, z: 6 }));

  array.forEach((point, index) => {
    console.log(`Index ${index}: Point ${point}`);
  });
  // 输出:
  // Index 0: Point McGePoint3d { x: 1, y: 2, z: 3 }
  // Index 1: Point McGePoint3d { x: 4, y: 5, z: 6 }

Parameters

NameTypeDescription
call(val: McGePoint3d, index: number) => void回调函数

Returns

void


isEmpty

isEmpty(): boolean

返回数组为空

Example

ts
import { McGePoint3dArray, McGePoint3d } from "mxcad"
  const array = new McGePoint3dArray();
  console.log(array.isEmpty()); // 输出: true

  array.append(new McGePoint3d({ x: 1, y: 2, z: 3 }));
  console.log(array.isEmpty()); // 输出: false

Returns

boolean

布尔值


length

length(): number

返回数组长度

Example

ts
import { McGePoint3dArray } from "mxcad"
const array = new McGePoint3dArray();
 console.log(array.length()); // 输出: 0

Returns

number

数组长度


setAt

setAt(index, val): void

通过数组索引设置数据元素的值

Example

ts
import { McGePoint3dArray, McGePoint3d } from "mxcad"

  const array = new McGePoint3dArray();
  array.append(new McGePoint3d({ x: 1, y: 2, z: 3 }));
  array.append(new McGePoint3d({ x: 4, y: 5, z: 6 }));

  array.setAt(0, new McGePoint3d({ x: 7, y: 8, z: 9 }));
  console.log(array.at(0)); // 输出: McGePoint3d { x: 7, y: 8, z: 9 }

Parameters

NameTypeDescription
indexnumber数组索引
valMcGePoint3d三维点对象

Returns

void