- Timestamp:
- 03/05/14 21:58:51 (11 years ago)
- Location:
- js/viewer-f0/js
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
js/viewer-f0/js/NeuronDrawer.js
r143 r161 8 8 this._controls = undefined; 9 9 this._showAxis = false; 10 this._unknown_symbol=[1,4, 25,25, 75,25, 75,75, 25,75, 25,25]; 11 this._neuron_symbol=[1,4, 75,50, 25,0, 25,99, 75,50, 100,50]; 12 this._inputonly_symbol=[1,5, 25,40, 35,40, 45,50, 35,60, 25,60, 25,40]; 13 this._outputonly_symbol=[1,7, 75,50, 75,60, 55,60, 65,50, 55,40, 75,40, 75,50, 100,50]; 14 10 15 } 11 16 … … 23 28 24 29 NeuronDrawer.prototype._prepareCamera = function () { 25 this._camera = new THREE.PerspectiveCamera(45, this._canvasWidth / this._canvasHeight, 1, 4000);30 this._camera = new THREE.PerspectiveCamera(45, this._canvasWidth / this._canvasHeight, 1, 10000); 26 31 this._camera.position.set(0, 0, 10); 27 32 this._camera.lookAt(this._scene.position); … … 60 65 } 61 66 62 NeuronDrawer.prototype._debug = function() 63 { 64 this._scene.add( new THREE.AxisHelper( 20 ) ); 65 } 66 67 NeuronDrawer.prototype.drawNeuron = function(x, y){ 68 var scheme = [4,4,26,27,26,73,73,73,73,27,26,27,1,73,50,100,50,1,56,68,46,68,2,41,47,51,32,51,68]; 69 //pobieranie schematu 70 //inne określenie położeń 67 NeuronDrawer.prototype._debug = function () { 68 this._scene.add(new THREE.AxisHelper(20)); 69 } 70 71 NeuronDrawer.prototype.drawNeuron = function (x, y, scheme) { 71 72 72 73 … … 80 81 var noOfLines = 0;//number of line to draw 81 82 noOfBlocks = scheme[position++]; 82 for (var i = 0; i < noOfBlocks; i++) 83 { 83 for (var i = 0; i < noOfBlocks; i++) { 84 84 noOfLines = scheme[position++]; 85 85 86 for (var j = 0; j < noOfLines; j++) 87 { 86 for (var j = 0; j < noOfLines; j++) { 88 87 var geometry = new THREE.Geometry(); 89 88 geometry.vertices.push(new THREE.Vector3(scheme[position++] + x, scheme[position++] + y, 0)); … … 98 97 var SCALE = 0.05; 99 98 100 obj.scale.set(SCALE, SCALE, SCALE);99 obj.scale.set(SCALE, SCALE, SCALE); 101 100 obj.rotateX(Math.PI);//rotate 180 degree 102 obj.translateY(-5.5);101 //obj.translateY(-5.5); 103 102 this._scene.add(obj) 104 105 } 106 107 108 109 NeuronDrawer.prototype.drawConnection = function(id, connections, einfos){ 103 } 104 105 NeuronDrawer.prototype._getNumberOfInputs = function(number, connections){ 106 107 var counter = 0; 108 109 for(var i = 0; i < connections.length; i++){ 110 if(connections[i].getDestination() == number) 111 counter++; 112 } 113 114 return counter; 115 } 116 117 NeuronDrawer.prototype._getNumberOfOutputs = function(number, connections){ 118 var counter = 0; 119 120 for(var i = 0; i < connections.length; i++){ 121 if(connections[i].getSource() == number) 122 counter++; 123 } 124 125 return counter; 126 } 127 128 NeuronDrawer.prototype.drawConnection = function (id, connections, einfos) { 110 129 111 130 var destination = connections[id].getDestination(); … … 114 133 115 134 //check how many conenctions have the same destination 116 for (var i = 0; i < connections.length; i++){117 if (connections[i].getDestination() == destination)135 for (var i = 0; i < connections.length; i++) { 136 if (connections[i].getDestination() == destination) 118 137 numberOfConnToDest++; 119 138 } 120 139 121 140 //check how many connections had been drawen 122 for (var i = 0; i < id; i++){123 if (connections[i].getDestination() == destination)141 for (var i = 0; i < id; i++) { 142 if (connections[i].getDestination() == destination) 124 143 numberOfDrawenCon++; 125 144 } … … 142 161 var geometry = new THREE.Geometry(); 143 162 geometry.vertices.push(new THREE.Vector3(100 + x2 * 100, 10 + 50 + y2 * 100, 0)); 144 geometry.vertices.push(new THREE.Vector3(10 + 100 + x2 * 100 163 geometry.vertices.push(new THREE.Vector3(10 + 100 + x2 * 100, 10 + 50 + y2 * 100, 0)); 145 164 var line = new THREE.Line(geometry, material); 146 165 line.scale.set(SCALE, SCALE, SCALE); 147 166 this._scene.add(line); 167 148 168 149 169 var geometry1 = new THREE.Geometry(); … … 168 188 169 189 //pierwszy pionowy 170 if (y1 >= y2) 171 { 190 if (y1 >= y2) { 172 191 var geometry = new THREE.Geometry(); 173 192 geometry.vertices.push(new THREE.Vector3(110 + (x2 * 100), 60 + y2 * 100, 0)); … … 179 198 } 180 199 181 else 182 { 200 else { 183 201 var geometry = new THREE.Geometry(); 184 202 geometry.vertices.push(new THREE.Vector3(110 + (x2 * 100), 60 + y2 * 100, 0)); … … 192 210 193 211 //poziomy 194 if (y1 >= y2) 195 { 212 if (y1 >= y2) { 196 213 var geometry = new THREE.Geometry(); 197 214 geometry.vertices.push(new THREE.Vector3(110 + (x2 * 100), 105 + y2 * 100, 0)); … … 203 220 //g.drawLine((int) ((110 + (x2 * 100)) * zoom), (int) ((105 + y2 * 100) * zoom), (int) ((10 + polozenieX + (x1 * 100)) * zoom), (int) ((105 + y2 * 100) * zoom)); 204 221 } 205 206 else 207 { 222 else { 208 223 var geometry = new THREE.Geometry(); 209 224 geometry.vertices.push(new THREE.Vector3(110 + (x2 * 100), 15 + y2 * 100, 0)); … … 218 233 219 234 //drugi pionowy 220 if (y1 >= y2) 221 { 235 if (y1 >= y2) { 222 236 var geometry = new THREE.Geometry(); 223 237 geometry.vertices.push(new THREE.Vector3(10 + positionX + (x1 * 100), 10 + positionY + y1 * 100, 0)); … … 229 243 //g.drawLine((int) ((10 + polozenieX + (x1 * 100)) * zoom), (int) ((10 + polozenieY + y1 * 100) * zoom), (int) ((10 + polozenieX + (x1 * 100)) * zoom), (int) ((105 + y2 * 100) * zoom)); 230 244 } 231 else 232 { 245 else { 233 246 var geometry = new THREE.Geometry(); 234 247 geometry.vertices.push(new THREE.Vector3(10 + positionX + (x1 * 100), 10 + positionY + y1 * 100, 0)); … … 243 256 } 244 257 245 NeuronDrawer.prototype.drawNetwork = function(neurons, connections, layouts){ 246 247 for(var i = 0; i < layouts.length; i++){ 248 this.drawNeuron(layouts[i].x * 100, -layouts[i].y * 100); 249 } 250 251 for(var i = 0; i < connections.length; i++) 252 this.drawConnection(i, connections, einfos); 253 } 254 255 NeuronDrawer.prototype.debugTest = function() 258 259 NeuronDrawer.prototype._chooseSchema = function(number, neurons, connections, classes) 256 260 { 257 258 } 259 261 var schema = this._unknown_symbol; 262 var type = neurons[number].getSchemeID(); 263 264 if(type != undefined) 265 { 266 if(classes[type].getScheme().length != 0) 267 { 268 if(this._getNumberOfInputs(number, connections) == 0) 269 schema = this._outputonly_symbol; 270 else if (this._getNumberOfOutputs(number, connections) == 0) 271 schema = this._inputonly_symbol; 272 else 273 schema = this._neuron_symbol; 274 } 275 } 276 277 return schema; 278 } 279 280 NeuronDrawer.prototype.drawNetwork = function (neurons, connections, layouts, classes) { 281 282 for (var i = 0; i < layouts.length; i++) { 283 var scheme = undefined; 284 285 scheme = this._chooseSchema(i,neurons, connections, classes) 286 287 this.drawNeuron(layouts[i].x * 100 , -layouts[i].y * 100 , scheme); 288 } 289 290 //for (var i = 0; i < connections.length; i++) 291 // this.drawConnection(i, connections, einfos); 292 } 293 294 295 NeuronDrawer.prototype.debugTest = function () { 296 297 } 298 -
js/viewer-f0/js/Structures/Neuro.js
r143 r161 5 5 6 6 Neuro.prototype = new Model(); 7 8 Neuro.prototype.getSchemeID = function(){ 9 var type = this._properties["d"]["VALUE"]; 10 type = type.replace("\"",""); 11 var index = type.indexOf(":"); 12 if(index != -1) 13 type = type.substr(0, index); 14 15 return type; 16 }
Note: See TracChangeset
for help on using the changeset viewer.