mirror of
https://github.com/xibyte/jsketcher
synced 2025-12-06 08:25:19 +01:00
Fixing lint issues before merging to main
This commit is contained in:
parent
b97d4d9701
commit
aa249f95d2
9 changed files with 45 additions and 58 deletions
2
externals.d.ts
vendored
2
externals.d.ts
vendored
|
|
@ -11,4 +11,4 @@ declare const verb: any;
|
||||||
declare const FS: any;
|
declare const FS: any;
|
||||||
declare const __CAD_APP: any;
|
declare const __CAD_APP: any;
|
||||||
declare const __DEBUG__: any;
|
declare const __DEBUG__: any;
|
||||||
|
declare let out: any;
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ export const ExportBREP: any = {
|
||||||
icon: 'img/cad/extrude',
|
icon: 'img/cad/extrude',
|
||||||
info: 'EXPORT BREP FILE CONTAINING SELECTED BODIES',
|
info: 'EXPORT BREP FILE CONTAINING SELECTED BODIES',
|
||||||
path:__dirname,
|
path:__dirname,
|
||||||
run: async (params: Params, ctx: ApplicationContext) => {
|
run: async (params: any, ctx: ApplicationContext) => {
|
||||||
console.log("this is it", this)
|
console.log("this is it", this)
|
||||||
const occ = ctx.occService;
|
const occ = ctx.occService;
|
||||||
const oci = occ.commandInterface;
|
const oci = occ.commandInterface;
|
||||||
|
|
@ -43,7 +43,6 @@ export const ExportBREP: any = {
|
||||||
resultingMessage = "yay";
|
resultingMessage = "yay";
|
||||||
|
|
||||||
throw {userMessage: resultingMessage};
|
throw {userMessage: resultingMessage};
|
||||||
return;
|
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -63,30 +62,24 @@ export const ExportBREP: any = {
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function downloadBlob(data, fileName, mimeType) {
|
||||||
|
const blob = new Blob([data], {
|
||||||
var downloadBlob, downloadURL;
|
|
||||||
|
|
||||||
downloadBlob = function(data, fileName, mimeType) {
|
|
||||||
var blob, url;
|
|
||||||
blob = new Blob([data], {
|
|
||||||
type: mimeType
|
type: mimeType
|
||||||
});
|
});
|
||||||
url = window.URL.createObjectURL(blob);
|
const url = window.URL.createObjectURL(blob);
|
||||||
downloadURL(url, fileName);
|
downloadURL(url, fileName);
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
return window.URL.revokeObjectURL(url);
|
return window.URL.revokeObjectURL(url);
|
||||||
}, 1000);
|
}, 1000);
|
||||||
};
|
}
|
||||||
|
|
||||||
downloadURL = function(data, fileName) {
|
function downloadURL(data, fileName) {
|
||||||
var a;
|
const a = document.createElement('a');
|
||||||
a = document.createElement('a');
|
|
||||||
a.href = data;
|
a.href = data;
|
||||||
a.id = "MyDownload"
|
a.id = "MyDownload"
|
||||||
a.download = fileName;
|
a.download = fileName;
|
||||||
document.body.appendChild(a);
|
document.body.appendChild(a);
|
||||||
a.style = 'display: none';
|
a.style.display = 'none';
|
||||||
a.click();
|
a.click();
|
||||||
a.remove();
|
a.remove();
|
||||||
};
|
}
|
||||||
|
|
@ -1,12 +1,13 @@
|
||||||
import {MShell} from "cad/model/mshell";
|
import {MShell} from "cad/model/mshell";
|
||||||
import {ApplicationContext} from "cad/context";
|
import {ApplicationContext} from "cad/context";
|
||||||
import {EntityKind} from "cad/model/entities";
|
import {EntityKind} from "cad/model/entities";
|
||||||
import {ActionDefinition} from "cad/actions/actionSystemBundle";
|
|
||||||
import { MEdge } from "cad/model/medge";
|
import { MEdge } from "cad/model/medge";
|
||||||
|
import NurbsCurve from "geom/curves/nurbsCurve";
|
||||||
|
|
||||||
|
|
||||||
interface GetInfoParams {
|
interface GetInfoParams {
|
||||||
targetBody: MShell | MEdge;
|
targetBody: MShell | MEdge;
|
||||||
|
brepEdge: MEdge;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const GetInfo: any = {
|
export const GetInfo: any = {
|
||||||
|
|
@ -25,12 +26,14 @@ export const GetInfo: any = {
|
||||||
let resultingMessage = "";
|
let resultingMessage = "";
|
||||||
|
|
||||||
|
|
||||||
if (targetBody.TYPE === EntityKind.EDGE){
|
if (targetBody instanceof MEdge){
|
||||||
resultingMessage = "Edge Length = "+ targetBody.brepEdge.curve.impl.verb.length().toFixed(4);
|
resultingMessage = "Edge Length = "+ (targetBody.brepEdge.curve.impl as NurbsCurve).verb.length().toFixed(4);
|
||||||
}
|
}
|
||||||
if (targetBody.TYPE === EntityKind.SHELL){
|
if (targetBody.TYPE === EntityKind.SHELL){
|
||||||
let listOfOutputs = [];
|
const listOfOutputs = [];
|
||||||
|
|
||||||
const out_old = out;
|
const out_old = out;
|
||||||
|
try {
|
||||||
out = function(msg) {
|
out = function(msg) {
|
||||||
listOfOutputs.push(msg);
|
listOfOutputs.push(msg);
|
||||||
//alert(JSON.stringify(msg));
|
//alert(JSON.stringify(msg));
|
||||||
|
|
@ -39,16 +42,14 @@ export const GetInfo: any = {
|
||||||
|
|
||||||
oci.vprops(params.targetBody);
|
oci.vprops(params.targetBody);
|
||||||
|
|
||||||
|
} finally {
|
||||||
out = out_old;
|
out = out_old;
|
||||||
|
}
|
||||||
|
|
||||||
const resultingVolumeArray = listOfOutputs.filter(function (str) { return str.includes("Mass") });
|
const resultingVolumeArray = listOfOutputs.filter(function (str) { return str.includes("Mass") });
|
||||||
resultingMessage = "Volume = " + resultingVolumeArray[0].trim().replace(' ', '').replace("Mass:","").trim();
|
resultingMessage = "Volume = " + resultingVolumeArray[0].trim().replace(' ', '').replace("Mass:","").trim();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
throw {userMessage: resultingMessage};
|
throw {userMessage: resultingMessage};
|
||||||
return;
|
return;
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -1,17 +1,13 @@
|
||||||
import { createMeshGeometry } from 'scene/geoms';
|
import {createMeshGeometry} from 'scene/geoms';
|
||||||
import { Plane } from 'geom/impl/plane';
|
import {Plane} from 'geom/impl/plane';
|
||||||
import Vector from 'math/vector';
|
import Vector from 'math/vector';
|
||||||
import { MOpenFaceShell } from '../../../../../web/app/cad/model/mopenFace';
|
import {MOpenFaceShell} from '../../../../../web/app/cad/model/mopenFace';
|
||||||
import { PlaneSurfacePrototype } from '../../../../../web/app/cad/model/surfacePrototype';
|
import {PlaneSurfacePrototype} from '../../../../../web/app/cad/model/surfacePrototype';
|
||||||
import CSys from "math/csys";
|
import CSys from "math/csys";
|
||||||
import { EntityKind } from "cad/model/entities";
|
import {EntityKind} from "cad/model/entities";
|
||||||
import { TextureLoader, MeshBasicMaterial,MeshLambertMaterial, Mesh, DoubleSide, PlaneGeometry } from "three";
|
|
||||||
//import THREE from "three";
|
|
||||||
|
|
||||||
|
|
||||||
|
function paramsToPlane({ orientation, datum, depth }) {
|
||||||
|
|
||||||
function paramsToPlane({ orientation, datum, depth }, cadRegistry) {
|
|
||||||
const csys = datum ? datum.csys : CSys.ORIGIN;
|
const csys = datum ? datum.csys : CSys.ORIGIN;
|
||||||
|
|
||||||
let axis;
|
let axis;
|
||||||
|
|
@ -29,8 +25,8 @@ function paramsToPlane({ orientation, datum, depth }, cadRegistry) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function previewGeomProvider(params, {cadRegistry}) {
|
function previewGeomProvider(params) {
|
||||||
const plane = paramsToPlane(params, cadRegistry);
|
const plane = paramsToPlane(params);
|
||||||
const tr = plane.get3DTransformation();
|
const tr = plane.get3DTransformation();
|
||||||
const w = 375, h = 375;
|
const w = 375, h = 375;
|
||||||
const a = tr._apply(new Vector(-w, -h, 0));
|
const a = tr._apply(new Vector(-w, -h, 0));
|
||||||
|
|
@ -65,15 +61,15 @@ export default {
|
||||||
paramsInfo: ({ depth }) => `(${depth})`,
|
paramsInfo: ({ depth }) => `(${depth})`,
|
||||||
previewGeomProvider,
|
previewGeomProvider,
|
||||||
run: (params, { cadRegistry }) => {
|
run: (params, { cadRegistry }) => {
|
||||||
|
|
||||||
return {
|
return {
|
||||||
consumed: [],
|
consumed: [],
|
||||||
created: [new MOpenFaceShell(new PlaneSurfacePrototype(paramsToPlane(params, cadRegistry)))]
|
created: [new MOpenFaceShell(new PlaneSurfacePrototype(paramsToPlane(params)))]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
form: [
|
form: [
|
||||||
{
|
{
|
||||||
type: 'choice',
|
type: 'choice',
|
||||||
style: "dropdown",
|
|
||||||
label: 'orientation',
|
label: 'orientation',
|
||||||
name: 'orientation',
|
name: 'orientation',
|
||||||
style: 'radio',
|
style: 'radio',
|
||||||
|
|
@ -103,7 +99,6 @@ export default {
|
||||||
// name: 'image',
|
// name: 'image',
|
||||||
// optional: true,
|
// optional: true,
|
||||||
// label: 'Optional Image',
|
// label: 'Optional Image',
|
||||||
|
|
||||||
// },
|
// },
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -48,10 +48,6 @@ export function fillUpMissingFields(params: any, schema: OperationSchema, contex
|
||||||
for (const field of fields) {
|
for (const field of fields) {
|
||||||
const md = schema[field] as SchemaField;
|
const md = schema[field] as SchemaField;
|
||||||
|
|
||||||
if (md.optional) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
let val = params[field];
|
let val = params[field];
|
||||||
|
|
||||||
const isPrimitive =
|
const isPrimitive =
|
||||||
|
|
@ -59,7 +55,7 @@ export function fillUpMissingFields(params: any, schema: OperationSchema, contex
|
||||||
&& md.type !== Types.object
|
&& md.type !== Types.object
|
||||||
&& md.type !== Types.entity;
|
&& md.type !== Types.entity;
|
||||||
|
|
||||||
if (isPrimitive && isValueNotProvided(val)) {
|
if (isPrimitive && isValueNotProvided(val) && !md.optional) {
|
||||||
params[field] = md.defaultValue;
|
params[field] = md.defaultValue;
|
||||||
} else if (md.type === Types.object) {
|
} else if (md.type === Types.object) {
|
||||||
if (!val) {
|
if (!val) {
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,8 @@ import {SectionWidgetProps} from "cad/mdf/ui/SectionWidget";
|
||||||
export interface BooleanWidgetProps extends FieldBasicProps {
|
export interface BooleanWidgetProps extends FieldBasicProps {
|
||||||
|
|
||||||
type: 'boolean';
|
type: 'boolean';
|
||||||
simplify: boolean | true;
|
|
||||||
|
simplify?: boolean;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -42,8 +43,7 @@ export const BooleanWidgetDefinition = (props: BooleanWidgetProps) => ({
|
||||||
name: "simplify",
|
name: "simplify",
|
||||||
label: 'simplify',
|
label: 'simplify',
|
||||||
type: "checkbox",
|
type: "checkbox",
|
||||||
defaultValue: true,
|
defaultValue: true
|
||||||
optional: true,
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "targets",
|
name: "targets",
|
||||||
|
|
|
||||||
|
|
@ -45,7 +45,7 @@ export function ChoiceWidget(props: ChoiceWidgetProps) {
|
||||||
val = value;
|
val = value;
|
||||||
name = value;
|
name = value;
|
||||||
}
|
}
|
||||||
return <RadioButton value={val} key={val}>{name}</RadioButton>
|
return <RadioButton value={val} label={name} key={val} />
|
||||||
})}
|
})}
|
||||||
</RadioButtonsField>;
|
</RadioButtonsField>;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,12 +5,15 @@ export class MOpenFaceShell extends MShell {
|
||||||
|
|
||||||
private surfacePrototype: any;
|
private surfacePrototype: any;
|
||||||
|
|
||||||
constructor(surfacePrototype, csys) {
|
constructor(surfacePrototype, csys?) {
|
||||||
super();
|
super();
|
||||||
this.surfacePrototype = surfacePrototype;
|
this.surfacePrototype = surfacePrototype;
|
||||||
this.csys = csys;
|
this.csys = csys;
|
||||||
this.faces.push(new MFace(this.id + '/SURFACE', this,
|
this.faces.push(new MFace(this.id + '/SURFACE', this,
|
||||||
surfacePrototype.boundTo([], 100, 100), csys));
|
surfacePrototype.boundTo([], 100, 100), csys));
|
||||||
|
if (!this.csys) {
|
||||||
|
this.csys = this.face.csys;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
get face() {
|
get face() {
|
||||||
|
|
|
||||||
|
|
@ -45,7 +45,6 @@ export class MShell extends MObject {
|
||||||
export class MBrepShell extends MShell {
|
export class MBrepShell extends MShell {
|
||||||
|
|
||||||
brepShell: Shell;
|
brepShell: Shell;
|
||||||
csys: CartesianCSys;
|
|
||||||
brepRegistry: Map<TopoObject, MObject>;
|
brepRegistry: Map<TopoObject, MObject>;
|
||||||
|
|
||||||
constructor(shell, csys?) {
|
constructor(shell, csys?) {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue