From ef32fdcb9a5ce0d11c6268ba5b9f3d73b9aad465 Mon Sep 17 00:00:00 2001 From: Amanda Ghassaei <amandaghassaei@gmail.com> Date: Thu, 29 Oct 2015 01:59:11 -0400 Subject: [PATCH] cleaning up --- js/cells/DMACell.js | 12 ++--- js/cells/supercells/DMASuperCell.js | 25 +++------- js/lattice/Lattice.js | 2 - js/lattice/LatticeBase.js | 50 ------------------- js/materials/DMAMaterials.js | 2 +- js/menus/ESetupMenuView.js | 6 --- js/menus/templates/CompositeMenuView.html | 1 - js/menus/templates/ESetupMenuView.html | 5 -- js/menus/templates/EditComponentMenuView.html | 1 - js/menus/templates/ViewMenuView.html | 1 - 10 files changed, 12 insertions(+), 93 deletions(-) diff --git a/js/cells/DMACell.js b/js/cells/DMACell.js index dce6d981..95086fa3 100644 --- a/js/cells/DMACell.js +++ b/js/cells/DMACell.js @@ -478,21 +478,17 @@ define(['underscore', 'three', 'threeModel', 'lattice', 'appState', 'globals', ' //parse DMACell.prototype.addToDenseArray = function(cellsArray, min){ var index = this.getAbsoluteIndex().sub(min); - if (cellsArray[index.x][index.y][index.z]) return [this, cellsArray[index.x][index.y][index.z]]; + if (cellsArray[index.x][index.y][index.z]) { + console.warn("cell overlap, something bad happened"); + return; + } cellsArray[index.x][index.y][index.z] = this; - return null; - }; - - DMACell.prototype.removeFromDenseArray = function(cellsArray, min){ - var index = this.getAbsoluteIndex().sub(min); - cellsArray[index.x][index.y][index.z] = null; }; - //destroy DMACell.prototype.destroy = function(){//todo remove reference from lattice.cells diff --git a/js/cells/supercells/DMASuperCell.js b/js/cells/supercells/DMASuperCell.js index 5cd16932..ec2f4810 100644 --- a/js/cells/supercells/DMASuperCell.js +++ b/js/cells/supercells/DMASuperCell.js @@ -170,32 +170,21 @@ define(['underscore', 'three', 'threeModel', 'lattice', 'appState', 'cell', 'mat } } - var overlap = false; this._loopCells(function(cell, x, y, z){ - var overlappingCells = null; - if (recursive){ - overlappingCells = cell.addToDenseArray(cells, bounds.min); - } else { - overlappingCells = DMACell.prototype.addToDenseArray.call(cell, cells, bounds.min); - } - if (overlappingCells) overlap = true; + if (recursive) cell.addToDenseArray(cells, bounds.min); + else DMACell.prototype.addToDenseArray.call(cell, cells, bounds.min); }); - if (overlap) { - console.warn("overlap detected"); - return [[[null]]]; - } return cells; }; DMASuperCell.prototype.addToDenseArray = function(cellsArray, min, forCAM){ - if (forCAM && this._isBottomLayer()) return DMACell.prototype.addToDenseArray.call(this, cellsArray, min);//this gives back the bottom layer cell for assembly, not necessarily the lattice pitch - var overlap = []; + if (forCAM && this._isBottomLayer()) { + DMACell.prototype.addToDenseArray.call(this, cellsArray, min); + return; + }//this gives back the bottom layer cell for assembly, not necessarily the lattice pitch this._loopCells(function(cell){ - var overlappingCells = cell.addToDenseArray(cellsArray, min, forCAM); - if (overlappingCells) overlap = overlap.concat(overlappingCells); + cell.addToDenseArray(cellsArray, min, forCAM); }); - if (overlap.length>0) return overlap; - return null; }; diff --git a/js/lattice/Lattice.js b/js/lattice/Lattice.js index 8a2bd5ea..b646dd62 100644 --- a/js/lattice/Lattice.js +++ b/js/lattice/Lattice.js @@ -20,8 +20,6 @@ define(['underscore', 'backbone', 'appState', 'globals', 'plist', 'materialsPlis aspectRatio: null, - overlappingCells: [], - nodes: [] }), diff --git a/js/lattice/LatticeBase.js b/js/lattice/LatticeBase.js index 05648546..11e29d96 100644 --- a/js/lattice/LatticeBase.js +++ b/js/lattice/LatticeBase.js @@ -530,56 +530,6 @@ define(['underscore', 'backbone', 'appState', 'globals', 'plist', 'three', 'thre return {x:xScale, y:yScale, z:zScale}; }, -// _parseSparseCell: function(){ -// -// this.cells = [[[null]]]; -// -// console.log("parse cells"); -// -// if (this.get("numCells") == 0) { -// console.warn("no cells in assembly"); -// this.cells = [[[null]]]; -// return; -// } -// -// var bounds = this.calculateBoundingBox(); -// this.set("cellsMin", bounds.min.clone().add(this.get("cellsMin"))); -// var size = bounds.max.sub(bounds.min); -// -// //create array of nulls -// var cells = []; -// for (var x=0;x<size.x;x++){ -// cells.push([]); -// for (var y=0;y<size.y;y++){ -// cells[x].push([]); -// for (var z=0;z<size.z;z++){ -// cells[x][y].push(null); -// } -// } -// } -// -// var min = this.get("cellsMin").sub(bounds.min); -// var overlap = []; -// var forCAM = appState.get("currentNav") == "navAssemble"; -// this._loopCells(this.sparseCells, function(cell){ -// var overlappingCells = cell.addToDenseArray(cells, min, forCAM); -// if (overlappingCells) overlap = overlap.concat(overlappingCells); -// }); -// this.set("overlappingCells", overlap); -// -// this.cells = cells; -// }, - - highlightOverlappingCells: function(){ - this._loopCells(this.sparseCells, function(cell){ - cell.setTransparent(true); - }); - _.each(this.get("overlappingCells"), function(cell){ - cell.show(); - }); - three.render(); - }, - showCellAtIndex: function(index){ index = (new THREE.Vector3()).subVectors(index, this.get("cellsMin"));//index is probably a json object from gcode comment var cell = this.cells[index.x][index.y][index.z]; diff --git a/js/materials/DMAMaterials.js b/js/materials/DMAMaterials.js index eef1edf4..8684df59 100644 --- a/js/materials/DMAMaterials.js +++ b/js/materials/DMAMaterials.js @@ -97,7 +97,7 @@ define(['underscore', 'backbone', 'three', 'appState', 'lattice', 'materialsPlis options = options || {}; json = data || {}; - var id = json.id || getNextMaterialID(); + var id = json.id || getNextCompositeID(); var material = new DMAMaterial(json, id); if (options.noAdd) return material;//in the new material menu, you may init a material before saving changes diff --git a/js/menus/ESetupMenuView.js b/js/menus/ESetupMenuView.js index 7abeafa5..484a66fc 100644 --- a/js/menus/ESetupMenuView.js +++ b/js/menus/ESetupMenuView.js @@ -10,7 +10,6 @@ define(['jquery', 'underscore', 'menuParent', 'plist', 'materialsPlist', 'text!m events: { "click #calcElectricalConnectivity": "_calcElectricalConnectivity", "click #calcStructuralConnectivity": "_calcStructuralConnectivity", - "click #showOverlappingCells": "_showOverlappingCells" }, _initialize: function(){ @@ -38,11 +37,6 @@ define(['jquery', 'underscore', 'menuParent', 'plist', 'materialsPlist', 'text!m lattice.calculateStructuralConnectivity(); }, - _showOverlappingCells: function(e){ - e.preventDefault(); - lattice.highlightOverlappingCells(); - }, - _makeTemplateJSON: function(){ return _.extend(this.model.toJSON(), eSim.toJSON(), plist, materialsPlist, lattice.toJSON()); }, diff --git a/js/menus/templates/CompositeMenuView.html b/js/menus/templates/CompositeMenuView.html index eecf3cc0..ec81e190 100644 --- a/js/menus/templates/CompositeMenuView.html +++ b/js/menus/templates/CompositeMenuView.html @@ -17,7 +17,6 @@ Available Materials:<br/> </label> <% }); %> <% _.each(materials, function(material, key){ - if (key.substr(0,5) == "super") return; if (material.noDelete) return; %> <label class="radio colorSwatches"> <input type="radio" <%if (key == materialType){ %>checked<%}%> name="materialType" value="<%= key %>" data-toggle="radio" class="custom-radio appState"><span class="icons"><span class="icon-unchecked"></span><span class="icon-checked"></span></span> diff --git a/js/menus/templates/ESetupMenuView.html b/js/menus/templates/ESetupMenuView.html index 8dc6bdb7..fbc40cfb 100644 --- a/js/menus/templates/ESetupMenuView.html +++ b/js/menus/templates/ESetupMenuView.html @@ -1,8 +1,3 @@ -<% if (overlappingCells.length>0) { %> - <div class="inlineWarning">Overlapping cells detected, check that hierarchical cells are not placed on top of one another. Simulation results may be inaccurate.<br/><br/> - <a href="#" id="showOverlappingCells" class="btn btn-block btn-lg btn-danger">Show Problem</a> - </div> -<% } %> Simulation Type: <div class="btn-group"> <button data-toggle="dropdown" class="btn dropdown-toggle" type="button"><%= allMaterialClasses[materialClass] %><span class="caret"></span></button> diff --git a/js/menus/templates/EditComponentMenuView.html b/js/menus/templates/EditComponentMenuView.html index 54669e7e..5624b291 100644 --- a/js/menus/templates/EditComponentMenuView.html +++ b/js/menus/templates/EditComponentMenuView.html @@ -72,7 +72,6 @@ Parent: </a></li> <% }); %> <% _.each(materials, function(material, key){ - if (key.substr(0,5) == "super") return; if (material.noDelete) return; %> <li><a class="stockMaterial dropdownSelector" data-id="<%= key %>" href="#"> <div class="materialColorSwatch"> diff --git a/js/menus/templates/ViewMenuView.html b/js/menus/templates/ViewMenuView.html index 7c5c3af3..03d60d3a 100644 --- a/js/menus/templates/ViewMenuView.html +++ b/js/menus/templates/ViewMenuView.html @@ -5,7 +5,6 @@ Set Material Visibility: <span class="materialListTitle"><%= materials[key].name %></span></div> <% }); %> <% _.each(materials, function(material, key){ - if (key.substr(0,5) == "super") return; if (material.noDelete) return; %> <div class="materialColorSwatch"> <div style="background-color:<% if(realisticColorScheme){ %><%= material.color %><% }else{ %><%= material.altColor %><% } %>"></div> -- GitLab