jsketcher/web/app/brep/vertexFactory.js
Val Erastov (xibyte) e11c1f7f4a geom module
2020-07-19 22:37:24 -07:00

32 lines
618 B
JavaScript

import {Vertex} from './topo/vertex';
import {veqXYZ} from '../../../modules/geom/tolerance';
import {Point} from '../../../modules/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);
}
}