mirror of
https://github.com/xibyte/jsketcher
synced 2025-12-22 08:26:26 +01:00
Update to use stable IDs for paterned / mirroed objects.
This commit is contained in:
parent
b5dc668147
commit
f8443e03e9
3 changed files with 30 additions and 15 deletions
|
|
@ -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<MirrorBodyParams> = {
|
||||
|
|
@ -17,19 +19,22 @@ export const MirrorBodyOperation: OperationDescriptor<MirrorBodyParams> = {
|
|||
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 {
|
||||
|
|
|
|||
|
|
@ -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<patternLinearParams> =
|
|||
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<patternLinearParams> =
|
|||
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);
|
||||
}
|
||||
|
||||
});
|
||||
|
|
|
|||
|
|
@ -53,7 +53,12 @@ export const PatternRadialOperation: OperationDescriptor<patternRadialParams> =
|
|||
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);
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in a new issue