[mxcad_2d API documentation] (../README. md)/[2d] (../modules/2d. md)/McGePoint3dArray
Class: McGePoint3dArray
2d.McGePoint3dArray
Array representing three-dimensional points
Table of contents
Constructors
Properties
Methods
Constructors
constructor
• new McGePoint3dArray(imp?, isDestroyImp?)
Constructor.
Parameters
| Name | Type | Description |
|---|---|---|
imp? | object | Internal implementation object |
isDestroyImp? | boolean | - |
Example
import { McGePoint3dArray, McGePoint3d } from "mxcad";
//Create a new instance of McGePoint3dArray
const myArray = new McGePoint3dArray();
//Initialize McGePoint3dArray by passing in an object
const initialValues = [
new McGePoint3d({ x: 1, y: 2, z: 3 }),
new McGePoint3d({ x: 4, y: 5, z: 6 }),
];
const myArray2 = new McGePoint3dArray(initialValues);Properties
imp
• imp: any
Internal implementation object
Methods
append
▸ append(val): void
Add a value
Parameters
| Name | Type | Description |
|---|---|---|
| Val | [McGePoint3d] (2d. McGePoint3d. md) | 3D point object |
Returns
void
Example
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 }));at
▸ at(index): McGePoint3d
Obtain the value of a data element based on the array index value
Parameters
| Name | Type | Description |
|---|---|---|
| Index | number | array index |
Returns
Example
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); //Output: McGePoint3d {x: 1, y: 2, z: 3}clear
▸ clear(): void
Clear the array
Returns
void
Example
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()); //Output: 0copy
▸ copy(val): McGePoint3dArray
Copy the value of the object
Parameters
| Name | Type | Description |
|---|---|---|
val | McGePoint3dArray | McGePoint3d[] | Array of 3D points |
Returns
Example
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 }));
//Copy the value of array2 to array1
array1.copy(array2);forEach
▸ forEach(call): void
iterate through an array
Parameters
| Name | Type | Description |
|---|---|---|
call | (val: McGePoint3d, index: number) => void | Callback function |
Returns
void
Example
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}`);
});
//Output:
// Index 0: Point McGePoint3d { x: 1, y: 2, z: 3 }
// Index 1: Point McGePoint3d { x: 4, y: 5, z: 6 }isEmpty
▸ isEmpty(): boolean
Return an empty array
Returns
boolean
Boolean value
Example
import { McGePoint3dArray, McGePoint3d } from "mxcad"
const array = new McGePoint3dArray();
console.log(array.isEmpty()); //Output: true
array.append(new McGePoint3d({ x: 1, y: 2, z: 3 }));
console.log(array.isEmpty()); //Output: falselength
▸ length(): number
Return the length of the array
Returns
number
array length
Example
import { McGePoint3dArray } from "mxcad"
const array = new McGePoint3dArray();
console.log(array.length()); //Output: 0setAt
▸ setAt(index, val): void
Set the value of data elements through array indexing
Parameters
| Name | Type | Description |
|---|---|---|
| Index | number | array index |
| Val | [McGePoint3d] (2d. McGePoint3d. md) | 3D point object |
Returns
void
Example
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)); //Output: McGePoint3d {x: 7, y: 8, z: 9}