work on sheet metal workbench

This commit is contained in:
Val Erastov 2022-07-24 12:48:05 -07:00
parent d97281a286
commit d70a8a5be9
3 changed files with 45 additions and 36 deletions

View file

@ -17,6 +17,14 @@ interface smTabParams {
boolean: BooleanDefinition; boolean: BooleanDefinition;
} }
const ROLE_TO_SM_KIND = {
'base': 'FLAT/A',
'lid': 'FLAT/B',
'sweep': 'THICKNESS'
}
export const smTabOperation: OperationDescriptor<smTabParams> = { export const smTabOperation: OperationDescriptor<smTabParams> = {
id: 'SM_TAB', id: 'SM_TAB',
label: 'SM Tab', label: 'SM Tab',
@ -47,12 +55,7 @@ export const smTabOperation: OperationDescriptor<smTabParams> = {
extrusionVector = dir.normalize()._multiply(params.thickness).negate(); extrusionVector = dir.normalize()._multiply(params.thickness).negate();
} }
const productionAnalyzer = new FromSketchProductionAnalyzer(occFaces,"SM/FLAT/A", "SM/FLAT/B","SM/THICKNESS"); const productionAnalyzer = new FromSketchProductionAnalyzer(occFaces,"SM/FLAT/A", "SM/FLAT/B","SM/THICKNESS");
console.log(productionAnalyzer);
const tools = occFaces.map((faceRef, i) => { const tools = occFaces.map((faceRef, i) => {
@ -63,7 +66,19 @@ export const smTabOperation: OperationDescriptor<smTabParams> = {
}).map(shapeName => occ.io.getShell(shapeName, productionAnalyzer)); }).map(shapeName => occ.io.getShell(shapeName, productionAnalyzer));
return occ.utils.applyBooleanModifier(tools, params.boolean, face, [face]); const operationResult = occ.utils.applyBooleanModifier(tools, params.boolean, face, [face]);
operationResult.created.forEach(shell => {
shell.traverse(obj => {
if (obj.productionInfo?.role) {
obj.productionInfo.sheetMetal = {
kind: ROLE_TO_SM_KIND[obj.productionInfo.role]
}
}
})
});
return operationResult;
}, },

View file

@ -192,16 +192,10 @@ export class ExpectedOrderProductionAnalyzer extends BasicProductionAnalyzer {
export class FromSketchProductionAnalyzer extends BasicProductionAnalyzer { export class FromSketchProductionAnalyzer extends BasicProductionAnalyzer {
profiles: FaceRef[]; profiles: FaceRef[];
baseName: string;
sweepName: string;
lidName:string;
constructor(profiles: FaceRef[], baseName?: string, lidName?:string, sweepName?: string) { constructor(profiles: FaceRef[]) {
super(); super();
this.profiles = profiles; this.profiles = profiles;
this.baseName = baseName ? baseName : "BASE";
this.lidName = lidName ? lidName : "LID";
this.sweepName = sweepName? sweepName: "SWEEP";
for (let originFace of this.profiles) { for (let originFace of this.profiles) {
classifier.prepare(originFace.topoShape); classifier.prepare(originFace.topoShape);
} }
@ -223,9 +217,9 @@ export class FromSketchProductionAnalyzer extends BasicProductionAnalyzer {
if (faceToFaceClassification === Classification.EXACT) { if (faceToFaceClassification === Classification.EXACT) {
base = createdFace; base = createdFace;
base.data.id = `F:${this.baseName}[${wireId}]`; base.data.id = `F:BASE[${wireId}]`;
base.data.productionInfo = { base.data.productionInfo = {
role: this.baseName, role: 'base',
originatingWire: wireId originatingWire: wireId
} }
break; break;
@ -239,55 +233,55 @@ export class FromSketchProductionAnalyzer extends BasicProductionAnalyzer {
for (let createdEdge of createdShell.edges) { for (let createdEdge of createdShell.edges) {
if (classifier.classifyEdgeToEdge(profileEdge, createdEdge) !== Classification.UNRELATED) { if (classifier.classifyEdgeToEdge(profileEdge, createdEdge) !== Classification.UNRELATED) {
createdEdge.data.id = `E:${this.baseName}[${seg.id}]`; createdEdge.data.id = `E:BASE[${seg.id}]`;
createdEdge.data.productionInfo = { createdEdge.data.productionInfo = {
role: this.baseName, role: 'base',
originatingPrimitive: seg.id originatingPrimitive: seg.id
} }
let halfEdge = createdEdge.getHalfEdge(he => he?.loop?.face && he.loop.face !== base); let halfEdge = createdEdge.getHalfEdge(he => he?.loop?.face && he.loop.face !== base);
if (halfEdge) { if (halfEdge) {
let face = halfEdge.loop.face; let face = halfEdge.loop.face;
face.data.id = `F:${this.sweepName}[${seg.id}]`; face.data.id = `F:SWEEP[${seg.id}]`;
face.data.productionInfo = { face.data.productionInfo = {
role: this.sweepName, role: 'sweep',
originatingPrimitive: seg.id originatingPrimitive: seg.id
} }
halfEdge.prev.edge.data.id = `E:${this.sweepName}[${seg.id}/A]`; halfEdge.prev.edge.data.id = `E:SWEEP[${seg.id}/A]`;
halfEdge.prev.edge.data.productionInfo = { halfEdge.prev.edge.data.productionInfo = {
role: this.sweepName, role: 'sweep',
originatingPrimitive: seg.id + '/A' originatingPrimitive: seg.id + '/A'
} }
halfEdge.prev.vertexA.data.id = `V:${this.lidName}[${seg.id}/A]` halfEdge.prev.vertexA.data.id = `V:LID[${seg.id}/A]`
halfEdge.prev.vertexA.data.productionInfo = { halfEdge.prev.vertexA.data.productionInfo = {
role: this.lidName, role: 'lid',
originatingPrimitive: seg.id + '/A' originatingPrimitive: seg.id + '/A'
} }
halfEdge.prev.vertexB.data.id = `V:${this.baseName}[${seg.id}/A]` halfEdge.prev.vertexB.data.id = `V:BASE[${seg.id}/A]`
halfEdge.prev.vertexB.data.productionInfo = { halfEdge.prev.vertexB.data.productionInfo = {
role: this.baseName, role: 'base',
originatingPrimitive: seg.id + '/A' originatingPrimitive: seg.id + '/A'
} }
//Extruded not closed wire //Extruded not closed wire
if (!halfEdge.next.twin()) { if (!halfEdge.next.twin()) {
halfEdge.next.edge.data.id = `E:${this.sweepName}[${seg.id}/B]`; halfEdge.next.edge.data.id = `E:SWEEP[${seg.id}/B]`;
halfEdge.next.edge.data.productionInfo = { halfEdge.next.edge.data.productionInfo = {
role: this.sweepName, role: 'sweep',
originatingPrimitive: seg.id + '/B' originatingPrimitive: seg.id + '/B'
} }
halfEdge.next.vertexA.data.id = `V:${this.baseName}[${seg.id}/B]` halfEdge.next.vertexA.data.id = `V:BASE[${seg.id}/B]`
halfEdge.next.vertexA.data.productionInfo = { halfEdge.next.vertexA.data.productionInfo = {
role: this.baseName, role: 'base',
originatingPrimitive: seg.id + '/B' originatingPrimitive: seg.id + '/B'
} }
halfEdge.prev.vertexB.data.id = `V:${this.lidName}[${seg.id}/B]` halfEdge.prev.vertexB.data.id = `V:LID[${seg.id}/B]`
halfEdge.prev.vertexB.data.productionInfo = { halfEdge.prev.vertexB.data.productionInfo = {
role: this.lidName, role: 'lid',
originatingPrimitive: seg.id + '/B' originatingPrimitive: seg.id + '/B'
} }
} }
@ -298,9 +292,9 @@ export class FromSketchProductionAnalyzer extends BasicProductionAnalyzer {
for (let createdFace of createdShell.faces) { for (let createdFace of createdShell.faces) {
if (!createdFace.data.productionInfo) { if (!createdFace.data.productionInfo) {
createdFace.data.id = `F:${this.lidName}[${wireId}]`; createdFace.data.id = `F:LID[${wireId}]`;
createdFace.data.productionInfo = { createdFace.data.productionInfo = {
role: this.lidName role: 'lid'
} }
break; break;
} }
@ -315,9 +309,9 @@ export class FromSketchProductionAnalyzer extends BasicProductionAnalyzer {
} }
if (he) { if (he) {
const originatingPrimitive = he.loop.face.data.productionInfo.originatingPrimitive; const originatingPrimitive = he.loop.face.data.productionInfo.originatingPrimitive;
createdEdge.data.id = `E:${this.lidName}[${originatingPrimitive}]`; createdEdge.data.id = `E:LID[${originatingPrimitive}]`;
createdEdge.data.productionInfo = { createdEdge.data.productionInfo = {
role: this.lidName, role: 'lid',
originatingPrimitive originatingPrimitive
} }
} }

View file

@ -49,7 +49,7 @@ export abstract class MObject {
} }
get productionInfo() { get productionInfo() {
return this.topology.data?.productionInfo; return this.topology?.data?.productionInfo;
} }
} }