From f8443e03e9fb847810f24cab2bd8b492cdb11fcd Mon Sep 17 00:00:00 2001 From: mmiscool Date: Sat, 13 May 2023 02:36:05 +0000 Subject: [PATCH] Update to use stable IDs for paterned / mirroed objects. --- .../mirrorBody/mirrorBody.operation.ts | 13 +++++++--- .../patternLinear/patternLinear.operation.ts | 25 +++++++++++-------- .../patternRadial/patternRadial.operation.ts | 7 +++++- 3 files changed, 30 insertions(+), 15 deletions(-) diff --git a/modules/workbenches/modeler/features/mirrorBody/mirrorBody.operation.ts b/modules/workbenches/modeler/features/mirrorBody/mirrorBody.operation.ts index 4a9529ac..f5bd773d 100644 --- a/modules/workbenches/modeler/features/mirrorBody/mirrorBody.operation.ts +++ b/modules/workbenches/modeler/features/mirrorBody/mirrorBody.operation.ts @@ -6,10 +6,12 @@ import Axis from "math/axis"; import { OperationDescriptor } from "cad/craft/operationBundle"; import { MShell } from 'cad/model/mshell'; import icon from "./MIRROR.svg"; +import { ExpectedOrderProductionAnalyzer, SameTopologyProductionAnalyzer } from "cad/craft/production/productionAnalyzer"; interface MirrorBodyParams { inputBodies: MShell[]; - face:MFace; + face: MFace; + featureId: string; } export const MirrorBodyOperation: OperationDescriptor = { @@ -17,19 +19,22 @@ export const MirrorBodyOperation: OperationDescriptor = { label: 'Mirror Body', icon, info: 'Mirrors selected body along plane of symytry.', - path:__dirname, + path: __dirname, paramsInfo: () => `(?)`, run: (params: MirrorBodyParams, ctx: ApplicationContext) => { const occ = ctx.occService; const oci = occ.commandInterface; - const created =[]; + const created = []; params.inputBodies.forEach((shellToMirror) => { const newShellName = shellToMirror.id + ":mirror"; oci.copy(shellToMirror, newShellName); oci.tmirror(newShellName, ...params.face.csys.origin.data(), ...params.face.csys.z.normalize().data()); - created.push(occ.io.getShell(newShellName)); + + const resultingShell = occ.io.getShell(newShellName, new SameTopologyProductionAnalyzer(shellToMirror, params.featureId + "MIRROR")); + resultingShell.id = shellToMirror.id + "[" + "M" + ":" + params.featureId + "]"; + created.push(resultingShell) }); return { diff --git a/modules/workbenches/modeler/features/patternLinear/patternLinear.operation.ts b/modules/workbenches/modeler/features/patternLinear/patternLinear.operation.ts index e1c9e2d9..d81b3178 100644 --- a/modules/workbenches/modeler/features/patternLinear/patternLinear.operation.ts +++ b/modules/workbenches/modeler/features/patternLinear/patternLinear.operation.ts @@ -7,17 +7,19 @@ import { UnitVector } from "math/vector"; import { OperationDescriptor } from "cad/craft/operationBundle"; import { MShell } from 'cad/model/mshell'; import { MDatum } from "cad/model/mdatum"; -import {Matrix3x4} from "math/matrix"; -import {AddLocation, SetLocation} from "cad/craft/e0/interact"; +import { Matrix3x4 } from "math/matrix"; +import { AddLocation, SetLocation } from "cad/craft/e0/interact"; import icon from "./LINEAR-PATTERN.svg"; +import { ExpectedOrderProductionAnalyzer, SameTopologyProductionAnalyzer } from "cad/craft/production/productionAnalyzer"; + interface patternLinearParams { inputBodies: MShell[]; patternMethod: string; - face: MFace; distance: number; qty: number; direction: UnitVector, + featureId: string; } @@ -26,7 +28,7 @@ export const PatternLinearOperation: OperationDescriptor = label: 'Linear pattern', icon, info: 'Creates a linear pattern.', - path:__dirname, + path: __dirname, paramsInfo: () => `(?)`, run: (params: patternLinearParams, ctx: ApplicationContext) => { const occ = ctx.occService; @@ -37,18 +39,21 @@ export const PatternLinearOperation: OperationDescriptor = params.inputBodies.forEach((shellToPatern, index) => { for (let i = 2; i <= params.qty; i++) { let distanceForInstance = 0; - if(params.patternMethod == 'Step Distance') distanceForInstance =params.distance*(i-1); - if(params.patternMethod == 'Span Distance') distanceForInstance =(params.distance / (params.qty-1))*(i-1); + if (params.patternMethod == 'Step Distance') distanceForInstance = params.distance * (i - 1); + if (params.patternMethod == 'Span Distance') distanceForInstance = (params.distance / (params.qty - 1)) * (i - 1); const trVec = params.direction.multiply(distanceForInstance); const tr = new Matrix3x4().setTranslation(trVec.x, trVec.y, trVec.z); - - const newShellName = shellToPatern.id + ":patern/" + index + "/" +i; + + const newShellName = shellToPatern.id + ":patern/" + index + "/" + i; oci.copy(shellToPatern, newShellName); AddLocation(newShellName, tr.toFlatArray()); - - created.push(occ.io.getShell(newShellName)); + + + const resultingShell = occ.io.getShell(newShellName, new SameTopologyProductionAnalyzer(shellToPatern, params.featureId + "P")); + resultingShell.id = shellToPatern.id + "[" + "PL:" + params.featureId + "]" + "[" + "I:" + i + "]"; + created.push(resultingShell); } }); diff --git a/modules/workbenches/modeler/features/patternRadial/patternRadial.operation.ts b/modules/workbenches/modeler/features/patternRadial/patternRadial.operation.ts index 3f237b13..8a54689e 100644 --- a/modules/workbenches/modeler/features/patternRadial/patternRadial.operation.ts +++ b/modules/workbenches/modeler/features/patternRadial/patternRadial.operation.ts @@ -53,7 +53,12 @@ export const PatternRadialOperation: OperationDescriptor = oci.copy(shellToPatern, newShellName); AddLocation(newShellName, tr.toFlatArray()); - created.push(occ.io.getShell(newShellName)); + + + const resultingShell = occ.io.getShell(newShellName, new SameTopologyProductionAnalyzer(shellToPatern, params.featureId + "P")); + resultingShell.id = shellToPatern.id + "[" + "PR:" + params.featureId + "]" + "[" + "I:" + i + "]"; + created.push(resultingShell); + } });