修复面域对圆弧和多段线计算错误的问题,修正单词拼写错误.

pull/704344/MERGE
ChenX_AMD 7 years ago
parent 326b67cfa2
commit f18292c4f3

@ -8,13 +8,13 @@ function expectReg(alg: RegionParse)
let data1 = alg.m_RegionsInternal.map(o => let data1 = alg.m_RegionsInternal.map(o =>
{ {
let res = []; let res = [];
o.forEach(r => { res.push(r.to.postion.toArray()) }) o.forEach(r => { res.push(r.to.position.toArray()) })
return res; return res;
}); });
let data2 = alg.m_RegionsOutline.map(o => let data2 = alg.m_RegionsOutline.map(o =>
{ {
let res = []; let res = [];
o.forEach(r => { res.push(r.to.postion.toArray()) }) o.forEach(r => { res.push(r.to.position.toArray()) })
return res; return res;
}); });

6
package-lock.json generated

@ -7443,7 +7443,7 @@
}, },
"js-tokens": { "js-tokens": {
"version": "3.0.2", "version": "3.0.2",
"resolved": "http://registry.npm.taobao.org/js-tokens/download/js-tokens-3.0.2.tgz", "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-3.0.2.tgz",
"integrity": "sha1-mGbfOVECEw449/mWvOtlRDIJwls=", "integrity": "sha1-mGbfOVECEw449/mWvOtlRDIJwls=",
"dev": true "dev": true
}, },
@ -8545,7 +8545,7 @@
}, },
"nan": { "nan": {
"version": "2.8.0", "version": "2.8.0",
"resolved": "http://registry.npm.taobao.org/nan/download/nan-2.8.0.tgz", "resolved": "https://registry.npmjs.org/nan/-/nan-2.8.0.tgz",
"integrity": "sha1-7XFfP+neArV6XmJS2QqWZ14fCFo=", "integrity": "sha1-7XFfP+neArV6XmJS2QqWZ14fCFo=",
"optional": true "optional": true
}, },
@ -14055,7 +14055,7 @@
}, },
"webworker-threads": { "webworker-threads": {
"version": "0.7.13", "version": "0.7.13",
"resolved": "http://registry.npm.taobao.org/webworker-threads/download/webworker-threads-0.7.13.tgz", "resolved": "https://registry.npmjs.org/webworker-threads/-/webworker-threads-0.7.13.tgz",
"integrity": "sha1-yEsYtrokElu503NC5E3rgVFi+4M=", "integrity": "sha1-yEsYtrokElu503NC5E3rgVFi+4M=",
"optional": true, "optional": true,
"requires": { "requires": {

@ -206,7 +206,7 @@ export class DrawRegTest implements Command
function createReg(r: Set<Route>) function createReg(r: Set<Route>)
{ {
let cus: Curve[] = []; let cus: Curve[] = [];
r.forEach(route => cus.push(route.curve)); r.forEach(route => cus.push(route.curve.Clone() as Curve));
let re = new Region(cus); let re = new Region(cus);
app.m_Database.ModelSpace.Append(re); app.m_Database.ModelSpace.Append(re);
} }

@ -36,20 +36,24 @@ export class Region extends Entity
return this.m_Shape; return this.m_Shape;
} }
Draw(renderType: RenderType): Object3D InitDrawObject(renderType: RenderType = RenderType.Wireframe): Object3D
{ {
let obj = super.Draw(renderType);
if (obj) return obj;
this.GeneralShape(); this.GeneralShape();
let geometry = new ShapeGeometry(this.m_Shape, 60); let geometry = new ShapeGeometry(this.m_Shape, 60);
let mesh = new THREE.Mesh(geometry, ColorMaterial.GetLineMaterial(this.ColorIndex)); let mesh = new THREE.Mesh(geometry, ColorMaterial.GetLineMaterial(this.ColorIndex));
this.m_DrawEntity.set(renderType, mesh);
mesh.userData = this;
return mesh; return mesh;
} }
UpdateDrawObject(type: RenderType, en: Object3D)
{
this.GeneralShape();
let lineObj = en as THREE.Mesh;
let geo = lineObj.geometry as THREE.Geometry;
geo.setFromPoints(this.m_Shape.getPoints(60));
geo.verticesNeedUpdate = true;
}
private GeneralShape() private GeneralShape()
{ {
this.m_Shape = new THREE.Shape(); this.m_Shape = new THREE.Shape();

@ -1,6 +1,7 @@
import { Vector3 } from 'three'; import { Vector3 } from 'three';
import { Curve } from '../DatabaseServices/Curve'; import { Curve } from '../DatabaseServices/Curve';
import { angle, equal } from './GeUtils';
//路线 //路线
export interface Route export interface Route
@ -14,7 +15,7 @@ export interface Route
interface Stand interface Stand
{ {
//位置 //位置
postion: Vector3; position: Vector3;
//路径 //路径
routes: Array<Route>; routes: Array<Route>;
} }
@ -72,7 +73,7 @@ export class RegionParse
this.m_RegionsOutline.push(routeS); this.m_RegionsOutline.push(routeS);
//计数增加 //计数增加
for (let route of routeS) for (let route of routeS)
this.AddCuUsedCout(route.curve, 1); this.AddCuUsedCount(route.curve, 1);
this.FindMinRegion(wayS); this.FindMinRegion(wayS);
} }
} }
@ -97,7 +98,7 @@ export class RegionParse
let needFinds = new Set<Stand>(); let needFinds = new Set<Stand>();
standS.forEach(w => needFinds.add(w)); standS.forEach(w => needFinds.add(w));
//已经走过的 //已经走过的
let wayedStands = new Set<Stand>(); let passingStands = new Set<Stand>();
let regs: RegionRouteS = []; let regs: RegionRouteS = [];
@ -106,7 +107,7 @@ export class RegionParse
//找到最小站 //找到最小站
let minStand = this.FindMinStand(needFinds); let minStand = this.FindMinStand(needFinds);
//添加为已经计算 //添加为已经计算
wayedStands.add(minStand); passingStands.add(minStand);
needFinds.delete(minStand); needFinds.delete(minStand);
//逆时针搜索 //逆时针搜索
@ -131,12 +132,12 @@ export class RegionParse
wayS.forEach(w => wayS.forEach(w =>
{ {
//站点拓展,如果该地点没有被走过,那么加入到需要搜寻的站点表 //站点拓展,如果该地点没有被走过,那么加入到需要搜寻的站点表
if (!wayedStands.has(w)) if (!passingStands.has(w))
needFinds.add(w); needFinds.add(w);
}); });
for (let route of routeS) for (let route of routeS)
this.AddCuUsedCout(route.curve, 1); this.AddCuUsedCount(route.curve, 1);
} }
} }
} }
@ -163,11 +164,11 @@ export class RegionParse
minStand = stand; minStand = stand;
continue; continue;
} }
if (minStand.postion.y > stand.postion.y) if (minStand.position.y > stand.position.y)
{ {
minStand = stand; minStand = stand;
} }
else if (minStand.postion.y === stand.postion.y && minStand.postion.x > stand.postion.x) else if (minStand.position.y === stand.position.y && minStand.position.x > stand.position.x)
{ {
minStand = stand; minStand = stand;
} }
@ -175,8 +176,6 @@ export class RegionParse
return minStand; return minStand;
} }
//
/** /**
* this.m_NodeMap * this.m_NodeMap
* *
@ -199,13 +198,18 @@ export class RegionParse
{ {
s.routes.sort((r1, r2) => s.routes.sort((r1, r2) =>
{ {
let v1 = r1.to.postion.clone().sub(s.postion); let a1: number, a2: number;
let v2 = r2.to.postion.clone().sub(s.postion); if (equal(r1.curve.StartPoint, s.position))
let a1 = Math.atan2(v1.y, v1.x); a1 = angle(r1.curve.GetFistDeriv(0));
let a2 = Math.atan2(v2.y, v2.x); else
if (a1 < 0) a1 += Math.PI * 2; a1 = angle(r1.curve.GetFistDeriv(r1.curve.EndParam).negate());
if (a2 < 0) a2 += Math.PI * 2;
return a1 < a2 ? -1 : 1; if (equal(r2.curve.StartPoint, s.position))
a2 = angle(r2.curve.GetFistDeriv(0));
else
a2 = angle(r2.curve.GetFistDeriv(r1.curve.EndParam).negate());
return a1 - a2;
}) })
}) })
} }
@ -225,7 +229,7 @@ export class RegionParse
if (this.m_NodeMap.has(gp)) if (this.m_NodeMap.has(gp))
return this.m_NodeMap.get(gp); return this.m_NodeMap.get(gp);
let stand = { postion: gp, routes: [] }; let stand = { position: gp, routes: [] };
this.m_NodeMap.set(p, stand); this.m_NodeMap.set(p, stand);
return stand; return stand;
} }
@ -255,7 +259,7 @@ export class RegionParse
lastCurve: Curve, //上一条线索引 lastCurve: Curve, //上一条线索引
wayStands: Set<Stand>, //走过的站 wayStands: Set<Stand>, //走过的站
routeS: Set<Route>, //走过的路 routeS: Set<Route>, //走过的路
cuMaxiumCout: number, //允许最大的行走次数 cuMaximumCount: number, //允许最大的行走次数
) )
{ {
let routeCount = nowStand.routes.length; let routeCount = nowStand.routes.length;
@ -281,8 +285,8 @@ export class RegionParse
//下一站 //下一站
let route = nowStand.routes[index]; let route = nowStand.routes[index];
let usedCout = this.GetCuUsedCount(route.curve); let usedCount = this.GetCuUsedCount(route.curve);
if (usedCout >= cuMaxiumCout) if (usedCount >= cuMaximumCount)
continue; continue;
//如果发现这条路已经走回去,中途回路 //如果发现这条路已经走回去,中途回路
@ -307,7 +311,7 @@ export class RegionParse
return true; return true;
//在下个路口试着往前走 //在下个路口试着往前走
let isFind = this.FindRegion(firstS, route.to, route.curve, wayStands, routeS, cuMaxiumCout); let isFind = this.FindRegion(firstS, route.to, route.curve, wayStands, routeS, cuMaximumCount);
if (isFind) if (isFind)
return true; return true;
else else
@ -329,7 +333,7 @@ export class RegionParse
} }
return count; return count;
} }
private AddCuUsedCout(cu: Curve, add: number) private AddCuUsedCount(cu: Curve, add: number)
{ {
this.m_CountCu.set(cu, this.GetCuUsedCount(cu) + add); this.m_CountCu.set(cu, this.GetCuUsedCount(cu) + add);
} }

Loading…
Cancel
Save