From d66127531b66b4d94f34ec7d08eed4dd44d38e73 Mon Sep 17 00:00:00 2001
From: Amanda Ghassaei <amandaghassaei@gmail.com>
Date: Sun, 8 Mar 2015 13:10:38 -0400
Subject: [PATCH] eod

---
 js/fea/DmaCell.js           | 57 +++++++++++++++++++++++++++++++++++++
 js/menus/LatticeMenuView.js |  9 +++++-
 js/models/Lattice.js        |  4 ++-
 main.html                   |  3 +-
 4 files changed, 69 insertions(+), 4 deletions(-)

diff --git a/js/fea/DmaCell.js b/js/fea/DmaCell.js
index 26d0418b..77d893ca 100644
--- a/js/fea/DmaCell.js
+++ b/js/fea/DmaCell.js
@@ -382,6 +382,63 @@ DMACell.prototype.toJSON = function(){
 
 
 
+//    var unitCellGeo3 = new THREE.TetrahedronGeometry(Math.sqrt(3/8));
+//    unitCellGeo3.applyMatrix(new THREE.Matrix4().makeRotationZ(Math.PI/4));
+//    unitCellGeo3.applyMatrix(new THREE.Matrix4().makeRotationX((Math.PI-Math.atan(2*Math.sqrt(2)))/2));
+//    unitCellGeo3.applyMatrix(new THREE.Matrix4().makeScale(1,1,2/3));
+//
+//    function DMAFreeFormSquashedTetraCell(indices, scale, parentCellPos, parentCellQuat, direction, parentType){
+//        DMAFreeFormTetraCell.call(this, indices, scale, parentCellPos, parentCellQuat, direction, parentType);
+//    }
+//    DMAFreeFormSquashedTetraCell.prototype = Object.create(DMAFreeFormTetraCell.prototype);
+//
+//    DMAFreeFormSquashedTetraCell.prototype._buildCellMesh = function(){//abstract mesh representation of cell
+//        return this._superBuildCellMesh(unitCellGeo3);
+//    };
+//
+//    DMAFreeFormSquashedTetraCell.prototype._doMeshTransformations = function(mesh){
+//        var direction = this.parentDirection.clone();
+//        var zAxis = new THREE.Vector3(0,0,1);
+//        zAxis.applyQuaternion(this.parentQuaternion);
+//        var quaternion = new THREE.Quaternion().setFromUnitVectors(zAxis, direction);
+//        quaternion.multiply(this.parentQuaternion);
+//
+//        if (this.parentType == "octa" && direction.sub(zAxis).length() > 0.1){//only do this if connecting to octa
+//            var zRot = new THREE.Quaternion().setFromAxisAngle(this.parentDirection, Math.PI);
+//            zRot.multiply(quaternion);
+//            quaternion = zRot;
+//        }
+//
+//        var eulerRot = new THREE.Euler().setFromQuaternion(quaternion);
+//        mesh.rotation.set(eulerRot.x, eulerRot.y, eulerRot.z);
+//    };
+//
+//    DMAFreeFormTetraCell.prototype.calcHighlighterPosition = function(face){
+//
+//        var direction = face.normal.clone();
+//        direction.applyQuaternion(this.cellMesh.quaternion);
+//
+//        var position = this.getPosition();
+//        var zScale = this.zScale()*3/2;
+//        position.x += direction.x*zScale/2;
+//        position.y += direction.y*zScale/2;
+//        position.z += direction.z*zScale/2;
+//
+//        return {index: _.clone(this.indices), direction:direction, position:position};
+//    };
+//
+//    DMAFreeFormSquashedTetraCell.prototype.zScale = function(scale){
+//        if (!scale) scale = dmaGlobals.lattice.get("scale");
+//        return 2*scale/Math.sqrt(24)*2/3;
+//    };
+//
+//    DMAFreeFormSquashedTetraCell.prototype.getType = function(){
+//        return "squashedTetra";
+//    };
+//    self.DMAFreeFormSquashedTetraCell = DMAFreeFormSquashedTetraCell;
+
+
+
     function DMATetraEdgeCell(indices, scale){
         DMATetraFaceCell.call(this, indices, scale, true);
     }
diff --git a/js/menus/LatticeMenuView.js b/js/menus/LatticeMenuView.js
index d2dc2f06..9dc9c7cc 100644
--- a/js/menus/LatticeMenuView.js
+++ b/js/menus/LatticeMenuView.js
@@ -17,7 +17,8 @@ LatticeMenuView = Backbone.View.extend({
         "change #preserveCells":                        "_changePreserveCells",
         "change #showInverse":                          "_showInverseCells",
         "click #freeformTetraCell":                     "_setTetraCell",
-        "click #freeformOctaCell":                      "_setOctaCell"
+        "click #freeformOctaCell":                      "_setOctaCell",
+        "click #freeformSquasehdTetraCell":             "_setSquashedTetraCell"
     },
 
 
@@ -119,6 +120,11 @@ LatticeMenuView = Backbone.View.extend({
         this.lattice.set("freeformCellType", "tetra");
     },
 
+    _setSquashedTetraCell: function(e){
+        e.preventDefault();
+        this.lattice.set("freeformCellType", "squashedTetra");
+    },
+
     _setOctaCell: function(e){
         e.preventDefault();
         this.lattice.set("freeformCellType", "octa");
@@ -161,6 +167,7 @@ LatticeMenuView = Backbone.View.extend({
                 <ul role="menu" class="dropdown-menu">\
                     <li><a id="freeformOctaCell" href="#">octa</a></li>\
                     <li><a id="freeformTetraCell" href="#">tetra</a></li>\
+                    <li><a id="freeformSquasehdTetraCell" href="#">squashedTetra</a></li>\
                 </ul>\
             </div><br/>\
         <% } else { %>\
diff --git a/js/models/Lattice.js b/js/models/Lattice.js
index 366a394a..5790d15e 100644
--- a/js/models/Lattice.js
+++ b/js/models/Lattice.js
@@ -664,9 +664,11 @@ Lattice = Backbone.Model.extend({
             if (type){
                 if (type == "octa") return new DMAFreeFormOctaCell(index, scale, parentPosition, parentOrientation, direction, parentType);
                 return new DMAFreeFormTetraCell(index, scale, parentPosition, parentOrientation, direction, parentType);
+//                return new DMAFreeFormSquashedTetraCell(index, scale, parentPosition, parentOrientation, direction, parentType);
             }
             if (this.get("freeformCellType") == "octa") return new DMAFreeFormOctaCell(index, scale, parentPosition, parentOrientation, direction, parentType);
             return new DMAFreeFormTetraCell(index, scale, parentPosition, parentOrientation, direction, parentType);
+//            return new DMAFreeFormSquashedTetraCell(index, scale, parentPosition, parentOrientation, direction, parentType);
         },
 
         getIndexForPosition: function(absPosition){//only used by baseplane
@@ -701,7 +703,7 @@ Lattice = Backbone.Model.extend({
 
         zScale: function(scale){
             if (!scale) scale = this.get("scale");
-            if (this.get("freeformCellType") == "octa") return 2*scale/Math.sqrt(6);
+//            if (this.get("freeformCellType") == "octa") return 2*scale/Math.sqrt(6);
             return 2*scale/Math.sqrt(24);
         },
 
diff --git a/main.html b/main.html
index 8b621e7d..394f8027 100644
--- a/main.html
+++ b/main.html
@@ -98,9 +98,8 @@
             <li><a id="saveJSON" href="#">Save JSON &nbsp&nbsp&nbsp&nbsp(CTRL/&#8984; + S)</a></li>
             <li><a data-toggle="modal" data-target="#saveAsModel" href="#">Save JSON As... &nbsp&nbsp&nbsp&nbsp(CTRL/&#8984 + Shift + S)</a></li>
             <li><a id="importJSON" href="#">Open JSON &nbsp&nbsp&nbsp&nbsp(CTRL/&#8984 + O)</a></li>
-            <li><a id="exportSTL" href="#">Export STL</a></li>
             <li class="divider"></li>
-            <li><a href="#">Separated link</a></li>
+            <li><a id="exportSTL" href="#">Export STL</a></li>
           </ul>
         </li>
         <li><a data-menu-id="about" class="menuHoverControls" href="#">About</a></li>
-- 
GitLab