Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 | 68x 68x 68x 512x 68x 762x 762x 762x 762x 4635x 4635x 4635x 3565x 3565x 3565x 761x 761x 173x 173x 173x 173x 1416x 1416x 1416x 1416x 1416x 1416x 173x 173x 149x 149x 149x 1402x 149x 3x 3x 3x 3x 3x 101x 101x 101x 12274x 101x 17x 17x 17x 17x 17x 3x 3x 3x 2x 3x 2x 2x 2x 2x 12x 12x 12x 45x 12x | import {
OpenCascadeInstance, TopAbs_ShapeEnum, TopoDS_Edge, TopoDS_Face, TopoDS_Shape,
TopoDS_Shell, TopoDS_Solid, TopoDS_Vertex, TopoDS_Wire
} from "../../../bitbybit-dev-occt/bitbybit-dev-occt";
export class IteratorService {
constructor(
public readonly occ: OpenCascadeInstance,
) { }
forEachWire(shape: TopoDS_Shape, callback: (index: number, wire: TopoDS_Wire) => void): void {
let wireIndex = 0;
const anExplorer = new this.occ.TopExp_Explorer_2(shape,
(this.occ.TopAbs_ShapeEnum.TopAbs_WIRE as TopAbs_ShapeEnum),
(this.occ.TopAbs_ShapeEnum.TopAbs_SHAPE as TopAbs_ShapeEnum));
for (anExplorer.Init(shape,
(this.occ.TopAbs_ShapeEnum.TopAbs_WIRE as TopAbs_ShapeEnum),
(this.occ.TopAbs_ShapeEnum.TopAbs_SHAPE as TopAbs_ShapeEnum)); anExplorer.More(); anExplorer.Next()) {
callback(wireIndex++, this.occ.TopoDS.Wire_2(anExplorer.Current()));
}
anExplorer.delete();
}
forEachEdge(shape: TopoDS_Shape, callback: (index: number, edge: TopoDS_Edge) => void) {
const edgeHashes = {};
let edgeIndex = 0;
const anExplorer = new this.occ.TopExp_Explorer_2(shape,
(this.occ.TopAbs_ShapeEnum.TopAbs_EDGE as TopAbs_ShapeEnum), (this.occ.TopAbs_ShapeEnum.TopAbs_SHAPE as TopAbs_ShapeEnum)
);
for (anExplorer.Init(shape, (this.occ.TopAbs_ShapeEnum.TopAbs_EDGE as TopAbs_ShapeEnum),
(this.occ.TopAbs_ShapeEnum.TopAbs_SHAPE as TopAbs_ShapeEnum));
anExplorer.More();
anExplorer.Next()
) {
const edge = this.occ.TopoDS.Edge_1(anExplorer.Current());
const edgeHash = edge.HashCode(100000000);
if (!Object.prototype.hasOwnProperty.call(edgeHashes, edgeHash)) {
edgeHashes[edgeHash] = edgeIndex;
edgeIndex++;
callback(edgeIndex, edge);
}
}
anExplorer.delete();
return edgeHashes;
}
forEachEdgeAlongWire(shape: TopoDS_Wire, callback: (index: number, edge: TopoDS_Edge) => void) {
const edgeHashes = {};
let edgeIndex = 0;
const anExplorer = new this.occ.BRepTools_WireExplorer_1();
for (anExplorer.Init_1(shape);
anExplorer.More();
anExplorer.Next()
) {
const edge = this.occ.TopoDS.Edge_1(anExplorer.Current());
const edgeHash = edge.HashCode(100000000);
Eif (!Object.prototype.hasOwnProperty.call(edgeHashes, edgeHash)) {
edgeHashes[edgeHash] = edgeIndex;
edgeIndex++;
callback(edgeIndex, edge);
}
}
anExplorer.delete();
return edgeHashes;
}
forEachFace(shape: TopoDS_Shape, callback: (index: number, face: TopoDS_Face) => void): void {
let faceIndex = 0;
const anExplorer = new this.occ.TopExp_Explorer_2(
shape,
(this.occ.TopAbs_ShapeEnum.TopAbs_FACE as TopAbs_ShapeEnum),
(this.occ.TopAbs_ShapeEnum.TopAbs_SHAPE as TopAbs_ShapeEnum)
);
for (anExplorer.Init(shape, (this.occ.TopAbs_ShapeEnum.TopAbs_FACE as TopAbs_ShapeEnum), (this.occ.TopAbs_ShapeEnum.TopAbs_SHAPE as TopAbs_ShapeEnum));
anExplorer.More();
anExplorer.Next()) {
callback(faceIndex++, this.occ.TopoDS.Face_1(anExplorer.Current()));
}
anExplorer.delete();
}
forEachShell(shape: TopoDS_Shape, callback: (index: number, shell: TopoDS_Shell) => void): void {
let faceIndex = 0;
const anExplorer = new this.occ.TopExp_Explorer_2(
shape,
(this.occ.TopAbs_ShapeEnum.TopAbs_SHELL as TopAbs_ShapeEnum),
(this.occ.TopAbs_ShapeEnum.TopAbs_SHAPE as TopAbs_ShapeEnum)
);
for (anExplorer.Init(shape, (this.occ.TopAbs_ShapeEnum.TopAbs_SHELL as TopAbs_ShapeEnum), (this.occ.TopAbs_ShapeEnum.TopAbs_SHAPE as TopAbs_ShapeEnum));
anExplorer.More();
anExplorer.Next()) {
callback(faceIndex++, this.occ.TopoDS.Shell_1(anExplorer.Current()));
}
anExplorer.delete();
}
forEachVertex(shape: TopoDS_Shape, callback: (index: number, vertex: TopoDS_Vertex) => void): void {
let faceIndex = 0;
const anExplorer = new this.occ.TopExp_Explorer_2(
shape,
(this.occ.TopAbs_ShapeEnum.TopAbs_VERTEX as TopAbs_ShapeEnum),
(this.occ.TopAbs_ShapeEnum.TopAbs_SHAPE as TopAbs_ShapeEnum)
);
for (anExplorer.Init(shape, (this.occ.TopAbs_ShapeEnum.TopAbs_VERTEX as TopAbs_ShapeEnum),
(this.occ.TopAbs_ShapeEnum.TopAbs_SHAPE as TopAbs_ShapeEnum));
anExplorer.More();
anExplorer.Next()) {
callback(faceIndex++, this.occ.TopoDS.Vertex_1(anExplorer.Current()));
}
anExplorer.delete();
}
forEachSolid(shape: TopoDS_Shape, callback: (index: number, solid: TopoDS_Solid) => void): void {
let solidIndex = 0;
const anExplorer = new this.occ.TopExp_Explorer_2(shape,
(this.occ.TopAbs_ShapeEnum.TopAbs_SOLID as TopAbs_ShapeEnum),
(this.occ.TopAbs_ShapeEnum.TopAbs_SHAPE as TopAbs_ShapeEnum));
for (anExplorer.Init(shape,
(this.occ.TopAbs_ShapeEnum.TopAbs_SOLID as TopAbs_ShapeEnum),
(this.occ.TopAbs_ShapeEnum.TopAbs_SHAPE as TopAbs_ShapeEnum)); anExplorer.More(); anExplorer.Next()) {
callback(solidIndex++, this.occ.TopoDS.Solid_2(anExplorer.Current()));
}
anExplorer.delete();
}
forEachCompound(shape: TopoDS_Shape, callback: (index: number, shape: TopoDS_Shape) => void): void {
let solidIndex = 0;
const anExplorer = new this.occ.TopExp_Explorer_2(shape,
(this.occ.TopAbs_ShapeEnum.TopAbs_COMPOUND as TopAbs_ShapeEnum),
(this.occ.TopAbs_ShapeEnum.TopAbs_SHAPE as TopAbs_ShapeEnum));
for (anExplorer.Init(shape,
(this.occ.TopAbs_ShapeEnum.TopAbs_COMPOUND as TopAbs_ShapeEnum),
(this.occ.TopAbs_ShapeEnum.TopAbs_SHAPE as TopAbs_ShapeEnum)); anExplorer.More(); anExplorer.Next()) {
callback(solidIndex++, anExplorer.Current());
}
anExplorer.delete();
}
forEachCompSolid(shape: TopoDS_Shape, callback: (index: number, shape: TopoDS_Shape) => void): void {
let solidIndex = 0;
const anExplorer = new this.occ.TopExp_Explorer_2(shape,
(this.occ.TopAbs_ShapeEnum.TopAbs_COMPSOLID as TopAbs_ShapeEnum),
(this.occ.TopAbs_ShapeEnum.TopAbs_SHAPE as TopAbs_ShapeEnum));
for (anExplorer.Init(shape,
(this.occ.TopAbs_ShapeEnum.TopAbs_COMPSOLID as TopAbs_ShapeEnum),
(this.occ.TopAbs_ShapeEnum.TopAbs_SHAPE as TopAbs_ShapeEnum)); anExplorer.More(); anExplorer.Next()) {
callback(solidIndex++, anExplorer.Current());
}
anExplorer.delete();
}
forEachShapeInCompound(shape: TopoDS_Shape, callback: (index: number, shape: TopoDS_Shape) => void): void {
let solidIndex = 0;
const iterator = new this.occ.TopoDS_Iterator_1();
for (iterator.Initialize(shape, true, true); iterator.More(); iterator.Next()) {
callback(solidIndex++, iterator.Value());
}
iterator.delete();
}
}
|