Skip to content
Snippets Groups Projects
Commit f8796624 authored by Amanda Ghassaei's avatar Amanda Ghassaei
Browse files

moving stuff around

parent 055f664a
Branches
No related tags found
No related merge requests found
Showing
with 553 additions and 7 deletions
......@@ -43,19 +43,19 @@
<!--fea stuff-->
<script src="js/fea/DmaNode.js"></script>
<script src="js/fea/DmaBeam.js"></script>
<script src="js/fea/DmaCell.js"></script>
<script src="js/fea/DMASuperCell.js"></script>
<script src="js/fea/DMACellFreeform.js"></script>
<script src="js/fea/DmaCellOcta.js"></script>
<script src="js/fea/DmaCellTetra.js"></script>
<script src="js/fea/DmaCellOther.js"></script>
<script src="js/cell/DmaCell.js"></script>
<script src="js/cell/DMASuperCell.js"></script>
<script src="js/cell/DMACellFreeform.js"></script>
<script src="js/cell/DmaCellOcta.js"></script>
<script src="js/cell/DmaCellTetra.js"></script>
<script src="js/cell/DmaCellOther.js"></script>
<script src="js/fea/DmaPart.js"></script>
<!--models-->
<script src="js/models/ThreeModel.js"></script>
<script src="js/models/LatticeOcta.js"></script>
<script src="js/models/LatticeOther.js"></script>
<script src="js/models/Lattice.js"></script>
<script src="js/lattice/Lattice.js"></script>
<script src="js/models/FillGeometry.js"></script>
<script src="js/models/BasePlane.js"></script>
<script src="js/models/extrudeVisualizer.js"></script>
......
File moved
File moved
File moved
File moved
File moved
File moved
/**
* Created by aghassaei on 5/26/15.
*/
_.extend(Lattice, {
CubeLattice: {
_initLatticeType: function(){
globals.basePlane = new SquareBasePlane();
globals.highlighter = new CubeHighlighter();
},
getIndexForPosition: function(absPosition){
return this._indexForPosition(absPosition);
},
getPositionForIndex: function(index){
return this._positionForIndex(index);
},
xScale: function(){
return 1+2*this.get("cellSeparation").xy;
},
yScale: function(){
return this.xScale();
},
zScale: function(){
return 1+2*this.get("cellSeparation").z;
},
makeCellForLatticeType: function(indices){
return new DMACubeCell(indices);
},
_undo: function(){//remove all the mixins, this will help with debugging later
var self = this;
_.each(_.keys(this.CubeLattice), function(key){
self[key] = null;
});
}
}
});
\ No newline at end of file
/**
* Created by aghassaei on 5/26/15.
*/
_.extend(Lattice, {
GIKLattice: {
_initLatticeType: function(){
globals.basePlane = new SquareBasePlane();
globals.highlighter = new GIKHighlighter();
},
getIndexForPosition: function(absPosition){
return this._indexForPosition(absPosition);
},
getPositionForIndex: function(index){
return this._positionForIndex(index);
},
xScale: function(){
return 1+2*this.get("cellSeparation").xy;
},
yScale: function(){
return this.xScale();
},
zScale: function(){
return 1.28*(1+2*this.get("cellSeparation").z);
},
makeCellForLatticeType: function(indices){
return new DMAGIKCell(indices);
},
makeSuperCell: function(range){
var length = this.get("gikLength");
var cells;
if (range) cells = this.addCellsInRange(range);
else {
cells = [];
for (var i=0;i<length;i++){
cells.push(this.makeCellForLatticeType(null));
}
}
if (cells.length < 1) return null;
var superCell = new DMASuperCell(length, range, cells);
_.each(cells, function(cell, index){
cell.setSuperCell(superCell, index);
});
return superCell;
},
_rasterGikCells: function(order, callback, var1, var2, var3, cells){
for (var i=this._getRasterLoopInit(var1);this._getRasterLoopCondition(i,var1);i+=this._getRasterLoopIterator(var1)){
for (var j=this._getRasterLoopInit(var2);this._getRasterLoopCondition(j,var2);j+=this._getRasterLoopIterator(var2)){
for (var k=this._getRasterLoopInit(var3);this._getRasterLoopCondition(k,var3);k+=this._getRasterLoopIterator(var3)){
var numToSkip = {x:0,y:0};
if (var1.order == 0){
if (var2.order == 1) numToSkip = this._doSuperCellCallback(cells, i, j, k, callback);
else if (var2.order == 2) numToSkip = this._doSuperCellCallback(cells, i, k, j, callback);
} else if (var1.order == 1){
if (var2.order == 0) numToSkip = this._doSuperCellCallback(cells, j, i, k, callback);
else if (var2.order == 2) numToSkip = this._doSuperCellCallback(cells, k, i, j, callback);
} else {
if (var2.order == 0) {
numToSkip = this._doSuperCellCallback(cells, j, k, i, callback);
}
else if (var2.order == 1) {
numToSkip = this._doSuperCellCallback(cells, k, j, i, callback);
}
}
}
}
}
},
_doSuperCellCallback: function(cells, x, y, z, callback){
var cell = cells[x][y][z];
if (z%2 != 0) cell = cells[y][x][z];
if (!cell) {
callback(null, x, y, z);
return {x:0,y:0};
}
var superCell = cell.superCell;
callback(superCell, x, y, z);
if (z%2 != 0) return {x:0, y:superCell.getLength()};
return {x:superCell.getLength(), y:0};
},
_undo: function(){//remove all the mixins, this will help with debugging later
var self = this;
_.each(_.keys(this.GIKLattice), function(key){
self[key] = null;
});
}
}
});
\ No newline at end of file
/**
* Created by aghassaei on 5/26/15.
*/
_.extend(Lattice, {
KelvinLattice: {
_initLatticeType: function(){
globals.basePlane = new SquareBasePlane();
globals.highlighter = new TruncatedCubeHighlighter();
},
getIndexForPosition: function(absPosition){
return this._indexForPosition(absPosition);
},
getPositionForIndex: function(index){
return this._positionForIndex(index);
},
xScale: function(){
return 2*Math.sqrt(2)+2*this.get("cellSeparation").xy;
},
yScale: function(){
return this.xScale();
},
zScale: function(){
return 2*Math.sqrt(2)+2*this.get("cellSeparation").z;
},
makeCellForLatticeType: function(indices){
return new DMATruncOctaCell(indices);
},
_undo: function(){//remove all the mixins, this will help with debugging later
var self = this;
_.each(_.keys(this.KelvinLattice), function(key){
self[key] = null;
});
}
}
});
\ No newline at end of file
File moved
/**
* Created by aghassaei on 5/26/15.
*/
_.extend(Lattice, {
OctaEdgeLattice: {
_initLatticeType: function(){
globals.basePlane = new OctaBasePlane();
globals.highlighter = new OctaEdgeHighlighter();
},
getIndexForPosition: function(absPosition){
//todo finish this
var yIndex = Math.floor(absPosition.y/this.yScale());
if (yIndex%2 != 0) absPosition.x += this.xScale()/2;
var yScale = 1/Math.sqrt(3);
var index = this._indexForPosition(absPosition);
if (index.z%3 == 1) {
absPosition.x -= this.xScale()/2;
absPosition.y += yScale/2;
} else if (index.z%3 == 2){
absPosition.y += yScale;
}
var index = this._indexForPosition(absPosition);
return index;
},
getPositionForIndex: function(index){
var position = _.clone(index);
var xScale = this.xScale();
var yScale = 1/Math.sqrt(3);
position.x = (position.x+1/2)*xScale;
position.y = position.y*this.yScale()+yScale/2;
position.z = (position.z+0.5)*this.zScale();
if (index.y%2 != 0) position.x -= this.xScale()/2;
if (index.z%3 == 1) {
position.x += this.xScale()/2;
position.y -= yScale/2;
} else if (index.z%3 == 2){
position.y -= yScale;
}
return position;
},
makeCellForLatticeType: function(indices){
return new DMAEdgeOctaCell(indices);
},
_undo: function(){//remove all the mixins, this will help with debugging later
var self = this;
_.each(_.keys(this.OctaEdgeLattice), function(key){
self[key] = null;
});
_.each(_.keys(this.OctaFaceLattice), function(key){
self[key] = null;
});
}
}
});
\ No newline at end of file
/**
* Created by aghassaei on 5/26/15.
*/
_.extend(Lattice, {
OctaFaceLattice: {
_initLatticeType: function(){
globals.basePlane = new OctaBasePlane();
globals.highlighter = new OctaFaceHighlighter();
},
getIndexForPosition: function(absPosition){
var yIndex = Math.floor(absPosition.y/this.yScale());
if (yIndex%2 != 0) absPosition.x += this.xScale()/2;
var index = this._indexForPosition(absPosition);
if (index.z%2 == 1) index.y += 1;
return index;
},
getPositionForIndex: function(index){
var position = _.clone(index);
position.x = (position.x+1/2);
position.y = position.y*this.yScale()+1/Math.sqrt(3)/2;
position.z = (position.z+0.5)*this.zScale();
if ((index.y%2) != 0) position.x -= this.xScale()/2;
return position;
},
xScale: function(){
return 1+2*this.get("cellSeparation").xy;
},
yScale: function(){
return this.xScale()/2*Math.sqrt(3);
},
zScale: function(){
return 2/Math.sqrt(6)+2*this.get("cellSeparation").z;
},
makeCellForLatticeType: function(indices){
return new DMAFaceOctaCell(indices);
},
_undo: function(){//remove all the mixins
var self = this;
_.each(_.keys(this.OctaFaceLattice), function(key){
self[key] = null;
});
}
}
});
\ No newline at end of file
/**
* Created by aghassaei on 5/26/15.
*/
_.extend(Lattice, {
OctaFreeFormFaceLattice: {
_initLatticeType: function(){
globals.basePlane = new OctaBasePlane();
globals.highlighter = new OctaFreeFormHighlighter();
this.set("freeformCellType", "octa");
},
addFreeFormCell: function(parentCellPos, parentCellOrient, direction, parentType, type){
var cells = this.get("cells");
cells[0][0].push(this.makeCellForLatticeType({x:0,y:0,z:cells[0][0].length}, parentCellPos, parentCellOrient, direction, parentType, type));
this.set("numCells", this.get("numCells")+1);
globals.three.render();
},
makeCellForLatticeType: function(index, parentPosition, parentOrientation, direction, parentType, type){
if (type){
if (type == "octa") return new DMAFreeFormOctaCell(index, parentPosition, parentOrientation, direction, parentType);
return new DMAFreeFormTetraCell(index, parentPosition, parentOrientation, direction, parentType);
}
if (this.get("freeformCellType") == "octa") return new DMAFreeFormOctaCell(index, parentPosition, parentOrientation, direction, parentType);
return new DMAFreeFormTetraCell(index, parentPosition, parentOrientation, direction, parentType);
},
getIndexForPosition: function(absPosition){//only used by baseplane
var yIndex = Math.floor(absPosition.y/this.yScale());
if (yIndex%2 != 0) absPosition.x += this.xScale()/2;
var index = this._indexForPosition(absPosition);
if (index.z%2 == 1) index.y += 1;
return index;
},
getPositionForIndex: function(index){//only used by baseplane
var position = _.clone(index);
var xScale = this.xScale();
position.x = (position.x+1/2)*xScale;
position.y = position.y*this.yScale()+1/Math.sqrt(3)/2;
position.z = (position.z+0.5)*this.zScale();
if ((index.y%2) != 0) position.x -= xScale/2;
return position;
},
xScale: function(){
return 1+2*this.get("cellSeparation").xy;
},
yScale: function(){
return this.xScale()/2*Math.sqrt(3);
},
zScale: function(){
if (this.get("freeformCellType") == "octa") return 2/Math.sqrt(6)+2*this.get("cellSeparation").xy;
return 2/Math.sqrt(24)+2*this.get("cellSeparation").xy;
},
_undo: function(){//remove all the mixins
var self = this;
this.set("freeformCellType", null);//todo get rid of this property
this.clearCells();
_.each(_.keys(this.OctaFreeFormFaceLattice), function(key){
self[key] = null;
});
}
}
});
\ No newline at end of file
/**
* Created by aghassaei on 5/26/15.
*/
_.extend(Lattice, {
OctaRotEdgeLattice: {
_initLatticeType: function(){
globals.basePlane = new RotEdgeOctaBasePlane();
globals.highlighter = new OctaVertexHighlighter();
},
getIndexForPosition: function(absPosition){
var position = {};
position.x = Math.floor(absPosition.x/this.xScale()+0.5);
position.y = Math.floor(absPosition.y/this.yScale()+0.5);
position.z = Math.floor(absPosition.z/this.zScale()+0.5);
return position;
},
getPositionForIndex: function(index){
var position = _.clone(index);
if (index.z %2 != 0){
position.x += 0.5;
position.y += 0.5;
}
position.x = (position.x)*this.xScale();
position.y = (position.y)*this.yScale();
position.z = (position.z+1)*this.zScale();
return position;
},
xScale: function(){
return 1 + 2*this.get("cellSeparation").xy;
},
yScale: function(){
return this.xScale();
},
zScale: function(){
return Math.sqrt(2)/2 + 2*this.get("cellSeparation").z;
},
makeCellForLatticeType: function(indices){
return new DMARotatedEdgeCell(indices);
},
_undo: function(){//remove all the mixins
var self = this;
_.each(_.keys(this.OctaRotEdgeLattice), function(key){
self[key] = null;
});
}
}
});
\ No newline at end of file
/**
* Created by aghassaei on 5/26/15.
*/
_.extend(Lattice, {
OctaVertexLattice: {
_initLatticeType: function(){
globals.basePlane = new SquareBasePlane();
globals.highlighter = new OctaVertexHighlighter();
},
getIndexForPosition: function(absPosition){
var position = {};
position.x = Math.floor(absPosition.x/this.xScale()+0.5);
position.y = Math.floor(absPosition.y/this.yScale()+0.5);
position.z = Math.floor(absPosition.z/this.zScale()+0.5);
return position;
},
getPositionForIndex: function(index){
var position = _.clone(index);
position.x = (position.x)*this.xScale();
position.y = (position.y)*this.yScale();
position.z = (position.z+0.5)*this.zScale();
return position;
},
xScale: function(){
return Math.sqrt(2)+this.get("cellSeparation").xy;
},
yScale: function(){
return this.xScale();
},
zScale: function(){
return Math.sqrt(2)+this.get("cellSeparation").z;
},
makeCellForLatticeType: function(indices){
return new DMAVertexOctaCell(indices);
},
_undo: function(){//remove all the mixins, this will help with debugging later
var self = this;
_.each(_.keys(this.OctaVertexLattice), function(key){
self[key] = null;
});
}
}
});
\ No newline at end of file
/**
* Created by aghassaei on 5/26/15.
*/
_.extend(Lattice, {
TruncatedCubeLattice: {
_initLatticeType: function(){
globals.basePlane = new SquareBasePlane();
globals.highlighter = new TruncatedCubeHighlighter();
},
getIndexForPosition: function(absPosition){
return this._indexForPosition(absPosition);
},
getPositionForIndex: function(index){
return this._positionForIndex(index);
},
xScale: function(){
return Math.sqrt(2)+2*this.get("cellSeparation").xy;
},
yScale: function(){
return this.xScale();
},
zScale: function(){
return Math.sqrt(2)+2*this.get("cellSeparation").z;
},
makeCellForLatticeType: function(indices){
return new DMATruncCubeCell(indices);
},
_undo: function(){//remove all the mixins, this will help with debugging later
var self = this;
_.each(_.keys(this.TruncatedCubeLattice), function(key){
self[key] = null;
});
}
}
});
\ No newline at end of file
......@@ -29,4 +29,6 @@ $(function(){
new ThreeView({model:globals.three});
if (globals.lattice.get("connectionType") != "gik") globals.lattice.addCellAtIndex({x:0,y:0,z:0});//add a cell
// return {globals:globals};
});
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment