!254 避免排钻穿透造型

Merge pull request !254 from ZoeLeeFZ/optDrawdrilling
pull/254/MERGE
ZoeLeeFZ 6 years ago committed by ChenX
parent eff3026ff1
commit 5be69b8080

@ -5,13 +5,14 @@ import { Singleton } from "../../Common/Singleton";
import { operationExpReg } from "../../Common/Utils"; import { operationExpReg } from "../../Common/Utils";
import { GangDrill } from "../../DatabaseServices/3DSolid/GangDrill"; import { GangDrill } from "../../DatabaseServices/3DSolid/GangDrill";
import { Board } from "../../DatabaseServices/Board"; import { Board } from "../../DatabaseServices/Board";
import { Circle } from "../../DatabaseServices/Circle";
import { ObjectId } from "../../DatabaseServices/ObjectId"; import { ObjectId } from "../../DatabaseServices/ObjectId";
import { CollisionDetection } from "../../Geometry/DrillParse/CollisionDetection"; import { CollisionDetection } from "../../Geometry/DrillParse/CollisionDetection";
import { Face } from "../../Geometry/DrillParse/Face"; import { Face } from "../../Geometry/DrillParse/Face";
import { cZAxis, equaln, MoveMatrix } from "../../Geometry/GeUtils"; import { cZAxis, equaln, MoveMatrix } from "../../Geometry/GeUtils";
import { FaceDirection } from "../../UI/Store/BoardInterface";
import { DrillingOption, SpacingType } from "../../UI/Store/drillInterface"; import { DrillingOption, SpacingType } from "../../UI/Store/drillInterface";
import { DrillStore } from "../../UI/Store/DrillStore"; import { DrillStore } from "../../UI/Store/DrillStore";
import { FaceDirection } from "../../UI/Store/BoardInterface";
export class DrawDrillingTool extends Singleton export class DrawDrillingTool extends Singleton
{ {
@ -209,12 +210,12 @@ export class DrawDrillingTool extends Singleton
for (let dist of this.m_MoveDistList) for (let dist of this.m_MoveDistList)
{ {
if (this.CheckModelingCollision(this.m_Face.m_InterBoard, this.drillEnts[0], dist))
continue;
if (this.drillEnts.length === 3) if (this.drillEnts.length === 3)
{ {
let pos = this.drillEnts[2].Position if (this.CheckModelingCollision(this.m_Face.m_LocalBoard, this.drillEnts[2], dist))
.applyMatrix4(MoveMatrix(new Vector3(dist)))
.applyMatrix4(this.m_Face.OCS);
if (this.CheckModelingCollision(pos))
continue; continue;
} }
//新的排钻列表 //新的排钻列表
@ -233,22 +234,20 @@ export class DrawDrillingTool extends Singleton
this.ParseDrillList(newDrillentList); this.ParseDrillList(newDrillentList);
} }
//排钻避开造型 //排钻避开造型
private CheckModelingCollision(pos: Vector3) private CheckModelingCollision(br: Board, en: GangDrill, dist: number)
{ {
let br = this.m_Face.m_LocalBoard; let mat = br.OCSInv.multiply(this.m_Face.OCS).multiply(MoveMatrix(new Vector3(dist)));
let modelings = br.BoardModeling; let modelings = br.BoardModeling;
pos.applyMatrix4(br.OCSInv); let pos = en.Position.applyMatrix4(mat);
for (let m of modelings) for (let m of modelings)
{ {
if (m.thickness === br.Thickness) let cu = m.shape.Outline.Curve;
pos.setZ(cu.Position.z);
//排钻在造型内或者和造型碰撞
if (cu.PtInCurve(pos) || cu.IntersectWith(new Circle(pos, en.Radian), 0).length > 0)
{ {
//TODO:暂先处理挖空的造型 return m.thickness === br.Thickness || en.Height > br.Thickness - m.thickness;
let cu = m.shape.Outline.Curve;
pos.setZ(cu.Position.z);
if (cu.PtInCurve(pos))
{
return true;
}
} }
} }
return false; return false;

@ -24,6 +24,10 @@ export class GangDrill extends Solid3D
drill.m_Shape = new Shape(Contour.CreateContour([new Circle(new Vector3(), rad)])); drill.m_Shape = new Shape(Contour.CreateContour([new Circle(new Vector3(), rad)]));
return drill; return drill;
} }
get Height()
{
return this.m_Height;
}
set Height(v: number) set Height(v: number)
{ {
this.m_Height = v; this.m_Height = v;

Loading…
Cancel
Save