Browse Source

changed movement parameter to only say stabilized if the support nodes are stabilized as well, though retaining the demand that both nodes and support nodes are stabilized before emitting event and stopping simulation.

v3_develop
Alex de Mulder 10 years ago
parent
commit
66c788b9b4
4 changed files with 54 additions and 29 deletions
  1. +26
    -14
      dist/vis.js
  2. +2
    -1
      examples/network/02_random_nodes.html
  3. +16
    -8
      lib/network/Network.js
  4. +10
    -6
      lib/network/mixins/SectorsMixin.js

+ 26
- 14
dist/vis.js View File

@ -22605,7 +22605,7 @@ return /******/ (function(modules) { // webpackBootstrap
* *
* @private * @private
*/ */
Network.prototype._discreteStepNodes = function(checkMovement) {
Network.prototype._discreteStepNodes = function() {
var interval = this.physicsDiscreteStepsize; var interval = this.physicsDiscreteStepsize;
var nodes = this.nodes; var nodes = this.nodes;
var nodeId; var nodeId;
@ -22628,16 +22628,16 @@ return /******/ (function(modules) { // webpackBootstrap
} }
} }
if (nodesPresent == true && (checkMovement === undefined || checkMovement == true)) {
if (nodesPresent == true) {
var vminCorrected = this.constants.minVelocity / Math.max(this.scale,0.05); var vminCorrected = this.constants.minVelocity / Math.max(this.scale,0.05);
if (vminCorrected > 0.5*this.constants.maxVelocity) { if (vminCorrected > 0.5*this.constants.maxVelocity) {
this.moving = true;
return true;
} }
else { else {
this.moving = this._isMoving(vminCorrected);
this.moving = this.moving || this.configurePhysics;
return this._isMoving(vminCorrected);
} }
} }
return false;
}; };
/** /**
@ -22648,13 +22648,21 @@ return /******/ (function(modules) { // webpackBootstrap
Network.prototype._physicsTick = function() { Network.prototype._physicsTick = function() {
if (!this.freezeSimulation) { if (!this.freezeSimulation) {
if (this.moving == true) { if (this.moving == true) {
var mainMovingStatus = false;
var supportMovingStatus = false;
this._doInAllActiveSectors("_initializeForceCalculation"); this._doInAllActiveSectors("_initializeForceCalculation");
this._doInAllActiveSectors("_discreteStepNodes");
var mainMoving = this._doInAllActiveSectors("_discreteStepNodes");
if (this.constants.smoothCurves.enabled == true && this.constants.smoothCurves.dynamic == true) { if (this.constants.smoothCurves.enabled == true && this.constants.smoothCurves.dynamic == true) {
this._doInSupportSector("_discreteStepNodes", false);
supportMovingStatus = this._doInSupportSector("_discreteStepNodes");
} }
// gather movement data from all sectors, if one moves, we are NOT stabilzied
for (var i = 0; i < mainMoving.length; i++) {mainMovingStatus = mainMoving[0] || mainMovingStatus;}
this.stabilizationIterations++;
// determine if the network has stabilzied
this.moving = mainMovingStatus || supportMovingStatus;
this.stabilizationIterations++;
} }
} }
}; };
@ -29293,12 +29301,13 @@ return /******/ (function(modules) { // webpackBootstrap
* @private * @private
*/ */
exports._doInAllActiveSectors = function(runFunction,argument) { exports._doInAllActiveSectors = function(runFunction,argument) {
var returnValues = [];
if (argument === undefined) { if (argument === undefined) {
for (var sector in this.sectors["active"]) { for (var sector in this.sectors["active"]) {
if (this.sectors["active"].hasOwnProperty(sector)) { if (this.sectors["active"].hasOwnProperty(sector)) {
// switch the global references to those of this sector // switch the global references to those of this sector
this._switchToActiveSector(sector); this._switchToActiveSector(sector);
this[runFunction]();
returnValues.push( this[runFunction]() );
} }
} }
} }
@ -29309,16 +29318,17 @@ return /******/ (function(modules) { // webpackBootstrap
this._switchToActiveSector(sector); this._switchToActiveSector(sector);
var args = Array.prototype.splice.call(arguments, 1); var args = Array.prototype.splice.call(arguments, 1);
if (args.length > 1) { if (args.length > 1) {
this[runFunction](args[0],args[1]);
returnValues.push( this[runFunction](args[0],args[1]) );
} }
else { else {
this[runFunction](argument);
returnValues.push( this[runFunction](argument) );
} }
} }
} }
} }
// we revert the global references back to our active sector // we revert the global references back to our active sector
this._loadLatestSector(); this._loadLatestSector();
return returnValues;
}; };
@ -29332,22 +29342,24 @@ return /******/ (function(modules) { // webpackBootstrap
* @private * @private
*/ */
exports._doInSupportSector = function(runFunction,argument) { exports._doInSupportSector = function(runFunction,argument) {
var returnValues = false;
if (argument === undefined) { if (argument === undefined) {
this._switchToSupportSector(); this._switchToSupportSector();
this[runFunction]();
returnValues = this[runFunction]();
} }
else { else {
this._switchToSupportSector(); this._switchToSupportSector();
var args = Array.prototype.splice.call(arguments, 1); var args = Array.prototype.splice.call(arguments, 1);
if (args.length > 1) { if (args.length > 1) {
this[runFunction](args[0],args[1]);
returnValues = this[runFunction](args[0],args[1]);
} }
else { else {
this[runFunction](argument);
returnValues = this[runFunction](argument);
} }
} }
// we revert the global references back to our active sector // we revert the global references back to our active sector
this._loadLatestSector(); this._loadLatestSector();
return returnValues;
}; };

+ 2
- 1
examples/network/02_random_nodes.html View File

@ -88,7 +88,7 @@
document.getElementById('selection').innerHTML = 'Selection: ' + params.nodes; document.getElementById('selection').innerHTML = 'Selection: ' + params.nodes;
}); });
network.on('stabilized', function (params) { network.on('stabilized', function (params) {
console.log('stabilized after ' + params.iterations + ' iterations');
document.getElementById('stabilization').innerHTML = 'Stabilization took ' + params.iterations + ' iterations.';
}); });
} }
</script> </script>
@ -106,5 +106,6 @@
<div id="mynetwork"></div> <div id="mynetwork"></div>
<p id="selection"></p> <p id="selection"></p>
<p id="stabilization"></p>
</body> </body>
</html> </html>

+ 16
- 8
lib/network/Network.js View File

@ -1947,7 +1947,7 @@ Network.prototype._isMoving = function(vmin) {
* *
* @private * @private
*/ */
Network.prototype._discreteStepNodes = function(checkMovement) {
Network.prototype._discreteStepNodes = function() {
var interval = this.physicsDiscreteStepsize; var interval = this.physicsDiscreteStepsize;
var nodes = this.nodes; var nodes = this.nodes;
var nodeId; var nodeId;
@ -1970,16 +1970,16 @@ Network.prototype._discreteStepNodes = function(checkMovement) {
} }
} }
if (nodesPresent == true && (checkMovement === undefined || checkMovement == true)) {
if (nodesPresent == true) {
var vminCorrected = this.constants.minVelocity / Math.max(this.scale,0.05); var vminCorrected = this.constants.minVelocity / Math.max(this.scale,0.05);
if (vminCorrected > 0.5*this.constants.maxVelocity) { if (vminCorrected > 0.5*this.constants.maxVelocity) {
this.moving = true;
return true;
} }
else { else {
this.moving = this._isMoving(vminCorrected);
this.moving = this.moving || this.configurePhysics;
return this._isMoving(vminCorrected);
} }
} }
return false;
}; };
/** /**
@ -1990,13 +1990,21 @@ Network.prototype._discreteStepNodes = function(checkMovement) {
Network.prototype._physicsTick = function() { Network.prototype._physicsTick = function() {
if (!this.freezeSimulation) { if (!this.freezeSimulation) {
if (this.moving == true) { if (this.moving == true) {
var mainMovingStatus = false;
var supportMovingStatus = false;
this._doInAllActiveSectors("_initializeForceCalculation"); this._doInAllActiveSectors("_initializeForceCalculation");
this._doInAllActiveSectors("_discreteStepNodes");
var mainMoving = this._doInAllActiveSectors("_discreteStepNodes");
if (this.constants.smoothCurves.enabled == true && this.constants.smoothCurves.dynamic == true) { if (this.constants.smoothCurves.enabled == true && this.constants.smoothCurves.dynamic == true) {
this._doInSupportSector("_discreteStepNodes", false);
supportMovingStatus = this._doInSupportSector("_discreteStepNodes");
} }
// gather movement data from all sectors, if one moves, we are NOT stabilzied
for (var i = 0; i < mainMoving.length; i++) {mainMovingStatus = mainMoving[0] || mainMovingStatus;}
// determine if the network has stabilzied
this.moving = mainMovingStatus || supportMovingStatus;
this.stabilizationIterations++;
this.stabilizationIterations++;
} }
} }
}; };

+ 10
- 6
lib/network/mixins/SectorsMixin.js View File

@ -365,12 +365,13 @@ exports._collapseSector = function() {
* @private * @private
*/ */
exports._doInAllActiveSectors = function(runFunction,argument) { exports._doInAllActiveSectors = function(runFunction,argument) {
var returnValues = [];
if (argument === undefined) { if (argument === undefined) {
for (var sector in this.sectors["active"]) { for (var sector in this.sectors["active"]) {
if (this.sectors["active"].hasOwnProperty(sector)) { if (this.sectors["active"].hasOwnProperty(sector)) {
// switch the global references to those of this sector // switch the global references to those of this sector
this._switchToActiveSector(sector); this._switchToActiveSector(sector);
this[runFunction]();
returnValues.push( this[runFunction]() );
} }
} }
} }
@ -381,16 +382,17 @@ exports._doInAllActiveSectors = function(runFunction,argument) {
this._switchToActiveSector(sector); this._switchToActiveSector(sector);
var args = Array.prototype.splice.call(arguments, 1); var args = Array.prototype.splice.call(arguments, 1);
if (args.length > 1) { if (args.length > 1) {
this[runFunction](args[0],args[1]);
returnValues.push( this[runFunction](args[0],args[1]) );
} }
else { else {
this[runFunction](argument);
returnValues.push( this[runFunction](argument) );
} }
} }
} }
} }
// we revert the global references back to our active sector // we revert the global references back to our active sector
this._loadLatestSector(); this._loadLatestSector();
return returnValues;
}; };
@ -404,22 +406,24 @@ exports._doInAllActiveSectors = function(runFunction,argument) {
* @private * @private
*/ */
exports._doInSupportSector = function(runFunction,argument) { exports._doInSupportSector = function(runFunction,argument) {
var returnValues = false;
if (argument === undefined) { if (argument === undefined) {
this._switchToSupportSector(); this._switchToSupportSector();
this[runFunction]();
returnValues = this[runFunction]();
} }
else { else {
this._switchToSupportSector(); this._switchToSupportSector();
var args = Array.prototype.splice.call(arguments, 1); var args = Array.prototype.splice.call(arguments, 1);
if (args.length > 1) { if (args.length > 1) {
this[runFunction](args[0],args[1]);
returnValues = this[runFunction](args[0],args[1]);
} }
else { else {
this[runFunction](argument);
returnValues = this[runFunction](argument);
} }
} }
// we revert the global references back to our active sector // we revert the global references back to our active sector
this._loadLatestSector(); this._loadLatestSector();
return returnValues;
}; };

Loading…
Cancel
Save