From 9983904a707f683950d0e7a85a130a41bcafa3b4 Mon Sep 17 00:00:00 2001 From: Val Erastov Date: Tue, 27 Jun 2017 19:22:37 -0700 Subject: [PATCH] Some method for generic boolean algorithm --- web/app/brep/geom/impl/nurbs.js | 9 ++++++--- web/app/brep/geom/impl/plane.js | 12 +++++------- web/app/brep/geom/surface.js | 22 ++++++++++++++++++++++ 3 files changed, 33 insertions(+), 10 deletions(-) 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;