diff --git a/web/app/brep/geom/impl/nurbs.js b/web/app/brep/geom/impl/nurbs.js index cc1c58ce..d6582529 100644 --- a/web/app/brep/geom/impl/nurbs.js +++ b/web/app/brep/geom/impl/nurbs.js @@ -85,8 +85,11 @@ export class NurbsSurface { this.verb = verbSurface; } - coplanarUnsigned(other, tolerance) { - const tess = this.verb.tessellate({maxDepth: 3}); + toNurbs() { + return this; + } + + coplanarUnsignedForSameClass(other, tolerance) { + throw 'not implemented' } - } \ No newline at end of file diff --git a/web/app/brep/geom/impl/plane.js b/web/app/brep/geom/impl/plane.js index 422c44a1..8a93fb18 100644 --- a/web/app/brep/geom/impl/plane.js +++ b/web/app/brep/geom/impl/plane.js @@ -52,16 +52,14 @@ export class Plane extends Surface { return this.__3dTr; } - coplanarUnsigned(other, tol) { - return other instanceof Plane && - math.areVectorsEqual(this.normal.multiply(this.w), other.normal.multiply(other.w), tol); + coplanarUnsignedForSameClass(other, tol) { + return math.areVectorsEqual(this.normal.multiply(this.w), other.normal.multiply(other.w), tol); //TODO: store this.normal.multiply(this.w) in a field since it's constant value } - equals(other, tol) { - return other instanceof Plane && - math.areVectorsEqual(this.normal, other.normal, tol) && - math.areEqual(this.w, other.w, tol); + equalsForSameClass(other, tol) { + return math.areVectorsEqual(this.normal, other.normal, tol) && + math.areEqual(this.w, other.w, tol); } toParametricForm() { diff --git a/web/app/brep/geom/surface.js b/web/app/brep/geom/surface.js index 3d655a20..1f81b7ab 100644 --- a/web/app/brep/geom/surface.js +++ b/web/app/brep/geom/surface.js @@ -13,8 +13,30 @@ export class Surface { throw 'not implemented'; } + coplanarUnsignedForSameClass(other, tol) { + throw 'not implemented'; + } + + equalsUnsignedForSameClass(other, tol) { + throw 'not implemented'; + } + isSameClass(other) { return this.constructor.name == other.constructor.name; } + + coplanarUnsigned(other, tol) { + if (this.isSameClass(other)) { + return this.coplanarUnsignedForSameClass(other, tol) + } + return this.toNurbs().coplanarUnsignedForSameClass(other.toNurbs()); + } + + equals(other, tol) { + if (this.isSameClass(other)) { + return this.equalsForSameClass(other, tol) + } + return this.toNurbs().equalsForSameClass(other.toNurbs()); + } } Surface.prototype.isPlane = false;