mirror of
https://github.com/xibyte/jsketcher
synced 2025-12-07 08:53:25 +01:00
split face API
This commit is contained in:
parent
65609aa500
commit
dcc7ef512d
5 changed files with 86 additions and 10 deletions
|
|
@ -5,6 +5,7 @@ import {PrimitiveData} from "engine/data/primitiveData";
|
||||||
import {EdgeTessellation, FaceTessellation, Tessellation2D} from "engine/tessellation";
|
import {EdgeTessellation, FaceTessellation, Tessellation2D} from "engine/tessellation";
|
||||||
import {BrepInputData} from "engine/data/brepInputData";
|
import {BrepInputData} from "engine/data/brepInputData";
|
||||||
import {Matrix3x4FlatData} from "math/matrix";
|
import {Matrix3x4FlatData} from "math/matrix";
|
||||||
|
import {CurveData} from "engine/data/curveData";
|
||||||
|
|
||||||
export enum BooleanType {
|
export enum BooleanType {
|
||||||
UNION = 1,
|
UNION = 1,
|
||||||
|
|
@ -133,6 +134,50 @@ export interface EngineAPI_V1 {
|
||||||
|
|
||||||
}): GenericResponse;
|
}): GenericResponse;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Split face by edge
|
||||||
|
*/
|
||||||
|
splitFace(params: {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Base shape containing face to split
|
||||||
|
*/
|
||||||
|
shape: Handle;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Face to split
|
||||||
|
*/
|
||||||
|
face: Handle;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Splitting edge
|
||||||
|
*/
|
||||||
|
edge: {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Curve definition
|
||||||
|
*/
|
||||||
|
curve: CurveData;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Optional bounds for the splitting curve. If uMin supplied uMax should be supplied as well
|
||||||
|
*/
|
||||||
|
uMin?: number;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Optional bounds for the splitting curve. If uMax supplied uMin should be supplied as well
|
||||||
|
*/
|
||||||
|
uMax?: number;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tessellation detail parameter
|
||||||
|
*/
|
||||||
|
deflection: number;
|
||||||
|
|
||||||
|
|
||||||
|
}): GenericResponse;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Lightweight loft operation returning only tessellation info. Meant to be used as a preview in wizards
|
* Lightweight loft operation returning only tessellation info. Meant to be used as a preview in wizards
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,8 @@
|
||||||
import {Vec3} from "math/vec";
|
import {Vec3} from "math/vec";
|
||||||
|
|
||||||
export interface CurveData {
|
export type CurveData = CurveBSplineData | CurveLineData | CurveUnknownData;
|
||||||
|
|
||||||
TYPE: string;
|
export interface CurveBSplineData {
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface CurveBSplineData extends CurveData {
|
|
||||||
|
|
||||||
TYPE: "B-SPLINE";
|
TYPE: "B-SPLINE";
|
||||||
|
|
||||||
|
|
@ -21,12 +17,15 @@ export interface CurveBSplineData extends CurveData {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface CurveLineData extends CurveData {
|
export interface CurveLineData {
|
||||||
|
|
||||||
TYPE: "LINE";
|
TYPE: "LINE";
|
||||||
|
|
||||||
|
a: Vec3;
|
||||||
|
b: Vec3;
|
||||||
|
|
||||||
}
|
}
|
||||||
export interface CurveUnknownData extends CurveData {
|
export interface CurveUnknownData {
|
||||||
|
|
||||||
TYPE: "UNKNOWN";
|
TYPE: "UNKNOWN";
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -49,6 +49,10 @@ export class GenericWASMEngine_V1 implements EngineAPI_V1 {
|
||||||
return callEngine(params, Module._SPI_revolve);
|
return callEngine(params, Module._SPI_revolve);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
splitFace(params) {
|
||||||
|
return callEngine(params, Module._SPI_splitFace);
|
||||||
|
}
|
||||||
|
|
||||||
stepImport(params) {
|
stepImport(params) {
|
||||||
return callEngine(params, Module._SPI_stepImport);
|
return callEngine(params, Module._SPI_stepImport);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
1
modules/engine/impl/wasm/externals.d.ts
vendored
1
modules/engine/impl/wasm/externals.d.ts
vendored
|
|
@ -9,6 +9,7 @@ declare var Module: {
|
||||||
_SPI_extrude: Function;
|
_SPI_extrude: Function;
|
||||||
_SPI_stepImport: Function;
|
_SPI_stepImport: Function;
|
||||||
_SPI_revolve: Function;
|
_SPI_revolve: Function;
|
||||||
|
_SPI_splitFace: Function;
|
||||||
_SPI_loftPreview: Function;
|
_SPI_loftPreview: Function;
|
||||||
_SPI_loft: Function;
|
_SPI_loft: Function;
|
||||||
_SPI_fillet: Function;
|
_SPI_fillet: Function;
|
||||||
|
|
|
||||||
|
|
@ -171,6 +171,32 @@ export function runSandbox(ctx: ApplicationContext) {
|
||||||
services.exposure.addOnScene(mBrepShell2);
|
services.exposure.addOnScene(mBrepShell2);
|
||||||
|
|
||||||
|
|
||||||
|
// addShellOnScene(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
function testSplitFace() {
|
||||||
|
const box1 = exposure.brep.primitives.box(500, 500, 500);
|
||||||
|
|
||||||
|
const serialized = writeBrep(box1);
|
||||||
|
const loaded = ctx.craftEngine.modellingEngine.loadModel(serialized);
|
||||||
|
const face = loaded.faces[0];
|
||||||
|
const [e1, e2] = face.loops[0];
|
||||||
|
|
||||||
|
const splitted = ctx.craftEngine.modellingEngine.splitFace({
|
||||||
|
deflection: DEFLECTION,
|
||||||
|
shape: loaded.ptr,
|
||||||
|
face: face.ptr,
|
||||||
|
edge: {
|
||||||
|
curve: {
|
||||||
|
TYPE: 'LINE',
|
||||||
|
a: [-250, -250, -250],
|
||||||
|
b: [ 250, -250, 250]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
services.exposure.addOnScene(readShellEntityFromJson(splitted));
|
||||||
|
|
||||||
// addShellOnScene(result);
|
// addShellOnScene(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -523,8 +549,9 @@ export function runSandbox(ctx: ApplicationContext) {
|
||||||
// window.voxelTest = voxelTest;
|
// window.voxelTest = voxelTest;
|
||||||
ctx.streams.lifecycle.projectLoaded.attach(ready => {
|
ctx.streams.lifecycle.projectLoaded.attach(ready => {
|
||||||
if (ready) {
|
if (ready) {
|
||||||
//testVertexMoving(ctx);
|
// testVertexMoving(ctx);
|
||||||
test4();
|
// test4();
|
||||||
|
testSplitFace();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue