!219 实现可用的DeepClone WblockClone 和Insert功能.

Merge pull request !219 from ChenX/CloneDesign
pull/219/MERGE
ChenX 6 years ago
parent ea2333d956
commit d4fdafcf40

@ -1,8 +1,9 @@
import { Vector3 } from 'three';
import { CADFile } from '../../src/DatabaseServices/CADFile';
import { CADFiler } from '../../src/DatabaseServices/CADFiler';
import { Curve } from '../../src/DatabaseServices/Curve';
import { Line } from './../../src/DatabaseServices/Line';
import { RegionParse } from './../../src/Geometry/RegionParse';
import { LoadCurvesFromFileData } from '../Utils/LoadEntity.util';
function expectReg(alg: RegionParse)
{
@ -231,37 +232,9 @@ test('保护伞', () =>
test('带圆弧的复杂图形测试', () =>
{
let file = new CADFile();
file.Data = [
["Line", 1, 1, 105, false, 0, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 1, [135.10332884629918, 7.41153204925861, 0], [141.2013396407662, -3.6141642356868466, 0]],
["Line", 1, 1, 106, false, 1, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 1, [141.2013396407662, -3.6141642356868466, 0], [129.0669141204631, -3.614164235686845, 0]],
["Line", 1, 1, 107, false, 2, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 1, [129.0669141204631, -3.614164235686845, 0], [118.90356279635137, 9.936970863128803, 0]],
["Line", 1, 1, 108, false, 3, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 1, [118.90356279635137, 9.936970863128803, 0], [129.25170232635605, 16.219769863488786, 0]],
["Line", 1, 1, 109, false, 4, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 1, [129.25170232635605, 16.219769863488786, 0], [131.77714114022623, 24.28885485414719, 0]],
["Line", 1, 1, 110, false, 5, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 1, [131.77714114022623, 24.28885485414719, 0], [121.09714288582433, 18.21968481731883, 0]],
["Line", 1, 1, 111, false, 6, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 1, [121.09714288582433, 18.21968481731883, 0], [115.57737509027845, 20.531494667657398, 0]],
["Line", 1, 1, 112, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 1, [115.57737509027845, 20.531494667657398, 0], [118.90356279635137, 9.936970863128803, 0]],
["Line", 1, 1, 113, false, 0, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 1, [129.25170232635605, 16.219769863488786, 0], [135.10332884629918, 7.41153204925861, 0]],
["Line", 1, 1, 114, false, 1, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 1, [135.10332884629918, 7.41153204925861, 0], [141.07814750350425, 7.411532049258609, 0]],
["Line", 1, 1, 115, false, 2, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 1, [141.07814750350425, 7.411532049258609, 0], [150.9951145530921, 6.9187635002107655, 0]],
["Line", 1, 1, 116, false, 3, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 1, [150.9951145530921, 6.9187635002107655, 0], [146.62179368029246, 22.625761001110725, 0]],
["Line", 1, 1, 171, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 1, [115.57737509027845, 20.531494667657398, 0], [122.16815443379333, 33.2818808742703, 0]],
["Line", 1, 1, 172, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 1, [122.16815443379333, 33.2818808742703, 0], [131.77714114022623, 24.28885485414719, 0]],
["Line", 1, 1, 173, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 1, [131.77714114022623, 24.28885485414719, 0], [140.3389946799325, 29.339732481887566, 0]],
["Line", 1, 1, 174, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 1, [140.3389946799325, 29.339732481887566, 0], [146.62179368029246, 22.625761001110725, 0]],
["Arc", 1, 1, 175, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 1, [151.10541370131332, 26.821442121699068, 0], [0, 0, 1], 6.14056907448819, 3.8938276244846772, 6.018122149019185, false],
["Arc", 1, 1, 176, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 1, [161.1393080144557, 24.097737845466003, 0], [0, 0, 1], 4.256430496141867, 2.8765294954293896, 5.103001249079749, true],
["Arc", 1, 1, 177, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 1, [164.0426698023552, 17.04682100167833, 0], [0, 0, 1], 3.368852318904628, 1.9614085954899536, 5.109952481560101, false],
["Arc", 1, 1, 178, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 1, [168.0577082733428, 7.485478534075631, 0], [0, 0, 1], 7.001287685275334, 1.9683598279703076, 3.2491377039705007, true],
["Arc", 1, 1, 179, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 1, [156.0343039466818, 6.18741259702873, 0], [0, 0, 1], 5.091984278064126, 0.10754505038070734, 2.997466317295445, false],
["Arc", 1, 1, 180, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 1, [146.05997836303806, 7.635012886374687, 0], [0, 0, 1], 4.986840923627034, 6.139058970885238, 3.1864217771069283, true],
["Arc", 1, 1, 181, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 1, [138.09073817490173, 7.277519322534491, 0], [0, 0, 1], 2.9904136682983347, 0.04482912351713572, 3.0967635300726575, false]];
let cus: Curve[] = [];
for (let i = 0; i < file.Data.length; i++)
{
cus.push(file.ReadObject(undefined) as Curve);
}
let cus = LoadCurvesFromFileData(
[23, "Line", 1, 1, -1, false, 0, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 1, [135.10332884629918, 7.41153204925861, 0], [141.2013396407662, -3.6141642356868466, 0], "Line", 1, 1, -1, false, 1, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 1, [141.2013396407662, -3.6141642356868466, 0], [129.0669141204631, -3.614164235686845, 0], "Line", 1, 1, -1, false, 2, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 1, [129.0669141204631, -3.614164235686845, 0], [118.90356279635137, 9.936970863128803, 0], "Line", 1, 1, -1, false, 3, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 1, [118.90356279635137, 9.936970863128803, 0], [129.25170232635605, 16.219769863488786, 0], "Line", 1, 1, -1, false, 4, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 1, [129.25170232635605, 16.219769863488786, 0], [131.77714114022623, 24.28885485414719, 0], "Line", 1, 1, -1, false, 5, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 1, [131.77714114022623, 24.28885485414719, 0], [121.09714288582433, 18.21968481731883, 0], "Line", 1, 1, -1, false, 6, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 1, [121.09714288582433, 18.21968481731883, 0], [115.57737509027845, 20.531494667657398, 0], "Line", 1, 1, -1, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 1, [115.57737509027845, 20.531494667657398, 0], [118.90356279635137, 9.936970863128803, 0], "Line", 1, 1, -1, false, 0, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 1, [129.25170232635605, 16.219769863488786, 0], [135.10332884629918, 7.41153204925861, 0], "Line", 1, 1, -1, false, 1, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 1, [135.10332884629918, 7.41153204925861, 0], [141.07814750350425, 7.411532049258609, 0], "Line", 1, 1, -1, false, 2, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 1, [141.07814750350425, 7.411532049258609, 0], [150.9951145530921, 6.9187635002107655, 0], "Line", 1, 1, -1, false, 3, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 1, [150.9951145530921, 6.9187635002107655, 0], [146.62179368029246, 22.625761001110725, 0], "Line", 1, 1, -1, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 1, [115.57737509027845, 20.531494667657398, 0], [122.16815443379333, 33.2818808742703, 0], "Line", 1, 1, -1, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 1, [122.16815443379333, 33.2818808742703, 0], [131.77714114022623, 24.28885485414719, 0], "Line", 1, 1, -1, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 1, [131.77714114022623, 24.28885485414719, 0], [140.3389946799325, 29.339732481887566, 0], "Line", 1, 1, -1, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 1, [140.3389946799325, 29.339732481887566, 0], [146.62179368029246, 22.625761001110725, 0], "Arc", 1, 1, -1, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 151.10541370131332, 26.821442121699068, 0, 1], 2, 6.14056907448819, 3.8938276244846772, 6.018122149019185, false, "Arc", 1, 1, -1, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 161.1393080144557, 24.097737845466003, 0, 1], 2, 4.256430496141867, 2.8765294954293896, 5.103001249079749, true, "Arc", 1, 1, -1, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 164.0426698023552, 17.04682100167833, 0, 1], 2, 3.368852318904628, 1.9614085954899536, 5.109952481560101, false, "Arc", 1, 1, -1, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 168.0577082733428, 7.485478534075631, 0, 1], 2, 7.001287685275334, 1.9683598279703076, 3.2491377039705007, true, "Arc", 1, 1, -1, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 156.0343039466818, 6.18741259702873, 0, 1], 2, 5.091984278064126, 0.10754505038070734, 2.997466317295445, false, "Arc", 1, 1, -1, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 146.05997836303806, 7.635012886374687, 0, 1], 2, 4.986840923627034, 6.139058970885238, 3.1864217771069283, true, "Arc", 1, 1, -1, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 138.09073817490173, 7.277519322534491, 0, 1], 2, 2.9904136682983347, 0.04482912351713572, 3.0967635300726575, false]
)
let g = new RegionParse(cus);
expect(g.m_RegionsInternal.length).toBe(7);

@ -1,73 +1,62 @@
import { CADFactory } from "../../src/DatabaseServices/CADFactory";
import { CADFile } from "../../src/DatabaseServices/CADFile";
import { Region } from "../../src/DatabaseServices/Region";
import { BoolOpeartionType } from "../../src/GraphicsSystem/BoolOperateUtils";
CADFactory.RegisterObject(Region);
function loadFile(data)
{
let file = new CADFile();
file.Data = data
let regs: Region[] = [];
for (let i = 0; i < file.Data.length; i++)
{
let reg = file.ReadObject(undefined) as Region;
regs.push(reg);
}
return regs.filter(r => r instanceof Region);
}
import { LoadRegionsFromFileData } from "../Utils/LoadEntity.util";
//没有洞
test('2没有洞的面域,相交', () =>
{
let data = [["Region", 1, 1, 4, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 1, 1, 1, 1, ["Polyline", 1, 1, -1, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 5, [-2.8550724637681157, -3.3478260869565215], 0, [1.4347826086956512, -3.3478260869565215], 0, [1.4347826086956512, -0.304347826086957], 0, [-2.8550724637681157, -0.304347826086957], 0, [-2.8550724637681157, -3.3478260869565215], 0, false], 0], ["Region", 1, 1, 6, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 1, 1, 1, 1, ["Polyline", 1, 1, -1, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 5, [-1.4492753623188404, -4.695652173913043], 0, [2.2753623188405787, -4.695652173913043], 0, [2.2753623188405787, -1.434782608695652], 0, [-1.4492753623188404, -1.434782608695652], 0, [-1.4492753623188404, -4.695652173913043], 0, false], 0]];
let regs: Region[] = loadFile(data);
let data =
[2, "Region", 1, 1, -1, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 1, 1, 1, 1, "Polyline", 1, 1, -1, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 4, [-2.8550724637681157, -3.3478260869565215], 0, [1.4347826086956512, -3.3478260869565215], 0, [1.4347826086956512, -0.304347826086957], 0, [-2.8550724637681157, -0.304347826086957], 0, true, 0, "Region", 1, 1, -1, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 1, 1, 1, 1, "Polyline", 1, 1, -1, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 4, [-1.4492753623188404, -4.695652173913043], 0, [2.2753623188405787, -4.695652173913043], 0, [2.2753623188405787, -1.434782608695652], 0, [-1.4492753623188404, -1.434782608695652], 0, true, 0]
let regs: Region[] = LoadRegionsFromFileData(data);
expect(regs.length).toBe(2);
regs[0].BooleanOper(regs[1], BoolOpeartionType.Intersection);
expect(regs[0].ShapeManager.ShapeList.length).toBe(1);
regs = loadFile(data);
regs = LoadRegionsFromFileData(data);
regs[0].BooleanOper(regs[1], BoolOpeartionType.Union);
expect(regs[0].ShapeManager.ShapeList.length).toBe(1);
regs = loadFile(data);
regs = LoadRegionsFromFileData(data);
regs[0].BooleanOper(regs[1], BoolOpeartionType.Union);
expect(regs[0].ShapeManager.ShapeList.length).toBe(1);
});
test('2面域,大的包含小的', () =>
{
let data = [["Region", 1, 1, 9, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 1, 1, 1, 1, ["Polyline", 1, 1, -1, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 5, [-1.8800742693409744, -12.621788424068765], 0, [6.005662808022923, -12.621788424068765], 0, [6.005662808022923, -8.540226017191973], 0, [-1.8800742693409744, -8.540226017191973], 0, [-1.8800742693409744, -12.621788424068765], 0, false], 0], ["Region", 1, 1, 10, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 1, 1, 1, 1, ["Polyline", 1, 1, -1, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 5, [-0.03742716332378216, -11.254663151862458], 0, [3.9450681948424067, -11.254663151862458], 0, [3.9450681948424067, -9.53089650429799], 0, [-0.03742716332378216, -9.53089650429799], 0, [-0.03742716332378216, -11.254663151862458], 0, false], 0]];
let regs = loadFile(data);
let data =
[2, "Region", 1, 1, -1, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 1, 1, 1, 1, "Polyline", 1, 1, -1, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 4, [-1.8800742693409744, -12.621788424068765], 0, [6.005662808022923, -12.621788424068765], 0, [6.005662808022923, -8.540226017191973], 0, [-1.8800742693409744, -8.540226017191973], 0, true, 0, "Region", 1, 1, -1, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 1, 1, 1, 1, "Polyline", 1, 1, -1, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 4, [-0.03742716332378216, -11.254663151862458], 0, [3.9450681948424067, -11.254663151862458], 0, [3.9450681948424067, -9.53089650429799], 0, [-0.03742716332378216, -9.53089650429799], 0, true, 0]
let regs = LoadRegionsFromFileData(data);
testBool(regs[0], regs[1], 1, 0, 1, 0, 1, 1);
testBool(regs[1], regs[0], 1, 0, 1, 0, 0, 0);
})
test('2没有洞的面域,不相交', () =>
{
let data = [["Region", 1, 1, 13, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 1, 1, 1, 1, ["Polyline", 1, 1, -1, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 5, [-4.711014253295126, -24.920368119197704], 0, [5.1917279358166155, -24.920368119197704], 0, [5.1917279358166155, -16.88167151862464], 0, [-4.711014253295126, -16.88167151862464], 0, [-4.711014253295126, -24.920368119197704], 0, false], 0], ["Region", 1, 1, 14, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 1, 1, 1, 1, ["Polyline", 1, 1, -1, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 5, [7.948962035530085, -25.735888064183378], 0, [14.084778764469913, -25.735888064183378], 0, [14.084778764469913, -19.716574184527214], 0, [7.948962035530085, -19.716574184527214], 0, [7.948962035530085, -25.735888064183378], 0, false], 0]];
let regs: Region[] = loadFile(data);
let data =
[2, "Region", 1, 1, -1, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 1, 1, 1, 1, "Polyline", 1, 1, -1, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 4, [-4.711014253295126, -24.920368119197704], 0, [5.1917279358166155, -24.920368119197704], 0, [5.1917279358166155, -16.88167151862464], 0, [-4.711014253295126, -16.88167151862464], 0, true, 0, "Region", 1, 1, -1, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 1, 1, 1, 1, "Polyline", 1, 1, -1, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 4, [7.948962035530085, -25.735888064183378], 0, [14.084778764469913, -25.735888064183378], 0, [14.084778764469913, -19.716574184527214], 0, [7.948962035530085, -19.716574184527214], 0, true, 0]
let regs: Region[] = LoadRegionsFromFileData(data);
expect(regs.length).toBe(2);
regs[0].BooleanOper(regs[1], BoolOpeartionType.Intersection);
expect(regs[0].ShapeManager.ShapeList.length).toBe(0);
regs = loadFile(data);
regs = LoadRegionsFromFileData(data);
regs[0].BooleanOper(regs[1], BoolOpeartionType.Union);
expect(regs[0].ShapeManager.ShapeList.length).toBe(2);
regs = loadFile(data);
regs = LoadRegionsFromFileData(data);
regs[0].BooleanOper(regs[1], BoolOpeartionType.Subtract);
expect(regs[0].ShapeManager.ShapeList.length).toBe(1);
});
test("多无洞面域,互相相交", () =>
{
let data = [["Region", 1, 1, 60, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 1, 1, 1, 1, ["Polyline", 1, 1, -1, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 5, [-0.8607930519232294, -2.5865143049017547], 0, [4.439811998377018, -2.5865143049017547], 0, [4.439811998377018, 1.1818845980460777], 0, [-0.8607930519232294, 1.1818845980460777], 0, [-0.8607930519232294, -2.5865143049017547], 0, false], 0], ["Region", 1, 1, 4, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 1, 1, 1, 1, ["Polyline", 1, 1, -1, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 5, [-2.8550724637681157, -3.3478260869565215], 0, [1.4347826086956512, -3.3478260869565215], 0, [1.4347826086956512, -0.304347826086957], 0, [-2.8550724637681157, -0.304347826086957], 0, [-2.8550724637681157, -3.3478260869565215], 0, false], 0], ["Region", 1, 1, 6, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 1, 1, 1, 1, ["Polyline", 1, 1, -1, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 5, [-1.4492753623188404, -4.695652173913043], 0, [2.2753623188405787, -4.695652173913043], 0, [2.2753623188405787, -1.434782608695652], 0, [-1.4492753623188404, -1.434782608695652], 0, [-1.4492753623188404, -4.695652173913043], 0, false], 0]];
let regs = loadFile(data);
let data =
[3, "Region", 1, 1, -1, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 1, 1, 1, 1, "Polyline", 1, 1, -1, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 4, [-0.8607930519232294, -2.5865143049017547], 0, [4.439811998377018, -2.5865143049017547], 0, [4.439811998377018, 1.1818845980460777], 0, [-0.8607930519232294, 1.1818845980460777], 0, true, 0, "Region", 1, 1, -1, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 1, 1, 1, 1, "Polyline", 1, 1, -1, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 4, [-2.8550724637681157, -3.3478260869565215], 0, [1.4347826086956512, -3.3478260869565215], 0, [1.4347826086956512, -0.304347826086957], 0, [-2.8550724637681157, -0.304347826086957], 0, true, 0, "Region", 1, 1, -1, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 1, 1, 1, 1, "Polyline", 1, 1, -1, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 4, [-1.4492753623188404, -4.695652173913043], 0, [2.2753623188405787, -4.695652173913043], 0, [2.2753623188405787, -1.434782608695652], 0, [-1.4492753623188404, -1.434782608695652], 0, true, 0]
let regs = LoadRegionsFromFileData(data);
expect(regs.length).toBe(3);
testRegionsBool(regs, 1, 0, 1, 0, 1, 0);
})
test("多无洞面域,互不相交", () =>
{
let data = [["Region", 1, 1, 13, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 1, 1, 1, 1, ["Polyline", 1, 1, -1, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 5, [-4.711014253295126, -24.920368119197704], 0, [5.1917279358166155, -24.920368119197704], 0, [5.1917279358166155, -16.88167151862464], 0, [-4.711014253295126, -16.88167151862464], 0, [-4.711014253295126, -24.920368119197704], 0, false], 0], ["Region", 1, 1, 14, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 1, 1, 1, 1, ["Polyline", 1, 1, -1, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 5, [7.948962035530085, -25.735888064183378], 0, [14.084778764469913, -25.735888064183378], 0, [14.084778764469913, -19.716574184527214], 0, [7.948962035530085, -19.716574184527214], 0, [7.948962035530085, -25.735888064183378], 0, false], 0], ["Region", 1, 1, 16, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 1, 1, 1, 1, ["Polyline", 1, 1, -1, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 5, [-14.225413611461313, -24.182516740401145], 0, [-8.90511682750716, -24.182516740401145], 0, [-8.90511682750716, -16.609831536962744], 0, [-14.225413611461313, -16.609831536962744], 0, [-14.225413611461313, -24.182516740401145], 0, false], 0]];
let regs = loadFile(data);
let data =
[3, "Region", 1, 1, -1, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 1, 1, 1, 1, "Polyline", 1, 1, -1, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 4, [-4.711014253295126, -24.920368119197704], 0, [5.1917279358166155, -24.920368119197704], 0, [5.1917279358166155, -16.88167151862464], 0, [-4.711014253295126, -16.88167151862464], 0, true, 0, "Region", 1, 1, -1, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 1, 1, 1, 1, "Polyline", 1, 1, -1, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 4, [7.948962035530085, -25.735888064183378], 0, [14.084778764469913, -25.735888064183378], 0, [14.084778764469913, -19.716574184527214], 0, [7.948962035530085, -19.716574184527214], 0, true, 0, "Region", 1, 1, -1, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 1, 1, 1, 1, "Polyline", 1, 1, -1, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 4, [-14.225413611461313, -24.182516740401145], 0, [-8.90511682750716, -24.182516740401145], 0, [-8.90511682750716, -16.609831536962744], 0, [-14.225413611461313, -16.609831536962744], 0, true, 0]
let regs = LoadRegionsFromFileData(data);
expect(regs.length).toBe(3);
testRegionsBool(regs, 3, 0, 0, 0, 1, 0);
})
@ -75,38 +64,43 @@ test("多无洞面域,互不相交", () =>
test('2面域,各有一个洞,不相交', () =>
{
let data = [["Region", 1, 1, 21, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 1, 1, 1, 1, ["Polyline", 1, 1, -1, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 5, [-22.59187156135242, -39.71001649292836], 0, [-10.261209993169047, -39.71001649292836], 0, [-10.261209993169047, -32.47907298072205], 0, [-22.59187156135242, -32.47907298072205], 0, [-22.59187156135242, -39.71001649292836], 0, false], 1, ["Polyline", 1, 1, -1, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 5, [-19.318918182143253, -36.28483272398853], 0, [-14.523660905627494, -36.28483272398853], 0, [-14.523660905627494, -34.38195285235529], 0, [-19.318918182143253, -34.38195285235529], 0, [-19.318918182143253, -36.28483272398853], 0, false]], ["Region", 1, 1, 22, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 1, 1, 1, 1, ["Polyline", 1, 1, -1, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 5, [-6.759911029363891, -42.52627870294555], 0, [4.048446641512894, -42.52627870294555], 0, [4.048446641512894, -34.9147592164126], 0, [-6.759911029363891, -34.9147592164126], 0, [-6.759911029363891, -42.52627870294555], 0, false], 1, ["Polyline", 1, 1, -1, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 5, [-3.7153032347507127, -40.69951402617764], 0, [1.308299626361034, -40.69951402617764], 0, [1.308299626361034, -37.42656064696847], 0, [-3.7153032347507127, -37.42656064696847], 0, [-3.7153032347507127, -40.69951402617764], 0, false]]];
let regs = loadFile(data);
let data =
[2, "Region", 1, 1, -1, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 1, 1, 1, 1, "Polyline", 1, 1, -1, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 4, [-22.59187156135242, -39.71001649292836], 0, [-10.261209993169047, -39.71001649292836], 0, [-10.261209993169047, -32.47907298072205], 0, [-22.59187156135242, -32.47907298072205], 0, true, 1, "Polyline", 1, 1, -1, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 4, [-19.318918182143253, -36.28483272398853], 0, [-14.523660905627494, -36.28483272398853], 0, [-14.523660905627494, -34.38195285235529], 0, [-19.318918182143253, -34.38195285235529], 0, true, "Region", 1, 1, -1, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 1, 1, 1, 1, "Polyline", 1, 1, -1, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 4, [-6.759911029363891, -42.52627870294555], 0, [4.048446641512894, -42.52627870294555], 0, [4.048446641512894, -34.9147592164126], 0, [-6.759911029363891, -34.9147592164126], 0, true, 1, "Polyline", 1, 1, -1, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 4, [-3.7153032347507127, -40.69951402617764], 0, [1.308299626361034, -40.69951402617764], 0, [1.308299626361034, -37.42656064696847], 0, [-3.7153032347507127, -37.42656064696847], 0, true]
let regs = LoadRegionsFromFileData(data);
testBool(regs[0], regs[1], 2, 2, 0, 0, 1, 1);
})
test('2面域,各有一个洞,相交', () =>
{
let data = [["Region", 1, 1, 22, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 1, 1, 1, 1, ["Polyline", 1, 1, -1, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 5, [-6.759911029363891, -42.52627870294555], 0, [4.048446641512894, -42.52627870294555], 0, [4.048446641512894, -34.9147592164126], 0, [-6.759911029363891, -34.9147592164126], 0, [-6.759911029363891, -42.52627870294555], 0, false], 1, ["Polyline", 1, 1, -1, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 5, [-3.7153032347507127, -40.69951402617764], 0, [1.308299626361034, -40.69951402617764], 0, [1.308299626361034, -37.42656064696847], 0, [-3.7153032347507127, -37.42656064696847], 0, [-3.7153032347507127, -40.69951402617764], 0, false]], ["Region", 1, 1, 31, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 1, 1, 1, 1, ["Polyline", 1, 1, -1, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 5, [-1.081717492410313, -43.85068309360228], 0, [15.009034702120339, -43.85068309360228], 0, [15.009034702120339, -32.98143326683323], 0, [-1.081717492410313, -32.98143326683323], 0, [-1.081717492410313, -43.85068309360228], 0, false], 1, ["Polyline", 1, 1, -1, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 5, [6.484132877203438, -41.29321254612721], 0, [12.345002881833807, -41.29321254612721], 0, [12.345002881833807, -36.81763908804584], 0, [6.484132877203438, -36.81763908804584], 0, [6.484132877203438, -41.29321254612721], 0, false]]];
let regs = loadFile(data);
let data =
[2, "Region", 1, 1, -1, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 1, 1, 1, 1, "Polyline", 1, 1, -1, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 4, [-6.759911029363891, -42.52627870294555], 0, [4.048446641512894, -42.52627870294555], 0, [4.048446641512894, -34.9147592164126], 0, [-6.759911029363891, -34.9147592164126], 0, true, 1, "Polyline", 1, 1, -1, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 4, [-3.7153032347507127, -40.69951402617764], 0, [1.308299626361034, -40.69951402617764], 0, [1.308299626361034, -37.42656064696847], 0, [-3.7153032347507127, -37.42656064696847], 0, true, "Region", 1, 1, -1, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 1, 1, 1, 1, "Polyline", 1, 1, -1, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 4, [-1.081717492410313, -43.85068309360228], 0, [15.009034702120339, -43.85068309360228], 0, [15.009034702120339, -32.98143326683323], 0, [-1.081717492410313, -32.98143326683323], 0, true, 1, "Polyline", 1, 1, -1, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 4, [6.484132877203438, -41.29321254612721], 0, [12.345002881833807, -41.29321254612721], 0, [12.345002881833807, -36.81763908804584], 0, [6.484132877203438, -36.81763908804584], 0, true]
let regs = LoadRegionsFromFileData(data);
testBool(regs[0], regs[1], 1, 2, 1, 0, 1, 0);
testBool(regs[1], regs[0], 1, 2, 1, 0, 2, 1);
})
test('2面域,包含关系,小的有洞', () =>
{
let data = [["Region", 1, 1, 36, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 1, 1, 1, 1, ["Polyline", 1, 1, -1, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 5, [-15.04124423071174, -72.72878802550831], 0, [12.451564154645265, -72.72878802550831], 0, [12.451564154645265, -54.08056528350259], 0, [-15.04124423071174, -54.08056528350259], 0, [-15.04124423071174, -72.72878802550831], 0, false], 1, ["Polyline", 1, 1, -1, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 5, [-9.286935498892833, -69.21226602273008], 0, [9.041603424678508, -69.21226602273008], 0, [9.041603424678508, -59.08894510564126], 0, [-9.286935498892833, -59.08894510564126], 0, [-9.286935498892833, -69.21226602273008], 0, false]], ["Region", 1, 1, 38, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 1, 1, 1, 1, ["Polyline", 1, 1, -1, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 5, [-22.180849509079643, -77.41748402921259], 0, [19.591169433013167, -77.41748402921259], 0, [19.591169433013167, -48.32625655168367], 0, [-22.180849509079643, -48.32625655168367], 0, [-22.180849509079643, -77.41748402921259], 0, false], 0]];
let regs = loadFile(data);
let data =
[2, "Region", 1, 1, -1, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 1, 1, 1, 1, "Polyline", 1, 1, -1, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 4, [-15.04124423071174, -72.72878802550831], 0, [12.451564154645265, -72.72878802550831], 0, [12.451564154645265, -54.08056528350259], 0, [-15.04124423071174, -54.08056528350259], 0, true, 1, "Polyline", 1, 1, -1, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 4, [-9.286935498892833, -69.21226602273008], 0, [9.041603424678508, -69.21226602273008], 0, [9.041603424678508, -59.08894510564126], 0, [-9.286935498892833, -59.08894510564126], 0, true, "Region", 1, 1, -1, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 1, 1, 1, 1, "Polyline", 1, 1, -1, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 4, [-22.180849509079643, -77.41748402921259], 0, [19.591169433013167, -77.41748402921259], 0, [19.591169433013167, -48.32625655168367], 0, [-22.180849509079643, -48.32625655168367], 0, true, 0]
let regs = LoadRegionsFromFileData(data);
expect(regs.length).toBe(2);
testBool(regs[1], regs[0], 1, 0, 1, 1, 2, 1);
testBool(regs[0], regs[1], 1, 0, 1, 1, 0, 0);
})
test('2面域,包含关系,大的有洞被小的包含,小的有洞', () =>
{
let data = [["Region", 1, 1, 41, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 1, 1, 1, 1, ["Polyline", 1, 1, -1, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 5, [-46.60469323746657, -127.77834155990918], 0, [24.855296309899348, -127.77834155990918], 0, [24.855296309899348, -89.28840982040936], 0, [-46.60469323746657, -89.28840982040936], 0, [-46.60469323746657, -127.77834155990918], 0, false], 1, ["Polyline", 1, 1, -1, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 5, [-24.077640165123658, -113.60569227598484], 0, [3.6709152749808487, -113.60569227598484], 0, [3.6709152749808487, -102.26757284884535], 0, [-24.077640165123658, -102.26757284884535], 0, [-24.077640165123658, -113.60569227598484], 0, false]], ["Region", 1, 1, 46, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 1, 1, 1, 1, ["Polyline", 1, 1, -1, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 5, [-59.58385626590253, -133.178866865994], 0, [39.83354881627835, -133.178866865994], 0, [39.83354881627835, -84.72332489316635], 0, [-59.58385626590253, -84.72332489316635], 0, [-59.58385626590253, -133.178866865994], 0, false], 1, ["Polyline", 1, 1, -1, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 5, [-15.723236376705094, -111.24855692139529], 0, [-1.5207499363935426, -111.24855692139529], 0, [-1.5207499363935426, -105.60933436421276], 0, [-15.723236376705094, -105.60933436421276], 0, [-15.723236376705094, -111.24855692139529], 0, false]]];
let regs = loadFile(data);
let data =
[2, "Region", 1, 1, -1, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 1, 1, 1, 1, "Polyline", 1, 1, -1, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 4, [-46.60469323746657, -127.77834155990918], 0, [24.855296309899348, -127.77834155990918], 0, [24.855296309899348, -89.28840982040936], 0, [-46.60469323746657, -89.28840982040936], 0, true, 1, "Polyline", 1, 1, -1, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 4, [-24.077640165123658, -113.60569227598484], 0, [3.6709152749808487, -113.60569227598484], 0, [3.6709152749808487, -102.26757284884535], 0, [-24.077640165123658, -102.26757284884535], 0, true, "Region", 1, 1, -1, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 1, 1, 1, 1, "Polyline", 1, 1, -1, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 4, [-59.58385626590253, -133.178866865994], 0, [39.83354881627835, -133.178866865994], 0, [39.83354881627835, -84.72332489316635], 0, [-59.58385626590253, -84.72332489316635], 0, true, 1, "Polyline", 1, 1, -1, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 4, [-15.723236376705094, -111.24855692139529], 0, [-1.5207499363935426, -111.24855692139529], 0, [-1.5207499363935426, -105.60933436421276], 0, [-15.723236376705094, -105.60933436421276], 0, true]
let regs = LoadRegionsFromFileData(data);
expect(regs.length).toBe(2);
testBool(regs[0], regs[1], 1, 1, 1, 1, 0, 0);
testBool(regs[1], regs[0], 1, 1, 1, 1, 2, 2);
})
test('2面域,各有洞,形状和洞都相交', () =>
{
let data = [["Region", 1, 1, 51, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 1, 1, 1, 1, ["Polyline", 1, 1, -1, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 5, [-55.41885848474738, -244.74737129761687], 0, [79.76223873944839, -244.74737129761687], 0, [79.76223873944839, -181.20070166231113], 0, [-55.41885848474738, -181.20070166231113], 0, [-55.41885848474738, -244.74737129761687], 0, false], 1, ["Polyline", 1, 1, -1, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 5, [-27.689402643886723, -225.97221890536744], 0, [58.38744986211828, -225.97221890536744], 0, [58.38744986211828, -196.79852057279527], 0, [-27.689402643886723, -196.79852057279527], 0, [-27.689402643886723, -225.97221890536744], 0, false]], ["Region", 1, 1, 53, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 1, 1, 1, 1, ["Polyline", 1, 1, -1, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 5, [-15.846614211852472, -278.5426456036658], 0, [52.032782898587726, -278.5426456036658], 0, [52.032782898587726, -158.95936728995414], 0, [-15.846614211852472, -158.95936728995414], 0, [-15.846614211852472, -278.5426456036658], 0, false], 1, ["Polyline", 1, 1, -1, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 5, [3.2173866787392393, -273.0545241351621], 0, [37.87920647981508, -273.0545241351621], 0, [37.87920647981508, -164.1586402601155], 0, [3.2173866787392393, -164.1586402601155], 0, [3.2173866787392393, -273.0545241351621], 0, false]]];
let regs = loadFile(data);
let data =
[2, "Region", 1, 1, -1, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 1, 1, 1, 1, "Polyline", 1, 1, -1, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 4, [-55.41885848474738, -244.74737129761687], 0, [79.76223873944839, -244.74737129761687], 0, [79.76223873944839, -181.20070166231113], 0, [-55.41885848474738, -181.20070166231113], 0, true, 1, "Polyline", 1, 1, -1, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 4, [-27.689402643886723, -225.97221890536744], 0, [58.38744986211828, -225.97221890536744], 0, [58.38744986211828, -196.79852057279527], 0, [-27.689402643886723, -196.79852057279527], 0, true, "Region", 1, 1, -1, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 1, 1, 1, 1, "Polyline", 1, 1, -1, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 4, [-15.846614211852472, -278.5426456036658], 0, [52.032782898587726, -278.5426456036658], 0, [52.032782898587726, -158.95936728995414], 0, [-15.846614211852472, -158.95936728995414], 0, true, 1, "Polyline", 1, 1, -1, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 4, [3.2173866787392393, -273.0545241351621], 0, [37.87920647981508, -273.0545241351621], 0, [37.87920647981508, -164.1586402601155], 0, [3.2173866787392393, -164.1586402601155], 0, true]
let regs = LoadRegionsFromFileData(data);
expect(regs.length).toBe(2);
testBool(regs[0], regs[1], 1, 5, 4, 0, 4, 0);
testBool(regs[1], regs[0], 1, 5, 4, 0, 4, 0);
@ -114,8 +108,9 @@ test('2面域,各有洞,形状和洞都相交', () =>
test("多都有洞面域,互不相交", () =>
{
let data = [["Region", 1, 1, 21, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 1, 1, 1, 1, ["Polyline", 1, 1, -1, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 5, [-22.59187156135242, -39.71001649292836], 0, [-10.261209993169047, -39.71001649292836], 0, [-10.261209993169047, -32.47907298072205], 0, [-22.59187156135242, -32.47907298072205], 0, [-22.59187156135242, -39.71001649292836], 0, false], 1, ["Polyline", 1, 1, -1, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 5, [-19.318918182143253, -36.28483272398853], 0, [-14.523660905627494, -36.28483272398853], 0, [-14.523660905627494, -34.38195285235529], 0, [-19.318918182143253, -34.38195285235529], 0, [-19.318918182143253, -36.28483272398853], 0, false]], ["Region", 1, 1, 22, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 1, 1, 1, 1, ["Polyline", 1, 1, -1, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 5, [-6.759911029363891, -42.52627870294555], 0, [4.048446641512894, -42.52627870294555], 0, [4.048446641512894, -34.9147592164126], 0, [-6.759911029363891, -34.9147592164126], 0, [-6.759911029363891, -42.52627870294555], 0, false], 1, ["Polyline", 1, 1, -1, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 5, [-3.7153032347507127, -40.69951402617764], 0, [1.308299626361034, -40.69951402617764], 0, [1.308299626361034, -37.42656064696847], 0, [-3.7153032347507127, -37.42656064696847], 0, [-3.7153032347507127, -40.69951402617764], 0, false]], ["Region", 1, 1, 57, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 1, 1, 1, 1, ["Polyline", 1, 1, -1, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 5, [-32.341023130284626, -29.89099796417434], 0, [-20.945903228429888, -29.89099796417434], 0, [-20.945903228429888, -23.98549786905254], 0, [-32.341023130284626, -23.98549786905254], 0, [-32.341023130284626, -29.89099796417434], 0, false], 1, ["Polyline", 1, 1, -1, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 5, [-28.59810053478489, -28.809709214363306], 0, [-22.276720151274237, -28.809709214363306], 0, [-22.276720151274237, -25.73219508028575], 0, [-28.59810053478489, -25.73219508028575], 0, [-28.59810053478489, -28.809709214363306], 0, false]]];
let regs = loadFile(data);
let data =
[3, "Region", 1, 1, -1, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 1, 1, 1, 1, "Polyline", 1, 1, -1, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 4, [-22.59187156135242, -39.71001649292836], 0, [-10.261209993169047, -39.71001649292836], 0, [-10.261209993169047, -32.47907298072205], 0, [-22.59187156135242, -32.47907298072205], 0, true, 1, "Polyline", 1, 1, -1, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 4, [-19.318918182143253, -36.28483272398853], 0, [-14.523660905627494, -36.28483272398853], 0, [-14.523660905627494, -34.38195285235529], 0, [-19.318918182143253, -34.38195285235529], 0, true, "Region", 1, 1, -1, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 1, 1, 1, 1, "Polyline", 1, 1, -1, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 4, [-6.759911029363891, -42.52627870294555], 0, [4.048446641512894, -42.52627870294555], 0, [4.048446641512894, -34.9147592164126], 0, [-6.759911029363891, -34.9147592164126], 0, true, 1, "Polyline", 1, 1, -1, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 4, [-3.7153032347507127, -40.69951402617764], 0, [1.308299626361034, -40.69951402617764], 0, [1.308299626361034, -37.42656064696847], 0, [-3.7153032347507127, -37.42656064696847], 0, true, "Region", 1, 1, -1, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 1, 1, 1, 1, "Polyline", 1, 1, -1, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 4, [-32.341023130284626, -29.89099796417434], 0, [-20.945903228429888, -29.89099796417434], 0, [-20.945903228429888, -23.98549786905254], 0, [-32.341023130284626, -23.98549786905254], 0, true, 1, "Polyline", 1, 1, -1, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 4, [-28.59810053478489, -28.809709214363306], 0, [-22.276720151274237, -28.809709214363306], 0, [-22.276720151274237, -25.73219508028575], 0, [-28.59810053478489, -25.73219508028575], 0, true]
let regs = LoadRegionsFromFileData(data);
expect(regs.length).toBe(3);
testRegionsBool(regs, 3, 3, 0, 0, 1, 1);
})

@ -1,24 +1,9 @@
import { Factory } from "../../src/DatabaseServices/CADFactory";
import { Board } from "../../src/DatabaseServices/Board";
import { CADFile } from "../../src/DatabaseServices/CADFile";
import { Curve } from "../../src/DatabaseServices/Curve";
import { calcEdgeSealing, paragraphCulist } from "../../src/GraphicsSystem/CalcEdgeSealing";
import { Polyline } from "../../src/DatabaseServices/Polyline";
import { calcEdgeSealing, paragraphCulist } from "../../src/GraphicsSystem/CalcEdgeSealing";
import { LoadBoardsFromFileData } from "../Utils/LoadEntity.util";
Factory(Board);
function loadFile(data)
{
let file = new CADFile();
file.Data = data;
let brs: Board[] = [];
let count = file.Read();
for (let i = 0; i < count; i++)
{
brs.push(file.ReadObject(undefined) as Board);
}
return brs;
}
function testBrSealing(br: Board, sealingSize: number[])
{
let originCurve = br.Shape.Outline.Curve;
@ -45,23 +30,26 @@ function testBrSealing(br: Board, sealingSize: number[])
}
test("常规板件,常规坐标系", () =>
{
let data = [1, ["Board", 1, 1, 3, false, 7, -1, [0, 1, 0, 0, -1, 0, 0, 0, 0, 0, 1, 0, 145.29914529914527, -290.5982905982906, 0, 1], 1, 1, ["Polyline", 1, 1, -1, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 4, [0, 0], 0, [600, 0], 0, [600, 1200], 0, [0, 1200], 0, true], 0, 1200, 600, 18, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 145.29914529914527, -290.5982905982906, 0, 1], 0, "", "{\"roomName\":\"\",\"cabinetName\":\"\",\"boardName\":\"\",\"material\":\"\",\"color\":\"\",\"lines\":0,\"bigHoleDir\":0,\"drillType\":\"three\",\"composingFace\":2,\"highSealed\":[],\"sealedUp\":\"1.0\",\"sealedDown\":\"1.0\",\"sealedLeft\":\"1.0\",\"sealedRight\":\"1.0\",\"knifeRad\":\"0\",\"grooveAddLength\":\"0\",\"grooveAddWidth\":\"0\",\"grooveAddDepth\":\"0\",\"spliteHeight\":\"\",\"spliteWidth\":\"\",\"spliteThickness\":\"\"}", 0]]
let layerBr = loadFile(data)[0];
let data =
[1, "Board", 1, 1, 0, false, 7, 0, [0, 1, 0, 0, -1, 0, 0, 0, 0, 0, 1, 0, 145.29914529914527, -290.5982905982906, 0, 1], 1, 1, "Polyline", 1, 1, 0, false, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 4, [0, 0], 0, [600, 0], 0, [600, 1200], 0, [0, 1200], 0, true, 0, 1200, 600, 18, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 145.29914529914527, -290.5982905982906, 0, 1], 0, "", "{\"roomName\":\"\",\"cabinetName\":\"\",\"boardName\":\"\",\"material\":\"\",\"color\":\"\",\"lines\":0,\"bigHoleDir\":0,\"drillType\":\"three\",\"composingFace\":2,\"highSealed\":[],\"sealedUp\":\"1.0\",\"sealedDown\":\"1.0\",\"sealedLeft\":\"1.0\",\"sealedRight\":\"1.0\",\"knifeRad\":\"0\",\"grooveAddLength\":\"0\",\"grooveAddWidth\":\"0\",\"grooveAddDepth\":\"0\",\"spliteHeight\":\"\",\"spliteWidth\":\"\",\"spliteThickness\":\"\"}", 0, 0]
let layerBr = LoadBoardsFromFileData(data)[0];
let sealingSize = [1, 1, 1, 1];
testBrSealing(layerBr, sealingSize);
sealingSize = [3, 2, 3, 2];
testBrSealing(layerBr, sealingSize);
data = [1, ["Board", 1, 1, 3, false, 7, -1, [0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, -292.022792022792, -213.67521367521368, 0, 1], 1, 1, ["Polyline", 1, 1, -1, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 4, [0, 0], 0, [600, 0], 0, [600, 1200], 0, [0, 1200], 0, true], 0, 1200, 600, 18, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -292.022792022792, -213.67521367521368, 0, 1], 1, "", "{\"roomName\":\"\",\"cabinetName\":\"\",\"boardName\":\"\",\"material\":\"\",\"color\":\"\",\"lines\":0,\"bigHoleDir\":0,\"drillType\":\"three\",\"composingFace\":2,\"highSealed\":[],\"sealedUp\":\"1.0\",\"sealedDown\":\"1.0\",\"sealedLeft\":\"1.0\",\"sealedRight\":\"1.0\",\"knifeRad\":\"0\",\"grooveAddLength\":\"0\",\"grooveAddWidth\":\"0\",\"grooveAddDepth\":\"0\",\"spliteHeight\":\"\",\"spliteWidth\":\"\",\"spliteThickness\":\"\"}", 0]]
let vBr = loadFile(data)[0];
data =
[1, "Board", 1, 1, 0, false, 7, 0, [0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, -292.022792022792, -213.67521367521368, 0, 1], 1, 1, "Polyline", 1, 1, 0, false, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 4, [0, 0], 0, [600, 0], 0, [600, 1200], 0, [0, 1200], 0, true, 0, 1200, 600, 18, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -292.022792022792, -213.67521367521368, 0, 1], 1, "", "{\"roomName\":\"\",\"cabinetName\":\"\",\"boardName\":\"\",\"material\":\"\",\"color\":\"\",\"lines\":0,\"bigHoleDir\":0,\"drillType\":\"three\",\"composingFace\":2,\"highSealed\":[],\"sealedUp\":\"1.0\",\"sealedDown\":\"1.0\",\"sealedLeft\":\"1.0\",\"sealedRight\":\"1.0\",\"knifeRad\":\"0\",\"grooveAddLength\":\"0\",\"grooveAddWidth\":\"0\",\"grooveAddDepth\":\"0\",\"spliteHeight\":\"\",\"spliteWidth\":\"\",\"spliteThickness\":\"\"}", 0, 0]
let vBr = LoadBoardsFromFileData(data)[0];
sealingSize = [2, 2, 2, 2];
testBrSealing(vBr, sealingSize);
})
test("异型板件,常规坐标系", () =>
{
let data = [1, ["Board", 1, 1, 9, false, 7, -1, [0, 1, 0, 0, -1, 0, 0, 0, 0, 0, 1, 0, 3681.8686077049847, -1396.263281011676, 0, 1], 1, 1, ["Polyline", 1, 1, -1, true, 7, -1, [6.123233995736766e-17, -1, 0, 0, 1, 6.123233995736766e-17, 0, 0, 0, 0, 1, 0, 1396.2632810116759, 3681.8686077049847, 0, 1], 2, 5, [2345.694899782759, -1396.263281011676], 0, [3681.8686077049847, -1396.263281011676], 0, [3681.8686077049847, 443.1597468696174], 0.41421356237309503, [3481.8686077049847, 643.1597468696174], 0, [2345.694899782759, 643.1597468696174], 0, true], 0, 1336.1737079222257, 2039.4230278812934, 18, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 3681.8686077049847, -1396.263281011676, 0, 1], 0, "层板", "{\"roomName\":\"\",\"cabinetName\":\"\",\"boardName\":\"\",\"material\":\"\",\"color\":\"\",\"lines\":0,\"bigHoleDir\":0,\"drillType\":\"three\",\"composingFace\":2,\"sealedUp\":\"1.0\",\"sealedDown\":\"1.0\",\"sealedLeft\":\"1.0\",\"sealedRight\":\"1.0\",\"knifeRad\":\"0\",\"grooveAddLength\":\"0\",\"grooveAddWidth\":\"0\",\"grooveAddDepth\":\"0\",\"spliteHeight\":\"\",\"spliteWidth\":\"\",\"spliteThickness\":\"\"}", 0]]
let data =
[1, "Board", 1, 1, 0, false, 7, 0, [0, 1, 0, 0, -1, 0, 0, 0, 0, 0, 1, 0, 3681.8686077049847, -1396.263281011676, 0, 1], 1, 1, "Polyline", 1, 1, 0, true, 7, 0, [6.123233995736766e-17, -1, 0, 0, 1, 6.123233995736766e-17, 0, 0, 0, 0, 1, 0, 1396.2632810116759, 3681.8686077049847, 0, 1], 2, 5, [2345.694899782759, -1396.263281011676], 0, [3681.8686077049847, -1396.263281011676], 0, [3681.8686077049847, 443.1597468696174], 0.41421356237309503, [3481.8686077049847, 643.1597468696174], 0, [2345.694899782759, 643.1597468696174], 0, true, 0, 1336.1737079222257, 2039.4230278812934, 18, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 3681.8686077049847, -1396.263281011676, 0, 1], 0, "层板", "{\"roomName\":\"\",\"cabinetName\":\"\",\"boardName\":\"\",\"material\":\"\",\"color\":\"\",\"lines\":0,\"bigHoleDir\":0,\"drillType\":\"three\",\"composingFace\":2,\"sealedUp\":\"1.0\",\"sealedDown\":\"1.0\",\"sealedLeft\":\"1.0\",\"sealedRight\":\"1.0\",\"knifeRad\":\"0\",\"grooveAddLength\":\"0\",\"grooveAddWidth\":\"0\",\"grooveAddDepth\":\"0\",\"spliteHeight\":\"\",\"spliteWidth\":\"\",\"spliteThickness\":\"\"}", 0, 0]
//第三段为圆弧
let br = loadFile(data)[0];
let br = LoadBoardsFromFileData(data)[0];
let sealingSize = [1, 1, 1];
testBrSealing(br, sealingSize);
sealingSize = [3, 3, 10];
@ -69,8 +57,9 @@ test("异型板件,常规坐标系", () =>
sealingSize = [10, 10, 5];
testBrSealing(br, sealingSize);
// 2,4,6,8段为圆弧
data = [1, ["Board", 1, 1, 11, false, 7, -1, [0, 1, 0, 0, -1, 0, 0, 0, 0, 0, 1, 0, 6239.212423224621, -1330.0896939146003, 0, 1], 1, 1, ["Polyline", 1, 1, -1, true, 7, -1, [6.123233995736766e-17, -1, 0, 0, 1, 6.123233995736766e-17, 0, 0, 0, 0, 1, 0, 1330.0896939146, 6239.212423224621, 0, 1], 2, 8, [5263.6654731094095, -1330.0896939146003], 0, [5939.212423224621, -1330.0896939146003], 0.41421356237309503, [6239.212423224621, -1030.0896939146003], 0, [6239.212423224621, 495.8218896107525], 0.41421356237309503, [5939.212423224621, 795.8218896107526], 0, [5263.6654731094095, 795.8218896107526], 0.4142135623730949, [4963.6654731094095, 495.8218896107527], 0, [4963.6654731094095, -1030.0896939146003], 0.4142135623730949, true], 0, 1275.546950115211, 2125.911583525353, 18, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 6239.212423224621, -1330.0896939146003, 0, 1], 0, "层板", "{\"roomName\":\"\",\"cabinetName\":\"\",\"boardName\":\"\",\"material\":\"\",\"color\":\"\",\"lines\":0,\"bigHoleDir\":0,\"drillType\":\"three\",\"composingFace\":2,\"sealedUp\":\"1.0\",\"sealedDown\":\"1.0\",\"sealedLeft\":\"1.0\",\"sealedRight\":\"1.0\",\"knifeRad\":\"0\",\"grooveAddLength\":\"0\",\"grooveAddWidth\":\"0\",\"grooveAddDepth\":\"0\",\"spliteHeight\":\"\",\"spliteWidth\":\"\",\"spliteThickness\":\"\",\"highSealed\":[]}", 0]]
br = loadFile(data)[0];
data =
[1, "Board", 1, 1, 0, false, 7, 0, [0, 1, 0, 0, -1, 0, 0, 0, 0, 0, 1, 0, 6239.212423224621, -1330.0896939146003, 0, 1], 1, 1, "Polyline", 1, 1, 0, true, 7, 0, [6.123233995736766e-17, -1, 0, 0, 1, 6.123233995736766e-17, 0, 0, 0, 0, 1, 0, 1330.0896939146, 6239.212423224621, 0, 1], 2, 8, [5263.6654731094095, -1330.0896939146003], 0, [5939.212423224621, -1330.0896939146003], 0.41421356237309503, [6239.212423224621, -1030.0896939146003], 0, [6239.212423224621, 495.8218896107525], 0.41421356237309503, [5939.212423224621, 795.8218896107526], 0, [5263.6654731094095, 795.8218896107526], 0.4142135623730949, [4963.6654731094095, 495.8218896107527], 0, [4963.6654731094095, -1030.0896939146003], 0.4142135623730949, true, 0, 1275.546950115211, 2125.911583525353, 18, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 6239.212423224621, -1330.0896939146003, 0, 1], 0, "层板", "{\"roomName\":\"\",\"cabinetName\":\"\",\"boardName\":\"\",\"material\":\"\",\"color\":\"\",\"lines\":0,\"bigHoleDir\":0,\"drillType\":\"three\",\"composingFace\":2,\"sealedUp\":\"1.0\",\"sealedDown\":\"1.0\",\"sealedLeft\":\"1.0\",\"sealedRight\":\"1.0\",\"knifeRad\":\"0\",\"grooveAddLength\":\"0\",\"grooveAddWidth\":\"0\",\"grooveAddDepth\":\"0\",\"spliteHeight\":\"\",\"spliteWidth\":\"\",\"spliteThickness\":\"\",\"highSealed\":[]}", 0, 0]
br = LoadBoardsFromFileData(data)[0];
sealingSize = [1];
testBrSealing(br, sealingSize);
sealingSize = [5];
@ -79,9 +68,10 @@ test("异型板件,常规坐标系", () =>
})
test("异型板件,非常规坐标系", () =>
{
let data = [1, ["Board", 1, 1, 15, false, 7, -1, [0, 0, 1, 0, -1, 0, 0, 0, 0, -1, 0, 0, 15844.064994449893, 0, -2833.834144511985, 1], 1, 1, ["Polyline", 1, 1, -1, true, 7, -1, [6.123233995736766e-17, -1, 0, 0, 1, 6.123233995736766e-17, 0, 0, 0, 0, 1, 0, 2833.8341445119845, 15844.064994449893, 0, 1], 2, 6, [5008.758238702114, -2833.834144511985], 0, [5008.758238702114, 2775.380162574158], -0.414213562373095, [7222.921780972962, 4989.543704845006], 0, [13759.976048629745, 4989.543704845006], -0.8565683416116343, [14392.594203564273, 919.700241432878], 0, [14076.28512609701, -2833.834144511985], 0, true], 0, 10835.306755747779, 7823.377849356992, 18, [1, 0, 0, 0, 0, 0, 1, 0, 0, -1, 0, 0, 15844.064994449893, 0, -2833.834144511985, 1], 0, "层板", "{\"roomName\":\"\",\"cabinetName\":\"\",\"boardName\":\"\",\"material\":\"\",\"color\":\"\",\"lines\":0,\"bigHoleDir\":0,\"drillType\":\"three\",\"composingFace\":2,\"highSealed\":[],\"sealedUp\":\"1.0\",\"sealedDown\":\"1.0\",\"sealedLeft\":\"1.0\",\"sealedRight\":\"1.0\",\"knifeRad\":\"0\",\"grooveAddLength\":\"0\",\"grooveAddWidth\":\"0\",\"grooveAddDepth\":\"0\",\"spliteHeight\":\"\",\"spliteWidth\":\"\",\"spliteThickness\":\"\"}", 0]]
let data =
[1, "Board", 1, 1, 0, false, 7, 0, [0, 0, 1, 0, -1, 0, 0, 0, 0, -1, 0, 0, 15844.064994449893, 0, -2833.834144511985, 1], 1, 1, "Polyline", 1, 1, 0, true, 7, 0, [6.123233995736766e-17, -1, 0, 0, 1, 6.123233995736766e-17, 0, 0, 0, 0, 1, 0, 2833.8341445119845, 15844.064994449893, 0, 1], 2, 6, [5008.758238702114, -2833.834144511985], 0, [5008.758238702114, 2775.380162574158], -0.414213562373095, [7222.921780972962, 4989.543704845006], 0, [13759.976048629745, 4989.543704845006], -0.8565683416116343, [14392.594203564273, 919.700241432878], 0, [14076.28512609701, -2833.834144511985], 0, true, 0, 10835.306755747779, 7823.377849356992, 18, [1, 0, 0, 0, 0, 0, 1, 0, 0, -1, 0, 0, 15844.064994449893, 0, -2833.834144511985, 1], 0, "层板", "{\"roomName\":\"\",\"cabinetName\":\"\",\"boardName\":\"\",\"material\":\"\",\"color\":\"\",\"lines\":0,\"bigHoleDir\":0,\"drillType\":\"three\",\"composingFace\":2,\"highSealed\":[],\"sealedUp\":\"1.0\",\"sealedDown\":\"1.0\",\"sealedLeft\":\"1.0\",\"sealedRight\":\"1.0\",\"knifeRad\":\"0\",\"grooveAddLength\":\"0\",\"grooveAddWidth\":\"0\",\"grooveAddDepth\":\"0\",\"spliteHeight\":\"\",\"spliteWidth\":\"\",\"spliteThickness\":\"\"}", 0, 0]
//第2,4段为圆弧
let br = loadFile(data)[0];
let br = LoadBoardsFromFileData(data)[0];
let sealingSize = [1, 1, 1, 1, 1, 1];
testBrSealing(br, sealingSize);
sealingSize = [3, 5, 3, 3, 3, 3];

@ -1,21 +1,7 @@
import { Board } from "../../src/DatabaseServices/Board";
import { Factory } from "../../src/DatabaseServices/CADFactory";
import { CADFile } from "../../src/DatabaseServices/CADFile";
import { FeedingToolPath } from "../../src/GraphicsSystem/ToolPath/FeedingToolPath";
import { LoadBoardsFromFileData } from "../Utils/LoadEntity.util";
Factory(Board);
function loadFile(data)
{
let file = new CADFile();
file.Data = data;
let brs: Board[] = [];
let count = file.Read();
for (let i = 0; i < count; i++)
{
brs.push(file.ReadObject(undefined) as Board);
}
return brs;
}
function testPathCount(br: Board, count?: number)
{
let holeCount = 0;
@ -37,67 +23,80 @@ let feedUtil = new FeedingToolPath();
test("通孔造型测试", () =>
{
let data = [1, ["Board", 1, 1, 44, false, 7, -1, [0, 1, 0, 0, -1, 0, 0, 0, 0, 0, 1, 0, 126.93136983439945, -7851.102620205904, 0, 1], 1, 1, ["Polyline", 1, 1, -1, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 4, [0, 0], 0, [600, 0], 0, [600, 1200], 0, [0, 1200], 0, true], 0, 1200, 600, 18, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 126.93136983439945, -7851.102620205904, 0, 1], 0, "", "{\"roomName\":\"\",\"cabinetName\":\"\",\"boardName\":\"\",\"material\":\"\",\"color\":\"\",\"lines\":0,\"bigHoleDir\":0,\"drillType\":\"three\",\"composingFace\":2,\"highSealed\":[],\"sealedUp\":\"1\",\"sealedDown\":\"1\",\"sealedLeft\":\"1\",\"sealedRight\":\"1\",\"knifeRad\":\"0\",\"grooveAddLength\":\"0\",\"grooveAddWidth\":\"0\",\"grooveAddDepth\":\"0\",\"spliteHeight\":\"\",\"spliteWidth\":\"\",\"spliteThickness\":\"\"}", 0, 1, 1, ["Polyline", 1, 1, -1, false, 1, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 7822.630590069403, 2129.4641561015833, 0, 1], 2, 4, [-7679.5111852499285, -1949.1412985704153], 0, [-7405.040814734067, -1949.141298570415], 0, [-7405.040814734067, -1275.3032520065758], 0, [-7679.5111852499285, -1275.303252006576], 0, true], 0, 18, 0, 3, 0]]
let brs = loadFile(data);
let data =
[1, "Board", 1, 1, -1, false, 7, -1, [0, 1, 0, 0, -1, 0, 0, 0, 0, 0, 1, 0, 126.93136983439945, -7851.102620205904, 0, 1], 1, 1, "Polyline", 1, 1, -1, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 4, [0, 0], 0, [600, 0], 0, [600, 1200], 0, [0, 1200], 0, true, 0, 1200, 600, 18, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 126.93136983439945, -7851.102620205904, 0, 1], 0, "", "{\"roomName\":\"\",\"cabinetName\":\"\",\"boardName\":\"\",\"material\":\"\",\"color\":\"\",\"lines\":0,\"bigHoleDir\":0,\"drillType\":\"three\",\"composingFace\":2,\"highSealed\":[],\"sealedUp\":\"1\",\"sealedDown\":\"1\",\"sealedLeft\":\"1\",\"sealedRight\":\"1\",\"knifeRad\":\"0\",\"grooveAddLength\":\"0\",\"grooveAddWidth\":\"0\",\"grooveAddDepth\":\"0\",\"spliteHeight\":\"\",\"spliteWidth\":\"\",\"spliteThickness\":\"\"}", 0, 1, 1, "Polyline", 1, 1, -1, false, 1, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 7822.630590069403, 2129.4641561015833, 0, 1], 2, 4, [-7679.5111852499285, -1949.1412985704153], 0, [-7405.040814734067, -1949.141298570415], 0, [-7405.040814734067, -1275.3032520065758], 0, [-7679.5111852499285, -1275.303252006576], 0, true, 0, 18, 0, 3, 0]
let brs = LoadBoardsFromFileData(data);
testPathCount(brs[0]);
})
test("带孔造型板件", () =>
{
let data = [1, ["Board", 1, 1, 9, false, 7, -1, [0, 1, 0, 0, -1, 0, 0, 0, 0, 0, 1, 0, 315.04650013028345, -2923.9345412691255, 0, 1], 1, 1, ["Polyline", 1, 1, -1, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 4, [0, 0], 0, [600, 0], 0, [600, 1200], 0, [0, 1200], 0, true], 0, 1200, 600, 18, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 315.04650013028345, -2923.9345412691255, 0, 1], 0, "", "{\"roomName\":\"\",\"cabinetName\":\"\",\"boardName\":\"\",\"material\":\"\",\"color\":\"\",\"lines\":0,\"bigHoleDir\":0,\"drillType\":\"three\",\"composingFace\":2,\"highSealed\":[],\"sealedUp\":\"1\",\"sealedDown\":\"1\",\"sealedLeft\":\"1\",\"sealedRight\":\"1\",\"knifeRad\":\"0\",\"grooveAddLength\":\"0\",\"grooveAddWidth\":\"0\",\"grooveAddDepth\":\"0\",\"spliteHeight\":\"\",\"spliteWidth\":\"\",\"spliteThickness\":\"\"}", 0, 1, 1, ["Polyline", 1, 1, -1, false, 1, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 2916.366392263997, 1987.6074302636166, 0, 1], 2, 4, [-2793.4596524207154, -1846.8398587682314], 0, [-2477.4137499665617, -1846.8398587682314], 0, [-2477.4137499665617, -1064.898703558386], 0, [-2793.4596524207154, -1064.898703558386], 0, true], 1, ["Polyline", 1, 1, -1, false, 1, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 2916.366392263997, 1987.6074302636166, 0, 1], 2, 4, [-2714.448176807177, -1707.8886430340776], 0, [-2570.047893789331, -1707.8886430340776], 0, [-2570.047893789331, -1247.442457562078], 0, [-2714.448176807177, -1247.442457562078], 0, true], 10, 0, 3, 0]]
let brs = loadFile(data);
let data =
[1, "Board", 1, 1, -1, false, 7, -1, [0, 1, 0, 0, -1, 0, 0, 0, 0, 0, 1, 0, 315.04650013028345, -2923.9345412691255, 0, 1], 1, 1, "Polyline", 1, 1, -1, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 4, [0, 0], 0, [600, 0], 0, [600, 1200], 0, [0, 1200], 0, true, 0, 1200, 600, 18, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 315.04650013028345, -2923.9345412691255, 0, 1], 0, "", "{\"roomName\":\"\",\"cabinetName\":\"\",\"boardName\":\"\",\"material\":\"\",\"color\":\"\",\"lines\":0,\"bigHoleDir\":0,\"drillType\":\"three\",\"composingFace\":2,\"highSealed\":[],\"sealedUp\":\"1\",\"sealedDown\":\"1\",\"sealedLeft\":\"1\",\"sealedRight\":\"1\",\"knifeRad\":\"0\",\"grooveAddLength\":\"0\",\"grooveAddWidth\":\"0\",\"grooveAddDepth\":\"0\",\"spliteHeight\":\"\",\"spliteWidth\":\"\",\"spliteThickness\":\"\"}", 0, 1, 1, "Polyline", 1, 1, -1, false, 1, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 2916.366392263997, 1987.6074302636166, 0, 1], 2, 4, [-2793.4596524207154, -1846.8398587682314], 0, [-2477.4137499665617, -1846.8398587682314], 0, [-2477.4137499665617, -1064.898703558386], 0, [-2793.4596524207154, -1064.898703558386], 0, true, 1, "Polyline", 1, 1, -1, false, 1, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 2916.366392263997, 1987.6074302636166, 0, 1], 2, 4, [-2714.448176807177, -1707.8886430340776], 0, [-2570.047893789331, -1707.8886430340776], 0, [-2570.047893789331, -1247.442457562078], 0, [-2714.448176807177, -1247.442457562078], 0, true, 10, 0, 3, 0]
let brs = LoadBoardsFromFileData(data);
testPathCount(brs[0]);
data = [2, ["Board", 1, 1, 9, false, 7, -1, [0, 1, 0, 0, -1, 0, 0, 0, 0, 0, 1, 0, 315.04650013028345, -2923.9345412691255, 0, 1], 1, 1, ["Polyline", 1, 1, -1, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 4, [0, 0], 0, [600, 0], 0, [600, 1200], 0, [0, 1200], 0, true], 0, 1200, 600, 18, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 315.04650013028345, -2923.9345412691255, 0, 1], 0, "", "{\"roomName\":\"\",\"cabinetName\":\"\",\"boardName\":\"\",\"material\":\"\",\"color\":\"\",\"lines\":0,\"bigHoleDir\":0,\"drillType\":\"three\",\"composingFace\":2,\"highSealed\":[],\"sealedUp\":\"1\",\"sealedDown\":\"1\",\"sealedLeft\":\"1\",\"sealedRight\":\"1\",\"knifeRad\":\"0\",\"grooveAddLength\":\"0\",\"grooveAddWidth\":\"0\",\"grooveAddDepth\":\"0\",\"spliteHeight\":\"\",\"spliteWidth\":\"\",\"spliteThickness\":\"\"}", 0, 1, 1, ["Polyline", 1, 1, -1, false, 1, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 2916.366392263997, 1987.6074302636166, 0, 1], 2, 4, [-2793.4596524207154, -1846.8398587682314], 0, [-2477.4137499665617, -1846.8398587682314], 0, [-2477.4137499665617, -1064.898703558386], 0, [-2793.4596524207154, -1064.898703558386], 0, true], 1, ["Polyline", 1, 1, -1, false, 1, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 2916.366392263997, 1987.6074302636166, 0, 1], 2, 4, [-2714.448176807177, -1707.8886430340776], 0, [-2570.047893789331, -1707.8886430340776], 0, [-2570.047893789331, -1247.442457562078], 0, [-2714.448176807177, -1247.442457562078], 0, true], 10, 0, 3, 0], ["Board", 1, 1, 35, false, 7, -1, [0, 1, 0, 0, -1, 0, 0, 0, 0, 0, 1, 0, 142.7476665886519, -6652.181401176747, 0, 1], 1, 1, ["Polyline", 1, 1, -1, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 4, [0, 0], 0, [600, 0], 0, [600, 1200], 0, [0, 1200], 0, true], 0, 1200, 600, 18, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 142.7476665886519, -6652.181401176747, 0, 1], 0, "", "{\"roomName\":\"\",\"cabinetName\":\"\",\"boardName\":\"\",\"material\":\"\",\"color\":\"\",\"lines\":0,\"bigHoleDir\":0,\"drillType\":\"three\",\"composingFace\":2,\"highSealed\":[],\"sealedUp\":\"1\",\"sealedDown\":\"1\",\"sealedLeft\":\"1\",\"sealedRight\":\"1\",\"knifeRad\":\"0\",\"grooveAddLength\":\"0\",\"grooveAddWidth\":\"0\",\"grooveAddDepth\":\"0\",\"spliteHeight\":\"\",\"spliteWidth\":\"\",\"spliteThickness\":\"\"}", 0, 1, 1, ["Polyline", 1, 1, -1, false, 2, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 6646.274106889091, 2021.2672500633112, 0, 1], 2, 6, [-6459.603607399157, -1131.628730342293], 0, [-6168.964728446474, -1131.628730342293], 0, [-6303.651038205035, -1393.9125967142265], 0, [-6186.686611309442, -1702.2733585298784], 0, [-6466.692360544344, -1702.2733585298784], 0, [-6388.716075947283, -1393.9125967142265], 0, true], 2, ["Circle", 1, 1, -1, false, 2, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 305.61977726617806, 415.9680345595966, 0, 1], 1, 49.62380364928433], ["Circle", 1, 1, -1, false, 2, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 309.447703964579, 788.5528998706459, 0, 1], 1, 43.30804682119281], 15, 0, 0, 0]]
brs = loadFile(data);
data =
[2, "Board", 1, 1, -1, false, 7, -1, [0, 1, 0, 0, -1, 0, 0, 0, 0, 0, 1, 0, 315.04650013028345, -2923.9345412691255, 0, 1], 1, 1, "Polyline", 1, 1, -1, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 4, [0, 0], 0, [600, 0], 0, [600, 1200], 0, [0, 1200], 0, true, 0, 1200, 600, 18, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 315.04650013028345, -2923.9345412691255, 0, 1], 0, "", "{\"roomName\":\"\",\"cabinetName\":\"\",\"boardName\":\"\",\"material\":\"\",\"color\":\"\",\"lines\":0,\"bigHoleDir\":0,\"drillType\":\"three\",\"composingFace\":2,\"highSealed\":[],\"sealedUp\":\"1\",\"sealedDown\":\"1\",\"sealedLeft\":\"1\",\"sealedRight\":\"1\",\"knifeRad\":\"0\",\"grooveAddLength\":\"0\",\"grooveAddWidth\":\"0\",\"grooveAddDepth\":\"0\",\"spliteHeight\":\"\",\"spliteWidth\":\"\",\"spliteThickness\":\"\"}", 0, 1, 1, "Polyline", 1, 1, -1, false, 1, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 2916.366392263997, 1987.6074302636166, 0, 1], 2, 4, [-2793.4596524207154, -1846.8398587682314], 0, [-2477.4137499665617, -1846.8398587682314], 0, [-2477.4137499665617, -1064.898703558386], 0, [-2793.4596524207154, -1064.898703558386], 0, true, 1, "Polyline", 1, 1, -1, false, 1, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 2916.366392263997, 1987.6074302636166, 0, 1], 2, 4, [-2714.448176807177, -1707.8886430340776], 0, [-2570.047893789331, -1707.8886430340776], 0, [-2570.047893789331, -1247.442457562078], 0, [-2714.448176807177, -1247.442457562078], 0, true, 10, 0, 3, 0, "Board", 1, 1, -1, false, 7, -1, [0, 1, 0, 0, -1, 0, 0, 0, 0, 0, 1, 0, 142.7476665886519, -6652.181401176747, 0, 1], 1, 1, "Polyline", 1, 1, -1, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 4, [0, 0], 0, [600, 0], 0, [600, 1200], 0, [0, 1200], 0, true, 0, 1200, 600, 18, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 142.7476665886519, -6652.181401176747, 0, 1], 0, "", "{\"roomName\":\"\",\"cabinetName\":\"\",\"boardName\":\"\",\"material\":\"\",\"color\":\"\",\"lines\":0,\"bigHoleDir\":0,\"drillType\":\"three\",\"composingFace\":2,\"highSealed\":[],\"sealedUp\":\"1\",\"sealedDown\":\"1\",\"sealedLeft\":\"1\",\"sealedRight\":\"1\",\"knifeRad\":\"0\",\"grooveAddLength\":\"0\",\"grooveAddWidth\":\"0\",\"grooveAddDepth\":\"0\",\"spliteHeight\":\"\",\"spliteWidth\":\"\",\"spliteThickness\":\"\"}", 0, 1, 1, "Polyline", 1, 1, -1, false, 2, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 6646.274106889091, 2021.2672500633112, 0, 1], 2, 6, [-6459.603607399157, -1131.628730342293], 0, [-6168.964728446474, -1131.628730342293], 0, [-6303.651038205035, -1393.9125967142265], 0, [-6186.686611309442, -1702.2733585298784], 0, [-6466.692360544344, -1702.2733585298784], 0, [-6388.716075947283, -1393.9125967142265], 0, true, 2, "Circle", 1, 1, -1, false, 2, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 305.61977726617806, 415.9680345595966, 0, 1], 1, 49.62380364928433, "Circle", 1, 1, -1, false, 2, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 309.447703964579, 788.5528998706459, 0, 1], 1, 43.30804682119281, 15, 0, 0, 0]
brs = LoadBoardsFromFileData(data);
testPathCount(brs[0]);
})
test("极限刀半径", () =>
{
let data = [1, ["Board", 1, 1, 23, false, 7, -1, [0, 1, 0, 0, -1, 0, 0, 0, 0, 0, 1, 0, -657.7056127057733, -888.0170782475586, 0, 1], 1, 1, ["Polyline", 1, 1, -1, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 4, [0, 0], 0, [600, 0], 0, [600, 1200], 0, [0, 1200], 0, true], 0, 1200, 600, 18, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -657.7056127057733, -888.0170782475586, 0, 1], 0, "", "{\"roomName\":\"\",\"cabinetName\":\"\",\"boardName\":\"\",\"material\":\"\",\"color\":\"\",\"lines\":0,\"bigHoleDir\":0,\"drillType\":\"three\",\"composingFace\":2,\"highSealed\":[],\"sealedUp\":\"1\",\"sealedDown\":\"1\",\"sealedLeft\":\"1\",\"sealedRight\":\"1\",\"knifeRad\":\"0\",\"grooveAddLength\":\"0\",\"grooveAddWidth\":\"0\",\"grooveAddDepth\":\"0\",\"spliteHeight\":\"\",\"spliteWidth\":\"\",\"spliteThickness\":\"\"}", 0, 1, 1, ["Polyline", 1, 1, -1, false, 1, -1, [0, -1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 669.7767195227455, 373.85642669358367, 0, 1], 2, 8, [-269.2307692307692, -223.9316239316239], 0, [-209.23076923076923, -223.9316239316239], 0, [-209.2307692307692, -473.9316239316239], 0, [40.7692307692308, -473.9316239316239], 0, [40.76923076923081, -533.9316239316239], 0, [-519.2307692307692, -533.9316239316238], 0, [-519.2307692307692, -473.9316239316238], 0, [-269.23076923076917, -473.9316239316238], 0, true], 0, 15, 0, 30, 0]]
let brs = loadFile(data);
let data =
[1, "Board", 1, 1, -1, false, 7, -1, [0, 1, 0, 0, -1, 0, 0, 0, 0, 0, 1, 0, -657.7056127057733, -888.0170782475586, 0, 1], 1, 1, "Polyline", 1, 1, -1, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 4, [0, 0], 0, [600, 0], 0, [600, 1200], 0, [0, 1200], 0, true, 0, 1200, 600, 18, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -657.7056127057733, -888.0170782475586, 0, 1], 0, "", "{\"roomName\":\"\",\"cabinetName\":\"\",\"boardName\":\"\",\"material\":\"\",\"color\":\"\",\"lines\":0,\"bigHoleDir\":0,\"drillType\":\"three\",\"composingFace\":2,\"highSealed\":[],\"sealedUp\":\"1\",\"sealedDown\":\"1\",\"sealedLeft\":\"1\",\"sealedRight\":\"1\",\"knifeRad\":\"0\",\"grooveAddLength\":\"0\",\"grooveAddWidth\":\"0\",\"grooveAddDepth\":\"0\",\"spliteHeight\":\"\",\"spliteWidth\":\"\",\"spliteThickness\":\"\"}", 0, 1, 1, "Polyline", 1, 1, -1, false, 1, -1, [0, -1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 669.7767195227455, 373.85642669358367, 0, 1], 2, 8, [-269.2307692307692, -223.9316239316239], 0, [-209.23076923076923, -223.9316239316239], 0, [-209.2307692307692, -473.9316239316239], 0, [40.7692307692308, -473.9316239316239], 0, [40.76923076923081, -533.9316239316239], 0, [-519.2307692307692, -533.9316239316238], 0, [-519.2307692307692, -473.9316239316238], 0, [-269.23076923076917, -473.9316239316238], 0, true, 0, 15, 0, 30, 0]
let brs = LoadBoardsFromFileData(data);
testPathCount(brs[0], 3);
data = [1, ["Board", 1, 1, 25, false, 7, -1, [0, 1, 0, 0, -1, 0, 0, 0, 0, 0, 1, 0, -663.8732094729834, -1836.8490686954794, 0, 1], 1, 1, ["Polyline", 1, 1, -1, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 4, [0, 0], 0, [600, 0], 0, [600, 1200], 0, [0, 1200], 0, true], 0, 1200, 600, 18, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -663.8732094729834, -1836.8490686954794, 0, 1], 0, "", "{\"roomName\":\"\",\"cabinetName\":\"\",\"boardName\":\"\",\"material\":\"\",\"color\":\"\",\"lines\":0,\"bigHoleDir\":0,\"drillType\":\"three\",\"composingFace\":2,\"highSealed\":[],\"sealedUp\":\"1\",\"sealedDown\":\"1\",\"sealedLeft\":\"1\",\"sealedRight\":\"1\",\"knifeRad\":\"0\",\"grooveAddLength\":\"0\",\"grooveAddWidth\":\"0\",\"grooveAddDepth\":\"0\",\"spliteHeight\":\"\",\"spliteWidth\":\"\",\"spliteThickness\":\"\"}", 0, 1, 1, ["Polyline", 1, 1, -1, false, 2, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 1784.6350413145396, 919.9380237783905, 0, 1], 2, 4, [-1450.7590848806103, 26.7131494779253], 0, [-1450.7590848806103, -719.3699285130117], 0, [-1480.7590848806103, -719.3699285130117], 0, [-1480.7590848806103, 26.88247329704346], 0, true], 0, 18, 0, 15, 0]]
brs = loadFile(data);
data =
[1, "Board", 1, 1, -1, false, 7, -1, [0, 1, 0, 0, -1, 0, 0, 0, 0, 0, 1, 0, -663.8732094729834, -1836.8490686954794, 0, 1], 1, 1, "Polyline", 1, 1, -1, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 4, [0, 0], 0, [600, 0], 0, [600, 1200], 0, [0, 1200], 0, true, 0, 1200, 600, 18, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -663.8732094729834, -1836.8490686954794, 0, 1], 0, "", "{\"roomName\":\"\",\"cabinetName\":\"\",\"boardName\":\"\",\"material\":\"\",\"color\":\"\",\"lines\":0,\"bigHoleDir\":0,\"drillType\":\"three\",\"composingFace\":2,\"highSealed\":[],\"sealedUp\":\"1\",\"sealedDown\":\"1\",\"sealedLeft\":\"1\",\"sealedRight\":\"1\",\"knifeRad\":\"0\",\"grooveAddLength\":\"0\",\"grooveAddWidth\":\"0\",\"grooveAddDepth\":\"0\",\"spliteHeight\":\"\",\"spliteWidth\":\"\",\"spliteThickness\":\"\"}", 0, 1, 1, "Polyline", 1, 1, -1, false, 2, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 1784.6350413145396, 919.9380237783905, 0, 1], 2, 4, [-1450.7590848806103, 26.7131494779253], 0, [-1450.7590848806103, -719.3699285130117], 0, [-1480.7590848806103, -719.3699285130117], 0, [-1480.7590848806103, 26.88247329704346], 0, true, 0, 18, 0, 15, 0]
brs = LoadBoardsFromFileData(data);
testPathCount(brs[0], 3);
data = [1, ["Board", 1, 1, 47, false, 7, -1, [0, 1, 0, 0, -1, 0, 0, 0, 0, 0, 1, 0, -1045.5289925195948, 676.3547294712749, 0, 1], 1, 1, ["Polyline", 1, 1, -1, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 4, [0, 0], 0, [600, 0], 0, [600, 1200], 0, [0, 1200], 0, true], 0, 1200, 600, 18, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -1045.5289925195948, 676.3547294712749, 0, 1], 0, "", "{\"roomName\":\"\",\"cabinetName\":\"\",\"boardName\":\"\",\"material\":\"\",\"color\":\"\",\"lines\":0,\"bigHoleDir\":0,\"drillType\":\"three\",\"composingFace\":2,\"highSealed\":[],\"sealedUp\":\"1\",\"sealedDown\":\"1\",\"sealedLeft\":\"1\",\"sealedRight\":\"1\",\"knifeRad\":\"0\",\"grooveAddLength\":\"0\",\"grooveAddWidth\":\"0\",\"grooveAddDepth\":\"0\",\"spliteHeight\":\"\",\"spliteWidth\":\"\",\"spliteThickness\":\"\"}", 0, 1, 1, ["Polyline", 1, 1, -1, false, 3, -1, [0, -1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, -89.78543368837677, 733.8187514408725, 0, 1], 2, 8, [-269.2307692307692, 119.65811965811966], 0, [-269.23076923076945, 631.2089459697221], 0, [526.6267506621481, 631.2089459697221], 0, [526.6267506621481, 119.65811965811963], 0, [466.6267506621481, 119.65811965811962], 0, [466.62675066214797, 571.2089459697221], 0, [-209.2307692307695, 571.2089459697221], 0, [-209.23076923076923, 119.65811965811966], 0, true], 0, 20, 0, 30, 0]]
brs = loadFile(data);
data =
[1, "Board", 1, 1, -1, false, 7, -1, [0, 1, 0, 0, -1, 0, 0, 0, 0, 0, 1, 0, -1045.5289925195948, 676.3547294712749, 0, 1], 1, 1, "Polyline", 1, 1, -1, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 4, [0, 0], 0, [600, 0], 0, [600, 1200], 0, [0, 1200], 0, true, 0, 1200, 600, 18, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -1045.5289925195948, 676.3547294712749, 0, 1], 0, "", "{\"roomName\":\"\",\"cabinetName\":\"\",\"boardName\":\"\",\"material\":\"\",\"color\":\"\",\"lines\":0,\"bigHoleDir\":0,\"drillType\":\"three\",\"composingFace\":2,\"highSealed\":[],\"sealedUp\":\"1\",\"sealedDown\":\"1\",\"sealedLeft\":\"1\",\"sealedRight\":\"1\",\"knifeRad\":\"0\",\"grooveAddLength\":\"0\",\"grooveAddWidth\":\"0\",\"grooveAddDepth\":\"0\",\"spliteHeight\":\"\",\"spliteWidth\":\"\",\"spliteThickness\":\"\"}", 0, 1, 1, "Polyline", 1, 1, -1, false, 3, -1, [0, -1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, -89.78543368837677, 733.8187514408725, 0, 1], 2, 8, [-269.2307692307692, 119.65811965811966], 0, [-269.23076923076945, 631.2089459697221], 0, [526.6267506621481, 631.2089459697221], 0, [526.6267506621481, 119.65811965811963], 0, [466.6267506621481, 119.65811965811962], 0, [466.62675066214797, 571.2089459697221], 0, [-209.2307692307695, 571.2089459697221], 0, [-209.23076923076923, 119.65811965811966], 0, true, 0, 20, 0, 30, 0]
brs = LoadBoardsFromFileData(data);
testPathCount(brs[0], 3);
data = [1, ["Board", 1, 1, 40, false, 7, -1, [0, 1, 0, 0, -1, 0, 0, 0, 0, 0, 1, 0, -703.1898726073867, -3031.7293464532195, 0, 1], 1, 1, ["Polyline", 1, 1, -1, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 4, [0, 0], 0, [600, 0], 0, [600, 1200], 0, [0, 1200], 0, true], 0, 1200, 600, 18, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -703.1898726073867, -3031.7293464532195, 0, 1], 0, "", "{\"roomName\":\"\",\"cabinetName\":\"\",\"boardName\":\"\",\"material\":\"\",\"color\":\"\",\"lines\":0,\"bigHoleDir\":0,\"drillType\":\"three\",\"composingFace\":2,\"highSealed\":[],\"sealedUp\":\"1\",\"sealedDown\":\"1\",\"sealedLeft\":\"1\",\"sealedRight\":\"1\",\"knifeRad\":\"0\",\"grooveAddLength\":\"0\",\"grooveAddWidth\":\"0\",\"grooveAddDepth\":\"0\",\"spliteHeight\":\"\",\"spliteWidth\":\"\",\"spliteThickness\":\"\"}", 0, 1, 1, ["Polyline", 1, 1, 60, false, 4, -1, [0, -1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 2958.0041022950545, -2782.375300102465, 0, 1], 2, 6, [-445.8689458689459, -202.27920227920225], 0, [-445.8689458689459, -142.27920227920225], 0, [-245.8689458689459, -142.27920227920225], 0, [-245.8689458689459, -82.27920227920225], 0, [-45.8689458689459, -82.27920227920225], 0, [-45.86894586894589, -202.27920227920225], 0, true], 0, 18, 0, 30, 0]]
brs = loadFile(data);
data =
[1, "Board", 1, 1, -1, false, 7, -1, [0, 1, 0, 0, -1, 0, 0, 0, 0, 0, 1, 0, -703.1898726073867, -3031.7293464532195, 0, 1], 1, 1, "Polyline", 1, 1, -1, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 4, [0, 0], 0, [600, 0], 0, [600, 1200], 0, [0, 1200], 0, true, 0, 1200, 600, 18, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -703.1898726073867, -3031.7293464532195, 0, 1], 0, "", "{\"roomName\":\"\",\"cabinetName\":\"\",\"boardName\":\"\",\"material\":\"\",\"color\":\"\",\"lines\":0,\"bigHoleDir\":0,\"drillType\":\"three\",\"composingFace\":2,\"highSealed\":[],\"sealedUp\":\"1\",\"sealedDown\":\"1\",\"sealedLeft\":\"1\",\"sealedRight\":\"1\",\"knifeRad\":\"0\",\"grooveAddLength\":\"0\",\"grooveAddWidth\":\"0\",\"grooveAddDepth\":\"0\",\"spliteHeight\":\"\",\"spliteWidth\":\"\",\"spliteThickness\":\"\"}", 0, 1, 1, "Polyline", 1, 1, -1, false, 4, -1, [0, -1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 2958.0041022950545, -2782.375300102465, 0, 1], 2, 6, [-445.8689458689459, -202.27920227920225], 0, [-445.8689458689459, -142.27920227920225], 0, [-245.8689458689459, -142.27920227920225], 0, [-245.8689458689459, -82.27920227920225], 0, [-45.8689458689459, -82.27920227920225], 0, [-45.86894586894589, -202.27920227920225], 0, true, 0, 18, 0, 30, 0]
brs = LoadBoardsFromFileData(data);
testPathCount(brs[0], 3);
data = [1, ["Board", 1, 1, 42, false, 7, -1, [0, 1, 0, 0, -1, 0, 0, 0, 0, 0, 1, 0, -723.8046937091931, -4479.271007572378, 0, 1], 1, 1, ["Polyline", 1, 1, -1, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 4, [0, 0], 0, [600, 0], 0, [600, 1200], 0, [0, 1200], 0, true], 0, 1200, 600, 18, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -723.8046937091931, -4479.271007572378, 0, 1], 0, "", "{\"roomName\":\"\",\"cabinetName\":\"\",\"boardName\":\"\",\"material\":\"\",\"color\":\"\",\"lines\":0,\"bigHoleDir\":0,\"drillType\":\"three\",\"composingFace\":2,\"highSealed\":[],\"sealedUp\":\"1\",\"sealedDown\":\"1\",\"sealedLeft\":\"1\",\"sealedRight\":\"1\",\"knifeRad\":\"0\",\"grooveAddLength\":\"0\",\"grooveAddWidth\":\"0\",\"grooveAddDepth\":\"0\",\"spliteHeight\":\"\",\"spliteWidth\":\"\",\"spliteThickness\":\"\"}", 0, 1, 1, ["Polyline", 1, 1, -1, false, 1, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 4420.876631461465, 1125.350549803055, 0, 1], 2, 6, [-4011.700851750289, -387.1968681241217], 0, [-4011.700851750289, -687.1968681241217], 0, [-4161.700851750289, -687.1968681241217], 0, [-4161.700851750289, -657.1968681241217], 0, [-4041.700851750289, -657.1968681241217], 0, [-4041.700851750289, -387.1968681241217], 0, true], 0, 18, 0, 15, 0]]
brs = loadFile(data);
data =
[1, "Board", 1, 1, -1, false, 7, -1, [0, 1, 0, 0, -1, 0, 0, 0, 0, 0, 1, 0, -723.8046937091931, -4479.271007572378, 0, 1], 1, 1, "Polyline", 1, 1, -1, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 4, [0, 0], 0, [600, 0], 0, [600, 1200], 0, [0, 1200], 0, true, 0, 1200, 600, 18, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -723.8046937091931, -4479.271007572378, 0, 1], 0, "", "{\"roomName\":\"\",\"cabinetName\":\"\",\"boardName\":\"\",\"material\":\"\",\"color\":\"\",\"lines\":0,\"bigHoleDir\":0,\"drillType\":\"three\",\"composingFace\":2,\"highSealed\":[],\"sealedUp\":\"1\",\"sealedDown\":\"1\",\"sealedLeft\":\"1\",\"sealedRight\":\"1\",\"knifeRad\":\"0\",\"grooveAddLength\":\"0\",\"grooveAddWidth\":\"0\",\"grooveAddDepth\":\"0\",\"spliteHeight\":\"\",\"spliteWidth\":\"\",\"spliteThickness\":\"\"}", 0, 1, 1, "Polyline", 1, 1, -1, false, 1, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 4420.876631461465, 1125.350549803055, 0, 1], 2, 6, [-4011.700851750289, -387.1968681241217], 0, [-4011.700851750289, -687.1968681241217], 0, [-4161.700851750289, -687.1968681241217], 0, [-4161.700851750289, -657.1968681241217], 0, [-4041.700851750289, -657.1968681241217], 0, [-4041.700851750289, -387.1968681241217], 0, true, 0, 18, 0, 15, 0]
brs = LoadBoardsFromFileData(data);
testPathCount(brs[0]);
})
test("复杂极限刀半径", () =>
{
let data = [1, ["Board", 1, 1, 3, false, 7, -1, [0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, -604.0236327121571, -287.85437391994753, 0, 1], 1, 1, ["Polyline", 1, 1, -1, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -929.3989071038254, 27.540983606557347, 0, 1], 2, 12, [1090.0546448087434, 872.1311475409834], 0, [1057.9234972677596, 599.0163934426229], 0, [929.3989071038254, 599.016393442623], 0, [929.3989071038254, 354.03292181069946], 0, [1167.7049180327872, 368.74316939890696], 0, [1114.1530054644809, 122.40437158469933], 0, [929.3989071038254, 143.05335904853735], 0, [929.3989071038254, -27.540983606557347], 0, [1529.3989071038254, -27.540983606557404], 0, [1529.3989071038254, 1172.4590163934427], 0, [929.3989071038254, 1172.4590163934427], 0, [929.3989071038254, 872.1311475409834], 0, true], 0, 1200, 600, 18, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -604.0236327121571, -287.85437391994753, 0, 1], 1, "左侧板", "{\"roomName\":\"\",\"cabinetName\":\"\",\"boardName\":\"\",\"material\":\"\",\"color\":\"\",\"lines\":0,\"bigHoleDir\":0,\"drillType\":\"three\",\"composingFace\":2,\"highSealed\":[],\"sealedUp\":\"1\",\"sealedDown\":\"1\",\"sealedLeft\":\"1\",\"sealedRight\":\"1\",\"knifeRad\":\"0\",\"grooveAddLength\":\"0\",\"grooveAddWidth\":\"0\",\"grooveAddDepth\":\"0\",\"spliteHeight\":\"\",\"spliteWidth\":\"\",\"spliteThickness\":\"\"}", 0, 2, 1, ["Polyline", 1, 1, -1, false, 2, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -1045.0710382513657, 11.47540983606541, 0, 1], 2, 12, [1111.5123746027145, 991.5327839891172], 0, [1234.7237593481482, 991.5327839891172], 0, [1234.7237593481482, 985.5327839891172], 0, [1118.2025855391182, 985.5327839891172], 0, [1118.2025855391182, 961.9843523533344], 0, [1238.6263823943837, 961.9843523533344], 0, [1238.6263823943837, 953.9843523533344], 0, [1102.0345757761427, 953.9843523533344], 0, [1102.0345757761427, 938.011096497888], 0, [1243.0865230186528, 938.011096497888], 0, [1243.0865230186528, 929.011096497888], 0, [1068.026003516091, 929.011096497888], 0, true], 0, 7.5, 0, 3, 0, 1, ["Polyline", 1, 1, -1, false, 1, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -1045.0710382513657, 11.47540983606541, 0, 1], 2, 21, [1045.0710382513657, 988.2305644705416], 0, [1071.838538645684, 1047.9617459060103], 0, [1045.0710382513657, 1056.0304182736754], 0, [1045.0710382513662, 1091.938334606794], 0, [1237.9650273224047, 1083.1256830601092], 0, [1543.8535519125685, 1083.1256830601092], 0, [1543.8535519125685, 1077.1256830601092], 0, [1249.5168174863388, 1077.1256830601092], 0, [1249.5168174863388, 1064.203778797814], 0, [1543.9255256830606, 1064.203778797814], 0, [1543.9255256830606, 1057.203778797814], 0, [1251.5572738797819, 1057.203778797814], 0, [1251.5572738797819, 1046.7141525683055], 0, [1544.800006994536, 1046.7141525683055], 0, [1301.694202404372, 980.8365604371581], 0, [1546.954728946011, 745.6150793512566], 0, [1300.598185827323, 682.4262257591249], 0, [1180.816692501768, 676.4610119480917], 0, [1205.7267759562842, 888.1967213114754], 0, [1205.7267759562842, 888.1967213114754], 0, [1045.0710382513657, 888.1967213114754], 0, true], 0, 6, 0, 3, 0]]
let brs = loadFile(data);
let data =
[1, "Board", 1, 1, -1, false, 7, -1, [0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, -604.0236327121571, -287.85437391994753, 0, 1], 1, 1, "Polyline", 1, 1, -1, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -929.3989071038254, 27.540983606557347, 0, 1], 2, 12, [1090.0546448087434, 872.1311475409834], 0, [1057.9234972677596, 599.0163934426229], 0, [929.3989071038254, 599.016393442623], 0, [929.3989071038254, 354.03292181069946], 0, [1167.7049180327872, 368.74316939890696], 0, [1114.1530054644809, 122.40437158469933], 0, [929.3989071038254, 143.05335904853735], 0, [929.3989071038254, -27.540983606557347], 0, [1529.3989071038254, -27.540983606557404], 0, [1529.3989071038254, 1172.4590163934427], 0, [929.3989071038254, 1172.4590163934427], 0, [929.3989071038254, 872.1311475409834], 0, true, 0, 1200, 600, 18, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -604.0236327121571, -287.85437391994753, 0, 1], 1, "左侧板", "{\"roomName\":\"\",\"cabinetName\":\"\",\"boardName\":\"\",\"material\":\"\",\"color\":\"\",\"lines\":0,\"bigHoleDir\":0,\"drillType\":\"three\",\"composingFace\":2,\"highSealed\":[],\"sealedUp\":\"1\",\"sealedDown\":\"1\",\"sealedLeft\":\"1\",\"sealedRight\":\"1\",\"knifeRad\":\"0\",\"grooveAddLength\":\"0\",\"grooveAddWidth\":\"0\",\"grooveAddDepth\":\"0\",\"spliteHeight\":\"\",\"spliteWidth\":\"\",\"spliteThickness\":\"\"}", 0, 2, 1, "Polyline", 1, 1, -1, false, 2, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -1045.0710382513657, 11.47540983606541, 0, 1], 2, 12, [1111.5123746027145, 991.5327839891172], 0, [1234.7237593481482, 991.5327839891172], 0, [1234.7237593481482, 985.5327839891172], 0, [1118.2025855391182, 985.5327839891172], 0, [1118.2025855391182, 961.9843523533344], 0, [1238.6263823943837, 961.9843523533344], 0, [1238.6263823943837, 953.9843523533344], 0, [1102.0345757761427, 953.9843523533344], 0, [1102.0345757761427, 938.011096497888], 0, [1243.0865230186528, 938.011096497888], 0, [1243.0865230186528, 929.011096497888], 0, [1068.026003516091, 929.011096497888], 0, true, 0, 7.5, 0, 3, 0, 1, "Polyline", 1, 1, -1, false, 1, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -1045.0710382513657, 11.47540983606541, 0, 1], 2, 21, [1045.0710382513657, 988.2305644705416], 0, [1071.838538645684, 1047.9617459060103], 0, [1045.0710382513657, 1056.0304182736754], 0, [1045.0710382513662, 1091.938334606794], 0, [1237.9650273224047, 1083.1256830601092], 0, [1543.8535519125685, 1083.1256830601092], 0, [1543.8535519125685, 1077.1256830601092], 0, [1249.5168174863388, 1077.1256830601092], 0, [1249.5168174863388, 1064.203778797814], 0, [1543.9255256830606, 1064.203778797814], 0, [1543.9255256830606, 1057.203778797814], 0, [1251.5572738797819, 1057.203778797814], 0, [1251.5572738797819, 1046.7141525683055], 0, [1544.800006994536, 1046.7141525683055], 0, [1301.694202404372, 980.8365604371581], 0, [1546.954728946011, 745.6150793512566], 0, [1300.598185827323, 682.4262257591249], 0, [1180.816692501768, 676.4610119480917], 0, [1205.7267759562842, 888.1967213114754], 0, [1205.7267759562842, 888.1967213114754], 0, [1045.0710382513657, 888.1967213114754], 0, true, 0, 6, 0, 3, 0]
let brs = LoadBoardsFromFileData(data);
testPathCount(brs[0]);
})
test("刀切到外轮廓情况", () =>
{
let data = [1, ["Board", 1, 1, 16, false, 7, -1, [0, 1, 0, 0, -1, 0, 0, 0, 0, 0, 1, 0, 5026.542613652899, -82.94991876210884, 0, 1], 1, 1, ["Polyline", 1, 1, -1, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 4, [0, 0], 0, [600, 0], 0, [600, 1200], 0, [0, 1200], 0, true], 0, 1200, 600, 18, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 5026.542613652899, -82.94991876210884, 0, 1], 0, "", "{\"roomName\":\"\",\"cabinetName\":\"\",\"boardName\":\"\",\"material\":\"\",\"color\":\"\",\"lines\":0,\"bigHoleDir\":0,\"drillType\":\"three\",\"composingFace\":2,\"highSealed\":[],\"sealedUp\":\"1\",\"sealedDown\":\"1\",\"sealedLeft\":\"1\",\"sealedRight\":\"1\",\"knifeRad\":\"0\",\"grooveAddLength\":\"0\",\"grooveAddWidth\":\"0\",\"grooveAddDepth\":\"0\",\"spliteHeight\":\"\",\"spliteWidth\":\"\",\"spliteThickness\":\"\"}", 0, 1, 1, ["Polyline", 1, 1, -1, false, 1, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 93.09030137237562, 6897.948239526741, 0, 1], 2, 4, [46.493939839332825, -6527.979974776644], 0, [340.601203930893, -6527.979974776644], 0, [340.601203930893, -6082.617546295138], 0, [46.493939839332825, -6082.617546295138], 0, true], 1, ["Circle", 1, 1, -1, false, 1, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 257.65748249413025, 589.5547926179952, 0, 1], 1, 116.11448843944343], 15, 0, 3, 0]];
let brs = loadFile(data);
let data =
[1, "Board", 1, 1, -1, false, 7, -1, [0, 1, 0, 0, -1, 0, 0, 0, 0, 0, 1, 0, 5026.542613652899, -82.94991876210884, 0, 1], 1, 1, "Polyline", 1, 1, -1, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 4, [0, 0], 0, [600, 0], 0, [600, 1200], 0, [0, 1200], 0, true, 0, 1200, 600, 18, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 5026.542613652899, -82.94991876210884, 0, 1], 0, "", "{\"roomName\":\"\",\"cabinetName\":\"\",\"boardName\":\"\",\"material\":\"\",\"color\":\"\",\"lines\":0,\"bigHoleDir\":0,\"drillType\":\"three\",\"composingFace\":2,\"highSealed\":[],\"sealedUp\":\"1\",\"sealedDown\":\"1\",\"sealedLeft\":\"1\",\"sealedRight\":\"1\",\"knifeRad\":\"0\",\"grooveAddLength\":\"0\",\"grooveAddWidth\":\"0\",\"grooveAddDepth\":\"0\",\"spliteHeight\":\"\",\"spliteWidth\":\"\",\"spliteThickness\":\"\"}", 0, 1, 1, "Polyline", 1, 1, -1, false, 1, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 93.09030137237562, 6897.948239526741, 0, 1], 2, 4, [46.493939839332825, -6527.979974776644], 0, [340.601203930893, -6527.979974776644], 0, [340.601203930893, -6082.617546295138], 0, [46.493939839332825, -6082.617546295138], 0, true, 1, "Circle", 1, 1, -1, false, 1, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 257.65748249413025, 589.5547926179952, 0, 1], 1, 116.11448843944343, 15, 0, 3, 0]
let brs = LoadBoardsFromFileData(data);
testPathCount(brs[0]);
data = [1, ["Board", 1, 1, 22, false, 7, -1, [0, 1, 0, 0, -1, 0, 0, 0, 0, 0, 1, 0, 5057.50249574722, -1024.0000779051127, 0, 1], 1, 1, ["Polyline", 1, 1, -1, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 4, [0, 0], 0, [600, 0], 0, [600, 1200], 0, [0, 1200], 0, true], 0, 1200, 600, 18, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 5057.50249574722, -1024.0000779051127, 0, 1], 0, "", "{\"roomName\":\"\",\"cabinetName\":\"\",\"boardName\":\"\",\"material\":\"\",\"color\":\"\",\"lines\":0,\"bigHoleDir\":0,\"drillType\":\"three\",\"composingFace\":2,\"highSealed\":[],\"sealedUp\":\"1\",\"sealedDown\":\"1\",\"sealedLeft\":\"1\",\"sealedRight\":\"1\",\"knifeRad\":\"0\",\"grooveAddLength\":\"0\",\"grooveAddWidth\":\"0\",\"grooveAddDepth\":\"0\",\"spliteHeight\":\"\",\"spliteWidth\":\"\",\"spliteThickness\":\"\"}", 0, 1, 1, ["Polyline", 1, 1, -1, false, 1, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 1042.216784740986, 6887.269493483857, 0, 1], 2, 4, [-442.216784740986, -6287.269493483857], 0, [-742.216784740986, -5687.269493483857], 0, [-1042.216784740986, -6287.269493483857], 0, [-742.216784740986, -6887.269493483857], 0, true], 1, ["Polyline", 1, 1, -1, false, 1, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 1042.216784740986, 6887.269493483857, 0, 1], 2, 4, [-892.216784740986, -6587.269493483857], 0, [-592.216784740986, -6587.269493483857], 0, [-592.216784740986, -5987.269493483857], 0, [-892.216784740986, -5987.269493483857], 0, true], 15, 0, 3, 0]]
brs = loadFile(data);
data =
[1, "Board", 1, 1, -1, false, 7, -1, [0, 1, 0, 0, -1, 0, 0, 0, 0, 0, 1, 0, 5057.50249574722, -1024.0000779051127, 0, 1], 1, 1, "Polyline", 1, 1, -1, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 4, [0, 0], 0, [600, 0], 0, [600, 1200], 0, [0, 1200], 0, true, 0, 1200, 600, 18, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 5057.50249574722, -1024.0000779051127, 0, 1], 0, "", "{\"roomName\":\"\",\"cabinetName\":\"\",\"boardName\":\"\",\"material\":\"\",\"color\":\"\",\"lines\":0,\"bigHoleDir\":0,\"drillType\":\"three\",\"composingFace\":2,\"highSealed\":[],\"sealedUp\":\"1\",\"sealedDown\":\"1\",\"sealedLeft\":\"1\",\"sealedRight\":\"1\",\"knifeRad\":\"0\",\"grooveAddLength\":\"0\",\"grooveAddWidth\":\"0\",\"grooveAddDepth\":\"0\",\"spliteHeight\":\"\",\"spliteWidth\":\"\",\"spliteThickness\":\"\"}", 0, 1, 1, "Polyline", 1, 1, -1, false, 1, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 1042.216784740986, 6887.269493483857, 0, 1], 2, 4, [-442.216784740986, -6287.269493483857], 0, [-742.216784740986, -5687.269493483857], 0, [-1042.216784740986, -6287.269493483857], 0, [-742.216784740986, -6887.269493483857], 0, true, 1, "Polyline", 1, 1, -1, false, 1, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 1042.216784740986, 6887.269493483857, 0, 1], 2, 4, [-892.216784740986, -6587.269493483857], 0, [-592.216784740986, -6587.269493483857], 0, [-592.216784740986, -5987.269493483857], 0, [-892.216784740986, -5987.269493483857], 0, true, 15, 0, 3, 0]
brs = LoadBoardsFromFileData(data);
testPathCount(brs[0]);
})
test("复杂造型测试", () =>
{
let data = [1, ["Board", 1, 1, 54, false, 7, -1, [0, 0, 1, 0, 0, -1, 0, 0, 1, 0, 0, 0, -919.5114893425489, -2703.8098770005176, -134.6026210568009, 1], 1, 1, ["Circle", 1, 1, -1, false, 7, -1, [0, -1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 382.3715309714528, 382.3715309714528, 0, 1], 1, 382.3715309714528], 0, 764.7430619429056, 764.7430619429056, 18, [0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, -919.5114893425489, -2703.8098770005176, -134.6026210568009, 1], 0, "层板", "{\"roomName\":\"\",\"cabinetName\":\"\",\"boardName\":\"\",\"material\":\"\",\"color\":\"\",\"lines\":0,\"bigHoleDir\":0,\"drillType\":\"three\",\"composingFace\":2,\"highSealed\":[],\"sealedUp\":\"1\",\"sealedDown\":\"1\",\"sealedLeft\":\"1\",\"sealedRight\":\"1\",\"knifeRad\":\"0\",\"grooveAddLength\":\"0\",\"grooveAddWidth\":\"0\",\"grooveAddDepth\":\"0\",\"spliteHeight\":\"\",\"spliteWidth\":\"\",\"spliteThickness\":\"\"}", 0, 12, 1, ["Polyline", 1, 1, -1, false, 1, -1, [0, -1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 134.6026210568009, -1224.6532653675133, 0, 1], 2, 4, [-1985.6277286542445, 194.21699734632784], 0, [-1228.4218640236884, 194.21699734632784], 0.06505182506170779, [-1227.3723277647396, 293.288035597694], 0, [-1986.6772649131926, 293.288035597694], 0.06505182506170767, true], 0, 10, 0, 3, 0, 1, ["Polyline", 1, 1, -1, false, 1, -1, [0, -1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 658.4697692228576, 691.9524021857917, 0, 1], 2, 2, [108.09377347199688, 48.88012586045511], -0.6501592260197776, [-36.242715090388515, -112.9601530205507], -0.14475251191859181, true], 0, 10, 0, 3, 0, 1, ["Polyline", 1, 1, -1, false, 1, -1, [0, -1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 90.4398943583576, 629.3207306904399, 0, 1], 2, 2, [-49.8138945074669, 50.80997934732096], -0.9109068504784374, [58.36556874536063, -40.70059547852842], -0.09345012042788828, true], 0, 10, 0, 3, 0, 1, ["Polyline", 1, 1, -1, false, 1, -1, [0, -1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 106.62611044415758, 117.47069904431623, 0, 1], 2, 2, [-53.9075765860091, -43.14301434924033], -0.9134441585739421, [45.27005907439718, 52.13413710723313], -0.09065675641591214, true], 0, 10, 0, 3, 0, 1, ["Polyline", 1, 1, -1, false, 2, -1, [0, -1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 786.5650872556355, 426.693071038251, 0, 1], 2, 2, [106.7018657003265, -26.944722394258406], -0.694630372644427, [-98.32737655143399, -49.427049571531825], -0.13740047935395364, true], 0, 10, 0, 3, 0, 1, ["Polyline", 1, 1, -1, false, 2, -1, [0, -1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 134.6026210568009, -1224.6532653675133, 0, 1], 2, 8, [-1742.842992143469, 270.75339078895075], 0, [-1465.8082380451083, 270.75339078895075], 0, [-1465.8082380451083, 264.75339078895075], 0, [-1734.1675823074033, 264.75339078895075], 0, [-1734.1675823074033, 241.83535800206553], 0, [-1465.8082380451083, 241.83535800206553], 0, [-1465.8082380451083, 234.83535800206553], 0, [-1747.4698773893706, 234.83535800206553], 0, true], 0, 10, 0, 3, 0, 1, ["Polyline", 1, 1, -1, false, 3, -1, [0, -1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 757.0918282392297, 199.97569398907103, 0, 1], 2, 2, [62.728362159705455, -81.25460132972853], -0.6202999489718836, [-102.6478640873703, -0.7574000218211268], -0.12204522179623141, true], 0, 10, 0, 3, 0, 1, ["Polyline", 1, 1, -1, false, 3, -1, [0, -1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 615.3934675834237, 37.87276939890694, 0, 1], 2, 2, [3.062518172307499, -73.61947577910792], -0.5578203020437067, [-67.19070005156576, 30.242619895222106], -0.08254084283422802, true], 0, 10, 0, 3, 0, 1, ["Circle", 1, 1, -1, false, 3, -1, [0, -1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 296.1754006981712, 336.45955497267846, 0, 1], 1, 15.87021639344266], 0, 10, 0, 3, 0, 1, ["Circle", 1, 1, -1, false, 3, -1, [0, -1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 299.3494439768467, 458.660221202186, 0, 1], 1, 5.610968815350429], 0, 10, 0, 3, 0, 1, ["Circle", 1, 1, -1, false, 4, -1, [0, -1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 537.4026898785589, 512.6189569398905, 0, 1], 1, 26.9326503136821], 0, 10, 0, 3, 0, 1, ["Circle", 1, 1, -1, false, 6, -1, [0, -1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 534.2286465998834, 261.869537923498, 0, 1], 1, 25.810456550614163], 0, 10, 0, 3, 0]]
let brs = loadFile(data);
let data =
[1, "Board", 1, 1, -1, false, 7, -1, [0, 0, 1, 0, 0, -1, 0, 0, 1, 0, 0, 0, -919.5114893425489, -2703.8098770005176, -134.6026210568009, 1], 1, 1, "Circle", 1, 1, -1, false, 7, -1, [0, -1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 382.3715309714528, 382.3715309714528, 0, 1], 1, 382.3715309714528, 0, 764.7430619429056, 764.7430619429056, 18, [0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, -919.5114893425489, -2703.8098770005176, -134.6026210568009, 1], 0, "层板", "{\"roomName\":\"\",\"cabinetName\":\"\",\"boardName\":\"\",\"material\":\"\",\"color\":\"\",\"lines\":0,\"bigHoleDir\":0,\"drillType\":\"three\",\"composingFace\":2,\"highSealed\":[],\"sealedUp\":\"1\",\"sealedDown\":\"1\",\"sealedLeft\":\"1\",\"sealedRight\":\"1\",\"knifeRad\":\"0\",\"grooveAddLength\":\"0\",\"grooveAddWidth\":\"0\",\"grooveAddDepth\":\"0\",\"spliteHeight\":\"\",\"spliteWidth\":\"\",\"spliteThickness\":\"\"}", 0, 12, 1, "Polyline", 1, 1, -1, false, 1, -1, [0, -1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 134.6026210568009, -1224.6532653675133, 0, 1], 2, 4, [-1985.6277286542445, 194.21699734632784], 0, [-1228.4218640236884, 194.21699734632784], 0.06505182506170779, [-1227.3723277647396, 293.288035597694], 0, [-1986.6772649131926, 293.288035597694], 0.06505182506170767, true, 0, 10, 0, 3, 0, 1, "Polyline", 1, 1, -1, false, 1, -1, [0, -1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 658.4697692228576, 691.9524021857917, 0, 1], 2, 2, [108.09377347199688, 48.88012586045511], -0.6501592260197776, [-36.242715090388515, -112.9601530205507], -0.14475251191859181, true, 0, 10, 0, 3, 0, 1, "Polyline", 1, 1, -1, false, 1, -1, [0, -1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 90.4398943583576, 629.3207306904399, 0, 1], 2, 2, [-49.8138945074669, 50.80997934732096], -0.9109068504784374, [58.36556874536063, -40.70059547852842], -0.09345012042788828, true, 0, 10, 0, 3, 0, 1, "Polyline", 1, 1, -1, false, 1, -1, [0, -1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 106.62611044415758, 117.47069904431623, 0, 1], 2, 2, [-53.9075765860091, -43.14301434924033], -0.9134441585739421, [45.27005907439718, 52.13413710723313], -0.09065675641591214, true, 0, 10, 0, 3, 0, 1, "Polyline", 1, 1, -1, false, 2, -1, [0, -1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 786.5650872556355, 426.693071038251, 0, 1], 2, 2, [106.7018657003265, -26.944722394258406], -0.694630372644427, [-98.32737655143399, -49.427049571531825], -0.13740047935395364, true, 0, 10, 0, 3, 0, 1, "Polyline", 1, 1, -1, false, 2, -1, [0, -1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 134.6026210568009, -1224.6532653675133, 0, 1], 2, 8, [-1742.842992143469, 270.75339078895075], 0, [-1465.8082380451083, 270.75339078895075], 0, [-1465.8082380451083, 264.75339078895075], 0, [-1734.1675823074033, 264.75339078895075], 0, [-1734.1675823074033, 241.83535800206553], 0, [-1465.8082380451083, 241.83535800206553], 0, [-1465.8082380451083, 234.83535800206553], 0, [-1747.4698773893706, 234.83535800206553], 0, true, 0, 10, 0, 3, 0, 1, "Polyline", 1, 1, -1, false, 3, -1, [0, -1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 757.0918282392297, 199.97569398907103, 0, 1], 2, 2, [62.728362159705455, -81.25460132972853], -0.6202999489718836, [-102.6478640873703, -0.7574000218211268], -0.12204522179623141, true, 0, 10, 0, 3, 0, 1, "Polyline", 1, 1, -1, false, 3, -1, [0, -1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 615.3934675834237, 37.87276939890694, 0, 1], 2, 2, [3.062518172307499, -73.61947577910792], -0.5578203020437067, [-67.19070005156576, 30.242619895222106], -0.08254084283422802, true, 0, 10, 0, 3, 0, 1, "Circle", 1, 1, -1, false, 3, -1, [0, -1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 296.1754006981712, 336.45955497267846, 0, 1], 1, 15.87021639344266, 0, 10, 0, 3, 0, 1, "Circle", 1, 1, -1, false, 3, -1, [0, -1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 299.3494439768467, 458.660221202186, 0, 1], 1, 5.610968815350429, 0, 10, 0, 3, 0, 1, "Circle", 1, 1, -1, false, 4, -1, [0, -1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 537.4026898785589, 512.6189569398905, 0, 1], 1, 26.9326503136821, 0, 10, 0, 3, 0, 1, "Circle", 1, 1, -1, false, 6, -1, [0, -1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 534.2286465998834, 261.869537923498, 0, 1], 1, 25.810456550614163, 0, 10, 0, 3, 0]
let brs = LoadBoardsFromFileData(data);
testPathCount(brs[0]);
data = [1, ["Board", 1, 1, 55, false, 7, -1, [0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1369.5548078237812, 1023.4201319657191, -0.00000703445402905345, 1], 1, 1, ["Polyline", 1, 1, -1, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 4, [0, 0], 0, [600, 0], 0, [600, 1200], 0, [0, 1200], 0, true], 0, 1200, 600, 18, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 1369.5548078237812, 1023.4201319657191, -0.00000703445402905345, 1], 1, "右侧板", "{\"roomName\":\"\",\"cabinetName\":\"\",\"boardName\":\"\",\"material\":\"\",\"color\":\"\",\"lines\":0,\"bigHoleDir\":0,\"drillType\":\"three\",\"composingFace\":2,\"highSealed\":[],\"sealedUp\":\"1\",\"sealedDown\":\"1\",\"sealedLeft\":\"1\",\"sealedRight\":\"1\",\"knifeRad\":\"0\",\"grooveAddLength\":\"0\",\"grooveAddWidth\":\"0\",\"grooveAddDepth\":\"0\",\"spliteHeight\":\"\",\"spliteWidth\":\"\",\"spliteThickness\":\"\"}", 0, 2, 1, ["Polyline", 1, 1, -1, false, 1, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -1112.552131147541, -16.083529411764744, 0, 1], 2, 4, [1231.0912524651885, 1062.969244235294], 0, [1585.4666497357766, 1062.969244235294], 0, [1585.4666497357766, 128.1994955294116], 0, [1228.3008950063647, 128.1994955294116], 0, true], 1, ["Polyline", 1, 1, -1, false, 1, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -1112.552131147541, -16.083529411764744, 0, 1], 2, 4, [1404.0934149122481, 647.2059828705881], 0, [1473.852351382836, 647.2059828705881], 0, [1473.852351382836, 809.046715482353], 0, [1404.0934149122481, 809.046715482353], 0, true], 3, 0, 3, 0, 1, ["Circle", 1, 1, -1, false, 2, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 291.54128376470703, 469.28172084705875, 0, 1], 1, 113.61929894258292], 0, 6, 0, 7, 0]]
brs = loadFile(data);
data =
[1, "Board", 1, 1, -1, false, 7, -1, [0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1369.5548078237812, 1023.4201319657191, -0.00000703445402905345, 1], 1, 1, "Polyline", 1, 1, -1, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 4, [0, 0], 0, [600, 0], 0, [600, 1200], 0, [0, 1200], 0, true, 0, 1200, 600, 18, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 1369.5548078237812, 1023.4201319657191, -0.00000703445402905345, 1], 1, "右侧板", "{\"roomName\":\"\",\"cabinetName\":\"\",\"boardName\":\"\",\"material\":\"\",\"color\":\"\",\"lines\":0,\"bigHoleDir\":0,\"drillType\":\"three\",\"composingFace\":2,\"highSealed\":[],\"sealedUp\":\"1\",\"sealedDown\":\"1\",\"sealedLeft\":\"1\",\"sealedRight\":\"1\",\"knifeRad\":\"0\",\"grooveAddLength\":\"0\",\"grooveAddWidth\":\"0\",\"grooveAddDepth\":\"0\",\"spliteHeight\":\"\",\"spliteWidth\":\"\",\"spliteThickness\":\"\"}", 0, 2, 1, "Polyline", 1, 1, -1, false, 1, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -1112.552131147541, -16.083529411764744, 0, 1], 2, 4, [1231.0912524651885, 1062.969244235294], 0, [1585.4666497357766, 1062.969244235294], 0, [1585.4666497357766, 128.1994955294116], 0, [1228.3008950063647, 128.1994955294116], 0, true, 1, "Polyline", 1, 1, -1, false, 1, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -1112.552131147541, -16.083529411764744, 0, 1], 2, 4, [1404.0934149122481, 647.2059828705881], 0, [1473.852351382836, 647.2059828705881], 0, [1473.852351382836, 809.046715482353], 0, [1404.0934149122481, 809.046715482353], 0, true, 3, 0, 3, 0, 1, "Circle", 1, 1, -1, false, 2, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 291.54128376470703, 469.28172084705875, 0, 1], 1, 113.61929894258292, 0, 6, 0, 7, 0]
brs = LoadBoardsFromFileData(data);
testPathCount(brs[0]);
})

