From 6b91f9c06b6e5b23f9ad943874324162ac01d830 Mon Sep 17 00:00:00 2001 From: Amanda Ghassaei <amandaghassaei@gmail.com> Date: Thu, 2 Jul 2015 19:54:36 -0700 Subject: [PATCH] eod --- js/cells/DMACell.js | 11 +++++++--- js/cells/GIKCell.js | 2 +- js/cells/supercells/DMASuperCell.js | 13 +++++------ js/cells/supercells/GIKSuperCell.js | 8 ++----- js/lattice/LatticeEsim.js | 4 ++-- js/main.js | 3 ++- .../electronics/{ => cells}/eSimCell.js | 7 ++++-- .../electronics/cells/eSimSuperCell.js | 22 +++++++++++++++++++ 8 files changed, 47 insertions(+), 23 deletions(-) rename js/simulation/electronics/{ => cells}/eSimCell.js (77%) create mode 100644 js/simulation/electronics/cells/eSimSuperCell.js diff --git a/js/cells/DMACell.js b/js/cells/DMACell.js index 53e652f9..a73f09d5 100644 --- a/js/cells/DMACell.js +++ b/js/cells/DMACell.js @@ -73,7 +73,8 @@ define(['underscore', 'three', 'threeModel', 'lattice', 'appState', 'globals', ' }; DMACell.prototype._getMeshName = function(){ - return "cell"; + if (this._isBottomLayer()) return "cell"; + return "supercell"; }; DMACell.prototype._buildWireframe = function(mesh, geometry, isBeam){//for "cell" view @@ -264,7 +265,7 @@ define(['underscore', 'three', 'threeModel', 'lattice', 'appState', 'globals', ' }; DMACell.prototype.getConditionalMode = function(mode){ - if (mode == "supercell" && this._isTopLayerCell()) return "cell"; + if (mode == "supercell" && this._isBottomLayer() && this._isTopLayer()) return "cell"; return mode; }; @@ -326,11 +327,15 @@ define(['underscore', 'three', 'threeModel', 'lattice', 'appState', 'globals', ' } }; + DMACell.prototype._isBottomLayer = function(){ + return true; + }; + DMACell.prototype._isMiddleLayer = function(){ return false; }; - DMACell.prototype._isTopLayerCell = function(){ + DMACell.prototype._isTopLayer = function(){ return this.superCell === null || this.superCell === undefined; }; diff --git a/js/cells/GIKCell.js b/js/cells/GIKCell.js index f17442b0..b62c2a58 100644 --- a/js/cells/GIKCell.js +++ b/js/cells/GIKCell.js @@ -12,7 +12,7 @@ define(['underscore', 'three', 'threeModel', 'lattice', 'appState', 'cubeCell'], GIKCell.prototype = Object.create(CubeCell.prototype); GIKCell.prototype._getMeshName = function(){ - return null; + return null;//never show the gik cell }; GIKCell.prototype._initParts = function(callback){ diff --git a/js/cells/supercells/DMASuperCell.js b/js/cells/supercells/DMASuperCell.js index c8c96f9e..1347f297 100644 --- a/js/cells/supercells/DMASuperCell.js +++ b/js/cells/supercells/DMASuperCell.js @@ -72,10 +72,6 @@ define(['underscore', 'three', 'threeModel', 'lattice', 'appState', 'cell'], }); }; - DMASuperCell.prototype._getMeshName = function(){ - return "supercell"; - }; - DMASuperCell.prototype.setMode = function(mode, callback){ var self = this; DMACell.prototype.setMode.call(this, mode, function(){ @@ -97,16 +93,17 @@ define(['underscore', 'three', 'threeModel', 'lattice', 'appState', 'cell'], }; + DMASuperCell.prototype._isBottomLayer = function(){ + return false; + }; + DMASuperCell.prototype._isMiddleLayer = function(){ return this.superCell !== null && this.superCell !== undefined; }; - DMASuperCell.prototype._isTopLayerCell = function(){ - return false; - }; DMASuperCell.prototype.setTransparent = function(evalFunction){ - DMACell.prototype.setTransparent.call(this, evalFunction); + DMACell.prototype.setTransparent.call(this, evalFunction);//todo don't pass down to cells if no change this._loopCells(function(cell){ if (cell) cell.setTransparent(evalFunction); }) diff --git a/js/cells/supercells/GIKSuperCell.js b/js/cells/supercells/GIKSuperCell.js index 8191c3ed..373ca701 100644 --- a/js/cells/supercells/GIKSuperCell.js +++ b/js/cells/supercells/GIKSuperCell.js @@ -57,18 +57,14 @@ define(['underscore', 'three', 'threeModel', 'lattice', 'appState', 'superCell', return wireframe; }; - GIKSuperCell.prototype._getMeshName = function(){ - return "cell"; + GIKSuperCell.prototype._isBottomLayer = function(){ + return true; }; GIKSuperCell.prototype._isMiddleLayer = function(){ return false; }; - GIKSuperCell.prototype._isTopLayerCell = function(){ - return this.superCell === null || this.superCell === undefined; - }; - GIKSuperCell.prototype.toJSON = function(){ var data = DMASuperCell.prototype.toJSON.call(this); if (!this.length) console.warn("no length assigned to gik supercell"); diff --git a/js/lattice/LatticeEsim.js b/js/lattice/LatticeEsim.js index aab2070f..21588ebe 100644 --- a/js/lattice/LatticeEsim.js +++ b/js/lattice/LatticeEsim.js @@ -2,7 +2,7 @@ * Created by aghassaei on 6/30/15. */ -define(['lattice', 'appState', 'threeModel', 'eSim', 'eSimCell'], function(lattice, appState, three, eSim){ +define(['lattice', 'appState', 'threeModel', 'eSim', 'eSimCell', 'eSimSuperCell'], function(lattice, appState, three, eSim){ @@ -24,7 +24,7 @@ define(['lattice', 'appState', 'threeModel', 'eSim', 'eSimCell'], function(latti var allVisible = groupNum < 0; this._loopCells(this.sparseCells, function(cell){ if (cell) cell.setTransparent(function(evalCell){ - return !evalCell.isConductive() || (!allVisible && groupNum != evalCell.getConductorGroupNum()) + return evalCell.conductiveGroupVisible(allVisible, groupNum); }); }); three.render(); diff --git a/js/main.js b/js/main.js index a88f8bf1..2dd08f1c 100644 --- a/js/main.js +++ b/js/main.js @@ -154,7 +154,8 @@ require.config({ //electronic sim eSim: 'simulation/electronics/eSim', latticeESim: 'lattice/latticeESim', - eSimCell: 'simulation/electronics/eSimCell', + eSimCell: 'simulation/electronics/cells/eSimCell', + eSimSuperCell: 'simulation/electronics/cells/eSimSuperCell', //cam diff --git a/js/simulation/electronics/eSimCell.js b/js/simulation/electronics/cells/eSimCell.js similarity index 77% rename from js/simulation/electronics/eSimCell.js rename to js/simulation/electronics/cells/eSimCell.js index 2b27dbe2..dd6a1f1d 100644 --- a/js/simulation/electronics/eSimCell.js +++ b/js/simulation/electronics/cells/eSimCell.js @@ -6,8 +6,7 @@ define(['cell', 'lattice'], function(DMACell, lattice){ DMACell.prototype.isConductive = function(){ - var material = this.getMaterial(); - return material.properties.conductive; + return this.getMaterial().properties.conductive; }; DMACell.prototype.setConductorGroupNum = function(num, force){ @@ -30,6 +29,10 @@ define(['cell', 'lattice'], function(DMACell, lattice){ }); }; + DMACell.prototype.conductiveGroupVisible = function(allVisible, groupNum){ + console.log(allVisible); + return !this.isConductive() || (!allVisible && groupNum != this._eSimConductorGroup); + }; }); \ No newline at end of file diff --git a/js/simulation/electronics/cells/eSimSuperCell.js b/js/simulation/electronics/cells/eSimSuperCell.js new file mode 100644 index 00000000..a95e734c --- /dev/null +++ b/js/simulation/electronics/cells/eSimSuperCell.js @@ -0,0 +1,22 @@ +/** + * Created by aghassaei on 7/2/15. + */ + + +define(['underscore', 'superCell'], function(_, DMASuperCell){ + + DMASuperCell.prototype.conductiveGroupVisible = function(allVisible, groupNum){ + if (allVisible) return this.isConductive(); + for (var i=0;i<this.cells.length;i++){ + for (var j=0;j<this.cells[0].length;j++){ + for (var k=0;j<this.cells[0][0].length;k++){ + console.log("here"); + if (this.cells[i][j[k]] && this.cells[i][j][k].conductiveGroupVisible(allVisible, groupNum)) return true; + } + } + } + return false; + }; + + return DMASuperCell; +}); \ No newline at end of file -- GitLab