Skip to content

Commit 755a22f

Browse files
committed
ENH: Split the test into two cases
The one which was described, and the other which was created using code.
1 parent 317bbec commit 755a22f

File tree

1 file changed

+62
-25
lines changed

1 file changed

+62
-25
lines changed

test/CuberilleTest_Issue66.cxx

Lines changed: 62 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -63,14 +63,35 @@ as an issue in case anyone else had any insight--pun intended. ;-D
6363
6464
*/
6565

66-
int
67-
CuberilleTest_Issue66(int argc, char * argv[])
66+
TImage::Pointer
67+
case1()
6868
{
6969
const auto image = TImage::New();
7070
TImage::RegionType region({ { 0, 0, 0 } }, { { 5, 4, 4 } });
7171
image->SetBufferedRegion(region);
72-
image->Allocate();
73-
image->FillBuffer(0);
72+
image->AllocateInitialized(); // zero filled image
73+
74+
image->SetPixel({ { 1, 1, 1 } }, 1); // A
75+
image->SetPixel({ { 2, 2, 1 } }, 1); // B
76+
77+
image->SetPixel({ { 1, 1, 0 } }, 1); // C
78+
image->SetPixel({ { 1, 2, 0 } }, 1); // D
79+
image->SetPixel({ { 2, 2, 0 } }, 1); // E
80+
81+
image->SetPixel({ { 1, 1, 2 } }, 1); // F
82+
image->SetPixel({ { 1, 2, 2 } }, 1); // G
83+
image->SetPixel({ { 2, 2, 2 } }, 1); // H
84+
85+
return image;
86+
}
87+
88+
TImage::Pointer
89+
case2()
90+
{
91+
const auto image = TImage::New();
92+
TImage::RegionType region({ { 0, 0, 0 } }, { { 5, 4, 4 } });
93+
image->SetBufferedRegion(region);
94+
image->AllocateInitialized(); // zero filled image
7495

7596
image->SetPixel({ { 1, 1, 1 } }, 1); // A
7697
image->SetPixel({ { 2, 1, 1 } }, 1); // B
@@ -83,31 +104,47 @@ CuberilleTest_Issue66(int argc, char * argv[])
83104
image->SetPixel({ { 2, 2, 2 } }, 1); // G
84105
image->SetPixel({ { 3, 2, 2 } }, 1); // H
85106

86-
itk::WriteImage(image, "input_issue66.nrrd");
107+
return image;
108+
}
87109

88-
const auto extract = TExtract::New();
89-
extract->SetInput(image);
90-
extract->SavePixelAsCellDataOn();
91-
extract->GenerateTriangleFacesOff();
92-
extract->ProjectVerticesToIsoSurfaceOff();
93110

94-
const auto m_writer = TMeshWriter::New();
95-
m_writer->SetInput(extract->GetOutput());
96-
m_writer->SetFileName("mesh.obj");
97-
m_writer->Update();
111+
int
112+
CuberilleTest_Issue66(int argc, char * argv[])
113+
{
114+
int countFailed = 0;
115+
for (const auto image : { case1(), case2() })
116+
{
98117

99-
const auto n_cell = extract->GetOutput()->GetNumberOfCells();
100-
const auto n_data = extract->GetOutput()->GetCellData()->Size();
118+
const auto extract = TExtract::New();
119+
extract->SetInput(image);
120+
extract->SavePixelAsCellDataOn();
121+
extract->GenerateTriangleFacesOff();
122+
extract->ProjectVerticesToIsoSurfaceOff();
123+
124+
const auto m_writer = TMeshWriter::New();
125+
m_writer->SetInput(extract->GetOutput());
126+
m_writer->SetFileName("mesh.obj");
127+
m_writer->Update();
128+
129+
const auto n_cell = extract->GetOutput()->GetNumberOfCells();
130+
const auto n_data = extract->GetOutput()->GetCellData()->Size();
131+
132+
if (n_cell != n_data)
133+
{
134+
std::cout << "This fails if using itk::QuadEdgeMesh." << std::endl;
135+
std::cout << "n_cell: " << n_cell << std::endl;
136+
std::cout << "n_data: " << n_data << std::endl;
137+
++countFailed;
138+
}
139+
else
140+
{
141+
std::cout << "This succeeds if using itk::Mesh." << std::endl;
142+
}
143+
}
101144

102-
if (n_cell != n_data)
145+
if (countFailed == 0)
103146
{
104-
std::cout << "This fails if using itk::QuadEdgeMesh." << std::endl;
105-
std::cout << "n_cell: " << n_cell << std::endl;
106-
std::cout << "n_data: " << n_data << std::endl;
107-
return EXIT_FAILURE;
147+
return EXIT_SUCCESS;
108148
}
109-
110-
std::cout << "This succeeds if using itk::Mesh." << std::endl;
111-
112-
return EXIT_SUCCESS;
149+
return EXIT_FAILURE;
113150
}

0 commit comments

Comments
 (0)