mirror of
https://github.com/xibyte/jsketcher
synced 2025-12-23 17:04:00 +01:00
implement 'surface gauge' for asserting the cad scene
This commit is contained in:
parent
beecafa9c2
commit
6817c66cca
2 changed files with 37 additions and 1 deletions
|
|
@ -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
|
||||
|
|
|
|||
33
web/test/utils/surfaceGauge.js
Normal file
33
web/test/utils/surfaceGauge.js
Normal 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 ] ] ));
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue