diff --git a/web/test/cases/craftCut.js b/web/test/cases/craftCut.js index 3f6e660a..4e7e3000 100644 --- a/web/test/cases/craftCut.js +++ b/web/test/cases/craftCut.js @@ -7,7 +7,7 @@ export function testCutMid(env, ui) { ui.selectFaces([0, 0, 210], [0, 0, 190]); let sui = ui.openSketcher(); - sui.addPolygon(-50, -50, 50, 50); + sui.addRectangle(-50, -50, 50, 50); ui.commitSketch(); ui.openWizard('CUT'); @@ -22,7 +22,7 @@ export function testCutCOI1Faces(env, ui) { ui.selectFaces([0, 0, 210], [0, 0, 190]); let sui = ui.openSketcher(); - sui.addPolygon(0, 0, 80, 100); + sui.addRectangle(0, 0, 80, 100); ui.commitSketch(); ui.openWizard('CUT'); @@ -37,7 +37,7 @@ export function testCutCOI2Faces(env, ui) { ui.selectFaces([0, 0, 210], [0, 0, 190]); let sui = ui.openSketcher(); - sui.addPolygon(0, 0, 100, 100); + sui.addRectangle(0, 0, 100, 100); ui.commitSketch(); ui.openWizard('CUT'); @@ -52,7 +52,7 @@ export function testCutCOI3Faces(env, ui) { ui.selectFaces([0, 0, 210], [0, 0, 190]); let sui = ui.openSketcher(); - sui.addPolygon(0, -100, 100, 100); + sui.addRectangle(0, -100, 100, 100); ui.commitSketch(); ui.openWizard('CUT'); @@ -67,7 +67,7 @@ export function testCutCOI4Faces(env, ui) { ui.selectFaces([0, 0, 210], [0, 0, 190]); let sui = ui.openSketcher(); - sui.addPolygon(-100, -100, 100, 100); + sui.addRectangle(-100, -100, 100, 100); ui.commitSketch(); ui.openWizard('CUT'); @@ -84,7 +84,7 @@ export function testCutMidAllWay(env, ui) { ui.selectFaces([0, 0, 210], [0, 0, 190]); let sui = ui.openSketcher(); - sui.addPolygon(-50, -50, 50, 50); + sui.addRectangle(-50, -50, 50, 50); ui.commitSketch(); ui.openWizard('CUT'); @@ -99,7 +99,7 @@ export function testCutCOI1FacesAllWay(env, ui) { ui.selectFaces([0, 0, 210], [0, 0, 190]); let sui = ui.openSketcher(); - sui.addPolygon(0, 0, 80, 100); + sui.addRectangle(0, 0, 80, 100); ui.commitSketch(); ui.openWizard('CUT'); @@ -114,7 +114,7 @@ export function testCutCOI2FacesAllWay(env, ui) { ui.selectFaces([0, 0, 210], [0, 0, 190]); let sui = ui.openSketcher(); - sui.addPolygon(0, 0, 100, 100); + sui.addRectangle(0, 0, 100, 100); ui.commitSketch(); ui.openWizard('CUT'); @@ -129,7 +129,7 @@ export function testCutCOI3FacesAllWay(env, ui) { ui.selectFaces([0, 0, 210], [0, 0, 190]); let sui = ui.openSketcher(); - sui.addPolygon(0, -100, 100, 100); + sui.addRectangle(0, -100, 100, 100); ui.commitSketch(); ui.openWizard('CUT'); @@ -144,7 +144,7 @@ export function testCutCOI4FacesAllWay(env, ui) { ui.selectFaces([0, 0, 210], [0, 0, 190]); let sui = ui.openSketcher(); - sui.addPolygon(-100, -100, 100, 100); + sui.addRectangle(-100, -100, 100, 100); ui.commitSketch(); ui.openWizard('CUT'); diff --git a/web/test/cases/craftExtrude.js b/web/test/cases/craftExtrude.js index 6ff06193..831cbe55 100644 --- a/web/test/cases/craftExtrude.js +++ b/web/test/cases/craftExtrude.js @@ -7,7 +7,7 @@ export function testExtrudeMid(env, ui) { ui.selectFaces([0, 0, 210], [0, 0, 190]); let sui = ui.openSketcher(); - sui.addPolygon(-50, -50, 50, 50); + sui.addRectangle(-50, -50, 50, 50); ui.commitSketch(); ui.openWizard('EXTRUDE'); @@ -22,7 +22,7 @@ export function testExtrudeCOI1Faces(env, ui) { ui.selectFaces([0, 0, 210], [0, 0, 190]); let sui = ui.openSketcher(); - sui.addPolygon(0, 0, 80, 100); + sui.addRectangle(0, 0, 80, 100); ui.commitSketch(); ui.openWizard('EXTRUDE'); @@ -37,7 +37,7 @@ export function testExtrudeCOI2Faces(env, ui) { ui.selectFaces([0, 0, 210], [0, 0, 190]); let sui = ui.openSketcher(); - sui.addPolygon(0, 0, 100, 100); + sui.addRectangle(0, 0, 100, 100); ui.commitSketch(); ui.openWizard('EXTRUDE'); @@ -52,7 +52,7 @@ export function testExtrudeCOI3Faces(env, ui) { ui.selectFaces([0, 0, 210], [0, 0, 190]); let sui = ui.openSketcher(); - sui.addPolygon(0, -100, 100, 100); + sui.addRectangle(0, -100, 100, 100); ui.commitSketch(); ui.openWizard('EXTRUDE'); @@ -67,7 +67,7 @@ export function testExtrudeCOI4Faces(env, ui) { ui.selectFaces([0, 0, 210], [0, 0, 190]); let sui = ui.openSketcher(); - sui.addPolygon(-100, -100, 100, 100); + sui.addRectangle(-100, -100, 100, 100); ui.commitSketch(); ui.openWizard('EXTRUDE'); diff --git a/web/test/cases/craftExtrudeOptions.js b/web/test/cases/craftExtrudeOptions.js index a4d09b86..1fdcd4c1 100644 --- a/web/test/cases/craftExtrudeOptions.js +++ b/web/test/cases/craftExtrudeOptions.js @@ -6,7 +6,7 @@ export const TEST_MODE = 'modellerUI'; export function testExtrudePrism(env, ui) { let sketcherUI = createPlaneAndOpenSketcher(ui); let sketchedFace = ui.context.services.selection.face.single; - let [S1, S2, S3, S4] = sketcherUI.addPolygon(-100, -100, 100, 100); + let [S1, S2, S3, S4] = sketcherUI.addRectangle(-100, -100, 100, 100); // let gauge = ui.prismSurfaceGauge([-100, -100, 0], [100, -100, 0], [50, 50, 0], [-50, 50, 0] ); // diff --git a/web/test/cases/craftLoft.js b/web/test/cases/craftLoft.js index 28d58296..361d082f 100644 --- a/web/test/cases/craftLoft.js +++ b/web/test/cases/craftLoft.js @@ -4,7 +4,7 @@ export const TEST_MODE = 'modellerUI'; export function testLoftOver2Sections(env, ui) { let sui = createPlaneAndOpenSketcher(ui); - sui.addPolygon(-100, -100, 100, 100); + sui.addRectangle(-100, -100, 100, 100); ui.commitSketch(); ui.openWizard('PLANE'); @@ -12,7 +12,7 @@ export function testLoftOver2Sections(env, ui) { ui.wizardOK(); ui.selectFaces([0, 0, 290], [0, 0, 310]); sui = ui.openSketcher(); - sui.addSerpinski([-100, 0], [100, 0], 2); + sui.addRectangle([0, -100], [100, 100], [-100, 100]); ui.commitSketch(); ui.openWizard('LOFT'); diff --git a/web/test/cases/craftRevolve.js b/web/test/cases/craftRevolve.js index cc840310..804f7471 100644 --- a/web/test/cases/craftRevolve.js +++ b/web/test/cases/craftRevolve.js @@ -5,7 +5,7 @@ export const TEST_MODE = 'modellerUI'; export function testRevolveHalfWay(env, ui) { createPlaneAndOpenSketcher(ui); let sui = ui.openSketcher(); - sui.addPolygon(20, -50, 50, 50); + sui.addRectangle(20, -50, 50, 50); sui.changeToConstructionLayer(); sui.addSegment(0, -50, 0, 50); ui.commitSketch(); @@ -21,7 +21,7 @@ export function testRevolveHalfWay(env, ui) { export function testRevolveAllWay(env, ui) { createPlaneAndOpenSketcher(ui); let sui = ui.openSketcher(); - sui.addPolygon(20, -50, 50, 50); + sui.addRectangle(20, -50, 50, 50); sui.changeToConstructionLayer(); sui.addSegment(0, -50, 0, 50); ui.commitSketch(); diff --git a/web/test/utils/scripts.js b/web/test/utils/scripts.js index 2942906b..045ca16d 100644 --- a/web/test/utils/scripts.js +++ b/web/test/utils/scripts.js @@ -8,7 +8,7 @@ export function createPlaneAndOpenSketcher(ui) { export function extrudeCube(ui) { let sketcherUI = createPlaneAndOpenSketcher(ui); - sketcherUI.addPolygon(-100, -100, 100, 100); + sketcherUI.addRectangle(-100, -100, 100, 100); ui.commitSketch(); ui.selectFaces([0, 0, -10], [0, 0, 10]); ui.openWizard('EXTRUDE'); diff --git a/web/test/utils/subjects/modeller/sketcherUISubject.js b/web/test/utils/subjects/modeller/sketcherUISubject.js index 253ddb63..2d0612a1 100644 --- a/web/test/utils/subjects/modeller/sketcherUISubject.js +++ b/web/test/utils/subjects/modeller/sketcherUISubject.js @@ -28,7 +28,7 @@ export function createSubjectFromInPlaceSketcher(ctx) { const addEllipticalArc = sketcher_utils.addEllipticalArc.bind(this, oldStyleSketcherApp); const addBezier = sketcher_utils.addBezier.bind(this, oldStyleSketcherApp); const move = sketcher_utils.moveInModel.bind(this, oldStyleSketcherApp); - function addPolygon(x0, y0, x1, y1) { + function addRectangle(x0, y0, x1, y1) { return [ addSegment(x0, y0, x1, y0), addSegment(x1, y0, x1, y1), @@ -40,24 +40,25 @@ export function createSubjectFromInPlaceSketcher(ctx) { 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; let dy = by - ay; - let D = Math.sqrt(dx*dx + dy*dy); - dx /= D; dy /= D; - let ddx = -dy * jointWidth; let ddy = dx * jointWidth; - - genSerpinskiImpl(ctx.services.sketcher.inPlaceEditor.viewer, {x: bx-ddx, y: by-ddy}, {x: ax-ddx, y: ay-ddy}, depth); addSegment(ax, ay, ax-ddx, ay-ddy); addSegment(bx, by, bx-ddx, by-ddy); } + function addPolygon(points) { + let p, q, n = points.length; + for(p = n - 1, q = 0; q < n; p = q++) { + addSegment(p, q); + } + } + function changeLayer(layerName) { ctx.services.sketcher.inPlaceEditor.viewer.setActiveLayerName(layerName); } @@ -71,8 +72,8 @@ export function createSubjectFromInPlaceSketcher(ctx) { } return { - addSegment, addPolygon, addArc, addCircle, addEllipse, addEllipticalArc, addSerpinski, addBezier, - move, changeLayer, changeToConstructionLayer, changeToDefaultLayer, + addSegment, addRectangle, addArc, addCircle, addEllipse, addEllipticalArc, addSerpinski, addBezier, addPolygon, + move, changeLayer, changeToConstructionLayer, changeToDefaultLayer } } \ No newline at end of file