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

Method Distance2ToBounds

Common/DataModel/vtkPointLocator.cxx:1648–1697  ·  view source on GitHub ↗

------------------------------------------------------------------------------ Calculate the distance between the point x and the specified bounds WARNING!!!!! Be very careful altering this routine. Simple changes to this routine can make is 25% slower!!!!

Source from the content-addressed store, hash-verified

1646// WARNING!!!!! Be very careful altering this routine. Simple changes to this
1647// routine can make is 25% slower!!!!
1648double vtkPointLocator::Distance2ToBounds(const double x[3], const double bounds[6])
1649{
1650 double distance;
1651 double deltas[3];
1652
1653 // Are we within the bounds?
1654 if (x[0] >= bounds[0] && x[0] <= bounds[1] && x[1] >= bounds[2] && x[1] <= bounds[3] &&
1655 x[2] >= bounds[4] && x[2] <= bounds[5])
1656 {
1657 return 0.0;
1658 }
1659
1660 deltas[0] = deltas[1] = deltas[2] = 0.0;
1661
1662 // dx
1663 //
1664 if (x[0] < bounds[0])
1665 {
1666 deltas[0] = bounds[0] - x[0];
1667 }
1668 else if (x[0] > bounds[1])
1669 {
1670 deltas[0] = x[0] - bounds[1];
1671 }
1672
1673 // dy
1674 //
1675 if (x[1] < bounds[2])
1676 {
1677 deltas[1] = bounds[2] - x[1];
1678 }
1679 else if (x[1] > bounds[3])
1680 {
1681 deltas[1] = x[1] - bounds[3];
1682 }
1683
1684 // dz
1685 //
1686 if (x[2] < bounds[4])
1687 {
1688 deltas[2] = bounds[4] - x[2];
1689 }
1690 else if (x[2] > bounds[5])
1691 {
1692 deltas[2] = x[2] - bounds[5];
1693 }
1694
1695 distance = vtkMath::Dot(deltas, deltas);
1696 return distance;
1697}
1698
1699//------------------------------------------------------------------------------
1700void vtkPointLocator::PrintSelf(ostream& os, vtkIndent indent)

Callers 2

Distance2ToBucketMethod · 0.95

Calls 1

DotFunction · 0.70

Tested by

no test coverage detected