Commit 94dacd7d authored by Mathias Chouet's avatar Mathias Chouet :spaghetti:
Browse files

PAB: added mechanisms related to downWall

Showing with 40 additions and 1 deletion
+40 -1
import { CalculatorType } from "../compute-node"; import { CalculatorType } from "../compute-node";
import { Nub } from "../nub"; import { Nub } from "../nub";
import { ParamCalculability } from "../param/param-definition"; import { ParamCalculability } from "../param/param-definition";
import { Session } from "../session";
import { ParallelStructure } from "../structure/parallel_structure"; import { ParallelStructure } from "../structure/parallel_structure";
import { Result } from "../util/result"; import { Result } from "../util/result";
import { PabCloisons } from "./pab_cloisons"; import { PabCloisons } from "./pab_cloisons";
...@@ -85,12 +86,26 @@ export class Pab extends Nub { ...@@ -85,12 +86,26 @@ export class Pab extends Nub {
return r; 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 * Once session is loaded, run a second pass on all PabCloisons to
* reinit their target if needed * reinit their target if needed
*/ */
public fixPAB(obj: any) { public fixPAB(obj: any) {
if (obj.children && Array.isArray(obj.children)) { if (obj.children && Array.isArray(obj.children)) {
// Cloisons models
for (const c of obj.children) { for (const c of obj.children) {
if (c.props.calcType === CalculatorType.PabCloisons) { // who knows ? if (c.props.calcType === CalculatorType.PabCloisons) { // who knows ?
const childUid = c.uid; const childUid = c.uid;
...@@ -102,6 +117,10 @@ export class Pab extends Nub { ...@@ -102,6 +117,10 @@ export class Pab extends Nub {
} // else cannot find target } // else cannot find target
} }
} }
// Downstream wall
if (obj.props.modeleCloisonAval) {
this.setDownWall(obj.props.modeleCloisonAval);
}
} }
} }
......
...@@ -372,12 +372,18 @@ export class Session { ...@@ -372,12 +372,18 @@ export class Session {
} }
case CalculatorType.Pab: 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( nub = new Pab(
new PabParams( new PabParams(
1.5, // Q 1.5, // Q
102, // Z1 102, // Z1
99 // Z2 99 // Z2
), undefined, dbg ), downWall, dbg
); );
break; break;
...@@ -473,6 +479,20 @@ export class Session { ...@@ -473,6 +479,20 @@ export class Session {
return cloisonsNubs; 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 * Crée un Nub de type Section
* @param nt ComputeNodeType * @param nt ComputeNodeType
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment