From 3e61dd4f25124221c3d9f5d59f7a9e011ed1befa Mon Sep 17 00:00:00 2001 From: Amanda Ghassaei <amandaghassaei@gmail.com> Date: Wed, 4 Mar 2015 01:53:49 -0500 Subject: [PATCH] consolidating --- js/fea/DmaCell.js | 2 +- js/models/AppState.js | 8 ++--- js/models/Lattice.js | 82 ++++++++++++++++++------------------------- 3 files changed, 40 insertions(+), 52 deletions(-) diff --git a/js/fea/DmaCell.js b/js/fea/DmaCell.js index 48d41669..dd7f0573 100644 --- a/js/fea/DmaCell.js +++ b/js/fea/DmaCell.js @@ -363,7 +363,7 @@ DMACell.prototype.destroy = function(){ var mesh = new THREE.SceneUtils.createMultiMaterialObject(unitCellGeo, cellMaterials); mesh.myParent = this;//we need a reference to this instance from the mesh for intersection selection stuff var wireframe = new THREE.BoxHelper(mesh.children[0]); - wireframe.material.color.set(); + wireframe.material.color.set(0x000000); mesh.children.push(wireframe); dmaGlobals.three.sceneAdd(mesh, "cell"); return mesh; diff --git a/js/models/AppState.js b/js/models/AppState.js index dabe3796..f3e50eee 100644 --- a/js/models/AppState.js +++ b/js/models/AppState.js @@ -25,10 +25,10 @@ AppState = Backbone.Model.extend({ }, allPartTypes:{ octa:{ - face: {triangle:"Triangle"}, - edge: {triangle:"Triangle"}, - edgeRot: {triangle:"Triangle"}, - vertex: {square:"Square", xShape:"X"} + face: {triangle:"Triangle", default:"Default"}, + edge: {triangle:"Triangle", default:"Default"}, + edgeRot: {triangle:"Triangle", default:"Default"}, + vertex: {square:"Square", xShape:"X", default:"Default"} }, cube:{ face: null diff --git a/js/models/Lattice.js b/js/models/Lattice.js index eceae0c4..956dae65 100644 --- a/js/models/Lattice.js +++ b/js/models/Lattice.js @@ -82,6 +82,25 @@ Lattice = Backbone.Model.extend({ }, + _addInverseCellsForIndex: function(index){ + + index = _.clone(index); + + var inverseIndicesToAdd = this._inverseIndicesToAdd(index); + + var invCells = this.get("inverseCells"); + var scale = this.get("scale"); + var self = this; + _.each(inverseIndicesToAdd, function(invIndex){ + self._checkForMatrixExpansion(invCells, invIndex, invIndex, "inverseCellsMax", "inverseCellsMin"); + var indexRel = self._subtract(invIndex, self.get("inverseCellsMin")); + if (!invCells[indexRel.x][indexRel.y][indexRel.z]) { + invCells[indexRel.x][indexRel.y][indexRel.z] = self._makeInvCellForLatticeType(invIndex, scale); + self.set("numInvCells", self.get("numInvCells")+1); + } + }); + }, + _indexForPosition: function(absPosition){ var position = {}; var scale = this.get("scale"); @@ -518,7 +537,7 @@ Lattice = Backbone.Model.extend({ return new DMATetraFaceCell(indices, scale, this); }, - _addInverseCellsForIndex: function(index){ + _inverseIndicesToAdd: function(index){ var oddZ = index.z%2 != 0; @@ -528,23 +547,6 @@ Lattice = Backbone.Model.extend({ var z0 = 0; if (oddZ) z0 = 1; - var inverseIndicesToAdd = this._getInverseIndicesToAdd(index, z0); - - var invCells = this.get("inverseCells"); - var scale = this.get("scale"); - var self = this; - _.each(inverseIndicesToAdd, function(invIndex){ - self._checkForMatrixExpansion(invCells, invIndex, invIndex, "inverseCellsMax", "inverseCellsMin"); - var indexRel = self._subtract(invIndex, self.get("inverseCellsMin")); - if (!invCells[indexRel.x][indexRel.y][indexRel.z]) { - invCells[indexRel.x][indexRel.y][indexRel.z] = self._makeInvCellForLatticeType(invIndex, scale); - self.set("numInvCells", self.get("numInvCells")+1); - } - }); - }, - - _getInverseIndicesToAdd: function(index, z0){ - if (this.get("connectionType") == "edge") z0 = 0; var z1 = Math.abs(z0-1); @@ -734,6 +736,21 @@ Lattice = Backbone.Model.extend({ return position; }, + _inverseIndicesToAdd: function(index){ + var inverseIndicesToAdd = [ + this._add(index, {x:0,y:0,z:0}), + this._add(index, {x:0,y:1,z:0}), + this._add(index, {x:1,y:0,z:0}), + this._add(index, {x:1,y:1,z:0}), + + this._add(index, {x:0,y:0,z:1}), + this._add(index, {x:0,y:1,z:1}), + this._add(index, {x:1,y:0,z:1}), + this._add(index, {x:1,y:1,z:1}) + ]; + return inverseIndicesToAdd; + }, + xScale: function(scale){ if (!scale) scale = this.get("scale"); return scale*Math.sqrt(2); @@ -756,35 +773,6 @@ Lattice = Backbone.Model.extend({ return new DMATruncCubeCell(indices, scale, this); }, - _addInverseCellsForIndex: function(index){ - - index = _.clone(index); - - var inverseIndicesToAdd = [ - this._add(index, {x:0,y:0,z:0}), - this._add(index, {x:0,y:1,z:0}), - this._add(index, {x:1,y:0,z:0}), - this._add(index, {x:1,y:1,z:0}), - - this._add(index, {x:0,y:0,z:1}), - this._add(index, {x:0,y:1,z:1}), - this._add(index, {x:1,y:0,z:1}), - this._add(index, {x:1,y:1,z:1}) - ]; - - var invCells = this.get("inverseCells"); - var scale = this.get("scale"); - var self = this; - _.each(inverseIndicesToAdd, function(invIndex){ - self._checkForMatrixExpansion(invCells, invIndex, invIndex, "inverseCellsMax", "inverseCellsMin"); - var indexRel = self._subtract(invIndex, self.get("inverseCellsMin")); - if (!invCells[indexRel.x][indexRel.y][indexRel.z]) { - invCells[indexRel.x][indexRel.y][indexRel.z] = self._makeInvCellForLatticeType(invIndex, scale); - self.set("numInvCells", self.get("numInvCells")+1); - } - }); - }, - _undo: function(){//remove all the mixins, this will help with debugging later var self = this; _.each(_.keys(this.OctaVertexLattice), function(key){ -- GitLab