From aa249f95d2671e8fcba62a143ad96de34f785631 Mon Sep 17 00:00:00 2001 From: Val Erastov Date: Sat, 5 Nov 2022 20:39:59 -0700 Subject: [PATCH] Fixing lint issues before merging to main --- externals.d.ts | 2 +- .../actions/exportBREP/exportBREP.action.ts | 25 ++++++--------- .../modeler/actions/getInfo/getInfo.action.ts | 31 ++++++++++--------- .../features/plane/simplePlaneOperation.ts | 25 ++++++--------- .../cad/craft/schema/initializeBySchema.ts | 6 +--- web/app/cad/mdf/ui/BooleanWidget.tsx | 6 ++-- web/app/cad/mdf/ui/ChoiceWidget.tsx | 2 +- web/app/cad/model/mopenFace.ts | 5 ++- web/app/cad/model/mshell.ts | 1 - 9 files changed, 45 insertions(+), 58 deletions(-) diff --git a/externals.d.ts b/externals.d.ts index e536f2be..c44786c3 100644 --- a/externals.d.ts +++ b/externals.d.ts @@ -11,4 +11,4 @@ declare const verb: any; declare const FS: any; declare const __CAD_APP: any; declare const __DEBUG__: any; - +declare let out: any; diff --git a/modules/workbenches/modeler/actions/exportBREP/exportBREP.action.ts b/modules/workbenches/modeler/actions/exportBREP/exportBREP.action.ts index 7b41e02b..c9d65413 100644 --- a/modules/workbenches/modeler/actions/exportBREP/exportBREP.action.ts +++ b/modules/workbenches/modeler/actions/exportBREP/exportBREP.action.ts @@ -15,7 +15,7 @@ export const ExportBREP: any = { icon: 'img/cad/extrude', info: 'EXPORT BREP FILE CONTAINING SELECTED BODIES', path:__dirname, - run: async (params: Params, ctx: ApplicationContext) => { + run: async (params: any, ctx: ApplicationContext) => { console.log("this is it", this) const occ = ctx.occService; const oci = occ.commandInterface; @@ -43,7 +43,6 @@ export const ExportBREP: any = { resultingMessage = "yay"; throw {userMessage: resultingMessage}; - return; }, @@ -63,30 +62,24 @@ export const ExportBREP: any = { ], } - - -var downloadBlob, downloadURL; - -downloadBlob = function(data, fileName, mimeType) { - var blob, url; - blob = new Blob([data], { +function downloadBlob(data, fileName, mimeType) { + const blob = new Blob([data], { type: mimeType }); - url = window.URL.createObjectURL(blob); + const url = window.URL.createObjectURL(blob); downloadURL(url, fileName); setTimeout(function() { return window.URL.revokeObjectURL(url); }, 1000); -}; +} -downloadURL = function(data, fileName) { - var a; - a = document.createElement('a'); +function downloadURL(data, fileName) { + const a = document.createElement('a'); a.href = data; a.id = "MyDownload" a.download = fileName; document.body.appendChild(a); - a.style = 'display: none'; + a.style.display = 'none'; a.click(); a.remove(); -}; \ No newline at end of file +} \ No newline at end of file diff --git a/modules/workbenches/modeler/actions/getInfo/getInfo.action.ts b/modules/workbenches/modeler/actions/getInfo/getInfo.action.ts index 696396da..6832235d 100644 --- a/modules/workbenches/modeler/actions/getInfo/getInfo.action.ts +++ b/modules/workbenches/modeler/actions/getInfo/getInfo.action.ts @@ -1,12 +1,13 @@ import {MShell} from "cad/model/mshell"; import {ApplicationContext} from "cad/context"; import {EntityKind} from "cad/model/entities"; -import {ActionDefinition} from "cad/actions/actionSystemBundle"; import { MEdge } from "cad/model/medge"; +import NurbsCurve from "geom/curves/nurbsCurve"; interface GetInfoParams { targetBody: MShell | MEdge; + brepEdge: MEdge; } export const GetInfo: any = { @@ -25,30 +26,30 @@ export const GetInfo: any = { let resultingMessage = ""; - if (targetBody.TYPE === EntityKind.EDGE){ - resultingMessage = "Edge Length = "+ targetBody.brepEdge.curve.impl.verb.length().toFixed(4); + if (targetBody instanceof MEdge){ + resultingMessage = "Edge Length = "+ (targetBody.brepEdge.curve.impl as NurbsCurve).verb.length().toFixed(4); } if (targetBody.TYPE === EntityKind.SHELL){ - let listOfOutputs = []; + const listOfOutputs = []; + const out_old = out; - out = function(msg) { - listOfOutputs.push(msg); + try { + out = function(msg) { + listOfOutputs.push(msg); //alert(JSON.stringify(msg)); out_old(msg); + } + + oci.vprops(params.targetBody); + + } finally { + out = out_old; } - - oci.vprops(params.targetBody); - - out = out_old; - - + const resultingVolumeArray = listOfOutputs.filter(function (str) { return str.includes("Mass") }); resultingMessage = "Volume = " + resultingVolumeArray[0].trim().replace(' ', '').replace("Mass:","").trim(); } - - - throw {userMessage: resultingMessage}; return; }, diff --git a/modules/workbenches/modeler/features/plane/simplePlaneOperation.ts b/modules/workbenches/modeler/features/plane/simplePlaneOperation.ts index 3b10c407..68b71b35 100644 --- a/modules/workbenches/modeler/features/plane/simplePlaneOperation.ts +++ b/modules/workbenches/modeler/features/plane/simplePlaneOperation.ts @@ -1,17 +1,13 @@ -import { createMeshGeometry } from 'scene/geoms'; -import { Plane } from 'geom/impl/plane'; +import {createMeshGeometry} from 'scene/geoms'; +import {Plane} from 'geom/impl/plane'; import Vector from 'math/vector'; -import { MOpenFaceShell } from '../../../../../web/app/cad/model/mopenFace'; -import { PlaneSurfacePrototype } from '../../../../../web/app/cad/model/surfacePrototype'; +import {MOpenFaceShell} from '../../../../../web/app/cad/model/mopenFace'; +import {PlaneSurfacePrototype} from '../../../../../web/app/cad/model/surfacePrototype'; import CSys from "math/csys"; -import { EntityKind } from "cad/model/entities"; -import { TextureLoader, MeshBasicMaterial,MeshLambertMaterial, Mesh, DoubleSide, PlaneGeometry } from "three"; -//import THREE from "three"; +import {EntityKind} from "cad/model/entities"; - - -function paramsToPlane({ orientation, datum, depth }, cadRegistry) { +function paramsToPlane({ orientation, datum, depth }) { const csys = datum ? datum.csys : CSys.ORIGIN; let axis; @@ -29,8 +25,8 @@ function paramsToPlane({ orientation, datum, depth }, cadRegistry) { } -function previewGeomProvider(params, {cadRegistry}) { - const plane = paramsToPlane(params, cadRegistry); +function previewGeomProvider(params) { + const plane = paramsToPlane(params); const tr = plane.get3DTransformation(); const w = 375, h = 375; const a = tr._apply(new Vector(-w, -h, 0)); @@ -65,15 +61,15 @@ export default { paramsInfo: ({ depth }) => `(${depth})`, previewGeomProvider, run: (params, { cadRegistry }) => { + return { consumed: [], - created: [new MOpenFaceShell(new PlaneSurfacePrototype(paramsToPlane(params, cadRegistry)))] + created: [new MOpenFaceShell(new PlaneSurfacePrototype(paramsToPlane(params)))] } }, form: [ { type: 'choice', - style: "dropdown", label: 'orientation', name: 'orientation', style: 'radio', @@ -103,7 +99,6 @@ export default { // name: 'image', // optional: true, // label: 'Optional Image', - // }, ], }; diff --git a/web/app/cad/craft/schema/initializeBySchema.ts b/web/app/cad/craft/schema/initializeBySchema.ts index bf5d1ebb..5b20b166 100644 --- a/web/app/cad/craft/schema/initializeBySchema.ts +++ b/web/app/cad/craft/schema/initializeBySchema.ts @@ -48,10 +48,6 @@ export function fillUpMissingFields(params: any, schema: OperationSchema, contex for (const field of fields) { const md = schema[field] as SchemaField; - if (md.optional) { - continue; - } - let val = params[field]; const isPrimitive = @@ -59,7 +55,7 @@ export function fillUpMissingFields(params: any, schema: OperationSchema, contex && md.type !== Types.object && md.type !== Types.entity; - if (isPrimitive && isValueNotProvided(val)) { + if (isPrimitive && isValueNotProvided(val) && !md.optional) { params[field] = md.defaultValue; } else if (md.type === Types.object) { if (!val) { diff --git a/web/app/cad/mdf/ui/BooleanWidget.tsx b/web/app/cad/mdf/ui/BooleanWidget.tsx index 929e5c60..ddadafcf 100644 --- a/web/app/cad/mdf/ui/BooleanWidget.tsx +++ b/web/app/cad/mdf/ui/BooleanWidget.tsx @@ -6,7 +6,8 @@ import {SectionWidgetProps} from "cad/mdf/ui/SectionWidget"; export interface BooleanWidgetProps extends FieldBasicProps { type: 'boolean'; - simplify: boolean | true; + + simplify?: boolean; } @@ -42,8 +43,7 @@ export const BooleanWidgetDefinition = (props: BooleanWidgetProps) => ({ name: "simplify", label: 'simplify', type: "checkbox", - defaultValue: true, - optional: true, + defaultValue: true }, { name: "targets", diff --git a/web/app/cad/mdf/ui/ChoiceWidget.tsx b/web/app/cad/mdf/ui/ChoiceWidget.tsx index ad0ae21f..ab551d59 100644 --- a/web/app/cad/mdf/ui/ChoiceWidget.tsx +++ b/web/app/cad/mdf/ui/ChoiceWidget.tsx @@ -45,7 +45,7 @@ export function ChoiceWidget(props: ChoiceWidgetProps) { val = value; name = value; } - return {name} + return })} ; } diff --git a/web/app/cad/model/mopenFace.ts b/web/app/cad/model/mopenFace.ts index 3961630e..94aacc8e 100644 --- a/web/app/cad/model/mopenFace.ts +++ b/web/app/cad/model/mopenFace.ts @@ -5,12 +5,15 @@ export class MOpenFaceShell extends MShell { private surfacePrototype: any; - constructor(surfacePrototype, csys) { + constructor(surfacePrototype, csys?) { super(); this.surfacePrototype = surfacePrototype; this.csys = csys; this.faces.push(new MFace(this.id + '/SURFACE', this, surfacePrototype.boundTo([], 100, 100), csys)); + if (!this.csys) { + this.csys = this.face.csys; + } } get face() { diff --git a/web/app/cad/model/mshell.ts b/web/app/cad/model/mshell.ts index 4ffa0b1e..9c704ca1 100644 --- a/web/app/cad/model/mshell.ts +++ b/web/app/cad/model/mshell.ts @@ -45,7 +45,6 @@ export class MShell extends MObject { export class MBrepShell extends MShell { brepShell: Shell; - csys: CartesianCSys; brepRegistry: Map; constructor(shell, csys?) {