MCPcopy Create free account
hub / github.com/Kitware/VTK / SimulateEdgeStep

Method SimulateEdgeStep

Infovis/BoostGraphAlgorithms/vtkBoostDividedEdgeBundling.cxx:366–489  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

364}
365
366void vtkBundlingMetadata::SimulateEdgeStep()
367{
368 vtkIdType numEdges = this->Graph->GetNumberOfEdges();
369
370 for (vtkIdType e1 = 0; e1 < numEdges; ++e1)
371 {
372 float weight1 = 1.0f;
373 for (int m1 = 0; m1 < this->MeshCount; ++m1)
374 {
375 // Immovable
376 if (m1 <= 0 || m1 >= this->MeshCount - 1)
377 {
378 continue;
379 }
380
381 // Move the point according to dynamics
382 vtkVector3f position = this->EdgeMesh[e1][m1];
383 vtkVector3f velocity = this->EdgeMeshVelocities[e1][m1];
384 vtkVector3f acceleration = this->EdgeMeshAccelerations[e1][m1];
385 velocity = velocity + acceleration * this->SimulationStep * 0.5f;
386 velocity = velocity * this->VelocityDamping;
387 position = position + velocity * this->SimulationStep;
388 this->EdgeMesh[e1][m1] = position;
389
390 acceleration = vtkVector3f(0.0f, 0.0f, 0.0f);
391
392 // Spring force
393 vtkVector3f prevPosition = this->EdgeMesh[e1][m1 - 1];
394 vtkVector3f prevDirection = prevPosition - position;
395 float prevDist = prevDirection.Norm();
396 float prevForce =
397 this->EdgeSpringConstant / 1000.0f * (this->MeshCount - 1) * prevDist * weight1;
398 prevDirection.Normalize();
399 acceleration = acceleration + prevForce * prevDirection;
400
401 vtkVector3f nextPosition = this->EdgeMesh[e1][m1 + 1];
402 vtkVector3f nextDirection = nextPosition - position;
403 float nextDist = nextDirection.Norm();
404 float nextForce =
405 this->EdgeSpringConstant / 1000.0f * (this->MeshCount - 1) * nextDist * weight1;
406 nextDirection.Normalize();
407 acceleration = acceleration + nextForce * nextDirection;
408
409 // Coulomb force
410 float normalizedEdgeCoulombConstant =
411 this->EdgeCoulombConstant / sqrt(static_cast<float>(numEdges));
412
413 for (vtkIdType e2 = 0; e2 < numEdges; ++e2)
414 {
415 if (e1 == e2)
416 {
417 continue;
418 }
419
420 float compatibility = this->EdgeCompatibilities[e1][e2];
421 if (compatibility <= 0.05)
422 {
423 continue;

Callers 1

LayoutEdgePointsMethod · 0.95

Calls 6

NormMethod · 0.80
vtkVector3fClass · 0.50
sqrtFunction · 0.50
powFunction · 0.50
GetNumberOfEdgesMethod · 0.45
NormalizeMethod · 0.45

Tested by

no test coverage detected