diff --git a/__test__/Booloperate/__snapshots__/union.test.ts.snap b/__test__/Booloperate/__snapshots__/union.test.ts.snap index a8f14af85..edbaacb69 100644 --- a/__test__/Booloperate/__snapshots__/union.test.ts.snap +++ b/__test__/Booloperate/__snapshots__/union.test.ts.snap @@ -1,3 +1,7 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`并集错误,错误的曲线包含 1`] = `"20000.01000"`; + +exports[`并集错误midparam错误 1`] = `"24331.20499"`; + +exports[`并集错误midparam错误 2`] = `"1"`; diff --git a/__test__/Booloperate/union.test.ts b/__test__/Booloperate/union.test.ts index 058b8efe8..1e67e74f7 100644 --- a/__test__/Booloperate/union.test.ts +++ b/__test__/Booloperate/union.test.ts @@ -1,5 +1,5 @@ -import { LoadRegionsFromFileData } from "../Utils/LoadEntity.util"; import { BoolOpeartionType } from "../../src/GraphicsSystem/BoolOperateUtils"; +import { LoadRegionsFromFileData } from "../Utils/LoadEntity.util"; import "../Utils/jest.util"; test('并集错误,错误的曲线包含', () => @@ -12,3 +12,14 @@ test('并集错误,错误的曲线包含', () => regs[0].BooleanOper(regs[1], BoolOpeartionType.Union); expect(regs[0].Area).toMatchNumberSnapshot(); }); + +test('并集错误midparam错误', () => +{ + let d = { "file": [10, "Region", 10, 2, 236, 0, 1, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 2249.810963130229, -3.9603816193107804, 0, 1], 0, 0, 1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 2249.810963130229, -3.9603816193107804, 0, 1], 0, 0, 1, 1, 1, 1, 1, "Polyline", 10, 2, 0, 0, 0, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 2249.810963130229, -3.9603816193107804, 0, 1], 0, 0, 1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 2249.810963130229, -3.9603816193107804, 0, 1], 0, 0, 1, 2, 4, [-4.250020688645947, 175.31068394135826], 0, [-9.804401758770386, 163.00625990250774], 0, [152.04430287123384, 89.94559664979542], 0, [157.59868394135842, 102.25002068864593], 0, true, 0, "Region", 10, 2, 237, 0, 1, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 2249.810963130229, -3.9603816193107804, 0, 1], 0, 0, 1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 2249.810963130229, -3.9603816193107804, 0, 1], 0, 0, 1, 1, 1, 1, 1, "Polyline", 10, 2, 0, 0, 0, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 2249.810963130229, -3.9603816193107804, 0, 1], 0, 0, 1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 2249.810963130229, -3.9603816193107804, 0, 1], 0, 0, 1, 2, 4, [142.50001607080964, 92.10206336063504], 0.3711582297072071, [352.6322568018771, 261.81694136762786], 0, [339.4275656299559, 264.65922472342237], -0.3724056821149683, [142.49998460187987, 105.60918902153855], 0, true, 0, "Region", 10, 2, 238, 0, 1, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 2249.810963130229, -3.9603816193107804, 0, 1], 0, 0, 1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 2249.810963130229, -3.9603816193107804, 0, 1], 0, 0, 1, 1, 1, 1, 1, "Polyline", 10, 2, 0, 0, 0, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 2249.810963130229, -3.9603816193107804, 0, 1], 0, 0, 1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 2249.810963130229, -3.9603816193107804, 0, 1], 0, 0, 1, 2, 4, [349.8966735085616, 249.10801165167487], 0.37115824487299626, [228.20071455564383, 490.24837053808045], 0, [222.64337947880304, 477.93746192813194], -0.3724056994861207, [336.69198724491287, 251.95031786976477], 0, true, 0, "Region", 10, 2, 239, 0, 1, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 2249.810963130229, -3.9603816193107804, 0, 1], 0, 0, 1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 2249.810963130229, -3.9603816193107804, 0, 1], 0, 0, 1, 1, 1, 1, 1, "Polyline", 10, 2, 0, 0, 0, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 2249.810963130229, -3.9603816193107804, 0, 1], 0, 0, 1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 2249.810963130229, -3.9603816193107804, 0, 1], 0, 0, 1, 2, 4, [234.49207929088746, 472.5887794382231], 0, [240.04940777751023, 484.899690951749], 0.3711581661337208, [-21.30116347367135, 416.671563138748], 0, [-10.435340980066968, 408.64807613249116], -0.37240560929681754, true, 0, "Region", 10, 2, 240, 0, 1, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 2249.810963130229, -3.9603816193107804, 0, 1], 0, 0, 1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 2249.810963130229, -3.9603816193107804, 0, 1], 0, 0, 1, 1, 1, 1, 1, "Polyline", 10, 2, 0, 0, 0, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 2249.810963130229, -3.9603816193107804, 0, 1], 0, 0, 1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 2249.810963130229, -3.9603816193107804, 0, 1], 0, 0, 1, 2, 4, [-2.71309915369622, 419.1059641667471], 0, [-13.578942277783057, 427.12942332029405], 0.37115822815921923, [-1.8740603488310112, 157.2744505517037], 0, [8.256250858381406, 166.20861186829777], -0.3724056803418778, true, 0, "Region", 10, 2, 241, 0, 1, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 2249.810963130229, -3.9603816193107804, 0, 1], 0, 0, 1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 2249.810963130229, -3.9603816193107804, 0, 1], 0, 0, 1, 1, 1, 1, 1, "Polyline", 10, 2, 0, 0, 0, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 2249.810963130229, -3.9603816193107804, 0, 1], 0, 0, 1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 2249.810963130229, -3.9603816193107804, 0, 1], 0, 0, 1, 2, 4, [-10.104851709079483, 165.44642686672242], 0, [0.6644356272143179, 157.30563757646675], 0, [108.50371420301629, 299.9640624188237], 0, [97.73442686672249, 308.10485170907936], 0, true, 0, "Region", 10, 2, 242, 0, 1, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 2249.810963130229, -3.9603816193107804, 0, 1], 0, 0, 1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 2249.810963130229, -3.9603816193107804, 0, 1], 0, 0, 1, 1, 1, 1, 1, "Polyline", 10, 2, 0, 0, 0, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 2249.810963130229, -3.9603816193107804, 0, 1], 0, 0, 1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 2249.810963130229, -3.9603816193107804, 0, 1], 0, 0, 1, 2, 4, [92.87513919839087, 292.5], 0, [106.49411805408573, 292.5], -0.506169876985489, [155.5, 341.50588194591427], 0, [155.5, 355.12486080160915], 0.4834853935785955, true, 0, "Region", 10, 2, 243, 0, 1, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 2249.810963130229, -3.9603816193107804, 0, 1], 0, 0, 1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 2249.810963130229, -3.9603816193107804, 0, 1], 0, 0, 1, 1, 1, 1, 1, "Polyline", 10, 2, 0, 0, 0, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 2249.810963130229, -3.9603816193107804, 0, 1], 0, 0, 1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 2249.810963130229, -3.9603816193107804, 0, 1], 0, 0, 1, 2, 4, [142.5, 355.12486080160915], 0, [142.5, 341.50588194591427], -0.506169876985489, [191.50588194591424, 292.5], 0, [205.1248608016091, 292.49999999999994], 0.4834853935785955, true, 0, "Region", 10, 2, 244, 0, 1, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 2249.810963130229, -3.9603816193107804, 0, 1], 0, 0, 1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 2249.810963130229, -3.9603816193107804, 0, 1], 0, 0, 1, 1, 1, 1, 1, "Polyline", 10, 2, 0, 0, 0, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 2249.810963130229, -3.9603816193107804, 0, 1], 0, 0, 1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 2249.810963130229, -3.9603816193107804, 0, 1], 0, 0, 1, 2, 4, [205.12486080160912, 305.5], 0, [191.50588194591427, 305.5], -0.5061698769854893, [142.5, 256.49411805408573], 0, [142.49999999999997, 242.87513919839088], 0.48348539357859577, true, 0, "Region", 10, 2, 245, 0, 1, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 2249.810963130229, -3.9603816193107804, 0, 1], 0, 0, 1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 2249.810963130229, -3.9603816193107804, 0, 1], 0, 0, 1, 1, 1, 1, 1, "Polyline", 10, 2, 0, 0, 0, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 2249.810963130229, -3.9603816193107804, 0, 1], 0, 0, 1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 2249.810963130229, -3.9603816193107804, 0, 1], 0, 0, 1, 2, 4, [157.82508739908394, 246.42748519955072], 0, [151.33203123896334, 258.2634567144505], 0, [-10.065570960569886, 169.72288411581593], 0, [-3.5725148004492864, 157.8869126009161], 0, true, 0], "basePt": { "x": 2191.810568371231, "y": 85.98521503048464, "z": 0 }, "ucs": [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1] }; + let regs = LoadRegionsFromFileData(d); + + for (let i = 1; i < regs.length; i++) + regs[0].BooleanOper(regs[i], BoolOpeartionType.Union); + expect(regs[0].Area).toMatchNumberSnapshot(); + expect(regs[0].ShapeManager.ShapeCount).toMatchNumberSnapshot(0); +}); diff --git a/src/DatabaseServices/Contour.ts b/src/DatabaseServices/Contour.ts index 18ee846e3..b71d627ce 100644 --- a/src/DatabaseServices/Contour.ts +++ b/src/DatabaseServices/Contour.ts @@ -283,7 +283,7 @@ export class Contour { //方向相同 if ( - equalv3(cu.GetFirstDeriv(cu.EndParam * 0.5).normalize(), pl.GetFirstDeriv(pl.EndParam * 0.5).normalize(), 1e-3) + equalv3(cu.GetFirstDeriv(cu.MidParam).normalize(), pl.GetFirstDeriv(pl.MidParam).normalize(), 1e-3) === isEqualNormal ) {