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

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 res = [];
o.forEach(r => { res.push(r.to.postion.toArray()) })
o.forEach(r => { res.push(r.to.position.toArray()) })
return res;
});
let data2 = alg.m_RegionsOutline.map(o =>
{
let res = [];
o.forEach(r => { res.push(r.to.postion.toArray()) })
o.forEach(r => { res.push(r.to.position.toArray()) })
return res;
});

6
package-lock.json generated

@ -7443,7 +7443,7 @@
},
"js-tokens": {
"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=",
"dev": true
},
@ -8545,7 +8545,7 @@
},
"nan": {
"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=",
"optional": true
},
@ -14055,7 +14055,7 @@
},
"webworker-threads": {
"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=",
"optional": true,
"requires": {

@ -206,7 +206,7 @@ export class DrawRegTest implements Command
function createReg(r: Set<Route>)
{
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);
app.m_Database.ModelSpace.Append(re);
}

@ -36,20 +36,24 @@ export class Region extends Entity
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();
let geometry = new ShapeGeometry(this.m_Shape, 60);
let mesh = new THREE.Mesh(geometry, ColorMaterial.GetLineMaterial(this.ColorIndex));
this.m_DrawEntity.set(renderType, mesh);
mesh.userData = this;
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()
{
this.m_Shape = new THREE.Shape();

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

Loading…
Cancel
Save