From 48a5869c756c7e8766a683419d93704c88cb23eb Mon Sep 17 00:00:00 2001 From: Amanda Ghassaei <amandaghassaei@gmail.com> Date: Sun, 25 Oct 2015 18:11:54 -0400 Subject: [PATCH] cells and sparse cells in sync for gik --- js/cells/supercells/DMASuperCell.js | 4 ++-- js/lattice/Lattice.js | 4 ++-- js/lattice/LatticeBase.js | 2 -- js/simulation/electronics/cells/eSimSuperCell.js | 16 ++++++++-------- js/three/ThreeModel.js | 8 ++++++-- 5 files changed, 18 insertions(+), 16 deletions(-) diff --git a/js/cells/supercells/DMASuperCell.js b/js/cells/supercells/DMASuperCell.js index 388d98c1..607cfa63 100644 --- a/js/cells/supercells/DMASuperCell.js +++ b/js/cells/supercells/DMASuperCell.js @@ -9,7 +9,7 @@ define(['underscore', 'three', 'threeModel', 'lattice', 'appState', 'cell', 'mat function DMASuperCell(json, superCell){//supercells might have supercells - this.cells = true;//flag for now + this.sparseCells = true;//flag for now DMACell.call(this, json, superCell); @@ -55,7 +55,7 @@ define(['underscore', 'three', 'threeModel', 'lattice', 'appState', 'cell', 'mat var origin = this.getAbsoluteOrigin(); var index = this.getAbsoluteIndex(); var min = index.clone().sub(origin); - var max = index.add(this.getAbsoluteDimensions()).sub(origin); + var max = index.add(this.getAbsoluteDimensions()).sub(origin).sub(new THREE.Vector3(1,1,1)); return {min: min, max: max}; }; diff --git a/js/lattice/Lattice.js b/js/lattice/Lattice.js index 75079cf6..befd9593 100644 --- a/js/lattice/Lattice.js +++ b/js/lattice/Lattice.js @@ -14,8 +14,8 @@ define(['underscore', 'backbone', 'appState', 'globals', 'plist', 'materialsPlis scale: 1.0, cellType: "cube", - connectionType: "face", - applicationType: "default", + connectionType: "gik", + applicationType: "willGik", partType: null, aspectRatio: null, diff --git a/js/lattice/LatticeBase.js b/js/lattice/LatticeBase.js index ad090915..b1a2b026 100644 --- a/js/lattice/LatticeBase.js +++ b/js/lattice/LatticeBase.js @@ -156,8 +156,6 @@ define(['underscore', 'backbone', 'appState', 'globals', 'plist', 'three', 'thre self._loopCells(flattenedCells, function(flatCell, x, y, z){ self.cells[relIndex.x+x][relIndex.y+y][relIndex.z+z] = flatCell; }); - console.log(self.cells); - console.log(self.sparseCells); cell.addToScene(); }); diff --git a/js/simulation/electronics/cells/eSimSuperCell.js b/js/simulation/electronics/cells/eSimSuperCell.js index 9b2f7894..a548f673 100644 --- a/js/simulation/electronics/cells/eSimSuperCell.js +++ b/js/simulation/electronics/cells/eSimSuperCell.js @@ -7,10 +7,10 @@ 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;k<this.cells[0][0].length;k++){ - if (this.cells[i][j][k] && this.cells[i][j][k].conductiveGroupVisible(allVisible, groupNum)) return true; + for (var i=0;i<this.sparseCells.length;i++){ + for (var j=0;j<this.sparseCells[0].length;j++){ + for (var k=0;k<this.sparseCells[0][0].length;k++){ + if (this.sparseCells[i][j][k] && this.sparseCells[i][j][k].conductiveGroupVisible(allVisible, groupNum)) return true; } } } @@ -18,10 +18,10 @@ define(['underscore', 'superCell'], function(_, DMASuperCell){ }; DMASuperCell.prototype.structuralGroupVisible = function(groupNum){ - for (var i=0;i<this.cells.length;i++){ - for (var j=0;j<this.cells[0].length;j++){ - for (var k=0;k<this.cells[0][0].length;k++){ - if (this.cells[i][j][k] && this.cells[i][j][k].structuralGroupVisible(groupNum)) return true; + for (var i=0;i<this.sparseCells.length;i++){ + for (var j=0;j<this.sparseCells[0].length;j++){ + for (var k=0;k<this.sparseCells[0][0].length;k++){ + if (this.sparseCells[i][j][k] && this.sparseCells[i][j][k].structuralGroupVisible(groupNum)) return true; } } } diff --git a/js/three/ThreeModel.js b/js/three/ThreeModel.js index 7d1be5af..a5ac8315 100644 --- a/js/three/ThreeModel.js +++ b/js/three/ThreeModel.js @@ -114,11 +114,15 @@ define(['underscore', 'three'], function(_, THREE){ } function removeCell(cell){ - cells.splice(cells.indexOf(cell), 1); + var index = cells.indexOf(cell); + if (index < 0) return; + cells.splice(index, 1); } function removeCompositeCell(cell){ - compositeCells.splice(compositeCells.indexOf(cell), 1); + var index = compositeCells.indexOf(cell); + if (index < 0) return; + compositeCells.splice(index, 1); } function getCells(){ -- GitLab