更新测试用例

pull/219/MERGE
ChenX 6 years ago
parent d4fdafcf40
commit 190e642c16

@ -1,11 +1,11 @@
import * as THREE from 'three';
import { Vector3 } from 'three';
import { Arc } from '../../src/DatabaseServices/Arc';
import { CADFiler } from '../../src/DatabaseServices/CADFiler';
import { Circle } from '../../src/DatabaseServices/Circle';
import { Curve } from '../../src/DatabaseServices/Curve';
import { Line } from '../../src/DatabaseServices/Line';
import { IntersectCircleAndCircle, IntersectLine3AndLine3, IntersectOption } from '../../src/GraphicsSystem/IntersectWith';
import { LoadCurvesFromFileData, LoadEntityFromFileData } from '../Utils/LoadEntity.util';
test('相交测试', () =>
{
@ -84,49 +84,45 @@ test('三维空间圆圆相交测试', () =>
})
test('三维空间直线和圆相交测试', () =>
{
let data = [["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], ["Line", 1, 1, 12, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 1, [2.4219301113484804, 0, 6.278428496635537], [9.19486541121855, 0, -0.38347507700715716]]]
let data =
[2, "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, "Line", 1, 1, 0, false, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 1, [2.4219301113484804, 0, 6.278428496635537], [9.19486541121855, 0, -0.38347507700715716]]
testLineAndCirIntersect(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], ["Line", 1, 1, 13, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 1, [-3.6226270297054635, 5.273119429622456, 0], [-3.6226270297054652, -5.297100907223948, 0]]];
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, "Line", 1, 1, 0, false, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 1, [-3.6226270297054635, 5.273119429622456, 0], [-3.6226270297054652, -5.297100907223948, 0]]
testLineAndCirIntersect(data);
data = [["Circle", 1, 1, 3, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 13.418897659897576, -9.71681408534522, 4.841809080303142, 1], 1, 5], ["Line", 1, 1, 13, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 1, [9.796270630192113, -4.443694655722764, 4.841809080303142], [9.796270630192112, -15.013914992569168, 4.841809080303142]]];
data =
[2, "Circle", 1, 1, 0, false, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 13.418897659897576, -9.71681408534522, 4.841809080303142, 1], 1, 5, "Line", 1, 1, 0, false, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 1, [9.796270630192113, -4.443694655722764, 4.841809080303142], [9.796270630192112, -15.013914992569168, 4.841809080303142]]
testLineAndCirIntersect(data);
data = [["Circle", 1, 1, 3, false, 7, -1, [0.8517840265050032, 0, -0.5238930923298417, 0, 0, 1, 0, 0, 0.5238930923298417, 0, 0.8517840265050032, 0, 15.469956975945145, -9.71681408534522, 4.4481472148971575, 1], 1, 5], ["Line", 1, 1, 13, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 1, [12.384261138056765, -4.443694655722764, 6.346016491847221], [12.384261138056765, -15.013914992569168, 6.346016491847222]]];
data =
[2, "Circle", 1, 1, 0, false, 7, 0, [0.8517840265050032, 0, -0.5238930923298417, 0, 0, 1, 0, 0, 0.5238930923298417, 0, 0.8517840265050032, 0, 15.469956975945145, -9.71681408534522, 4.4481472148971575, 1], 1, 5, "Line", 1, 1, 0, false, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 1, [12.384261138056765, -4.443694655722764, 6.346016491847221], [12.384261138056765, -15.013914992569168, 6.346016491847222]]
testLineAndCirIntersect(data);
})
test('补充相交测试', () =>
{
let data = [["Line", 1, 1, 2308, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 1.3934337707580937, 0.039495588796686576, 0, 1], 1, [12.270990240675426, 8.520323796959827, 0], [12.270990240675426, 4.4951100391838885, 0]], ["Arc", 1, 1, 2313, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 13.662687223232803, 4.584664645783669, 0, 1], 2, 0.003163048700428762, 6.156784789283385, 3.3367334474492862, true]]
let cus = loadFile(data);
let data =
[2, "Line", 1, 1, 0, false, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 1.3934337707580937, 0.039495588796686576, 0, 1], 1, [12.270990240675426, 8.520323796959827, 0], [12.270990240675426, 4.4951100391838885, 0], "Arc", 1, 1, 0, false, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 13.662687223232803, 4.584664645783669, 0, 1], 2, 0.003163048700428762, 6.156784789283385, 3.3367334474492862, true]
let cus = LoadEntityFromFileData(data);
let [cu1, cu2] = cus[0] instanceof Line ? cus : cus.reverse();
let pts = cu1.IntersectWith(cu2, 0);
expect(pts.length).toBe(1);
data = [["Line", 1, 1, 2308, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 1.3934337707580937, 0.039495588796686576, 0, 1], 1, [12.270990240675426, 8.520323796959827, 0], [12.270990240675426, 4.4951100391838885, 0]], ["Circle", 1, 1, 2320, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 13.662687223232803, 4.584664645783669, 0, 1], 1, 0.0031630487004287015]];
cus = loadFile(data);
data =
[2, "Line", 1, 1, 0, false, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 1.3934337707580937, 0.039495588796686576, 0, 1], 1, [12.270990240675426, 8.520323796959827, 0], [12.270990240675426, 4.4951100391838885, 0], "Circle", 1, 1, 0, false, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 13.662687223232803, 4.584664645783669, 0, 1], 1, 0.0031630487004287015]
cus = LoadEntityFromFileData(data);
[cu1, cu2] = cus[0] instanceof Line ? cus : cus.reverse();
pts = cu1.IntersectWith(cu2, 0);
expect(pts.length).toBe(2);
})
function loadFile(data)
{
let file = new CADFiler();
file.Data = data;
let cus: Curve[] = [];
for (let i = 0; i < file.Data.length; i++)
{
cus.push(file.ReadObject(undefined) as Curve);
}
return cus;
}
function testCirAndCirIntersect(data)
{
let cus = loadFile(data) as Array<Circle | Arc>;
let cus = LoadCurvesFromFileData(data) as Array<Circle | Arc>;
let pts = IntersectCircleAndCircle(cus[0], cus[1]);
expect(pts).toMatchSnapshot();
}
function testLineAndCirIntersect(data)
{
let cus = loadFile(data);
let cus = LoadCurvesFromFileData(data);
let [cu1, cu2] = cus[0] instanceof Line ? cus : cus.reverse();
let pts = cu1.IntersectWith(cu2, IntersectOption.ExtendBoth);
expect(pts).toMatchSnapshot();
@ -148,8 +144,7 @@ test('直线和圆相切', () =>
{
let data =
[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 cus = LoadEntityFromFileData(data) as Array<Curve>;
let pts = cus[0].IntersectWith(cus[1], 0);
expect(pts).toMatchSnapshot();
});

@ -3,6 +3,7 @@ import { Vector2, Vector3 } from 'three';
import { IsPointInPolyLine } from '../../src/DatabaseServices/PointInPolyline';
import { Polyline } from '../../src/DatabaseServices/Polyline';
import { CADFiler } from '../../src/DatabaseServices/CADFiler';
import { LoadCurvesFromFileData } from '../Utils/LoadEntity.util';
test('点在多段线内', () =>
@ -148,15 +149,8 @@ describe("", () =>
{
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 CADFiler();
f.Data = plData;
let pl = f.ReadObject(undefined) as Polyline;
let pl = LoadCurvesFromFileData(plData)[0] as Polyline;
let p = new Vector3(-3, -0.16000000000000014, 0);
expect(pl.PtInCurve(p)).toBeFalsy();
});

Loading…
Cancel
Save