split face API

This commit is contained in:
Val Erastov (xibyte) 2020-12-09 23:16:57 -08:00
parent 65609aa500
commit dcc7ef512d
5 changed files with 86 additions and 10 deletions

View file

@ -5,6 +5,7 @@ import {PrimitiveData} from "engine/data/primitiveData";
import {EdgeTessellation, FaceTessellation, Tessellation2D} from "engine/tessellation";
import {BrepInputData} from "engine/data/brepInputData";
import {Matrix3x4FlatData} from "math/matrix";
import {CurveData} from "engine/data/curveData";
export enum BooleanType {
UNION = 1,
@ -133,6 +134,50 @@ export interface EngineAPI_V1 {
}): 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

View file

@ -1,12 +1,8 @@
import {Vec3} from "math/vec";
export interface CurveData {
export type CurveData = CurveBSplineData | CurveLineData | CurveUnknownData;
TYPE: string;
}
export interface CurveBSplineData extends CurveData {
export interface CurveBSplineData {
TYPE: "B-SPLINE";
@ -21,12 +17,15 @@ export interface CurveBSplineData extends CurveData {
}
export interface CurveLineData extends CurveData {
export interface CurveLineData {
TYPE: "LINE";
a: Vec3;
b: Vec3;
}
export interface CurveUnknownData extends CurveData {
export interface CurveUnknownData {
TYPE: "UNKNOWN";

View file

@ -49,6 +49,10 @@ export class GenericWASMEngine_V1 implements EngineAPI_V1 {
return callEngine(params, Module._SPI_revolve);
}
splitFace(params) {
return callEngine(params, Module._SPI_splitFace);
}
stepImport(params) {
return callEngine(params, Module._SPI_stepImport);
}

View file

@ -9,6 +9,7 @@ declare var Module: {
_SPI_extrude: Function;
_SPI_stepImport: Function;
_SPI_revolve: Function;
_SPI_splitFace: Function;
_SPI_loftPreview: Function;
_SPI_loft: Function;
_SPI_fillet: Function;

View file

@ -171,6 +171,32 @@ export function runSandbox(ctx: ApplicationContext) {
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);
}
@ -523,8 +549,9 @@ export function runSandbox(ctx: ApplicationContext) {
// window.voxelTest = voxelTest;
ctx.streams.lifecycle.projectLoaded.attach(ready => {
if (ready) {
//testVertexMoving(ctx);
test4();
// testVertexMoving(ctx);
// test4();
testSplitFace();
}
});