@ -1,23 +1,23 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`changev 1`] = `"[1,3,[\\"BlockTableRecord\\",1,0,false,1,[\\"Line\\",1,1,3,false,7,-1,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],1,[2,3,4],[0,0,0]]],[\\"MaerialTableRecord\\",1,1,false,0],[\\"ObjectCollection\\",1,2,false,0],1,0,1,[\\"CommandHistoryRecord\\",1,\\"\\",2,0,1,[\\"HistorycRecord\\",1,[\\"RemoveObjectData\\",1,0],[\\"CreateObjectData\\",1,[[\\"Line\\",1,1,3,false,7,-1,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],1,[0,0,0],[0,0,0]]]],\\"\\"],3,1,[\\"ObjectAllDataHistoryRecord\\",1,1,[\\"AllObjectData\\",1,[1,1,3,false,7,-1,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],1,[0,0,0],[0,0,0]]],\\"\\",\\"\\",3]]]"`;
exports[`changev 1`] = `"[1,5,\\"BlockTableRecord\\",1,1,false,1,\\"Line\\",1,1,4,false,7,0,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],1,[2,3,4],[0,0,0],\\"MaerialTableRecord\\",1,2,false,0,\\"ObjectCollection\\",1,3,false,0,1,0,1,\\"CommandHistoryRecord\\",1,\\"\\",2,1,1,\\"HistorycRecord\\",1,\\"RemoveObjectData\\",1,0,\\"CreateObjectData\\",1,[\\"Line\\",1,1,4,false,7,0,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],1,[0,0,0],[0,0,0]],\\"\\",4,1,\\"ObjectAllDataHistoryRecord\\",1,1,\\"AllObjectData\\",1,[1,1,4,false,7,0,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],1,[0,0,0],[0,0,0]],\\"\\",\\"\\",4]"`;
exports[`创建 修改 撤销撤销 重做重做 撤销 重做 1`] = `"[1,3,[\\"BlockTableRecord\\",1,0,false,1,[\\"Line\\",1,1,3,false,7,-1,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],1,[1,2,3],[0,0,0]]],[\\"MaerialTableRecord\\",1,1,false,0],[\\"ObjectCollection\\",1,2,false,0],1,0,1,[\\"CommandHistoryRecord\\",1,\\"\\",2,0,1,[\\"HistorycRecord\\",1,[\\"RemoveObjectData\\",1,0],[\\"CreateObjectData\\",1,[[\\"Line\\",1,1,3,false,7,-1,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],1,[0,0,0],[0,0,0]]]],\\"\\"],3,1,[\\"ObjectAllDataHistoryRecord\\",1,1,[\\"AllObjectData\\",1,[1,1,3,false,7,-1,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],1,[0,0,0],[0,0,0]]],[\\"AllObjectData\\",1,[1,1,3,false,7,-1,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],1,[1,2,3],[0,0,0]]],\\"\\",3]]]"`;
exports[`创建 修改 撤销撤销 重做重做 撤销 重做 1`] = `"[1,5,\\"BlockTableRecord\\",1,1,false,1,\\"Line\\",1,1,4,false,7,0,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],1,[1,2,3],[0,0,0],\\"MaerialTableRecord\\",1,2,false,0,\\"ObjectCollection\\",1,3,false,0,1,0,1,\\"CommandHistoryRecord\\",1,\\"\\",2,1,1,\\"HistorycRecord\\",1,\\"RemoveObjectData\\",1,0,\\"CreateObjectData\\",1,[\\"Line\\",1,1,4,false,7,0,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],1,[0,0,0],[0,0,0]],\\"\\",4,1,\\"ObjectAllDataHistoryRecord\\",1,1,\\"AllObjectData\\",1,[1,1,4,false,7,0,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],1,[0,0,0],[0,0,0]],\\"AllObjectData\\",1,[1,1,4,false,7,0,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],1,[1,2,3],[0,0,0]],\\"\\",4]"`;
exports[`创建 修改 撤销撤销 重做重做 撤销 重做 2`] = `"[[\\"HistoricManage\\",1,0,1,[\\"CommandHistoryRecord\\",1,\\"\\",2,0,1,[\\"HistorycRecord\\",1,[\\"RemoveObjectData\\",1,0],[\\"CreateObjectData\\",1,[[\\"Line\\",1,1,3,false,7,-1,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],1,[0,0,0],[0,0,0]]]],\\"\\"],3,1,[\\"ObjectAllDataHistoryRecord\\",1,1,[\\"AllObjectData\\",1,[1,1,3,false,7,-1,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],1,[0,0,0],[0,0,0]]],[\\"AllObjectData\\",1,[1,1,3,false,7,-1,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],1,[1,2,3],[0,0,0]]],\\"\\",3]]]]"`;
exports[`创建 修改 撤销撤销 重做重做 撤销 重做 2`] = `"[\\"HistoricManage\\",1,0,1,\\"CommandHistoryRecord\\",1,\\"\\",2,1,1,\\"HistorycRecord\\",1,\\"RemoveObjectData\\",1,0,\\"CreateObjectData\\",1,[\\"Line\\",1,1,4,false,7,0,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],1,[0,0,0],[0,0,0]],\\"\\",4,1,\\"ObjectAllDataHistoryRecord\\",1,1,\\"AllObjectData\\",1,[1,1,4,false,7,0,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],1,[0,0,0],[0,0,0]],\\"AllObjectData\\",1,[1,1,4,false,7,0,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],1,[1,2,3],[0,0,0]],\\"\\",4]"`;
exports[`测试创建 1`] = `"[[\\"AllObjectData\\",1,[]]]"`;
exports[`测试创建 1`] = `"[\\"AllObjectData\\",1,[]]"`;
exports[`测试创建 2`] = `"[[\\"BlockTableRecord\\",1,-1,false,0]]"`;
exports[`测试创建 2`] = `"[\\"BlockTableRecord\\",1,0,false,0]"`;
exports[`测试创建 3`] = `"[[\\"CommandHistoryRecord\\",1,null,0]]"`;
exports[`测试创建 3`] = `"[\\"CommandHistoryRecord\\",1,null,0]"`;
exports[`测试创建 4`] = `"[[\\"CreateObjectData\\",1,[]]]"`;
exports[`测试创建 4`] = `"[\\"CreateObjectData\\",1,[]]"`;
exports[`测试创建 5`] = `"[[\\"HistorycRecord\\",1,\\"\\",\\"\\",\\"\\"]]"`;
exports[`测试创建 5`] = `"[\\"HistorycRecord\\",1,\\"\\",\\"\\",\\"\\"]"`;
exports[`测试创建 6`] = `"[[\\"Line\\",1,1,-1,false,7,-1,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],1,[0,0,0],[0,0,0]]]"`;
exports[`测试创建 6`] = `"[\\"Line\\",1,1,0,false,7,0,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],1,[0,0,0],[0,0,0]]"`;
exports[`测试创建 7`] = `"[[\\"ObjectAllDataHistoryRecord\\",1,1,\\"\\",\\"\\",\\"\\",-1]]"`;
exports[`测试创建 7`] = `"[\\"ObjectAllDataHistoryRecord\\",1,1,\\"\\",\\"\\",\\"\\",0]"`;
exports[`测试创建 8`] = `"[[\\"RemoveObjectData\\",1,null]]"`;
exports[`测试创建 8`] = `"[\\"RemoveObjectData\\",1,null]"`;

