|
|
|
@ -1,8 +1,10 @@
|
|
|
|
|
import { CADFile } from '../../src/DatabaseServices/CADFile';
|
|
|
|
|
import { Polyline } from '../../src/DatabaseServices/Polyline';
|
|
|
|
|
import { GetPointAtCurveDir } from '../../src/Common/CurveUtils';
|
|
|
|
|
import { Vector3 } from 'three';
|
|
|
|
|
import { Vector3, Vector2 } from 'three';
|
|
|
|
|
import { Factory } from '../../src/DatabaseServices/CADFactory';
|
|
|
|
|
|
|
|
|
|
Factory(Polyline);
|
|
|
|
|
test('2个大圆中间', () =>
|
|
|
|
|
{
|
|
|
|
|
let f = new CADFile();
|
|
|
|
@ -36,6 +38,20 @@ test('点在端点且端点平行', () =>
|
|
|
|
|
expect(isR).toBeTruthy();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('点在和端点平行', () =>
|
|
|
|
|
{
|
|
|
|
|
let pl = new Polyline();
|
|
|
|
|
pl.AddVertexAt(0, new Vector2(0, 0));
|
|
|
|
|
pl.AddVertexAt(1, new Vector2(0, 5));
|
|
|
|
|
pl.AddVertexAt(2, new Vector2(0, 10));
|
|
|
|
|
|
|
|
|
|
let p = new Vector3(5, 5, 0);
|
|
|
|
|
|
|
|
|
|
let isR = GetPointAtCurveDir(pl, p);
|
|
|
|
|
|
|
|
|
|
expect(isR).toBeTruthy();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
test('点在端点上且点在圆心上', () =>
|
|
|
|
|
{
|
|
|
|
@ -201,4 +217,27 @@ test('点在圆弧的弦中心上', () =>
|
|
|
|
|
pt = new Vector3().fromArray([5, 5.5, 0]);
|
|
|
|
|
isR = GetPointAtCurveDir(pl, pt);
|
|
|
|
|
expect(isR).toBeTruthy();
|
|
|
|
|
|
|
|
|
|
pt = new Vector3().fromArray([6, 10, 0]);
|
|
|
|
|
isR = GetPointAtCurveDir(pl, pt);
|
|
|
|
|
expect(isR).toBeTruthy();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
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.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;
|
|
|
|
|
|
|
|
|
|
let pt = new Vector3().fromArray([-2246.7733894227954, -220.1844621837422, 0]);
|
|
|
|
|
let isR = GetPointAtCurveDir(pl, pt);
|
|
|
|
|
expect(isR).toBeFalsy();
|
|
|
|
|
|
|
|
|
|
pt = new Vector3().fromArray([-2184.668414731696, -221.35723534211996, 0]);
|
|
|
|
|
|
|
|
|
|
//[1,["Circle",1,1,4,false,7,-1,[1,0,0,0,0,1,0,0,0,0,1,0,-2184,-221.357,0,1],1,1]]
|
|
|
|
|
isR = GetPointAtCurveDir(pl, pt);
|
|
|
|
|
expect(isR).toBeFalsy();
|
|
|
|
|
});
|
|
|
|
|