implement 'surface gauge' for asserting the cad scene

This commit is contained in:
Val Erastov 2019-02-15 19:40:30 -08:00
parent beecafa9c2
commit 6817c66cca
2 changed files with 37 additions and 1 deletions

View file

@ -15,6 +15,7 @@ import {Plane} from '../../brep/geom/impl/plane';
import pip from '../tess/pip';
import {readShellEntityFromJson} from '../scene/wrappers/entityIO';
import * as vec from '../../math/vec'
import NurbsSurface from '../../brep/geom/surfaces/nurbsSurface';
export default {
@ -26,7 +27,9 @@ export default {
pip,
validator: BREPValidator,
geom: {
Point, BrepCurve, Plane, createBoundingSurface
Point, BrepCurve,
Plane, createBoundingSurface,
NurbsSurface
},
topo: {
Edge, Loop, Face, Shell, Vertex

View file

@ -0,0 +1,33 @@
import * as vec from '../../app/math/math'
import {assertFaceOrigination, assertFaceRole} from './asserts';
export class SurfaceGauge {
constructor(surface, rayCast) {
this.surface = surface;
this.rayCast = rayCast;
}
sample(u, v, delta = 10) {
let normal = this.surface.normal(u, v);
let pt = this.surface.point(u, v);
let deltaV = vec.mul(normal, delta);
let [face] = ui.rayCastFaces(vec.add(pt, deltaV), vec.sub(pt, deltaV));
let sampleAssertations = {
assertFaceOrigination: (sketchId, primitiveId) => {
assertFaceOrigination(face, sketchId, primitiveId);
return sampleAssertations;
},
assertFaceRole: role => {
assertFaceRole(face, role);
return sampleAssertations
}
}
}
static prism(surfaceImpl, a, b, c, d) {
return new SurfaceGauge(surfaceImpl(1, 1, [0,0,1,1], [0,0,1,1],
[ [ a, b] ,
[ c, d ] ] ));
}
}