pull/55/head
ChenX 7 years ago
parent 03685419dc
commit 75a18feb2f

@ -44,6 +44,8 @@ export function polar(v: Vector3 | Vector2, an: number, dis: number): Vector3 |
export function angle(v: Vector3 | Vector2) export function angle(v: Vector3 | Vector2)
{ {
if (equaln(v.y, 0) && v.x > 0)
return 0;
let angle = Math.atan2(v.y, v.x); let angle = Math.atan2(v.y, v.x);
if (angle < 0) angle += Math.PI * 2; if (angle < 0) angle += Math.PI * 2;
return angle; return angle;

@ -1,5 +1,6 @@
import { Vector3 } from 'three'; import { Vector3 } from 'three';
import { Arc } from '../DatabaseServices/Arc';
import { Curve } from '../DatabaseServices/Curve'; import { Curve } from '../DatabaseServices/Curve';
import { angle, equal } from './GeUtils'; import { angle, equal } from './GeUtils';
@ -61,10 +62,9 @@ export class RegionParse
//找到最小的站. //找到最小的站.
let minStand = this.FindMinStand(needFinds); let minStand = this.FindMinStand(needFinds);
needFinds.delete(minStand); needFinds.delete(minStand);
//顺时针搜索. //逆时针+逆时针
for (let i = minStand.routes.length; i--;) for (let i = minStand.routes.length; i--;)
{ {
let route = minStand.routes[i];
let wayS = new Set<Stand>(); let wayS = new Set<Stand>();
let routeS = new Set<Route>(); let routeS = new Set<Route>();
let isFind = this.FindRegion(minStand, minStand, undefined, wayS, routeS, 1); let isFind = this.FindRegion(minStand, minStand, undefined, wayS, routeS, 1);
@ -86,7 +86,7 @@ export class RegionParse
} }
/** /**
* 使,,. * 使,,.
* . * .
* *
* @param {Set<Stand>} standS * @param {Set<Stand>} standS
@ -110,7 +110,7 @@ export class RegionParse
passingStands.add(minStand); passingStands.add(minStand);
needFinds.delete(minStand); needFinds.delete(minStand);
//时针搜索 //时针搜索
for (let j = minStand.routes.length; j--;) for (let j = minStand.routes.length; j--;)
{ {
let route = minStand.routes[j]; let route = minStand.routes[j];
@ -187,12 +187,19 @@ export class RegionParse
{ {
for (let cu of cuList) for (let cu of cuList)
{ {
let startS = this.GetStand(cu.StartPoint); //由于圆弧可能导致最低点计算错误的问题.
let endS = this.GetStand(cu.EndPoint); if (cu instanceof Arc)
let routeS2E: Route = { curve: cu, to: endS }; {
let routeE2S: Route = { curve: cu, to: startS }; let underPt = cu.Center.add(new Vector3(0, -cu.Radius));
startS.routes.push(routeS2E); let param = cu.GetParamAtPoint(underPt);
endS.routes.push(routeE2S); if (cu.ParamOnCurve(param))
{
let arcs = cu.GetSplitCurves(param);
arcs.forEach(a => this.addCurveToMap(a));
continue;
}
}
this.addCurveToMap(cu);
} }
this.m_NodeMap.forEach(s => this.m_NodeMap.forEach(s =>
{ {
@ -215,6 +222,16 @@ export class RegionParse
} }
private addCurveToMap(cu: Curve)
{
let startS = this.GetStand(cu.StartPoint);
let endS = this.GetStand(cu.EndPoint);
let routeS2E: Route = { curve: cu, to: endS };
let routeE2S: Route = { curve: cu, to: startS };
startS.routes.push(routeS2E);
endS.routes.push(routeE2S);
}
/** /**
* . * .
* *
@ -253,7 +270,7 @@ export class RegionParse
} }
//寻找闭合轮廓,下一站总是使用时针规划. //寻找闭合轮廓,下一站总是使用时针规划.
private FindRegion(firstS: Stand, //起点 private FindRegion(firstS: Stand, //起点
nowStand: Stand, //当前站 nowStand: Stand, //当前站
lastCurve: Curve, //上一条线索引 lastCurve: Curve, //上一条线索引
@ -267,7 +284,7 @@ export class RegionParse
let lastIndex = -1; let lastIndex = -1;
if (lastCurve) if (lastCurve)
{ {
for (let i = routeCount; i--;)//时针搜索. for (let i = routeCount; i--;)//时针搜索.
{ {
if (nowStand.routes[i].curve === lastCurve) if (nowStand.routes[i].curve === lastCurve)
{ {
@ -279,7 +296,7 @@ export class RegionParse
for (let i = 0; i < routeCount - 1; i++) for (let i = 0; i < routeCount - 1; i++)
{ {
let index = lastIndex + i + 1;//转弯,时针 let index = lastIndex + i + 1;//转弯,时针
if (index >= routeCount) index -= routeCount; if (index >= routeCount) index -= routeCount;
//下一站 //下一站

Loading…
Cancel
Save