fix filter construction geometry in 3D

This commit is contained in:
Val Erastov 2022-11-26 22:31:43 -08:00
parent 05d4222e28
commit e7c2ac0058
5 changed files with 5558 additions and 505 deletions

6008
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -18,7 +18,6 @@ export function operationIconToActionIcon(icon, appearance) {
} else { } else {
appearance.icon = resolveIcon(icon); appearance.icon = resolveIcon(icon);
} }
console.log(icon, appearance)
} }
export function resolveAppearance<R>(op: Operation<R>, params: R) { export function resolveAppearance<R>(op: Operation<R>, params: R) {

View file

@ -111,14 +111,12 @@ export class MFace extends MObject {
} }
const addSketchObjects = sketchObjects => { const addSketchObjects = sketchObjects => {
const isConstruction = sketchObjects === sketch.constructionSegments;
for (const sketchObject of sketchObjects) { for (const sketchObject of sketchObjects) {
const mSketchObject = new MSketchObject(this, sketchObject); const mSketchObject = new MSketchObject(this, sketchObject);
mSketchObject.construction = isConstruction; mSketchObject.construction = sketchObject.construction;
this.sketchObjects.push(mSketchObject); this.sketchObjects.push(mSketchObject);
} }
}; };
addSketchObjects(sketch.constructionSegments);
addSketchObjects(sketch.connections); addSketchObjects(sketch.connections);
addSketchObjects(sketch.loops); addSketchObjects(sketch.loops);

View file

@ -15,6 +15,7 @@ export class SketchPrimitive {
id: string; id: string;
inverted: boolean; inverted: boolean;
construction: boolean = false;
constructor(id) { constructor(id) {
this.id = id; this.id = id;

View file

@ -12,14 +12,12 @@ export class SketchGeom {
connections: SketchPrimitive[]; connections: SketchPrimitive[];
loops: SketchPrimitive[]; loops: SketchPrimitive[];
constructionSegments: SketchPrimitive[];
_contours: Contour[]; _contours: Contour[];
points: []; points: any[];
constructor() { constructor() {
this.connections = []; this.connections = [];
this.loops = []; this.loops = [];
this.constructionSegments = [];
this._contours = null; this._contours = null;
this.points = []; this.points = [];
} }
@ -36,11 +34,11 @@ export class SketchGeom {
} }
getAllObjects() { getAllObjects() {
return [...this.connections, ...this.loops, ...this.constructionSegments]; return [...this.connections, ...this.loops];
} }
} }
export function ReadSketch(sketch, sketchId, readConstructionSegments) { export function ReadSketch(sketch, sketchId) {
const getID = obj => sketchObjectGlobalId(sketchId, obj.id); const getID = obj => sketchObjectGlobalId(sketchId, obj.id);
const out = new SketchGeom(); const out = new SketchGeom();
@ -66,20 +64,21 @@ export function ReadSketch(sketch, sketchId, readConstructionSegments) {
} }
for (const obj of sketch.objects) { for (const obj of sketch.objects) {
const isConstructionObject = obj.role === 'construction'; const isConstructionObject = obj.role === 'construction';
if (isConstructionObject && !readConstructionSegments) continue;
// if (isConstructionObject && obj._class !== 'TCAD.TWO.Segment') continue;
// if (isConstructionObject && obj._class !== 'TCAD.TWO.Segment') continue;
const data = obj.data; const data = obj.data;
let createdObj: SketchPrimitive;
if (obj.type === 'Segment') { if (obj.type === 'Segment') {
const segA = ReadSketchPoint(data.a); const segA = ReadSketchPoint(data.a);
const segB = ReadSketchPoint(data.b); const segB = ReadSketchPoint(data.b);
const pushOn = isConstructionObject ? out.constructionSegments : out.connections; createdObj = new sm.Segment(getID(obj), segA, segB);
pushOn.push(new sm.Segment(getID(obj), segA, segB)); out.connections.push(createdObj);
} else if (obj.type === 'Arc') { } else if (obj.type === 'Arc') {
const arcA = ReadSketchPoint(data.a); const arcA = ReadSketchPoint(data.a);
const arcB = ReadSketchPoint(data.b); const arcB = ReadSketchPoint(data.b);
const arcCenter = ReadSketchPoint(data.c); const arcCenter = ReadSketchPoint(data.c);
out.connections.push(new sm.Arc(getID(obj), arcA, arcB, arcCenter)); createdObj = new sm.Arc(getID(obj), arcA, arcB, arcCenter);
out.connections.push(createdObj);
} else if (obj.type === 'EllipticalArc') { } else if (obj.type === 'EllipticalArc') {
if (data.ep1) { if (data.ep1) {
continue; continue;
@ -90,16 +89,19 @@ export function ReadSketch(sketch, sketchId, readConstructionSegments) {
const rot = readSketchFloat(data.rot); const rot = readSketchFloat(data.rot);
const a = ReadSketchPoint(data.a); const a = ReadSketchPoint(data.a);
const b = ReadSketchPoint(data.b); const b = ReadSketchPoint(data.b);
out.loops.push(new sm.EllipticalArc(getID(obj), c, rx, ry, rot, a, b)); createdObj = new sm.EllipticalArc(getID(obj), c, rx, ry, rot, a, b);
out.loops.push(createdObj);
} else if (obj.type === 'BezierCurve') { } else if (obj.type === 'BezierCurve') {
const a = ReadSketchPoint(data.cp1); const a = ReadSketchPoint(data.cp1);
const b = ReadSketchPoint(data.cp4); const b = ReadSketchPoint(data.cp4);
const cp1 = ReadSketchPoint(data.cp2); const cp1 = ReadSketchPoint(data.cp2);
const cp2 = ReadSketchPoint(data.cp3); const cp2 = ReadSketchPoint(data.cp3);
out.connections.push(new sm.BezierCurve(getID(obj), a, b, cp1, cp2)); createdObj = new sm.BezierCurve(getID(obj), a, b, cp1, cp2);
out.connections.push(createdObj);
} else if (obj.type === 'Circle') { } else if (obj.type === 'Circle') {
const circleCenter = ReadSketchPoint(data.c); const circleCenter = ReadSketchPoint(data.c);
out.loops.push(new sm.Circle(getID(obj), circleCenter, readSketchFloat(data.r))); createdObj = new sm.Circle(getID(obj), circleCenter, readSketchFloat(data.r));
out.loops.push(createdObj);
} else if (obj.type === 'Ellipse') { } else if (obj.type === 'Ellipse') {
if (data.ep1) { if (data.ep1) {
continue; continue;
@ -108,7 +110,8 @@ export function ReadSketch(sketch, sketchId, readConstructionSegments) {
const rx = readSketchFloat(data.rx); const rx = readSketchFloat(data.rx);
const ry = readSketchFloat(data.ry); const ry = readSketchFloat(data.ry);
const rot = readSketchFloat(data.rot); const rot = readSketchFloat(data.rot);
out.loops.push(new sm.Ellipse(getID(obj), c, rx, ry, rot)); createdObj = new sm.Ellipse(getID(obj), c, rx, ry, rot);
out.loops.push(createdObj);
} else if (obj.type === 'Point') { } else if (obj.type === 'Point') {
if (data.ep1) { if (data.ep1) {
continue; continue;
@ -120,19 +123,23 @@ export function ReadSketch(sketch, sketchId, readConstructionSegments) {
const z = 0; const z = 0;
//out.points.push(ReadSketchPoint(data)); //out.points.push(ReadSketchPoint(data));
const point = createdObj = {
out.points.push({
id:getID(obj), id:getID(obj),
point:{x,y,z} point:{x,y,z}
}) } as any;
out.points.push(createdObj);
} }
createdObj.construction = isConstructionObject;
} }
return out; return out;
} }
export function FetchContours(geom): Contour[] { export function FetchContours(geom): Contour[] {
const contours = findClosedContours(geom.connections); const contours = findClosedContours(geom.connections.filter(c => !c.construction));
for (const loop of geom.loops) { for (const loop of geom.loops) {
if (loop.construction) {
continue;
}
const contour = new sm.Contour(); const contour = new sm.Contour();
contour.add(loop); contour.add(loop);
contours.push(contour); contours.push(contour);