diff --git a/index.html b/index.html index 328b67d46eab839784f0d36821ac526778af393e..63cc8af5d493d2f5fb0473e4126ede9dd3176c53 100644 --- a/index.html +++ b/index.html @@ -44,6 +44,7 @@ <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> diff --git a/js/fea/DMASuperCell.js b/js/fea/DMASuperCell.js new file mode 100644 index 0000000000000000000000000000000000000000..a2d2ab5ccef11e267b14cf0411b6f04a7e1cc4e1 --- /dev/null +++ b/js/fea/DMASuperCell.js @@ -0,0 +1,40 @@ +/** + * Created by aghassaei on 5/15/15. + */ + + +var cellMaterials = [new THREE.MeshNormalMaterial()]; + +DMASuperCell = function(length, index){ + this.mesh = this._buildSuperCellMesh(length); + this.index = _.clone(index); + this.setScale(); + dmaGlobals.three.sceneAdd(this.mesh); +}; + +DMASuperCell.prototype._buildSuperCellMesh = function(length){ + var superCellGeo = new THREE.BoxGeometry(1,1,1); + superCellGeo.applyMatrix(new THREE.Matrix4().makeScale(length, 1, 1)); + var mesh = THREE.SceneUtils.createMultiMaterialObject(superCellGeo, cellMaterials); + var wireframe = new THREE.BoxHelper(mesh.children[0]); + wireframe.material.color.set(0x000000); + mesh.children.push(wireframe); + return mesh; +}; + +DMASuperCell.prototype._setPosition = function(index){ + var position = dmaGlobals.lattice.getPositionForIndex(index); + this.mesh.position.set(position.x, position.y, position.z); +}; + +DMASuperCell.prototype.setScale = function(scale){ + if (!scale) scale = dmaGlobals.lattice.get("scale"); + this.mesh.scale.set(scale, scale, scale); + this._setPosition(this.index); +}; + +DMASuperCell.prototype.destroy = function(){ + dmaGlobals.three.sceneRemove(this.mesh); + this.mesh = null; + this.index = null; +} \ No newline at end of file diff --git a/js/fea/DmaCellOther.js b/js/fea/DmaCellOther.js index 9f31426f81f319a3f98f5ac49011788704f71e79..adcd7cae4950ed8a55278bf8f7bae826aae3a273 100644 --- a/js/fea/DmaCellOther.js +++ b/js/fea/DmaCellOther.js @@ -60,6 +60,32 @@ var cellMaterial = [new THREE.MeshNormalMaterial()]; })(); +(function () { + + var unitCellGeo = new THREE.BoxGeometry(1,1,1); + + function DMAGIKCell(indices, scale, cellMode, partType){ + DMACubeCell.call(this, indices, scale, cellMode, partType); + } + DMAGIKCell.prototype = Object.create(DMACubeCell.prototype); + + DMAGIKCell.prototype._buildCellMesh = function(){ + return DMACell.prototype._buildCellMesh.call(this, cellMaterial); + }; + + DMAGIKCell.prototype._setCellMeshVisibility = function(visible){ + this.cellMesh.visible = false; + }; + + DMAGIKCell.prototype.setSuperCell = function(superCell, index, length){ + this.superCellIndex = index; + this.superCellLength = length; + }; + + self.DMAGIKCell = DMAGIKCell; + +})(); + /////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////TRUNCATED CUBE CLASS/////////////////////////////////////////////////// diff --git a/js/models/Lattice.js b/js/models/Lattice.js index 3acecb4ba37fe95b3b74dccf111699bebe5b3d3b..32e8c3cd01de921a9986980f0b43f7be96b6f855 100644 --- a/js/models/Lattice.js +++ b/js/models/Lattice.js @@ -448,6 +448,7 @@ Lattice = Backbone.Model.extend({ if (connectionType == "face"){ _.extend(this, this.CubeLattice); } else if (connectionType == "gik"){ + if (!loadingFromFile) this.clearCells(); _.extend(this, this.GIKLattice); } } else if (cellType == "truncatedCube"){ diff --git a/js/models/LatticeOther.js b/js/models/LatticeOther.js index fd8610f2239cb065aa8dcec1d8b739b16a2144d3..a165f4a9ecb73359c3cb1eeb5f75317e7a76aa33 100644 --- a/js/models/LatticeOther.js +++ b/js/models/LatticeOther.js @@ -84,7 +84,17 @@ OtherLatticeSubclasses = { }, makeCellForLatticeType: function(indices, scale){ - return new DMACubeCell(indices, scale); + return new DMAGIKCell(indices, scale); + }, + + addSuperCell: function(range){ + + var length = this.get("gikLength"); + var superCell = new DMASuperCell(length, range.max); + var cells = this.addCellsInRange(range); + _.each(cells, function(cell, index){ + cell.setSuperCell(superCell, index, length); + }); }, _undo: function(){//remove all the mixins, this will help with debugging later diff --git a/js/threeViews/Highlighter.js b/js/threeViews/Highlighter.js index 7e13ea624ede99159cf25610e886b872fe6a5601..bb8fa30b0e7dd4835c1396ddc6d00d515243d712 100644 --- a/js/threeViews/Highlighter.js +++ b/js/threeViews/Highlighter.js @@ -250,7 +250,7 @@ GIKHighlighter = Highlighter.extend({ if (this.mesh.rotation.z == 0) min = {x:position.x-(dmaGlobals.lattice.get("gikLength")-1), y:position.y, z:position.z}; else min = {x:position.x, y:position.y-(dmaGlobals.lattice.get("gikLength")-1), z:position.z}; var range = {min:min, max:position}; - dmaGlobals.lattice.addCellsInRange(range); + dmaGlobals.lattice.addSuperCell(range); } else { if (!this.highlightedObject) return; if (!(this.highlightedObject instanceof DMACell)) return;