Test ContourModelElement performance
| 78 | |
| 79 | // Test ContourModelElement performance |
| 80 | static bool TestANN() |
| 81 | { |
| 82 | int64 startJob, stopJob, durationJob; |
| 83 | |
| 84 | int maxNumberPts = 1000; |
| 85 | |
| 86 | // worst case query |
| 87 | mitk::Point3D query; |
| 88 | query[0] = query[1] = query[2] = -100; |
| 89 | |
| 90 | /*+++++++++++++++++++++++++++++ BruteForce +++++++++++++++++++++++++++++++++++++++++*/ |
| 91 | std::string fileName = std::string(MITK_TEST_OUTPUT_DIR) + "/Bruteforce-test.csv"; |
| 92 | |
| 93 | std::ofstream out(fileName.c_str()); |
| 94 | if (!out.good()) |
| 95 | { |
| 96 | out.close(); |
| 97 | return false; |
| 98 | } |
| 99 | |
| 100 | std::locale previousLocale(out.getloc()); |
| 101 | std::locale I("C"); |
| 102 | out.imbue(I); |
| 103 | |
| 104 | mitk::ContourModelElement::Pointer contour = mitk::ContourModelElement::New(); |
| 105 | |
| 106 | for (int step = 0; step < 1000; step++) |
| 107 | { |
| 108 | for (int i = 0; i < 10; i++) |
| 109 | { |
| 110 | startJob = GetTimeMs64(); |
| 111 | mitk::ContourModelElement::VertexType *v = contour->BruteForceGetVertexAt(query, 0.001); |
| 112 | stopJob = GetTimeMs64(); |
| 113 | durationJob = (stopJob - startJob); |
| 114 | out << durationJob << ";"; |
| 115 | } |
| 116 | mitk::Point3D p; |
| 117 | p[0] = p[1] = p[2] = 1; |
| 118 | contour->AddVertex(p, false); |
| 119 | |
| 120 | out << std::endl; |
| 121 | } |
| 122 | out.close(); |
| 123 | out.imbue(previousLocale); |
| 124 | /*+++++++++++++++++++++++++++++ END BruteForce +++++++++++++++++++++++++++++++++++++++++*/ |
| 125 | |
| 126 | /*+++++++++++++++++++++++++++++ ANN +++++++++++++++++++++++++++++++++++++++++*/ |
| 127 | std::string fileName2 = std::string(MITK_TEST_OUTPUT_DIR) + "/ANN-test.csv"; |
| 128 | |
| 129 | std::ofstream out2(fileName2.c_str()); |
| 130 | if (!out2.good()) |
| 131 | { |
| 132 | out2.close(); |
| 133 | return false; |
| 134 | } |
| 135 | |
| 136 | std::locale previousLocale2(out2.getloc()); |
| 137 | std::locale I2("C"); |
no test coverage detected