@@ -107,6 +107,7 @@ void GeneratePoleFigures(const std::string& phaseName, size_t opsIndex, hid_t ex
107107 {
108108 std::string layoutStr = (layoutType == PoleFigureLayoutType::Horizontal) ? " Horz" : (layoutType == PoleFigureLayoutType::Vertical) ? " Vert" : " Sqr" ;
109109 hid_t layoutGroupId = H5Support::H5Utilities::createGroup (exemplarFileId, layoutStr);
110+ REQUIRE (layoutGroupId > 0 );
110111 H5Support::H5ScopedGroupSentinel layoutGroupSentinel (layoutGroupId, true );
111112
112113 for (size_t sampleId = 0 ; sampleId < k_NumSamplingGroups; ++sampleId)
@@ -157,22 +158,32 @@ void GeneratePoleFigures(const std::string& phaseName, size_t opsIndex, hid_t ex
157158 REQUIRE (result.height == metrics.pageHeight );
158159
159160 UInt8ArrayType::Pointer image = result.image ;
160- // std::string outputPath = fmt::format("{}/Pole_Figure_Images/Pole_Figure_{}_{}_{}.tif", ebsdlib::unit_test::k_TestFilesDir, layoutStr,op->getRotationPointGroup() , sampleId);
161- // auto writerResult = TiffWriter::WriteColorImage(outputPath, result.width, result.height, 4, result.image->data());
162- // REQUIRE(writerResult.first == 0);
163- //
164161 std::string datasetName = fmt::format (" {}" , sampleId);
165- // std::vector<hsize_t> dims = {static_cast<hsize_t>(result.height), static_cast<hsize_t>(result.width), 4ULL};
166- // herr_t err = H5Support::H5Lite::writePointerDataset(layoutGroupId, datasetName, dims.size(), dims.data(), result.image->data());
167- // REQUIRE(err == 0);
162+ #if WRITE_EXEMPLAR_IMAGES
163+ std::string outputPath = fmt::format (" {}/Pole_Figure_Images/Pole_Figure_{}_{}_{}.tif" , ebsdlib::unit_test::k_TestFilesDir, layoutStr,op->getRotationPointGroup () , sampleId);
164+ auto writerResult = TiffWriter::WriteColorImage (outputPath, result.width , result.height , 4 , result.image ->data ());
165+ REQUIRE (writerResult.first == 0 );
166+ //
167+
168+ std::vector<hsize_t > dims = {static_cast <hsize_t >(result.height ), static_cast <hsize_t >(result.width ), 4ULL };
169+ herr_t err = H5Support::H5Lite::writePointerDataset (layoutGroupId, datasetName, dims.size (), dims.data (), result.image ->data ());
170+ REQUIRE (err == 0 );
171+ #else
172+
168173 std::vector<uint8_t > exemplarData;
169174 err = H5Support::H5Lite::readVectorDataset (layoutGroupId, datasetName, exemplarData);
170175 REQUIRE (err == 0 );
171176 REQUIRE (exemplarData.size () == static_cast <size_t >(result.width * result.height * 4 ));
177+ size_t misMatchCount = 0 ;
172178 for (size_t i = 0 ; i < exemplarData.size (); i++)
173179 {
174- REQUIRE (exemplarData[i] == (*image)[i]);
180+ if (exemplarData[i] != (*image)[i])
181+ {
182+ misMatchCount++;
183+ }
175184 }
185+ REQUIRE (misMatchCount == 0 );
186+ #endif
176187 }
177188 }
178189}
@@ -181,19 +192,29 @@ void GeneratePoleFigures(const std::string& phaseName, size_t opsIndex, hid_t ex
181192TEST_CASE (" ebsdlib::PoleFigureCompositorTest::All_Laue_Classes" , " [EbsdLib][PoleFigureCompositorTest]" )
182193{
183194 const ebsdlib::unit_test::TestFileSentinel testDataSentinel (ebsdlib::unit_test::k_TestFilesDir, " Laue_Orientation_Clusters_v6.tar.gz" , " Laue_Orientation_Clusters_v6" , true , true );
184- const ebsdlib::unit_test::TestFileSentinel testDataSentinel1 (ebsdlib::unit_test::k_TestFilesDir, " Pole_Figure_Images.tar.gz" , " Pole_Figure_Images" , true , true );
195+ const ebsdlib::unit_test::TestFileSentinel testDataSentinel1 (ebsdlib::unit_test::k_TestFilesDir, " Pole_Figure_Images.tar.gz" , " Pole_Figure_Images"
196+ #if WRITE_EXEMPLAR_IMAGES
197+ , false , false
198+ #endif
199+ );
185200
186201 const std::string hdfInputFile = fmt::format (" {}/Pole_Figure_Images/Exemplar_Data.h5" , ebsdlib::unit_test::k_TestFilesDir);
187202 hid_t fileId = -1 ;
188- // if(!std::filesystem::exists(hdfInputFile))
189- // {
190- // fileId = H5Support::H5Utilities::createFile(hdfInputFile);
191- // }
192- // else
203+ #if WRITE_EXEMPLAR_IMAGES
204+ if (!std::filesystem::exists (hdfInputFile))
205+ {
206+ std::cout << " Creating " << hdfInputFile << std::endl;
207+ fileId = H5Support::H5Utilities::createFile (hdfInputFile);
208+ }
209+ else
210+ #else
193211 {
212+ std::cout << " Opening " << hdfInputFile << std::endl;
194213 fileId = H5Support::H5Utilities::openFile (hdfInputFile, true );
195214 }
196- H5Support::H5ScopedFileSentinel fileSentinel (fileId, true );
215+ #endif
216+ REQUIRE (fileId > 0 );
217+ H5Support::H5ScopedFileSentinel fileSentinel (fileId, false );
197218
198219 std::vector<LaueOps::Pointer> ops = LaueOps::GetAllOrientationOps ();
199220
@@ -210,10 +231,13 @@ TEST_CASE("ebsdlib::PoleFigureCompositorTest::All_Laue_Classes", "[EbsdLib][Pole
210231 tested.insert (rpg);
211232
212233 hid_t layoutGroupId = H5Support::H5Utilities::createGroup (fileId, rpg);
213- H5Support::H5ScopedGroupSentinel layoutGroupSentinel (layoutGroupId, true );
234+ REQUIRE (layoutGroupId > 0 );
235+ H5Support::H5ScopedGroupSentinel layoutGroupSentinel (layoutGroupId, false );
214236
215237 const std::string phaseName = fmt::format (" Laue_{}" , rpg);
238+ #if !WRITE_EXEMPLAR_IMAGES
216239 SECTION (phaseName + " VMF" )
240+ #endif
217241 {
218242 GeneratePoleFigures (phaseName, opsIdx, layoutGroupId);
219243 }
0 commit comments