添加Join方法. 修改Trim代码. 重构点选的选择集.

pull/59/head
ChenX 7 years ago
parent 50a87fd8a8
commit df5ce0ff62

@ -64,6 +64,12 @@ exports[`圆弧偏移 15`] = `3.141592653589793`;
exports[`圆弧偏移 16`] = `25`;
exports[`圆弧切割参数重复 1`] = `3`;
exports[`圆弧合并 1`] = `1`;
exports[`圆弧合并 2`] = `0.5`;
exports[`最近点 1`] = `
Vector3 {
"x": 0,

@ -97,6 +97,13 @@ test("圆弧的切割2", () =>
expect(arc.GetSplitCurves([0.2, 0.5, 0.8]).length).toBe(4);
});
test('圆弧切割参数重复', () =>
{
let arc = new Arc(new Vector3(5, 0, 0), 5, Math.PI, 0);
let arcs = arc.GetSplitCurves([0, 1e-8, 0.5, 1, 1 + 1e-8]);
expect(arcs.length).toMatchSnapshot();
});
test("圆弧延伸-反向", () =>
{
let arc = new Arc(new Vector3(5, 0, 0), 5, Math.PI, 0);
@ -182,3 +189,57 @@ test('最近点', () =>
expect(arc.GetClosestPointTo(new Vector3(8, 0, 0), true)/*?*/).toMatchSnapshot();//0,0,0.
});
test('圆弧合并', () =>
{
let arc = new Arc(new Vector3(), 1, 0, 1);
let arc2 = new Arc(new Vector3(), 1, 3, 4);
//成了一个圆
expect(arc.Join(arc2)).toBeTruthy();
expect(equaln(arc.AllAngle, Math.PI * 2)).toBeTruthy();
arc = new Arc(new Vector3(), 1, 0, 1).Reverse();
arc2 = new Arc(new Vector3(), 1, 0.5, 0.2).Reverse();
expect(arc.Join(arc2)).toBeFalsy();
//终点捅了进去
arc = new Arc(new Vector3(), 1, 0, 1).Reverse();
arc2 = new Arc(new Vector3(), 1, 0.5, 5).Reverse();
expect(arc.Join(arc2)).toBeTruthy();
expect(arc.StartAngle).toMatchSnapshot();
expect(arc.EndAngle).toMatchSnapshot();
//包含.
arc = new Arc(new Vector3(), 1, 0, 1).Reverse();
arc2 = new Arc(new Vector3(), 1, 5, 3);
expect(arc.Join(arc2)).toBeTruthy();
arc.Reverse();
expect(arc.StartAngle).toBe(0);
expect(arc.EndAngle).toBe(1);
//起点捅了进去
arc2 = new Arc(new Vector3(), 1, 3, 0.5).Reverse();
expect(arc.Join(arc2)).toBeTruthy();
expect(arc.StartAngle).toBe(0);
expect(arc.EndAngle).toBe(0.5);
//被包含
arc = new Arc(new Vector3(), 1, 0, 1).Reverse();
arc2 = new Arc(new Vector3(), 1, 0.5, 0.8);
expect(arc.Join(arc2)).toBeTruthy();
arc.Reverse();
expect(arc.StartAngle).toBe(0.5);
expect(arc.EndAngle).toBe(0.8);
//容差允许
arc = new Arc(new Vector3(), 1, 0, 1);
arc2 = new Arc(new Vector3(), 1, 0.5, 1e-6).Reverse();
expect(arc.Join(arc2)).toBeTruthy();
expect(arc.StartAngle).toBe(0.5);
expect(arc.EndAngle).toBe(1);
});

@ -157,28 +157,46 @@ test('拉伸直线的夹点', () =>
test('直线合并', () =>
{
let l1 = new Line(new Vector3(0, 0, 0), new Vector3(0, 5, 0));
let l2 = new Line(new Vector3(0, 10, 0), new Vector3(0, 5, 0));
let l1 = new Line(new Vector3(0), new Vector3(10));
let l2 = new Line(new Vector3(0), new Vector3(0));
//终点对终点
let jOk = l1.Join(l2);
expect(jOk).toBeTruthy();
//L1 -----------
//L2 --
l2.StartPoint = new Vector3(-5);
l2.EndPoint = new Vector3(-3);
expect(l1.Join(l2)).toBeFalsy();
//包含
l1 = new Line(new Vector3(0, 15, 0), new Vector3(0, 5, 0));
//L1 -----------
//L2 -----------
l2.StartPoint = new Vector3(-5);
l2.EndPoint = new Vector3(5);
expect(l1.Join(l2)).toBeTruthy();
//终点对起点
l1 = new Line(new Vector3(0, 15, 0), new Vector3(0, 10, 0));
//L1 -----------
//L2 ----
l2.StartPoint = new Vector3(2);
l2.EndPoint = new Vector3(5);
expect(l1.Join(l2)).toBeTruthy();
//起点对终点
l1 = new Line(new Vector3(0, 5, 0), new Vector3(0, 15, 0));
//L1 -----------
//L2 ----
l2.StartPoint = new Vector3(9);
l2.EndPoint = new Vector3(12);
expect(l1.Join(l2)).toBeTruthy();
//不平行1
l1 = new Line(new Vector3(1, 5, 0), new Vector3(0, 15, 0));
//L1 -----------
//L2 ----
l2.StartPoint = new Vector3(15);
l2.EndPoint = new Vector3(12);
expect(l1.Join(l2)).toBeFalsy();
//L1 -----------
//L2 ---------------------
l2.StartPoint = new Vector3(-2);
l2.EndPoint = new Vector3(12);
expect(l1.Join(l2)).toBeTruthy();
});

@ -27,7 +27,7 @@
"@types/react": "^16.3.5",
"@types/react-dom": "^16.0.4",
"@types/stats.js": "^0.17.0",
"@types/three": "^0.91.6",
"@types/three": "^0.91.7",
"@types/webpack": "^4.1.3",
"@types/webpack-env": "^1.13.4",
"add-asset-html-webpack-plugin": "^2.1.3",

@ -22,7 +22,6 @@ export class DrawLine implements Command
let drawLines: Line[] = [];
while (true)
{
app.m_Editor.m_CommandStore.Prompt("请输入点2:");
ptRes = await app.m_Editor.GetPoint({
Msg: "请输入点2:",
BasePoint: ptLast,

@ -1,22 +1,16 @@
import { Vector3 } from 'three';
import { app } from '../ApplicationServices/Application';
import { Curve } from '../DatabaseServices/Curve';
import { Polyline } from '../DatabaseServices/Polyline';
import { Command } from '../Editor/CommandMachine';
import { PromptStatus } from '../Editor/PromptResult';
import { SelectBox } from '../Editor/SelectBox';
import { SelectPick } from '../Editor/SelectPick';
import { SelectSet, SelectType } from '../Editor/SelectSet';
import { SelectSet } from '../Editor/SelectSet';
import { RenderType } from '../GraphicsSystem/Enum';
import { IntersectOption } from '../GraphicsSystem/IntersectWith';
import { PathPlugin } from 'awesome-typescript-loader/dist/paths-plugin';
import { Circle } from '../DatabaseServices/Circle';
//TODO: 需要全部计算完成后在打断.
//并且计算打断后需要更新裁剪对象.
export class Command_Trim implements Command
{
async exec(ss: SelectSet)
@ -65,34 +59,30 @@ export class Command_Trim implements Command
let paramS = inPts.map(p => cu.GetParamAtPoint(p));
let splitCus = cu.GetSplitCurves(paramS);
if (splitCus.length <= 1)
{
cu.Erase();
continue;
}
else
{
//测试代码 绘制出被打断的曲线
// for (let cu of splitCus)
// {
// app.m_Database.ModelSpace.Append(cu)
// }
}
if (s instanceof SelectBox)
{
let set = s;
splitCus = splitCus.filter(cu => { return !set.IntersectObject(cu.Draw(RenderType.Wireframe)) });
splitCus.forEach(cu => app.m_Database.ModelSpace.Append(cu));
}
//TODO:圆的连接出了点问题
let cuStart: Curve;
for (let cu of splitCus)
{
if (!cuStart)
cuStart = cu;
else
if (!cuStart.Join(cu))
{
app.m_Database.ModelSpace.Append(cuStart);
cuStart = cu;
}
}
if (cuStart)
app.m_Database.ModelSpace.Append(cuStart);
}
cu.Erase();
}
}
app.m_Editor.UpdateScreen();
app.m_Viewer.m_GripScene.Clear();
app.m_Editor.m_SelectCtrl.Cancel();
}
}
}

@ -0,0 +1,106 @@
/**
* ,
*
* @param {Array<any>} arr
* @param {*} el
*/
export function arrayRemove<T>(arr: Array<T>, el: T): Array<T>
{
let j = 0;
for (let i = 0, l = arr.length; i < l; i++)
{
if (arr[i] !== el)
{
arr[j++] = arr[i];
}
}
arr.length = j;
return arr;
}
export function arrayRemoveOnce<T>(arr: Array<T>, el: T): Array<T>
{
let j = 0;
let isErase = false;
for (let i = 0, l = arr.length; i < l; i++)
{
if (isErase || arr[i] !== el)
{
arr[j++] = arr[i];
}
else isErase = true;
}
arr.length = j;
return arr;
}
/**
*
*
* @param {(e: T) => boolean} checkFuntion
* @memberof Array
*/
export function arrayRemoveIf<T>(arr: Array<T>, checkFuntion: (e: T) => boolean): Array<T>
{
let j = 0;
for (let i = 0, l = arr.length; i < l; i++)
{
if (!checkFuntion(arr[i]))
{
arr[j++] = arr[i];
}
}
arr.length = j;
return arr;
}
export function arrayFirst<T>(arr: Array<T>): T
{
return arr[0];
}
export function arrayLast<T>(arr: Array<T>): T
{
return arr[arr.length - 1];
}
export function arraySortByNumber<T>(arr: Array<T>): Array<T>
{
arr.sort(sortNumberCompart);
return arr;
}
/**
*
*
* @param {(e1, e2) => boolean} [checkFuction]
*/
export function arrayRemoveDuplicateBySort<T>(arr: Array<T>, checkFuction?: (e1, e2) => boolean): Array<T>
{
checkFuction = checkFuction || checkEqual;
let j = 1;
for (let i = 1, l = arr.length; i < l; i++)
{
if (!checkFuction(arr[i], arr[j - 1]))
{
arr[j++] = arr[i];
}
}
arr.length = j;
return arr;
}
function sortNumberCompart(e1, e2)
{
return e1 - e2;
}
function checkEqual(e1, e2): boolean
{
return e1 === e2;
}

@ -1 +0,0 @@
//导入其他js模块

@ -21,18 +21,6 @@ export function isNum(s: string)
{
return !isNaN(parseFloat(s));
}
export function ArrayRemove(arr: Array<any>, el: any)
{
let index = arr.indexOf(el);
if (index > -1)
arr.splice(index, 1)
}
export function Last(arr: Array<any>)
{
return arr[arr.length - 1];
}
export function clamp(value, min, max)
{

@ -1,10 +1,11 @@
import * as THREE from 'three';
import { Box3, Matrix4, ShapeGeometry, Vector3, Object3D, Vector2 } from 'three';
import { Box3, Matrix4, Object3D, ShapeGeometry, Vector2, Vector3 } from 'three';
import { arraySortByNumber } from '../Common/ArrayExt';
import { ColorMaterial } from '../Common/ColorPalette';
import { rotateLine, Vec3DTo2D, Vec2DTo3D, getCircleCenter } from '../Common/CurveUtils';
import { equal, equaln, polar, angle, midPoint, angleTo2Pi } from '../Geometry/GeUtils';
import { Vec2DTo3D, getCircleCenter } from '../Common/CurveUtils';
import { angle, angleTo2Pi, equaln, midPoint, polar, equal } from '../Geometry/GeUtils';
import { RenderType } from '../GraphicsSystem/Enum';
import { IntersectOption, IntersectArcAndArc, IntersectCircleAndArc, IntersectLineAndArc, reverseIntersectOption, IntersectPolylineAndCurve } from '../GraphicsSystem/IntersectWith';
import { IntersectArcAndArc, IntersectCircleAndArc, IntersectLineAndArc, IntersectOption, IntersectPolylineAndCurve, reverseIntersectOption } from '../GraphicsSystem/IntersectWith';
import { Factory } from './CADFactory';
import { CADFile } from './CADFile';
import { Circle } from './Circle';
@ -235,39 +236,23 @@ export class Arc extends Curve
GetAngleAtParam(param: number)
{
return this.m_StartAngle + param * this.AllAngle * (this.m_Clockwise ? -1 : 1);
return angleTo2Pi(this.m_StartAngle + param * this.AllAngle * (this.m_Clockwise ? -1 : 1));
}
GetSplitCurves(param: number[] | number): Arc[]
{
//切割参数列表
let params: number[];
if (param instanceof Array)
{
params = param.filter(param => !isNaN(param) && (param > 0 && param < 1));
params.push(0, 1);
params.sort();
}
else
{
params = [0, param, 1];
}
let params = this.SplitParamSort(param);
//角度列表
let ans = params.map(p => this.GetAngleAtParam(p));
//返回圆弧表
let arcs: Arc[] = [];
for (let i = 0; i < ans.length - 1; i++)
{
if (!equaln(ans[i], ans[i + 1]))
{
let arc = this.Clone() as Arc;
arc.StartAngle = ans[i];
arc.EndAngle = ans[i + 1];
arcs.push(arc);
}
let arc = this.Clone() as Arc;
arc.StartAngle = ans[i];
arc.EndAngle = ans[i + 1];
arcs.push(arc);
}
return arcs;
}
@ -296,11 +281,62 @@ export class Arc extends Curve
this.Update();
}
Reverse()
Join(cu: Curve): boolean
{
if (cu instanceof Arc)
{
if (equal(cu.Center, this.m_Center) && equaln(cu.m_Radius, this.m_Radius))
{
let [sa, ea] = [cu.StartAngle, cu.EndAngle];
if (cu.m_Clockwise != this.m_Clockwise)
[sa, ea] = [ea, sa];
let allAn = this.AllAngle;
let saAllan = this.ComputeAnlge(sa);
let eaAllan = this.ComputeAnlge(ea);
if (eaAllan < saAllan && saAllan < allAn)
{
//圆
this.EndAngle = this.GetAngleAtParam(-1e-6);
return true;
}
//使用按负方向去计算它的参数
let saParam: number;
if (saAllan > allAn)
saParam = (saAllan - Math.PI * 2) / allAn;
else
saParam = saAllan / allAn;
let eaParam: number;
if (eaAllan > saAllan && saAllan > allAn)
eaParam = (eaAllan - Math.PI * 2) / allAn;
else
eaParam = eaAllan / allAn;
let pMin = Math.max(0, saParam);
let pMax = Math.min(1, eaParam);
if (pMin <= pMax + 1e-5)
{
if (saParam < 0)
this.StartAngle = sa;
if (eaParam > 1)
this.EndAngle = ea;
return true;
}
}
}
return false;
}
Reverse(): this
{
this.WriteAllObjectRecord();
this.m_Clockwise = !this.m_Clockwise;
[this.m_StartAngle, this.m_EndAngle] = [this.m_EndAngle, this.m_StartAngle];
return this;
}
IntersectWith(curve: Curve, intType: IntersectOption): Vector3[]

@ -1,26 +1,18 @@
import * as THREE from 'three';
import { Box3, EllipseCurve, Geometry, Matrix4, Vector3, Object3D } from 'three';
import { Box3, EllipseCurve, Geometry, Matrix4, Object3D, Vector3 } from 'three';
import { arrayFirst } from '../Common/ArrayExt';
import { ColorMaterial } from '../Common/ColorPalette';
import { rotateLine } from '../Common/CurveUtils';
import { clamp } from '../Common/Utils';
import { Arc } from '../DatabaseServices/Arc';
import { angle, angleTo, equaln, polar, angleTo2Pi } from '../Geometry/GeUtils';
import { angle, equaln, polar } from '../Geometry/GeUtils';
import { RenderType } from '../GraphicsSystem/Enum';
import
{
IntersectOption,
IntersectCircleAndArc,
IntersectCircleAndCircle,
IntersectLineAndCircle,
reverseIntersectOption,
IntersectPolylineAndCurve,
} from '../GraphicsSystem/IntersectWith';
import { IntersectCircleAndArc, IntersectCircleAndCircle, IntersectLineAndCircle, IntersectOption, IntersectPolylineAndCurve, reverseIntersectOption } from '../GraphicsSystem/IntersectWith';
import { Factory } from './CADFactory';
import { CADFile } from './CADFile';
import { Curve } from './Curve';
import { Line } from './Line';
import { Polyline } from './Polyline';
import { clamp } from '../Common/Utils';
@Factory
export class Circle extends Curve
@ -118,24 +110,14 @@ export class Circle extends Curve
GetSplitCurves(param: number[] | number)
{
let anglelist: number[];
if (param instanceof Array)
{
if (param.length < 2) return [];
param.sort((a, b) => a - b);
anglelist = [];
for (let p of param)
{
if (!isNaN(p) && p >= 0 && p <= 1)
anglelist.push(Math.PI * 2 * p);
}
anglelist.push(anglelist[0]);
anglelist.reverse();
}
else
{
return [];
}
let params = this.SplitParamSort(param);
params.shift();
params.pop();
if (params.length < 2) return [];
params.push(arrayFirst(params));
params.reverse();
let anglelist = params.map(param => Math.PI * 2 * param);
let curvelist = new Array<Arc>();
for (let i = 0; i < anglelist.length - 1; i++)

@ -1,5 +1,5 @@
import { Mesh, Object3D, Vector3 } from 'three';
import { arrayRemoveDuplicateBySort, arraySortByNumber } from '../Common/ArrayExt';
import { ColorMaterial } from '../Common/ColorPalette';
import { equal } from '../Geometry/GeUtils';
import { RenderType } from '../GraphicsSystem/Enum';
@ -7,7 +7,6 @@ import { IntersectOption } from '../GraphicsSystem/IntersectWith';
import { Factory } from './CADFactory';
import { Entity } from './Entity';
export enum ExtendType
{
/**
@ -84,6 +83,21 @@ export abstract class Curve extends Entity
* @memberof Curve
*/
GetSplitCurves(param: number[] | number): Array<Curve> { return; }
protected SplitParamSort(param: number[] | number): number[]
{
//切割参数列表
let params: number[];
if (param instanceof Array)
{
params = param.filter(param => this.ParamOnCurve(param));
params.push(0, this.EndParam);
arraySortByNumber(params);
arrayRemoveDuplicateBySort(params);
}
else
params = [0, param, 1];
return params;
}
Extend(newParam: number) { }
/**
* 线线,true
@ -94,7 +108,7 @@ export abstract class Curve extends Entity
Join(cu: Curve): boolean { return false };
//翻转曲线.首尾调换.
Reverse() { };
Reverse(): this { return this; };
//点在曲线上
PtOnCurve(pt: Vector3): boolean

@ -20,6 +20,7 @@ import { CADFile } from './CADFile';
import { Circle } from './Circle';
import { Curve } from './Curve';
import { Polyline } from './Polyline';
import { arraySortByNumber } from '../Common/ArrayExt';
@Factory
export class Line extends Curve
@ -151,31 +152,10 @@ export class Line extends Curve
{
return this.GetDistAtParam(this.GetParamAtPoint(pt));
}
GetSplitCurves(params: number[] | number)
GetSplitCurves(param: number[] | number)
{
let pts = new Array<Vector3>();
pts.push(this.StartPoint);
if (typeof params === 'number')
{
if (params > 0 && params < 1)
{
pts.push(this.GetPointAtParam(params));
}
}
else
{
params = params.filter(param => param > 1e-8 && param < 1 - 1e-8);
params.sort((d1, d2) =>
{
return d1 < d2 ? -1 : 1;
});
for (let param of params)
{
pts.push(this.GetPointAtParam(param));
}
}
pts.push(this.EndPoint);
let params = this.SplitParamSort(param);
let pts = params.map(param => this.GetPointAtParam(param));
let ret = new Array<Curve>();
if (pts.length > 2)
{
@ -226,29 +206,27 @@ export class Line extends Curve
if (!isParallelTo(this.GetFistDeriv(0), cu.GetFistDeriv(0)))
return false;
let param1 = this.GetParamAtPoint(cu.StartPoint);
let param2 = this.GetParamAtPoint(cu.EndPoint);
let [param1, param2] = arraySortByNumber([this.GetParamAtPoint(cu.StartPoint), this.GetParamAtPoint(cu.EndPoint)]);
if (this.PtOnCurve(cu.StartPoint))
let pmin = Math.max(0, param1);
let pmax = Math.min(1, param2);
if (pmin < pmax)
{
if (!this.ParamOnCurve(param2))
this.Extend(param2);
return true;
}
else if (this.PtOnCurve(cu.EndPoint))
{
if (!this.ParamOnCurve(param1))
if (param1 < 0)
this.Extend(param1);
if (param2 > 1)
this.Extend(param2);
return true;
}
}
return false;
};
Reverse()
Reverse(): this
{
this.WriteAllObjectRecord();
[this.m_StartPoint, this.m_EndPoint] = [this.m_EndPoint, this.m_StartPoint];
return this;
}
GetOffsetCurves(offsetDist: number): Array<Curve>

@ -1,10 +1,10 @@
import { HistorycRecord } from './HistorycRecord';
import { ArrayRemove } from '../Common/Utils';
import { Factory } from './CADFactory';
import { CADFile } from './CADFile';
import { RemoveObjectData } from './RemoveObjectData';
import { CADObject } from './CADObject';
import { CreateObjectData } from './CreateObjectData';
import { arrayRemoveOnce } from '../Common/ArrayExt';
//对象集合.
@ -46,7 +46,7 @@ export class ObjectCollection<T extends CADObject> extends CADObject
}
Remove(obj: T)
{
ArrayRemove(this.objectCol, obj);
arrayRemoveOnce(this.objectCol, obj);
obj.Erase();
obj.GoodBye();
let undoRec = this.UndoRecord();

@ -1,28 +1,21 @@
import * as THREE from 'three';
import { Geometry, Matrix4, Object3D, Vector2, Vector3, Box3, Interpolant } from 'three';
import { Box3, Geometry, Matrix4, Object3D, Vector2, Vector3 } from 'three';
import { CreateBoardUtil } from '../ApplicationServices/mesh/createBoard';
import { arrayLast } from '../Common/ArrayExt';
import { ColorMaterial } from '../Common/ColorPalette';
import
{
rotateLine,
Vec2DTo3D,
Vec3DTo2D,
ExtendDir,
getDeterminant,
} from '../Common/CurveUtils';
import { equal, equaln, updateGeometry, angle } from '../Geometry/GeUtils';
import { Vec2DTo3D, Vec3DTo2D, getDeterminant, rotateLine } from '../Common/CurveUtils';
import { FixIndex } from '../Common/Utils';
import { equal, equaln, updateGeometry } from '../Geometry/GeUtils';
import { RenderType } from '../GraphicsSystem/Enum';
import { IntersectOption, IntersectPolylineAndCurve } from '../GraphicsSystem/IntersectWith';
import { angleTo } from './../Geometry/GeUtils';
import { Arc } from './Arc';
import { Factory } from './CADFactory';
import { CADFile } from './CADFile';
import { Circle } from './Circle';
import { Curve, ExtendType } from './Curve';
import { angleTo } from './../Geometry/GeUtils';
import { IntersectOption, IntersectLineAndCircle, IntersectLAndL, IntersectPolylineAndCurve } from '../GraphicsSystem/IntersectWith';
import { intercept } from 'mobx';
import { Line } from './Line';
import { Arc } from './Arc';
import { FixIndex, ArrayRemove, Last } from '../Common/Utils';
import { Circle } from './Circle';
export interface PolylineProps
{
@ -43,10 +36,10 @@ export class Polyline extends Curve
}
//翻转曲线,首尾调换
Reverse()
Reverse(): this
{
if (this.m_LineData.length === 0)
return;
return this;
this.WriteAllObjectRecord();
let pts = [];
@ -68,6 +61,8 @@ export class Polyline extends Curve
this.m_LineData.push({ pt: pts[i], bul: buls[i] });
}
this.Update();
return this;
}
set LineData(data: PolylineProps[])
{
@ -110,7 +105,7 @@ export class Polyline extends Curve
//闭合且起点不等于终点
if (this.m_ClosedMark &&
!this.m_LineData[0].pt.equals(Last(this.m_LineData).pt))
!this.m_LineData[0].pt.equals(arrayLast(this.m_LineData).pt))
{
return this.m_LineData.length;
}
@ -124,7 +119,7 @@ export class Polyline extends Curve
let startV = this.m_LineData[i];
let endV = this.m_LineData[i + 1];
area += getDeterminant(startV.pt, endV.pt) / 2
area += getDeterminant(startV.pt, endV.pt) / 2;
if (startV.bul != 0)
{
@ -134,7 +129,7 @@ export class Polyline extends Curve
}
if (!this.IsClose)
{
let startV = this.m_LineData[this.m_LineData.length - 1];
let startV = arrayLast(this.m_LineData);
let endV = this.m_LineData[0];
area += getDeterminant(startV.pt, endV.pt) / 2
}
@ -1206,7 +1201,7 @@ export class Polyline extends Curve
}
//闭合且起点不等于终点
if (this.m_ClosedMark &&
!this.m_LineData[0].pt.equals(Last(this.m_LineData).pt))
!this.m_LineData[0].pt.equals(arrayLast(this.m_LineData).pt))
{
pts.push(pts[0].clone());
buls.push(buls[0]);

@ -1,10 +1,10 @@
import { Matrix4, Vector3 } from 'three';
import * as THREE from 'three';
import { ArrayRemove } from '../Common/Utils';
import { Viewer } from '../GraphicsSystem/Viewer';
import { PreViewer } from '../GraphicsSystem/PreViewer';
import { Matrix4, Vector3 } from 'three';
import { arrayRemoveOnce } from '../Common/ArrayExt';
import { Entity } from '../DatabaseServices/Entity';
import { PreViewer } from '../GraphicsSystem/PreViewer';
import { Viewer } from '../GraphicsSystem/Viewer';
//
@ -134,7 +134,7 @@ export class SelectSet
{
if (this.m_IdSelect.has(obj.id))
{
ArrayRemove(this.m_IdSelect.get(obj.id).m_SelectList, obj);
arrayRemoveOnce(this.m_IdSelect.get(obj.id).m_SelectList, obj);
this.m_IdSelect.delete(obj.id);
}
}

@ -2,9 +2,10 @@ import { observer } from 'mobx-react';
import * as React from 'react';
import { end } from 'xaop';
import { app } from '../../../ApplicationServices/Application';
import { arrayRemoveOnce } from '../../../Common/ArrayExt';
import { KeyWord } from '../../../Common/InputState';
import { KeyBoard } from '../../../Common/KeyEnum';
import { ArrayRemove, FixIndex, isLetter, isNum } from '../../../Common/Utils';
import { FixIndex, isLetter, isNum } from '../../../Common/Utils';
import './InputHint.css';
interface InputHintProps
@ -162,7 +163,7 @@ export class InputHint extends React.Component<InputHintProps, InputHitState>
if (!this.props.isCmdIng)
{
let hcmdList = this.state.historyCmdList;
ArrayRemove(hcmdList, cmd);
arrayRemoveOnce(hcmdList, cmd);
hcmdList.push(cmd);
}
this.props.handleInputCallback(cmd);

@ -1,10 +1,11 @@
import { autorun } from 'mobx';
import { arrayRemoveOnce } from '../../Common/ArrayExt';
import { KeyBoard } from '../../Common/KeyEnum';
import { ArrayRemove, FixIndex } from '../../Common/Utils';
import { FixIndex } from '../../Common/Utils';
import { DownPanelStore } from '../Store/DownPanelStore';
import { DynamicInput } from './DynamicInputBase';
//所有的动态输入框的管理类
export class DynamicInputManage
{
@ -75,7 +76,7 @@ export class DynamicInputManage
}
public RemoveDynamicInput(dynInput: DynamicInput)
{
ArrayRemove(this.inputCollection, dynInput);
arrayRemoveOnce(this.inputCollection, dynInput);
}
//注册事件
private RegisterEvent()

@ -1,5 +1,4 @@
import { ArrayRemove } from '../../Common/Utils';
import { arrayRemoveOnce } from '../../Common/ArrayExt';
/**
* Layout onsize
*
@ -32,14 +31,14 @@ class LayoutOnsizeEventManage
arr.push(callback);
return () =>
{
ArrayRemove(arr, callback);
arrayRemoveOnce(arr, callback);
}
}
remove(id: string, callback)
{
if (this.callbackList.has(id))
{
ArrayRemove(this.callbackList.get(id), callback);
arrayRemoveOnce(this.callbackList.get(id), callback);
}
}
}

Loading…
Cancel
Save