From 8e5c63d9d35b7c4a8e277c1d32cb85dd2a8132d7 Mon Sep 17 00:00:00 2001
From: Amanda Ghassaei <amandaghassaei@gmail.com>
Date: Fri, 14 Aug 2015 19:14:53 -0400
Subject: [PATCH] special parse cells for cam context

---
 js/cam/Cam.js                       | 2 +-
 js/cells/supercells/DMASuperCell.js | 5 +++--
 js/lattice/Lattice.js               | 4 +++-
 js/lattice/LatticeBase.js           | 5 +++--
 js/lattice/LatticeCAM.js            | 4 ++--
 js/plists/CamPList.js               | 2 +-
 6 files changed, 13 insertions(+), 9 deletions(-)

diff --git a/js/cam/Cam.js b/js/cam/Cam.js
index 8ee2ac19..a4582a43 100644
--- a/js/cam/Cam.js
+++ b/js/cam/Cam.js
@@ -259,7 +259,7 @@ define(['underscore', 'three', 'backbone', 'appState', 'latticeCAM', 'threeModel
             if (appState.get("stockSimulationPlaying")){
                 three.startAnimationLoop();
                 var currentLine = this.get("simLineNumber");
-                if (currentLine == 0) lattice.hideCells();
+                if (currentLine == 0) lattice.hideCells("cells");
                 var allLines = this.get("dataOut").split("\n");
                 if(currentLine<allLines.length){
                     var self = this;
diff --git a/js/cells/supercells/DMASuperCell.js b/js/cells/supercells/DMASuperCell.js
index 81881a8d..925316bc 100644
--- a/js/cells/supercells/DMASuperCell.js
+++ b/js/cells/supercells/DMASuperCell.js
@@ -114,10 +114,11 @@ define(['underscore', 'three', 'threeModel', 'lattice', 'appState', 'cell'],
 
 
      //parse
-    DMASuperCell.prototype.addToDenseArray = function(cellsArray, min){
+    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 = false;
         this._loopCells(function(cell){
-            if (cell) overlap |= cell.addToDenseArray(cellsArray, min);
+            if (cell) overlap |= cell.addToDenseArray(cellsArray, min, forCAM);
         });
         return overlap;
     };
diff --git a/js/lattice/Lattice.js b/js/lattice/Lattice.js
index 0cd49e79..8afdd8fb 100644
--- a/js/lattice/Lattice.js
+++ b/js/lattice/Lattice.js
@@ -161,9 +161,11 @@ define(['underscore', 'backbone', 'appState', 'globals', 'plist', 'three', 'thre
 
             var min = this.get("cellsMin").sub(bounds.min);
             var overlap = false;
+            var forCAM = appState.get("currentNav") == "navAssemble";
+            console.log(forCAM);
             this._loopCells(this.sparseCells, function(cell){
                 if (!cell) return;
-                overlap |= cell.addToDenseArray(cells, min);
+                overlap |= cell.addToDenseArray(cells, min, forCAM);
             });
             this.set("overlapDetected", overlap);
 
diff --git a/js/lattice/LatticeBase.js b/js/lattice/LatticeBase.js
index bc7993af..ade2d7cc 100644
--- a/js/lattice/LatticeBase.js
+++ b/js/lattice/LatticeBase.js
@@ -456,8 +456,9 @@ define(['underscore', 'backbone', 'appState', 'globals', 'plist', 'three', 'thre
             else this.hideCells();
         },
 
-        hideCells: function(){
-            this._iterCells(this.sparseCells, function(cell){
+        hideCells: function(whichArray){
+            if (!whichArray) whichArray = "sparseCells";
+            this._iterCells(this[whichArray], function(cell){
                 if (cell) cell.hide();
             });
             three.render();
diff --git a/js/lattice/LatticeCAM.js b/js/lattice/LatticeCAM.js
index a367a0be..bc7a87f8 100644
--- a/js/lattice/LatticeCAM.js
+++ b/js/lattice/LatticeCAM.js
@@ -9,7 +9,7 @@ define(['lattice', 'three'], function(lattice, THREE){
 
         showCellAtIndex: function(index){
             var latticeIndex = (new THREE.Vector3()).subVectors(index, this.get("cellsMin"));//index is probably a json object from gcode comment
-            var cell = this.sparseCells[latticeIndex.x][latticeIndex.y][latticeIndex.z];
+            var cell = this.cells[latticeIndex.x][latticeIndex.y][latticeIndex.z];
             if (cell) cell.show();
             else console.warn("placing a cell that does not exist");
         },
@@ -24,7 +24,7 @@ define(['lattice', 'three'], function(lattice, THREE){
                 firstLetter = order.charAt(0);
                 order = order.substr(1);
             }
-            if (!cells) cells = this.sparseCells;//grab cells once at beginning and hold onto it in case changes are made while looping
+            if (!cells) cells = this.cells;//grab cells once at beginning and hold onto it in case changes are made while looping
             var newVarOrder;
             var newVarDim;
             if (firstLetter == 'X'){
diff --git a/js/plists/CamPList.js b/js/plists/CamPList.js
index eb1e6262..68ec428e 100644
--- a/js/plists/CamPList.js
+++ b/js/plists/CamPList.js
@@ -138,7 +138,7 @@ define(['three'], function(THREE){
                     camStrategy: "raster",
                     placementOrder: "XYZ",//used for raster strategy entry
                     camProcess: "gcode",
-                    rapidHeight:10,
+                    rapidHeight:40,
                     rapidHeightRelative: true,
                     safeHeight: 0.5,
                     originPosition: new THREE.Vector3(0,0,0),
-- 
GitLab