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

Method FindBoundaryEdge

Rendering/Annotation/vtkCubeAxesActor.cxx:2384–2502  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

2382
2383//------------------------------------------------------------------------------
2384void vtkCubeAxesActor::FindBoundaryEdge(int& xloc, int& yloc, int& zloc, double pts[8][3])
2385{
2386 // boundary edges fly mode
2387 xloc = yloc = zloc = 1;
2388 int i, xIdx = 0, yIdx = 0, zIdx = 0, zIdx2 = 0;
2389 int xAxes = 0, yAxes = 0, zAxes = 0;
2390 double slope = 0.0, minSlope, num, den, d2;
2391 double e1[3], e2[3], e3[3];
2392 int idx = 0;
2393
2394 // Find distance to origin
2395 double d2Min = VTK_FLOAT_MAX;
2396 for (i = 0; i < 8; i++)
2397 {
2398 d2 = pts[i][0] * pts[i][0] + pts[i][1] * pts[i][1];
2399 if (d2 < d2Min)
2400 {
2401 d2Min = d2;
2402 idx = i;
2403 }
2404 }
2405
2406 // find minimum slope point connected to closest point and on
2407 // right side (in projected coordinates). This is the first edge.
2408 minSlope = VTK_FLOAT_MAX;
2409 for (xIdx = 0, i = 0; i < 3; i++)
2410 {
2411 num = (pts[vtkCubeAxesActorConn[idx][i]][1] - pts[idx][1]);
2412 den = (pts[vtkCubeAxesActorConn[idx][i]][0] - pts[idx][0]);
2413 if (den != 0.0)
2414 {
2415 slope = num / den;
2416 }
2417 if (slope < minSlope && den > 0)
2418 {
2419 xIdx = vtkCubeAxesActorConn[idx][i];
2420 yIdx = vtkCubeAxesActorConn[idx][(i + 1) % 3];
2421 zIdx = vtkCubeAxesActorConn[idx][(i + 2) % 3];
2422 xAxes = i;
2423 minSlope = slope;
2424 }
2425 }
2426
2427 // find edge (connected to closest point) on opposite side
2428 for (i = 0; i < 3; i++)
2429 {
2430 e1[i] = (pts[xIdx][i] - pts[idx][i]);
2431 e2[i] = (pts[yIdx][i] - pts[idx][i]);
2432 e3[i] = (pts[zIdx][i] - pts[idx][i]);
2433 }
2434 vtkMath::Normalize(e1);
2435 vtkMath::Normalize(e2);
2436 vtkMath::Normalize(e3);
2437
2438 if (vtkMath::Dot(e1, e2) < vtkMath::Dot(e1, e3))
2439 {
2440 yAxes = (xAxes + 1) % 3;
2441 }

Callers 1

DetermineRenderAxesMethod · 0.95

Calls 2

NormalizeFunction · 0.50
DotFunction · 0.50

Tested by

no test coverage detected