!1086 功能:右侧造型面板加入槽加深和加宽,通槽自动加长

pull/1086/MERGE
ZoeLeeFZ 4 years ago committed by ChenX
parent 4ef725881e
commit 55f3e99f01

@ -8,18 +8,17 @@ import { Circle } from "../../DatabaseServices/Entity/Circle";
import { Curve } from "../../DatabaseServices/Entity/Curve";
import { Line } from "../../DatabaseServices/Entity/Line";
import { Polyline } from "../../DatabaseServices/Entity/Polyline";
import { HardwareCompositeEntity } from '../../DatabaseServices/Hardware/HardwareCompositeEntity';
import { Shape } from "../../DatabaseServices/Shape";
import { ShapeManager } from "../../DatabaseServices/ShapeManager";
import { Route } from "../../Geometry/CurveMap";
import { GetSideFaceMtx } from "../../Geometry/DrillParse/BoardGetFace";
import { angleTo, isParallelTo, MoveMatrix, XAxis } from "../../Geometry/GeUtils";
import { RegionParse } from "../../Geometry/RegionParse";
import { Production } from "../../Production/Product";
import { FaceDirection } from "../../UI/Store/BoardInterface";
import { BoolOpeartionType, isTargetCurInOrOnSourceCur } from "../BoolOperateUtils";
import { GetSealedBoardContour } from "../CalcEdgeSealing";
import { GetCurveToInDir, GetOffsetCurves, OptimizeToolPath } from "./OptimizeToolPath";
import { FixIndex } from "../../Nest/Common/Util";
/**
*
@ -158,7 +157,7 @@ export class FeedingToolPath extends Singleton
let modelings = br.BoardModeling;
let allModeling = GetModelingFromCustomDrill(br);
modelings.push(...allModeling.modeling);
let cus = this.CalcPath(modelings, br.Thickness);
let cus = this.CalcPath(modelings, br);
let outline = br.ContourCurve as Polyline;
let dir = Math.sign(outline.Area2);
@ -180,7 +179,7 @@ export class FeedingToolPath extends Singleton
sideOutlines.push(pl);
}
cus.push(...this.CalcPath(allModeling.sideModeling, br.Height));
cus.push(...this.CalcPath(allModeling.sideModeling, br));
//加入板件轮廓
cus.unshift(br.ContourCurve.Clone());
if (cus.length === 1)
@ -210,17 +209,18 @@ export class FeedingToolPath extends Singleton
*
* TODO:===ys
*/
CalcPath(modelings: IModeling[], thickness: number): Curve[]
CalcPath(modelings: IModeling[], br: Board): Curve[]
{
let cus: Curve[] = [];
for (let m of modelings)
{
cus.push(...this.GetModelFeedPath(thickness, m));
cus.push(...this.GetModelFeedPath(br, m));
}
return cus;
}
GetModelFeedPath(brThickness: number, m: IModeling): Curve[]
GetModelFeedPath(br: Board, m: IModeling): Curve[]
{
const brThickness = br.Thickness;
let cus: Curve[] = [];
let { shape, thickness, knifeRadius, addLen, addWidth, addDepth } = m;
if (!knifeRadius) knifeRadius = 3;
@ -228,6 +228,7 @@ export class FeedingToolPath extends Singleton
shape = shape.Clone();
shape.Z0();
this.GrooveAddSize(shape, addLen, addWidth);
this.HandleThoughGroove(br, shape, knifeRadius);
if (thickness >= brThickness)
{
@ -323,12 +324,97 @@ export class FeedingToolPath extends Singleton
let modelings = br.BoardModeling;
for (let i = 0; i < modelings.length; i++)
{
let cus = this.GetModelFeedPath(br.Thickness, modelings[i]);
let cus = this.GetModelFeedPath(br, modelings[i]);
if (cus.length === 0)
errorIndexs.push(i);
}
return errorIndexs;
}
HandleThoughGroove(br: Board, shape: Shape, knifeRadius: number)
{
let brCon = br.ContourCurve;
let outline = shape.Outline.Curve;
if (outline instanceof Circle) return;
let cus = outline.Explode();
let hasChange = false;
for (let i = 0; i < cus.length; i++)
{
let c = cus[i];
if (c instanceof Line)
{
let mp = c.Midpoint;
if (brCon.PtOnCurve(mp))
{
hasChange = true;
let cs = c.GetOffsetCurves(knifeRadius);
cus[i] = cs[0];
let fline = cus[FixIndex(i - 1, cus.length)];
if (fline instanceof Line)
{
let intPts = fline.IntersectWith(cs[0], 3);
if (intPts.length === 0)
{
console.error("未知错误情况");
return;
}
fline.EndPoint = intPts[0];
cs[0].StartPoint = intPts[0];
}
else
{
let newLine = new Line(fline.EndPoint, cs[0].StartPoint);
if (i === 0)
{
cus.push(newLine);
}
else
{
cus.splice(i, 0, newLine);
i++;
}
}
let backLine = cus[FixIndex(i + 1, cus.length)];
if (backLine instanceof Line)
{
let intPts = backLine.IntersectWith(cs[0], 3);
if (intPts.length === 0)
{
console.error("未知错误情况");
return;
}
backLine.StartPoint = intPts[0];
cs[0].EndPoint = intPts[0];
}
else
{
let newLine = new Line(cs[0].EndPoint, backLine.StartPoint);
if (i + 1 === cus.length)
{
cus.unshift(newLine);
}
else
{
cus.splice(i + 1, 0, newLine);
i++;
}
}
}
}
}
if (hasChange)
{
let con = Contour.CreateContour(Polyline.Combine(cus));
if (con)
shape.Outline = con;
else
console.error("错误");
}
}
}
export function GetModelingFromCustomDrill(br: Board)
{

@ -368,7 +368,6 @@ export namespace Production
export function GetBoardModelingData(br: Board, offsetTanslation: Vector3)
{
const tool = FeedingToolPath.GetInstance() as FeedingToolPath;
const thickness = br.Thickness;
const getModelings = (ms: IModeling[], isSide: boolean): IModelingData[] =>
{
@ -381,7 +380,7 @@ export namespace Production
continue;
if (!isSide)
m.shape.ApplyMatrix(MoveMatrix(offsetTanslation.clone().negate()));
let feeding = tool.GetModelFeedPath(thickness, m).map(ConverToPolylineAndSplitArc);
let feeding = tool.GetModelFeedPath(br, m).map(ConverToPolylineAndSplitArc);
if (feeding.length > 0)
data.push({
feeding,

@ -188,12 +188,12 @@ export class BoardConfigModal extends React.Component<BoardConfigProps, {}>{
store.modelingStore.ChangeModelingValue(color - 1, data);
}
let cu = JigUtils.Draw(data.shape.Outline.Curve.Clone().ApplyMatrix(br.OCS));
let cu = JigUtils.Draw(data.shape.Outline.Curve.Clone().Z0().ApplyMatrix(br.OCS));
cu.ColorIndex = color;
moveCus.push(cu);
for (let c of data.shape.Holes)
{
cu = JigUtils.Draw(c.Curve.Clone().ApplyMatrix(br.OCS));
cu = JigUtils.Draw(c.Curve.Clone().Z0().ApplyMatrix(br.OCS));
cu.ColorIndex = color;
moveCus.push(cu);
}
@ -368,6 +368,8 @@ export class BoardConfigModal extends React.Component<BoardConfigProps, {}>{
groove.ContourCurve = shape.Outline.Curve;
groove.KnifeRadius = cd.knifeRad;
groove.GroovesAddLength = cd.addLen;
groove.GroovesAddWidth = cd.addWidth;
groove.GroovesAddDepth = cd.addDepth;
for (let hole of shape.Holes)
{
let holeSolid = new ExtrudeSolid();

@ -1,5 +1,5 @@
import { Button, Card, Checkbox, Classes, Intent, IOptionProps, Popover, Position, Radio, RadioGroup, HTMLSelect } from '@blueprintjs/core';
import { observable, toJS } from 'mobx';
import { observable, toJS, action } from 'mobx';
import { observer } from 'mobx-react';
import * as React from 'react';
import { DirUrl, TemplateUrls } from '../../../Common/HostUrl';
@ -40,12 +40,12 @@ export class DrillTypeCom extends React.Component<{ store: DrillStore; }, { type
this.handleUpdate();
}
};
private handleUpdate = () =>
private handleUpdate = action(() =>
{
const store = this.props.store;
observable(store.rules).replace(store.drillConfig.get(store.type));
store.ChangeRules(0);
};
});
private renderRadiosType = () =>
{
const store = this.props.store;
@ -125,7 +125,7 @@ export class SelectDrillTemp extends React.Component<{ store: DrillStore; }, {}>
@observable drillingDirList: IOptionProps[] = [];
private _dirCache: Map<string, IOptionProps[]> = new Map();
private _fun: Function;
async UNSAFE_componentWillMount()
async UNSAFE_componentWillMount()
{
await this.getDirList();
this._fun = end(this.props.store, this.props.store.ChangeRules, async () =>

@ -9,7 +9,7 @@
#RightPanel .bp3-tab-panel {
width: 100%;
overflow: auto;
padding: 10px;
padding: 5px;
}
#RightPanel .bp3-tab-panel.tab-unstyle {
@ -32,7 +32,7 @@
&>li>label {
text-align: center;
flex: 1;
width: 20%;
box-shadow: 0 0 0 0 rgba(19, 124, 189, 0),
0 0 0 0 rgba(19, 124, 189, 0),
0 0 0 0 rgba(19, 124, 189, 0),
@ -52,9 +52,18 @@
span,
input,
&>div {
width: 20%;
width: 15%;
margin: 0;
}
&>span:first-child,
&>label:first-child {
line-height: 2;
width: 10%;
padding: 0;
text-align: center;
display: inline-block;
}
}
}

@ -15,6 +15,8 @@ export interface IModelingItem
dir: FaceDirection;
knifeRad: number;
addLen: number;
addWidth: number;
addDepth: number;
}
@inject("store")
@ -34,6 +36,8 @@ export class ModelingComponent extends React.Component<{ store?: RightPanelStore
<Label></Label>
<Label></Label>
<Label></Label>
<Label></Label>
<Label></Label>
</li>
{
uiData.map((item, index) =>
@ -46,22 +50,15 @@ export class ModelingComponent extends React.Component<{ store?: RightPanelStore
if (k === "dir")
{
return (
<HTMLSelect
options={
[{
label: "正", value: FaceDirection.Front
},
{
label: "反", value: FaceDirection.Back
}]
}
value={item[k]}
<select value={data[index].dir}
onChange={e =>
{
data[index].dir = safeEval(e.target.value) as FaceDirection;
item[k] = safeEval(e.target.value);
data[index].dir = Number(e.target.value) as FaceDirection;
}}
/>
>
<option value={FaceDirection.Front}></option>
<option value={FaceDirection.Back}></option>
</select>
);
}
else if (k !== "color")

@ -1,5 +1,5 @@
import { observable, toJS } from 'mobx';
import { observable, toJS, action } from 'mobx';
import { app } from '../../ApplicationServices/Application';
import { EBoardKeyList } from '../../Common/BoardKeyList';
import { CheckObjectType, CheckoutValid } from '../../Common/CheckoutVaildValue';
@ -171,6 +171,7 @@ export class BoardStore extends Singleton implements IConfigStore
];
return newConfig;
}
@action
UpdateOption(cof: IConfigOption)
{
if (!cof.option)
@ -192,6 +193,7 @@ export class BoardStore extends Singleton implements IConfigStore
this.InitDrillType();
this.InitRectDrillData(cof.processData.highDrill);
}
@action
protected UpdateRemarks(cof: IConfigOption)
{
this.remarks.forEach(d =>

@ -1,4 +1,4 @@
import { observable, toJS } from "mobx";
import { observable, toJS, action } from "mobx";
import { CheckObjectType, CheckoutValid } from "../../Common/CheckoutVaildValue";
import { DataAdapter } from "../../Common/DataAdapter";
import { IConfigOption } from "../Components/Board/UserConfig";
@ -184,6 +184,7 @@ export class DrillStore extends BoardStore
newConfig.ruleMap = toJS(config, { exportMapsAsObjects: false });
return newConfig;
}
@action
UpdateOption(cof: IConfigOption)
{
this.drillConfig.clear();

@ -1,30 +1,23 @@
import { observable, toJS } from "mobx";
import { observable, toJS, action } from "mobx";
import { IModelingItem } from "../../Components/RightPanel/ModelingComponent";
import { Modify } from "../../../Common/TypeOperator";
import { IModeling } from "../../../DatabaseServices/Entity/Board";
import { FixedNotZero } from "../../../Common/Utils";
import { FaceDirection } from "../BoardInterface";
import { FaceDirection, IUiOption } from "../BoardInterface";
import { IConfigOption } from "../../Components/Board/UserConfig";
import { IConfigStore } from "../BoardStore";
type IUIModeiling = Modify<IModelingItem, {
color: string;
height: string;
knifeRad: string;
addLen: string;
}>;
export class ModelingStore implements IConfigStore
{
@observable configName = "默认";
@observable configsNames: string[] = [];
@observable modelingItems: IModelingItem[] = [];
@observable UIModelingItems: IUIModeiling[] = [];
@observable UIModelingItems: IUiOption<IModelingItem>[] = [];
isUpdate = true;
constructor()
{
this.InitModelingItems();
}
@action
InitModelingItems()
{
this.modelingItems.length = 0;
@ -34,29 +27,42 @@ export class ModelingStore implements IConfigStore
this.UIModelingItems.push({
color: (i + 1).toString(),
height: "0",
dir: FaceDirection.Front,
dir: "0",
knifeRad: "3",
addLen: "0"
addLen: "0",
addWidth: "0",
addDepth: "0",
});
this.modelingItems.push({
color: i + 1,
height: 0,
dir: FaceDirection.Front,
knifeRad: 3,
addLen: 0
addLen: 0,
addWidth: 0,
addDepth: 0,
});
}
}
@action
ChangeModelingValue(index: number, data: IModeling)
{
this.modelingItems[index].height = data.thickness;
this.UIModelingItems[index]["height"] = FixedNotZero(data.thickness, 2);
this.UIModelingItems[index].height = FixedNotZero(data.thickness, 2);
this.modelingItems[index].dir = data.dir;
this.UIModelingItems[index]["dir"] = data.dir;
this.modelingItems[index].knifeRad = data.knifeRadius;
this.UIModelingItems[index]["knifeRad"] = data.knifeRadius.toString();
this.UIModelingItems[index].knifeRad = data.knifeRadius.toString();
this.modelingItems[index].addLen = data.addLen;
this.UIModelingItems[index]["addLen"] = data.addLen.toString();
this.UIModelingItems[index].addLen = data.addLen.toString();
this.modelingItems[index].addWidth = data.addWidth;
this.UIModelingItems[index].addWidth = data.addWidth.toString();
this.modelingItems[index].addDepth = data.addDepth;
this.UIModelingItems[index].addDepth = data.addDepth.toString();
}
InitOption()
{
@ -69,6 +75,7 @@ export class ModelingStore implements IConfigStore
newConfig.option = toJS(this.modelingItems);
return newConfig;
}
@action
UpdateOption(cof: IConfigOption)
{
observable(this.modelingItems).replace(cof.option as IModelingItem[]);
@ -77,6 +84,8 @@ export class ModelingStore implements IConfigStore
this.UIModelingItems[i].height = this.modelingItems[i].height.toString();
this.UIModelingItems[i].knifeRad = this.modelingItems[i].knifeRad.toString();
this.UIModelingItems[i].addLen = this.modelingItems[i].addLen.toString();
this.UIModelingItems[i].addWidth = this.modelingItems[i].addWidth?.toString() ?? "0";
this.UIModelingItems[i].addDepth = this.modelingItems[i].addDepth?.toString() ?? "0";
}
}
}

Loading…
Cancel
Save