diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 93a7bdbd5..c5516ef32 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -183,6 +183,15 @@ stages: - build/*.png - build/*.pnm - build/*.pmm + - build/*/*.png + - build/*/*.pnm + - build/*/*.pmm + - build/*/*/*.png + - build/*/*/*.pnm + - build/*/*/*.pmm + - build/*/*/*/*.png + - build/*/*/*/*.pnm + - build/*/*/*/*.pmm .cmake_memcheck_linux: &cmake_memcheck_linux stage: test diff --git a/data/baseline/contour-tangle.png b/data/baseline/filter/contour-tangle.png similarity index 100% rename from data/baseline/contour-tangle.png rename to data/baseline/filter/contour-tangle.png diff --git a/data/baseline/contour-uniform.png b/data/baseline/filter/contour-uniform.png similarity index 100% rename from data/baseline/contour-uniform.png rename to data/baseline/filter/contour-uniform.png diff --git a/data/baseline/contour-wedge.png b/data/baseline/filter/contour-wedge.png similarity index 100% rename from data/baseline/contour-wedge.png rename to data/baseline/filter/contour-wedge.png diff --git a/data/baseline/point-transform.png b/data/baseline/filter/point-transform.png similarity index 100% rename from data/baseline/point-transform.png rename to data/baseline/filter/point-transform.png diff --git a/data/baseline/split-sharp-edges.png b/data/baseline/filter/split-sharp-edges.png similarity index 100% rename from data/baseline/split-sharp-edges.png rename to data/baseline/filter/split-sharp-edges.png diff --git a/data/baseline/streamline.png b/data/baseline/filter/streamline.png similarity index 100% rename from data/baseline/streamline.png rename to data/baseline/filter/streamline.png diff --git a/data/baseline/surface-normals.png b/data/baseline/filter/surface-normals.png similarity index 100% rename from data/baseline/surface-normals.png rename to data/baseline/filter/surface-normals.png diff --git a/data/baseline/rendering/wireframer/wf_uniform3D.png b/data/baseline/rendering/wireframer/wf_uniform3D.png index 153672b1c..ab59beb95 100644 --- a/data/baseline/rendering/wireframer/wf_uniform3D.png +++ b/data/baseline/rendering/wireframer/wf_uniform3D.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:814e5d4df064deceb334cb9e3d9de707cb052ebf2fea7fd8e3dd3229cdc245e9 -size 48370 +oid sha256:8ba37986bfea23490f255ed7dcbe20d4cfdd695279969c7bcaa5fef844c4d0e7 +size 47960 diff --git a/vtkm/filter/ImageDifference.hxx b/vtkm/filter/ImageDifference.hxx index 74b579d63..9bec16deb 100644 --- a/vtkm/filter/ImageDifference.hxx +++ b/vtkm/filter/ImageDifference.hxx @@ -122,9 +122,9 @@ inline VTKM_CONT vtkm::cont::DataSet ImageDifference::DoExecute( "Difference within threshold: " << this->ImageDiffWithinThreshold << ", for pixels outside threshold: " << errorPixels.GetNumberOfValues() - << ", with total number of pixels: " << thresholdOutput.GetNumberOfValues() - << ", and an allowable percentage of errored pixels: " - << this->AllowedPixelErrorRatio << ", with a total summed threshold error: " + << ", with a total number of pixesl: " << thresholdOutput.GetNumberOfValues() + << ", and an allowable pixel error ratio: " << this->AllowedPixelErrorRatio + << ", with a total summed threshold error: " << vtkm::cont::Algorithm::Reduce(errorPixels, static_cast(0))); vtkm::cont::DataSet clone; diff --git a/vtkm/filter/testing/RegressionTestContourFilter.cxx b/vtkm/filter/testing/RegressionTestContourFilter.cxx index 6a50df5b3..069db5f58 100644 --- a/vtkm/filter/testing/RegressionTestContourFilter.cxx +++ b/vtkm/filter/testing/RegressionTestContourFilter.cxx @@ -51,7 +51,11 @@ void TestContourFilterWedge() result.PrintSummary(std::cout); vtkm::rendering::testing::RenderAndRegressionTest( - result, "gyroid", colorTable, "contour-wedge.png", static_cast(0.08)); + result, + "gyroid", + colorTable, + "filter/contour-wedge.png", + static_cast(0.08)); } void TestContourFilterUniform() @@ -81,7 +85,7 @@ void TestContourFilterUniform() //Y axis Flying Edge algorithm has subtle differences at a couple of boundaries vtkm::rendering::testing::RenderAndRegressionTest( - result, "pointvar", colorTable, "contour-uniform.png"); + result, "pointvar", colorTable, "filter/contour-uniform.png"); } void TestContourFilterTangle() @@ -109,7 +113,7 @@ void TestContourFilterTangle() //Y axis Flying Edge algorithm has subtle differences at a couple of boundaries vtkm::rendering::testing::RenderAndRegressionTest( - result, "nodevar", colorTable, "contour-tangle.png"); + result, "nodevar", colorTable, "filter/contour-tangle.png"); } void TestContourFilter() diff --git a/vtkm/filter/testing/RegressionTestPointTransform.cxx b/vtkm/filter/testing/RegressionTestPointTransform.cxx index c0fb52008..4671e6758 100644 --- a/vtkm/filter/testing/RegressionTestPointTransform.cxx +++ b/vtkm/filter/testing/RegressionTestPointTransform.cxx @@ -52,13 +52,8 @@ void TestPointTransform() result = vectorMagnitude.Execute(result); result.PrintSummary(std::cout); - C canvas(512, 512); - M mapper; - vtkm::rendering::Scene scene; - auto view = vtkm::rendering::testing::GetViewPtr( - result, "pointvar", canvas, mapper, scene, colorTable, static_cast(0.0)); - - VTKM_TEST_ASSERT(test_equal_images(view, "point-transform.png")); + vtkm::rendering::testing::RenderAndRegressionTest( + result, "pointvar", colorTable, "filter/point-transform.png"); } } // namespace diff --git a/vtkm/filter/testing/RegressionTestSplitSharpEdges.cxx b/vtkm/filter/testing/RegressionTestSplitSharpEdges.cxx index 95a50c814..5b6563f7c 100644 --- a/vtkm/filter/testing/RegressionTestSplitSharpEdges.cxx +++ b/vtkm/filter/testing/RegressionTestSplitSharpEdges.cxx @@ -45,13 +45,8 @@ void TestSplitSharpEdges() auto result = splitSharpEdges.Execute(dataSet); result.PrintSummary(std::cout); - C canvas(512, 512); - M mapper; - vtkm::rendering::Scene scene; - auto view = vtkm::rendering::testing::GetViewPtr( - result, "pointvar", canvas, mapper, scene, colorTable, static_cast(0.0)); - - VTKM_TEST_ASSERT(test_equal_images(view, "split-sharp-edges.png")); + vtkm::rendering::testing::RenderAndRegressionTest( + result, "pointvar", colorTable, "filter/split-sharp-edges.png"); } } // namespace diff --git a/vtkm/filter/testing/RegressionTestStreamline.cxx b/vtkm/filter/testing/RegressionTestStreamline.cxx index 2aff45161..8e228ce0f 100644 --- a/vtkm/filter/testing/RegressionTestStreamline.cxx +++ b/vtkm/filter/testing/RegressionTestStreamline.cxx @@ -68,13 +68,8 @@ void TestStreamline() result = tube.Execute(result); result.PrintSummary(std::cout); - C canvas(512, 512); - M mapper; - vtkm::rendering::Scene scene; - auto view = vtkm::rendering::testing::GetViewPtr( - result, "pointvar", canvas, mapper, scene, colorTable, static_cast(0.0)); - - VTKM_TEST_ASSERT(test_equal_images(view, "streamline.png")); + vtkm::rendering::testing::RenderAndRegressionTest( + result, "pointvar", colorTable, "filter/streamline.png"); } } // namespace diff --git a/vtkm/filter/testing/RegressionTestSurfaceNormals.cxx b/vtkm/filter/testing/RegressionTestSurfaceNormals.cxx index e03ce3c2d..e9a9a3e9e 100644 --- a/vtkm/filter/testing/RegressionTestSurfaceNormals.cxx +++ b/vtkm/filter/testing/RegressionTestSurfaceNormals.cxx @@ -47,13 +47,8 @@ void TestSurfaceNormals() auto result = surfaceNormals.Execute(dataSet); result.PrintSummary(std::cout); - C canvas(512, 512); - M mapper; - vtkm::rendering::Scene scene; - auto view = vtkm::rendering::testing::GetViewPtr( - result, "pointvar", canvas, mapper, scene, colorTable, static_cast(0.0)); - - VTKM_TEST_ASSERT(test_equal_images(view, "surface-normals.png")); + vtkm::rendering::testing::RenderAndRegressionTest( + result, "pointvar", colorTable, "filter/surface-normals.png"); } } // namespace diff --git a/vtkm/io/FileUtils.cxx b/vtkm/io/FileUtils.cxx index 6d6c69839..e8c1785e4 100644 --- a/vtkm/io/FileUtils.cxx +++ b/vtkm/io/FileUtils.cxx @@ -9,7 +9,18 @@ //============================================================================ #include +#include + #include +// TODO (nadavi): Once we get c++17 installed uncomment this +// #include +#include +#include + +#ifdef _MSC_VER +#include +#endif + namespace vtkm { @@ -25,5 +36,148 @@ bool EndsWith(const std::string& value, const std::string& ending) return std::equal(ending.rbegin(), ending.rend(), value.rbegin()); } +std::string Filename(const std::string& filePath) +{ + // TODO (nadavi): Once we get c++17 installed uncomment this + // std::filesystem::path path(filePath); + // return path.filename(); + +#ifdef _MSC_VER + auto lastSlashPos = filePath.rfind(GetWindowsPathSeperator(filePath)); +#else + auto lastSlashPos = filePath.rfind('/'); +#endif + if (lastSlashPos != std::string::npos) + { + return filePath.substr(lastSlashPos + 1); + } + return filePath; +} + +std::string ParentPath(const std::string& filePath) +{ + // TODO (nadavi): Once we get c++17 installed uncomment this + // std::filesystem::path path(filePath); + // return path.parent_path(); + +#ifdef _MSC_VER + auto lastSlashPos = filePath.rfind(GetWindowsPathSeperator(filePath)); +#else + auto lastSlashPos = filePath.rfind('/'); +#endif + if (lastSlashPos != std::string::npos) + { + return filePath.substr(0, lastSlashPos); + } + return ""; +} + +bool CreateDirectoriesFromFilePath(const std::string& filePath) +{ + // TODO (nadavi): Once we get c++17 installed uncomment this + // auto dir = ParentPath(filePath); + // if (dir.empty()) + // { + // return false; + // } + // return std::filesystem::create_directories(dir); + + auto dir = ParentPath(filePath); + if (dir.empty()) + { + return false; + } + +#ifdef _MSC_VER + auto ret = _mkdir(dir.c_str()); +#else + mode_t mode = 0755; + auto ret = mkdir(dir.c_str(), mode); +#endif + + if (ret == 0) + { + return true; + } + + switch (errno) + { + case ENOENT: + { + if (!CreateDirectoriesFromFilePath(dir)) + { + return false; + } + return CreateDirectoriesFromFilePath(filePath); + } + case EEXIST: + return false; + default: + return false; + } +} + +std::string MergePaths(const std::string& filePathPrefix, const std::string& filePathSuffix) +{ + // TODO (nadavi): Once we get c++17 installed uncomment this + // NOTE: This function may not directly mimic the c++ filesystem '/' behavior + // the edge case tests will probably need to be updated when switching. + // std::filesystem::path prefix(filePathPrefix); + // std::filesystem::path suffix(filePathSuffix); + // std::filesystem::path fullPath = prefix / suffix; + // return fullPath.string(); + + auto prefix = filePathPrefix; + auto suffix = filePathSuffix; + char prefixPathSeperator = '/'; + char suffixPathSeperator = '/'; + + if (prefix.empty() && suffix.empty()) + { + return ""; + } + else if (prefix.empty()) + { + return suffix; + } + else if (suffix.empty()) + { + return prefix; + } + +#ifdef _MSC_VER + prefixPathSeperator = GetWindowsPathSeperator(prefix); + suffixPathSeperator = suffix[0] == '/' || suffix[0] == '\\' ? suffix[0] : prefixPathSeperator; +#endif + + if (prefix[prefix.length() - 1] == prefixPathSeperator) + { + prefix = prefix.substr(0, prefix.length() - 1); + } + if (suffix[0] == suffixPathSeperator) + { + suffix = suffix.substr(1, suffix.length()); + } + return prefix + prefixPathSeperator + suffix; +} + +std::string PrefixStringToFilename(const std::string& filePath, const std::string& prefix) +{ + auto parentPath = ParentPath(filePath); + auto filename = Filename(filePath); + filename = prefix + filename; + return MergePaths(parentPath, filename); +} + +char GetWindowsPathSeperator(const std::string& filePath) +{ + auto slashType = filePath.rfind('/'); + if (slashType == std::string::npos) + { + return '\\'; + } + return '/'; +} + } // namespace vtkm::io } // namespace vtkm diff --git a/vtkm/io/FileUtils.h b/vtkm/io/FileUtils.h index 150d3b16d..8d86d6d0c 100644 --- a/vtkm/io/FileUtils.h +++ b/vtkm/io/FileUtils.h @@ -19,8 +19,37 @@ namespace vtkm namespace io { +/// \brief Checks if a provided string ends with a specific substring. VTKM_IO_EXPORT bool EndsWith(const std::string& value, const std::string& ending); +/// \brief Returns the filename component of a filePath string. +/// Mimics the functionality of the c++17 filesystem::path filename function +VTKM_IO_EXPORT std::string Filename(const std::string& filePath); + +/// \brief Returns the directory component of a filePath string. +/// Mimics the functionality of the c++17 filesystem::path parent_path function +VTKM_IO_EXPORT std::string ParentPath(const std::string& filePath); + +/// \brief Creates all the directories found in a given filePath component +/// if they don't exist. Only returns true if directories are actually created. +VTKM_IO_EXPORT bool CreateDirectoriesFromFilePath(const std::string& filePath); + +/// \brief Merges two filepath strings together using the correct system filepath seperator +/// EX: MergePaths("path/to/merge", "some/filename.txt") = "path/to/merge/some/filename.txt" +/// EX: MergePaths("path/to/merge/", "/some/filename.txt") = "path/to/merge/some/filename.txt" +VTKM_IO_EXPORT std::string MergePaths(const std::string& filePathPrefix, + const std::string& filePathSuffix); + +/// \brief Takes the supplied prefix and prepends it to the filename for the provided filePath +/// EX: PrefixStringToFilename("/some/path/to/filename.txt", "prefix-") = "/some/path/to/prefix-filename.txt" +VTKM_IO_EXPORT std::string PrefixStringToFilename(const std::string& filePath, + const std::string& prefix); + +/// \brief determine which path separator to use for windows given a provided path +/// Should return one of either '\\' or '/' depending on what the provided path uses. +/// If no seperator is found it will just return '\\' +VTKM_IO_EXPORT char GetWindowsPathSeperator(const std::string& filePath); + } // namespace vtkm::io } // namespace vtkm diff --git a/vtkm/io/ImageWriterBase.cxx b/vtkm/io/ImageWriterBase.cxx index 0bb4871a1..50fd54be3 100644 --- a/vtkm/io/ImageWriterBase.cxx +++ b/vtkm/io/ImageWriterBase.cxx @@ -8,6 +8,7 @@ // PURPOSE. See the above copyright notice for more information. //============================================================================ +#include #include #include @@ -75,7 +76,13 @@ void ImageWriterBase::WriteDataSet(const vtkm::cont::DataSet& dataSet, } } + if (CreateDirectoriesFromFilePath(this->FileName)) + { + VTKM_LOG_S(vtkm::cont::LogLevel::Info, + "Created output directory: " << ParentPath(this->FileName)); + } this->Write(width, height, colorField.GetData().AsArrayHandle()); } -} + } // namespace vtkm::io +} // namespace vtkm diff --git a/vtkm/io/testing/UnitTestFileUtils.cxx b/vtkm/io/testing/UnitTestFileUtils.cxx index 0eb49764c..8e7f038d8 100644 --- a/vtkm/io/testing/UnitTestFileUtils.cxx +++ b/vtkm/io/testing/UnitTestFileUtils.cxx @@ -11,6 +11,13 @@ #include #include +#ifdef _MSC_VER +#include +#else +#include +#endif + +#include #include using namespace vtkm::io; @@ -27,11 +34,153 @@ void TestEndsWith() VTKM_TEST_ASSERT(EndsWith("empty_string", ""), "Ending did not match ''"); } +void TestGetWindowsPathSeperator() +{ + VTKM_TEST_ASSERT(GetWindowsPathSeperator("some/test/path") == '/', "/ should be the separator"); + VTKM_TEST_ASSERT(GetWindowsPathSeperator("some\\test\\path") == '\\', + "\\ should be the seperator"); + VTKM_TEST_ASSERT(GetWindowsPathSeperator("some\\test/path") == '/', "Always prefer / over \\"); + VTKM_TEST_ASSERT(GetWindowsPathSeperator("some/test\\path") == '/', "Always prefer / over \\"); +} + +void TestFilename() +{ + VTKM_TEST_ASSERT(Filename("filename.txt") == "filename.txt", + "Should not affect filename without dir"); + VTKM_TEST_ASSERT(Filename("test/path/filename.txt") == "filename.txt", "Should strip linux path"); + VTKM_TEST_ASSERT(Filename("test/path/dir/") == "", "Should return empty string if ends in a dir"); +#ifdef _MSC_VER + VTKM_TEST_ASSERT(Filename("C:\\windows\\path\\filename.txt") == "filename.txt", + "Should strip windows paths"); + VTKM_TEST_ASSERT(Filename("test\\path\\dir\\") == "", + "Should return empty string if ends in a dir"); +#endif +} + +void TestParentPath() +{ + VTKM_TEST_ASSERT(ParentPath("filename.txt") == "", "Should return empty string"); + VTKM_TEST_ASSERT(ParentPath("test/path/filename.txt") == "test/path", "Should strip Linux file"); + VTKM_TEST_ASSERT(ParentPath("test/path/dir/") == "test/path/dir", + "Should remove only the trailing /"); +#ifdef _MSC_VER + VTKM_TEST_ASSERT(ParentPath("C:\\windows\\path\\filename.txt") == "C:\\windows\\path", + "Should strip the Windows file"); + VTKM_TEST_ASSERT(ParentPath("test\\path\\dir\\") == "test\\path\\dir", + "Should remove only the trailing \\"); +#endif +} + +void TestCreateDirectoriesFromFilePath() +{ + VTKM_TEST_ASSERT(!CreateDirectoriesFromFilePath("filename.txt"), + "no dir to create from file path, should return false"); +#ifdef _MSC_VER + vtkm::Id pid = _getpid(); +#else + vtkm::Id pid = getpid(); +#endif + std::string baseDir; + vtkm::cont::TryExecute( + [](const vtkm::cont::DeviceAdapterId& device, vtkm::Id id, std::string& dir) { + dir = "test_dir" + std::to_string(device.GetValue()) + "_id" + std::to_string(id); + return true; + }, + pid, + baseDir); + + VTKM_TEST_ASSERT(CreateDirectoriesFromFilePath(baseDir + "/filename.txt"), + "Should create the " + baseDir + " dir"); + VTKM_TEST_ASSERT(!CreateDirectoriesFromFilePath(baseDir + "/filename.txt"), + baseDir + " was just created, should be false"); + VTKM_TEST_ASSERT(CreateDirectoriesFromFilePath(baseDir + "/test_1/"), + "Should create the 'test_1' dir"); + VTKM_TEST_ASSERT(CreateDirectoriesFromFilePath(baseDir + "/test_2/test_3/file"), + "should create the full path 'test_2/test_3' in " + baseDir); +#ifdef _MSC_VER + baseDir = "win_" + baseDir; + VTKM_TEST_ASSERT(CreateDirectoriesFromFilePath(baseDir + "\\filename.txt"), + "Should create the " + baseDir + " dir"); + VTKM_TEST_ASSERT(!CreateDirectoriesFromFilePath(baseDir + "\\filename.txt"), + baseDir + " was just created, should be false"); + VTKM_TEST_ASSERT(CreateDirectoriesFromFilePath(baseDir + "\\test_1\\"), + "Should create the 'test_1' dir"); + VTKM_TEST_ASSERT(CreateDirectoriesFromFilePath(baseDir + "\\test_2\\test_3\\file"), + "should create the full path 'test_2\\test_3' in " + baseDir); +#endif +} + +void TestMergePaths() +{ + VTKM_TEST_ASSERT(MergePaths("some/path", "filename.txt") == "some/path/filename.txt", + "should append filename.txt " + MergePaths("some/path", "filename.txt")); + VTKM_TEST_ASSERT(MergePaths("", "filename.txt") == "filename.txt", + "should just return the suffix"); + VTKM_TEST_ASSERT(MergePaths("some/path", "") == "some/path", "should just return the prefix"); + VTKM_TEST_ASSERT(MergePaths("end/in/slash/", "/start/slash") == "end/in/slash/start/slash", + "Should do correct slash merge"); + VTKM_TEST_ASSERT(MergePaths("", "") == "", "Empty paths, empty return string"); +#ifdef _MSC_VER + VTKM_TEST_ASSERT(MergePaths("some\\path", "filename.txt") == "some\\path\\filename.txt", + "should append filename.txt"); + VTKM_TEST_ASSERT(MergePaths("some\\path", "") == "some\\path", "should just return the prefix"); + VTKM_TEST_ASSERT(MergePaths("end\\in\\slash\\", "\\start\\slash") == + "end\\in\\slash\\start\\slash", + "Should do correct slash merge"); + VTKM_TEST_ASSERT(MergePaths("bad\\combo", "bad/combo") == "bad\\combo\\bad/combo", + "Should use the prefix seperator"); + VTKM_TEST_ASSERT(MergePaths("bad\\combo", "/bad/combo") == "bad\\combo\\bad/combo", + "Should use the prefix seperator"); + VTKM_TEST_ASSERT(MergePaths("bad/combo", "\\bad\\combo") == "bad/combo/bad\\combo", + "Should use the prefix seperator"); +#endif +} + +void TestPrefixStringToFilename() +{ + VTKM_TEST_ASSERT(PrefixStringToFilename("some/path/filename.txt", "prefix-") == + "some/path/prefix-filename.txt", + "should prefix file"); + VTKM_TEST_ASSERT(PrefixStringToFilename("/path/here.txt", "dir/prefix-") == + "/path/dir/prefix-here.txt", + "should prepend dir+prefix"); + VTKM_TEST_ASSERT(PrefixStringToFilename("filename.txt", "prefix-") == "prefix-filename.txt", + "should prefix only file"); + VTKM_TEST_ASSERT(PrefixStringToFilename("some/path/", "prefix-") == "some/path/prefix-", + "should append to file, not dir"); + VTKM_TEST_ASSERT(PrefixStringToFilename("", "prefix-") == "prefix-", + "should just return the prefix-"); + VTKM_TEST_ASSERT(PrefixStringToFilename("", "") == "", "Should return empty string"); + VTKM_TEST_ASSERT(PrefixStringToFilename("some/path/filename.txt", "") == "some/path/filename.txt", + "should return file path"); +#ifdef _MSC_VER + VTKM_TEST_ASSERT(PrefixStringToFilename("some\\path\\filename.txt", "prefix-") == + "some\\path\\prefix-filename.txt", + "should prefix file"); + VTKM_TEST_ASSERT(PrefixStringToFilename("\\path\\here.txt", "dir\\prefix-") == + "\\path\\dir\\prefix-here.txt", + "should prepend dir+prefix"); + VTKM_TEST_ASSERT(PrefixStringToFilename("some\\path\\", "prefix-") == "some\\path\\prefix-", + "should append to file, not dir"); + VTKM_TEST_ASSERT(PrefixStringToFilename("some\\path\\filename.txt", "") == + "some\\path\\filename.txt", + "should return file path"); +#endif +} + + void TestUtils() { TestEndsWith(); + TestGetWindowsPathSeperator(); + TestFilename(); + TestParentPath(); + TestCreateDirectoriesFromFilePath(); + TestMergePaths(); + TestPrefixStringToFilename(); } -} + +} // namespace int UnitTestFileUtils(int argc, char* argv[]) { diff --git a/vtkm/rendering/testing/Testing.h b/vtkm/rendering/testing/Testing.h index 84983b4fa..5fd675117 100644 --- a/vtkm/rendering/testing/Testing.h +++ b/vtkm/rendering/testing/Testing.h @@ -13,11 +13,13 @@ #include #include +#include #include #include #include #include +#include #include #include @@ -56,8 +58,8 @@ inline TestEqualResult test_equal_images(const std::shared_ptr view, view->Paint(); view->GetCanvas().RefreshColorBuffer(); - const std::string testImageName = - vtkm::cont::testing::Testing::WriteDirPath("test-" + fileNames[0]); + const std::string testImageName = vtkm::cont::testing::Testing::WriteDirPath( + vtkm::io::PrefixStringToFilename(fileNames[0], "test-")); vtkm::io::WriteImageFile(view->GetCanvas().GetDataSet(), testImageName, "color"); for (const auto& fileName : fileNames) @@ -79,7 +81,8 @@ inline TestEqualResult test_equal_images(const std::shared_ptr view, const std::string outputImagePath = vtkm::cont::testing::Testing::WriteDirPath(fileName); vtkm::io::WriteImageFile(view->GetCanvas().GetDataSet(), outputImagePath, "color"); - imageResult.PushMessage("File '" + fileName + "' did not exist but has been generated"); + imageResult.PushMessage("File '" + fileName + + "' did not exist but has been generated here: " + outputImagePath); testResults.PushMessage(imageResult.GetMergedMessage()); continue; } @@ -110,7 +113,8 @@ inline TestEqualResult test_equal_images(const std::shared_ptr view, if (writeDiff && resultDataSet.HasPointField("image-diff")) { - const std::string diffName = vtkm::cont::testing::Testing::WriteDirPath("diff-" + fileName); + const std::string diffName = vtkm::cont::testing::Testing::WriteDirPath( + vtkm::io::PrefixStringToFilename(fileName, "diff-")); vtkm::io::WriteImageFile(resultDataSet, diffName, "image-diff"); } diff --git a/vtkm/rendering/testing/UnitTestMapperWireframer.cxx b/vtkm/rendering/testing/UnitTestMapperWireframer.cxx index a883ba502..5c29cb658 100644 --- a/vtkm/rendering/testing/UnitTestMapperWireframer.cxx +++ b/vtkm/rendering/testing/UnitTestMapperWireframer.cxx @@ -99,16 +99,34 @@ void RenderTests() vtkm::cont::testing::MakeTestDataSet maker; vtkm::cont::ColorTable colorTable("samsel fire"); - vtkm::rendering::testing::Render( - maker.Make3DRegularDataSet0(), "pointvar", colorTable, "wf_reg3D.pnm"); - vtkm::rendering::testing::Render( - maker.Make3DRectilinearDataSet0(), "pointvar", colorTable, "wf_rect3D.pnm"); - vtkm::rendering::testing::Render( - maker.Make3DExplicitDataSet4(), "pointvar", colorTable, "wf_expl3D.pnm"); - vtkm::rendering::testing::Render( - Make3DUniformDataSet(), "pointvar", colorTable, "wf_uniform3D.pnm"); - vtkm::rendering::testing::Render( - Make2DExplicitDataSet(), "cellVar", colorTable, "wf_lines2D.pnm"); + vtkm::rendering::testing::RenderAndRegressionTest( + maker.Make3DRegularDataSet0(), "pointvar", colorTable, "rendering/wireframer/wf_reg3D.png"); + vtkm::rendering::testing::RenderAndRegressionTest(maker.Make3DRectilinearDataSet0(), + "pointvar", + colorTable, + "rendering/wireframer/wf_rect3D.png"); + vtkm::rendering::testing::RenderAndRegressionTest( + Make2DExplicitDataSet(), "cellVar", colorTable, "rendering/wireframer/wf_lines2D.png"); + + // These tests are very fickle on multiple machines and on different devices + // Need to boost the maximum number of allowable error pixels manually + { + C canvas(512, 512); + M mapper; + vtkm::rendering::Scene scene; + auto view = vtkm::rendering::testing::GetViewPtr( + Make3DUniformDataSet(), "pointvar", canvas, mapper, scene, colorTable); + VTKM_TEST_ASSERT(test_equal_images(view, "rendering/wireframer/wf_uniform3D.png", 0, 0, 0.05f)); + } + { + C canvas(512, 512); + M mapper; + vtkm::rendering::Scene scene; + auto view = vtkm::rendering::testing::GetViewPtr( + maker.Make3DExplicitDataSet4(), "pointvar", canvas, mapper, scene, colorTable); + VTKM_TEST_ASSERT(test_equal_images(view, "rendering/wireframer/wf_expl3D.png", 0, 0, 0.005f)); + } + // // Test the 1D cell set line plot with multiple lines //