mirror of
https://github.com/xibyte/jsketcher
synced 2026-02-14 19:33:46 +01:00
Updated SMtab command to use FromSketchProductionAnalyzer and modified FromSketchProductionAnalyzer to allow defining the labeling of faces and edges for sheet metal use.
This commit is contained in:
parent
73de12c99c
commit
7e39a9bd62
2 changed files with 46 additions and 46 deletions
|
|
@ -1,11 +1,12 @@
|
|||
import {roundValueForPresentation as r} from 'cad/craft/operationHelper';
|
||||
import {MFace} from "cad/model/mface";
|
||||
import {ApplicationContext} from "context";
|
||||
import {EntityKind} from "cad/model/entities";
|
||||
import {BooleanDefinition} from "cad/craft/schema/common/BooleanDefinition";
|
||||
import {UnitVector} from "math/vector";
|
||||
import {OperationDescriptor} from "cad/craft/operationPlugin";
|
||||
import {FromSketchProductionAnalyzer} from "cad/craft/production/productionAnalyzer";
|
||||
import { roundValueForPresentation as r } from 'cad/craft/operationHelper';
|
||||
import { MFace } from "cad/model/mface";
|
||||
import { ApplicationContext } from "context";
|
||||
import { EntityKind } from "cad/model/entities";
|
||||
import { BooleanDefinition } from "cad/craft/schema/common/BooleanDefinition";
|
||||
import { UnitVector } from "math/vector";
|
||||
import { OperationDescriptor } from "cad/craft/operationPlugin";
|
||||
import { FromSketchProductionAnalyzer } from "cad/craft/production/productionAnalyzer";
|
||||
import { FaceRef } from "cad/craft/e0/OCCUtils";
|
||||
|
||||
interface smTabParams {
|
||||
thickness: number;
|
||||
|
|
@ -47,14 +48,19 @@ export const smTabOperation: OperationDescriptor<smTabParams> = {
|
|||
|
||||
const dir: UnitVector = face.normal();
|
||||
|
||||
let extrusionVector;
|
||||
let extrusionVector = {};
|
||||
if (params.flipper == true) {
|
||||
extrusionVector = dir.normalize()._multiply(params.thickness);
|
||||
} else {
|
||||
extrusionVector = dir.normalize()._multiply(params.thickness).negate();
|
||||
}
|
||||
|
||||
const productionAnalyzer = new FromSketchProductionAnalyzer(occFaces);
|
||||
|
||||
|
||||
|
||||
|
||||
const productionAnalyzer = new FromSketchProductionAnalyzer(occFaces,"SM/FLAT/A", "SM/FLAT/B","SM/THICKNESS");
|
||||
console.log(productionAnalyzer);
|
||||
|
||||
const tools = occFaces.map((faceRef, i) => {
|
||||
|
||||
|
|
@ -65,19 +71,7 @@ export const smTabOperation: OperationDescriptor<smTabParams> = {
|
|||
}).map(shapeName => occ.io.getShell(shapeName, productionAnalyzer));
|
||||
|
||||
|
||||
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;
|
||||
return occ.utils.applyBooleanModifier(tools, params.boolean, face, [face]);
|
||||
|
||||
},
|
||||
|
||||
|
|
|
|||
|
|
@ -192,10 +192,16 @@ export class ExpectedOrderProductionAnalyzer extends BasicProductionAnalyzer {
|
|||
export class FromSketchProductionAnalyzer extends BasicProductionAnalyzer {
|
||||
|
||||
profiles: FaceRef[];
|
||||
baseName: string;
|
||||
sweepName: string;
|
||||
lidName:string;
|
||||
|
||||
constructor(profiles: FaceRef[]) {
|
||||
constructor(profiles: FaceRef[], baseName?: string, lidName?:string, sweepName?: string) {
|
||||
super();
|
||||
this.profiles = profiles;
|
||||
this.baseName = baseName ? baseName : "BASE";
|
||||
this.lidName = lidName ? lidName : "LID";
|
||||
this.sweepName = sweepName? sweepName: "SWEEP";
|
||||
for (let originFace of this.profiles) {
|
||||
classifier.prepare(originFace.topoShape);
|
||||
}
|
||||
|
|
@ -217,9 +223,9 @@ export class FromSketchProductionAnalyzer extends BasicProductionAnalyzer {
|
|||
|
||||
if (faceToFaceClassification === Classification.EXACT) {
|
||||
base = createdFace;
|
||||
base.data.id = `F:BASE[${wireId}]`;
|
||||
base.data.id = `F:${this.baseName}[${wireId}]`;
|
||||
base.data.productionInfo = {
|
||||
role: 'base',
|
||||
role: this.baseName,
|
||||
originatingWire: wireId
|
||||
}
|
||||
break;
|
||||
|
|
@ -233,55 +239,55 @@ export class FromSketchProductionAnalyzer extends BasicProductionAnalyzer {
|
|||
for (let createdEdge of createdShell.edges) {
|
||||
|
||||
if (classifier.classifyEdgeToEdge(profileEdge, createdEdge) !== Classification.UNRELATED) {
|
||||
createdEdge.data.id = `E:BASE[${seg.id}]`;
|
||||
createdEdge.data.id = `E:${this.baseName}[${seg.id}]`;
|
||||
createdEdge.data.productionInfo = {
|
||||
role: 'base',
|
||||
role: this.baseName,
|
||||
originatingPrimitive: seg.id
|
||||
}
|
||||
let halfEdge = createdEdge.getHalfEdge(he => he?.loop?.face && he.loop.face !== base);
|
||||
if (halfEdge) {
|
||||
let face = halfEdge.loop.face;
|
||||
face.data.id = `F:SWEEP[${seg.id}]`;
|
||||
face.data.id = `F:${this.sweepName}[${seg.id}]`;
|
||||
face.data.productionInfo = {
|
||||
role: 'sweep',
|
||||
role: this.sweepName,
|
||||
originatingPrimitive: seg.id
|
||||
}
|
||||
|
||||
halfEdge.prev.edge.data.id = `E:SWEEP[${seg.id}/A]`;
|
||||
halfEdge.prev.edge.data.id = `E:${this.sweepName}[${seg.id}/A]`;
|
||||
halfEdge.prev.edge.data.productionInfo = {
|
||||
role: 'sweep',
|
||||
role: this.sweepName,
|
||||
originatingPrimitive: seg.id + '/A'
|
||||
}
|
||||
|
||||
halfEdge.prev.vertexA.data.id = `V:LID[${seg.id}/A]`
|
||||
halfEdge.prev.vertexA.data.id = `V:${this.lidName}[${seg.id}/A]`
|
||||
halfEdge.prev.vertexA.data.productionInfo = {
|
||||
role: 'lid',
|
||||
role: this.lidName,
|
||||
originatingPrimitive: seg.id + '/A'
|
||||
}
|
||||
|
||||
halfEdge.prev.vertexB.data.id = `V:BASE[${seg.id}/A]`
|
||||
halfEdge.prev.vertexB.data.id = `V:${this.baseName}[${seg.id}/A]`
|
||||
halfEdge.prev.vertexB.data.productionInfo = {
|
||||
role: 'base',
|
||||
role: this.baseName,
|
||||
originatingPrimitive: seg.id + '/A'
|
||||
}
|
||||
|
||||
//Extruded not closed wire
|
||||
if (!halfEdge.next.twin()) {
|
||||
halfEdge.next.edge.data.id = `E:SWEEP[${seg.id}/B]`;
|
||||
halfEdge.next.edge.data.id = `E:${this.sweepName}[${seg.id}/B]`;
|
||||
halfEdge.next.edge.data.productionInfo = {
|
||||
role: 'sweep',
|
||||
role: this.sweepName,
|
||||
originatingPrimitive: seg.id + '/B'
|
||||
}
|
||||
|
||||
halfEdge.next.vertexA.data.id = `V:BASE[${seg.id}/B]`
|
||||
halfEdge.next.vertexA.data.id = `V:${this.baseName}[${seg.id}/B]`
|
||||
halfEdge.next.vertexA.data.productionInfo = {
|
||||
role: 'base',
|
||||
role: this.baseName,
|
||||
originatingPrimitive: seg.id + '/B'
|
||||
}
|
||||
|
||||
halfEdge.prev.vertexB.data.id = `V:LID[${seg.id}/B]`
|
||||
halfEdge.prev.vertexB.data.id = `V:${this.lidName}[${seg.id}/B]`
|
||||
halfEdge.prev.vertexB.data.productionInfo = {
|
||||
role: 'lid',
|
||||
role: this.lidName,
|
||||
originatingPrimitive: seg.id + '/B'
|
||||
}
|
||||
}
|
||||
|
|
@ -292,9 +298,9 @@ export class FromSketchProductionAnalyzer extends BasicProductionAnalyzer {
|
|||
|
||||
for (let createdFace of createdShell.faces) {
|
||||
if (!createdFace.data.productionInfo) {
|
||||
createdFace.data.id = `F:LID[${wireId}]`;
|
||||
createdFace.data.id = `F:${this.lidName}[${wireId}]`;
|
||||
createdFace.data.productionInfo = {
|
||||
role: 'lid'
|
||||
role: this.lidName
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
@ -306,9 +312,9 @@ export class FromSketchProductionAnalyzer extends BasicProductionAnalyzer {
|
|||
const he = createdEdge.getHalfEdge(he => he?.loop?.face?.data?.productionInfo?.role === 'sweep');
|
||||
if (he) {
|
||||
const originatingPrimitive = he.loop.face.data.productionInfo.originatingPrimitive;
|
||||
createdEdge.data.id = `E:LID[${originatingPrimitive}]`;
|
||||
createdEdge.data.id = `E:${this.lidName}[${originatingPrimitive}]`;
|
||||
createdEdge.data.productionInfo = {
|
||||
role: 'lid',
|
||||
role: this.lidName,
|
||||
originatingPrimitive
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue