Skip to content

Commit

Permalink
More surface-surface intersection thoughts
Browse files Browse the repository at this point in the history
  • Loading branch information
pboyer committed Nov 30, 2014
1 parent 58d7e7e commit 56a07af
Show file tree
Hide file tree
Showing 12 changed files with 354 additions and 397 deletions.
30 changes: 9 additions & 21 deletions build/verb.js
Expand Up @@ -26,7 +26,7 @@ verb.eval.mesh = verb.eval.mesh || {};
// ####verb.EPSILON
//
// Used for numeric comparisons
verb.EPSILON = 1e-8;
verb.EPSILON = 1e-10;

// ####verb.TOLERANCE
//
Expand Down Expand Up @@ -3594,14 +3594,12 @@ verb.eval.nurbs.intersect_rational_surface_surface_by_aabb_refine = function( de
};

// todo: need to be able to predict the number of divisions
var tessOptions = { minDivsU: 20, minDivsV: 20, tol: 5e-2 };

var tess1 = verb.eval.nurbs.tessellate_rational_surface_adaptive( srfObj1.degree_u,
srfObj1.knots_u,
srfObj1.degree_v,
srfObj1.knots_v,
srfObj1.homo_control_points,
tessOptions );
srfObj1.homo_control_points);

var srfObj2 = {
degree_u : degree_u2,
Expand All @@ -3615,8 +3613,7 @@ verb.eval.nurbs.intersect_rational_surface_surface_by_aabb_refine = function( de
srfObj2.knots_u,
srfObj2.degree_v,
srfObj2.knots_v,
srfObj2.homo_control_points,
tessOptions );
srfObj2.homo_control_points);

var resApprox = verb.eval.mesh.intersect_meshes_by_aabb( tess1.points, tess1.faces, tess1.uvs, tess2.points, tess2.faces, tess2.uvs );

Expand All @@ -3630,7 +3627,7 @@ verb.eval.nurbs.intersect_rational_surface_surface_by_aabb_refine = function( de

// 3) perform cubic interpolation
return exactPls.map(function(x){
return verb.eval.nurbs.rational_interp_curve( x.map(function(x){ return x.pt; }), 2 );
return verb.eval.nurbs.rational_interp_curve( x.map(function(x){ return x.pt; }), 3 );
});

// TODO: represent this in uv space
Expand Down Expand Up @@ -3660,11 +3657,10 @@ verb.eval.mesh.intersect_meshes_by_aabb = function( points1, tris1, uvs1, points
res[1].tri2id = ids[1];

return res;
})
.filter(function(x){ return x; })
}).filter(function(x){ return x; })
.filter(function(x){
var dif = numeric.sub( x[0].pt, x[1].pt );
return numeric.dot( dif, dif ) > verb.TOLERANCE
return numeric.dot( dif, dif ) > verb.EPSILON
});

// TODO: this is too expensive and this only occurs when the intersection
Expand All @@ -3684,8 +3680,8 @@ verb.eval.mesh.intersect_meshes_by_aabb = function( points1, tris1, uvs1, points
var s4 = numeric.sub( a[1].uvtri1, b[0].uvtri1 );
var d4 = numeric.dot( s4, s4 );

return ( d1 < verb.TOLERANCE && d2 < verb.TOLERANCE ) ||
( d3 < verb.TOLERANCE && d4 < verb.TOLERANCE );
return ( d1 < verb.EPSILON && d2 < verb.EPSILON ) ||
( d3 < verb.EPSILON && d4 < verb.EPSILON );

});

