|
|
@ -13,10 +13,10 @@ import { boardUVGenerator, boardUVGenerator2 } from '../../Geometry/BoardUVGener
|
|
|
|
import { BufferGeometryUtils } from '../../Geometry/BufferGeometryUtils';
|
|
|
|
import { BufferGeometryUtils } from '../../Geometry/BufferGeometryUtils';
|
|
|
|
import { equaln, equalv3, IdentityMtx4, XAxis, XAxisN, YAxis, YAxisN, ZAxis, ZeroVec } from '../../Geometry/GeUtils';
|
|
|
|
import { equaln, equalv3, IdentityMtx4, XAxis, XAxisN, YAxis, YAxisN, ZAxis, ZeroVec } from '../../Geometry/GeUtils';
|
|
|
|
import { PointShapeUtils } from '../../Geometry/PointShapeUtils';
|
|
|
|
import { PointShapeUtils } from '../../Geometry/PointShapeUtils';
|
|
|
|
import { GetBoardHighSeal, GetBoardSealingCurves, HandleRectBoardSealingData } from '../../GraphicsSystem/CalcEdgeSealing';
|
|
|
|
import { GetBoardHighSeal, GetBoardSealingCurves, SetBoardTopDownLeftRightSealData } from '../../GraphicsSystem/CalcEdgeSealing';
|
|
|
|
import { RenderType } from '../../GraphicsSystem/RenderType';
|
|
|
|
import { RenderType } from '../../GraphicsSystem/RenderType';
|
|
|
|
import { VData2Curve, VKnifToolPath } from '../../GraphicsSystem/ToolPath/VKnifToolPath';
|
|
|
|
import { VData2Curve, VKnifToolPath } from '../../GraphicsSystem/ToolPath/VKnifToolPath';
|
|
|
|
import { BoardOpenDir, BoardProcessOption, BoardType, ComposingType, DrillType, FaceDirection, IHighSealedItem, LinesType } from '../../UI/Store/BoardInterface';
|
|
|
|
import { BoardOpenDir, BoardProcessOption, BoardType, ComposingType, DrillType, FaceDirection, LinesType } from '../../UI/Store/BoardInterface';
|
|
|
|
import { CylinderHole } from '../3DSolid/CylinderHole';
|
|
|
|
import { CylinderHole } from '../3DSolid/CylinderHole';
|
|
|
|
import { ExtrudeHole } from '../3DSolid/ExtrudeHole';
|
|
|
|
import { ExtrudeHole } from '../3DSolid/ExtrudeHole';
|
|
|
|
import { AutoRecord } from '../AutoRecord';
|
|
|
|
import { AutoRecord } from '../AutoRecord';
|
|
|
@ -34,10 +34,10 @@ import { ExtrudeContourCurve, ExtrudeSolid } from './Extrude';
|
|
|
|
import { Polyline } from './Polyline';
|
|
|
|
import { Polyline } from './Polyline';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//排钻配置名是合法的
|
|
|
|
//排钻配置名是合法的 可用的
|
|
|
|
function IsValidDriName(name: string): boolean
|
|
|
|
function IsValidDriName(name: string): boolean
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return name === DrillType.None || name === DrillType.More || HostApplicationServices.DrillConfigs.has(name);
|
|
|
|
return name === DrillType.None || HostApplicationServices.DrillConfigs.has(name);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
export interface IModeling
|
|
|
|
export interface IModeling
|
|
|
@ -753,66 +753,100 @@ export class Board extends ExtrudeSolid
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 板件的轮廓,在板件坐标系中的表现方式.
|
|
|
|
* 板件的轮廓,在板件坐标系中的表现方式.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
get ContourCurve()
|
|
|
|
override get ContourCurve()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return super.ContourCurve;
|
|
|
|
return super.ContourCurve;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
set ContourCurve(cu: ExtrudeContourCurve)
|
|
|
|
|
|
|
|
|
|
|
|
//设置新的板件轮廓,这里重载为了保持正确的排钻封边映射
|
|
|
|
|
|
|
|
override set ContourCurve(newContour: ExtrudeContourCurve)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
//标识是否被初始化
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 保持排钻边和封边数据对应正确性
|
|
|
|
|
|
|
|
* (2x2种可能性)
|
|
|
|
|
|
|
|
* 矩形->矩形
|
|
|
|
|
|
|
|
* 矩形->异形
|
|
|
|
|
|
|
|
* 异形->异形
|
|
|
|
|
|
|
|
* 异形->矩形
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//上下左右排钻属性(在矩形时生效)
|
|
|
|
TempRectHoleOption.up = undefined;
|
|
|
|
TempRectHoleOption.up = undefined;
|
|
|
|
|
|
|
|
ParseBoardRectHoleType(this, TempRectHoleOption);//分析旧的上下左右排钻
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let oldHightSealCurves = GetBoardSealingCurves(this);//旧的封边轮廓
|
|
|
|
|
|
|
|
let hightSealDatas = GetBoardHighSeal(this, oldHightSealCurves);//旧的封边数据
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let oldContour = this.ContourCurve;//旧的轮廓
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let defaultDrillType = this._BoardProcessOption.drillType;
|
|
|
|
|
|
|
|
if (!IsValidDriName(defaultDrillType) && this._BoardProcessOption.highDrill)
|
|
|
|
|
|
|
|
for (let name of this._BoardProcessOption.highDrill)
|
|
|
|
|
|
|
|
if (IsValidDriName(name))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
defaultDrillType = name;
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!IsValidDriName(defaultDrillType))
|
|
|
|
|
|
|
|
defaultDrillType = HostApplicationServices.DrillConfigs.size ? HostApplicationServices.DrillConfigs.entries().next().value[0] : DrillType.None;
|
|
|
|
|
|
|
|
|
|
|
|
let needRename = !IsValidDriName(this.BoardProcessOption.drillType);
|
|
|
|
super.ContourCurve = newContour;//设置新的轮廓
|
|
|
|
if (!this.contourCurve || cu.EndParam !== this.contourCurve.EndParam || needRename)
|
|
|
|
|
|
|
|
|
|
|
|
//保持排钻边属性
|
|
|
|
|
|
|
|
if (this.isRect && TempRectHoleOption.up)//矩形->矩形
|
|
|
|
|
|
|
|
SetBrHighHoleTypeFromRectHoleType(this, TempRectHoleOption);//直接应用旧的矩形数据
|
|
|
|
|
|
|
|
else//异形->矩形 矩形->异形 异形->异形
|
|
|
|
{
|
|
|
|
{
|
|
|
|
let defaultType = this._BoardProcessOption.drillType;
|
|
|
|
let indexMap: number[] = [];
|
|
|
|
if (needRename)
|
|
|
|
|
|
|
|
|
|
|
|
for (let i = 0; i < newContour.EndParam; i++)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
defaultType = HostApplicationServices.DrillConfigs.size ? HostApplicationServices.DrillConfigs.entries().next().value[0] : "不排";
|
|
|
|
let p = newContour.GetPointAtParam(i + 0.5);
|
|
|
|
this._BoardProcessOption.drillType = defaultType;
|
|
|
|
|
|
|
|
|
|
|
|
let cp = oldContour.GetClosestPointTo(p, false);
|
|
|
|
|
|
|
|
let cparam = oldContour.GetParamAtPoint2(cp);
|
|
|
|
|
|
|
|
indexMap.push(Math.floor(cparam));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
this._BoardProcessOption.highDrill = Array(cu.EndParam).fill(defaultType);
|
|
|
|
|
|
|
|
|
|
|
|
let highDrill: string[] = [];
|
|
|
|
|
|
|
|
for (let index of indexMap)
|
|
|
|
|
|
|
|
highDrill.push(this._BoardProcessOption.highDrill[index] ?? defaultDrillType);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this._BoardProcessOption.highDrill = highDrill;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (this.isRect)
|
|
|
|
|
|
|
|
ParseBoardRectHoleType(this, TempRectHoleOption);
|
|
|
|
|
|
|
|
else//之前不是异形,现在也不是异形时,对排钻边和封边进行映射,避免错误
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
let size = cu.BoundingBox.getSize(new Vector3);
|
|
|
|
|
|
|
|
let isRect = equaln(size.x * size.y, cu.Area, 0.1);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!isRect)
|
|
|
|
this._BoardProcessOption.highSealed.length = 0;
|
|
|
|
{
|
|
|
|
//保持封边属性
|
|
|
|
let indexMap: number[] = [];
|
|
|
|
if (this.isRect)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
SetBoardTopDownLeftRightSealData(this, hightSealDatas, oldHightSealCurves);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else//变成了异形
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
let newhightSealCurves = GetBoardSealingCurves(this);
|
|
|
|
|
|
|
|
|
|
|
|
for (let i = 0; i < cu.EndParam; i++)
|
|
|
|
for (let i = 0; i < newhightSealCurves.length; i++)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
let p = cu.GetPointAtParam(i + 0.5);
|
|
|
|
let newC = newhightSealCurves[i];
|
|
|
|
|
|
|
|
let p = newC.GetPointAtParam(newC.EndParam * 0.5);
|
|
|
|
|
|
|
|
|
|
|
|
let cp = this.contourCurve.GetClosestPointTo(p, false);
|
|
|
|
let closesIndex = 0;
|
|
|
|
let cparam = this.contourCurve.GetParamAtPoint2(cp);
|
|
|
|
let closesDistance = Infinity;
|
|
|
|
indexMap.push(Math.floor(cparam));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let highDrill = [];
|
|
|
|
for (let j = 0; j < oldHightSealCurves.length; j++)
|
|
|
|
let highSealed = [];
|
|
|
|
{
|
|
|
|
for (let index of indexMap)
|
|
|
|
let oldC = oldHightSealCurves[j];
|
|
|
|
|
|
|
|
let d = oldC.GetClosestPointTo(p, false).distanceTo(p);
|
|
|
|
|
|
|
|
if (d < closesDistance)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
highDrill.push(this._BoardProcessOption.highDrill[index] ?? this._BoardProcessOption.drillType);
|
|
|
|
closesIndex = j;
|
|
|
|
highSealed.push(this._BoardProcessOption.highSealed[index] ?? 0);
|
|
|
|
closesDistance = d;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
this._BoardProcessOption.highDrill = highDrill;
|
|
|
|
|
|
|
|
this._BoardProcessOption.highSealed = highSealed;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this._BoardProcessOption.highSealed.push(hightSealDatas[closesIndex]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
super.ContourCurve = cu;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (this.isRect && TempRectHoleOption.up)
|
|
|
|
|
|
|
|
SetBrHighHoleTypeFromRectHoleType(this, TempRectHoleOption);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Explode()
|
|
|
|
Explode()
|
|
|
@ -832,9 +866,7 @@ export class Board extends ExtrudeSolid
|
|
|
|
|
|
|
|
|
|
|
|
this.WriteAllObjectRecord();
|
|
|
|
this.WriteAllObjectRecord();
|
|
|
|
|
|
|
|
|
|
|
|
let highSeals: IHighSealedItem[];
|
|
|
|
let highSeals = GetBoardHighSeal(this, GetBoardSealingCurves(this));
|
|
|
|
// if (this.isRect)
|
|
|
|
|
|
|
|
highSeals = GetBoardHighSeal(this, GetBoardSealingCurves(this));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let a = Math.atan2(x.y, x.x);
|
|
|
|
let a = Math.atan2(x.y, x.x);
|
|
|
|
|
|
|
|
|
|
|
@ -858,8 +890,7 @@ export class Board extends ExtrudeSolid
|
|
|
|
if (this.contourCurve instanceof Polyline)
|
|
|
|
if (this.contourCurve instanceof Polyline)
|
|
|
|
this.contourCurve.UpdateOCSTo(IdentityMtx4);
|
|
|
|
this.contourCurve.UpdateOCSTo(IdentityMtx4);
|
|
|
|
|
|
|
|
|
|
|
|
// if (this.isRect)
|
|
|
|
SetBoardTopDownLeftRightSealData(this, highSeals);//这里不可以用缓存的曲线 否则分析错误,必须重新开始分析曲线
|
|
|
|
HandleRectBoardSealingData(this, highSeals);//这里不可以用缓存的曲线 否则分析错误,必须重新开始分析曲线
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.Update();
|
|
|
|
this.Update();
|
|
|
|
return this;
|
|
|
|
return this;
|
|
|
@ -896,8 +927,8 @@ export class Board extends ExtrudeSolid
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (!this.Id)
|
|
|
|
if (!this.Id)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// super.ApplyMirrorMatrix(m); //这个变更导致镜像错误 因为实体没有正常的被更新. 所以需要注意的是,如果需要镜像变更,需要给实体一个id!!!
|
|
|
|
// super.ApplyMirrorMatrix(m); //这个变更导致镜像错误 因为实体没有正常的被更新(更新下面的属性?). 所以需要注意的是,如果需要镜像变更,需要给实体一个id!!!
|
|
|
|
return this;
|
|
|
|
return this;//为了优化性能,在jig模式下不去计算封边排钻等属性,不重绘板
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
this.ContourCurve;//因为下面翻转孔面的代码,所以必须初始化这个
|
|
|
|
this.ContourCurve;//因为下面翻转孔面的代码,所以必须初始化这个
|
|
|
@ -941,7 +972,7 @@ export class Board extends ExtrudeSolid
|
|
|
|
this.BoardProcessOption.highSealed = highSeals;
|
|
|
|
this.BoardProcessOption.highSealed = highSeals;
|
|
|
|
|
|
|
|
|
|
|
|
if (!hasSplitSize)//&& this.isRect
|
|
|
|
if (!hasSplitSize)//&& this.isRect
|
|
|
|
HandleRectBoardSealingData(this, highSeals);
|
|
|
|
SetBoardTopDownLeftRightSealData(this, highSeals);
|
|
|
|
//重新构建SpaceOCS
|
|
|
|
//重新构建SpaceOCS
|
|
|
|
this._SpaceOCS.multiplyMatrices(this._Matrix, new Matrix4().getInverse(this.RotateMat));
|
|
|
|
this._SpaceOCS.multiplyMatrices(this._Matrix, new Matrix4().getInverse(this.RotateMat));
|
|
|
|
|
|
|
|
|
|
|
|