retrieving production info from raw data coming from the engine

This commit is contained in:
Val Erastov 2019-02-15 19:39:23 -08:00
parent 6a6c8d96eb
commit beecafa9c2
2 changed files with 32 additions and 1 deletions

View file

@ -5,7 +5,7 @@ import {MSketchObject} from './msketchObject';
import {EMPTY_ARRAY} from 'gems/iterables';
import CSys from '../../math/csys';
import {MSketchLoop} from './mloop';
import {sketchObjects} from '../../sketcher/fetchers';
import {ProductionInfo} from './productionInfo';
export class MFace extends MObject {
@ -138,6 +138,14 @@ export class MFace extends MObject {
}
return this._worldToSketchTransformation;
}
get productionInfo() {
if (this._productionInfo === undefined) {
this._productionInfo = !this.brepFace.data.productionInfo ? null :
ProductionInfo.fromRawData(this.brepFace.data.productionInfo);
}
return this._productionInfo;
}
}
export class MBrepFace extends MFace {

View file

@ -0,0 +1,23 @@
export class ProductionInfo {
role = undefined;
originatedFromPrimitive = undefined;
static fromRawData(rawProductionInfo) {
let info = new ProductionInfo();
function collectProductionInfo(rawInfo) {
Object.keys(info).forEach(attr => {
if (info[attr] === undefined && rawInfo[attr] !== undefined) {
info[attr] = rawInfo[attr]
}
});
if (rawInfo.derived) {
rawInfo.derived.forEach(d => collectProductionInfo(d));
}
}
collectProductionInfo(rawProductionInfo);
return info;
}
}