!962 优化:排钻碰撞

pull/962/MERGE
ZoeLeeFZ 4 years ago committed by ChenX
parent fd52af163c
commit 22964ab019

@ -24,6 +24,9 @@ import { Entity } from "../../DatabaseServices/Entity/Entity";
import { Box3Ext } from "../../Geometry/Box";
import { ExtrudeHole } from "../../DatabaseServices/3DSolid/ExtrudeHole";
import { Hole } from "../../DatabaseServices/3DSolid/Hole";
import { ExtrudeSolid } from "../../DatabaseServices/Entity/Extrude";
import { Shape } from "../../DatabaseServices/Shape";
import { Contour } from "../../DatabaseServices/Contour";
export class DrawDrillingTool extends Singleton
{
@ -445,9 +448,24 @@ export class DrawDrillingTool extends Singleton
{
let mat = b.OCSInv.multiply(this.m_Face.OCS).multiply(MoveMatrix(new Vector3(dist)));
let bo = box.clone().applyMatrix4(mat) as Box3Ext;
return b.Grooves.some(g => g.BoundingBox.applyMatrix4(b.OCSInv).intersectsBox(bo));
return b.Grooves.some(g => this.IsDrillCollisionModeling(g, bo, b.OCSInv));
});
}
private IsDrillCollisionModeling(g: ExtrudeSolid, box: Box3, ocsInv: Matrix4)
{
let b1 = g.GetBoundingBoxInMtx(ocsInv);
let isBoxInt = b1.intersectsBox(box);
if (g.IsRect && g.Grooves.length === 0)
return isBoxInt;
if (!isBoxInt) return false;
let shape = g.Shape.ApplyMatrix(g.OCS).ApplyMatrix(ocsInv).Z0();
let rectLine = new Polyline().RectangleFrom2Pt(box.min.setZ(0), box.max.setZ(0));
let rectShape = new Shape(Contour.CreateContour(rectLine));
return rectShape.IntersectionBoolOperation(shape).length > 0;
}
// 分析当前排钻
private ParseDrillList(drills: ObjectId[][], woodPinss: ObjectId[][])
@ -611,7 +629,8 @@ export class DrawDrillingTool extends Singleton
{
if (isTK(refDr)) continue;
let bs2 = getDrillsBox(refDr, this.m_Face.OCSInv);
if (bs1[0].intersectsBox(bs2[0]) || (bs2[1] && bs1[1] && bs1[1].intersectsBox(bs2[1])))
//#I1FFNB
if (bs1.some(b => bs2.some(b2 => b2.intersectsBox(b))))
{
let offsetDist = this.m_Option.collsionDist;
this.MoveDrillEnts(ds, offsetDist, this.m_Face.IsPositiveFace ? 1 : -1);

@ -412,6 +412,10 @@ export class ExtrudeSolid extends Entity
this._Matrix.setPosition(this.Position.add(v));
}
}
get IsRect()
{
return this.isRect;
}
/**
*

@ -67,6 +67,7 @@ export class Shape
this._Outline.Curve.Z0();
for (let h of this._Holes)
h.Curve.Z0();
return this;
}
MatrixPlanarizere()

@ -52,7 +52,7 @@ export class Box3Ext extends Box3
interBox.max.setComponent(splitType, Math.max(this.min.getComponent(splitType), b2.min.getComponent(splitType)));
return interBox;
}
intersectsBox(box: this, fuzz = 1e-8): boolean
intersectsBox(box: Box3, fuzz = 1e-8): boolean
{
return IntersectsBox(this, box, fuzz);
}

Loading…
Cancel
Save