------------------------------------------------------------------------------
| 841 | |
| 842 | //------------------------------------------------------------------------------ |
| 843 | void vtkHyperTreeGridPlaneCutter::ReorderCutPoints(int n, double points[][3]) |
| 844 | { |
| 845 | // Iterate over all polygonal vertices but the last one |
| 846 | for (int i = 0; i < n - 2; ++i) |
| 847 | { |
| 848 | // Search the closest point to i in the sense of sharing the most coordinates |
| 849 | int index = i + 1; // in practice a don't care, set to satisfy -Wuninitialized |
| 850 | int minDistance = 4; |
| 851 | for (int j = i + 1; j < n; ++j) |
| 852 | { |
| 853 | // Compute the distance: number of different coordinates |
| 854 | int distance = 0; |
| 855 | if (!vtkMathUtilities::FuzzyCompare(points[j][0], points[i][0], ::SQRT_DBL_EPSILON)) |
| 856 | { |
| 857 | ++distance; |
| 858 | } |
| 859 | if (!vtkMathUtilities::FuzzyCompare(points[j][1], points[i][1], ::SQRT_DBL_EPSILON)) |
| 860 | { |
| 861 | ++distance; |
| 862 | } |
| 863 | if (!vtkMathUtilities::FuzzyCompare(points[j][2], points[i][2], ::SQRT_DBL_EPSILON)) |
| 864 | { |
| 865 | ++distance; |
| 866 | } |
| 867 | if (distance < minDistance) |
| 868 | { |
| 869 | // Store the index of current point and update minDistance |
| 870 | index = j; |
| 871 | minDistance = distance; |
| 872 | } |
| 873 | } |
| 874 | if (index != i + 1) |
| 875 | { |
| 876 | // If the closest point is not i + 1, then swap point positions |
| 877 | double swap[3]; |
| 878 | memcpy(swap, points[index], 3 * sizeof(double)); |
| 879 | memcpy(points[index], points[i + 1], 3 * sizeof(double)); |
| 880 | memcpy(points[i + 1], swap, 3 * sizeof(double)); |
| 881 | } |
| 882 | } |
| 883 | } |
| 884 | VTK_ABI_NAMESPACE_END |
no test coverage detected