mirror of https://gitee.com/cf-fz/WebCAD.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
102 lines
4.9 KiB
102 lines
4.9 KiB
|
|
import { Vector3 } from "three";
|
|
import { FilletUtils } from "../../src/Add-on/FilletUtils";
|
|
import { equalCurve } from "../../src/Common/CurveUtils";
|
|
import { Polyline } from "../../src/DatabaseServices/Entity/Polyline";
|
|
import { PromptEntityResult } from "../../src/Editor/PromptResult";
|
|
import { LoadEntityFromFileData } from "../Utils/LoadEntity.util";
|
|
|
|
let fillet = new FilletUtils();
|
|
test('多段线首尾倒角有圆弧', () =>
|
|
{
|
|
TestFilletPolyline(
|
|
[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)]
|
|
);
|
|
});
|
|
|
|
test('多段线闭合标志首尾有弧', () =>
|
|
{
|
|
TestFilletPolyline(
|
|
[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]),
|
|
new Vector3().fromArray([2316.870065964417, 369.68282338998426, 0]),
|
|
new Vector3().fromArray([2372.2120461809227, 345.01469025367805, 0])
|
|
]
|
|
);
|
|
|
|
|
|
});
|
|
|
|
test('双圆多段线倒角', () =>
|
|
{
|
|
//双圆
|
|
TestFilletPolyline(
|
|
[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]),
|
|
new Vector3().fromArray([695.0427029021831, -579.0860583389696, 0]),
|
|
new Vector3().fromArray([776.3783481250921, -599.2347834977858, 0])
|
|
]
|
|
);
|
|
|
|
//双圆 CloseMark
|
|
TestFilletPolyline(
|
|
[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]),
|
|
new Vector3().fromArray([695.0427029021831, -579.0860583389696, 0]),
|
|
new Vector3().fromArray([776.3783481250921, -599.2347834977858, 0])
|
|
]
|
|
);
|
|
});
|
|
|
|
function TestFilletPolyline(
|
|
curveData: any,
|
|
radius: number,
|
|
filletPts: Vector3[]
|
|
)
|
|
{
|
|
let pl = LoadEntityFromFileData(curveData)[0] as Polyline;
|
|
fillet.FilletRadius = radius;
|
|
|
|
|
|
let es1 = new PromptEntityResult(pl, undefined);
|
|
let es2 = new PromptEntityResult(pl, undefined);
|
|
|
|
for (let i = 0; i < filletPts.length / 2; i++)
|
|
{
|
|
es1.Point = filletPts[i * 2];
|
|
es2.Point = filletPts[i * 2 + 1];
|
|
|
|
let res = fillet.Fillet(es1, es2);
|
|
expect(res.cu1.Length).toMatchSnapshot();
|
|
|
|
pl.Reverse();
|
|
|
|
res = fillet.Fillet(es1, es2);
|
|
expect(res.cu1.Length).toMatchSnapshot();
|
|
}
|
|
}
|
|
|
|
test('法向量相反EqualPolyline', () =>
|
|
{
|
|
let d =
|
|
[2, "Polyline", 2, 1, 103, false, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 2.112676056338046, 2.1126760563380316, 0, 1], 1, 2, 6, [0, 0], 0, [5, 0], 1, [5, 5], -1, [5, 10], 0, [0, 10], 0, [0, 0], 0, false, "Polyline", 2, 1, 104, false, 7, 0, [-1, 0, 0, 0, 0, 1, 0, 0, 0, 0, -1, 0, 0, 0, 0, 1], 1, 2, 6, [-7.112676056338046, 7.112676056338032], 0.9999999999999999, [-7.112676056338046, 2.1126760563380316], 0, [-2.112676056338046, 2.1126760563380316], 0, [-2.112676056338046, 12.112676056338032], 0, [-7.112676056338046, 12.112676056338032], -0.9999999999999999, [-7.112676056338046, 7.112676056338032], 0, false];
|
|
|
|
let pls = LoadEntityFromFileData(d) as Polyline[];
|
|
|
|
expect(equalCurve(pls[0], pls[1])).toBeTruthy();
|
|
|
|
let pl2 = pls[0].Clone().Reverse();
|
|
expect(equalCurve(pls[0], pl2)).toBeTruthy();
|
|
});
|