craft loft tests

This commit is contained in:
Val Erastov 2019-02-19 12:23:55 -08:00
parent ce25b3b521
commit 30eb68774c
2 changed files with 59 additions and 5 deletions

View file

@ -12,7 +12,7 @@ export function testLoftOver2Sections(env, ui) {
ui.wizardOK();
ui.selectFaces([0, 0, 290], [0, 0, 310]);
sui = ui.openSketcher();
sui.addRectangle([0, -100], [100, 100], [-100, 100]);
sui.addPolygon([0, -100], [100, 100], [-100, 100]);
ui.commitSketch();
ui.openWizard('LOFT');
@ -22,5 +22,57 @@ export function testLoftOver2Sections(env, ui) {
env.done();
}
export function testLoftOver3Sections(env, ui) {
let sui = createPlaneAndOpenSketcher(ui);
sui.addRectangle(-100, -100, 100, 100);
ui.commitSketch();
ui.openWizard('PLANE');
ui.wizardContext.updateParam('depth', 300);
ui.wizardOK();
ui.selectFaces([0, 0, 290], [0, 0, 310]);
sui = ui.openSketcher();
sui.addPolygon([0, -100], [100, 100], [-100, 100]);
ui.commitSketch();
ui.openWizard('PLANE');
ui.wizardContext.updateParam('depth', 600);
ui.wizardOK();
ui.selectFaces([0, 0, 590], [0, 0, 610]);
sui = ui.openSketcher();
sui.addPolygon([0, 100], [100, -100], [-100, -100]);
ui.commitSketch();
ui.openWizard('LOFT');
ui.select([-3, -3, 610], [-3, -3, 590]);
ui.select([-3, -3, 310], [-3, -3, 290]);
ui.select([-3, -3, -10], [-3, -3, 10]);
ui.wizardOK();
env.done();
}
export function testLoftCircleSections(env, ui) {
let sui = createPlaneAndOpenSketcher(ui);
sui.addRectangle(-100, -100, 100, 100);
ui.commitSketch();
ui.openWizard('PLANE');
ui.wizardContext.updateParam('depth', 300);
ui.wizardOK();
ui.selectFaces([0, 0, 290], [0, 0, 310]);
sui = ui.openSketcher();
sui.addCircle(0, 0, 100);
ui.commitSketch();
ui.openWizard('LOFT');
ui.select([-3, -3, 310], [-3, -3, 290]);
ui.select([-3, -3, -10], [-3, -3, 10]);
ui.wizardOK();
env.done();
}

View file

@ -37,7 +37,7 @@ export function createSubjectFromInPlaceSketcher(ctx) {
];
}
function addSerpinski([ax, ay], [bx, by], depth) {
function addSerpinski(ax, ay, bx, by, depth) {
genSerpinskiImpl(ctx.services.sketcher.inPlaceEditor.viewer, {x: ax, y: ay}, {x: bx, y: by}, depth);
let jointWidth = distance(ax, ay, bx, by) / (depth + 1) / 2;
let dx = bx - ax;
@ -52,10 +52,12 @@ export function createSubjectFromInPlaceSketcher(ctx) {
addSegment(bx, by, bx-ddx, by-ddy);
}
function addPolygon(points) {
let p, q, n = points.length;
function addPolygon() {
let p, q, n = arguments.length;
for(p = n - 1, q = 0; q < n; p = q++) {
addSegment(p, q);
let [ax, ay] = arguments[p];
let [bx, by] = arguments[q];
addSegment(ax, ay, bx, by);
}
}