mirror of
https://github.com/xibyte/jsketcher
synced 2025-12-15 04:45:06 +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
444745dbe1
commit
d552e5aa62
2 changed files with 52 additions and 36 deletions
|
|
@ -5,7 +5,8 @@ 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;
|
||||
|
|
@ -33,27 +34,36 @@ export const smTabOperation: OperationDescriptor<smTabParams> = {
|
|||
let sketch = ctx.sketchStorageService.readSketch(face.id);
|
||||
if (!sketch) throw 'sketch not found for the face ' + face.id;
|
||||
|
||||
const occFaces = occ.utils.sketchToFaces(sketch, face.csys).map(ref => ref.face);
|
||||
|
||||
|
||||
const dir: UnitVector= face.normal();
|
||||
const occFaces = occ.utils.sketchToFaces(sketch, face.csys);
|
||||
|
||||
let extrusionVector =[];
|
||||
if (params.flipper == true){
|
||||
extrusionVector = dir.normalize()._multiply(params.thickness).data();
|
||||
const dir: UnitVector = face.normal();
|
||||
|
||||
let extrusionVector = {};
|
||||
if (params.flipper == true) {
|
||||
extrusionVector = dir.normalize()._multiply(params.thickness);
|
||||
} else {
|
||||
extrusionVector = dir.normalize()._multiply(params.thickness).negate().data();
|
||||
extrusionVector = dir.normalize()._multiply(params.thickness).negate();
|
||||
}
|
||||
|
||||
|
||||
const tools = occFaces.map((faceName, i) => {
|
||||
|
||||
|
||||
|
||||
|
||||
const productionAnalyzer = new FromSketchProductionAnalyzer(occFaces,"SM/FLAT/A", "SM/FLAT/B","SM/THICKNESS");
|
||||
console.log(productionAnalyzer);
|
||||
|
||||
const tools = occFaces.map((faceRef, i) => {
|
||||
|
||||
const faceName = faceRef.face;
|
||||
const shapeName = "Tool/" + i;
|
||||
const bla = oci.prism(shapeName, faceName, ...extrusionVector);
|
||||
console.log(bla);
|
||||
oci.prism(shapeName, faceName, ...extrusionVector.data());
|
||||
return shapeName;
|
||||
});
|
||||
}).map(shapeName => occ.io.getShell(shapeName, productionAnalyzer));
|
||||
|
||||
|
||||
return occ.utils.applyBooleanModifier(tools, params.boolean);
|
||||
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;
|
||||
}
|
||||
|
|
@ -309,9 +315,9 @@ export class FromSketchProductionAnalyzer extends BasicProductionAnalyzer {
|
|||
}
|
||||
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