diff --git a/src/pab/pab.ts b/src/pab/pab.ts index 4833c18e2a27677abe2904879ec45c527edd02b0..f56c53112d64031583f612effe9caf4d446b8887 100644 --- a/src/pab/pab.ts +++ b/src/pab/pab.ts @@ -1,6 +1,7 @@ import { CalculatorType } from "../compute-node"; import { Nub } from "../nub"; import { ParamCalculability } from "../param/param-definition"; +import { Session } from "../session"; import { ParallelStructure } from "../structure/parallel_structure"; import { Result } from "../util/result"; import { PabCloisons } from "./pab_cloisons"; @@ -85,12 +86,26 @@ export class Pab extends Nub { return r; } + /** + * Finds the ParallelStructure targetted by modelUid and defines it as the current downWall + */ + public setDownWall(modelUid: string) { + this.properties.setPropValue("modeleCloisonAval", modelUid); + const dw = (Session.getInstance().findNubByUid(modelUid) as ParallelStructure); + if (dw) { + this.downWall = dw; + } /* else { + console.error("Pab.setDownWall : cannot find target ParallelStructure"); + } */ + } + /** * Once session is loaded, run a second pass on all PabCloisons to * reinit their target if needed */ public fixPAB(obj: any) { if (obj.children && Array.isArray(obj.children)) { + // Cloisons models for (const c of obj.children) { if (c.props.calcType === CalculatorType.PabCloisons) { // who knows ? const childUid = c.uid; @@ -102,6 +117,10 @@ export class Pab extends Nub { } // else cannot find target } } + // Downstream wall + if (obj.props.modeleCloisonAval) { + this.setDownWall(obj.props.modeleCloisonAval); + } } } diff --git a/src/session.ts b/src/session.ts index 0880b8393962206cd6376e8fd35b6754ae0596b8..8e9b40421bbd4332f890c2c3b6eecacfa1efa52d 100644 --- a/src/session.ts +++ b/src/session.ts @@ -372,12 +372,18 @@ export class Session { } case CalculatorType.Pab: + const modeleCloisonAval: string = params.getPropValue("modeleCloisonAval"); + let downWall; + if (modeleCloisonAval) { + downWall = (Session.getInstance().findNubByUid(modeleCloisonAval) as ParallelStructure); + // si le module ParallelStructure ciblé n'existe pas, Session.fixPAB() est censé s'en occuper + } nub = new Pab( new PabParams( 1.5, // Q 102, // Z1 99 // Z2 - ), undefined, dbg + ), downWall, dbg ); break; @@ -473,6 +479,20 @@ export class Session { return cloisonsNubs; } + /** + * Returns all Nubs of type ParallelStructure (no sub-types), + * to be used as downWall models in PAB + */ + public getParallelStructureNubs() { + const psNubs: Nub[] = []; + for (const n of this._nubs) { + if (n.constructor === ParallelStructure) { // exact class checking + psNubs.push(n); + } + } + return psNubs; + } + /** * Crée un Nub de type Section * @param nt ComputeNodeType