mirror of https://gitee.com/cf-fz/WebCAD.git
parent
212eeffa28
commit
85ee8e860d
@ -0,0 +1,54 @@
|
||||
import { Path } from "./Path";
|
||||
import { Point } from "./Point";
|
||||
|
||||
export class NestCache
|
||||
{
|
||||
static count1 = 0;
|
||||
static count2 = 0;
|
||||
static count3 = 0;
|
||||
|
||||
private static _pathId = -1;
|
||||
static get PathId()
|
||||
{
|
||||
return this._pathId++;
|
||||
}
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
||||
static PositionCache = new Map<string, Point>();
|
||||
static NFPCache = new Map<string, Point[][]>();
|
||||
|
||||
|
||||
private static CacheRect = new Map<string, Path>();
|
||||
|
||||
/**
|
||||
* 用于创建原点在0点的矩形路径
|
||||
*/
|
||||
static CreatePath(x: number, y: number): Path
|
||||
{
|
||||
let key = `${x.toFixed(2)},${y.toFixed(2)}`;
|
||||
let path = this.CacheRect.get(key);
|
||||
if (path) return path;
|
||||
path = new Path([
|
||||
{ x: 0, y: 0 },
|
||||
{ x: x, y: 0 },
|
||||
{ x: x, y: y },
|
||||
{ x: 0, y: y },
|
||||
]);
|
||||
this.CacheRect.set(key, path);
|
||||
return path;
|
||||
}
|
||||
|
||||
static Clear()
|
||||
{
|
||||
this.count1 = 0;
|
||||
this.count2 = 0;
|
||||
this.count3 = 0;
|
||||
this._pathId = -1;
|
||||
this.CacheRect.clear();
|
||||
this.PositionCache.clear();
|
||||
this.NFPCache.clear();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in new issue