From f0310522b40dc1de9fcae3b2877bfaae2c44a0f4 Mon Sep 17 00:00:00 2001 From: Val Erastov Date: Fri, 12 Aug 2022 23:54:10 -0700 Subject: [PATCH] code cleanup --- .../examples/features/occ_bottle/index.ts | 1 - .../features/fillet/fillet.operation.ts | 4 ---- .../modeler/features/hole/Hole.operation.ts | 4 +--- .../importModel/importModel.operation.ts | 4 +--- .../modeler/features/loft/loft.operation.ts | 7 +------ .../mirrorBody/mirrorBody.operation.ts | 1 - .../patternLinear/patternLinear.operation.ts | 1 - .../features/revolve/revolve.operation.ts | 5 ++--- .../features/scaleBody/scaleBody.operation.ts | 19 ++++++------------ .../modeler/features/shell/shell.operation.ts | 16 +++++---------- .../features/smFlange/smFlange.operation.ts | 20 ++++++------------- .../features/smTab/smTab.operation.ts | 7 +++---- web/app/cad/model/mface.ts | 6 +++++- 13 files changed, 30 insertions(+), 65 deletions(-) diff --git a/modules/workbenches/examples/features/occ_bottle/index.ts b/modules/workbenches/examples/features/occ_bottle/index.ts index 9ebda20c..6a5413b9 100644 --- a/modules/workbenches/examples/features/occ_bottle/index.ts +++ b/modules/workbenches/examples/features/occ_bottle/index.ts @@ -19,7 +19,6 @@ export const OCCBottle:OperationDescriptor = { run: ({width, height, thickness, color}, ctx: ApplicationContext) => { const occObj = createOCCBottle(width, height, thickness, ctx.occService.occContext); const mobject = new MBrepShell(occ2brep(occObj, ctx.occService.occContext)); - console.log(color); return { consumed: [], created: [mobject] diff --git a/modules/workbenches/modeler/features/fillet/fillet.operation.ts b/modules/workbenches/modeler/features/fillet/fillet.operation.ts index 348d0937..dc62868d 100644 --- a/modules/workbenches/modeler/features/fillet/fillet.operation.ts +++ b/modules/workbenches/modeler/features/fillet/fillet.operation.ts @@ -25,8 +25,6 @@ export const FilletOperation: OperationDescriptor = { const occ = ctx.occService; const oci = occ.commandInterface; - console.log(params.edges); - //add all the edges and size to seperate arrays for each shell that edges are selected from const groups = new Map() @@ -69,8 +67,6 @@ export const FilletOperation: OperationDescriptor = { result.created.push(occ.io.getShell(newShellName, analyzer)); }); - console.log(result); - return result; }, form: [ diff --git a/modules/workbenches/modeler/features/hole/Hole.operation.ts b/modules/workbenches/modeler/features/hole/Hole.operation.ts index 4f64899a..80a1a0ed 100644 --- a/modules/workbenches/modeler/features/hole/Hole.operation.ts +++ b/modules/workbenches/modeler/features/hole/Hole.operation.ts @@ -33,11 +33,10 @@ export const HoleOperation: OperationDescriptor = { }) => `(${r(depth)} ${r(counterBoreDiameter)}) ${r(counterBoreDepth)})`, run: (params: HoleParams, ctx: ApplicationContext) => { - console.log(params); let occ = ctx.occService; const oci = occ.commandInterface; - var returnObject = { + const returnObject = { consumed: [], created: [] }; @@ -45,7 +44,6 @@ export const HoleOperation: OperationDescriptor = { //let sketch = ctx.sketchStorageService.readSketch(params.sketch.id); //console.log(sketch, "sketch info here"); - oci.pcylinder("result", params.diameter / 2, params.depth); // if (params.holeType == "normal") { diff --git a/modules/workbenches/modeler/features/importModel/importModel.operation.ts b/modules/workbenches/modeler/features/importModel/importModel.operation.ts index 9b9f4574..17df353a 100644 --- a/modules/workbenches/modeler/features/importModel/importModel.operation.ts +++ b/modules/workbenches/modeler/features/importModel/importModel.operation.ts @@ -30,7 +30,6 @@ export const ImportModelOpperation: OperationDescriptor = { if (FileName.endsWith("BRP") || FileName.endsWith("BREP")) { //FreeCAD some times omits this text from the top of BRP files //as part of the brp files stored in the .FCStf file archive format - console.log(rawContent); if (!rawContent.startsWith("DBRep_DrawableShape")) { rawContent = `DBRep_DrawableShape\n` + rawContent; } @@ -65,9 +64,8 @@ export const ImportModelOpperation: OperationDescriptor = { FS.writeFile(importBrepShapeName, `DBRep_DrawableShape\n` + zipContent); oci.readbrep(importBrepShapeName, importBrepShapeName); returnObject.created.push(occ.io.getShell(importBrepShapeName)); - console.log(importBrepShapeName); } catch (e) { - console.log(e) + console.warn(e) } } } diff --git a/modules/workbenches/modeler/features/loft/loft.operation.ts b/modules/workbenches/modeler/features/loft/loft.operation.ts index 90795658..3ef04b6d 100644 --- a/modules/workbenches/modeler/features/loft/loft.operation.ts +++ b/modules/workbenches/modeler/features/loft/loft.operation.ts @@ -28,8 +28,6 @@ export const LoftOperation: OperationDescriptor = { if (params.loftType == "smooth") loftType = 0; if (params.loftType == "sharp") loftType = 1; - //console.log(params.loops); - let sketches = []; const wires = params.loops.map((loop, i) => { @@ -39,16 +37,13 @@ export const LoftOperation: OperationDescriptor = { return occ.io.sketchLoader.pushContourAsWire(loop.contour, shapeName, loop.face.csys).wire }); - //console.log("This is the info you are looking for", sketches); - let sweepSources = []; let indexOfMostSegments = 0; let longestPath = 0; let primarySketch = {}; - sketches.forEach(function (item, index) { - //console.log(item, index); + sketches.forEach((item, index) => { if(params.loops[index].contour.segments.length > longestPath){ longestPath = params.loops[index].contour.segments.length; diff --git a/modules/workbenches/modeler/features/mirrorBody/mirrorBody.operation.ts b/modules/workbenches/modeler/features/mirrorBody/mirrorBody.operation.ts index d1fe5dbe..0f9b9874 100644 --- a/modules/workbenches/modeler/features/mirrorBody/mirrorBody.operation.ts +++ b/modules/workbenches/modeler/features/mirrorBody/mirrorBody.operation.ts @@ -18,7 +18,6 @@ export const MirrorBodyOperation: OperationDescriptor = { info: 'Mirrors selected body along plane of symytry.', paramsInfo: ({ }) => `(${r()})`, run: (params: MirrorBodyParams, ctx: ApplicationContext) => { - console.log(params); let occ = ctx.occService; const oci = occ.commandInterface; diff --git a/modules/workbenches/modeler/features/patternLinear/patternLinear.operation.ts b/modules/workbenches/modeler/features/patternLinear/patternLinear.operation.ts index 0de3dc59..49506257 100644 --- a/modules/workbenches/modeler/features/patternLinear/patternLinear.operation.ts +++ b/modules/workbenches/modeler/features/patternLinear/patternLinear.operation.ts @@ -27,7 +27,6 @@ export const PatternLinearOperation: OperationDescriptor = info: 'Creates a linear pattern.', paramsInfo: ({ }) => `(?)`, run: (params: patternLinearParams, ctx: ApplicationContext) => { - console.log(params); let occ = ctx.occService; const oci = occ.commandInterface; diff --git a/modules/workbenches/modeler/features/revolve/revolve.operation.ts b/modules/workbenches/modeler/features/revolve/revolve.operation.ts index 1ac50a8e..56617106 100644 --- a/modules/workbenches/modeler/features/revolve/revolve.operation.ts +++ b/modules/workbenches/modeler/features/revolve/revolve.operation.ts @@ -29,7 +29,6 @@ export const RevolveOperation: OperationDescriptor = { info: 'Revolves 2D sketch', paramsInfo: ({angle}) => `(${r(angle)})`, run: (params: RevolveParams, ctx: ApplicationContext) => { - console.log(params); let occ = ctx.occService; const oci = occ.commandInterface; @@ -42,7 +41,7 @@ export const RevolveOperation: OperationDescriptor = { if (!sketch) { if (face instanceof MBrepFace) { - var args = ["FaceTool", face, ...params.axis.origin.data(), ...params.axis.direction.data(), params.angle]; + const args = ["FaceTool", face, ...params.axis.origin.data(), ...params.axis.direction.data(), params.angle]; oci.revol(...args); return occ.utils.applyBooleanModifier([occ.io.getShell("FaceTool")], params.boolean, face, [], (targets, tools) => new FromMObjectProductionAnalyzer(targets, [face])); @@ -60,7 +59,7 @@ export const RevolveOperation: OperationDescriptor = { const tools = sweepSources.map((faceRef, i) => { const faceName = faceRef.face; const shapeName = "Tool/" + i; - var args = [shapeName, faceName, ...params.axis.origin.data(), ...params.axis.direction.data(), params.angle]; + const args = [shapeName, faceName, ...params.axis.origin.data(), ...params.axis.direction.data(), params.angle]; oci.revol(...args); return shapeName; }).map(shapeName => occ.io.getShell(shapeName, productionAnalyzer)); diff --git a/modules/workbenches/modeler/features/scaleBody/scaleBody.operation.ts b/modules/workbenches/modeler/features/scaleBody/scaleBody.operation.ts index e7d2797c..ff59baf4 100644 --- a/modules/workbenches/modeler/features/scaleBody/scaleBody.operation.ts +++ b/modules/workbenches/modeler/features/scaleBody/scaleBody.operation.ts @@ -1,10 +1,8 @@ -import { CSys } from 'math/csys'; -import { MShell } from 'cad/model/mshell'; -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 { OperationDescriptor } from "cad/craft/operationPlugin"; +import {MShell} from 'cad/model/mshell'; +import {roundValueForPresentation as r} from 'cad/craft/operationHelper'; +import {ApplicationContext} from "context"; +import {EntityKind} from "cad/model/entities"; +import {OperationDescriptor} from "cad/craft/operationPlugin"; interface scaleParams { @@ -19,16 +17,14 @@ export const ScaleOperation: OperationDescriptor = { info: 'Scale Body', paramsInfo: ({ distance }) => `(${r(distance)})`, run: (params: scaleParams, ctx: ApplicationContext) => { - console.log(params); let occ = ctx.occService; const oci = occ.commandInterface; - var returnObject = { + const returnObject = { consumed: params.shells, created: [] }; - params.shells.forEach((currentShell) => { const newShellId = currentShell.id + ":scaled"; oci.copy(currentShell, newShellId); @@ -36,9 +32,6 @@ export const ScaleOperation: OperationDescriptor = { returnObject.created.push(occ.io.getShell(newShellId)); }); - - console.log(returnObject); - return returnObject; }, diff --git a/modules/workbenches/modeler/features/shell/shell.operation.ts b/modules/workbenches/modeler/features/shell/shell.operation.ts index 02096e3a..6f7f81f5 100644 --- a/modules/workbenches/modeler/features/shell/shell.operation.ts +++ b/modules/workbenches/modeler/features/shell/shell.operation.ts @@ -17,13 +17,12 @@ export const ShellOperation: OperationDescriptor = { info: 'Shells 2D sketch', paramsInfo: ({thickness}) => `(${r(thickness)})`, run: (params: ShellParams, ctx: ApplicationContext) => { - console.log(params); let occ = ctx.occService; const oci = occ.commandInterface; - var bodiesToShell = []; - var returnObject = { + const bodiesToShell = []; + const returnObject = { consumed: [], created: [] }; @@ -41,20 +40,15 @@ export const ShellOperation: OperationDescriptor = { //perform the opperations on each of the bodies. Object.keys(bodiesToShell).forEach((shellToOpperateOnName) => { - var shellToOpperateOn = bodiesToShell[shellToOpperateOnName]; - var newShellName = shellToOpperateOnName + "f"; + const shellToOpperateOn = bodiesToShell[shellToOpperateOnName]; + const newShellName = shellToOpperateOnName + "f"; - console.log(shellToOpperateOn); - - var bodyToPerformShellOpperationOn = shellToOpperateOn[0].shell; + const bodyToPerformShellOpperationOn = shellToOpperateOn[0].shell; oci.offsetcompshape(newShellName, bodyToPerformShellOpperationOn, -params.thickness, "1.e-3", ...shellToOpperateOn) returnObject.created.push(occ.io.getShell(newShellName)); }); - console.log(returnObject); - return returnObject; - }, form: [ { diff --git a/modules/workbenches/sheetMetal/features/smFlange/smFlange.operation.ts b/modules/workbenches/sheetMetal/features/smFlange/smFlange.operation.ts index 8cce6719..f50a8408 100644 --- a/modules/workbenches/sheetMetal/features/smFlange/smFlange.operation.ts +++ b/modules/workbenches/sheetMetal/features/smFlange/smFlange.operation.ts @@ -20,7 +20,6 @@ export const smFlangeOperation: OperationDescriptor = { info: 'Creates Sheet metal flange', paramsInfo: ({ angle }) => `(${r(angle)})`, run: (params: smFlangeParams, ctx: ApplicationContext) => { - console.log(params); let occ = ctx.occService; const oci = occ.commandInterface; @@ -33,7 +32,6 @@ export const smFlangeOperation: OperationDescriptor = { for (let i = 0; i < face.edges.length; i++) { const edgeKind = face.edges[i].productionInfo.sheetMetal.kind; - console.log(edgeKind); if (edgeKind == "FLAT/A" && !params.flip) { revolveVector = face.edges[i].toAxis(); revolveVectorOrigin = revolveVector.origin; @@ -48,7 +46,6 @@ export const smFlangeOperation: OperationDescriptor = { } } - console.log(revolveVectorOrigin); //revolveVectorOrigin.y -=0; //revolveVectorOrigin.z +=2; @@ -65,24 +62,19 @@ export const smFlangeOperation: OperationDescriptor = { targets: [params.face.shell] } - console.log(params.face.shell); - - tools[0].edges.forEach(async (newEdge) => { - params.face.shell.edges.forEach(async (edgeToLookAt) => { + tools[0].edges.forEach((newEdge) => { + params.face.shell.edges.forEach((edgeToLookAt) => { if (JSON.stringify(newEdge.topology.data.tessellation) == JSON.stringify(edgeToLookAt.topology.data.tessellation)) { - console.log("We have a match", edgeToLookAt.productionInfo.sheetMetal.kind); + console.debug("We have a match", edgeToLookAt.productionInfo.sheetMetal.kind); newEdge.productionInfo ={}; - newEdge.productionInfo = { sheetMetal: { kind: edgeToLookAt.productionInfo.sheetMetal.kind } }; + newEdge.productionInfo = {sheetMetal: {kind: edgeToLookAt.productionInfo.sheetMetal.kind}}; //newEdge.productionInfo.sheetMetal.kind = edgeToLookAt.productionInfo.sheetMetal.kind; - console.log(newEdge, edgeToLookAt); - console.log(newEdge.productionInfo); + console.debug(newEdge, edgeToLookAt); + console.debug(newEdge.productionInfo); } }); }); - - - //return occ.utils.applyBooleanModifier(tools, booleanOperation); return { created: tools, consumed: [] diff --git a/modules/workbenches/sheetMetal/features/smTab/smTab.operation.ts b/modules/workbenches/sheetMetal/features/smTab/smTab.operation.ts index 07321f79..351acfaa 100644 --- a/modules/workbenches/sheetMetal/features/smTab/smTab.operation.ts +++ b/modules/workbenches/sheetMetal/features/smTab/smTab.operation.ts @@ -33,15 +33,14 @@ export const smTabOperation: OperationDescriptor = { run: (params: smTabParams, ctx: ApplicationContext) => { let occ = ctx.occService; - console.log(ctx.craftService.modifications$.value.history); const oci = occ.commandInterface; const face = params.sketch; let sketch = ctx.sketchStorageService.readSketch(face.id); - if (!sketch) throw 'sketch not found for the face ' + face.id; - - + if (!sketch) { + throw 'sketch not found for the face ' + face.id; + } const occFaces = occ.utils.sketchToFaces(sketch, face.csys); diff --git a/web/app/cad/model/mface.ts b/web/app/cad/model/mface.ts index 4a97bad3..1b42721e 100644 --- a/web/app/cad/model/mface.ts +++ b/web/app/cad/model/mface.ts @@ -13,6 +13,7 @@ import {EntityKind} from "cad/model/entities"; import {Matrix3x4} from "math/matrix"; import {TopoObject} from "brep/topo/topo-object"; import Axis from "math/axis"; +import {MEdge} from "cad/model/medge"; export class MFace extends MObject { @@ -180,6 +181,9 @@ export class MFace extends MObject { return this.brepFace; } + get edges(): MEdge[] { + return []; + } } export class MBrepFace extends MFace { @@ -192,7 +196,7 @@ export class MBrepFace extends MFace { this.brepFace = brepFace; } - get edges() { + get edges(): MEdge[] { let out = []; for (let he of this.brepFace.edges) { let edge = (this.shell as MBrepShell).brepRegistry.get(he.edge);