|
|
|
@ -2,23 +2,28 @@ import { Vector3 } from "three";
|
|
|
|
|
import { Curve } from "../DatabaseServices/Curve";
|
|
|
|
|
import { CurveIntersection } from "../Geometry/CurveIntersection";
|
|
|
|
|
import { CurveMap } from "../Geometry/CurveMap";
|
|
|
|
|
import { equal } from "../Geometry/GeUtils";
|
|
|
|
|
import { equal, equaln } from "../Geometry/GeUtils";
|
|
|
|
|
import { Stand } from "../Geometry/RegionParse";
|
|
|
|
|
import { app } from "../ApplicationServices/Application";
|
|
|
|
|
import { Circle } from "../DatabaseServices/Circle";
|
|
|
|
|
|
|
|
|
|
export class LinkSelf
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
private curveUseData: WeakMap<Curve, boolean> = new WeakMap();
|
|
|
|
|
private curveIndexData: WeakMap<Curve, number> = new WeakMap();
|
|
|
|
|
sealCus: Set<Curve>[] = [];
|
|
|
|
|
noSealCus: Curve[][] = [];
|
|
|
|
|
private m_Count;
|
|
|
|
|
private cuMap: CurveMap;
|
|
|
|
|
constructor(cus: Curve[])
|
|
|
|
|
{
|
|
|
|
|
this.m_Count = cus.length;
|
|
|
|
|
//打断曲线
|
|
|
|
|
let breakCus: Curve[] = this.BreakCurve(cus);
|
|
|
|
|
// breakCus.forEach(c =>
|
|
|
|
|
// {
|
|
|
|
|
// c.ColorIndex = 3;
|
|
|
|
|
// app.m_Database.ModelSpace.Append(c);
|
|
|
|
|
// })
|
|
|
|
|
|
|
|
|
|
//曲线图 用来快速搜索求交
|
|
|
|
|
this.cuMap = this.GenerateCurveMap(breakCus);
|
|
|
|
@ -36,8 +41,8 @@ export class LinkSelf
|
|
|
|
|
let insMap = new CurveIntersection(cus.concat());
|
|
|
|
|
//打断后存储的曲线列表
|
|
|
|
|
let breakCus: Curve[] = [];
|
|
|
|
|
let count = cus.length;
|
|
|
|
|
for (let i = 0; i < count; i++)
|
|
|
|
|
// let count = cus.length;
|
|
|
|
|
for (let i = 0; i < this.m_Count; i++)
|
|
|
|
|
{
|
|
|
|
|
let cu = cus[i];
|
|
|
|
|
//交点数据
|
|
|
|
@ -58,12 +63,15 @@ export class LinkSelf
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
for (let c of spCus)
|
|
|
|
|
{
|
|
|
|
|
if (!equaln(c.Length, 0, 1e-6))
|
|
|
|
|
{
|
|
|
|
|
this.SetCurveIndex(c, i);
|
|
|
|
|
breakCus.push(c);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return breakCus;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -72,8 +80,6 @@ export class LinkSelf
|
|
|
|
|
{
|
|
|
|
|
let breakCount = breakCus.length;
|
|
|
|
|
|
|
|
|
|
let selfRoutes: Set<Curve>[] = [];
|
|
|
|
|
|
|
|
|
|
//搜索闭合自交
|
|
|
|
|
for (let i = 0; i < breakCount; i++)
|
|
|
|
|
{
|
|
|
|
@ -99,18 +105,18 @@ export class LinkSelf
|
|
|
|
|
if (routeIndex < cuIndex)
|
|
|
|
|
continue;//不和小于自己索引的计算
|
|
|
|
|
|
|
|
|
|
routeCus.add(cu);
|
|
|
|
|
routeCus.add(route.curve);
|
|
|
|
|
|
|
|
|
|
//如果存在闭合区域
|
|
|
|
|
if (this.FindCloseCurve(route.to, cuIndex, ways, routeCus, cuMap))
|
|
|
|
|
{
|
|
|
|
|
routeCus.add(route.curve);
|
|
|
|
|
routeCus.add(cu);
|
|
|
|
|
//提取闭合区域
|
|
|
|
|
for (let c of routeCus)
|
|
|
|
|
{
|
|
|
|
|
this.SetCurveUse(c);
|
|
|
|
|
}
|
|
|
|
|
this.sealCus.push(routeCus);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -145,6 +151,17 @@ export class LinkSelf
|
|
|
|
|
{
|
|
|
|
|
let oldCount = cs.length;
|
|
|
|
|
let routes = cuMap.GetStand(isInv ? originCu.StartPoint : originCu.EndPoint).routes;
|
|
|
|
|
// 最后一段从大到小搜
|
|
|
|
|
|
|
|
|
|
for (let i = 0; i < routes.length; i++)
|
|
|
|
|
{
|
|
|
|
|
let index = this.GetCurveIndex(routes[i].curve);
|
|
|
|
|
if (index === cuIndex)
|
|
|
|
|
{
|
|
|
|
|
routes.unshift(routes.splice(i, 1)[0]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (let j = routes.length; j--;) //按照索引从小到大搜索
|
|
|
|
|
{
|
|
|
|
|
let cu2 = routes[j].curve;
|
|
|
|
@ -152,7 +169,7 @@ export class LinkSelf
|
|
|
|
|
if (this.GetCurveUse(cu2)) continue;
|
|
|
|
|
if (cuIndex === cu2Index)
|
|
|
|
|
{
|
|
|
|
|
continue;//如果和自身的线连接,则需要判断这条路线是否合理
|
|
|
|
|
// continue;//如果和自身的线连接,则需要判断这条路线是否合理
|
|
|
|
|
}
|
|
|
|
|
//能够连接
|
|
|
|
|
let isLink = isInv ? equal(cu2.EndPoint, originCu.StartPoint) : equal(cu2.StartPoint, originCu.EndPoint);
|
|
|
|
@ -225,7 +242,6 @@ export class LinkSelf
|
|
|
|
|
this.curveIndexData.set(curve, index);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//搜索闭合的区域
|
|
|
|
|
private FindCloseCurve(nowStand: Stand, cuIndex: number, ways: Stand[], routes: Set<Curve>, cuMap: CurveMap)
|
|
|
|
|
{
|
|
|
|
@ -242,7 +258,6 @@ export class LinkSelf
|
|
|
|
|
if (routeIndex < cuIndex)
|
|
|
|
|
continue;//不和小于自己索引的计算
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//验证通过,可以连接.
|
|
|
|
|
let toStand = route.to;
|
|
|
|
|
|
|
|
|
|