mirror of https://gitee.com/cf-fz/WebCAD.git
parent
f8bfe68927
commit
3c16e714b0
@ -0,0 +1,70 @@
|
|||||||
|
|
||||||
|
import * as fs from "fs";
|
||||||
|
import * as path from "path";
|
||||||
|
import { LoadRegionsFromFileData } from "../__test__/Utils/LoadEntity.util";
|
||||||
|
import { Region } from "../src/DatabaseServices/Region";
|
||||||
|
import { BoolOpeartionType } from "../src/GraphicsSystem/BoolOperateUtils";
|
||||||
|
|
||||||
|
function a(testfile: string)
|
||||||
|
{
|
||||||
|
testfile = path.resolve(__dirname, testfile);
|
||||||
|
let stream = fs.createReadStream(testfile);
|
||||||
|
|
||||||
|
let remaining = "";
|
||||||
|
stream.on("data", function (data: string)
|
||||||
|
{
|
||||||
|
remaining += data;
|
||||||
|
let index = remaining.indexOf('\n');
|
||||||
|
while (index > -1)
|
||||||
|
{
|
||||||
|
let line = remaining.substring(0, index);
|
||||||
|
remaining = remaining.substring(index + 1);
|
||||||
|
gg(line);
|
||||||
|
index = remaining.indexOf('\n');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
stream.on('end', function ()
|
||||||
|
{
|
||||||
|
console.log(JSON.stringify(datas));
|
||||||
|
stream.close();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function testBool(regs: Region[])
|
||||||
|
{
|
||||||
|
console.time();
|
||||||
|
regs[0].Clone().BooleanOper(regs[1].Clone(), BoolOpeartionType.Intersection);
|
||||||
|
regs[0].Clone().BooleanOper(regs[1].Clone(), BoolOpeartionType.Subtract);
|
||||||
|
regs[0].Clone().BooleanOper(regs[1].Clone(), BoolOpeartionType.Union);
|
||||||
|
console.timeEnd();
|
||||||
|
}
|
||||||
|
|
||||||
|
let datas = [];
|
||||||
|
|
||||||
|
function gg(d: string)
|
||||||
|
{
|
||||||
|
d = d.trimLeft();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (d[0] === "[")
|
||||||
|
{
|
||||||
|
|
||||||
|
let data = JSON.parse(d);
|
||||||
|
let regs = LoadRegionsFromFileData(data);
|
||||||
|
// testBool(regs);
|
||||||
|
|
||||||
|
datas.push(d);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (error)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
a("../__test__/Booloperate/bool2.test.ts");
|
Loading…
Reference in new issue