From 7d0b320f926534162bd596c1255265b6a8e16003 Mon Sep 17 00:00:00 2001
From: Amanda Ghassaei <amandaghassaei@gmail.com>
Date: Sun, 23 Aug 2015 12:07:15 -0400
Subject: [PATCH] fixed parsing bug

---
 js/cam/assemblers/AssemblerPost.js  | 3 ++-
 js/cam/assemblers/Component.js      | 2 +-
 js/cells/DMACell.js                 | 2 +-
 js/cells/supercells/GIKSuperCell.js | 9 +++++++++
 4 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/js/cam/assemblers/AssemblerPost.js b/js/cam/assemblers/AssemblerPost.js
index 13757e2e..909853d1 100644
--- a/js/cam/assemblers/AssemblerPost.js
+++ b/js/cam/assemblers/AssemblerPost.js
@@ -125,7 +125,7 @@ define(['underscore', 'appState', 'lattice', 'cam'], function(_, appState, latti
         //offset for rotation
         var offset = self.components.substrate.centerOfRotation.clone().multiplyScalar(settings.scale);//offset in lattice pitch
         var dist = position.clone().sub(offset);
-        position = offset.add(new THREE.Vector3(-dist.y-3*settings.scale, dist.x-0.335, position.z));
+        position = offset.add(new THREE.Vector3(-dist.y, dist.x-0.335, position.z));
     } else {
         position.y -= 1;
         position.x -= settings.scale;
@@ -217,6 +217,7 @@ define(['underscore', 'appState', 'lattice', 'cam'], function(_, appState, latti
             if (!cell) return;
 
             var cellPosition = cell.getAbsolutePosition().multiplyScalar(settings.scale);
+            if (cell.getMinPosition) cellPosition = cell.getMinPosition().multiplyScalar(settings.scale);
             var cellIndex = cell.getAbsoluteIndex();
 
             if (!self.shouldPickUpStock){
diff --git a/js/cam/assemblers/Component.js b/js/cam/assemblers/Component.js
index 0073567d..e67e7b0f 100644
--- a/js/cam/assemblers/Component.js
+++ b/js/cam/assemblers/Component.js
@@ -135,7 +135,7 @@ define(['underscore', 'cam', 'three'], function(_, cam, THREE){
     };
 
     Component.prototype.applyRotation = function(vector){//todo local rotation?
-        vector.applyQuaternion(this.getAbsoluteOrientation());
+        vector.applyQuaternion(this.getOrientation());
         return vector;
     };
 
diff --git a/js/cells/DMACell.js b/js/cells/DMACell.js
index cd230940..8400570a 100644
--- a/js/cells/DMACell.js
+++ b/js/cells/DMACell.js
@@ -126,7 +126,7 @@ define(['underscore', 'three', 'threeModel', 'lattice', 'appState', 'globals', '
     };
 
     DMACell.prototype.applyRotation = function(vector){//todo local rotation?
-        vector.applyQuaternion(this.getAbsoluteOrientation());
+        vector.applyQuaternion(this.getOrientation());
         return vector;
     };
 
diff --git a/js/cells/supercells/GIKSuperCell.js b/js/cells/supercells/GIKSuperCell.js
index 6161eeff..3738fc66 100644
--- a/js/cells/supercells/GIKSuperCell.js
+++ b/js/cells/supercells/GIKSuperCell.js
@@ -49,6 +49,15 @@ define(['underscore', 'three', 'threeModel', 'lattice', 'appState', 'superCell',
         return unitGeos[key];
     };
 
+    GIKSuperCell.prototype.getMinPosition = function(){//for assembly
+        var position = this.getAbsolutePosition();
+        var oppPosition = this.applyAbsoluteRotation(new THREE.Vector3(3,0,0));
+        oppPosition.add(position);
+        position.x = Math.min(position.x, oppPosition.x);
+        position.y = Math.max(position.y, oppPosition.y);
+        return position;
+    };
+
     GIKSuperCell.prototype._buildWireframe = function(mesh){
         var wireframe = new THREE.BoxHelper(mesh);
         wireframe.material.color.set(0x000000);
-- 
GitLab