修正面域求交错误

pull/482/head
ChenX 5 years ago
parent cc6b7d67d2
commit 583bbfdf37

@ -1,5 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`#I118PO 1`] = `6298.780447492156`;
exports[`交点大于等于2_但是还是分离 1`] = `310430.5057844047`;
exports[`交点大于等于2_但是还是分离 2`] = `40090.549687200226`;

@ -16,3 +16,14 @@ test('交点大于等于2_但是还是分离', () =>
reg.BooleanOper(reg2.Clone(), BoolOpeartionType.Subtract);
expect(reg.Area).toMatchSnapshot();
});
test(`#I118PO`, () =>
{
let d = [2, "Region", 5, 2, 109, false, 1, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 0, 0, 1, 1, 1, 1, "Polyline", 5, 2, 0, false, 0, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 0, 0, 2, 4, [0, 0], 0, [349.99999999999983, 0], 0, [349.99999999999983, 18], 0, [0, 18], 0, true, 0, "Region", 5, 2, 110, false, 1, 7, 0, [-0.6481962787933795, -0.7614732983883384, -3.969057490217688e-17, 0, 0.7614732983883384, -0.6481962787933795, 4.66267918753728e-17, 0, 6.123233995736766e-17, 0, -1, 0, -507.79108398045344, 1098.4374795109752, -4.082417520817821e-14, 1], 0, 0, 1, 1, 1, 1, "Polyline", 5, 2, 0, false, 0, 7, 0, [-0.6481962787933795, -0.7614732983883384, -3.969057490217688e-17, 0, -0.7614732983883384, 0.6481962787933795, -4.66267918753728e-17, 0, 6.123233995736766e-17, 0, -1, 0, -507.79108398045344, 1098.4374795109752, -4.082417520817821e-14, 1], 0, 0, 2, 4, [9.993381848422814, -884.0586414166524], 0.17863084838388266, [280.4138219783257, -1365.1880927528969], 0, [507.2825195560087, -1098.6724383169787], -0.09662306706998787, [400.5809327775901, -964.8005274526736], 0, true, 0];
let [reg1, reg2] = LoadRegionsFromFileData(d);
let reg = reg1.Clone();
reg.BooleanOper(reg2.Clone(), BoolOpeartionType.Intersection);
expect(reg.ShapeManager.ShapeCount).toBe(1);
expect(reg.Area).toMatchSnapshot();
})

@ -1,4 +1,3 @@
import * as THREE from "three";
import { Vector3 } from "three";
import { arrayLast, arrayRemoveDuplicateBySort, arrayRemoveIf } from "../Common/ArrayExt";
import { curveLinkGroup, equalCurve } from "../Common/CurveUtils";
@ -185,10 +184,8 @@ export class Contour
}
/**
* 线.
* @param {Contour} target
* @returns {intersectionList //交集曲线表, unionList //并集曲线表}
*/
GetIntersetAndUnionList(target: Contour)
GetIntersetAndUnionList(target: Contour): { intersectionList: Curve[], unionList: Curve[] }
{
let intersectionList: Curve[] = [];
let unionList: Curve[] = [];
@ -232,7 +229,7 @@ export class Contour
{
//在目标分离曲线数组从若有相等的曲线,且相等的线段不连接2区域则直接加入合并和相交集合中
//在目标数组中就直接跳过不在添加在2轮廓有共线部分时需此判断
hasEqualCus = targetCus.some(l => equalCurve(pl, l));
hasEqualCus = targetCus.some(l => fastEqualCurve(pl, l));
if (hasEqualCus)
{
//获得共有线段中点2侧的点,判断是否有存在2区域外的点
@ -260,7 +257,7 @@ export class Contour
for (let pl of targetCus)
{
let hasEqualCus = sourceCus.some(l => equalCurve(pl, l));
let hasEqualCus = sourceCus.some(l => fastEqualCurve(pl, l));
if (hasEqualCus && disLink)
{
continue;
@ -421,7 +418,7 @@ export class Contour
/**
* 线,使
*/
function fastEqualCurve(c1: Polyline, c2: Polyline, tolerance = 1e-3)
function fastEqualCurve(c1: Curve, c2: Curve, tolerance = 1e-3)
{
let sp1 = c1.StartPoint;
let ep1 = c1.EndPoint;

Loading…
Cancel
Save