Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
DMDesign
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Amanda Ghassaei
DMDesign
Commits
faf1109d
Commit
faf1109d
authored
10 years ago
by
Amanda Ghassaei
Browse files
Options
Downloads
Patches
Plain Diff
still working out kinks with exanding cell array
parent
6ea7ca03
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
js/fea/dmaCell.js
+26
-25
26 additions, 25 deletions
js/fea/dmaCell.js
js/fea/dmaPart.js
+19
-38
19 additions, 38 deletions
js/fea/dmaPart.js
js/models/lattice.js
+121
-8
121 additions, 8 deletions
js/models/lattice.js
with
166 additions
and
71 deletions
js/fea/dmaCell.js
+
26
−
25
View file @
faf1109d
...
...
@@ -22,24 +22,33 @@
var
cellMaterials
=
[
new
THREE
.
MeshNormalMaterial
(),
new
THREE
.
MeshBasicMaterial
({
color
:
0x000000
,
wireframe
:
true
})];
function
Cell
(
mode
,
position
)
{
function
DMACell
(
mode
,
position
)
{
this
.
position
=
position
;
this
.
drawForMode
(
mode
,
position
);
this
.
parts
=
this
.
_initParts
();
//
this.
parts = this._createParts(nodes, config
);
this
.
drawForMode
(
mode
);
}
Cell
.
prototype
.
_buildPartsMesh
=
function
(){
// var parts = [];
// for (var i=0;i<nodes.length;i++){
// parts.push(new Part(nodes[i], config[i]));
// }
// return parts;
return
null
;
DMACell
.
prototype
.
_initParts
=
function
(){
var
parts
=
[];
for
(
var
i
=
0
;
i
<
3
;
i
++
){
parts
.
push
(
new
DMAPart
(
i
));
}
return
parts
;
};
DMACell
.
prototype
.
_buildPartsMesh
=
function
(
position
){
var
parts
=
[];
for
(
var
i
=
0
;
i
<
nodes
.
length
;
i
++
){
parts
.
push
(
new
Part
(
nodes
[
i
],
config
[
i
]));
}
return
parts
;
};
Cell
.
prototype
.
_buildCellMesh
=
function
(
position
){
//abstract mesh representation of cell
DMA
Cell
.
prototype
.
_buildCellMesh
=
function
(
position
){
//abstract mesh representation of cell
var
mesh
;
...
...
@@ -56,8 +65,8 @@
return
mesh
;
};
Cell
.
prototype
.
drawForMode
=
function
(
mode
,
position
){
position
=
position
||
this
.
position
;
DMA
Cell
.
prototype
.
drawForMode
=
function
(
mode
){
position
=
this
.
position
;
if
(
mode
==
"
cell
"
){
if
(
this
.
cellMesh
)
this
.
_setCellMeshVisibility
(
true
);
else
{
...
...
@@ -75,7 +84,7 @@
}
};
Cell
.
prototype
.
_setCellMeshVisibility
=
function
(
visibility
){
DMA
Cell
.
prototype
.
_setCellMeshVisibility
=
function
(
visibility
){
if
(
!
this
.
cellMesh
)
return
;
this
.
cellMesh
.
visible
=
visibility
;
// _.each(this.cellMesh.children, function(childMesh){
...
...
@@ -83,22 +92,14 @@
// });
};
Cell
.
prototype
.
remove
=
function
(){
DMA
Cell
.
prototype
.
remove
=
function
(){
if
(
this
.
cellMesh
)
window
.
three
.
sceneRemove
(
this
.
cellMesh
);
};
Cell
.
prototype
.
translate
=
function
(
dx
,
dy
,
dz
){
};
Cell
.
prototype
.
rotate
=
function
(
rx
,
ry
,
rz
){
};
Cell
.
prototype
.
_destroy
=
function
(){
DMACell
.
prototype
.
_destroy
=
function
(){
if
(
this
.
cellMesh
)
this
.
cellMesh
.
myCell
=
null
;
};
self
.
Cell
=
Cell
;
self
.
DMACell
=
DMACell
;
})();
This diff is collapsed.
Click to expand it.
js/fea/dmaPart.js
+
19
−
38
View file @
faf1109d
...
...
@@ -5,51 +5,32 @@
//a part, element with a single material, handled by assembler
(
function
()
{
function
DmaPart
(
geometry
,
nodes
)
{
//list of nodes, config tells how nodes are connected
this
.
nodes
=
nodes
;
// this.beams = this._createBeams(nodes, config);
this
.
scale
=
10
;
this
.
geometry
=
geometry
;
this
.
render
();
}
var
partGeometry1
;
DmaPart
.
prototype
.
_createBeams
=
function
(
nodes
,
config
){
var
beams
=
[];
_
.
each
(
config
,
function
(
pair
){
beams
.
push
(
new
Beam
(
nodes
[
pair
[
0
]],
nodes
[
pair
[
2
]]));
});
return
beams
;
};
function
DMAPart
(
type
)
{
// this.nodes = nodes;
// this.beams = this._createBeams(nodes, config);
this
.
scale
=
10
;
// this.geometry = geometry;
}
DmaPart
.
prototype
.
render
=
function
(){
//translate geo to nodes
var
midpoint
=
this
.
nodes
[
0
].
getMidPoint
(
this
.
nodes
[
1
]);
// this.geometry.applyMatrix(new THREE.Matrix4().makeTranslation());
DMAPart
.
prototype
.
_createBeams
=
function
(
nodes
,
config
){
// var beams = [];
// _.each(config, function(pair){
// beams.push(new Beam(nodes[pair[0]], nodes[pair[2]]));
// });
// return beams;
};
DMAPart
.
prototype
.
render
=
function
(){
};
var
mesh
=
new
THREE
.
Mesh
(
this
.
geometry
);
var
scale
=
this
.
scale
*
2.5
;
mesh
.
scale
.
set
(
scale
,
scale
,
scale
);
// mesh.rotateZ(Math.PI);
self
.
DMAPart
=
DMAPart
;
mesh
.
position
.
x
=
midpoint
[
0
];
mesh
.
position
.
y
=
midpoint
[
1
];
mesh
.
position
.
z
=
midpoint
[
2
];
new
BeamNode
(
0
,
0
,
0
);
window
.
three
.
sceneAdd
(
mesh
);
window
.
three
.
render
();
};
DmaPart
.
prototype
.
translate
=
function
(
dx
,
dy
,
dz
){
};
DmaPart
.
prototype
.
rotate
=
function
(
rx
,
ry
,
rz
){
};
})();
//////////////////////////////////////////////////////////////
/////////////////SUBCLASSES///////////////////////////////////
...
...
This diff is collapsed.
Click to expand it.
js/models/lattice.js
+
121
−
8
View file @
faf1109d
...
...
@@ -10,7 +10,9 @@ Lattice = Backbone.Model.extend({
cellType
:
"
octa
"
,
connectionType
:
"
face
"
,
nodes
:
[],
cells
:
[],
cells
:
[[[]]],
//3D matrix containing all cells and null, dynamic
cellsMin
:
{
x
:
0
,
y
:
0
,
z
:
0
},
//min position of cells matrix
cellsMax
:
{
x
:
0
,
y
:
0
,
z
:
0
},
//min position of cells matrix
numCells
:
0
,
partType
:
"
triangle
"
,
cellMode
:
"
cell
"
...
...
@@ -24,14 +26,125 @@ Lattice = Backbone.Model.extend({
this
.
listenTo
(
this
,
"
change:cellMode
"
,
this
.
_cellModeDidChange
);
},
addCell
:
function
(
position
){
addCell
:
function
(
absPosition
){
var
cells
=
this
.
get
(
"
cells
"
);
if
(
this
.
get
(
"
cellMode
"
)
==
"
parts
"
)
return
;
//remove this eventually
cells
.
push
(
new
Cell
(
this
.
get
(
"
cellMode
"
),
position
));
this
.
set
(
"
numCells
"
,
cells
.
length
);
//calc indices in cell matrix
var
scale
=
this
.
get
(
"
scale
"
);
var
octHeight
=
3
*
scale
/
8
*
Math
.
sqrt
(
5
);
//this isn't quite right
var
triHeight
=
scale
/
2
*
Math
.
sqrt
(
3
);
var
position
=
{};
position
.
x
=
Math
.
round
(
absPosition
.
x
/
scale
);
position
.
y
=
Math
.
round
(
absPosition
.
y
/
triHeight
);
position
.
z
=
Math
.
round
(
absPosition
.
z
/
octHeight
);
//check for matrix expansion
var
lastMax
=
this
.
get
(
"
cellsMax
"
);
var
lastMin
=
this
.
get
(
"
cellsMin
"
);
var
newMax
=
this
.
_updateCellsMax
(
position
,
lastMax
);
var
newMin
=
this
.
_updateCellsMin
(
position
,
lastMin
);
if
(
newMax
)
{
this
.
_expandCellsArray
(
cells
,
this
.
_subtract
(
newMax
,
lastMin
),
false
);
this
.
set
(
"
cellsMax
"
,
newMax
);
}
if
(
newMin
)
{
this
.
_expandCellsArray
(
cells
,
this
.
_subtract
(
newMin
,
lastMin
),
true
);
this
.
set
(
"
cellsMin
"
,
newMin
);
}
console
.
log
(
cells
);
cells
[
position
.
x
][
position
.
y
][
position
.
z
]
=
new
DMACell
(
this
.
get
(
"
cellMode
"
),
absPosition
);
// console.log(cells);
// this.set("numCells", cells.length);
window
.
three
.
render
();
},
_expandCellsArray
:
function
(
cells
,
expansion
,
fromFront
){
_
.
each
(
_
.
keys
(
expansion
),
function
(
key
){
if
(
expansion
[
key
]
==
0
)
return
;
//no expansion on this axis
var
cellsX
=
cells
.
length
;
var
cellsY
=
cellsX
>
0
?
0
:
cells
[
0
].
length
;
var
cellsZ
=
cellsY
>
0
?
0
:
cells
[
0
][
0
].
length
;
if
(
key
==
"
x
"
){
for
(
var
x
=
0
;
x
<
expansion
[
key
];
x
++
){
var
newLayer
=
[];
for
(
var
y
=
0
;
y
<
cellsY
;
y
++
){
var
newCol
=
[];
for
(
var
z
=
0
;
z
<
cellsZ
;
z
++
){
newCol
.
push
(
null
);
}
newLayer
.
push
(
newCol
);
}
if
(
fromFront
)
cells
.
unshift
(
newLayer
);
else
cells
.
push
(
newLayer
);
}
}
else
if
(
key
==
"
y
"
){
for
(
var
x
=
0
;
x
<
cellsX
;
x
++
){
for
(
var
y
=
0
;
y
<
expansion
[
key
];
y
++
){
var
newCol
=
[];
for
(
var
z
=
0
;
z
<
cellsZ
;
z
++
){
newCol
.
push
(
null
);
}
if
(
fromFront
)
cells
.
unshift
(
newCol
);
else
cells
.
push
(
newCol
);
}
}
}
else
if
(
key
==
"
z
"
){
for
(
var
x
=
0
;
x
<
cellsX
;
x
++
){
for
(
var
y
=
0
;
y
<
cellsY
;
y
++
){
for
(
var
z
=
0
;
z
<
expansion
[
key
];
z
++
){
if
(
fromFront
)
cells
[
x
][
y
].
unshift
(
null
);
else
cells
[
x
][
y
].
push
(
null
);
}
}
}
}
});
},
_updateCellsMin
:
function
(
newPosition
,
currentMin
){
var
newMin
=
{};
var
hasChanged
=
false
;
_
.
each
(
_
.
keys
(
newPosition
),
function
(
key
){
if
(
newPosition
[
key
]
<
currentMin
[
key
]){
hasChanged
=
true
;
newMin
[
key
]
=
newPosition
[
key
];
}
else
{
newMin
[
key
]
=
currentMin
[
key
];
}
});
if
(
hasChanged
)
return
newMin
;
return
false
;
},
_updateCellsMax
:
function
(
newPosition
,
currentMax
){
var
newMax
=
{};
var
hasChanged
=
false
;
_
.
each
(
_
.
keys
(
newPosition
),
function
(
key
){
if
(
newPosition
[
key
]
>
currentMax
[
key
]){
hasChanged
=
true
;
newMax
[
key
]
=
newPosition
[
key
];
}
else
{
newMax
[
key
]
=
currentMax
[
key
];
}
});
if
(
hasChanged
)
return
newMax
;
return
false
;
},
_subtract
:
function
(
pos1
,
pos2
){
return
{
x
:
pos1
.
x
-
pos2
.
x
,
y
:
pos1
.
y
-
pos2
.
y
,
z
:
pos1
.
z
-
pos2
.
z
};
},
_add
:
function
(
pos1
,
pos2
){
return
{
x
:
pos1
.
x
+
pos2
.
x
,
y
:
pos1
.
y
+
pos2
.
y
,
z
:
pos1
.
z
+
pos2
.
z
};
},
removeCell
:
function
(
object
){
var
cells
=
this
.
get
(
"
cells
"
);
var
cell
=
object
.
parent
.
myCell
;
...
...
@@ -48,9 +161,9 @@ Lattice = Backbone.Model.extend({
clearCells
:
function
(){
_
.
each
(
this
.
get
(
"
cells
"
),
function
(
cell
){
cell
.
remove
();
if
(
cell
.
remove
)
cell
.
remove
();
});
this
.
set
(
"
cells
"
,
[]
);
this
.
set
(
"
cells
"
,
this
.
defaults
.
cells
);
this
.
set
(
"
numCells
"
,
0
);
window
.
three
.
render
();
},
...
...
@@ -58,7 +171,7 @@ Lattice = Backbone.Model.extend({
_cellModeDidChange
:
function
(){
var
mode
=
this
.
get
(
"
cellMode
"
);
_
.
each
(
this
.
get
(
"
cells
"
),
function
(
cell
){
cell
.
drawForMode
(
mode
);
if
(
cell
.
drawForMode
)
cell
.
drawForMode
(
mode
);
});
window
.
three
.
render
();
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment