mirror of
https://github.com/xibyte/jsketcher
synced 2025-12-22 08:26:26 +01:00
fix typescript type errors, sketchModel
This commit is contained in:
parent
dff06f1972
commit
8afc46bd48
4 changed files with 30 additions and 39 deletions
|
|
@ -5,7 +5,7 @@ export default class VectorFactory {
|
|||
|
||||
vectors: Vector[];
|
||||
|
||||
constructor(tolerance) {
|
||||
constructor() {
|
||||
this.vectors = [];
|
||||
}
|
||||
|
||||
|
|
@ -24,7 +24,7 @@ export default class VectorFactory {
|
|||
return null;
|
||||
}
|
||||
|
||||
create(x, y, z, onExistent): Vector {
|
||||
create(x, y, z, onExistent?): Vector {
|
||||
let vector = this.find(x, y, z);
|
||||
if (vector === null) {
|
||||
vector = new Vector(x, y, z);
|
||||
|
|
|
|||
|
|
@ -2,6 +2,6 @@ import React from 'react';
|
|||
import ls from './Row.less';
|
||||
import cx from 'classnames';
|
||||
|
||||
export default function Row({className, props, children}) {
|
||||
export default function Row({className, children, ...props}) {
|
||||
return <div className={cx(ls.root, className)} {...props} >{children}</div>;
|
||||
}
|
||||
|
|
@ -11,7 +11,7 @@ import {OCCCommandInterface} from "cad/craft/e0/occCommandInterface";
|
|||
|
||||
const RESOLUTION = 20;
|
||||
|
||||
class SketchPrimitive {
|
||||
export class SketchPrimitive {
|
||||
|
||||
id: string;
|
||||
inverted: boolean;
|
||||
|
|
@ -195,6 +195,11 @@ export class Arc extends SketchPrimitive {
|
|||
}
|
||||
|
||||
export class BezierCurve extends SketchPrimitive {
|
||||
a: Vector;
|
||||
b: Vector;
|
||||
cp1: Vector;
|
||||
cp2: Vector;
|
||||
|
||||
constructor(id, a, b, cp1, cp2) {
|
||||
super(id);
|
||||
this.a = a;
|
||||
|
|
@ -209,6 +214,14 @@ export class BezierCurve extends SketchPrimitive {
|
|||
}
|
||||
|
||||
export class EllipticalArc extends SketchPrimitive {
|
||||
|
||||
c: Vector;
|
||||
rx: number;
|
||||
ry: number;
|
||||
rot: number
|
||||
a: Vector;
|
||||
b: Vector;
|
||||
|
||||
constructor(id, c, rx, ry, rot, a, b) {
|
||||
super(id);
|
||||
this.c = c;
|
||||
|
|
@ -266,6 +279,12 @@ export class Circle extends SketchPrimitive {
|
|||
}
|
||||
|
||||
export class Ellipse extends SketchPrimitive {
|
||||
|
||||
c: Vector;
|
||||
rx: number;
|
||||
ry: number;
|
||||
rot: number
|
||||
|
||||
constructor(id, c, rx, ry, rot) {
|
||||
super(id);
|
||||
this.c = c;
|
||||
|
|
@ -345,21 +364,6 @@ export class Contour {
|
|||
}
|
||||
}
|
||||
|
||||
class CompositeCurve {
|
||||
|
||||
constructor() {
|
||||
this.curves = [];
|
||||
this.points = [];
|
||||
this.groups = [];
|
||||
}
|
||||
|
||||
add(curve, point, group) {
|
||||
this.curves.push(curve);
|
||||
this.points.push(point);
|
||||
this.groups.push(group);
|
||||
}
|
||||
}
|
||||
|
||||
function adjustEnds(arc, a, b) {
|
||||
let data = arc.asNurbs();
|
||||
|
||||
|
|
|
|||
|
|
@ -5,14 +5,15 @@ import Joints from 'gems/joints';
|
|||
import sketchObjectGlobalId from './sketchObjectGlobalId';
|
||||
import VectorFactory from 'math/vectorFactory';
|
||||
import {strictEqual2D} from "math/equality";
|
||||
import {Contour, Segment} from "./sketchModel";
|
||||
import {Contour, Segment, SketchPrimitive} from "./sketchModel";
|
||||
import Vector from "math/vector";
|
||||
|
||||
export class SketchGeom {
|
||||
|
||||
private connections: Segment[];
|
||||
private loops: Segment[];
|
||||
private constructionSegments: Segment[];
|
||||
private _contours: Contour[];
|
||||
connections: SketchPrimitive[];
|
||||
loops: SketchPrimitive[];
|
||||
constructionSegments: SketchPrimitive[];
|
||||
_contours: Contour[];
|
||||
|
||||
constructor() {
|
||||
this.connections = [];
|
||||
|
|
@ -31,20 +32,6 @@ export class SketchGeom {
|
|||
get contours(): Contour[] {
|
||||
return this.fetchContours();
|
||||
}
|
||||
|
||||
findById(id) {
|
||||
function _find() {
|
||||
for (let arr of arguments) {
|
||||
for (let segment of arr) {
|
||||
if (segment.id === id) {
|
||||
return segment;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
return _find(this.connections, this.loops, this.constructionSegments);
|
||||
}
|
||||
|
||||
getAllObjects() {
|
||||
return [...this.connections, ...this.loops, ...this.constructionSegments];
|
||||
|
|
@ -69,7 +56,7 @@ export function ReadSketch(sketch, sketchId, readConstructionSegments) {
|
|||
}
|
||||
let vectorFactory = new VectorFactory();
|
||||
let pointsById = new Map();
|
||||
function ReadSketchPoint(pt) {
|
||||
function ReadSketchPoint(pt): Vector {
|
||||
return vectorFactory.create(pt.x, pt.y, 0);
|
||||
}
|
||||
if (sketch.version !== 3) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue