Hide menu
Loading...
Searching...
No Matches
ShapeIterator

Iterates over child shapes of a B-Rep shape or shape-based body.

The iterator supports two usage scenarios:

  • iteration over direct children;
  • iteration over subshapes of a specified type.

To retrieve direct children of a shape, ShapeIterator should be used as follows:

const face = ...;
for (let child of new ShapeIterator (face)) {
const type = child.type;
}

To retrieve subshapes of a particular type, ShapeIterator should be used by specifying a type of interest as follows:

const solid = ...;
for (let child of new ShapeIterator (solid, ShapeType.FACE)) {
// "child" has Face type
}

When using the latter approach, exploration is performed by traversing the graph of subshapes in a depth-first manner. Each subshape will be found as many times as it is registered in the parent subshape.

The order of returned subshapes is deterministic and corresponds to the order in which the subshapes were added during construction.

When constructed from a MeshBody, the iterator is empty because mesh bodies do not expose B-Rep shapes.

Extends

Implements

Constructors

Constructor

new ShapeIterator(shape, type?): ShapeIterator

Creates an iterator over a shape.

Parameters

shape

Shape

Parent B-Rep shape.

type?

ShapeType

Type of iterated shapes.

Returns

ShapeIterator

Overrides

BaseObject.constructor

Constructor

new ShapeIterator(body, shapeType?): ShapeIterator

Creates an iterator over a body.

Parameters

body

Body

Parent body.

shapeType?

ShapeType

Type of iterated shape.

Returns

ShapeIterator

Overrides

BaseObject.constructor

Accessors

id

Get Signature

get id(): bigint

Returns the unique identifier of the object.

Returns

bigint

Inherited from

BaseObject.id

Methods

[iterator]()

‍**[iterator]**(): Iterator<Shape, Shape>

Returns the iterator itself.

Returns

Iterator<Shape, Shape>

Implementation of

Iterable.[iterator]


next()

next(): IteratorResult<Shape, Shape>

Returns the next iterated shape.

Returns

IteratorResult<Shape, Shape>