| 1001 | //------------------------------------------------------------------------------ |
| 1002 | template <typename T> |
| 1003 | void CellTree<T>::Classify(const double origin[3], const double dir[3], double& rDist, |
| 1004 | TCellTreeNode*& nearNode, TCellTreeNode*& parent, TCellTreeNode*& farNode, int& mustCheck) |
| 1005 | { |
| 1006 | double tOriginToDivPlane = parent->GetLeftMaxValue() - origin[parent->GetDimension()]; |
| 1007 | double tOriginToDivPlane2 = parent->GetRightMinValue() - origin[parent->GetDimension()]; |
| 1008 | double tDivDirection = dir[parent->GetDimension()]; |
| 1009 | if (tOriginToDivPlane2 > 0) // origin is right of the rmin |
| 1010 | { |
| 1011 | nearNode = &this->Nodes.at(parent->GetLeftChildIndex()); |
| 1012 | farNode = &this->Nodes.at(parent->GetLeftChildIndex() + 1); |
| 1013 | rDist = (tDivDirection) ? tOriginToDivPlane2 / tDivDirection : VTK_DOUBLE_MAX; |
| 1014 | } |
| 1015 | else if (tOriginToDivPlane < 0) // origin is left of the lm |
| 1016 | { |
| 1017 | farNode = &this->Nodes.at(parent->GetLeftChildIndex()); |
| 1018 | nearNode = &this->Nodes.at(parent->GetLeftChildIndex() + 1); |
| 1019 | rDist = (tDivDirection) ? tOriginToDivPlane / tDivDirection : VTK_DOUBLE_MAX; |
| 1020 | } |
| 1021 | else |
| 1022 | { |
| 1023 | if (tOriginToDivPlane > 0 && tOriginToDivPlane2 < 0) |
| 1024 | { |
| 1025 | mustCheck = 1; // The point is within right min and left max. both left and right subtrees |
| 1026 | // must be checked |
| 1027 | } |
| 1028 | |
| 1029 | if (tDivDirection < 0) |
| 1030 | { |
| 1031 | nearNode = &this->Nodes.at(parent->GetLeftChildIndex()); |
| 1032 | farNode = &this->Nodes.at(parent->GetLeftChildIndex() + 1); |
| 1033 | if (!(tOriginToDivPlane > 0 || tOriginToDivPlane < 0)) |
| 1034 | { |
| 1035 | mustCheck = 1; // Ray was exactly on edge left max box. |
| 1036 | } |
| 1037 | rDist = (tDivDirection) ? 0 / tDivDirection : VTK_DOUBLE_MAX; |
| 1038 | } |
| 1039 | else |
| 1040 | { |
| 1041 | farNode = &this->Nodes.at(parent->GetLeftChildIndex()); |
| 1042 | nearNode = &this->Nodes.at(parent->GetLeftChildIndex() + 1); |
| 1043 | if (!(tOriginToDivPlane2 > 0 || tOriginToDivPlane2 < 0)) |
| 1044 | { |
| 1045 | mustCheck = 1; // Ray was exactly on edge right min box. |
| 1046 | } |
| 1047 | rDist = (tDivDirection) ? 0 / tDivDirection : VTK_DOUBLE_MAX; |
| 1048 | } |
| 1049 | } |
| 1050 | } |
| 1051 | |
| 1052 | //------------------------------------------------------------------------------ |
| 1053 | template <typename T> |