/*
Copyright (C) 2017 Jayesh Salvi, Blue Math Software Inc.
This file is part of bluemath.
bluemath is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
bluemath is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with bluemath. If not, see .
*/
export class Triangulation {
private points : number[];
private triangles : number[];
private edges : number[][];
private vertices : number[][];
constructor(
points : number[],
triangles? : number[],
edges? : number[][],
vertices? : number[][]
)
{
this.points = points.slice();
if(triangles && edges && vertices) {
this.triangles = triangles;
this.edges = edges;
this.vertices = vertices;
} else {
// Initialize triangulation by creating a bounding triangle that
// is big enough to enclose all points
this.createBoundingTriangle();
}
}
private createBoundingTriangle() {
console.assert(false); // TODO
}
static fromPSLG(points:number[]) {
return new Triangulation(points);
}
static fromTriangulation(
points:number[],
triangles:number[],
edges : number[][],
vertices : number[][]
) {
return new Triangulation(points,triangles,edges,vertices);
}
runDelaunay() {
}
toSVG(width=600,height=600) {
const VTX_RADIUS = 3;
const VTX_STYLE = 'fill:#f88';
const TRI_STYLE = 'fill:#806;stroke:none';
let vtxmarkup = ``;
for(let i=0; i\n`;
}
vtxmarkup += ``;
let trimarkup = ``;
for(let i=0; i`;
}
trimarkup += ``;
return ``;
}
}