diff --git a/js/cells/DMACell.js b/js/cells/DMACell.js index e5ebfb454ccebfb5c4a3494a3cb008f3486afd6b..14eecd552e085343f34d4562a862482092a9f4b0 100644 --- a/js/cells/DMACell.js +++ b/js/cells/DMACell.js @@ -218,6 +218,10 @@ define(['underscore', 'three', 'threeModel', 'lattice', 'appState', 'globals', ' this.setMode(mode); }; + DMACell.prototype.getMaterialName = function(){ + return this.materialName; + }; + DMACell.prototype.getMaterial = function(returnTHREEObject){ if (!this.materialName) { console.warn("no material type set for cell"); diff --git a/js/lattice/Lattice.js b/js/lattice/Lattice.js index a8daf39013e0d1a563cf71ea5abb8a1b74c71235..958e984cc4d5b1d6b3908bdc10409e1af497c0df 100644 --- a/js/lattice/Lattice.js +++ b/js/lattice/Lattice.js @@ -16,6 +16,8 @@ define(['underscore', 'backbone', 'appState', 'globals', 'plist', 'three', 'thre connectionType: "face", partType: null, + denseCellsMin: null, + nodes: [], cellSeparation: {xy:0, z:0}//spacing for connectors/joints @@ -140,6 +142,7 @@ define(['underscore', 'backbone', 'appState', 'globals', 'plist', 'three', 'thre } var bounds = this.calculateBoundingBox(); + this.set("denseCellsMin", bounds.min.clone().add(this.get("cellsMin"))); var size = bounds.max.sub(bounds.min); //create array of nulls diff --git a/js/lattice/LatticeEsim.js b/js/lattice/LatticeEsim.js index 66ed1caaa358b11e40ccd3002f53105ba8edcc4b..04e21b59e8cc25a0cb28289d2af81379a4120f89 100644 --- a/js/lattice/LatticeEsim.js +++ b/js/lattice/LatticeEsim.js @@ -9,7 +9,7 @@ define(['lattice', 'eSim', 'eSimCell'], function(lattice, eSim){ calculateConnectivity: function(){ var num = 1; this._loopCells(this.cells, function(cell){ - if (cell) cell.setConnectivityGroupNum(num++, true); + if (cell) cell.setConnectivityGroupNum(num++); }); this._loopCells(this.cells, function(cell){ if (cell) cell.propagateConnectivityGroupNum(); @@ -18,16 +18,16 @@ define(['lattice', 'eSim', 'eSimCell'], function(lattice, eSim){ }, _calcNumberConnectedComponents: function(){ - var groups = []; + var groups = {}; this._loopCells(this.cells, function(cell){ if (!cell) return; - if (groups.indexOf(cell.getConnectivityGroupNum())<0) groups.push(cell.getConnectivityGroupNum()); + if (!groups[cell.getConnectivityGroupNum()] && cell.getMaterialName() == "brass") groups[cell.getConnectivityGroupNum()] = cell.getMaterialName(); }); - eSim.set("numConnectedComponents", groups.length); + eSim.set("numConnectedComponents", _.keys(groups).length); }, propagateToNeighbors: function(index, callback){ - index.sub(this.get("cellsMin"));//todo wrong + index.sub(this.get("denseCellsMin")); var xLength = this.cells.length; var yLength = this.cells[0].length; var zLength = this.cells[0][0].length; diff --git a/js/menus/templates/ESetupMenuView.html b/js/menus/templates/ESetupMenuView.html index a6bd5cb166103963f8a042c7bada2dab830753e8..e1607e72a3238d76753e9c7bf3dd3e8b0e04a914 100644 --- a/js/menus/templates/ESetupMenuView.html +++ b/js/menus/templates/ESetupMenuView.html @@ -8,4 +8,8 @@ Simulation Type: </ul> </div><br/><br/> <a href="#" id="calcConnectivity" class="btn btn-block btn-lg btn-default">Calculate Connectivity</a><br/> -<% if(numConnectedComponents){ %>Num Connected Components:  <%= numConnectedComponents %> <% } %> \ No newline at end of file +<% if(numConnectedComponents){ %>Num Connected Conductors:  <%= numConnectedComponents %><br/><br/> +Show Conductors: + + +<% } %> \ No newline at end of file diff --git a/js/simulation/electronics/eSimCell.js b/js/simulation/electronics/eSimCell.js index 58527050da473e538583a597c5274feab2acce22..90fb49e238c61f845128ad9c91683426a1b8fe98 100644 --- a/js/simulation/electronics/eSimCell.js +++ b/js/simulation/electronics/eSimCell.js @@ -5,11 +5,11 @@ //assume latticeESim has loaded? define(['cell', 'lattice'], function(DMACell, lattice){ - DMACell.prototype.setConnectivityGroupNum = function(num, force){ - if (force) this._eSimConnectivityGroup = num; + DMACell.prototype.setConnectivityGroupNum = function(num, materialName){ + if (!materialName) this._eSimConnectivityGroup = num; else if (this._eSimConnectivityGroup>num){ this._eSimConnectivityGroup = num; - this.propagateConnectivityGroupNum(num); + this.propagateConnectivityGroupNum(num, materialName); } }; @@ -17,10 +17,12 @@ define(['cell', 'lattice'], function(DMACell, lattice){ return this._eSimConnectivityGroup; }; - DMACell.prototype.propagateConnectivityGroupNum = function(num){ - if (num===undefined) num = this._eSimConnectivityGroup; + DMACell.prototype.propagateConnectivityGroupNum = function(num, materialName){ + if (materialName === undefined) materialName = this.materialName; + if (materialName != "brass") return; + if (num === undefined) num = this._eSimConnectivityGroup; lattice.propagateToNeighbors(this.getAbsoluteIndex(), function(neighbor){ - if (neighbor) neighbor.setConnectivityGroupNum(num); + if (neighbor) neighbor.setConnectivityGroupNum(num, materialName); }); };