Expand Down Expand Up @@ -3805,7 +3801,7 @@ verb.eval.mesh.lookup_adj_segment = function( segEnd, tree, numSegments ) {
// we expect one result to be self, one to be neighbor and no more
var adj = tree.nearest({ x: segEnd.pt[0], y: segEnd.pt[1], z: segEnd.pt[2] }, numResults)
.filter(function(r){
return segEnd != r[0].ele && r[1] < verb.TOLERANCE;
return segEnd != r[0].ele && r[1] < verb.EPSILON;
})
.map(function(r){ return r[0].ele; });

Expand Down Expand Up @@ -4760,14 +4756,6 @@ verb.eval.nurbs.AdaptiveRefinementNode.prototype.shouldDivide = function( option
this.splitHoriz = numeric.norm2Squared( numeric.sub( this.corners[1].normal, this.corners[2].normal ) ) > options.normTol ||
numeric.norm2Squared( numeric.sub( this.corners[3].normal, this.corners[0].normal ) ) > options.normTol;

// is curved in u direction?
// this.splitVert = verb.eval.nurbs.dist_to_seg( this.corners[0].point, this.midpoints[0].point, this.corners[1].point ) > options.edgeTol ||
// verb.eval.nurbs.dist_to_seg( this.corners[2].point, this.midpoints[2].point, this.corners[3].point ) > options.edgeTol;

// // is curved in v direction?
// this.splitHoriz = verb.eval.nurbs.dist_to_seg( this.corners[1].point, this.midpoints[1].point, this.corners[2].point ) > options.edgeTol ||
// verb.eval.nurbs.dist_to_seg( this.corners[0].point, this.midpoints[3].point, this.corners[3].point ) > options.edgeTol;

if ( this.splitVert || this.splitHoriz ) return true;

var center = this.center();
Expand Down
4 changes: 2 additions & 2 deletions build/verb.min.js

Large diffs are not rendered by default.

28 changes: 8 additions & 20 deletions build/verbEval.js
Expand Up @@ -1155,14 +1155,12 @@ verb.eval.nurbs.intersect_rational_surface_surface_by_aabb_refine = function( de
};

// todo: need to be able to predict the number of divisions
var tessOptions = { minDivsU: 20, minDivsV: 20, tol: 5e-2 };

var tess1 = verb.eval.nurbs.tessellate_rational_surface_adaptive( srfObj1.degree_u,
srfObj1.knots_u,
srfObj1.degree_v,
srfObj1.knots_v,
srfObj1.homo_control_points,
tessOptions );
srfObj1.homo_control_points);

var srfObj2 = {
degree_u : degree_u2,
Expand All @@ -1176,8 +1174,7 @@ verb.eval.nurbs.intersect_rational_surface_surface_by_aabb_refine = function( de
srfObj2.knots_u,
srfObj2.degree_v,
srfObj2.knots_v,
srfObj2.homo_control_points,
tessOptions );
srfObj2.homo_control_points);

var resApprox = verb.eval.mesh.intersect_meshes_by_aabb( tess1.points, tess1.faces, tess1.uvs, tess2.points, tess2.faces, tess2.uvs );

Expand All @@ -1191,7 +1188,7 @@ verb.eval.nurbs.intersect_rational_surface_surface_by_aabb_refine = function( de

// 3) perform cubic interpolation
return exactPls.map(function(x){
return verb.eval.nurbs.rational_interp_curve( x.map(function(x){ return x.pt; }), 2 );
return verb.eval.nurbs.rational_interp_curve( x.map(function(x){ return x.pt; }), 3 );
});

// TODO: represent this in uv space
Expand Down Expand Up @@ -1221,11 +1218,10 @@ verb.eval.mesh.intersect_meshes_by_aabb = function( points1, tris1, uvs1, points
res[1].tri2id = ids[1];

return res;
})
.filter(function(x){ return x; })
}).filter(function(x){ return x; })
.filter(function(x){
var dif = numeric.sub( x[0].pt, x[1].pt );
return numeric.dot( dif, dif ) > verb.TOLERANCE
return numeric.dot( dif, dif ) > verb.EPSILON
});

// TODO: this is too expensive and this only occurs when the intersection
Expand All @@ -1245,8 +1241,8 @@ verb.eval.mesh.intersect_meshes_by_aabb = function( points1, tris1, uvs1, points
var s4 = numeric.sub( a[1].uvtri1, b[0].uvtri1 );
var d4 = numeric.dot( s4, s4 );

return ( d1 < verb.TOLERANCE && d2 < verb.TOLERANCE ) ||
( d3 < verb.TOLERANCE && d4 < verb.TOLERANCE );
return ( d1 < verb.EPSILON && d2 < verb.EPSILON ) ||
( d3 < verb.EPSILON && d4 < verb.EPSILON );

});

Expand Down Expand Up @@ -1366,7 +1362,7 @@ verb.eval.mesh.lookup_adj_segment = function( segEnd, tree, numSegments ) {
// we expect one result to be self, one to be neighbor and no more
var adj = tree.nearest({ x: segEnd.pt[0], y: segEnd.pt[1], z: segEnd.pt[2] }, numResults)
.filter(function(r){
return segEnd != r[0].ele && r[1] < verb.TOLERANCE;
return segEnd != r[0].ele && r[1] < verb.EPSILON;
})
.map(function(r){ return r[0].ele; });

Expand Down Expand Up @@ -2321,14 +2317,6 @@ verb.eval.nurbs.AdaptiveRefinementNode.prototype.shouldDivide = function( option
this.splitHoriz = numeric.norm2Squared( numeric.sub( this.corners[1].normal, this.corners[2].normal ) ) > options.normTol ||
numeric.norm2Squared( numeric.sub( this.corners[3].normal, this.corners[0].normal ) ) > options.normTol;

// is curved in u direction?
// this.splitVert = verb.eval.nurbs.dist_to_seg( this.corners[0].point, this.midpoints[0].point, this.corners[1].point ) > options.edgeTol ||
// verb.eval.nurbs.dist_to_seg( this.corners[2].point, this.midpoints[2].point, this.corners[3].point ) > options.edgeTol;

// // is curved in v direction?
// this.splitHoriz = verb.eval.nurbs.dist_to_seg( this.corners[1].point, this.midpoints[1].point, this.corners[2].point ) > options.edgeTol ||
// verb.eval.nurbs.dist_to_seg( this.corners[0].point, this.midpoints[3].point, this.corners[3].point ) > options.edgeTol;

if ( this.splitVert || this.splitHoriz ) return true;

var center = this.center();
Expand Down
4 changes: 2 additions & 2 deletions build/verbEval.min.js

Large diffs are not rendered by default.

0 comments on commit 56a07af

Please sign in to comment.