!2666 优化:圆弧板提取应用功能

pull/2667/MERGE
黄诗津 6 months ago committed by ChenX
parent 27131b5221
commit cb8d017390

@ -0,0 +1,18 @@
import { Factory } from "../../src/DatabaseServices/CADFactory";
import { CADFiler } from "../../src/DatabaseServices/CADFiler";
import { Database } from "../../src/DatabaseServices/Database";
import { TemplateRecord } from "../../src/DatabaseServices/Template/TemplateRecord";
test('圆弧板模板倒角半径为0', () =>
{
let json = `[11,102,1,2,1,0,0,1,"",2,2,0,0,1,"Board",10,2,100,0,1,2,0,[0,1,0,0,-1,0,0,0,0,0,1,0,800,0,0,1],101,0,1,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],0,0,1,3,800,449.2333530337135,18,true,"Polyline",10,2,0,0,0,7,0,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],0,0,1,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],0,0,1,2,4,[0,0],0,[449.2333530337135,0],0,[449.2333530337135,800],0,[0,800],0,true,0,3,0,0,0,0,0,19,0,"层板","","","","","",0,0,"三合一",2,0,"0","0","0","0","","","",4,"三合一","三合一","三合一","三合一",true,true,1,"1","1",0,0,0,0,0,0,0,true,0,0,null,0,0,"","","","",0,false,0,"Polyline",10,2,0,0,0,2,0,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],0,0,1,[1,0,0,0,0,1,0,0,0,0,1,0,-2914.643523520821,-28.28220860874053,0,1],0,0,1,2,4,[0,0],0,[183.64996103329167,0],0.41421356237309503,[260.03150412339346,76.3815430901018],0,[260.03150412339346,221.9850877696656],0,false,0,1,true,2,-1,0,6,6,2,0,0,0,3,0,1,119.97985,6,6,2,0,0,0,3,0,2,4,0,0,5,0,2,3,0,0,5,0,0,0,0,0,1,-1,0,2,5,0,0,1,"TemplateRecord",3,2,101,0,5,1,"圆弧板",0,0,0,11,"TemplateParam",2,"L","",800,null,"宽",1,null,null,null,0,false,"TemplateParam",2,"W","",260.031494140625,null,"深",1,null,null,null,0,false,"TemplateParam",2,"H","",221.985107421875,null,"高",1,null,null,null,0,false,"TemplateParam",2,"PX","",0,null,null,1,null,null,null,0,false,"TemplateParam",2,"PY","",0,null,null,1,null,null,null,0,false,"TemplateParam",2,"PZ","",0,null,null,1,null,null,null,0,false,"TemplateParam",2,"RX","",0,null,null,1,null,null,null,0,false,"TemplateParam",2,"RY","",0,null,null,1,null,null,null,0,false,"TemplateParam",2,"RZ","",0,null,null,1,null,null,null,0,false,"TemplateParam",2,"BH","",18,null,"板厚",1,null,null,null,0,false,"TemplateParam",2,"R","",0,null,"圆弧",1,null,null,null,1,"TemplateFilletAction",5,3,"动作1","R",null,1,100,0,0,0,1,-1.5,false,1,100,"",-1,1,2,6,0,0,0,1,2,7,0,0,1,"",2,8,0,0,0,2,9,0,0,0,1,2,10,0,0,1,"",2,11,0,0,0,0,1,2,12,0,0,5,0,0,null]`;
Factory(TemplateRecord);
let file = JSON.parse(json);
let f = new CADFiler(file);
let db = new Database().FileRead(f);
let template = db.TemplateTable.Objects[0].Root;
template.UpdateTemplateTree();
});

@ -29,6 +29,12 @@ export class Command_DrawArcBoard implements Command
if (pathRes.Status !== PromptStatus.OK) return;
let path1 = pathRes.Entity as Polyline;
await DrawArcBoard(path1);
}
}
export async function GetArcBoardParams(path1: Polyline)
{
UCSUtils.UCSMtx = path1.OCS;
path1 = ArcBoardBuild.OffsetPolyline(path1, 18);
@ -89,6 +95,16 @@ export class Command_DrawArcBoard implements Command
});
if (faceRes.Status !== PromptStatus.OK) return;
const params = { odir, faceRes, path2 };
return params;
}
export async function DrawArcBoard(path1: Polyline)
{
const params = await GetArcBoardParams(path1);
if (!params) return;
const { odir, faceRes, path2 } = params;
//4.选择要弯曲的板 或者创建个板
const brRes = await app.Editor.GetSelection({
Msg: "选择要弯曲的板:",
@ -245,7 +261,6 @@ export class Command_DrawArcBoard implements Command
br.FixArcSweepPathLength();
}
}
}
}
//like ExtrudeApplyContour

@ -5,13 +5,13 @@ import * as React from 'react';
import { MathUtils, Matrix4, Scene, Vector3 } from "three";
import { ArcBoardBuild } from "../../../Add-on/ArcBoard/ArcBoardBuild";
import { ArcBoardOptions } from "../../../Add-on/ArcBoard/ArcBoardFeeding";
import { Path2BoardPath } from "../../../Add-on/ArcBoard/DrawArcBoard";
import { GetArcBoardParams, Path2BoardPath } from "../../../Add-on/ArcBoard/DrawArcBoard";
import { ExtrudeApplyContour, SelectExtrudeContour, selectOutlinePosition } from "../../../Add-on/DrawBoard/DrawSpecialShapeBoardTool";
import { FaceDirection } from "../../../Add-on/DrawDrilling/DrillType";
import { app } from "../../../ApplicationServices/Application";
import { CheckObjectType } from "../../../Common/CheckoutVaildValue";
import { BigFaceSelectOption } from "../../../Common/CommonSelectOption";
import { ConverCircleToPolyline, curveLinkGroup } from "../../../Common/CurveUtils";
import { ConverCircleToPolyline, GetPointAtCurveDir, curveLinkGroup } from "../../../Common/CurveUtils";
import { DisposeThreeObj } from "../../../Common/Dispose";
import { ToplineUrls } from "../../../Common/HostUrl";
import { Log, LogType } from "../../../Common/Log";
@ -33,7 +33,7 @@ import { Polyline } from "../../../DatabaseServices/Entity/Polyline";
import { Region } from "../../../DatabaseServices/Entity/Region";
import { CommandWrap } from "../../../Editor/CommandMachine";
import { JigUtils } from "../../../Editor/JigUtils";
import { PromptStatus } from "../../../Editor/PromptResult";
import { PromptPointResult, PromptStatus } from "../../../Editor/PromptResult";
import { SelectBox, SelectType } from "../../../Editor/SelectBox";
import { CreateContours } from "../../../Geometry/CreateContour2";
import { ContourTreeNode } from "../../../Geometry/ExtrudeMeshGeomBuilder/ExtrudeEdgeGeometry2";
@ -72,7 +72,8 @@ const EDITOR_2D_PATH = "editor2dpath";
const EDITOR_3D_PATH = "editor3dpath";
@observer
export class BoardConfigModal extends React.Component<BoardConfigProps, {}>{
export class BoardConfigModal extends React.Component<BoardConfigProps, {}>
{
private pars = [["height", "显示高"], ["width", "显示宽"], ["thickness", "显示厚"],
];
private groovePars = [
@ -794,7 +795,7 @@ export class BoardConfigModal extends React.Component<BoardConfigProps, {}>{
build.ParseSweepCurves();
let pls = build.SweepCurves1.map(c => c.Clone());
let pl = Polyline.Combine(pls);
pl.Position = br.Position;
pl.ApplyMatrix(new Matrix4().makeRotationX(Math.PI / 2)).ApplyMatrix(br.OCS).ApplyMatrix(build.Rotate2OCSMtx);
let cu = JigUtils.Draw(pl);
await selectOutlinePosition(cu);
@ -807,9 +808,107 @@ export class BoardConfigModal extends React.Component<BoardConfigProps, {}>{
ChangeCurveBoard = async () =>
{
const DrawBoardByParams = async (br: Board, path1: Polyline, path2: Polyline, odir: number, faceRes: PromptPointResult) =>
{
//见光面方向
let fdir = GetPointAtCurveDir(path1, faceRes.Point);
let backPath: Polyline;
let brWidth: number;
//如果见光面方向等于偏移方向 则使用path1 作为背面路径
if (fdir === odir)
{
backPath = path1;
if (odir < 0)
backPath.Reverse();
brWidth = Number.parseFloat(FixedNotZero(path2.Length, 5));
}
else//反之
{
backPath = path2;
if (odir > 0)
backPath.Reverse();
brWidth = Number.parseFloat(FixedNotZero(path1.Length, 5));
}
enum Keep
{
none = 0,
br = 1,
path = 2,
}
let kp = Keep.none;
let keyRes = await app.Editor.GetKeyWords({
Msg: "请选择需要应用的尺寸",
KeyWordList: [
{
key: "1",
msg: "路径"
},
{
key: "2",
msg: "板"
}
]
});
if (keyRes.Status !== PromptStatus.Keyword) return;
kp = (keyRes.StringResult === "1") ? Keep.path : Keep.br;
let path = backPath.Clone();
let [angle, isRev] = Path2BoardPath(br, path);
if (isRev)
{
let dir = FaceDirection.Front;
if (backPath === path1)
{
path = path2.Clone();
dir = (fdir === odir) ? FaceDirection.Back : FaceDirection.Front;
}
else
{
path = path1.Clone();
dir = (fdir === odir) ? FaceDirection.Front : FaceDirection.Back;
}
br.SweepVisibleFace = dir;
//TODO:正确的计算见光面
[angle, isRev] = Path2BoardPath(br, path);
}
else
{
let dir: FaceDirection;
if (backPath === path1)
{
dir = (fdir === odir) ? FaceDirection.Front : FaceDirection.Back;
}
else
{
dir = (fdir === odir) ? FaceDirection.Back : FaceDirection.Front;
}
br.SweepVisibleFace = dir;
}
br.SetSweepPath(path, angle);
let length = br.ArcBuild.SweepLength;
let brLength = br.ParseBoardLengthInArcSweep();
if (kp === Keep.path || (length < brLength && path.IsClose))
br.FixContourByArcSweepPath();
else
br.FixArcSweepPathLength();
};
await CommandWrap(async () =>
{
let br = this.props.br;
const br = this.props.br;
app.Editor.ModalManage.Destory();
let brsRes = await app.Editor.GetSelection({
@ -855,22 +954,22 @@ export class BoardConfigModal extends React.Component<BoardConfigProps, {}>{
let paths = cuRes.SelectSet.SelectEntityList as Curve[];
let pl = curveLinkGroup(paths)[0]; //应用第一个曲线
let curves = Polyline.Combine(pl);
const path1 = Polyline.Combine(pl);
Path2BoardPath(br, curves);
curves.Move(curves.StartPoint.negate());
br.SetSweepPath(curves, br.SweepAngle);
br.FixArcSweepPathLength();
const params = await GetArcBoardParams(path1);
if (!params) return;
const { odir, faceRes, path2 } = params;
await DrawBoardByParams(br, path1, path2, odir, faceRes);
}
else
{
let pl = curveLinkGroup(cus)[0];
let curves = Polyline.Combine(pl).Clone();
const path1 = Polyline.Combine(pl).Clone();
Path2BoardPath(br, curves);
curves.Move(curves.StartPoint.negate());
br.SetSweepPath(curves, br.SweepAngle);
br.FixArcSweepPathLength();
const params = await GetArcBoardParams(path1);
if (!params) return;
const { odir, faceRes, path2 } = params;
await DrawBoardByParams(br, path1, path2, odir, faceRes);
}
}, "圆弧应用");
};

Loading…
Cancel
Save