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

Method BuildCurvedLeader

Rendering/Annotation/vtkLeaderActor2D.cxx:476–597  ·  view source on GitHub ↗

------------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

474
475//------------------------------------------------------------------------------
476void vtkLeaderActor2D::BuildCurvedLeader(double p1[3], double p2[3], double ray[3],
477 double rayLength, double theta, vtkViewport* viewport, int viewportChanged)
478{
479 // Determine where the center is
480 double radius = fabs(this->Radius) * rayLength;
481 double midPoint[3], center[3];
482 int i;
483 midPoint[0] = p1[0] + 0.5 * ray[0];
484 midPoint[1] = p1[1] + 0.5 * ray[1];
485 midPoint[2] = p1[2] + 0.5 * ray[2];
486 double d = sqrt(radius * radius - rayLength * rayLength / 4.0);
487 if (this->Radius > 0)
488 {
489 center[0] = midPoint[0] + d * sin(theta);
490 center[1] = midPoint[1] - d * cos(theta);
491 center[2] = 0.0;
492 }
493 else
494 {
495 center[0] = midPoint[0] - d * sin(theta);
496 center[1] = midPoint[1] + d * cos(theta);
497 center[2] = 0.0;
498 }
499
500 // Compute some angles; make sure they are <= 180 degrees
501 double phi = atan2(rayLength / 2.0, d);
502 double theta1 = atan2(p1[1] - center[1], p1[0] - center[0]);
503 double theta2 = atan2(p2[1] - center[1], p2[0] - center[0]);
504 if ((theta1 >= 0.0 && theta1 <= vtkMath::Pi() && theta2 >= 0.0 && theta2 <= vtkMath::Pi()) ||
505 (theta1 <= 0.0 && theta1 >= -vtkMath::Pi() && theta2 <= 0.0 && theta2 >= -vtkMath::Pi()))
506 {
507 // do nothing angles are fine
508 }
509 else if (theta1 >= 0.0 && theta2 <= 0.0)
510 {
511 if ((theta1 - theta2) >= vtkMath::Pi())
512 {
513 theta2 = theta2 + 2.0 * vtkMath::Pi();
514 }
515 }
516 else // if ( theta1 <= 0.0 && theta2 >= 0.0 )
517 {
518 if ((theta2 - theta1) >= vtkMath::Pi())
519 {
520 theta1 = theta1 + 2.0 * vtkMath::Pi();
521 }
522 }
523
524 // Build the polyline for the leader. Start by generating the points.
525 double x[3];
526 x[2] = 0.0;
527 double length = radius * phi;
528 int numDivs = static_cast<int>((length / 3.0) + 1); // every three pixels
529 for (i = 0; i <= numDivs; i++)
530 {
531 theta = theta1 + (static_cast<double>(i) / numDivs) * (theta2 - theta1);
532 x[0] = center[0] + radius * cos(theta);
533 x[1] = center[1] + radius * sin(theta);

Callers 1

BuildLeaderMethod · 0.95

Calls 15

SetFontSizeMethod · 0.95
InStringBoxMethod · 0.95
PiFunction · 0.85
to_std_formatFunction · 0.85
InsertCellPointMethod · 0.80
sqrtFunction · 0.50
sinFunction · 0.50
cosFunction · 0.50
format_to_nFunction · 0.50
InsertPointMethod · 0.45
SetInputMethod · 0.45
GetMTimeMethod · 0.45

Tested by

no test coverage detected