mirror of
https://github.com/xibyte/jsketcher
synced 2025-12-10 02:13:58 +01:00
32 lines
584 B
JavaScript
32 lines
584 B
JavaScript
import {Vertex} from './topo/vertex';
|
|
import {veqXYZ} from 'geom/tolerance';
|
|
import {Point} from 'geom/point';
|
|
|
|
export default class VertexFactory {
|
|
|
|
constructor() {
|
|
this.vertices = [];
|
|
}
|
|
|
|
get(_x, _y, _z) {
|
|
for (let vertex of this.vertices) {
|
|
let {x, y, z} = vertex.point;
|
|
if (veqXYZ(_x, _y, _z, x, y, z)) {
|
|
return vertex;
|
|
}
|
|
}
|
|
let v = new Vertex(new Point(_x, _y, _z));
|
|
this.vertices.push(v);
|
|
return v;
|
|
}
|
|
|
|
getPoint({x, y, z}) {
|
|
return this.get(x, y, z);
|
|
}
|
|
|
|
getData([x, y, z]) {
|
|
return this.get(x, y, z);
|
|
}
|
|
}
|
|
|
|
|