diff --git a/web/app/brep/io/brepIO.js b/web/app/brep/io/brepIO.js index 0189eaf7..892757bf 100644 --- a/web/app/brep/io/brepIO.js +++ b/web/app/brep/io/brepIO.js @@ -7,6 +7,8 @@ import {Plane} from '../geom/impl/plane'; import Vector from '../../../../modules/math/vector'; import NullSurface from '../geom/surfaces/nullSurface'; import BBox from '../../math/bbox'; +import NurbsCurve from '../geom/curves/nurbsCurve'; +import BrepCurve from '../geom/curves/brepCurve'; export function readBrep(data) { @@ -78,8 +80,7 @@ function readSurface(s, inverted, face) { function readCurve(curve) { switch (curve.TYPE) { case 'B-SPLINE': - console.dir(curve); - + return new BrepCurve(NurbsCurve.create(curve.deg, curve.knots, curve.cp, curve.weights)); case 'CONIC': //... case 'LINE': diff --git a/web/app/cad/sketch/sketchBoundaries.js b/web/app/cad/sketch/sketchBoundaries.js index 37ee1d42..1454b9cf 100644 --- a/web/app/cad/sketch/sketchBoundaries.js +++ b/web/app/cad/sketch/sketchBoundaries.js @@ -1,9 +1,21 @@ -import {Matrix3} from "../../math/l3space"; -import {circleFromPoints, distanceAB, TOLERANCE} from "../../math/math"; -import {iteratePath} from "../cad-utils"; +import {circleFromPoints, distanceAB, TOLERANCE} from '../../math/math'; +import {iteratePath} from '../cad-utils'; +import NurbsCurve from '../../brep/geom/curves/nurbsCurve'; export function getSketchBoundaries(sceneFace) { - const boundary = {lines: [], arcs: [], circles: []}; + const boundary = {lines: [], arcs: [], circles: [], nurbses: []}; + let w2sTr = sceneFace.worldToSketchTransformation; + let _w2sTrArr = null; + let w2sTrArr = () => _w2sTrArr || (_w2sTrArr = w2sTr.toArray()); + for (let he of sceneFace.brepFace.edges) { + if (he.edge.curve.impl.constructor.name === 'NurbsCurve' && he.edge.curve.impl.degree() !== 1) { + boundary.nurbses.push(he.edge.curve.impl.transform(w2sTrArr()).serialize()) + } else { + addSegment(w2sTr.apply(he.vertexA.point), w2sTr.apply(he.vertexB.point)); + } + } + return boundary; + function sameSketchObject(a, b) { if (a.sketchConnectionObject === undefined || b.sketchConnectionObject === undefined) { @@ -15,8 +27,6 @@ export function getSketchBoundaries(sceneFace) { let paths = sceneFace.getBounds(); //sceneFace.polygon.collectPaths(paths); - - let w2sTr = sceneFace.worldToSketchTransformation; function addSegment(a, b) { boundary.lines.push({