@ -2,7 +2,7 @@ import * as THREE from 'three';
import { AllObjectData } from '../../src/DatabaseServices/AllObjectData';
import { BlockTableRecord } from '../../src/DatabaseServices/BlockTableRecord';
import { CADFactory } from '../../src/DatabaseServices/CADFactory';
import { CADFile } from '../../src/DatabaseServices/CADFile';
import { CADFiler } from '../../src/DatabaseServices/CADFiler';
import { CADObject } from '../../src/DatabaseServices/CADObject';
import { CommandHistoryRecord } from '../../src/DatabaseServices/CommandHistoryRecord';
import { CreateObjectData } from '../../src/DatabaseServices/CreateObjectData';
@ -15,7 +15,7 @@ import { RemoveObjectData } from '../../src/DatabaseServices/RemoveObjectData';
function CadObjectToString(obj: CADObject)
{
let file = new CADFile();
let file = new CADFiler();
file.WriteObject(obj)
return file.ToString();
}
@ -40,7 +40,7 @@ test('测试创建', () =>
expect(str).toMatchSnapshot();
//确保对象正确的反序列化
let fileNew = new CADFile();
let fileNew = new CADFiler();
fileNew.Data = JSON.parse(str);
let objNew = CADFactory.CreateObject(C.name);
@ -147,13 +147,15 @@ test('xxx', () =>
db.hm.Redo();
let f = new CADFile();
let f = new CADFiler();
db.hm.WriteFile(f);
let db2 = new Database();
f.database = db2;
db2.hm.ReadFile(f);
let f3 = new CADFile();
let f3 = new CADFiler();
f3.database = db2;
db2.hm.WriteFile(f3);
expect(f3.ToString()).toBe(f.ToString());//对象序列化反序列化后 数据应该一样

@ -9,8 +9,8 @@ let fillet = new FilletUtils();
test('多段线首尾倒角有圆弧', () =>
{
TestFilletPolyline(
[1, ["Polyline", 1, 1, 3, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 375.4375364613715, 208.47861732064138, 0, 1], 2, 10, [-171.7455621301774, 180.2537770455558], -0.40012702806387124, [171.7455621301774, 180.2537770455558], 0, [221.74556213017775, 180.2537770455558], 0, [221.74556213017775, -72.32657236535573], 0, [-3.441731405810515, -260.5746253213081], 0, [-137.90517157255817, -260.5746253213081], 0, [-137.90517157255817, -37.838102302837456], 0, [-221.7455621301774, -37.838102302837456], 0, [-221.7455621301774, 180.2537770455558], 0, [-171.7455621301774, 180.2537770455558], 0, false]],
50,
[1, "Polyline", 1, 1, 0, false, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 375.4375364613715, 208.47861732064138, 0, 1], 2, 10, [-171.7455621301774, 180.2537770455558], -0.40012702806387124, [171.7455621301774, 180.2537770455558], 0, [221.74556213017775, 180.2537770455558], 0, [221.74556213017775, -72.32657236535573], 0, [-3.441731405810515, -260.5746253213081], 0, [-137.90517157255817, -260.5746253213081], 0, [-137.90517157255817, -37.838102302837456], 0, [-221.7455621301774, -37.838102302837456], 0, [-221.7455621301774, 180.2537770455558], 0, [-171.7455621301774, 180.2537770455558], 0, false]
, 50,
[new Vector3(178, 388), new Vector3(224, 460)]
)
});
@ -18,8 +18,8 @@ test('多段线首尾倒角有圆弧', () =>
test('多段线闭合标志首尾有弧', () =>
{
TestFilletPolyline(
[1, ["Polyline", 1, 1, 30, false, 1, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 2175.4664840507453, 164.7609132081223, 0, 1], 2, 6, [-171.7455621301774, 180.25377704555575], 0, [-221.7455621301774, 180.2537770455558], 0, [-221.7455621301774, -37.838102302837456], 0, [221.74556213017786, -37.838102302837456], 0, [221.74556213017786, 180.2537770455558], 0, [171.7455621301774, 180.25377704555575], 0.4001270280638712, true]],
50,
[1, "Polyline", 1, 1, 0, false, 1, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 2175.4664840507453, 164.7609132081223, 0, 1], 2, 6, [-171.7455621301774, 180.25377704555575], 0, [-221.7455621301774, 180.2537770455558], 0, [-221.7455621301774, -37.838102302837456], 0, [221.74556213017786, -37.838102302837456], 0, [221.74556213017786, 180.2537770455558], 0, [171.7455621301774, 180.25377704555575], 0.4001270280638712, true]
, 50,
[
new Vector3().fromArray([1978.720921920568, 345.01469025367805, 0]),
new Vector3().fromArray([2059.1464975640683, 384.8918356028163, 0]),
@ -35,8 +35,8 @@ test('双圆多段线倒角', () =>
{
//双圆
TestFilletPolyline(
[1, ["Polyline", 1, 1, 36, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 669.3126866217343, -478.9366812060718, 0, 1], 2, 3, [76.66953810162238, -86.81133085285757], -2.219258954152199, [71.33090803386779, 64.97443486580221], -3.5679817627813364, [76.66953810162238, -86.81133085285757], 0, false]],
50,
[1, "Polyline", 1, 1, 0, false, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 669.3126866217343, -478.9366812060718, 0, 1], 2, 3, [76.66953810162238, -86.81133085285757], -2.219258954152199, [71.33090803386779, 64.97443486580221], -3.5679817627813364, [76.66953810162238, -86.81133085285757], 0, false]
, 50,
[
new Vector3().fromArray([655.0295275228787, -390.0373584486947, 0]),
new Vector3().fromArray([794.1254343980869, -359.44086563487383, 0]),
@ -47,8 +47,8 @@ test('双圆多段线倒角', () =>
//双圆 CloseMark
TestFilletPolyline(
[1, ["Polyline", 1, 1, 37, false, 1, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 669.3126866217344, -478.9366812060718, 0, 1], 2, 2, [70.71115893702552, -76.919569940087], -2.2862716785205572, [71.33090803386779, 64.97443486580221], -3.8599589051482246, true]],
50,
[1, "Polyline", 1, 1, 0, false, 1, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 669.3126866217344, -478.9366812060718, 0, 1], 2, 2, [70.71115893702552, -76.919569940087], -2.2862716785205572, [71.33090803386779, 64.97443486580221], -3.8599589051482246, true]
, 50,
[
new Vector3().fromArray([655.0295275228787, -390.0373584486947, 0]),
new Vector3().fromArray([794.1254343980869, -359.44086563487383, 0]),

@ -1,7 +1,7 @@
import * as THREE from 'three';
import { Vector3 } from 'three';
import { Arc } from '../../src/DatabaseServices/Arc';
import { CADFile } from '../../src/DatabaseServices/CADFile';
import { CADFiler } from '../../src/DatabaseServices/CADFiler';
import { Circle } from '../../src/DatabaseServices/Circle';
import { Curve } from '../../src/DatabaseServices/Curve';
import { Line } from '../../src/DatabaseServices/Line';
@ -66,15 +66,20 @@ test('三维空间直线相交测试', () =>
})
test('三维空间圆圆相交测试', () =>
{
let data = [["Circle", 1, 1, 3, false, 7, -1, [-0.1485675258840154, -0.98346692600856, 0.10353982663678746, 0, 0.8068528994682419, -0.18108783903750572, -0.5623127183093208, 0, 0.5717657639911589, 0, 0.8204169129946106, 0, 5.585923427922135, -0.5874251796993211, -0.834443475807827, 1], 1, 2.1223349919617873], ["Circle", 1, 1, 9, false, 7, -1, [-0.1485675258840154, -0.98346692600856, 0.10353982663678746, 0, 0.8068528994682419, -0.18108783903750572, -0.5623127183093208, 0, 0.5717657639911589, 0, 0.8204169129946106, 0, 3.2540542870196947, -1.8996318241962369, 0.7906850652516981, 1], 1, 1.5840127550993974]]
let data =
[2, "Circle", 1, 1, 0, false, 7, 0, [-0.1485675258840154, -0.98346692600856, 0.10353982663678746, 0, 0.8068528994682419, -0.18108783903750572, -0.5623127183093208, 0, 0.5717657639911589, 0, 0.8204169129946106, 0, 5.585923427922135, -0.5874251796993211, -0.834443475807827, 1], 1, 2.1223349919617873, "Circle", 1, 1, 0, false, 7, 0, [-0.1485675258840154, -0.98346692600856, 0.10353982663678746, 0, 0.8068528994682419, -0.18108783903750572, -0.5623127183093208, 0, 0.5717657639911589, 0, 0.8204169129946106, 0, 3.2540542870196947, -1.8996318241962369, 0.7906850652516981, 1], 1, 1.5840127550993974]
testCirAndCirIntersect(data);
data = [["Circle", 1, 1, 3, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 1, 5], ["Circle", 1, 1, 4, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 2.5, 0, 0, 1], 1, 5]];
data =
[2, "Circle", 1, 1, 0, false, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 1, 5, "Circle", 1, 1, 0, false, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 2.5, 0, 0, 1], 1, 5]
testCirAndCirIntersect(data);
data = [["Circle", 1, 1, 5, false, 7, -1, [1, 0, 0, 0, 0, 0, 1, 0, 0, -1, 0, 0, 0, 0, 0, 1], 1, 5], ["Circle", 1, 1, 6, false, 7, -1, [1, 0, 0, 0, 0, 0, 1, 0, 0, -1, 0, 0, 2.5, 0, 0, 1], 1, 5]];
data =
[2, "Circle", 1, 1, 0, false, 7, 0, [1, 0, 0, 0, 0, 0, 1, 0, 0, -1, 0, 0, 0, 0, 0, 1], 1, 5, "Circle", 1, 1, 0, false, 7, 0, [1, 0, 0, 0, 0, 0, 1, 0, 0, -1, 0, 0, 2.5, 0, 0, 1], 1, 5]
testCirAndCirIntersect(data);
data = [["Arc", 1, 1, 10, false, 7, -1, [0, -1, 0, 0, 0, 0, 1, 0, -1, 0, 0, 0, 0, -7.223901135674274, -7.066640793063616, 1], 2, 4.787455889013074, 2.4468553886273967, 0.7203768859081977, true], ["Arc", 1, 1, 11, false, 7, -1, [0, -1, 0, 0, 0, 0, 1, 0, -1, 0, 0, 0, 0, -12.887397630639091, -5.59172322768673, 1], 2, 4.265691675276281, 3.020045238916937, 0.9631807673370143, true]]
data =
[2, "Arc", 1, 1, 0, false, 7, 0, [0, -1, 0, 0, 0, 0, 1, 0, -1, 0, 0, 0, 0, -7.223901135674274, -7.066640793063616, 1], 2, 4.787455889013074, 2.4468553886273967, 0.7203768859081977, true, "Arc", 1, 1, 0, false, 7, 0, [0, -1, 0, 0, 0, 0, 1, 0, -1, 0, 0, 0, 0, -12.887397630639091, -5.59172322768673, 1], 2, 4.265691675276281, 3.020045238916937, 0.9631807673370143, true]
testCirAndCirIntersect(data);
data = [["Circle", 1, 1, 4, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 2.5, 0, 0, 1], 1, 5], ["Circle", 1, 1, 6, false, 7, -1, [1, 0, 0, 0, 0, 0, 1, 0, 0, -1, 0, 0, 2.5, 0, 0, 1], 1, 5]];
data =
[2, "Circle", 1, 1, 0, false, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 2.5, 0, 0, 1], 1, 5, "Circle", 1, 1, 0, false, 7, 0, [1, 0, 0, 0, 0, 0, 1, 0, 0, -1, 0, 0, 2.5, 0, 0, 1], 1, 5]
testCirAndCirIntersect(data);
})
test('三维空间直线和圆相交测试', () =>
@ -104,7 +109,7 @@ test('补充相交测试', () =>
})
function loadFile(data)
{
let file = new CADFile();
let file = new CADFiler();
file.Data = data;
let cus: Curve[] = [];
for (let i = 0; i < file.Data.length; i++)
@ -142,7 +147,7 @@ test('直线和圆 圆心和直线重合的时候', () =>
test('直线和圆相切', () =>
{
let data =
[["Line", 1, 1, 24, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0.33854166666666696, 0, 1], 1, [23700.893770110895, 6917.069643795053, 0], [34450.21257120082, 3606.4429407977773, 0]], ["Circle", 1, 1, 29, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 34567.94904695702, 3989.061644487676, 0, 1], 1, 400]]
[2, "Line", 1, 1, 0, false, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0.33854166666666696, 0, 1], 1, [23700.893770110895, 6917.069643795053, 0], [34450.21257120082, 3606.4429407977773, 0], "Circle", 1, 1, 0, false, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 34567.94904695702, 3989.061644487676, 0, 1], 1, 400]
let cus = loadFile(data) as Array<Curve>;
let pts = cus[0].IntersectWith(cus[1], 0);

@ -2,7 +2,7 @@ import { Vector2, Vector3 } from 'three';
import { IsPointInPolyLine } from '../../src/DatabaseServices/PointInPolyline';
import { Polyline } from '../../src/DatabaseServices/Polyline';
import { CADFile } from '../../src/DatabaseServices/CADFile';
import { CADFiler } from '../../src/DatabaseServices/CADFiler';
test('点在多段线内', () =>
@ -146,15 +146,10 @@ describe("", () =>
test('点在曲线外精度问题', () =>
{
let plData = [["Polyline", 1, 1, 4317, false, 3, -1,
[1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1],
2, 5,
[-3, 3.6739403974420594e-16], 0.9999999999999999,
[3, 3.6739403974420594e-16], 0, [3, 10], 0.9999999999999999,
[-3, 10], 0, [-3, -3.6739403974420594e-16], 0,
false]];
let plData =
[1, "Polyline", 1, 1, 0, false, 3, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 5, [-3, 3.6739403974420594e-16], 0.9999999999999999, [3, 3.6739403974420594e-16], 0, [3, 10], 0.9999999999999999, [-3, 10], 0, [-3, -3.6739403974420594e-16], 0, false]
let f = new CADFile();
let f = new CADFiler();
f.Data = plData;
let pl = f.ReadObject(undefined) as Polyline;
@ -167,9 +162,9 @@ describe("", () =>
test('精度过低导致的错误', () =>
{
let f = new CADFile();
let f = new CADFiler();
f.Data =
[1, ["Polyline", 1, 1, 18237, false, 2, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0.7938671363300003, 0.39666461398798525, 0, 1], 2, 5, [12.414545456418505, 8.796498405316765], 0, [12.015990240675425, 8.743859037199755], 0, [12.23362472371057, 8.552710046188702], 0, [12.233990240675425, 8.552758322014249], 0, [12.414545456418505, 8.796498405316765], 0, false]]
[1, "Polyline", 1, 1, 0, false, 2, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0.7938671363300003, 0.39666461398798525, 0, 1], 2, 5, [12.414545456418505, 8.796498405316765], 0, [12.015990240675425, 8.743859037199755], 0, [12.23362472371057, 8.552710046188702], 0, [12.233990240675425, 8.552758322014249], 0, [12.414545456418505, 8.796498405316765], 0, false]
let p = new Vector3().fromArray([13.027857377005425, 8.947146562082409, 0]);
@ -181,9 +176,9 @@ describe("", () =>
test('圆弧起点切线与直线相切IKOTO', () =>
{
let f = new CADFile();
let f = new CADFiler();
f.Data =
[1, ["Polyline", 1, 1, 4, false, 2, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 2.1413261486708848, -0.2136470533821324, 0, 1], 2, 5, [376.7856405585377, -104.2720901386406], -0.9999999999999999, [378.6693614887703, -104.2720901386406], 0, [378.4693614887703, -104.2720901386406], 0.9999999999999999, [376.9856405585377, -104.2720901386406], 0, [376.7856405585377, -104.2720901386406], 0, false]]
[1, "Polyline", 1, 1, 0, false, 2, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 2.1413261486708848, -0.2136470533821324, 0, 1], 2, 5, [376.7856405585377, -104.2720901386406], -0.9999999999999999, [378.6693614887703, -104.2720901386406], 0, [378.4693614887703, -104.2720901386406], 0.9999999999999999, [376.9856405585377, -104.2720901386406], 0, [376.7856405585377, -104.2720901386406], 0, false]
let p = new Vector3().fromArray([380.6106876374412, -106.61364416876692, 0]);
@ -194,9 +189,9 @@ describe("", () =>
test('直线和圆弧相切IKOTO', () =>
{
let f = new CADFile();
let f = new CADFiler();
f.Data =
[1, ["Polyline", 1, 1, 667, false, 6, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 5, [5135.438782795266, 1651.835443234731], -0.9999915853997117, [5470.58864251807, 1651.8382633987026], 0, [5370.588642280742, 1651.8413831024218], 0.9999560507337252, [5235.438782795266, 1651.835443234731], 0, [5135.438782795266, 1651.835443234731], 0, false]]
[1, "Polyline", 1, 1, 0, false, 6, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 5, [5135.438782795266, 1651.835443234731], -0.9999915853997117, [5470.58864251807, 1651.8382633987026], 0, [5370.588642280742, 1651.8413831024218], 0.9999560507337252, [5235.438782795266, 1651.835443234731], 0, [5135.438782795266, 1651.835443234731], 0, false]
f.Read();
@ -211,9 +206,9 @@ describe("", () =>
test('大圆弧', () =>
{
let f = new CADFile();
let f = new CADFiler();
f.Data =
[1, ["Polyline", 1, 1, 5, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 3, [5.113122171945702, 3.235294117647059], 2.037852023242286, [6.69683257918552, 0.7918552036199095], 0, [5.113122171945702, 3.235294117647059], 0, false]]
[1, "Polyline", 1, 1, 0, false, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 3, [5.113122171945702, 3.235294117647059], 2.037852023242286, [6.69683257918552, 0.7918552036199095], 0, [5.113122171945702, 3.235294117647059], 0, false]
let p = new Vector3().fromArray([5.113122171945701, 0.7239819004524888, 0]);
f.Read();

@ -1,4 +1,4 @@
import { CADFile } from '../../src/DatabaseServices/CADFile';
import { CADFiler } from '../../src/DatabaseServices/CADFiler';
import { Polyline } from '../../src/DatabaseServices/Polyline';
import { GetPointAtCurveDir } from '../../src/Common/CurveUtils';
import { Vector3, Vector2 } from 'three';
@ -7,9 +7,9 @@ import { Factory } from '../../src/DatabaseServices/CADFactory';
Factory(Polyline);
test('2个大圆中间', () =>
{
let f = new CADFile();
let f = new CADFiler();
f.Data =
[1, ["Polyline", 1, 1, 17, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 3, [108.37693694676932, 28.257776463252547], 0.4472440944881872, [108.37693694676932, 17.68555707305448], 3.5940684866260213, [111.70676982557188, 14.089337563947739], 0.5086040192926764, false]]
[1, "Polyline", 1, 1, 0, false, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 3, [108.37693694676932, 28.257776463252547], 0.4472440944881872, [108.37693694676932, 17.68555707305448], 3.5940684866260213, [111.70676982557188, 14.089337563947739], 0.5086040192926764, false]
f.Read();
let pl = f.ReadObject() as Polyline;
@ -26,9 +26,9 @@ test('2个大圆中间', () =>
test('点在端点且端点平行', () =>
{
let f = new CADFile();
let f = new CADFiler();
f.Data =
[1, ["Polyline", 1, 1, 16, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 43.1743189069092, -3.552713678800501e-15, 0, 1], 2, 3, [35.26780526232293, 5.878508963172803], -0.8898689681740283, [35.26780526232293, 13.326990467988661], 0, [35.26780526232293, 23.770222268555234], 0, false]]
[1, "Polyline", 1, 1, 0, false, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 43.1743189069092, -3.552713678800501e-15, 0, 1], 2, 3, [35.26780526232293, 5.878508963172803], -0.8898689681740283, [35.26780526232293, 13.326990467988661], 0, [35.26780526232293, 23.770222268555234], 0, false]
f.Read();
let pl = f.ReadObject() as Polyline;
@ -55,9 +55,9 @@ test('点在和端点平行', () =>
test('点在端点上且点在圆心上', () =>
{
let f = new CADFile();
let f = new CADFiler();
f.Data =
[1, ["Polyline", 1, 1, 31, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 5, [17.513342658829444, 9.06588623278316], 0, [19.513342658829444, 9.06588623278316], 0.9999999999999999, [19.513342658829444, 7.06588623278316], -0.9999999999999999, [19.513342658829444, 5.06588623278316], 0, [17.513342658829444, 5.06588623278316], 0, true]]
[1, "Polyline", 1, 1, 0, false, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 5, [17.513342658829444, 9.06588623278316], 0, [19.513342658829444, 9.06588623278316], 0.9999999999999999, [19.513342658829444, 7.06588623278316], -0.9999999999999999, [19.513342658829444, 5.06588623278316], 0, [17.513342658829444, 5.06588623278316], 0, true]
f.Read();
let pl = f.ReadObject() as Polyline;
@ -70,9 +70,9 @@ test('点在端点上且点在圆心上', () =>
test('存在精度误差,并且点在圆内', () =>
{
let f = new CADFile();
let f = new CADFiler();
f.Data =
[1, ["Polyline", 1, 1, 3, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 5, [0, 0], 0, [2, 0], 1, [2, 2], -1, [2, 4], 0, [0, 4], 0, true]]
[1, "Polyline", 1, 1, 0, false, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 5, [0, 0], 0, [2, 0], 1, [2, 2], -1, [2, 4], 0, [0, 4], 0, true]
f.Read();
let pl = f.ReadObject() as Polyline;
@ -102,9 +102,9 @@ test('存在精度误差,并且点在圆内', () =>
test('大于1凸度的圆', () =>
{
let f = new CADFile();
let f = new CADFiler();
f.Data =
[1, ["Polyline", 1, 1, 46, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 4, [0, 0], 0, [1, 0], 3.7050811739160006, [1, 1.7149500468022372], 0, [0, 1.7149500468022374], 0, true]]
[1, "Polyline", 1, 1, 0, false, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 4, [0, 0], 0, [1, 0], 3.7050811739160006, [1, 1.7149500468022372], 0, [0, 1.7149500468022374], 0, true]
f.Read();
let pl = f.ReadObject() as Polyline;
@ -117,9 +117,9 @@ test('大于1凸度的圆', () =>
test('盲区计算', () =>
{
let f = new CADFile();
let f = new CADFiler();
f.Data =
[1, ["Polyline", 1, 1, 65, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 3, [0, 0], 0, [1, 0], 0.6998085535161632, [1, -1], -1.9959956751332304, false]]
[1, "Polyline", 1, 1, 0, false, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 3, [0, 0], 0, [1, 0], 0.6998085535161632, [1, -1], -1.9959956751332304, false]
f.Read();
let pl = f.ReadObject() as Polyline;
@ -139,9 +139,9 @@ test('盲区计算', () =>
test('参数点在终点上', () =>
{
let f = new CADFile();
let f = new CADFiler();
f.Data =
[1, ["Polyline", 1, 1, 38, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 9, [26.388805509867886, 5.284389892538414], 0, [28.388805509867886, 5.284389892538414], 0.9999999999999999, [28.388805509867886, 7.284389892538414], -0.9999999999999999, [28.388805509867886, 9.284389892538414], 0, [24.129449189553043, 9.284389892538414], 0, [24.129449189553043, 13.772242014802323], 0, [33.10581078647962, 13.772242014802321], 0, [33.10581078647962, 0.368763303745288], 0, [27.762738407356657, 0.36876330374528865], 0, true]]
[1, "Polyline", 1, 1, 0, false, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 9, [26.388805509867886, 5.284389892538414], 0, [28.388805509867886, 5.284389892538414], 0.9999999999999999, [28.388805509867886, 7.284389892538414], -0.9999999999999999, [28.388805509867886, 9.284389892538414], 0, [24.129449189553043, 9.284389892538414], 0, [24.129449189553043, 13.772242014802323], 0, [33.10581078647962, 13.772242014802321], 0, [33.10581078647962, 0.368763303745288], 0, [27.762738407356657, 0.36876330374528865], 0, true]
f.Read();
let pl = f.ReadObject() as Polyline;
let pt = new Vector3().fromArray([24.40481807693597, 4.679455426066854, 0]);
@ -164,9 +164,9 @@ test('参数点在终点上', () =>
test('点在小角内', () =>
{
let f = new CADFile();
let f = new CADFiler();
f.Data =
[1, ["Polyline", 1, 1, 27, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -47.5997122622927, 10.897558314909338, 0, 1], 2, 4, [-0.906131771640112, 6.969061295372345], 3.7897716494829594, [4.660056657223795, 6.487252124645892], 0, [20.106696883852685, 18.393201133144473], 0, [9.169563739376775, 22.583048158640217], 0, false]]
[1, "Polyline", 1, 1, 0, false, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -47.5997122622927, 10.897558314909338, 0, 1], 2, 4, [-0.906131771640112, 6.969061295372345], 3.7897716494829594, [4.660056657223795, 6.487252124645892], 0, [20.106696883852685, 18.393201133144473], 0, [9.169563739376775, 22.583048158640217], 0, false]
f.Read();
let pl = f.ReadObject() as Polyline;
@ -183,9 +183,9 @@ test('点在小角内', () =>
test('首尾点相等', () =>
{
let f = new CADFile();
let f = new CADFiler();
f.Data =
[1, ["Polyline", 1, 1, 264, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 6, [0, 0], 0, [5, 0], 0.9999999999999999, [5, 5], -0.9999999999999999, [5, 10], 0, [0, 10], 0, [0, 0], 0, false]]
[1, "Polyline", 1, 1, 0, false, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 6, [0, 0], 0, [5, 0], 0.9999999999999999, [5, 5], -0.9999999999999999, [5, 10], 0, [0, 10], 0, [0, 0], 0, false]
f.Read();
let pl = f.ReadObject() as Polyline;
@ -201,9 +201,9 @@ test('首尾点相等', () =>
test('点在圆弧的弦中心上', () =>
{
let f = new CADFile();
let f = new CADFiler();
f.Data =
[1, ["Polyline", 1, 1, 264, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 6, [0, 0], 0, [5, 0], 0.9999999999999999, [5, 5], -0.9999999999999999, [5, 10], 0, [0, 10], 0, [0, 0], 0, false]]
[1, "Polyline", 1, 1, 0, false, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 6, [0, 0], 0, [5, 0], 0.9999999999999999, [5, 5], -0.9999999999999999, [5, 10], 0, [0, 10], 0, [0, 0], 0, false]
f.Read();
let pl = f.ReadObject() as Polyline;
@ -225,9 +225,9 @@ test('点在圆弧的弦中心上', () =>
test('圆弧过大导致直线小角错误', () =>
{
let f = new CADFile();
let f = new CADFiler();
f.Data =
[1, ["Polyline", 1, 1, 3, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -0.028011204481791063, 0.028011204481792618, 0, 1], 2, 4, [-2241.358078364921, -214.80916327845875], -1.1401903887488165, [-2190.503423306555, -220.10318099746846], -1.1044015866963386, [-2231.667025600985, -212.01859443849355], 0, [-2241.358078364921, -214.80916327845875], 0, false]]
[1, "Polyline", 1, 1, 0, false, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -0.028011204481791063, 0.028011204481792618, 0, 1], 2, 4, [-2241.358078364921, -214.80916327845875], -1.1401903887488165, [-2190.503423306555, -220.10318099746846], -1.1044015866963386, [-2231.667025600985, -212.01859443849355], 0, [-2241.358078364921, -214.80916327845875], 0, false]
f.Read();
let pl = f.ReadObject() as Polyline;

@ -1,20 +1,13 @@
import { Factory } from "../../src/DatabaseServices/CADFactory";
import { CADFile } from "../../src/DatabaseServices/CADFile";
import { CADFiler } from "../../src/DatabaseServices/CADFiler";
import { Curve } from "../../src/DatabaseServices/Curve";
import { Polyline } from "../../src/DatabaseServices/Polyline";
import { LoadEntityFromFileData } from "../Utils/LoadEntity.util";
Factory(Polyline);
function loadFile(data)
{
let file = new CADFile();
file.Data = data;
let cus: Curve[] = [];
let count = file.Read();
for (let i = 0; i < count; i++)
{
cus.push(file.ReadObject(undefined) as Curve);
}
return cus;
return LoadEntityFromFileData(data) as Curve[];
}
function EntityToMatchSnapshot(ens: Curve[])
@ -34,11 +27,9 @@ function testOffset(pl: Curve, dis)
test('IKKGK圆与直线补圆弧', () =>
{
let f = new CADFile();
f.Data =
[1, ["Polyline", 1, 1, 5, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -47.808747539346534, 10.92028558763661, 0, 1], 2, 3, [-0.906131771640112, 6.969061295372345], 3.7897716494829594, [4.660056657223795, 6.487252124645892], 0, [18.466397865202012, 17.128892766521286], 0, false]]
f.Read();
let pl = f.ReadObject() as Polyline;
let pl = loadFile(
[1, "Polyline", 1, 1, 0, false, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -47.808747539346534, 10.92028558763661, 0, 1], 2, 3, [-0.906131771640112, 6.969061295372345], 3.7897716494829594, [4.660056657223795, 6.487252124645892], 0, [18.466397865202012, 17.128892766521286], 0, false]
)[0] as Polyline;
//负1 左边. 禁止补圆弧
let cus = pl.GetOffsetCurves(-1);
@ -64,7 +55,7 @@ describe("闭合多段线", () =>
test('闭合多段线偏移测试1', () =>
{
let data =
[1, ["Polyline", 1, 1, 3, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 4, [6.059716713881022, 3.983456090651555], 1.1217395195062214, [6.383002832861191, 4.064022662889515], 0, [4.929178470254959, 8.399433427762037], 1.2642365052895204, [5.750708215297452, 4.050991501416427], 0.7171789779484218, true]]
[1, "Polyline", 1, 1, 0, false, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 4, [6.059716713881022, 3.983456090651555], 1.1217395195062214, [6.383002832861191, 4.064022662889515], 0, [4.929178470254959, 8.399433427762037], 1.2642365052895204, [5.750708215297452, 4.050991501416427], 0.7171789779484218, true]
let cus = loadFile(data);
for (let i = 1; i < 10; i += 1)
{
@ -82,7 +73,7 @@ describe("闭合多段线", () =>
test('闭合多段线偏移测试2', () =>
{
let data =
[1, ["Polyline", 1, 1, 734, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 4, [8.176442643449754, 4.003694129881114], 0.6482011490054378, [8.554554536583165, 4.090460859042256], 0, [7.7292787370841225, 8.733182129315965], 0, [7.8227800907745895, 4.037582052934876], 1.223388515290821, true]]
[1, "Polyline", 1, 1, 0, false, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 4, [8.176442643449754, 4.003694129881114], 0.6482011490054378, [8.554554536583165, 4.090460859042256], 0, [7.7292787370841225, 8.733182129315965], 0, [7.8227800907745895, 4.037582052934876], 1.223388515290821, true]
let cus = loadFile(data);
expect(cus[0].GetOffsetCurves(-0.1799).length).toBe(2);
@ -107,7 +98,7 @@ describe("闭合多段线", () =>
test('闭合多段线偏移测试3', () =>
{
let data =
[1, ["Polyline", 1, 1, 1172, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 5, [12.52535684411379, 4.512623511896158], 0.39558516940595195, [13.121416971132648, 4.487590129452889], 0, [12.414545456418505, 8.796498405316765], 0, [12.015990240675425, 8.743859037199755], 0, [12.015990240675425, 4.4951100391838885], 0.8508932598252141, true]]
[1, "Polyline", 1, 1, 0, false, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 5, [12.52535684411379, 4.512623511896158], 0.39558516940595195, [13.121416971132648, 4.487590129452889], 0, [12.414545456418505, 8.796498405316765], 0, [12.015990240675425, 8.743859037199755], 0, [12.015990240675425, 4.4951100391838885], 0.8508932598252141, true]
let cus = loadFile(data);
for (let i = 0.5; i < 10; i += 1)
@ -126,7 +117,7 @@ describe("闭合多段线", () =>
test('闭合多段线偏移测试4', () =>
{
let data =
[1, ["Polyline", 1, 1, 1453, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 5, [17.138593827490823, 4.9429359111242475], 0.6262511063576436, [18.12066066115083, 4.8347623552068075], 0, [18.12066066115083, 10.450468898178228], 0, [16.250318720818097, 10.450468898178228], 0, [16.250318720818097, 4.952028938447833], 0.8739221457690426, true]];
[1, "Polyline", 1, 1, 0, false, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 5, [17.138593827490823, 4.9429359111242475], 0.6262511063576436, [18.12066066115083, 4.8347623552068075], 0, [18.12066066115083, 10.450468898178228], 0, [16.250318720818097, 10.450468898178228], 0, [16.250318720818097, 4.952028938447833], 0.8739221457690426, true]
let cus = loadFile(data);
for (let i = 1; i < 10; i += 2)
{
@ -141,7 +132,8 @@ describe("闭合多段线", () =>
expect(cus[0].GetOffsetCurves(-i).length).toBe(0);
}
//变换曲线顺序
data = [1, ["Polyline", 1, 1, 1891, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 5, [22.178278439318607, -1.9155229050126357], 0, [22.83746943877066, -1.800164480108526], 0, [23.79329638797614, -6.11786552651948], -0.871731137783436, [23.348342463346004, -6.282663276382493], -0.7430788314178012, [22.903388538715866, -6.267501883395095], 0, true]];
data =
[1,"Polyline",1,1,0,false,7,0,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],2,5,[22.178278439318607,-1.9155229050126357],0,[22.83746943877066,-1.800164480108526],0,[23.79329638797614,-6.11786552651948],-0.871731137783436,[23.348342463346004,-6.282663276382493],-0.7430788314178012,[22.903388538715866,-6.267501883395095],0,true]
cus = loadFile(data);
for (let i = 0.01; i <= 0.33; i += 0.03)
{
@ -155,7 +147,7 @@ describe("闭合多段线", () =>
test('闭合多段线偏移测试5', () =>
{
let data =
[1, ["Polyline", 1, 1, 264, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 6, [0, 0], 0, [5, 0], 0.9999999999999999, [5, 5], -0.9999999999999999, [5, 10], 0, [0, 10], 0, [0, 0], 0, false]];
[1, "Polyline", 1, 1, 0, false, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 6, [0, 0], 0, [5, 0], 0.9999999999999999, [5, 5], -0.9999999999999999, [5, 10], 0, [0, 10], 0, [0, 0], 0, false]
let cus = loadFile(data);
for (let i = 0.5; i < 10; i += 1.5)
{
@ -197,7 +189,7 @@ describe("闭合多段线", () =>
test('闭合多段线偏移测试6', () =>
{
let data =
[1, ["Polyline", 1, 1, 11080, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -2.007355593658339, -15.226898894860806, 0, 1], 2, 6, [0.06393073988345588, -13.474722415885717], 0, [0.06393073988345643, -4.4950563800695225], 0, [6.069811270331949, -4.495056380069524], -0.9999999999999999, [6.0698112703319484, -9.101508437403805], 0.8261854469247998, [6.069811270331948, -13.53303193559881], 0, [0.06393073988345588, -13.474722415885717], 0, false]];
[1, "Polyline", 1, 1, 0, false, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -2.007355593658339, -15.226898894860806, 0, 1], 2, 6, [0.06393073988345588, -13.474722415885717], 0, [0.06393073988345643, -4.4950563800695225], 0, [6.069811270331949, -4.495056380069524], -0.9999999999999999, [6.0698112703319484, -9.101508437403805], 0.8261854469247998, [6.069811270331948, -13.53303193559881], 0, [0.06393073988345588, -13.474722415885717], 0, false]
let cus = loadFile(data);
for (let i = 0.5; i < 10; i += 1)//i+=0.5
{
@ -216,7 +208,7 @@ describe("闭合多段线", () =>
test('闭合多段线偏移测试7', () =>
{
let data =
[1, ["Polyline", 1, 1, 3103, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 6, [7.068575921553821, 19.385189367549113], 0, [17.866251977281493, 27.179961431447197], -0.7242773730087224, [27.449988121418478, 20.215779833374317], -0.5496546648274403, [21.06083069199382, 18.554598901723907], 0.7351204491094537, [17.802360402987244, 16.70174324719076], -1.609719383557213, [7.068575921553821, 19.385189367549113], 0, true]];
[1, "Polyline", 1, 1, 0, false, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 6, [7.068575921553821, 19.385189367549113], 0, [17.866251977281493, 27.179961431447197], -0.7242773730087224, [27.449988121418478, 20.215779833374317], -0.5496546648274403, [21.06083069199382, 18.554598901723907], 0.7351204491094537, [17.802360402987244, 16.70174324719076], -1.609719383557213, [7.068575921553821, 19.385189367549113], 0, true]
let cus = loadFile(data);
//外偏移
for (let i = 0.5; i < 5.5; i += 1)
@ -242,7 +234,7 @@ describe("闭合多段线", () =>
test('闭合多段线偏移测试8', () =>
{
let data =
[1, ["Polyline", 1, 1, 8895, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 9, [-35.77751476623335, 275.4953263952156], 0, [220.87993293360785, 358.6317790975911], 0, [317.8724610863793, 154.43698298649332], 0, [128.26300755464567, 91.72000989522755], 0, [202.6482547094027, 193.81740795077644], 0, [96.90452100901277, 149.33211308371583], 0, [167.64343251892882, 238.30270281783706], 0, [-5.9221441755043855, 147.87357882577945], 0, [115.1361992332179, 265.2855865896607], 0, true]];
[1, "Polyline", 1, 1, 0, false, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 9, [-35.77751476623335, 275.4953263952156], 0, [220.87993293360785, 358.6317790975911], 0, [317.8724610863793, 154.43698298649332], 0, [128.26300755464567, 91.72000989522755], 0, [202.6482547094027, 193.81740795077644], 0, [96.90452100901277, 149.33211308371583], 0, [167.64343251892882, 238.30270281783706], 0, [-5.9221441755043855, 147.87357882577945], 0, [115.1361992332179, 265.2855865896607], 0, true]
let cus = loadFile(data);
//外偏移 -
for (let i = 20; i < 200; i += 100)
@ -270,7 +262,7 @@ describe("闭合多段线", () =>
test('闭合多段线偏移测试9', () =>
{
let data =
[1, ["Polyline", 1, 1, 12283, false, 2, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -2494.1602062139054, -154.37421492307953, 0, 1], 2, 4, [-835.9056689963722, -81.71614968554674], -1.404257507243489, [-2.5205246091134654, -224.3682931983378], -0.7704346688180675, [-677.9527382520764, -55.635630094036955], 0, [-835.9056689963722, -81.71614968554674], 0, false]];
[1, "Polyline", 1, 1, 0, false, 2, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -2494.1602062139054, -154.37421492307953, 0, 1], 2, 4, [-835.9056689963722, -81.71614968554674], -1.404257507243489, [-2.5205246091134654, -224.3682931983378], -0.7704346688180675, [-677.9527382520764, -55.635630094036955], 0, [-835.9056689963722, -81.71614968554674], 0, false]
let cus = loadFile(data);
//外偏移 -
//内偏移+
@ -295,7 +287,7 @@ describe("闭合多段线", () =>
test('闭合多段线偏移测试10', () =>
{
let data =
[1, ["Polyline", 1, 1, 4133, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -38.7066882611841, -36.73336766355714, 0, 1], 2, 10, [57.916496677407835, -1.0361149153581897], 0, [57.916496677407835, 9.149866136686853], 0, [63.00948720343037, 6.40233177396418], 0, [67.96845166297861, 11.696361399698116], 0, [67.96845166297861, 5.866227508067071], 0, [76.41209385085804, 8.144670638129776], -0.6438035714487224, [82.13500688930966, 1.215523001409662], -0.16133386709235895, [73.7315725213725, -7.388950466238915], -0.24328993833238707, [62.473382937533245, -7.388950466238914], 0.16864648307761998, [53.5472469103464, -6.102300228085856], -1.9523252757782097, true]]
[1, "Polyline", 1, 1, 0, false, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -38.7066882611841, -36.73336766355714, 0, 1], 2, 10, [57.916496677407835, -1.0361149153581897], 0, [57.916496677407835, 9.149866136686853], 0, [63.00948720343037, 6.40233177396418], 0, [67.96845166297861, 11.696361399698116], 0, [67.96845166297861, 5.866227508067071], 0, [76.41209385085804, 8.144670638129776], -0.6438035714487224, [82.13500688930966, 1.215523001409662], -0.16133386709235895, [73.7315725213725, -7.388950466238915], -0.24328993833238707, [62.473382937533245, -7.388950466238914], 0.16864648307761998, [53.5472469103464, -6.102300228085856], -1.9523252757782097, true]
let cus = loadFile(data);
//外偏移 -
for (let i = 5; i < 20; i += 5)
@ -321,7 +313,7 @@ describe("闭合多段线", () =>
test('闭合多段线偏移测试11', () =>
{
let data =
[1, ["Polyline", 1, 1, 109, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 9, [8.533519553072624, 3.044692737430166], 0, [8.198324022346368, 5.782122905027932], 0, [9.483240223463685, 4.594972067039105], 0, [10.293296089385473, 4.958100558659217], 0, [11.298882681564244, 3.50558659217877], 0, [11.648044692737429, 3.1424581005586587], 0, [9.525139664804467, 2.3324022346368705], 0, [9.748603351955305, 3.589385474860334], 0, [8.519553072625698, 1.3268156424580995], 0, true]];
[1, "Polyline", 1, 1, 0, false, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 9, [8.533519553072624, 3.044692737430166], 0, [8.198324022346368, 5.782122905027932], 0, [9.483240223463685, 4.594972067039105], 0, [10.293296089385473, 4.958100558659217], 0, [11.298882681564244, 3.50558659217877], 0, [11.648044692737429, 3.1424581005586587], 0, [9.525139664804467, 2.3324022346368705], 0, [9.748603351955305, 3.589385474860334], 0, [8.519553072625698, 1.3268156424580995], 0, true]
let cus = loadFile(data);
//外偏移 -
for (let i = 0.1; i <= 0.3; i += 0.1)
@ -345,7 +337,7 @@ describe("闭合多段线", () =>
test('闭合多段线偏移测试12', () =>
{
let data =
[1, ["Polyline", 1, 1, 4132, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 12, [13.549363225511495, 3.33570646745377], 0, [14.34284463241268, 4.996139781895137], 0, [14.523074259257426, 3.9557232996550056], 0, [15.838887129162556, 4.9814356943054605], 0, [15.943612070431213, 3.9627476292376005], 0, [17.33950450111622, 4.461280640196535], 0, [18.123624596131165, 2.7156799524846913], 0, [17.99903152781382, 1.6177035379380693], 0, [16.03466125512531, 2.900960499995888], 0, [15.014220997727234, 1.7794865537465168], 0, [14.332835411729478, 2.6268506799232134], 0, [13.549363225511495, 3.33570646745377], 0, false]];
[1, "Polyline", 1, 1, 0, false, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 12, [13.549363225511495, 3.33570646745377], 0, [14.34284463241268, 4.996139781895137], 0, [14.523074259257426, 3.9557232996550056], 0, [15.838887129162556, 4.9814356943054605], 0, [15.943612070431213, 3.9627476292376005], 0, [17.33950450111622, 4.461280640196535], 0, [18.123624596131165, 2.7156799524846913], 0, [17.99903152781382, 1.6177035379380693], 0, [16.03466125512531, 2.900960499995888], 0, [15.014220997727234, 1.7794865537465168], 0, [14.332835411729478, 2.6268506799232134], 0, [13.549363225511495, 3.33570646745377], 0, false]
let cus = loadFile(data);
//外偏移 -
for (let i = 0.5; i <= 2; i += 0.5)
@ -373,7 +365,7 @@ describe("闭合多段线", () =>
test('闭合多段线偏移测试13', () =>
{
let data =
[1, ["Polyline", 1, 1, 2689, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 13.053732578466253, -1.845982384833612, 0, 1], 2, 12, [10.73237450059647, 5.925995426719515], 0, [14.934000173256667, 9.279899014962986], 0, [15.443475259425389, 6.338838290261696], 0, [16.902963217271246, 7.476549375511614], 0, [17.07910144494388, 5.7632047972414195], 0, [18.04054823840169, 6.106578652047782], 0, [19.469515702452366, 2.925424892792106], 0, [19.064111106000592, -0.6472031134391991], 0, [17.253277279358528, 2.956832838161076], 0, [14.95258895308757, 3.1324290048358128], 0, [13.37431523183268, 1.7225442000746034], 0, [10.73237450059647, 5.925995426719515], 0, false]];
[1, "Polyline", 1, 1, 0, false, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 13.053732578466253, -1.845982384833612, 0, 1], 2, 12, [10.73237450059647, 5.925995426719515], 0, [14.934000173256667, 9.279899014962986], 0, [15.443475259425389, 6.338838290261696], 0, [16.902963217271246, 7.476549375511614], 0, [17.07910144494388, 5.7632047972414195], 0, [18.04054823840169, 6.106578652047782], 0, [19.469515702452366, 2.925424892792106], 0, [19.064111106000592, -0.6472031134391991], 0, [17.253277279358528, 2.956832838161076], 0, [14.95258895308757, 3.1324290048358128], 0, [13.37431523183268, 1.7225442000746034], 0, [10.73237450059647, 5.925995426719515], 0, false]
let cus = loadFile(data);
//外偏移 -
for (let i = 0.5; i <= 2; i += 0.5)
@ -387,7 +379,7 @@ describe("闭合多段线", () =>
test('闭合多段线偏移测试14', () =>
{
let data =
[1, ["Polyline", 1, 1, 1625, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 14, [340.820007357324, -3.870032999900914], 0, [431.6163856609081, 116.2815653567217], 0, [485.54806901416487, 54.84040710617603], 0, [533.3356365423672, 67.81131829240235], 0, [624.1320148459513, 40.504136847715344], 0, [656.9006325795757, 23.43714844478601], -0.783383849320176, [633.0068488154745, -74.86870475608706], 0.4462700081240285, [605.0169878346704, -106.27196341747704], -0.8416099256631104, [529.9222388617812, -128.11770857322662], 0, [510.1245323143834, -22.98506001118185], 0, [430.251026588674, -129.48306764546098], 0, [430.251026588674, -65.99387078656383], 0, [351.74287993519897, -145.86737651227318], 0, [303.2726328708796, -87.83961594231337], 0, true]]
[1, "Polyline", 1, 1, 0, false, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 14, [340.820007357324, -3.870032999900914], 0, [431.6163856609081, 116.2815653567217], 0, [485.54806901416487, 54.84040710617603], 0, [533.3356365423672, 67.81131829240235], 0, [624.1320148459513, 40.504136847715344], 0, [656.9006325795757, 23.43714844478601], -0.783383849320176, [633.0068488154745, -74.86870475608706], 0.4462700081240285, [605.0169878346704, -106.27196341747704], -0.8416099256631104, [529.9222388617812, -128.11770857322662], 0, [510.1245323143834, -22.98506001118185], 0, [430.251026588674, -129.48306764546098], 0, [430.251026588674, -65.99387078656383], 0, [351.74287993519897, -145.86737651227318], 0, [303.2726328708796, -87.83961594231337], 0, true]
let cus = loadFile(data);
//外偏移 -
for (let i = 10; i <= 90; i += 10)
@ -413,7 +405,7 @@ describe("闭合多段线", () =>
test('闭合多段线偏移测试15', () =>
{
let data =
[1, ["Polyline", 1, 1, 394, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 8, [-3.096429035694039, 1.977370035127478], 0, [2.646251476487261, 5.186031066288948], -0.5113280232193118, [8.158566581303122, 2.619102241359773], 0.23700604598013766, [11.103952861189804, -1.2148363240793185], -1.4842976346055852, [7.994019861756378, -4.028585228328609], 0.5402454464135219, [3.1398916351274853, -2.8932128634560885], -1.0879771453350477, [1.4615150957507161, -0.803469525212464], -0.082022192610066, [-3.096429035694039, 1.977370035127478], 0, true]];
[1, "Polyline", 1, 1, 0, false, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 8, [-3.096429035694039, 1.977370035127478], 0, [2.646251476487261, 5.186031066288948], -0.5113280232193118, [8.158566581303122, 2.619102241359773], 0.23700604598013766, [11.103952861189804, -1.2148363240793185], -1.4842976346055852, [7.994019861756378, -4.028585228328609], 0.5402454464135219, [3.1398916351274853, -2.8932128634560885], -1.0879771453350477, [1.4615150957507161, -0.803469525212464], -0.082022192610066, [-3.096429035694039, 1.977370035127478], 0, true]
let cus = loadFile(data);
//外偏移 -
for (let i = 0.5; i <= 5.5; i += 1)
@ -442,7 +434,7 @@ describe("闭合多段线", () =>
test('闭合多段线偏移测试16', () =>
{
let data =
[1, ["Polyline", 1, 1, 4, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 5, [-6.203966005665723, -0.056657223796033884], 0, [-1.8834846458923415, -0.923353563739375], -1.4125691360015384, [-1.9069913201133035, -1.5932937790368253], 0, [-6.189801699716714, -2.2096317280453257], -2.3881275241710798, [-6.203966005665723, -0.056657223796033884], 0, true]];
[1, "Polyline", 1, 1, 0, false, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 5, [-6.203966005665723, -0.056657223796033884], 0, [-1.8834846458923415, -0.923353563739375], -1.4125691360015384, [-1.9069913201133035, -1.5932937790368253], 0, [-6.189801699716714, -2.2096317280453257], -2.3881275241710798, [-6.203966005665723, -0.056657223796033884], 0, true]
let cus = loadFile(data);
//外偏移 -
//内偏移+
@ -463,7 +455,7 @@ describe("补圆弧测试", () =>
test("补圆弧测试1", () =>
{
let data =
[1, ["Polyline", 1, 1, 8815, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 5, [-99.60068327971061, 80.69599512140186], 0, [-48.362234971168355, 80.69599512140186], -0.9874208089640422, [-14.972250883848176, 88.46675505445091], -1.1745224194600496, [18.29631507951812, 78.51046889023182], 0, [89.44733571649859, 78.5104688902318], 0, false]];
[1, "Polyline", 1, 1, 0, false, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 5, [-99.60068327971061, 80.69599512140186], 0, [-48.362234971168355, 80.69599512140186], -0.9874208089640422, [-14.972250883848176, 88.46675505445091], -1.1745224194600496, [18.29631507951812, 78.51046889023182], 0, [89.44733571649859, 78.5104688902318], 0, false]
let cus = loadFile(data);
// 向上-
// 向下+
@ -477,7 +469,7 @@ describe("补圆弧测试", () =>
test("补圆弧测试2", () =>
{
let data =
[1, ["Polyline", 1, 1, 12266, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 5, [-869.4193524531552, -50.92359793870933], 0, [-609.861025770732, -50.92359793870939], -0.8167984427288847, [-480.7149315189898, -23.068558002059024], -1.4042575072434897, [-317.9835774160859, -50.92359793870939], 0, [-92.77019349218811, -50.92359793870939], 0, false]];
[1, "Polyline", 1, 1, 0, false, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 5, [-869.4193524531552, -50.92359793870933], 0, [-609.861025770732, -50.92359793870939], -0.8167984427288847, [-480.7149315189898, -23.068558002059024], -1.4042575072434897, [-317.9835774160859, -50.92359793870939], 0, [-92.77019349218811, -50.92359793870939], 0, false]
let cus = loadFile(data);
// 向上-
// 向下+
@ -491,7 +483,7 @@ describe("补圆弧测试", () =>
test("补圆弧测试3", () =>
{
let data =
[1, ["Polyline", 1, 1, 12272, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 4, [-894.3165541673695, -331.80629190023], 0, [-671.3300245231958, -331.80629190023], -1.0058680701224356, [-535.7124860261546, -329.1982623137485], 0, [-214.92484688892245, -329.1982623137485], 0, false]];
[1, "Polyline", 1, 1, 0, false, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 4, [-894.3165541673695, -331.80629190023], 0, [-671.3300245231958, -331.80629190023], -1.0058680701224356, [-535.7124860261546, -329.1982623137485], 0, [-214.92484688892245, -329.1982623137485], 0, false]
let cus = loadFile(data);
// 向上-
// 向下+
@ -504,7 +496,7 @@ describe("补圆弧测试", () =>
test("补圆弧测试3", () =>
{
let data =
[1, ["Polyline", 1, 1, 195, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 23, [-25.572010711696727, -62.383195892823124], 0, [-10.312959798454724, -40.55427583637971], 0, [0.28360333574111785, -55.81332674962171], 0, [9.820510156517361, -48.18380129300071], 0, [18.721623189241864, -65.13830230771404], 0, [29.530117586121616, -60.47581452866788], 0, [39.06702440689787, -79.97349069558823], 0, [51.78290016793288, -70.64851513749588], -0.6227891115113805, [70.85671380948538, -80.60928448363998], 0.3759603135798005, [86.75155851077912, -99.68309812519247], -1.1383492019405204, [81.45327694368122, -117.6972554533254], 0.6271394112393051, [57.2931129977147, -138.2545879336653], -1.2933960333754264, [21.68866086681669, -138.2545879336653], -0.8106183277649434, [-17.73055399239181, -132.9563063665674], 0, [-43.37423677714574, -105.82910474302606], 0, [-51.003762233766736, -83.5763221612148], 0, [-48.67251834424364, -64.07864599429448], 0, [-62.65998168138215, -50.09118265715597], 0, [-86.39628310198083, -65.35023357039795], 0, [-86.39628310198083, -33.13668164244262], 0, [-73.68040734094582, -13.639005475522275], 0, [-43.16230551446182, -13.639005475522275], 0, [-33.62539869368556, -11.307761585999202], 0, false]];
[1, "Polyline", 1, 1, 0, false, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 23, [-25.572010711696727, -62.383195892823124], 0, [-10.312959798454724, -40.55427583637971], 0, [0.28360333574111785, -55.81332674962171], 0, [9.820510156517361, -48.18380129300071], 0, [18.721623189241864, -65.13830230771404], 0, [29.530117586121616, -60.47581452866788], 0, [39.06702440689787, -79.97349069558823], 0, [51.78290016793288, -70.64851513749588], -0.6227891115113805, [70.85671380948538, -80.60928448363998], 0.3759603135798005, [86.75155851077912, -99.68309812519247], -1.1383492019405204, [81.45327694368122, -117.6972554533254], 0.6271394112393051, [57.2931129977147, -138.2545879336653], -1.2933960333754264, [21.68866086681669, -138.2545879336653], -0.8106183277649434, [-17.73055399239181, -132.9563063665674], 0, [-43.37423677714574, -105.82910474302606], 0, [-51.003762233766736, -83.5763221612148], 0, [-48.67251834424364, -64.07864599429448], 0, [-62.65998168138215, -50.09118265715597], 0, [-86.39628310198083, -65.35023357039795], 0, [-86.39628310198083, -33.13668164244262], 0, [-73.68040734094582, -13.639005475522275], 0, [-43.16230551446182, -13.639005475522275], 0, [-33.62539869368556, -11.307761585999202], 0, false]
let cus = loadFile(data);
// 向外-
// 向内+
@ -519,7 +511,7 @@ describe("补圆弧测试", () =>
test("补圆弧测试3", () =>
{
let data =
[1, ["Polyline", 1, 1, 3, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 10, [-5.637393767705383, -1.586402266288952], 0, [-0.84985835694051, 1.954674220963173], -0.5207626681247078, [1.728045325779038, 1.0906515580736542], -1.2136457904456304, [4.060938624362605, 1.3838754084985838], -1.0694858869096764, [6.891142200566573, -0.047681051558073895], -1.4716493502287318, [9.178341602266286, -2.976612659490083], -1.5003222663355726, [8.09233325325779, -7.040916632294616], -0.9628743606456998, [4.53257790368272, -7.478753541076488], -1.076087427994497, [2.3229461756373926, -7.478753541076488], 0, [-5.39660056657224, -7.478753541076487], 0, false]];
[1, "Polyline", 1, 1, 0, false, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 10, [-5.637393767705383, -1.586402266288952], 0, [-0.84985835694051, 1.954674220963173], -0.5207626681247078, [1.728045325779038, 1.0906515580736542], -1.2136457904456304, [4.060938624362605, 1.3838754084985838], -1.0694858869096764, [6.891142200566573, -0.047681051558073895], -1.4716493502287318, [9.178341602266286, -2.976612659490083], -1.5003222663355726, [8.09233325325779, -7.040916632294616], -0.9628743606456998, [4.53257790368272, -7.478753541076488], -1.076087427994497, [2.3229461756373926, -7.478753541076488], 0, [-5.39660056657224, -7.478753541076487], 0, false]
let cus = loadFile(data);
// 向外-
// 向内+
@ -546,7 +538,7 @@ describe("不规则不闭合多段线测试", () =>
test("test1", () =>
{
let data =
[1, ["Polyline", 1, 1, 3135, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 6, [16.034190840579708, -16.545186318840567], 0, [36.985943188405784, -16.545186318840567], 0, [31.311510260869554, -12.507609043478254], 0, [48.334809043478245, -12.507609043478254], 0, [43.969860637681144, -16.6543100289855], 0, [56.84645843478259, -16.654310028985503], 0, false]]
[1, "Polyline", 1, 1, 0, false, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 6, [16.034190840579708, -16.545186318840567], 0, [36.985943188405784, -16.545186318840567], 0, [31.311510260869554, -12.507609043478254], 0, [48.334809043478245, -12.507609043478254], 0, [43.969860637681144, -16.6543100289855], 0, [56.84645843478259, -16.654310028985503], 0, false]
let cus = loadFile(data);
for (let i = 1.27; i <= 2.96; i += 0.2)
{
@ -562,7 +554,7 @@ describe("不规则不闭合多段线测试", () =>
test("test2-共线线段", () =>
{
let data =
[1, ["Polyline", 1, 1, 8814, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 7, [15.642409533480423, -31.01626057276902], 0, [38.129771973149346, -31.016260572769028], 0, [32.85929640135194, -26.50707591689791], 0, [47.440945483324754, -26.50707591689791], 0, [45.33685543194063, -31.016260572769028], 0, [61.52187596164093, -31.016260572769035], 0, [70.31099992504923, -35.88209931313313], 0, false]];
[1, "Polyline", 1, 1, 0, false, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 7, [15.642409533480423, -31.01626057276902], 0, [38.129771973149346, -31.016260572769028], 0, [32.85929640135194, -26.50707591689791], 0, [47.440945483324754, -26.50707591689791], 0, [45.33685543194063, -31.016260572769028], 0, [61.52187596164093, -31.016260572769035], 0, [70.31099992504923, -35.88209931313313], 0, false]
let cus = loadFile(data);
for (let i = 1.82; i <= 3.37; i += 0.3)
{
@ -575,21 +567,24 @@ describe("不规则不闭合多段线测试", () =>
}
cus[0].Reverse();
expect(cus[0].GetOffsetCurves(-18).length).toBe(2);
data = [1, ["Polyline", 1, 1, 22696, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 7, [21.944751443449043, -31.01626057276902], 0, [38.129771973149346, -31.016260572769028], 0, [32.85929640135194, -26.50707591689791], 0, [47.440945483324754, -26.50707591689791], 0, [45.33685543194063, -31.016260572769028], 0, [61.52187596164093, -31.016260572769035], 0, [70.31099992504923, -35.88209931313313], 0, false]];
data =
[1,"Polyline",1,1,0,false,7,0,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],2,7,[21.944751443449043,-31.01626057276902],0,[38.129771973149346,-31.016260572769028],0,[32.85929640135194,-26.50707591689791],0,[47.440945483324754,-26.50707591689791],0,[45.33685543194063,-31.016260572769028],0,[61.52187596164093,-31.016260572769035],0,[70.31099992504923,-35.88209931313313],0,false]
cus = loadFile(data);
expect(cus[0].GetOffsetCurves(11.4).length).toBe(1);
data = [1, ["Polyline", 1, 1, 24383, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -56.21146708819905, -48.62279820279199, 0, 1], 2, 7, [26.333787338902418, -31.01626057276902], 0, [35.05226039203026, -31.016260572769013], 0, [32.85929640135194, -26.50707591689791], 0, [47.440945483324754, -26.50707591689791], 0, [41.54871106124796, -31.016260572769013], 0, [61.52187596164093, -31.016260572769035], 0, [70.31099992504923, -35.88209931313313], 0, false]]
data =
[1,"Polyline",1,1,0,false,7,0,[1,0,0,0,0,1,0,0,0,0,1,0,-56.21146708819905,-48.62279820279199,0,1],2,7,[26.333787338902418,-31.01626057276902],0,[35.05226039203026,-31.016260572769013],0,[32.85929640135194,-26.50707591689791],0,[47.440945483324754,-26.50707591689791],0,[41.54871106124796,-31.016260572769013],0,[61.52187596164093,-31.016260572769035],0,[70.31099992504923,-35.88209931313313],0,false]
cus = loadFile(data);
expect(cus[0].GetOffsetCurves(5.2).length).toBe(1);
data = [1, ["Polyline", 1, 1, 4, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 6, [-3.158640226628895, -0.9915014164305944], 0, [-1.0906515580736538, -0.991501416430595], 0, [-1.983002832861189, 0.18413597733711037], 0, [1.0906515580736549, 0.3966005665722377], 0, [0.2974504249291776, -0.9915014164305944], 0, [3.966005665722378, -0.9915014164305953], 0, false]];
data =
[1,"Polyline",1,1,0,false,7,0,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],2,6,[-3.158640226628895,-0.9915014164305944],0,[-1.0906515580736538,-0.991501416430595],0,[-1.983002832861189,0.18413597733711037],0,[1.0906515580736549,0.3966005665722377],0,[0.2974504249291776,-0.9915014164305944],0,[3.966005665722378,-0.9915014164305953],0,false]
cus = loadFile(data);
expect(cus[0].GetOffsetCurves(2.01133).length).toBe(1);
})
test("test3", () =>
{
let data =
[1, ["Polyline", 1, 1, 4308, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 5, [-41.52354973772388, -163.989590203395], 0, [-41.5235497377239, -231.3399374277236], 0, [21.016058399152634, -231.3399374277236], 0, [21.016058399152623, -294.68133541250876], 1.378670046466899, [261.5530127717545, -216.10593031745873], 0, false]];
[1, "Polyline", 1, 1, 0, false, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 5, [-41.52354973772388, -163.989590203395], 0, [-41.5235497377239, -231.3399374277236], 0, [21.016058399152634, -231.3399374277236], 0, [21.016058399152623, -294.68133541250876], 1.378670046466899, [261.5530127717545, -216.10593031745873], 0, false]
let cus = loadFile(data);
for (let i = -100; i <= 181; i += 30)
{
@ -600,7 +595,7 @@ describe("不规则不闭合多段线测试", () =>
test("test4", () =>
{
let data =
[1, ["Polyline", 1, 1, 14565, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -131.50093441946296, -806.1569163328921, 0, 1], 2, 24, [256.5228611988947, -38.705370748164505], 0, [372.1955588024039, 31.844231195771492], 0, [372.1955588024039, -31.54297461172431], 0, [450.9819163032461, 37.57414810492366], 0, [423.0485713711294, -54.10452244151095], 0, [589.216161736542, 52.97329979827009], 0, [611.0614699526845, -2.177150452319474], 0, [672.6580767260702, 61.21005535517633], 0, [678.0298738284004, 13.938240854670997], 0, [735.329042919922, 21.100636991111184], 0, [684.1179105443746, -21.515620020708024], 0, [730.6734854312358, -32.61733403219032], 0, [815.1897598412304, 38.29038771856768], 0, [835.6025888300849, -8.981426781937659], 0, [862.1034545349137, 74.4604882075907], 0, [943.4539498526012, 74.46048820759069], 0, [986.972668777612, -29.064785548515978], 0, [924.5022496755805, -66.26627108118637], 0, [1001.0109652050348, -106.27541589934134], 0, [965.9152241364777, -128.73669018321777], 0, [1006.6262837760039, -176.46689803645526], 0, [904.1467198558175, -189.8032796425069], 0, [981.3573502066429, -242.44689124534239], 0, [1004.5205393118904, -256.48518767276516], 0, false]];
[1, "Polyline", 1, 1, 0, false, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -131.50093441946296, -806.1569163328921, 0, 1], 2, 24, [256.5228611988947, -38.705370748164505], 0, [372.1955588024039, 31.844231195771492], 0, [372.1955588024039, -31.54297461172431], 0, [450.9819163032461, 37.57414810492366], 0, [423.0485713711294, -54.10452244151095], 0, [589.216161736542, 52.97329979827009], 0, [611.0614699526845, -2.177150452319474], 0, [672.6580767260702, 61.21005535517633], 0, [678.0298738284004, 13.938240854670997], 0, [735.329042919922, 21.100636991111184], 0, [684.1179105443746, -21.515620020708024], 0, [730.6734854312358, -32.61733403219032], 0, [815.1897598412304, 38.29038771856768], 0, [835.6025888300849, -8.981426781937659], 0, [862.1034545349137, 74.4604882075907], 0, [943.4539498526012, 74.46048820759069], 0, [986.972668777612, -29.064785548515978], 0, [924.5022496755805, -66.26627108118637], 0, [1001.0109652050348, -106.27541589934134], 0, [965.9152241364777, -128.73669018321777], 0, [1006.6262837760039, -176.46689803645526], 0, [904.1467198558175, -189.8032796425069], 0, [981.3573502066429, -242.44689124534239], 0, [1004.5205393118904, -256.48518767276516], 0, false]
let cus = loadFile(data);
expect(cus[0].GetOffsetCurves(-100).length).toBe(1);
expect(cus[0].GetOffsetCurves(46.8).length).toBe(2);
@ -613,7 +608,7 @@ describe("不规则不闭合多段线测试", () =>
test("test5", () =>
{
let data =
[1, ["Polyline", 1, 1, 3, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 18, [-3.895184135977337, 0.7648725212464592], 0, [0.8215297450424939, 0.7648725212464592], 0, [-2.1246458923512743, -2.1388101983002827], 0, [5.311614730878187, -2.1388101983002827], 0, [1.89801699716714, 3.4844192634560907], 0, [6.671388101983003, 3.4844192634560907], 0, [6.671388101983002, -3.4985835694051], 0, [10.6657223796034, -0.11331444759206824], 0, [8.810198300283286, 1.161473087818697], 0, [14.674220963172807, 3.30028328611898], 0, [16.713881019830033, -2.521246458923512], 0, [11.55807365439094, -5.773371104815864], 0, [3.8441926345609083, -5.773371104815863], 0, [2.3569405099150167, -8.787535410764873], 0, [-1.5297450424929169, -6.090651558073655], 0, [-6.586402266288951, -12.674220963172807], 0, [-8.113314447592067, -8.767705382436262], 0, [-10.929178470254957, -12.436260623229463], 0, false]];
[1, "Polyline", 1, 1, 0, false, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 18, [-3.895184135977337, 0.7648725212464592], 0, [0.8215297450424939, 0.7648725212464592], 0, [-2.1246458923512743, -2.1388101983002827], 0, [5.311614730878187, -2.1388101983002827], 0, [1.89801699716714, 3.4844192634560907], 0, [6.671388101983003, 3.4844192634560907], 0, [6.671388101983002, -3.4985835694051], 0, [10.6657223796034, -0.11331444759206824], 0, [8.810198300283286, 1.161473087818697], 0, [14.674220963172807, 3.30028328611898], 0, [16.713881019830033, -2.521246458923512], 0, [11.55807365439094, -5.773371104815864], 0, [3.8441926345609083, -5.773371104815863], 0, [2.3569405099150167, -8.787535410764873], 0, [-1.5297450424929169, -6.090651558073655], 0, [-6.586402266288951, -12.674220963172807], 0, [-8.113314447592067, -8.767705382436262], 0, [-10.929178470254957, -12.436260623229463], 0, false]
let cus = loadFile(data);
expect(cus[0].GetOffsetCurves(0.755).length).toBe(3);
expect(cus[0].GetOffsetCurves(1.915).length).toBe(4);
@ -630,7 +625,7 @@ describe("不规则不闭合多段线测试", () =>
test("test6", () =>
{
let data =
[1, ["Polyline", 1, 1, 2781, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -38.54242746474825, 6.4891615215880964, 0, 1], 2, 3, [18.466397865202012, 17.128892766521286], 0, [4.660056657223795, 6.487252124645892], -3.7897716494829594, [-0.906131771640112, 6.969061295372345], 0, false]];
[1, "Polyline", 1, 1, 0, false, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -38.54242746474825, 6.4891615215880964, 0, 1], 2, 3, [18.466397865202012, 17.128892766521286], 0, [4.660056657223795, 6.487252124645892], -3.7897716494829594, [-0.906131771640112, 6.969061295372345], 0, false]
let cus = loadFile(data);
for (let i = -2.766; i <= 4.57; i++)
@ -662,7 +657,7 @@ describe("不规则不闭合多段线测试", () =>
test("test7", () =>
{
let data =
[1, ["Polyline", 1, 1, 2347, false, 1, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -86.54515219838936, -34.782221464287886, 0, 1], 2, 5, [-51.274354719855246, 28.573003242461496], 0, [-13.931531095689206, 15.255196629685734], 3.7897716494829594, [-8.365342666825299, 14.77338745895928], 0, [5.4409985411529185, 25.415028100834675], 0.37399715496699776, [29.033295173881022, 23.38858533792915], 0, false]];
[1, "Polyline", 1, 1, 0, false, 1, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -86.54515219838936, -34.782221464287886, 0, 1], 2, 5, [-51.274354719855246, 28.573003242461496], 0, [-13.931531095689206, 15.255196629685734], 3.7897716494829594, [-8.365342666825299, 14.77338745895928], 0, [5.4409985411529185, 25.415028100834675], 0.37399715496699776, [29.033295173881022, 23.38858533792915], 0, false]
let cus = loadFile(data);
expect(cus[0].GetOffsetCurves(-3.133).length).toBe(2);
for (let i = 10; i <= 60; i += 10)
@ -687,7 +682,7 @@ describe("不规则不闭合多段线测试", () =>
test("test8", () =>
{
let data =
[1, ["Polyline", 1, 1, 395, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 8, [14.442408344729744, 12.584578126613017], 0, [14.442408344729742, 4.502438174603963], 0, [20.086360825183, 4.502438174603963], 0, [20.086360825183, -0.9157562066311582], 0, [26.226981123916133, -0.9157562066311598], 0.4633692494967541, [33.496391918739924, 7.663051563657783], -0.673355221273594, [51.96340443478295, 18.996108144407916], 0.32851266965536, [64.10919017271836, 18.996108144407913], -1.9784627492130062, false]];
[1, "Polyline", 1, 1, 0, false, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 8, [14.442408344729744, 12.584578126613017], 0, [14.442408344729742, 4.502438174603963], 0, [20.086360825183, 4.502438174603963], 0, [20.086360825183, -0.9157562066311582], 0, [26.226981123916133, -0.9157562066311598], 0.4633692494967541, [33.496391918739924, 7.663051563657783], -0.673355221273594, [51.96340443478295, 18.996108144407916], 0.32851266965536, [64.10919017271836, 18.996108144407913], -1.9784627492130062, false]
let cus = loadFile(data);
for (let i = -15; i <= 15; i += 5)
{
@ -698,7 +693,7 @@ describe("不规则不闭合多段线测试", () =>
test("test9-2圆弧没交点", () =>
{
let data =
[1, ["Polyline", 1, 1, 23321, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 3, [-245.7800398731897, -124.83507012637789], 0.47532901948537815, [-247.69480466441718, -117.62074637472406], 0.12615539092932912, [-193.96898890583213, -126.5297489543612], 0, false]]
[1, "Polyline", 1, 1, 0, false, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 3, [-245.7800398731897, -124.83507012637789], 0.47532901948537815, [-247.69480466441718, -117.62074637472406], 0.12615539092932912, [-193.96898890583213, -126.5297489543612], 0, false]
let cus = loadFile(data);
expect(cus[0].GetOffsetCurves(11.22).length).toBe(1);
expect(cus[0].GetOffsetCurves(-11.22).length).toBe(1);
@ -706,7 +701,7 @@ describe("不规则不闭合多段线测试", () =>
test("test10-共线部分错误裁剪", () =>
{
let data =
[1, ["Polyline", 1, 1, 151, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 13, [37846.488077851434, 5711.914029035103], 0, [28152.473806690192, 5711.914029035104], 0, [31338.416239942802, 10002.31650581529], 0, [39750.51284565329, 10002.316505815288], 0, [39750.51284565329, 17632.65706309083], 0, [45109.026777541825, 17632.65706309083], 0, [45109.02677754183, 10002.31650581529], 0, [54643.39210261924, 10002.31650581529], -0.8704734266845496, [55266.30970531861, 5526.15551510335], 0, [45201.90603450778, 5526.155515103216], 0, [45201.90603450778, 249.9945243911434], 0, [37846.488077851434, 435.75303832303064], 0, [37846.488077851434, 5711.914029035103], 0, false]]
[1, "Polyline", 1, 1, 0, false, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 13, [37846.488077851434, 5711.914029035103], 0, [28152.473806690192, 5711.914029035104], 0, [31338.416239942802, 10002.31650581529], 0, [39750.51284565329, 10002.316505815288], 0, [39750.51284565329, 17632.65706309083], 0, [45109.026777541825, 17632.65706309083], 0, [45109.02677754183, 10002.31650581529], 0, [54643.39210261924, 10002.31650581529], -0.8704734266845496, [55266.30970531861, 5526.15551510335], 0, [45201.90603450778, 5526.155515103216], 0, [45201.90603450778, 249.9945243911434], 0, [37846.488077851434, 435.75303832303064], 0, [37846.488077851434, 5711.914029035103], 0, false]
let cus = loadFile(data);
expect(cus[0].GetOffsetCurves(2700).length).toBe(1);
})
@ -715,14 +710,9 @@ describe("不规则不闭合多段线测试", () =>
test('提前丢失所有的线段', () =>
{
let f = new CADFile();
f.Data =
[1, ["Polyline", 1, 1, 12, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -17.386067452264705, 17.11283965241085, 0, 1], 2, 3, [108.37693694676932, 28.257776463252547], 0.4472440944881872, [108.37693694676932, 17.68555707305448], 3.5940684866260213, [111.70676982557188, 14.089337563947739], 0.5086040192926764, false]]
f.Read();
let pl = f.ReadObject() as Polyline;
let pl = loadFile(
[1, "Polyline", 1, 1, 0, false, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -17.386067452264705, 17.11283965241085, 0, 1], 2, 3, [108.37693694676932, 28.257776463252547], 0.4472440944881872, [108.37693694676932, 17.68555707305448], 3.5940684866260213, [111.70676982557188, 14.089337563947739], 0.5086040192926764, false]
)[0] as Polyline;
let cus = pl.GetOffsetCurves(-7.155086190577401);
@ -732,14 +722,9 @@ test('提前丢失所有的线段', () =>
test('中间区域需要圆裁剪', () =>
{
let f = new CADFile();
f.Data =
[1, ["Polyline", 1, 1, 2628, false, 1, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -1325.2800870006804, -703.3564533406019, 0, 1], 2, 5, [-51.274354719855246, 28.573003242461496], 0, [-13.931531095689206, 15.255196629685734], 3.7897716494829594, [-8.365342666825299, 14.77338745895928], 0, [5.4409985411529185, 25.415028100834675], 0.37399715496699776, [29.033295173881022, 23.38858533792915], 0, false]]
f.Read();
let pl = f.ReadObject() as Polyline;
let pl = loadFile(
[1, "Polyline", 1, 1, 0, false, 1, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -1325.2800870006804, -703.3564533406019, 0, 1], 2, 5, [-51.274354719855246, 28.573003242461496], 0, [-13.931531095689206, 15.255196629685734], 3.7897716494829594, [-8.365342666825299, 14.77338745895928], 0, [5.4409985411529185, 25.415028100834675], 0.37399715496699776, [29.033295173881022, 23.38858533792915], 0, false]
)[0] as Polyline;
let cus = pl.GetOffsetCurves(-35.6);
@ -749,14 +734,9 @@ test('中间区域需要圆裁剪', () =>
test('拱门偏移', () =>
{
let f = new CADFile();
f.Data =
[1, ["Polyline", 1, 1, 6, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 4, [0, 0], 0, [0, 2], -1, [1, 2], 0, [1, 0], 0, false]]
f.Read();
let pl = f.ReadObject() as Polyline;
let pl = loadFile(
[1, "Polyline", 1, 1, 0, false, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 4, [0, 0], 0, [0, 2], -1, [1, 2], 0, [1, 0], 0, false]
)[0] as Polyline;
let cus = pl.GetOffsetCurves(0.4);
EntityToMatchSnapshot(cus);
@ -767,13 +747,11 @@ test('拱门偏移', () =>
test('土偏移因为点在圆弧切线上错误导致的丢失', () =>
{
let f = new CADFile();
f.Data =
[1, ["Polyline", 1, 1, 3, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -9159.663865546216, 8361.344537815126, 0, 1], 2, 17, [28900.928792569663, -4648.336577340973], -0.9999999999999999, [28900.928792569663, 580.3540867812549], 0, [37687.5122530782, 580.3540867812552], 0, [37687.5122530782, 5568.3816889128875], 0, [27851.140930176796, 5568.381688912888], 0, [31251.043800494088, 10146.917554273516], 0, [39591.53702088006, 10146.917554273514], 0, [39591.53702088006, 17633.191417258837], -0.9999999999999999, [45238.18434134903, 17633.191417258837], 0, [45238.184341349035, 10146.917554273516], 0, [54628.482972136226, 10146.917554273516], -0.8741669928857767, [55271.13672581777, 5382.623174980927], 0, [45331.063598314984, 5382.623174981001], 0, [45331.063598314984, 1648.4655418896164], 0, [53885.44891640867, 1648.4655418896143], -0.6803347640614656, [56371.20555398866, -4648.336577340822], 0, [28900.928792569663, -4648.336577340976], 0, false]]
let pl = loadFile(
f.Read();
[1, "Polyline", 1, 1, 0, false, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -9159.663865546216, 8361.344537815126, 0, 1], 2, 17, [28900.928792569663, -4648.336577340973], -0.9999999999999999, [28900.928792569663, 580.3540867812549], 0, [37687.5122530782, 580.3540867812552], 0, [37687.5122530782, 5568.3816889128875], 0, [27851.140930176796, 5568.381688912888], 0, [31251.043800494088, 10146.917554273516], 0, [39591.53702088006, 10146.917554273514], 0, [39591.53702088006, 17633.191417258837], -0.9999999999999999, [45238.18434134903, 17633.191417258837], 0, [45238.184341349035, 10146.917554273516], 0, [54628.482972136226, 10146.917554273516], -0.8741669928857767, [55271.13672581777, 5382.623174980927], 0, [45331.063598314984, 5382.623174981001], 0, [45331.063598314984, 1648.4655418896164], 0, [53885.44891640867, 1648.4655418896143], -0.6803347640614656, [56371.20555398866, -4648.336577340822], 0, [28900.928792569663, -4648.336577340976], 0, false]
)[0] as Polyline;
let pl = f.ReadObject() as Polyline;
let cus = pl.GetOffsetCurves(-801);
expect(cus.length).toBe(1);
@ -784,12 +762,10 @@ test('土偏移因为点在圆弧切线上错误导致的丢失', () =>
//ISSUE #IKSMH
test('闭合多段线判断精度和重复交点参数导致偏移丢失', () =>
{
let f = new CADFile();
f.Data =
[1, ["Polyline", 1, 1, 3, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0.042016806722689815, 0.028011204481792618, 0, 1], 2, 11, [15758.920914649752, -1642.832074394305], 1.1432358165627696, [15758.920914649756, -3551.5797508523133], 0.010240353549940432, [20850.68748853413, -2761.478041111637], 0.39873042440013945, [23564.17781148077, 901.7338948663096], 0.029927117999965277, [22452.27083112051, 6973.8467189556395], 0, [31778.947378692996, 6973.846718955635], 0, [31327.636369627562, 7575.594679533537], 0, [31646.066893308867, 7787.881806674935], 0, [20955.832135358123, 7787.881806674936], 0, [21703.795934364476, 5637.485884531684], -0.559029831351755, [15758.920914649752, -1642.832074394304], 0, false]]
let pl = loadFile(
f.Read();
let pl = f.ReadObject() as Polyline;
[1, "Polyline", 1, 1, 0, false, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0.042016806722689815, 0.028011204481792618, 0, 1], 2, 11, [15758.920914649752, -1642.832074394305], 1.1432358165627696, [15758.920914649756, -3551.5797508523133], 0.010240353549940432, [20850.68748853413, -2761.478041111637], 0.39873042440013945, [23564.17781148077, 901.7338948663096], 0.029927117999965277, [22452.27083112051, 6973.8467189556395], 0, [31778.947378692996, 6973.846718955635], 0, [31327.636369627562, 7575.594679533537], 0, [31646.066893308867, 7787.881806674935], 0, [20955.832135358123, 7787.881806674936], 0, [21703.795934364476, 5637.485884531684], -0.559029831351755, [15758.920914649752, -1642.832074394304], 0, false]
)[0] as Polyline;
for (let d of [40, 50, 100, 200, 300])
{
@ -802,12 +778,10 @@ test('闭合多段线判断精度和重复交点参数导致偏移丢失', () =>
//ISSUE #IKSMH
test('简单图形因为点在线内算法错误导致的丢失', () =>
{
let f = new CADFile();
f.Data =
[1, ["Polyline", 1, 1, 3, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -0.01400560224089542, 0.37815126050420145, 0, 1], 2, 7, [2.075848303393214, 0.09193367302761479], -3.109533447960064, [2.8332320619106284, 1.1077844311377247], 0, [3.542914171656688, 1.1077844311377247], 0, [3.542914171656688, -0.4890219560878247], 0, [2.0758483033932134, -0.4890219560878247], 0, [2.0758483033932134, -0.4890219560878247], 0, [2.0758483033932134, 0.09193367302761501], 0, false]]
f.Read();
let pl = f.ReadObject() as Polyline;
let pl = loadFile(
[1, "Polyline", 1, 1, 0, false, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -0.01400560224089542, 0.37815126050420145, 0, 1], 2, 7, [2.075848303393214, 0.09193367302761479], -3.109533447960064, [2.8332320619106284, 1.1077844311377247], 0, [3.542914171656688, 1.1077844311377247], 0, [3.542914171656688, -0.4890219560878247], 0, [2.0758483033932134, -0.4890219560878247], 0, [2.0758483033932134, -0.4890219560878247], 0, [2.0758483033932134, 0.09193367302761501], 0, false]
)[0] as Polyline;
for (let d of [0.2, 0.3, 0.4, 0.5])
{
@ -820,12 +794,10 @@ test('简单图形因为点在线内算法错误导致的丢失', () =>
test('圆求交错误导致的线丢失', () =>
{
let f = new CADFile();
f.Data =
[1, ["Polyline", 1, 1, 1077, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 8, [245.62964413684085, 1116.1391538309313], -0.6953179171905909, [357.14209871457234, 1741.1251588427203], -0.6821635222887411, [892.2042303620135, 1596.040230558597], 0.37526047823909664, [1317.3934365017694, 1221.2756098839004], 0.14384173346393453, [1715.0964405621776, 1096.7424042631346], 0.026448384140957723, [1793.2064027435729, 1099.4889679050386], -0.1912121824403452, [733.4339688924879, 1000.3133228797258], -0.3304377553967397, [245.62964413684108, 1116.139153830931], 0, false]]
let pl = loadFile(
f.Read();
let pl = f.ReadObject() as Polyline;
[1, "Polyline", 1, 1, 0, false, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 8, [245.62964413684085, 1116.1391538309313], -0.6953179171905909, [357.14209871457234, 1741.1251588427203], -0.6821635222887411, [892.2042303620135, 1596.040230558597], 0.37526047823909664, [1317.3934365017694, 1221.2756098839004], 0.14384173346393453, [1715.0964405621776, 1096.7424042631346], 0.026448384140957723, [1793.2064027435729, 1099.4889679050386], -0.1912121824403452, [733.4339688924879, 1000.3133228797258], -0.3304377553967397, [245.62964413684108, 1116.139153830931], 0, false]
)[0] as Polyline;
for (let d of [10, 20, 30, 40, 269, 280, 320])//270 280 320因为圆弧选点导致的错误
{
@ -844,7 +816,7 @@ test('海豚圆选点导致的错误', () =>
{
let cus = loadFile(
[1, ["Polyline", 1, 1, 540, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 5.653674874772044, 7.68794016265532, 0, 1], 2, 8, [933.8513988456853, 1095.3110732229222], -0.8740345959811056, [920.2952842385836, 1109.7702508499967], 0, [1041.059365726312, 1258.0770175893115], -0.47531159669542833, [1335.8552450029906, 1258.0770175893115], 0.4755782365532149, [1656.4630038262355, 1258.2164686086066], 0.011876098909362552, [1662.4715751586689, 1265.9781137467012], -0.44350119503715907, [1205.357990246699, 1110.5168645352571], 0.28917769175330255, [933.8513988456853, 1095.3110732229222], 0, false]]
[1, "Polyline", 1, 1, 0, false, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 5.653674874772044, 7.68794016265532, 0, 1], 2, 8, [933.8513988456853, 1095.3110732229222], -0.8740345959811056, [920.2952842385836, 1109.7702508499967], 0, [1041.059365726312, 1258.0770175893115], -0.47531159669542833, [1335.8552450029906, 1258.0770175893115], 0.4755782365532149, [1656.4630038262355, 1258.2164686086066], 0.011876098909362552, [1662.4715751586689, 1265.9781137467012], -0.44350119503715907, [1205.357990246699, 1110.5168645352571], 0.28917769175330255, [933.8513988456853, 1095.3110732229222], 0, false]
)
let pl = cus[0] as Polyline;
testOffset(pl, 10);
@ -854,7 +826,7 @@ test('海豚圆选点导致的错误', () =>
test('复杂圆盘选点', () =>
{
let cus = loadFile(
[1, ["Polyline", 1, 1, 3, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 21, [-4.193877551020408, 0.5102040816326532], 0, [-2.051020408163265, 2.418367346938776], 0, [-1.0612244897959189, 0.7244897959183673], 0, [1.591836734693877, 1.153061224489796], 0, [1.5918367346938769, -0.13265306122449028], 0.20147559294404743, [2.6632653061224483, -2.6836734693877555], -1.1981710602936018, [-0.959183673469388, -5.244897959183675], 0.25804389257576854, [-2.8061224489795915, -3.897959183673469], 0.18939417098307887, [-5.571428571428572, -4.6020408163265305], -1.079995071965533, [-7.982857142857145, -0.6404081632653051], 1.1849950705219705, [-11.56285714285714, 4.179591836734694], -6.781917601823303, [-9.102857142857141, 9.019591836734694], 0.9585222487987152, [-7.222857142857144, 8.599591836734694], -0.7670525420358739, [14.397142857142853, 8.599591836734689], -0.13182825774707282, [14.397142857142851, 1.1795918367346951], 0.7921649344252789, [18.149142857142856, -0.836408163265304], -2.2405773687929207, [18.653142857142853, -5.176408163265303], 0.3179128740881875, [12.381142857142857, -5.176408163265302], -1.0648321015993136, [9.13314285714286, 0.08759183673469462], 1.761831734888522, [3.0011428571428587, 3.7835918367346952], -1.1347525744875853, [-1.702857142857143, 4.399591836734693], -0.019957132806512356, true]]
[1, "Polyline", 1, 1, 0, false, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 21, [-4.193877551020408, 0.5102040816326532], 0, [-2.051020408163265, 2.418367346938776], 0, [-1.0612244897959189, 0.7244897959183673], 0, [1.591836734693877, 1.153061224489796], 0, [1.5918367346938769, -0.13265306122449028], 0.20147559294404743, [2.6632653061224483, -2.6836734693877555], -1.1981710602936018, [-0.959183673469388, -5.244897959183675], 0.25804389257576854, [-2.8061224489795915, -3.897959183673469], 0.18939417098307887, [-5.571428571428572, -4.6020408163265305], -1.079995071965533, [-7.982857142857145, -0.6404081632653051], 1.1849950705219705, [-11.56285714285714, 4.179591836734694], -6.781917601823303, [-9.102857142857141, 9.019591836734694], 0.9585222487987152, [-7.222857142857144, 8.599591836734694], -0.7670525420358739, [14.397142857142853, 8.599591836734689], -0.13182825774707282, [14.397142857142851, 1.1795918367346951], 0.7921649344252789, [18.149142857142856, -0.836408163265304], -2.2405773687929207, [18.653142857142853, -5.176408163265303], 0.3179128740881875, [12.381142857142857, -5.176408163265302], -1.0648321015993136, [9.13314285714286, 0.08759183673469462], 1.761831734888522, [3.0011428571428587, 3.7835918367346952], -1.1347525744875853, [-1.702857142857143, 4.399591836734693], -0.019957132806512356, true]
);
let pl = cus[0] as Polyline;
@ -868,7 +840,7 @@ test('复杂圆盘选点', () =>
test('补充bug测试', () =>
{
let data =
[1, ["Polyline", 1, 1, 3, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 3014.1813078325877, -118.48659432946494, 0, 1], 2, 25, [7212.90932057689, -239.9823077249786], -0.9999999999999921, [7212.9093205768895, 122.19897643916269], 0, [7779.276759343887, 122.19897643916269], 0, [7779.276759344071, 428.1814280252842], 0.1947099739542557, [7740.981455628771, 522.7925370761521], 0, [7304.310456694637, 522.7925370760897], 0, [7489.002384561892, 796.1365903196343], 0, [7742.516525859682, 796.1365903196343], 0, [7742.516525859682, 961.2048135488966], -1.3463056702167695, [8021.98728468389, 876.8699986200176], 0, [8021.987284683929, 789.3738464533299], -0.05161685745547489, [8028.1320183974, 790.0098847386233], 0, [8444.377142303902, 790.0098847389027], -1.1043175340350022, [8413.555740131487, 479.90559801040376], 0, [8049.204632346665, 479.9055980109795], 1.512505548953077, [8054.570478774117, 467.3001115689552], 0.06283615294599319, [8055.684165377956, 468.79464872233984], 0, [8055.684165377962, 182.7089738110588], -0.056342427094734256, [8062.381207162069, 183.46603224647305], 0, [8468.88396462686, 183.4660322464784], -0.20525770195463292, [8655.475816304977, 103.49809581299945], -0.8336853670274493, [8492.531297747215, -120.51154890075377], 0, [8104.435007347477, -120.51154890071338], -0.6646338605614993, [7740.532382653638, -239.9823077249987], 0, [7212.90932057689, -239.9823077249786], 0, false]];
[1, "Polyline", 1, 1, 0, false, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 3014.1813078325877, -118.48659432946494, 0, 1], 2, 25, [7212.90932057689, -239.9823077249786], -0.9999999999999921, [7212.9093205768895, 122.19897643916269], 0, [7779.276759343887, 122.19897643916269], 0, [7779.276759344071, 428.1814280252842], 0.1947099739542557, [7740.981455628771, 522.7925370761521], 0, [7304.310456694637, 522.7925370760897], 0, [7489.002384561892, 796.1365903196343], 0, [7742.516525859682, 796.1365903196343], 0, [7742.516525859682, 961.2048135488966], -1.3463056702167695, [8021.98728468389, 876.8699986200176], 0, [8021.987284683929, 789.3738464533299], -0.05161685745547489, [8028.1320183974, 790.0098847386233], 0, [8444.377142303902, 790.0098847389027], -1.1043175340350022, [8413.555740131487, 479.90559801040376], 0, [8049.204632346665, 479.9055980109795], 1.512505548953077, [8054.570478774117, 467.3001115689552], 0.06283615294599319, [8055.684165377956, 468.79464872233984], 0, [8055.684165377962, 182.7089738110588], -0.056342427094734256, [8062.381207162069, 183.46603224647305], 0, [8468.88396462686, 183.4660322464784], -0.20525770195463292, [8655.475816304977, 103.49809581299945], -0.8336853670274493, [8492.531297747215, -120.51154890075377], 0, [8104.435007347477, -120.51154890071338], -0.6646338605614993, [7740.532382653638, -239.9823077249987], 0, [7212.90932057689, -239.9823077249786], 0, false]
let pl = loadFile(data)[0];
@ -883,7 +855,7 @@ test('补充bug测试', () =>
test('多段线存在0长度线段导致偏移错误', () =>
{
let pl = loadFile(
[1, ["Polyline", 1, 1, 199, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 9, [18464.40681262459, -261.95809608907166], 0, [23818.6302458671, 7299.349805818285], 0, [34567.94904695702, 3988.7231028210094], 0, [34567.94904695702, 3988.7231028210094], 0, [42946.69564096247, 8484.635909360519], -0.7515576999403787, [50221.90000063549, 1045.9438112678758], -0.43729267560971036, [41557.04986439571, -997.652918977356], -0.5825417553875781, [27905.82370635756, -6760.5956982689095], 0, [19404.461308537397, -2591.658368568635], 0, true]]
[1, "Polyline", 1, 1, 0, false, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 9, [18464.40681262459, -261.95809608907166], 0, [23818.6302458671, 7299.349805818285], 0, [34567.94904695702, 3988.7231028210094], 0, [34567.94904695702, 3988.7231028210094], 0, [42946.69564096247, 8484.635909360519], -0.7515576999403787, [50221.90000063549, 1045.9438112678758], -0.43729267560971036, [41557.04986439571, -997.652918977356], -0.5825417553875781, [27905.82370635756, -6760.5956982689095], 0, [19404.461308537397, -2591.658368568635], 0, true]
)[0];
testOffset(pl, 400);
@ -894,7 +866,7 @@ test('多段线存在0长度线段导致偏移错误', () =>
test('纯圆生成的多段线偏移', () =>
{
let pl = loadFile(
[1, ["Polyline", 1, 1, 710, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 1904.6173097681894, -4.547473508864641e-13, 0, 1], 2, 2, [18361.211643461193, 495.8146231175723], 0.7691548555148293, [18910.40925296759, 2564.4589522583397], 1.3001283068422635, true]]
[1, "Polyline", 1, 1, 0, false, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 1904.6173097681894, -4.547473508864641e-13, 0, 1], 2, 2, [18361.211643461193, 495.8146231175723], 0.7691548555148293, [18910.40925296759, 2564.4589522583397], 1.3001283068422635, true]
)[0];
testOffset(pl, 100);
@ -904,7 +876,7 @@ test('纯圆生成的多段线偏移', () =>
test('多段线因为合并问题造成的错误', () =>
{
let pl = loadFile(
[1, ["Polyline", 1, 1, 38, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 10, [560.4622946261899, 280.3468208092485], 0, [273.1213872832369, 280.3468208092485], 0, [273.1213872832369, 70.80924855491334], 0, [273.1213872832369, 70.80924855491334], 0, [520.5860801571987, 70.80924855491334], 0.45552774411272906, [773.2934581245079, 9.947706891888771], 1.0105662598284268, [843.111615774608, 120.72879526430421], 0.42745194242823337, [695.3090834219281, 321.1478937918483], 3.4733857741050023, [602.1148370593586, 307.0986147536708], 0.07222028753966563, [560.4622946261899, 280.3468208092485], 0, false]]
[1, "Polyline", 1, 1, 0, false, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 10, [560.4622946261899, 280.3468208092485], 0, [273.1213872832369, 280.3468208092485], 0, [273.1213872832369, 70.80924855491334], 0, [273.1213872832369, 70.80924855491334], 0, [520.5860801571987, 70.80924855491334], 0.45552774411272906, [773.2934581245079, 9.947706891888771], 1.0105662598284268, [843.111615774608, 120.72879526430421], 0.42745194242823337, [695.3090834219281, 321.1478937918483], 3.4733857741050023, [602.1148370593586, 307.0986147536708], 0.07222028753966563, [560.4622946261899, 280.3468208092485], 0, false]
)[0];
testOffset(pl, 37.8831);

@ -1,11 +1,11 @@
import { Factory } from "../../src/DatabaseServices/CADFactory";
import { CADFile } from "../../src/DatabaseServices/CADFile";
import { CADFiler } from "../../src/DatabaseServices/CADFiler";
import { Curve } from "../../src/DatabaseServices/Curve";
import { Polyline } from "../../src/DatabaseServices/Polyline";
Factory(Polyline);
function loadFile(data)
{
let file = new CADFile();
let file = new CADFiler();
file.Data = data;
let cus: Curve[] = [];
let count = file.Read();
@ -19,7 +19,7 @@ test('补充bug测试#IKWGF', () =>
{
//https://gitee.com/BearCAD/WebThreeJs/issues/IKWGF
let data =
[1, ["Polyline", 1, 1, 28, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -1.073087818696886, -6.460623229461753, 0, 1], 2, 13, [2.913294797687863, 5.657009425680781], -0.10216571300036134, [3.0668619767188887, 5.578034682080925], 0, [4.6094463694365295, 5.578034682080925], -2.632498680881094, [4.609446369436524, 3.627167630057804], 0, [2.4566473988439355, 3.627167630057804], 0, [2.4566473988439355, 3.627167630057804], 0, [2.4566473988439355, 4.990312071734102], -0.11795690250598688, [2.37813156168231, 5.1728323699421965], 0, [1.8884393063583844, 5.1728323699421965], 0, [1.8884393063583844, 5.1728323699421965], 0, [1.8884393063583844, 6.15606936416185], 0, [2.913294797687864, 6.15606936416185], 0, [2.913294797687864, 5.657009425680784], 0, false]];
[1, "Polyline", 1, 1, 0, false, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -1.073087818696886, -6.460623229461753, 0, 1], 2, 13, [2.913294797687863, 5.657009425680781], -0.10216571300036134, [3.0668619767188887, 5.578034682080925], 0, [4.6094463694365295, 5.578034682080925], -2.632498680881094, [4.609446369436524, 3.627167630057804], 0, [2.4566473988439355, 3.627167630057804], 0, [2.4566473988439355, 3.627167630057804], 0, [2.4566473988439355, 4.990312071734102], -0.11795690250598688, [2.37813156168231, 5.1728323699421965], 0, [1.8884393063583844, 5.1728323699421965], 0, [1.8884393063583844, 5.1728323699421965], 0, [1.8884393063583844, 6.15606936416185], 0, [2.913294797687864, 6.15606936416185], 0, [2.913294797687864, 5.657009425680784], 0, false]
let pl = loadFile(data)[0];

@ -1,5 +1,5 @@
import { Vector2, Vector3 } from 'three';
import { CADFile } from '../../src/DatabaseServices/CADFile';
import { CADFiler } from '../../src/DatabaseServices/CADFiler';
import { Polyline } from '../../src/DatabaseServices/Polyline';
import { equaln, equalv3 } from '../../src/Geometry/GeUtils';
@ -473,9 +473,9 @@ describe('多段线', () =>
//直线和圆的求交的det精度不能为0.1 太大了.请保证这个测试是通过的
test('最近点精度', () =>
{
let f = new CADFile();
let f = new CADFiler();
f.Data =
[1, ["Polyline", 1, 1, 3, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 5, [0, 0], 0, [2, 0], 1, [2, 2], -1, [2, 4], 0, [0, 4], 0, true]]
[1, "Polyline", 1, 1, 0, false, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 5, [0, 0], 0, [2, 0], 1, [2, 2], -1, [2, 4], 0, [0, 4], 0, true]
f.Read();
let pl = f.ReadObject() as Polyline;
pl.Reverse();
@ -500,9 +500,9 @@ describe('多段线', () =>
test('存在大圆弧的多段线面积', () =>
{
let f = new CADFile();
let f = new CADFiler();
f.Data =
[1, ["Polyline", 1, 1, 1606, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -19.17745164184445, -6.335408131680751, 0, 1], 2, 5, [11.884352072596577, -75.64730611519322], -1.9523252757782086, [16.25360183965801, -70.58112080246555], 0, [14.621427950114992, -70.9720172143345], 1.8583004340984604, [11.834326201222096, -73.95002751582643], 0, [11.884352072596577, -75.64730611519322], 0, false]]
[1, "Polyline", 1, 1, 0, false, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -19.17745164184445, -6.335408131680751, 0, 1], 2, 5, [11.884352072596577, -75.64730611519322], -1.9523252757782086, [16.25360183965801, -70.58112080246555], 0, [14.621427950114992, -70.9720172143345], 1.8583004340984604, [11.834326201222096, -73.95002751582643], 0, [11.884352072596577, -75.64730611519322], 0, false]
f.Read();
@ -515,8 +515,9 @@ describe('多段线', () =>
test('最近点参数刚好在端点上', () =>
{
let f = new CADFile();
f.Data = [1, ["Polyline", 1, 1, 11, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 15.725529745042493, -3.9968028886505635e-15, 0, 1], 2, 3, [13.07875354107649, 3.8181303116147296], 0, [18.159206798866855, 3.8181303116147296], 0.664293193717279, [18.159206798866855, -1.4844192634560907], -0.10977222864644352, false]];
let f = new CADFiler();
f.Data =
[1, "Polyline", 1, 1, 0, false, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 15.725529745042493, -3.9968028886505635e-15, 0, 1], 2, 3, [13.07875354107649, 3.8181303116147296], 0, [18.159206798866855, 3.8181303116147296], 0.664293193717279, [18.159206798866855, -1.4844192634560907], -0.10977222864644352, false]
f.Read();
let pl = f.ReadObject() as Polyline;
@ -531,7 +532,7 @@ test('最近点参数刚好在端点上', () =>
function loadFile(data)
{
let file = new CADFile();
let file = new CADFiler();
file.Data = data;
let cus: Polyline[] = [];
let count = file.Read();
@ -546,7 +547,7 @@ function loadFile(data)
test('点在线上精度', () =>
{
let data =
[1, ["Polyline", 1, 1, 4, false, 2, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 6.283029954893735, -0.21450491241551983, 0, 1], 2, 5, [-6.290104635739899, 3.3748564511765324], -0.10216571300036131, [-6.136537456708874, 3.2958817075766764], 0, [-6.236783847999098, 3.0649817075766763], 0.44141445079284647, [-6.5210046357398985, 3.121255471298752], 0, [-6.290104635739899, 3.3748564511765324], 0, false]]
[1, "Polyline", 1, 1, 0, false, 2, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 6.283029954893735, -0.21450491241551983, 0, 1], 2, 5, [-6.290104635739899, 3.3748564511765324], -0.10216571300036131, [-6.136537456708874, 3.2958817075766764], 0, [-6.236783847999098, 3.0649817075766763], 0.44141445079284647, [-6.5210046357398985, 3.121255471298752], 0, [-6.290104635739899, 3.3748564511765324], 0, false]
let pl = loadFile(data)[0];

@ -1,18 +1,45 @@
import { CADFile } from "../../src/DatabaseServices/CADFile";
import { CADFiler } from "../../src/DatabaseServices/CADFiler";
import { Entity } from "../../src/DatabaseServices/Entity";
import { Polyline } from "../../src/DatabaseServices/Polyline";
import { Factory } from "../../src/DatabaseServices/CADFactory";
import { Curve } from "../../src/DatabaseServices/Curve";
import { Board } from "../../src/DatabaseServices/Board";
import { Region } from "../../src/DatabaseServices/Region";
Factory(Polyline);
Factory(Region);
Factory(Board);
export function LoadEntityFromFileData(data)
{
let file = new CADFile();
let file = new CADFiler();
file.Data = data;
let ens: Entity[] = [];
let count = file.Read();
if (typeof count !== "number")
{
count = file.Data.length;
file.Reset();
}
for (let i = 0; i < count; i++)
{
ens.push(file.ReadObject(undefined) as Entity);
ens.push(file.ReadObject() as Entity);
}
return ens;
}
export function LoadCurvesFromFileData(data)
{
return LoadEntityFromFileData(data) as Curve[];
}
export function LoadBoardsFromFileData(data)
{
return LoadEntityFromFileData(data) as Board[];
}
export function LoadRegionsFromFileData(data)
{
return LoadEntityFromFileData(data) as Region[];
}

@ -1,4 +1,6 @@
import { app } from '../ApplicationServices/Application';
import { DeepCloneFiler } from '../DatabaseServices/DeepCloneFiler';
import { Entity } from '../DatabaseServices/Entity';
import { Command } from '../Editor/CommandMachine';
import { JigUtils } from '../Editor/JigUtils';
import { PromptStatus } from '../Editor/PromptResult';
@ -9,19 +11,21 @@ export class Command_Copy implements Command
async exec()
{
let ssRes = await app.m_Editor.GetSelection({ Msg: "请选择需要拷贝的实体:", UseSelect: true });
if (ssRes.Status != PromptStatus.OK)
if (ssRes.Status !== PromptStatus.OK)
return;
let ptRes = await app.m_Editor.GetPoint({ Msg: "请选择复制基点:" });
if (ptRes.Status != PromptStatus.OK)
if (ptRes.Status !== PromptStatus.OK)
return;
let ptBase = ptRes.Value;
let ptLast = ptBase.clone();
let orgEns = ssRes.SelectSet.SelectEntityList;
let jigEns = orgEns.map(e => JigUtils.Draw(e));
let f = new DeepCloneFiler();
let cloneEns: Entity[] = f.CloneObjects(orgEns) as Entity[];
let jigEns = cloneEns.map(e => JigUtils.Draw(e));
while (true)
{
app.m_Database.hm.StartMark();
@ -40,11 +44,11 @@ export class Command_Copy implements Command
if (ptRes2.Status === PromptStatus.OK)
{
let moveM = MoveMatrix(ptRes2.Value.sub(ptBase));
for (let e of orgEns)
app.m_Database.CheapClone(f, new Map(), app.m_Database.ModelSpace);
for (let obj of cloneEns)
{
e = e.Clone().ApplyMatrix(moveM);
e.RestoreJigMaterial();
app.m_Database.ModelSpace.Append(e);
let en = obj as Entity;
en.ApplyMatrix(moveM);
}
}
else

@ -1,6 +1,6 @@
import { app } from "../ApplicationServices/Application";
import { copyTextToClipboard } from "../Common/Utils";
import { CADFile } from "../DatabaseServices/CADFile";
import { CADFiler } from "../DatabaseServices/CADFiler";
export class CopyClip
{
@ -9,7 +9,7 @@ export class CopyClip
let ss = app.m_Editor.m_SelectCtrl.SelectSet;
if (ss.SelectEntityList.length === 0) return;
let f = new CADFile();
let f = new CADFiler();
f.Write(ss.SelectEntityList.length);
ss.SelectEntityList.forEach(e => f.WriteObject(e));

@ -0,0 +1,73 @@
import { Vector3 } from "three";
import { app } from "../ApplicationServices/Application";
import { Singleton } from "../Common/Singleton";
import { CADFiler } from "../DatabaseServices/CADFiler";
import { Database } from "../DatabaseServices/Database";
import { Entity } from "../DatabaseServices/Entity";
import { FileInfo, FileServer } from "../DatabaseServices/FileServer";
import { Command } from "../Editor/CommandMachine";
import { JigUtils } from "../Editor/JigUtils";
import { PromptStatus } from "../Editor/PromptResult";
import { MoveMatrix } from "../Geometry/GeUtils";
import { IndexedDbStore, StoreName } from "../IndexedDb/IndexedDbStore";
import { InsertModal } from "../UI/Components/Modal/InsertModal";
import { ModalPosition } from "../UI/Components/Modal/ModalsManage";
export class Command_Insert implements Command
{
async exec()
{
let fileServer = Singleton.GetInstance(FileServer);
let files = await fileServer.ReadFileList();
let finfo: FileInfo;
let props = {
files, res: (f) =>
{
finfo = f;
}
};
app.m_Editor.m_ModalManage.RenderModal(InsertModal, ModalPosition.Center, props);
let state = await app.m_Editor.m_ModalManage.Wait();
if (state !== 1 || !finfo)
return;
let store = await IndexedDbStore.CADStore();
let fileData = await store.Get(StoreName.Dwg, finfo.fileId);
if (fileData)
{
let deepFile = new CADFiler(fileData);
let db = new Database();
deepFile.database = db;
db.FileRead(deepFile);
let ens = app.m_Database.DeepCloneObjects(db.ModelSpace.objectCol, app.m_Database.ModelSpace) as Entity[];
if (ens.length > 0)
{
let ensClone = ens.map(e => JigUtils.Draw(e));
let ptLast = new Vector3();
let ptRes = await app.m_Editor.GetPoint(
{
Msg: "请点击移动终点:",
Callback: (p: THREE.Vector3) =>
{
let moveMatrix = MoveMatrix(p.clone().sub(ptLast));
ensClone.forEach(e => e.ApplyMatrix(moveMatrix));
ptLast.copy(p);
}
});
JigUtils.End();
if (ptRes.Status === PromptStatus.OK)
{
let moveM = MoveMatrix(ptRes.Value);
ens.forEach(e => e.ApplyMatrix(moveM));
}
}
}
}
}

@ -1,7 +1,7 @@
import { Command } from "../Editor/CommandMachine";
import { app } from "../ApplicationServices/Application";
import { IndexedDbStore, StoreName } from "../IndexedDb/IndexedDbStore";
import { CADFile } from "../DatabaseServices/CADFile";
import { CADFiler } from "../DatabaseServices/CADFiler";
import { Singleton } from "../Common/Singleton";
import { RightPanelStore } from "../UI/Store/RightPanelStore";
@ -19,7 +19,8 @@ export class Open implements Command
{
store.m_CurrentFileId = fid;
let cadF = new CADFile();
let cadF = new CADFiler();
cadF.database = app.m_Database;
cadF.Data = file;
app.m_Database.FileRead(cadF);
Singleton.GetInstance(RightPanelStore).lightStore.InitScene();

@ -1,7 +1,7 @@
import { Matrix4 } from "three";
import { app } from "../ApplicationServices/Application";
import { readClipboardText } from "../Common/Utils";
import { CADFile } from "../DatabaseServices/CADFile";
import { CADFiler } from "../DatabaseServices/CADFiler";
import { Entity } from "../DatabaseServices/Entity";
import { PromptStatus } from "../Editor/PromptResult";
import { JigUtils } from "../Editor/JigUtils";
@ -16,7 +16,7 @@ export class PasteClip
let obj = JSON.parse(str);
if (obj)
{
let f = new CADFile();
let f = new CADFiler();
f.Data = obj;
let count = f.Read();

@ -6,7 +6,6 @@ export class Undo implements Command
async exec()
{
app.m_Database.hm.Undo();
app.m_Editor.UpdateScreen();
}
}
@ -16,6 +15,5 @@ export class Redo implements Command
async exec()
{
app.m_Database.hm.Redo();
app.m_Editor.UpdateScreen();
}
}

@ -0,0 +1,39 @@
import { app } from "../ApplicationServices/Application";
import { Singleton } from "../Common/Singleton";
import { formateDate } from "../Common/Utils";
import { Database } from "../DatabaseServices/Database";
import { Entity } from "../DatabaseServices/Entity";
import { FileServer } from "../DatabaseServices/FileServer";
import { Command } from "../Editor/CommandMachine";
import { PromptStatus } from "../Editor/PromptResult";
import { MoveMatrix } from "../Geometry/GeUtils";
export class Command_Wblock implements Command
{
async exec()
{
let ssRes = await app.m_Editor.GetSelection({ Msg: "请选择需要拷贝的实体:", UseSelect: true });
if (ssRes.Status !== PromptStatus.OK)
return;
let ptRes = await app.m_Editor.GetPoint({ Msg: "请选择复制基点:" });
if (ptRes.Status !== PromptStatus.OK)
return;
let newDb = new Database();
let cloneEns = newDb.DeepCloneObjects(ssRes.SelectSet.SelectEntityList, newDb.ModelSpace) as Entity[];
let moveM = MoveMatrix(ptRes.Value.negate());
for (let en of cloneEns)
en.ApplyMatrix(moveM);
let fileServer = Singleton.GetInstance(FileServer);
let fileInfo = await fileServer.CreateFile();
//更新最后修改时间
fileInfo.modifyTime = formateDate(new Date(), "yyyy-MM-dd hh:mm:ss");
fileServer.UpdateFileInfo(fileInfo);
let f = newDb.FileWrite();
fileServer.UpdateFile(fileInfo.fileId, f.Data);
}
}

@ -1,8 +1,29 @@
import { Command } from "../../Editor/CommandMachine";
import { app } from "../../ApplicationServices/Application";
import { PromptStatus } from "../../Editor/PromptResult";
import { CADObject } from "../../DatabaseServices/CADObject";
import { MoveMatrix } from "../../Geometry/GeUtils";
import { Vector3 } from "three";
import { Entity } from "../../DatabaseServices/Entity";
export class Test implements Command
{
async exec()
{
let ssRes = await app.m_Editor.GetSelection();
if (ssRes.Status === PromptStatus.OK)
{
let objs: CADObject[] = [];
app.m_Database.DeepCloneObjects(ssRes.SelectSet.SelectEntityList, app.m_Database.ModelSpace, new Map(), objs);
let moveMatrix = MoveMatrix(new Vector3(2000, 0, 0));
for (let obj of objs)
{
let en = obj as Entity;
en.ApplyMatrix(moveMatrix);
}
}
}
}

@ -2,7 +2,7 @@ import { Vector3 } from 'three';
import * as xaop from 'xaop';
import { end } from 'xaop';
import { KeyBoard, MouseKey } from '../Common/KeyEnum';
import { CADFile } from '../DatabaseServices/CADFile';
import { CADFiler } from '../DatabaseServices/CADFiler';
import { Database } from '../DatabaseServices/Database';
import { Entity } from '../DatabaseServices/Entity';
import { FontLoader } from '../DatabaseServices/Text/FontLoader';
@ -180,22 +180,25 @@ export class ApplicationService
appUi.setDocumentName("新文件");
}
FileOut(): CADFile
FileOut(): CADFiler
{
let f = this.m_Database.FileWrite();
let vf = new CADFile();
let vf = new CADFiler();
this.m_Viewer.m_CameraCtrl.WriteFile(vf);
f.Write(vf.Data);
return f;
}
OpenFile(f: CADFile)
OpenFile(f: CADFiler)
{
f.database = this.m_Database;
f.Reset();
this.m_Database.FileRead(f);
let viewData = f.Read();
if (viewData)
this.m_Viewer.m_CameraCtrl.ReadFile(new CADFile(viewData));
this.m_Viewer.m_CameraCtrl.ReadFile(new CADFiler(viewData));
else
this.m_Viewer.ZoomAll();
}
}

@ -1,7 +1,7 @@
import * as THREE from 'three';
import { MeshNormalMaterial, Object3D, Geometry, Vector3, ExtrudeGeometry } from "three";
import { RenderType } from "../../GraphicsSystem/RenderType";
import { CADFile } from '../CADFile';
import { CADFiler } from '../CADFiler';
import { Solid3D } from "./Solid3D";
import { Factory } from '../CADFactory';
import { Contour } from '../Contour';
@ -69,7 +69,7 @@ export class Cylineder extends Solid3D
(obj.geometry as Geometry).verticesNeedUpdate = true;
}
ReadFile(file: CADFile)
ReadFile(file: CADFiler)
{
super.ReadFile(file);
let ver = file.Read();//1
@ -77,7 +77,7 @@ export class Cylineder extends Solid3D
this.m_Height = file.Read();
this.m_Center.fromArray(file.Read());
}
WriteFile(file: CADFile)
WriteFile(file: CADFiler)
{
super.WriteFile(file);
file.Write(1);//ver

@ -2,7 +2,7 @@ import * as THREE from 'three';
import { ExtrudeGeometry, Geometry, MeshNormalMaterial, Object3D, Vector3 } from "three";
import { RenderType } from "../../GraphicsSystem/RenderType";
import { Factory } from '../CADFactory';
import { CADFile } from '../CADFile';
import { CADFiler } from '../CADFiler';
import { Circle } from '../Circle';
import { Contour } from '../Contour';
import { Shape } from '../Shape';
@ -65,15 +65,17 @@ export class GangDrill extends Solid3D
(obj.geometry as Geometry).verticesNeedUpdate = true;
}
ReadFile(file: CADFile)
ReadFile(file: CADFiler)
{
super.ReadFile(file);
let ver = file.Read();//1
this.m_Shape = new Shape();
this.m_Shape.ReadFile(file);
this.m_Height = file.Read();
this.Update();
}
WriteFile(file: CADFile)
WriteFile(file: CADFiler)
{
super.WriteFile(file);
file.Write(1);//ver

@ -4,7 +4,7 @@ import { equalv3, isParallelTo, MoveMatrix } from '../../Geometry/GeUtils';
import { SweepGeometry } from '../../Geometry/SweepGeometry';
import { RenderType } from "../../GraphicsSystem/RenderType";
import { Factory } from "../CADFactory";
import { CADFile } from '../CADFile';
import { CADFiler } from '../CADFiler';
import { Curve } from "../Curve";
import { DbPhysicalMaterial } from '../PhysicalMaterial';
import { IsPointInPolyLine } from '../PointInPolyline';
@ -160,14 +160,14 @@ export class SweepSolid extends Solid3D
this.m_PathCurve.MoveStretchPoints(indexList, vec);
this.Update();
}
ReadFile(file: CADFile)
ReadFile(file: CADFiler)
{
super.ReadFile(file);
let ver = file.Read();//1
this.m_Contour = file.ReadObject() as Polyline;
this.m_PathCurve = file.ReadObject() as Curve;
}
WriteFile(file: CADFile)
WriteFile(file: CADFiler)
{
super.WriteFile(file);
file.Write(1);//ver

@ -1,5 +1,5 @@
import { Factory } from './CADFactory';
import { CADFile } from './CADFile';
import { CADFiler } from './CADFiler';
import { ISerialize } from './ISerialize';
import { CADObject } from './CADObject';
/**
@ -12,17 +12,17 @@ import { CADObject } from './CADObject';
@Factory
export class AllObjectData implements ISerialize
{
file: CADFile;
file: CADFiler;
constructor(obj?: CADObject)
{
this.file = new CADFile();
this.file = new CADFiler();
if (obj)
obj.WriteFile(this.file);
}
//#region -------------------------File-------------------------
//对象应该实现dataIn和DataOut的方法,为了对象的序列化和反序列化
//对象从文件中读取数据,初始化自身
ReadFile(file: CADFile)
ReadFile(file: CADFiler)
{
let ver = file.Read();
let data = file.Read();
@ -30,7 +30,7 @@ export class AllObjectData implements ISerialize
return this;
}
//对象将自身数据写入到文件.
WriteFile(file: CADFile)
WriteFile(file: CADFiler)
{
file.Write(1);
file.Write(this.file.Data);

@ -10,7 +10,7 @@ import { angle, angleTo2Pi, equaln, equalv3, midPoint, MoveMatrix, polar } from
import { RenderType } from '../GraphicsSystem/RenderType';
import { IntersectArcAndArc, IntersectCircleAndArc, IntersectLineAndArc, IntersectOption, IntersectPolylineAndCurve, reverseIntersectOption } from '../GraphicsSystem/IntersectWith';
import { Factory } from './CADFactory';
import { CADFile } from './CADFile';
import { CADFiler } from './CADFiler';
import { Circle } from './Circle';
import { Curve } from './Curve';
import { Line } from './Line';
@ -743,7 +743,7 @@ export class Arc extends Curve
//对象应该实现dataIn和DataOut的方法,为了对象的序列化和反序列化
//对象从文件中读取数据,初始化自身
ReadFile(file: CADFile)
ReadFile(file: CADFiler)
{
super.ReadFile(file);
let ver = file.Read();
@ -759,7 +759,7 @@ export class Arc extends Curve
this.Update();
}
//对象将自身数据写入到文件.
WriteFile(file: CADFile)
WriteFile(file: CADFiler)
{
super.WriteFile(file);
file.Write(2);

@ -9,7 +9,7 @@ import ThreeBSP from '../Geometry/ThreeCSG';
import { RenderType } from '../GraphicsSystem/RenderType';
import { BoardProcessOption, ComposingType, DrillType, LinesType, PXLFaceType } from '../UI/Store/BoardInterface';
import { Factory } from './CADFactory';
import { CADFile } from './CADFile';
import { CADFiler } from './CADFiler';
import { Circle } from './Circle';
import { Contour } from './Contour';
import { Curve } from './Curve';
@ -197,15 +197,22 @@ export class Board extends Entity
}
Erase(isErase: boolean = true)
{
if (isErase === this.IsErase)
return;
super.Erase(isErase);
for (const [id,] of this.m_DrillList)
for (const [id, dris] of this.m_DrillList)
{
if (id)
{
let notErase = !isErase && id.Object && !id.Object.IsErase;
for (let dri of dris)
{
this.ClearDrillList(id);
let br = id.Object as Board;
br.ClearDrillList(this.Id);
for (let d of dri)
if (d && d.Object)
d.Object.Erase(!notErase);
}
}
}
this.m_DrillList.clear();
super.Erase(isErase);
}
get RotateMat()
{
@ -859,7 +866,7 @@ export class Board extends Entity
// mesh.material = ColorMaterial.GetBasicMaterial(this.ColorIndex);
}
ReadFile(file: CADFile)
ReadFile(file: CADFiler)
{
super.ReadFile(file);
let ver = file.Read();
@ -877,7 +884,7 @@ export class Board extends Entity
let size = file.Read();
for (let i = 0; i < size; i++)
{
let id = this.ReadObjectId(file);
let id = file.ReadObjectId();
let drIdList: ObjectId[][] = [];
let count = file.Read();
for (let i = 0; i < count; i++)
@ -886,7 +893,7 @@ export class Board extends Entity
let count1 = file.Read();
for (let j = 0; j < count1; j++)
{
let fileId = this.ReadObjectId(file);
let fileId = file.ReadObjectId();
fileId && drIDs.push(fileId);
}
drIdList.push(drIDs);
@ -911,7 +918,7 @@ export class Board extends Entity
this.Update();
}
WriteFile(file: CADFile)
WriteFile(file: CADFiler)
{
super.WriteFile(file);
file.Write(1);
@ -928,14 +935,15 @@ export class Board extends Entity
file.Write(this.m_DrillList.size);
for (let [id, idList] of this.m_DrillList)
{
this.WriteObjectId(file, id);
if (id && id.Object && !id.Object.IsErase)
{
file.WriteObjectId(id);
file.Write(idList.length);
for (let ids of idList)
{
file.Write(ids.length);
for (let id of ids)
{
this.WriteObjectId(file, id)
file.WriteObjectId(id);
}
}
}

@ -1,4 +1,3 @@
import { CADObject } from "./CADObject";
/**
* CAD, ,
@ -15,7 +14,7 @@ export class CADFactory
{
this.factory.objectNameMap.set(C.name, C);
}
static CreateObject(name: string): CADObject
static CreateObject(name: string): any
{
let C = this.factory.objectNameMap.get(name);
if (C) return new C();

@ -8,15 +8,14 @@ import { ObjectId } from './ObjectId';
* CAD
*
* @export
* @class CADFile
* @class CADFiler
*/
export class CADFile
export class CADFiler
{
database: Database;
private readIndex: number = 0;
private dataList: any[];
constructor(data: any[] = [])
constructor(private dataList = [])
{
this.dataList = data;
}
Destroy()
@ -24,29 +23,33 @@ export class CADFile
delete this.dataList;
delete this.readIndex;
}
get Data()
{
return this.dataList;
}
set Data(v)
set Data(data)
{
this.dataList = v;
this.dataList = data;
this.Reset();
}
Reset()
{
this.readIndex = 0;
}
WriteString(str: string)
{
this.dataList.push(str);
}
ReadString(): string
{
let str = this.dataList[this.readIndex] as string;
this.readIndex++;
return str;
return this.dataList[this.readIndex++] as string;
}
WriteObject(obj: ISerialize)
{
if (!obj)
@ -54,33 +57,37 @@ export class CADFile
this.Write("");
return;
}
let tempFile = new CADFile();
tempFile.WriteString(obj.constructor.name);
obj.WriteFile(tempFile);
this.Write(tempFile.Data);
tempFile.Destroy();//GC
this.WriteString(obj.constructor.name);
obj.WriteFile(this);
}
ReadObject(db?: Database, obj?: CADObject): CADObject
{
let data = this.Read();
let tempFile = new CADFile();
tempFile.Data = data;
let className = tempFile.ReadString();
ReadObject(obj?: CADObject): CADObject
{
let className = this.ReadString();
if (className)
{
if (obj === undefined)
{
obj = CADFactory.CreateObject(className);
if (db !== undefined && obj instanceof CADObject)
obj.SetDefaultDb(db);
if (this.database !== undefined && obj instanceof CADObject)
obj.SetDefaultDb(this.database);
}
obj.ReadFile(tempFile);
tempFile.Destroy();
obj.ReadFile(this);
return obj;
}
}
CloneObjects(objects: ISerialize[], clonedObjects: ISerialize[] = [])
{
for (let o of objects)
this.WriteObject(o);
let count = objects.length;
for (let i = 0; i < count; i++)
clonedObjects.push(this.ReadObject());
return clonedObjects;
}
Write(data: any)
{
if (data instanceof ObjectId)
@ -88,12 +95,27 @@ export class CADFile
else
this.dataList.push(data);
}
Read(): any
{
let data = this.dataList[this.readIndex];
this.readIndex++;
return data;
return this.dataList[this.readIndex++];
}
WriteObjectId(id: ObjectId)
{
if (id)
this.Write(id.Index);
else
this.Write(0);
}
ReadObjectId(): ObjectId
{
let index = this.Read();
if (this.database)
return this.database.GetObjectId(index, true);
}
ToString()
{
return JSON.stringify(this.dataList);

@ -1,10 +1,11 @@
import { CADFile } from './CADFile';
import { CADFiler } from './CADFiler';
import { CommandHistoryRecord } from './CommandHistoryRecord';
import { Database } from './Database';
import { ISerialize } from './ISerialize';
import { ObjectId } from './ObjectId';
import { EraseEntityData } from './EraseEntityData';
import { AllObjectData } from './AllObjectData';
import { CADFactory } from './CADFactory';
export abstract class CADObject
{
@ -32,12 +33,13 @@ export abstract class CADObject
//private 私有的方法,暴露给Db的添加对象,方法使用.
//只用对象加入到db中,我们才初始化ObjectId.
//从db池中分配id给自身使用. 除非你创建对象往db里面加,否则不要调用该方法
InitObjectId(db: Database)
SetOwnerDatabase(db: Database)
{
if (!this._db)
{
this._db = db;
this.objectId = db.AllocateId(this);
this.objectId = db.AllocateId();
this.objectId.Object = this;
}
else
console.warn("同一个对象无法重复设置到数据库中!");
@ -52,6 +54,8 @@ export abstract class CADObject
}
Erase(isErase: boolean = true)
{
if (isErase === this._isErase)
return;
let undoData = this.UndoRecord();
if (undoData)
undoData.CreateEraseHistory(this, isErase);
@ -73,11 +77,11 @@ export abstract class CADObject
//对象应该实现dataIn和DataOut的方法,为了对象的序列化和反序列化
//对象从文件中读取数据,初始化自身
ReadFile(file: CADFile)
ReadFile(file: CADFiler)
{
let ver = file.Read();
//write Id;
let id = this.ReadObjectId(file);
let id = file.ReadObjectId();
if (!this.objectId && id)//避免CopyFrom时错误的修改自身Id
{
this.objectId = id;
@ -86,10 +90,10 @@ export abstract class CADObject
this._isErase = file.Read();
}
//对象将自身数据写入到文件.
WriteFile(file: CADFile)
WriteFile(file: CADFiler)
{
file.Write(1);
this.WriteObjectId(file, this.objectId);
file.WriteObjectId(this.objectId);
file.Write(this._isErase);
}
//局部撤销
@ -97,6 +101,7 @@ export abstract class CADObject
{
if (undoData instanceof AllObjectData)
{
undoData.file.database = this._db;
undoData.file.Reset();
this.ReadFile(undoData.file);
}
@ -123,41 +128,39 @@ export abstract class CADObject
//复制出一个实体,所有的关联引用全部失效,如有需要,请重新关联.
Clone(): this
{
let file = new CADFile();
file.WriteObject(this);
let newObject = file.ReadObject() as this;
let newObject = CADFactory.CreateObject(this.constructor.name) as this;
let file = new CADFiler();
this.WriteFile(file);
file.Reset();
newObject.ReadFile(file);
newObject.objectId = undefined;
newObject._db = undefined;
return newObject;
}
DeepClone(
ownerObject: CADObject,
cloneObejct: CADObject,
idMaping: Map<number, ObjectId> = undefined,
isPrimary = true
): this
{
return this;
}
//从一个实体拷贝数据,实体类型必须相同.
CopyFrom(obj: CADObject)
{
let id = this.objectId;
this.WriteAllObjectRecord();
let f = new CADFile();
let f = new CADFiler();
obj.WriteFile(f);
this.ReadFile(f);
this.objectId = id;
}
//-------------------------File End-------------------------
protected WriteObjectId(file: CADFile, id: ObjectId)
{
if (id)
{
file.Write(id.Index);
}
else
file.Write(-1);
}
protected ReadObjectId(file: CADFile): ObjectId
{
let index = file.Read();
if (index >= 0 && this._db)
{
return ObjectId.Create(this._db, index);
}
}
}

@ -12,7 +12,7 @@ import { RenderType } from '../GraphicsSystem/RenderType';
import { IntersectCircleAndArc, IntersectCircleAndCircle, IntersectLineAndCircle, IntersectOption, IntersectPolylineAndCurve, reverseIntersectOption } from '../GraphicsSystem/IntersectWith';
import { Arc } from './Arc';
import { Factory } from './CADFactory';
import { CADFile } from './CADFile';
import { CADFiler } from './CADFiler';
import { Curve } from './Curve';
import { Line } from './Line';
import { Polyline } from './Polyline';
@ -364,7 +364,7 @@ export class Circle extends Curve
//对象应该实现dataIn和DataOut的方法,为了对象的序列化和反序列化
//对象从文件中读取数据,初始化自身
ReadFile(file: CADFile)
ReadFile(file: CADFiler)
{
super.ReadFile(file);
let ver = file.Read();
@ -372,7 +372,7 @@ export class Circle extends Curve
this.Update();
}
//对象将自身数据写入到文件.
WriteFile(file: CADFile)
WriteFile(file: CADFiler)
{
super.WriteFile(file);
file.Write(1);

@ -1,5 +1,5 @@
import { Factory } from './CADFactory';
import { CADFile } from './CADFile';
import { CADFiler } from './CADFiler';
import { CADObject } from './CADObject';
import { EraseEntityData } from "./EraseEntityData";
import { HistorycRecord } from './HistorycRecord';
@ -101,7 +101,7 @@ export class CommandHistoryRecord extends CADObject
//对象从文件中读取数据,初始化自身
ReadFile(file: CADFile)
ReadFile(file: CADFiler)
{
let ver = file.Read();
this.commandName = file.Read();
@ -110,26 +110,26 @@ export class CommandHistoryRecord extends CADObject
this.historyCol.clear();
for (let i = 0; i < cout; i++)
{
let id = this.ReadObjectId(file);
let id = file.ReadObjectId();
let length = file.Read();
let recs = [];
this.historyCol.set(id, recs);
for (let j = 0; j < length; j++)
{
let rec = file.ReadObject(this._db);
let rec = file.ReadObject();
recs.push(rec);
}
}
}
//对象将自身数据写入到文件.
WriteFile(file: CADFile)
WriteFile(file: CADFiler)
{
file.Write(1);
file.Write(this.commandName);
file.Write(this.historyCol.size);
for (let [id, recs] of this.historyCol)
{
file.Write(id.Index);
file.WriteObjectId(id);
file.Write(recs.length);
for (let rec of recs)
{

@ -1,42 +1,43 @@
import { Factory } from './CADFactory';
import { CADFile } from './CADFile';
import { CADFiler } from './CADFiler';
import { CADObject } from './CADObject';
import { Database } from './Database';
@Factory
export class CreateObjectData extends CADObject
{
private cadFile: CADFile;
private CADFiler: CADFiler;
constructor(obj?: CADObject)
{
super();
this.cadFile = new CADFile();
this.CADFiler = new CADFiler();
if (obj)
this.cadFile.WriteObject(obj);
this.CADFiler.WriteObject(obj);
}
getObject(db: Database): CADObject
{
this.cadFile.Reset();
let obj = this.cadFile.ReadObject(db);
this.cadFile.Reset();
this.CADFiler.Reset();
this.CADFiler.database = db;
let obj = this.CADFiler.ReadObject();
this.CADFiler.Reset();
return obj;
}
//#region -----------------------------File-----------------------------
//对象应该实现dataIn和DataOut的方法,为了对象的序列化和反序列化
//对象从文件中读取数据,初始化自身
ReadFile(file: CADFile)
ReadFile(file: CADFiler)
{
file.Read();//ver;
let data = file.Read();
this.cadFile.Data = data;
this.CADFiler.Data = data;
}
//对象将自身数据写入到文件.
WriteFile(file: CADFile)
WriteFile(file: CADFiler)
{
file.Write(1);//ver
file.Write(this.cadFile.Data);
file.Write(this.CADFiler.Data);
}
//#endregion -----------------------------File End-----------------------------
}

@ -1,39 +1,40 @@
import { BlockTableRecord } from './BlockTableRecord';
import { Factory } from './CADFactory';
import { CADFile } from './CADFile';
import { CADFiler } from './CADFiler';
import { CADObject } from './CADObject';
import { HistoricManage } from './HistoricManage';
import { MaerialTableRecord } from './MaerialTableRecord';
import { ObjectCollection } from './ObjectCollection';
import { ObjectId } from './ObjectId';
import { DbTexture } from './Texture';
import { IdMaping } from './IdMaping';
import { Vector3 } from 'three';
import { DeepCloneFiler } from './DeepCloneFiler';
import { Entity } from './Entity';
@Factory
export class Database
{
id: ObjectId;
hm: HistoricManage;
//块表记录
blockTableCol: BlockTableRecord[];
BlockTable: BlockTableRecord[];
//模型空间
ModelSpace: BlockTableRecord;
//材质字典...
MaterialDict: MaerialTableRecord;
TextureTableCol: ObjectCollection<DbTexture>;
private idCout = -1;
private idIndex = 1;
private idMap = new Map<number, ObjectId>();
constructor()
{
this.id = ObjectId.Create(this, -100);
this.ModelSpace = new BlockTableRecord();
this.ModelSpace.InitObjectId(this);
this.ModelSpace.SetOwnerDatabase(this);
this.MaterialDict = new MaerialTableRecord();
this.MaterialDict.InitObjectId(this);
this.MaterialDict.SetOwnerDatabase(this);
this.TextureTableCol = new ObjectCollection<DbTexture>();
this.TextureTableCol.InitObjectId(this);
this.TextureTableCol.SetOwnerDatabase(this);
this.hm = new HistoricManage();
this.hm.SetDefaultDb(this);
@ -50,11 +51,13 @@ export class Database
this.hm.historyRecord.length = 0;
}
FileWrite(): CADFile
//#region Serialize
FileWrite(): CADFiler
{
let file = new CADFile();
let file = new CADFiler();
file.Write(1);//ver;
file.Write(this.idCout);
file.Write(this.idIndex);
file.WriteObject(this.ModelSpace);
file.WriteObject(this.MaterialDict);
file.WriteObject(this.TextureTableCol);
@ -62,14 +65,14 @@ export class Database
return file;
}
FileRead(file: CADFile)
FileRead(file: CADFiler)
{
this.Destroy();
let ver = file.Read();
this.idCout = file.Read();
file.ReadObject(this, this.ModelSpace);
file.ReadObject(this, this.MaterialDict);
file.ReadObject(this, this.TextureTableCol);
this.idIndex = file.Read();
file.ReadObject(this.ModelSpace);
file.ReadObject(this.MaterialDict);
file.ReadObject(this.TextureTableCol);
for (let mat of this.MaterialDict.objectCol)
{
@ -79,28 +82,115 @@ export class Database
}
//创建一个id,自动递增它的索引号,并且会自动加入到db的id列表中.
AllocateId(obj: CADObject): ObjectId
//#endregion
//#region Clone
/**
* (objects),(owner).
* @param objects
* @param owner
* @param idMap id
* @param deferXlation ID
* @returns
*/
DeepCloneObjects(
objects: CADObject[],
owner: CADObject,
idMap: IdMaping = new Map(),
clonedObjects: CADObject[] = [],
deferXlation = false
): CADObject[]
{
if (obj.Db.id === this.id)
// if (obj.Db === this)
let f = new DeepCloneFiler();
f.CloneObjects(objects, clonedObjects);
this.CheapClone(f, idMap, owner);
return clonedObjects;
}
CheapClone(f: DeepCloneFiler, idMap: Map<ObjectId, ObjectId>, owner: CADObject)
{
this.idCout++;
let id = ObjectId.Create(this, this.idCout);
id.Object = obj;
return id;
for (let [index, objectId] of f.idMaping)
{
if (objectId.Object)
{
objectId.Index = this.idIndex++;
this.idMap.set(objectId.Index, objectId);
idMap.set(this.GetObjectId(index), objectId);
if (owner instanceof BlockTableRecord)
{
let ent = objectId.Object as Entity;
ent.SetDefaultDb(this);
owner.Append(ent, false);
}
}
}
else
console.warn("警告:对象不属于该数据库!");
}
/*
private , ObjectId使.
id, id, , 使 ObjectId.Create,,使,AllocateId
/**
* .
* @param objects
* @param owner
* @param idMap id
* @param cloning DuplicateRecordCloning
* @param deferXlation ID
*/
GetObjectId(index: number): ObjectId
WblockCloneObejcts(
objects: CADObject[],
owner: CADObject,
idMap: IdMaping,
cloning: any,
deferXlation = false
)
{
return this.idMap.get(index);
}
Insert()
{
}
/**
*
* @param outputDataBase
* @param objects
* @param basePoint
* @param cloning
*/
Wblock(
outputDataBase: Database,
objects: CADObject[],
basePoint: Vector3,
cloning: any
)
{
}
//#endregion
//#region IdManager
//创建一个id,自动递增它的索引号,并且会自动加入到db的id列表中.
AllocateId(): ObjectId
{
return this.GetObjectId(this.idIndex++, true);
}
GetObjectId(index: number, create = false): ObjectId
{
//id 从1开始,0被保留作为空id
if (index === 0) return undefined;
let id = this.idMap.get(index);
if (!create || id) return id;
id = new ObjectId(index);
this.idMap.set(index, id);
return id;
}
@ -115,4 +205,7 @@ export class Database
console.warn("警告:尝试加入已经存在的id!");
this.idMap.set(index, id);
}
//#endregion
}

@ -0,0 +1,19 @@
import { CADFiler } from "./CADFiler";
import { ObjectId } from "./ObjectId";
export class DeepCloneFiler extends CADFiler
{
idMaping = new Map<number, ObjectId>();
ReadObjectId()
{
let index = this.Read();
if (index <= 0) return;
let id = this.idMaping.get(index);
if (id) return id;
id = new ObjectId();
this.idMaping.set(index, id);
return id;
}
}

@ -8,7 +8,7 @@ import { RenderType } from "../../GraphicsSystem/RenderType";
import { IntersectOption } from "../../GraphicsSystem/IntersectWith";
import { Arc } from "../Arc";
import { Factory } from "../CADFactory";
import { CADFile } from "../CADFile";
import { CADFiler } from "../CADFiler";
import { Entity } from "../Entity";
import { Line } from "../Line";
import { Text, TextAligen } from "../Text/Text";
@ -290,7 +290,7 @@ export class LineAngularDimension extends Entity
//对象应该实现dataIn和DataOut的方法,为了对象的序列化和反序列化
//对象从文件中读取数据,初始化自身
ReadFile(file: CADFile)
ReadFile(file: CADFiler)
{
super.ReadFile(file);
let ver = file.Read();
@ -302,7 +302,7 @@ export class LineAngularDimension extends Entity
this.Update();
}
//对象将自身数据写入到文件.
WriteFile(file: CADFile)
WriteFile(file: CADFiler)
{
super.WriteFile(file);
file.Write(1);

@ -6,7 +6,7 @@ import { BufferGeometryUtils } from "../../Geometry/BufferGeometryUtils";
import { angle, angleAndX, midPoint } from "../../Geometry/GeUtils";
import { RenderType } from "../../GraphicsSystem/RenderType";
import { Factory } from "../CADFactory";
import { CADFile } from "../CADFile";
import { CADFiler } from "../CADFiler";
import { Entity } from "../Entity";
import { Line } from "../Line";
import { Polyline } from "../Polyline";
@ -260,7 +260,7 @@ export class AlignedDimension extends Entity
//对象应该实现dataIn和DataOut的方法,为了对象的序列化和反序列化
//对象从文件中读取数据,初始化自身
ReadFile(file: CADFile)
ReadFile(file: CADFiler)
{
super.ReadFile(file);
let ver = file.Read();
@ -271,7 +271,7 @@ export class AlignedDimension extends Entity
this.Update();
}
//对象将自身数据写入到文件.
WriteFile(file: CADFile)
WriteFile(file: CADFiler)
{
super.WriteFile(file);
file.Write(1);

@ -4,7 +4,7 @@ import { ColorMaterial } from '../Common/ColorPalette';
import { MoveMatrix, rotatePoint } from '../Geometry/GeUtils';
import { RenderType } from '../GraphicsSystem/RenderType';
import { Factory } from './CADFactory';
import { CADFile } from './CADFile';
import { CADFiler } from './CADFiler';
import { Curve } from './Curve';
@Factory
@ -138,7 +138,7 @@ export class Ellipse extends Curve
this.Center = p;
}
}
ReadFile(file: CADFile)
ReadFile(file: CADFiler)
{
super.ReadFile(file);
let ver = file.Read();
@ -147,7 +147,7 @@ export class Ellipse extends Curve
this.Angle = file.Read();
}
//对象将自身数据写入到文件.
WriteFile(file: CADFile)
WriteFile(file: CADFiler)
{
super.WriteFile(file);
file.Write(1);

@ -5,7 +5,7 @@ import { equaln, equalv3 } from '../Geometry/GeUtils';
import { RenderType } from '../GraphicsSystem/RenderType';
import { IntersectOption } from '../GraphicsSystem/IntersectWith';
import { Factory } from './CADFactory';
import { CADFile } from './CADFile';
import { CADFiler } from './CADFiler';
import { CADObject } from './CADObject';
import { ObjectId } from './ObjectId';
import { ObjectSnapMode } from '../Editor/ObjectSnapMode';
@ -259,6 +259,8 @@ export class Entity extends CADObject
}
Erase(isErase: boolean = true)
{
if (isErase === this._isErase)
return;
super.Erase(isErase);
this.UpdateVisible();
this.EraseEvent(isErase);
@ -375,21 +377,21 @@ export class Entity extends CADObject
}
//对象从文件中读取数据,初始化自身
ReadFile(file: CADFile)
ReadFile(file: CADFiler)
{
let ver = file.Read();
super.ReadFile(file);
this.m_Color = file.Read();
this.m_MaterialId = this.ReadObjectId(file);
this.m_MaterialId = file.ReadObjectId();
this.m_Matrix.fromArray(file.Read());
}
//对象将自身数据写入到文件.
WriteFile(file: CADFile)
WriteFile(file: CADFiler)
{
file.Write(1);
super.WriteFile(file);
file.Write(this.m_Color);
this.WriteObjectId(file, this.m_MaterialId);
file.WriteObjectId(this.m_MaterialId);
file.Write(this.m_Matrix.toArray());
}
//局部撤销

@ -1,15 +1,15 @@
import { Factory } from './CADFactory';
import { CADFile } from './CADFile';
import { CADFiler } from './CADFiler';
import { ISerialize } from './ISerialize';
@Factory
export class EraseEntityData implements ISerialize
{
ReadFile(file: CADFile): this
ReadFile(file: CADFiler): this
{
this.isErase = file.Read();
return this;
}
WriteFile(file: CADFile): this
WriteFile(file: CADFiler): this
{
file.Write(this.isErase);
return this;

@ -1,6 +1,6 @@
import { CommandState } from '../Editor/CommandState';
import { Factory } from './CADFactory';
import { CADFile } from './CADFile';
import { CADFiler } from './CADFiler';
import { CADObject } from './CADObject';
import { CommandHistoryRecord } from './CommandHistoryRecord';
@ -30,7 +30,7 @@ export class HistoricManage extends CADObject
}
//对象从文件中读取数据,初始化自身
ReadFile(file: CADFile)
ReadFile(file: CADFiler)
{
let ver = file.Read();
this.curIndex = file.Read();
@ -38,11 +38,11 @@ export class HistoricManage extends CADObject
this.historyRecord = [];
for (let i = 0; i < cout; i++)
{
this.historyRecord.push(file.ReadObject(this._db) as CommandHistoryRecord);
this.historyRecord.push(file.ReadObject() as CommandHistoryRecord);
}
}
//对象将自身数据写入到文件.
WriteFile(file: CADFile)
WriteFile(file: CADFiler)
{
file.Write(1);
file.Write(this.curIndex);

@ -1,5 +1,5 @@
import { Factory } from './CADFactory';
import { CADFile } from './CADFile';
import { CADFiler } from './CADFiler';
import { CADObject } from './CADObject';
import { ISerialize } from './ISerialize';
@ -22,7 +22,7 @@ export class HistorycRecord extends CADObject
//对象应该实现dataIn和DataOut的方法,为了对象的序列化和反序列化
//对象从文件中读取数据,初始化自身
ReadFile(file: CADFile)
ReadFile(file: CADFiler)
{
let ver = file.Read();
this.undoData = file.ReadObject();
@ -30,7 +30,7 @@ export class HistorycRecord extends CADObject
this.userData = file.ReadObject();
}
//对象将自身数据写入到文件.
WriteFile(file: CADFile)
WriteFile(file: CADFiler)
{
file.Write(1);
file.WriteObject(this.undoData);

@ -1,7 +1,7 @@
import { CADFile } from "./CADFile";
import { CADFiler } from "./CADFiler";
export interface ISerialize
{
ReadFile(file: CADFile);
WriteFile(file: CADFile);
ReadFile(file: CADFiler);
WriteFile(file: CADFiler);
}

@ -0,0 +1,3 @@
import { ObjectId } from "./ObjectId";
export type IdMaping = Map<ObjectId, ObjectId>;

@ -4,7 +4,7 @@ import { UpdateDraw } from "../../Common/Status";
import { equalv3 } from "../../Geometry/GeUtils";
import { RenderType } from "../../GraphicsSystem/RenderType";
import { Factory } from "../CADFactory";
import { CADFile } from "../CADFile";
import { CADFiler } from "../CADFiler";
import { Light } from "./Light";
/**
@ -93,14 +93,14 @@ export class DirectionalLight extends Light
}
}
ReadFile(file: CADFile)
ReadFile(file: CADFiler)
{
super.ReadFile(file);
let ver = file.Read();
this.m_Target.fromArray(file.Read());
this.Update();
}
WriteFile(file: CADFile)
WriteFile(file: CADFiler)
{
super.WriteFile(file);
file.Write(1);//ver

@ -3,7 +3,7 @@ import { Object3D } from "three";
import { Factory } from "../CADFactory";
import { Light } from "./Light";
import { RenderType } from "../../GraphicsSystem/RenderType";
import { CADFile } from "../CADFile";
import { CADFiler } from "../CADFiler";
@Factory
export class HemisphereLight extends Light
@ -32,7 +32,7 @@ export class HemisphereLight extends Light
let lg = en as THREE.HemisphereLight;
lg.groundColor = this.m_GroundColor;
}
ReadFile(file: CADFile)
ReadFile(file: CADFiler)
{
super.ReadFile(file);
let ver = file.Read();
@ -40,7 +40,7 @@ export class HemisphereLight extends Light
this.Update();
}
//对象将自身数据写入到文件.
WriteFile(file: CADFile)
WriteFile(file: CADFiler)
{
super.WriteFile(file);
file.Write(1);//ver

@ -1,7 +1,7 @@
import * as THREE from 'three';
import { Color, Vector3, Object3D } from 'three';
import { Factory } from '../CADFactory';
import { CADFile } from '../CADFile';
import { CADFiler } from '../CADFiler';
import { Entity } from '../Entity';
import { ObjectSnapMode } from '../../Editor/ObjectSnapMode';
import { MoveMatrix } from '../../Geometry/GeUtils';
@ -96,7 +96,7 @@ export class Light extends Entity
this.m_Intensity = v;
this.Update();
}
ReadFile(file: CADFile)
ReadFile(file: CADFiler)
{
super.ReadFile(file);
let ver = file.Read();
@ -106,7 +106,7 @@ export class Light extends Entity
this.Update();
}
//对象将自身数据写入到文件.
WriteFile(file: CADFile)
WriteFile(file: CADFiler)
{
super.WriteFile(file);
file.Write(1);

@ -1,7 +1,7 @@
import * as THREE from 'three';
import { Mesh, Object3D } from 'three';
import { Factory } from '../CADFactory';
import { CADFile } from '../CADFile';
import { CADFiler } from '../CADFiler';
import { Light } from './Light';
import { RenderType } from '../../GraphicsSystem/RenderType';
@ -71,7 +71,7 @@ export class PointLight extends Light
}
ReadFile(file: CADFile)
ReadFile(file: CADFiler)
{
super.ReadFile(file);
let ver = file.Read();
@ -79,7 +79,7 @@ export class PointLight extends Light
this.m_Decay = file.Read();
this.Update();
}
WriteFile(file: CADFile)
WriteFile(file: CADFiler)
{
super.WriteFile(file);
file.Write(1);

@ -3,7 +3,7 @@ import { Object3D, Vector3, Matrix4, RectAreaLightHelper } from "three";
import { Factory } from "../CADFactory";
import { Light } from "./Light";
import { RenderType } from "../../GraphicsSystem/RenderType";
import { CADFile } from "../CADFile";
import { CADFiler } from "../CADFiler";
import { UpdateDraw } from "../../Common/Status";
@Factory
@ -117,7 +117,7 @@ export class RectAreaLight extends Light
box.updateMatrixWorld(true);
}
}
ReadFile(file: CADFile)
ReadFile(file: CADFiler)
{
super.ReadFile(file);
let ver = file.Read();
@ -127,7 +127,7 @@ export class RectAreaLight extends Light
this.Update();
}
//对象将自身数据写入到文件.
WriteFile(file: CADFile)
WriteFile(file: CADFiler)
{
super.WriteFile(file);
file.Write(1);

@ -6,7 +6,7 @@ import { ObjectSnapMode } from "../../Editor/ObjectSnapMode";
import { BufferGeometryUtils } from "../../Geometry/BufferGeometryUtils";
import { RenderType } from "../../GraphicsSystem/RenderType";
import { Factory } from "../CADFactory";
import { CADFile } from "../CADFile";
import { CADFiler } from "../CADFiler";
import { Light } from "./Light";
import { equalv3 } from "../../Geometry/GeUtils";
/**
@ -201,7 +201,7 @@ export class SpotLight extends Light
helper.cone.lookAt(light.target.position);
}
}
ReadFile(file: CADFile)
ReadFile(file: CADFiler)
{
super.ReadFile(file);
let ver = file.Read();
@ -212,7 +212,7 @@ export class SpotLight extends Light
this.m_Target.fromArray(file.Read());
this.Update();
}
WriteFile(file: CADFile)
WriteFile(file: CADFiler)
{
super.WriteFile(file);
file.Write(1);

@ -12,7 +12,7 @@ import { RenderType } from '../GraphicsSystem/RenderType';
import { IntersectLineAndArc, IntersectLineAndCircle, IntersectLineAndLine, IntersectOption, IntersectPolylineAndCurve, reverseIntersectOption } from '../GraphicsSystem/IntersectWith';
import { Arc } from './Arc';
import { Factory } from './CADFactory';
import { CADFile } from './CADFile';
import { CADFiler } from './CADFiler';
import { Circle } from './Circle';
import { Curve } from './Curve';
import { Polyline } from './Polyline';
@ -346,7 +346,7 @@ export class Line extends Curve
//对象应该实现dataIn和DataOut的方法,为了对象的序列化和反序列化
//对象从文件中读取数据,初始化自身
ReadFile(file: CADFile)
ReadFile(file: CADFiler)
{
super.ReadFile(file);
let ver = file.Read();//1
@ -355,7 +355,7 @@ export class Line extends Curve
this.Update();
}
//对象将自身数据写入到文件.
WriteFile(file: CADFile)
WriteFile(file: CADFiler)
{
super.WriteFile(file);
file.Write(1);//ver

@ -1,6 +1,6 @@
import { Factory } from './CADFactory';
import { CADObject } from './CADObject';
import { CADFile } from './CADFile';
import { CADFiler } from './CADFiler';
@Factory
export class Material extends CADObject
@ -14,13 +14,13 @@ export class Material extends CADObject
//对象应该实现dataIn和DataOut的方法,为了对象的序列化和反序列化
//对象从文件中读取数据,初始化自身
ReadFile(file: CADFile)
ReadFile(file: CADFiler)
{
super.ReadFile(file);
let ver = file.Read();
}
//对象将自身数据写入到文件.
WriteFile(file: CADFile)
WriteFile(file: CADFiler)
{
super.WriteFile(file);
file.Write(1);

@ -1,5 +1,5 @@
import { Factory } from './CADFactory';
import { CADFile } from './CADFile';
import { CADFiler } from './CADFiler';
import { CADObject } from './CADObject';
import { AllObjectData } from "./AllObjectData";
import { HistorycRecord } from './HistorycRecord';
@ -28,18 +28,18 @@ export class ObjectAllDataHistoryRecord extends HistorycRecord
//#region -------------------------File-------------------------
//对象从文件中读取数据,初始化自身
ReadFile(file: CADFile)
ReadFile(file: CADFiler)
{
let ver = file.Read();
super.ReadFile(file);
this.objId = this.ReadObjectId(file);
this.objId = file.ReadObjectId();
}
//对象将自身数据写入到文件.
WriteFile(file: CADFile)
WriteFile(file: CADFiler)
{
file.Write(1);
super.WriteFile(file);
this.WriteObjectId(file, this.objId);
file.WriteObjectId(this.objId);
}
//局部撤销
ApplyPartialUndo(undoData: CADObject)

@ -1,6 +1,6 @@
import { HistorycRecord } from './HistorycRecord';
import { Factory } from './CADFactory';
import { CADFile } from './CADFile';
import { CADFiler } from './CADFiler';
import { RemoveObjectData } from './RemoveObjectData';
import { CADObject } from './CADObject';
import { CreateObjectData } from './CreateObjectData';
@ -14,16 +14,16 @@ export class ObjectCollection<T extends CADObject> extends CADObject
objectCol: T[] = [];
//添加一个对象进入集合,这个集合存在db中,那么将自动分配id.
Append(obj: T)
Append(obj: T, check = true)
{
if (obj.Id)
if (check && obj.Id)
{
console.warn("同一个对象不能重复加入图纸!");
return;
}
if (this._db && !obj.Id)
{
obj.InitObjectId(this._db);
obj.SetOwnerDatabase(this._db);
}
this.objectCol.push(obj);
this.AppendEvent(obj);
@ -73,7 +73,7 @@ export class ObjectCollection<T extends CADObject> extends CADObject
//对象应该实现dataIn和DataOut的方法,为了对象的序列化和反序列化
//对象从文件中读取数据,初始化自身
ReadFile(file: CADFile)
ReadFile(file: CADFiler)
{
this.Destroy();
super.ReadFile(file);
@ -81,12 +81,12 @@ export class ObjectCollection<T extends CADObject> extends CADObject
this.objectCol = [];
for (let i = 0; i < cout; i++)
{
let obj = file.ReadObject(this._db) as T;
let obj = file.ReadObject() as T;
this.objectCol.push(obj);
}
}
//对象将自身数据写入到文件.
WriteFile(file: CADFile)
WriteFile(file: CADFiler)
{
super.WriteFile(file);
file.Write(this.objectCol.length);

@ -14,7 +14,7 @@ export class ObjectId
private obj: CADObject;
//对外隐藏构造函数,如果需要构造一个id,请使用 Create 静态方法.
private constructor(index: number = -1, obj?: CADObject)
constructor(index: number = 0, obj?: CADObject)
{
this.id = index;
this.obj = obj;
@ -55,5 +55,9 @@ export class ObjectId
{
return this.id;
}
set Index(index: number)
{
this.id = index;
}
}

@ -3,7 +3,7 @@ import * as THREE from 'three';
import * as xaop from 'xaop';
import { Factory } from './CADFactory';
import { CADFile } from './CADFile';
import { CADFiler } from './CADFiler';
import { Material } from './Material';
import { ObjectId } from './ObjectId';
import { DbTexture } from './Texture';
@ -92,7 +92,7 @@ export class DbPhysicalMaterial extends Material
//对象从文件中读取数据,初始化自身
@action
ReadFile(file: CADFile)
ReadFile(file: CADFiler)
{
super.ReadFile(file);
let ver = file.Read();
@ -103,14 +103,14 @@ export class DbPhysicalMaterial extends Material
this.matalness = file.Read();
this.opacity = file.Read();
this.depthTest = file.Read();
this.map = this.ReadObjectId(file);
this.bumpMap = this.ReadObjectId(file);
this.map = file.ReadObjectId();
this.bumpMap = file.ReadObjectId();
this.bumpScale = file.Read();
this.roughnessMap = this.ReadObjectId(file);
this.roughnessMap = file.ReadObjectId();
this.roughness = file.Read();
}
//对象将自身数据写入到文件.
WriteFile(file: CADFile)
WriteFile(file: CADFiler)
{
super.WriteFile(file);
file.Write(1);
@ -121,10 +121,10 @@ export class DbPhysicalMaterial extends Material
file.Write(this.matalness);
file.Write(this.opacity);
file.Write(this.depthTest);
this.WriteObjectId(file, this.map);
this.WriteObjectId(file, this.bumpMap);
file.WriteObjectId(this.map);
file.WriteObjectId(this.bumpMap);
file.Write(this.bumpScale);
this.WriteObjectId(file, this.roughnessMap);
file.WriteObjectId(this.roughnessMap);
file.Write(this.roughness);
}
//#endregion

@ -15,7 +15,7 @@ import { IntersectOption, IntersectPolylineAndCurve } from '../GraphicsSystem/In
import { PolyOffsetUtil } from '../GraphicsSystem/OffsetPolyline';
import { Arc } from './Arc';
import { Factory } from './CADFactory';
import { CADFile } from './CADFile';
import { CADFiler } from './CADFiler';
import { Curve, ExtendType } from './Curve';
import { Line } from './Line';
import { IsPointInPolyLine } from './PointInPolyline';
@ -678,7 +678,7 @@ export class Polyline extends Curve
}
else if (cu instanceof Polyline)
{
let f = new CADFile();
let f = new CADFiler();
cu.WriteFile(f);
this.ReadFile(f);
}
@ -1278,7 +1278,7 @@ export class Polyline extends Curve
}
this.Update();
}
ReadFile(file: CADFile)
ReadFile(file: CADFiler)
{
super.ReadFile(file);
let ver = file.Read();
@ -1296,7 +1296,7 @@ export class Polyline extends Curve
this.Update();
}
//对象将自身数据写入到文件.
WriteFile(file: CADFile)
WriteFile(file: CADFiler)
{
super.WriteFile(file);
file.Write(2);

@ -6,7 +6,7 @@ import { BoolOpeartionType } from '../GraphicsSystem/BoolOperateUtils';
import { RenderType } from '../GraphicsSystem/RenderType';
import { Arc } from './Arc';
import { Factory } from './CADFactory';
import { CADFile } from './CADFile';
import { CADFiler } from './CADFiler';
import { Circle } from './Circle';
import { Contour } from './Contour';
import { Curve } from './Curve';
@ -193,7 +193,7 @@ export class Region extends Entity
regionGroup.add(mesh);
})
}
ReadFile(file: CADFile)
ReadFile(file: CADFiler)
{
super.ReadFile(file);
let ver = file.Read();//1
@ -201,7 +201,7 @@ export class Region extends Entity
this.m_ShapeManager.ReadFile(file);
this.Update();
}
WriteFile(file: CADFile)
WriteFile(file: CADFiler)
{
super.WriteFile(file);
file.Write(1);//ver

@ -1,5 +1,5 @@
import { Factory } from './CADFactory';
import { CADFile } from './CADFile';
import { CADFiler } from './CADFiler';
import { CADObject } from './CADObject';
@Factory
@ -20,13 +20,13 @@ export class RemoveObjectData extends CADObject
//对象应该实现dataIn和DataOut的方法,为了对象的序列化和反序列化
//对象从文件中读取数据,初始化自身
ReadFile(file: CADFile)
ReadFile(file: CADFiler)
{
file.Read();//ver
this.index = file.Read();
}
//对象将自身数据写入到文件.
WriteFile(file: CADFile)
WriteFile(file: CADFiler)
{
file.Write(1);
file.Write(this.index);

@ -1,6 +1,6 @@
import * as THREE from 'three';
import { arrayRemoveIf } from '../Common/ArrayExt';
import { CADFile } from './CADFile';
import { CADFiler } from './CADFiler';
import { Contour } from './Contour';
import { Curve } from './Curve';
import { Polyline } from './Polyline';
@ -422,7 +422,7 @@ export class Shape
));
}
//读写文件
ReadFile(file: CADFile)
ReadFile(file: CADFiler)
{
let ver = file.Read();//1
this.m_Outline = Contour.CreateContour([file.ReadObject() as Curve])
@ -437,7 +437,7 @@ export class Shape
}
//对象将自身数据写入到文件.
WriteFile(file: CADFile)
WriteFile(file: CADFiler)
{
file.Write(1);//ver
file.WriteObject(this.m_Outline.Curve);

@ -1,5 +1,5 @@
import { BoolOpeartionType } from '../GraphicsSystem/BoolOperateUtils';
import { CADFile } from './CADFile';
import { CADFiler } from './CADFiler';
import { Shape } from './Shape';
import { Matrix4 } from 'three';
@ -126,7 +126,7 @@ export class ShapeManager
}
}
ReadFile(file: CADFile)
ReadFile(file: CADFiler)
{
let ver = file.Read();//1
let cout = file.Read();
@ -137,7 +137,7 @@ export class ShapeManager
this.m_ShapeList.push(obj);
}
}
WriteFile(file: CADFile)
WriteFile(file: CADFiler)
{
file.Write(1);//ver
file.Write(this.ShapeList.length);

@ -5,7 +5,7 @@ import { BufferGeometryUtils } from '../Geometry/BufferGeometryUtils';
import { equalv3 } from '../Geometry/GeUtils';
import { RenderType } from '../GraphicsSystem/RenderType';
import { Factory } from './CADFactory';
import { CADFile } from './CADFile';
import { CADFiler } from './CADFiler';
import { Curve } from './Curve';
@Factory
@ -107,7 +107,7 @@ export class Spline extends Curve
spl.geometry = BufferGeometryUtils.CreateFromPts(pts);
}
}
ReadFile(file: CADFile)
ReadFile(file: CADFiler)
{
super.ReadFile(file);
let ver = file.Read();//1
@ -118,7 +118,7 @@ export class Spline extends Curve
this.m_PointList.push(new Vector3().fromArray(file.Read()));
}
}
WriteFile(file: CADFile)
WriteFile(file: CADFiler)
{
super.WriteFile(file);
file.Write(1);//ver

@ -5,7 +5,7 @@ import { setRotationOnAxis } from '../../Common/Matrix4Utils';
import { MoveMatrix } from '../../Geometry/GeUtils';
import { RenderType } from '../../GraphicsSystem/RenderType';
import { Factory } from '../CADFactory';
import { CADFile } from '../CADFile';
import { CADFiler } from '../CADFiler';
import { Entity } from '../Entity';
import { FontLoader } from './FontLoader';
@ -178,7 +178,7 @@ export class Text extends Entity
//对象应该实现dataIn和DataOut的方法,为了对象的序列化和反序列化
//对象从文件中读取数据,初始化自身
ReadFile(file: CADFile)
ReadFile(file: CADFiler)
{
super.ReadFile(file);
let ver = file.Read();//1
@ -189,7 +189,7 @@ export class Text extends Entity
this.m_Align = file.Read();
}
//对象将自身数据写入到文件.
WriteFile(file: CADFile)
WriteFile(file: CADFiler)
{
super.WriteFile(file);
file.Write(1);//ver

@ -3,7 +3,7 @@ import * as THREE from 'three';
import { LoadImageFromMd5 } from '../Loader/ImageLoader';
import { Factory } from './CADFactory';
import { CADFile } from './CADFile';
import { CADFiler } from './CADFiler';
import { CADObject } from './CADObject';
/**
@ -62,7 +62,7 @@ export class DbTexture extends CADObject
//对象从文件中读取数据,初始化自身.
@action
ReadFile(file: CADFile)
ReadFile(file: CADFiler)
{
super.ReadFile(file);
let ver = file.Read();
@ -76,7 +76,7 @@ export class DbTexture extends CADObject
this.imageMd5 = file.Read();
}
//对象将自身数据写入到文件.
WriteFile(file: CADFile)
WriteFile(file: CADFiler)
{
super.WriteFile(file);
file.Write(1);

@ -93,12 +93,16 @@ import { commandMachine } from './CommandMachine';
import { DrawTopline } from '../Add-on/DrawTopline';
import { ViewChange } from '../Add-on/ViewChange';
import { Vector3 } from 'three';
import { Command_Wblock } from '../Add-on/Wblock';
import { Command_Insert } from '../Add-on/Insert';
export function registerCommand()
{
commandMachine.RegisterCommand("b", new DrawBox())
commandMachine.RegisterCommand("insert", new Command_Insert())
commandMachine.RegisterCommand("l", new DrawLine())
commandMachine.RegisterCommand("u", new Undo())
commandMachine.RegisterCommand("redo", new Redo())
@ -166,6 +170,7 @@ export function registerCommand()
commandMachine.RegisterCommand("reg2", new DrawRegTest());
commandMachine.RegisterCommand("copy", new Command_Copy());
commandMachine.RegisterCommand("Wblock", new Command_Wblock());
commandMachine.RegisterCommand("lisp", new Command_Lisp());

@ -1,16 +1,13 @@
import { app } from "../ApplicationServices/Application";
import { Entity } from "../DatabaseServices/Entity";
import { RenderType } from "../GraphicsSystem/RenderType";
import { CADFile } from "../DatabaseServices/CADFile";
import { CADFiler } from "../DatabaseServices/CADFiler";
export class Jig
{
//临时图形,如果需要,将被销毁.
private m_JigEnts: Entity[] = [];
//图纸数据缓存,用于还原
private m_EntityCacheData: {
Ent: Entity;
File: CADFile;
}[] = [];
EntityCacheData: { Ent: Entity; File: CADFiler; }[] = [];
private m_OrgEntitys: Entity[] = [];
End()
{
@ -24,7 +21,7 @@ export class Jig
RestoreOriginEntity()
{
this.m_OrgEntitys.forEach(e => e.RestoreJigMaterial());
this.m_EntityCacheData.length = 0;
this.EntityCacheData.length = 0;
}
/**
* .
@ -40,9 +37,9 @@ export class Jig
enNew = enOrg.Clone();
this.m_OrgEntitys.push(enOrg);
enOrg.UpdateJigMaterial();
let f = new CADFile();
let f = new CADFiler();
enNew.WriteFile(f);
this.m_EntityCacheData.push({ Ent: enNew, File: f });
this.EntityCacheData.push({ Ent: enNew, File: f });
}
else
enNew = enOrg;
@ -57,7 +54,7 @@ export class Jig
*/
Restore()
{
this.m_EntityCacheData.forEach((v) =>
this.EntityCacheData.forEach((v) =>
{
v.File.Reset();
v.Ent.ReadFile(v.File);

@ -23,6 +23,11 @@ export class JigUtils
jig.End();
}
static get Jig()
{
return jig;
}
/**
*
*

@ -1,5 +1,5 @@
import { Box3, Camera, Math as TMath, OrthographicCamera, PerspectiveCamera, Vector3 } from 'three';
import { CADFile } from '../DatabaseServices/CADFile';
import { CADFiler } from '../DatabaseServices/CADFiler';
import { Orbit } from '../Geometry/Orbit';
const ViewScopeSize = 4e4;
@ -243,7 +243,7 @@ export class CameraUpdate
//#region -------------------------File-------------------------
//对象应该实现dataIn和DataOut的方法,为了对象的序列化和反序列化
//对象从文件中读取数据,初始化自身
ReadFile(file: CADFile)
ReadFile(file: CADFiler)
{
let ver = file.Read();
this.m_ViewHeight = file.Read();
@ -254,7 +254,7 @@ export class CameraUpdate
this.Update();
}
//对象将自身数据写入到文件.
WriteFile(file: CADFile)
WriteFile(file: CADFiler)
{
file.Write(1);
file.Write(this.m_ViewHeight);

@ -0,0 +1,82 @@
import { Classes, Icon, Button } from "@blueprintjs/core";
import React = require("react");
import { FileInfo } from "../../../DatabaseServices/FileServer";
import { app } from "../../../ApplicationServices/Application";
export class InsertModal extends React.Component<{ files: FileInfo[], res: any }, {}>
{
rootStyle: React.CSSProperties = {
width: 520
}
render()
{
return (
<div id="InsertModal" className={Classes.DIALOG_CONTAINER} style={this.rootStyle}>
<div className={Classes.DIALOG}>
<div className={Classes.DIALOG_HEADER} data-id="dragArea">
<Icon icon="search-around" iconSize={18} />
<h4 className={Classes.HEADING}></h4>
<Button
icon="cross"
aria-label="Close"
minimal={true}
/>
</div>
<div
className={Classes.DIALOG_BODY}
style={{
overflowX: "hidden",
overflowY: "auto",
color: "white",
display: "flex",
flexDirection: "row",
flexWrap: "wrap",
alignContent: "flex-start",
width: "100%",
height: "100%"
}}
>
{this.props.files.map(f =>
{
return <img src={f.pic}
style={{
width: "75px",
height: "75px",
display: "flex",
flexDirection: "column",
float: "left",
margin: 5,
justifyContent: "space-between",
alignItems: "center"
}}
onClick={e =>
{
this.props.res(f);
app.m_Editor.m_ModalManage.m_PromisRes(1);
app.m_Editor.m_ModalManage.Clear();
}}
/>;
})}
</div>
<div className={Classes.DIALOG_FOOTER}>
<div className={Classes.DIALOG_FOOTER_ACTIONS}>
<Button
className="LeftRightBtn"
intent="success"
text="确定"
/>
<Button
className="LeftRightBtn"
intent="danger"
text="取消"
/>
</div>
</div>
</div>
</div>
)
}
}

@ -4,7 +4,7 @@ import * as React from 'react';
import { app } from '../../../ApplicationServices/Application';
import { FileSystem } from '../../../Common/FileSystem';
import { Singleton } from '../../../Common/Singleton';
import { CADFile } from '../../../DatabaseServices/CADFile';
import { CADFiler } from '../../../DatabaseServices/CADFiler';
import { FileServer } from '../../../DatabaseServices/FileServer';
import { TopPanelStore } from '../../Store/TopPanelStore';
import { FileItem } from './FileItem';
@ -71,7 +71,7 @@ export class FilePanel extends React.Component<{ store?: TopPanelStore }, {}>
{
if (fserver.m_CurFileId !== fid)
{
app.OpenFile(new CADFile(await fserver.ReadFile(fid)));
app.OpenFile(new CADFiler(await fserver.ReadFile(fid)));
fserver.m_CurFileId = fid;
fserver.SetLastOpenId(fid);

@ -34,7 +34,8 @@ window.onload = function ()
async function loadFirst()
{
let cmd = (await import("./Add-on/testEntity/test")).Test;
commandMachine.RegisterCommand("tt", new cmd());
let c = new cmd();
commandMachine.RegisterCommand("tt", c);
}
loadFirst(); // 必须先加载一次,否则无法触发热模块替换

Loading…
Cancel
Save