修复共边导致的差集结果错误

pull/348/MERGE
ChenX 5 years ago
parent 93edfeb1a6
commit 14454494f3

@ -0,0 +1,3 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`简单差集 1`] = `377232.7083535502`;

@ -50,7 +50,16 @@ test("多无洞面域,互相相交", () =>
let regs = LoadRegionsFromFileData(data);
expect(regs.length).toBe(3);
testRegionsBool(regs, 1, 0, 1, 0, 1, 0);
})
});
test('简单差集', () =>
{
let d = [2, "Region", 4, 2, 621, false, 1, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 0, 1, 1, 1, 1, "Polyline", 4, 2, 0, false, 0, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 0, 2, 4, [1445.5476870961775, -414.05675626156443], 0, [2311.4623870961777, -414.05675626156443], 0, [2311.4623870961777, 21.589743738435573], 0, [1445.5476870961775, 21.589743738435573], 0, true, 0, "Region", 4, 2, 622, false, 1, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 0, 1, 1, 1, 1, "Polyline", 4, 2, 0, false, 0, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 0, 2, 4, [1833.6495890686276, 21.589743738435573], 0, [2041.7917890686276, 21.589743738435573], 0, [2041.7917890686276, 206.17484373843558], 0, [1833.6495890686276, 206.17484373843558], 0, true, 0]
let regs = LoadRegionsFromFileData(d);
regs[0].BooleanOper(regs[1], BoolOpeartionType.Subtract);
expect(regs[0].Area).toMatchSnapshot();
});
test("多无洞面域,互不相交", () =>
{

@ -10,13 +10,13 @@ exports[`刀切到外轮廓情况: 曲线长度 4`] = `1478.9393851461323`;
exports[`刀切到外轮廓情况: 曲线长度 5`] = `729.5688477133849`;
exports[`刀切到外轮廓情况: 曲线长度 6`] = `939.4039853849375`;
exports[`刀切到外轮廓情况: 曲线长度 6`] = `939.4039853849376`;
exports[`刀切到外轮廓情况: 曲线长度 7`] = `13736.35564962633`;
exports[`刀切到外轮廓情况: 曲线长度 7`] = `13736.355649626326`;
exports[`刀切到外轮廓情况: 曲线长度 8`] = `1216.987577519942`;
exports[`刀切到外轮廓情况: 曲线长度 9`] = `13428.231939084184`;
exports[`刀切到外轮廓情况: 曲线长度 9`] = `13428.231939084195`;
exports[`刀切到外轮廓情况: 曲线长度 10`] = `939.4039853849374`;
@ -36,7 +36,7 @@ exports[`刀切到外轮廓情况: 走刀数量 1`] = `2`;
exports[`刀切到外轮廓情况: 走刀数量 2`] = `8`;
exports[`复杂极限刀半径: 曲线长度 1`] = `1068.3190582501115`;
exports[`复杂极限刀半径: 曲线长度 1`] = `1068.3190582501113`;
exports[`复杂极限刀半径: 曲线长度 2`] = `35730.26757931215`;
@ -46,25 +46,25 @@ exports[`复杂极限刀半径: 曲线长度 4`] = `4356.840832388074`;
exports[`复杂极限刀半径: 曲线长度 5`] = `951.5402172137751`;
exports[`复杂极限刀半径: 曲线长度 6`] = `3278.917934988776`;
exports[`复杂极限刀半径: 曲线长度 6`] = `3278.9179349887763`;
exports[`复杂极限刀半径: 走刀数量 1`] = `3`;
exports[`复杂造型测试: 曲线长度 1`] = `24373.250750763476`;
exports[`复杂造型测试: 曲线长度 2`] = `4285.071854430759`;
exports[`复杂造型测试: 曲线长度 2`] = `4285.071854430757`;
exports[`复杂造型测试: 曲线长度 3`] = `2418.143451783812`;
exports[`复杂造型测试: 曲线长度 3`] = `2418.1434517838106`;
exports[`复杂造型测试: 曲线长度 4`] = `2293.0762218537748`;
exports[`复杂造型测试: 曲线长度 4`] = `2293.0762218537734`;
exports[`复杂造型测试: 曲线长度 5`] = `4096.105045378745`;
exports[`复杂造型测试: 曲线长度 5`] = `4096.105045378747`;
exports[`复杂造型测试: 曲线长度 6`] = `910.1341511193467`;
exports[`复杂造型测试: 曲线长度 6`] = `910.1341511193466`;
exports[`复杂造型测试: 曲线长度 7`] = `2841.13372275202`;
exports[`复杂造型测试: 曲线长度 7`] = `2841.1337227520216`;
exports[`复杂造型测试: 曲线长度 8`] = `1079.273647743498`;
exports[`复杂造型测试: 曲线长度 8`] = `1079.2736477434973`;
exports[`复杂造型测试: 曲线长度 9`] = `227.8342135021163`;
@ -78,17 +78,17 @@ exports[`复杂造型测试: 曲线长度 13`] = `2402.511185283596`;
exports[`复杂造型测试: 曲线长度 14`] = `1715.2225461089636`;
exports[`复杂造型测试: 曲线长度 15`] = `493.42887087968927`;
exports[`复杂造型测试: 曲线长度 15`] = `493.42887087968916`;
exports[`复杂造型测试: 曲线长度 16`] = `352.7973262382525`;
exports[`复杂造型测试: 曲线长度 17`] = `342.70973636046426`;
exports[`复杂造型测试: 曲线长度 18`] = `476.0989607667294`;
exports[`复杂造型测试: 曲线长度 18`] = `476.0989607667295`;
exports[`复杂造型测试: 曲线长度 19`] = `1167.5479341842504`;
exports[`复杂造型测试: 曲线长度 20`] = `413.7195254587743`;
exports[`复杂造型测试: 曲线长度 20`] = `413.7195254587742`;
exports[`复杂造型测试: 曲线长度 21`] = `275.9275697576068`;
@ -100,13 +100,13 @@ exports[`复杂造型测试: 曲线长度 24`] = `169.22283273433305`;
exports[`复杂造型测试: 曲线长度 25`] = `162.171881370416`;
exports[`复杂造型测试: 曲线长度 26`] = `106446.82051694988`;
exports[`复杂造型测试: 曲线长度 26`] = `106446.82051696385`;
exports[`复杂造型测试: 曲线长度 27`] = `5545.665343214347`;
exports[`复杂造型测试: 曲线长度 28`] = `3600`;
exports[`复杂造型测试: 曲线长度 29`] = `2581.084814115112`;
exports[`复杂造型测试: 曲线长度 29`] = `2581.0848141151123`;
exports[`复杂造型测试: 曲线长度 30`] = `463.19933816470575`;
@ -152,7 +152,7 @@ exports[`极限刀半径: 曲线长度 5`] = `3600`;
exports[`极限刀半径: 曲线长度 6`] = `1552.3359576397822`;
exports[`极限刀半径: 曲线长度 7`] = `1638.9591725161224`;
exports[`极限刀半径: 曲线长度 7`] = `1638.9591725161226`;
exports[`极限刀半径: 曲线长度 8`] = `3600`;

@ -20,27 +20,27 @@ exports[`圆求交错误导致的线丢失 1`] = `4148.6552839918695`;
exports[`圆求交错误导致的线丢失 2`] = `4425.280774659357`;
exports[`圆求交错误导致的线丢失 3`] = `4021.9003332433504`;
exports[`圆求交错误导致的线丢失 3`] = `4021.9003332433485`;
exports[`圆求交错误导致的线丢失 4`] = `4581.2242286506635`;
exports[`圆求交错误导致的线丢失 5`] = `3900.6079069452903`;
exports[`圆求交错误导致的线丢失 5`] = `3900.607906945287`;
exports[`圆求交错误导致的线丢失 6`] = `4757.46853225238`;
exports[`圆求交错误导致的线丢失 7`] = `3783.74866210012`;
exports[`圆求交错误导致的线丢失 7`] = `3783.7486621001212`;
exports[`圆求交错误导致的线丢失 8`] = `4972.012479701851`;
exports[`圆求交错误导致的线丢失 9`] = `1148.6632687596896`;
exports[`圆求交错误导致的线丢失 9`] = `1148.663268759687`;
exports[`圆求交错误导致的线丢失 10`] = `5979.881810920418`;
exports[`圆求交错误导致的线丢失 11`] = `1049.959913317264`;
exports[`圆求交错误导致的线丢失 11`] = `1049.9599133172633`;
exports[`圆求交错误导致的线丢失 12`] = `6051.226641876329`;
exports[`圆求交错误导致的线丢失 13`] = `722.4732418587953`;
exports[`圆求交错误导致的线丢失 13`] = `722.4732418587954`;
exports[`圆求交错误导致的线丢失 14`] = `6316.980887212943`;
@ -66,7 +66,7 @@ exports[`复杂圆盘选点 10`] = `206.8233228255668`;
exports[`多段线因为合并问题造成的错误 1`] = `1`;
exports[`多段线因为合并问题造成的错误 2`] = `2210.3833040297095`;
exports[`多段线因为合并问题造成的错误 2`] = `2210.3833040297086`;
exports[`多段线存在0长度线段导致偏移错误 1`] = `1`;

@ -2,7 +2,7 @@
exports[`补充bug测试#IKWGF 1`] = `1.1376403544773552`;
exports[`补充bug测试#IKWGF 2`] = `0.44573953236152586`;
exports[`补充bug测试#IKWGF 2`] = `0.44573953236152686`;
exports[`补充bug测试#IKWGF 3`] = `10.732981364094256`;
@ -16,10 +16,10 @@ exports[`补充bug测试#IKWGF 7`] = `14.067113755971711`;
exports[`补充bug测试#IKWGF 8`] = `2.168984971098264`;
exports[`补充bug测试#IKWGF 9`] = `11.891017922899273`;
exports[`补充bug测试#IKWGF 9`] = `11.89101792289927`;
exports[`补充bug测试#IKWGF 10`] = `1.0803374679586235`;
exports[`补充bug测试#IKWGF 11`] = `0.39474593983890816`;
exports[`补充bug测试#IKWGF 11`] = `0.39474593983890793`;
exports[`补充bug测试#IKWGF 12`] = `10.69886845125427`;

@ -132,7 +132,7 @@ describe("闭合多段线", () =>
}
//变换曲线顺序
data =
[1,"Polyline",1,1,0,false,7,0,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],2,5,[22.178278439318607,-1.9155229050126357],0,[22.83746943877066,-1.800164480108526],0,[23.79329638797614,-6.11786552651948],-0.871731137783436,[23.348342463346004,-6.282663276382493],-0.7430788314178012,[22.903388538715866,-6.267501883395095],0,true]
[1, "Polyline", 1, 1, 0, false, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 5, [22.178278439318607, -1.9155229050126357], 0, [22.83746943877066, -1.800164480108526], 0, [23.79329638797614, -6.11786552651948], -0.871731137783436, [23.348342463346004, -6.282663276382493], -0.7430788314178012, [22.903388538715866, -6.267501883395095], 0, true]
cus = loadFile(data);
for (let i = 0.01; i <= 0.33; i += 0.03)
{
@ -567,16 +567,16 @@ describe("不规则不闭合多段线测试", () =>
cus[0].Reverse();
expect(cus[0].GetOffsetCurves(-18).length).toBe(2);
data =
[1,"Polyline",1,1,0,false,7,0,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],2,7,[21.944751443449043,-31.01626057276902],0,[38.129771973149346,-31.016260572769028],0,[32.85929640135194,-26.50707591689791],0,[47.440945483324754,-26.50707591689791],0,[45.33685543194063,-31.016260572769028],0,[61.52187596164093,-31.016260572769035],0,[70.31099992504923,-35.88209931313313],0,false]
[1, "Polyline", 1, 1, 0, false, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 7, [21.944751443449043, -31.01626057276902], 0, [38.129771973149346, -31.016260572769028], 0, [32.85929640135194, -26.50707591689791], 0, [47.440945483324754, -26.50707591689791], 0, [45.33685543194063, -31.016260572769028], 0, [61.52187596164093, -31.016260572769035], 0, [70.31099992504923, -35.88209931313313], 0, false]
cus = loadFile(data);
expect(cus[0].GetOffsetCurves(11.4).length).toBe(1);
data =
[1,"Polyline",1,1,0,false,7,0,[1,0,0,0,0,1,0,0,0,0,1,0,-56.21146708819905,-48.62279820279199,0,1],2,7,[26.333787338902418,-31.01626057276902],0,[35.05226039203026,-31.016260572769013],0,[32.85929640135194,-26.50707591689791],0,[47.440945483324754,-26.50707591689791],0,[41.54871106124796,-31.016260572769013],0,[61.52187596164093,-31.016260572769035],0,[70.31099992504923,-35.88209931313313],0,false]
[1, "Polyline", 1, 1, 0, false, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -56.21146708819905, -48.62279820279199, 0, 1], 2, 7, [26.333787338902418, -31.01626057276902], 0, [35.05226039203026, -31.016260572769013], 0, [32.85929640135194, -26.50707591689791], 0, [47.440945483324754, -26.50707591689791], 0, [41.54871106124796, -31.016260572769013], 0, [61.52187596164093, -31.016260572769035], 0, [70.31099992504923, -35.88209931313313], 0, false]
cus = loadFile(data);
expect(cus[0].GetOffsetCurves(5.2).length).toBe(1);
data =
[1,"Polyline",1,1,0,false,7,0,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],2,6,[-3.158640226628895,-0.9915014164305944],0,[-1.0906515580736538,-0.991501416430595],0,[-1.983002832861189,0.18413597733711037],0,[1.0906515580736549,0.3966005665722377],0,[0.2974504249291776,-0.9915014164305944],0,[3.966005665722378,-0.9915014164305953],0,false]
[1, "Polyline", 1, 1, 0, false, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 6, [-3.158640226628895, -0.9915014164305944], 0, [-1.0906515580736538, -0.991501416430595], 0, [-1.983002832861189, 0.18413597733711037], 0, [1.0906515580736549, 0.3966005665722377], 0, [0.2974504249291776, -0.9915014164305944], 0, [3.966005665722378, -0.9915014164305953], 0, false]
cus = loadFile(data);
expect(cus[0].GetOffsetCurves(2.01133).length).toBe(1);
})

@ -0,0 +1,13 @@
import { ShapeManager } from "../../DatabaseServices/ShapeManager";
import { Region } from "../../DatabaseServices/Entity/Region";
import { app } from "../../ApplicationServices/Application";
export function DrawShapeManage(sm: ShapeManager)
{
let reg1 = new Region();
//@ts-ignore
reg1.m_ShapeManager = sm;
reg1 = reg1.Clone();
app.Database.ModelSpace.Append(reg1);
}

@ -1,10 +1,10 @@
import * as THREE from "three";
import { Vector3 } from "three";
import { arrayRemoveDuplicateBySort, arrayRemoveIf, arrayLast } from "../Common/ArrayExt";
import { arrayLast, arrayRemoveDuplicateBySort, arrayRemoveIf } from "../Common/ArrayExt";
import { curveLinkGroup, equalCurve } from "../Common/CurveUtils";
import { Status } from "../Common/Status";
import { FixIndex } from "../Common/Utils";
import { equaln, rotatePoint, equalv3, equalv2 } from "../Geometry/GeUtils";
import { equaln, equalv2, equalv3, rotatePoint } from "../Geometry/GeUtils";
import { RegionParse, Route } from "../Geometry/RegionParse";
import { isTargetCurInOrOnSourceCur } from "../GraphicsSystem/BoolOperateUtils";
import { IntersectOption } from "../GraphicsSystem/IntersectWith";
@ -18,6 +18,17 @@ let cache = new WeakMap();
export class Contour
{
private m_Curve: Polyline | Circle;
protected SetCurve(cu: Polyline | Circle)
{
if (cu instanceof Polyline)
{
if (cu.Area2 < 0)
cu.Reverse();
}
this.m_Curve = cu;
}
static CreateContour(cus: Curve[] | Polyline | Circle, needLink = true)
{
if (cus instanceof Curve)
@ -25,7 +36,7 @@ export class Contour
if (cus.IsClose)
{
let c = new Contour();
c.m_Curve = cus;
c.SetCurve(cus);
return c;
}
return;
@ -41,7 +52,7 @@ export class Contour
}
let c = new Contour();
c.m_Curve = closeCurve;
c.SetCurve(closeCurve);
return c;
}
}
@ -294,6 +305,8 @@ export class Contour
{
if (hasEqualCus) return false;
hasEqualCus = fastEqualCurve(cu, pl);
if (hasEqualCus && !equalv3(cu.GetFistDeriv(0).normalize(), pl.GetFistDeriv(0).normalize()))
subtractList.push(pl);
return hasEqualCus;
});
if (hasEqualCus)

Loading…
Cancel
Save