diff --git a/js/fea/DmaCell.js b/js/fea/DmaCell.js index fee678377a975c8d542392c1af5d24369b9f83e0..622d264c9f9353ec2b3292237ea819718aa7d14a 100644 --- a/js/fea/DmaCell.js +++ b/js/fea/DmaCell.js @@ -21,7 +21,7 @@ function DMACell(indices, scale, lattice, inverse) { DMACell.prototype.removePart = function(index){ this.parts[index].destroy(); this.parts[index] = null; - var hasAnyParts = false; + var hasAnyParts = false;//check if all parts have been deleted _.each(this.parts, function(part){ if (part) hasAnyParts = true; }); @@ -32,7 +32,6 @@ DMACell.prototype._setMeshPosition = function(mesh, position){ mesh.position.x = position.x; mesh.position.y = position.y; mesh.position.z = position.z; - return mesh; }; DMACell.prototype.drawForMode = function(cellMode, inverseMode){ diff --git a/js/models/Lattice.js b/js/models/Lattice.js index ba855ae138a23783b2b96993c9d7dcc193aee0f4..febe16ab4b4444dd2dee7b773d265c5ffb489647 100644 --- a/js/models/Lattice.js +++ b/js/models/Lattice.js @@ -77,7 +77,6 @@ Lattice = Backbone.Model.extend({ if (!cells[index.x][index.y][index.z]) { cells[index.x][index.y][index.z] = this._makeCellForLatticeType(indices, scale); this.set("numCells", this.get("numCells")+1); - if (this._shouldHaveInverseCells()) this._addInverseCellsForIndex(indices); dmaGlobals.three.render(); } else console.warn("already a cell there"); @@ -128,6 +127,7 @@ Lattice = Backbone.Model.extend({ if (cell) cell.destroy(); }); this.set("cells", [[[null]]]); + this._clearInverseCells(); this.set("cellsMax", {x:0, y:0, z:0}); this.set("cellsMin", {x:0, y:0, z:0}); this.set("nodes", []); @@ -136,6 +136,15 @@ Lattice = Backbone.Model.extend({ dmaGlobals.three.render(); }, + _clearInverseCells: function(){ + this._iterCells(this.get("inverseCells"), function(cell){ + if (cell) cell.destroy(); + }); + this.set("inverseCells", [[[null]]]); + this.set("inverseCellsMin", {x:0, y:0, z:0}); + this.set("inverseCellsMax", {x:0, y:0, z:0}); + }, + //////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////FILL GEOMETRY//////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////// @@ -361,6 +370,7 @@ Lattice = Backbone.Model.extend({ var self = this; var scale = this.get("scale"); var cells = this.get("cells"); + this._clearInverseCells(); this._loopCells(cells, function(cell, x, y, z){ if (!cell) return; var index = cell.indices; @@ -497,6 +507,7 @@ Lattice = Backbone.Model.extend({ }, _makeCellForLatticeType: function(indices, scale){ + this._addInverseCellsForIndex(indices); return new DMASideOctaCell(indices, scale, this); }, @@ -504,10 +515,6 @@ Lattice = Backbone.Model.extend({ return new DMATetraCell(indices, scale, this); }, - _shouldHaveInverseCells: function(){ - return true; - }, - _addInverseCellsForIndex: function(index){ index = _.clone(index); @@ -621,10 +628,6 @@ Lattice = Backbone.Model.extend({ return new DMAVertexOctaCell(indices, scale, this); }, - _shouldHaveInverseCells: function(){ - return false; - }, - _undo: function(){//remove all the mixins, this will help with debugging later var self = this; _.each(_.keys(this.OctaVertexLattice), function(key){ @@ -675,10 +678,6 @@ Lattice = Backbone.Model.extend({ return new DMACubeCell(indices, scale, this); }, - _shouldHaveInverseCells: function(){ - return false; - }, - _undo: function(){//remove all the mixins, this will help with debugging later var self = this; _.each(_.keys(this.CubeLattice), function(key){