code cleanup

This commit is contained in:
Val Erastov 2022-08-12 23:54:10 -07:00
parent 3bcbc4125b
commit f0310522b4
13 changed files with 30 additions and 65 deletions

View file

@ -19,7 +19,6 @@ export const OCCBottle:OperationDescriptor<any> = {
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]

View file

@ -25,8 +25,6 @@ export const FilletOperation: OperationDescriptor<any> = {
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<MShell, any[]>()
@ -69,8 +67,6 @@ export const FilletOperation: OperationDescriptor<any> = {
result.created.push(occ.io.getShell(newShellName, analyzer));
});
console.log(result);
return result;
},
form: [

View file

@ -33,11 +33,10 @@ export const HoleOperation: OperationDescriptor<HoleParams> = {
}) => `(${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<HoleParams> = {
//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") {

View file

@ -30,7 +30,6 @@ export const ImportModelOpperation: OperationDescriptor<ImportModelParams> = {
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<ImportModelParams> = {
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)
}
}
}

View file

@ -28,8 +28,6 @@ export const LoftOperation: OperationDescriptor<LoftParams> = {
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<LoftParams> = {
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;

View file

@ -18,7 +18,6 @@ export const MirrorBodyOperation: OperationDescriptor<MirrorBodyParams> = {
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;

View file

@ -27,7 +27,6 @@ export const PatternLinearOperation: OperationDescriptor<patternLinearParams> =
info: 'Creates a linear pattern.',
paramsInfo: ({ }) => `(?)`,
run: (params: patternLinearParams, ctx: ApplicationContext) => {
console.log(params);
let occ = ctx.occService;
const oci = occ.commandInterface;

View file

@ -29,7 +29,6 @@ export const RevolveOperation: OperationDescriptor<RevolveParams> = {
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<RevolveParams> = {
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<RevolveParams> = {
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));

View file

@ -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<scaleParams> = {
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<scaleParams> = {
returnObject.created.push(occ.io.getShell(newShellId));
});
console.log(returnObject);
return returnObject;
},

View file

@ -17,13 +17,12 @@ export const ShellOperation: OperationDescriptor<ShellParams> = {
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<ShellParams> = {
//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: [
{

View file

@ -20,7 +20,6 @@ export const smFlangeOperation: OperationDescriptor<smFlangeParams> = {
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<smFlangeParams> = {
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<smFlangeParams> = {
}
}
console.log(revolveVectorOrigin);
//revolveVectorOrigin.y -=0;
//revolveVectorOrigin.z +=2;
@ -65,24 +62,19 @@ export const smFlangeOperation: OperationDescriptor<smFlangeParams> = {
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: []

View file

@ -33,15 +33,14 @@ export const smTabOperation: OperationDescriptor<smTabParams> = {
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);

View file

@ -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);