mirror of
https://github.com/xibyte/jsketcher
synced 2025-12-11 19:05:07 +01:00
brep / move nurbs implementation code out to the nurbs-impl module
This commit is contained in:
parent
cbf5739c36
commit
7aea6bd872
2 changed files with 10 additions and 7 deletions
|
|
@ -113,9 +113,7 @@ export function curveClosestParam(curve, point) {
|
|||
return verb.eval.Analyze.rationalCurveClosestParam(curve, point);
|
||||
}
|
||||
|
||||
export function verb_surface_isec(nurbs1, nurbs2) {
|
||||
const surface0 = nurbs1.asNurbs();
|
||||
const surface1 = nurbs2.asNurbs();
|
||||
export function surfaceIntersect(surface0, surface1) {
|
||||
const tess1 = verb.eval.Tess.rationalSurfaceAdaptive(surface0);
|
||||
const tess2 = verb.eval.Tess.rationalSurfaceAdaptive(surface1);
|
||||
const resApprox = verb.eval.Intersect.meshes(tess1,tess2);
|
||||
|
|
@ -127,11 +125,15 @@ export function verb_surface_isec(nurbs1, nurbs2) {
|
|||
return exactPls.map(function(x) {
|
||||
return verb.eval.Make.rationalInterpCurve(x.map(function(y) {
|
||||
return y.point;
|
||||
}), x.length - 1);
|
||||
}), surfaceMaxDegree(surface0) === 1 && surfaceMaxDegree(surface1) === 1 ? 1 : x.length - 1);
|
||||
}).map(cd => new verb.geom.NurbsCurve(cd));
|
||||
}
|
||||
|
||||
export function verb_curve_isec(curve1, curve2) {
|
||||
export function surfaceMaxDegree(surface) {
|
||||
return Math.max(surface.degreeU, surface.degreeV);
|
||||
}
|
||||
|
||||
export function curveIntersect(curve1, curve2) {
|
||||
|
||||
let result = [];
|
||||
let segs1 = curveTessellate(curve1);
|
||||
|
|
|
|||
|
|
@ -118,7 +118,7 @@ export class NurbsCurve extends Curve {
|
|||
isecOn(other, this, 0);
|
||||
isecOn(other, this, 1);
|
||||
|
||||
impl.verb_curve_isec(this.data, other.data, tol).forEach( i => add({
|
||||
impl.curveIntersect(this.data, other.data, tol).forEach(i => add({
|
||||
u0: i.u0,
|
||||
u1: i.u1,
|
||||
p0: i.point0,
|
||||
|
|
@ -149,6 +149,7 @@ export class NurbsSurface extends Surface {
|
|||
|
||||
constructor(verbSurface, inverted) {
|
||||
super();
|
||||
this.data = verbSurface.asNurbs();
|
||||
this.verb = verbSurface;
|
||||
this.inverted = inverted === true;
|
||||
this.mirrored = NurbsSurface.isMirrored(this);
|
||||
|
|
@ -217,7 +218,7 @@ export class NurbsSurface extends Surface {
|
|||
}
|
||||
|
||||
intersectSurfaceForSameClass(other, tol) {
|
||||
const curves = impl.verb_surface_isec(this.verb, other.verb, tol);
|
||||
const curves = impl.surfaceIntersect(this.data, other.data, tol);
|
||||
let inverted = this.inverted !== other.inverted;
|
||||
return curves.map(curve => new NurbsCurve(inverted ? curve.reverse() : curve));
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue