Skip to content

Commit

Permalink
fixing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
xibyte committed Jul 19, 2020
1 parent 4f7e726 commit 7fe6828
Show file tree
Hide file tree
Showing 11 changed files with 63 additions and 26 deletions.
4 changes: 3 additions & 1 deletion cypress.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,7 @@
"pluginsFile": "test/cypress/plugins/index.js",
"screenshotsFolder": "test/cypress/screenshots",
"videosFolder": "test/cypress/videos",
"supportFile": "test/cypress/support/index.js"
"supportFile": "test/cypress/support/index.js",
"viewportWidth": 1600,
"viewportHeight": 1000
}
4 changes: 2 additions & 2 deletions modules/math/l3space.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export type Basis = [Vector, Vector, Vector];

export type Vec3 = [number, number, number];

export type Matrix3x4Data = [number, number, number, number, number, number, number, number, number, number, number, number];
export type Matrix3x4Data = [[number, number, number, number],[number, number, number, number],[number, number, number, number]];

const freeze = Object.freeze;

Expand Down Expand Up @@ -180,7 +180,7 @@ export class Matrix3 {
);
};

toArray(): [[number, number, number, number],[number, number, number, number],[number, number, number, number]] {
toArray(): Matrix3x4Data {
return [
[this.mxx, this.mxy, this.mxz, this.tx],
[this.myx, this.myy, this.myz, this.ty],
Expand Down
1 change: 1 addition & 0 deletions test/coreTests/testCases/craftExtrude.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {extrudeCube} from '../utils/scripts';
import {testExtrudeBezier} from "./craftExtrudeBasicShapes";

export const TEST_MODE = 'modellerUI';

Expand Down
9 changes: 6 additions & 3 deletions test/coreTests/testCases/craftRevolve.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
import {createPlaneAndOpenSketcher, extrudeCube} from '../utils/scripts';
import {testExtrudeCOI1Faces} from "./craftExtrude";

export const TEST_MODE = 'modellerUI';

testRevolveHalfWay.only = true;
export async function testRevolveHalfWay(env, ui) {
await createPlaneAndOpenSketcher(ui);
let sui = ui.openSketcher();
sui.addRectangle(20, -50, 50, 50);
sui.addRectangle(200, -500, 500, 500);
sui.changeToConstructionLayer();
sui.addSegment(0, -50, 0, 50);
sui.addSegment(0, -500, 0, 500);
ui.commitSketch();

ui.openWizard('REVOLVE');
ui.wizardContext.updateParam('angle', 180);
ui.select([0, 0, 10], [0, 0, -10]);
ui.simulateClickByRayCast([0, 0, 10], [0, 0, -10]);
ui.simulateClickByRayCast([100, 0, 10], [100, 0, -10]);
await ui.wizardOK();


Expand Down
2 changes: 1 addition & 1 deletion test/coreTests/utils/sketcherUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ export function addEllipticalArc(ctx, aX, aY, bX, bY, rX, rY) {
export function addBezier(ctx, aX, aY, bX, bY) {
[aX, aY] = modelToScreen(ctx.viewer, aX, aY);
[bX, bY] = modelToScreen(ctx.viewer, bX, bY);
ctx.actions['addBezierCurve'].action();
ctx.actions.BezierTool.invoke(ctx);
moveAndClickXY(ctx, aX, aY);
let curve = ctx.viewer.toolManager.tool.curve;
moveAndClickXY(ctx, bX, bY);
Expand Down
2 changes: 2 additions & 0 deletions test/cypress/support/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,10 @@ declare namespace Cypress {
}

export interface SketcherTPI {

addRectangle(x1: number, y1: number, x2: number, y2: number): any;

addCircle(x: number, y: number, r: number): any;
}

type vec3 = [number, number, number];
Expand Down
2 changes: 1 addition & 1 deletion web/app/cad/craft/e0/operationHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ function createRevolveCommand(request, {cadRegistry, sketchStorageService}) {

let pivot = cadRegistry.findSketchObject(request.axis).sketchPrimitive;
let tr = face.csys.outTransformation;
let vec = __CAD_APP.services.exposure.math.dir;
let vec = __CAD_APP.services.exposure.math.vec;
let axisOrigin = tr._apply3(pivot.a.data());
let axisDir = vec._normalize(vec._sub(tr._apply3(pivot.b.data()), axisOrigin))

Expand Down
2 changes: 2 additions & 0 deletions web/app/cad/sketch/sketcherPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import initReassignSketchMode from './reassignSketchMode';
import {Viewer} from "../../sketcher/viewer2d";
import {IO} from "../../sketcher/io";
import {Generator} from "../../sketcher/id-generator";
import {NOOP} from "gems/func";

export function defineStreams(ctx) {
ctx.streams.sketcher = {
Expand Down Expand Up @@ -79,6 +80,7 @@ export function activate(ctx) {
function updateSketchForFace(mFace) {
let sketch = ctx.sketchStorageService.readSketch(mFace.defaultSketchId);
mFace.setSketch(sketch);
ctx.craftService.models$.mutate(NOOP);// to reindex all entities
streams.sketcher.update.next(mFace);
}

Expand Down
40 changes: 33 additions & 7 deletions web/app/sketcher/constr/ANConstraints.ts
Original file line number Diff line number Diff line change
Expand Up @@ -336,17 +336,43 @@ export const ConstraintDefinitions
icon: PointOnCurveConstraintIcon,

defineParamsScope: ([pt, ellipse], callback) => {
ellipse.visitParams(callback);
callback(new Param(0, 't'));
pt.visitParams(callback);
ellipse.visitParams(callback);
callback(new Param(Math.atan2(pt.y - ellipse.c.y, pt.x - ellipse.c.x), 't'));
},

collectPolynomials: (polynomials, [p1x,p1y, p2x,p2y, r, t, px, py]) => {
const ellipsePoly = (p, t, p0, p1, p2, p3) => new Polynomial()
.monomial(-1);
collectPolynomials: (polynomials, [px,py, cx,cy, rx,ry, rot, t]) => {

polynomials.push(new Polynomial()
.monomial(-1)
.term(px, POW_1_FN)
.monomial()
.term(cx, POW_1_FN)
.monomial()
.term(rx, POW_1_FN)
.term(rot, COS_FN)
.term(t, COS_FN)
.monomial(-1)
.term(ry, POW_1_FN)
.term(rot, SIN_FN)
.term(t, SIN_FN)
);

polynomials.push(new Polynomial()
.monomial(-1)
.term(py, POW_1_FN)
.monomial()
.term(cy, POW_1_FN)
.monomial()
.term(rx, POW_1_FN)
.term(rot, SIN_FN)
.term(t, COS_FN)
.monomial()
.term(ry, POW_1_FN)
.term(rot, COS_FN)
.term(t, SIN_FN)
);

// polynomials.push(ellipsePoly());
// polynomials.push(ellipsePoly());
},

Expand Down Expand Up @@ -956,7 +982,7 @@ export interface ConstraintSchema {

id: string;
name: string,
icon: IconType,
icon?: IconType,
constants?: {
[name: string]: {
readOnly?: boolean;
Expand Down
2 changes: 1 addition & 1 deletion web/app/sketcher/constr/AlgNumSystem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {compositeFn} from "gems/func";
import {AlgNumConstraint} from "./ANConstraints";
import {SolverParam} from "./solverParam";

const DEBUG = true;
const DEBUG = false;

export class AlgNumSubSystem {

Expand Down
21 changes: 11 additions & 10 deletions web/app/sketcher/io.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,23 @@
import {Generator} from './id-generator'
import {Viewer} from './viewer2d'
import {Styles} from './styles'
import {Arc} from './shapes/arc'
import {EndPoint} from './shapes/point'
import {Segment} from './shapes/segment'
import {Circle} from './shapes/circle'
import {Ellipse} from './shapes/ellipse'
import {EllipticalArc} from './shapes/elliptical-arc'
import {BezierCurve} from './shapes/bezier-curve'
import {LinearDimension, AngleBetweenDimension, DiameterDimension, Dimension, HDimension, VDimension} from './shapes/dim'
import {
AngleBetweenDimension,
DiameterDimension,
Dimension,
HDimension,
LinearDimension,
VDimension
} from './shapes/dim'
import Vector from 'math/vector';
import exportTextData from 'gems/exportTextData';
import {AlgNumConstraint} from "./constr/ANConstraints";
import {AlgNumConstraint, ConstraintSerialization} from "./constr/ANConstraints";
import {SketchGenerator} from "./generators/sketchGenerator";
import {BoundaryGeneratorSchema} from "./generators/boundaryGenerator";
import {SketchTypes} from "./shapes/sketch-types";
Expand Down Expand Up @@ -41,12 +47,7 @@ export interface SketchFormat_V3 {
typeId: string
}[];

constraints: {
typeId: string,
objects: string[],
constants: {[key: string]: string},
annotations: any
}[];
constraints: ConstraintSerialization[];

}[];

Expand Down Expand Up @@ -125,7 +126,7 @@ export class IO {
skobj = Ellipse.read(obj.id, obj.data);
} else if (type === EllipticalArc.prototype.TYPE) {
skobj = EllipticalArc.read(obj.id, obj.data);
} else if (type === EllipticalArc.prototype.TYPE) {
} else if (type === BezierCurve.prototype.TYPE) {
skobj = BezierCurve.read(obj.id, obj.data);
}
if (skobj != null) {
Expand Down

0 comments on commit 7fe6828

Please sign in to comment.