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

Method IntersectWithPlane

Common/DataModel/vtkBox.cxx:590–621  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

588
589//------------------------------------------------------------------------------
590vtkTypeBool vtkBox::IntersectWithPlane(double bounds[6], double origin[3], double normal[3])
591{
592 // Evaluate the eight points. If there is a sign change, then there is an
593 // intersection.
594 double p[3], d;
595 int x, y, z, sign = 1, firstOne = 1;
596
597 for (z = 4; z <= 5; ++z)
598 {
599 p[2] = bounds[z];
600 for (y = 2; y <= 3; ++y)
601 {
602 p[1] = bounds[y];
603 for (x = 0; x <= 1; ++x)
604 {
605 p[0] = bounds[x];
606 d = vtkPlane::Evaluate(normal, origin, p);
607 if (firstOne)
608 {
609 sign = (d >= 0 ? 1 : -1);
610 firstOne = 0;
611 }
612 if (d == 0.0 || (sign > 0 && d < 0.0) || (sign < 0 && d > 0.0))
613 {
614 return 1;
615 }
616 } // x
617 } // y
618 } // z
619
620 return 0; // no intersection
621}
622
623//------------------------------------------------------------------------------
624// Support for IntersectWithPlane

Callers 1

Calls 9

PiFunction · 0.85
EvaluateFunction · 0.70
NormalizeFunction · 0.70
DotFunction · 0.70
CrossFunction · 0.50
sortFunction · 0.50
emplace_backMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected