📄 itkreadwritespatialobjecttest.cxx
字号:
return EXIT_FAILURE;
}
}
}
}
if(!maskFound)
{
std::cout << "No Mask!" << std::endl;
std::cout<<" [FAILED]"<<std::endl;
return EXIT_FAILURE;
}
std::cout<<" [PASSED]"<<std::endl;
std::cout<<"Testing Blob validity:";
for(obj = mySceneChildren->begin(); obj != mySceneChildren->end(); obj++)
{
BlobType::PointListType::const_iterator pit;
if(!strcmp((*obj)->GetTypeName(),"BlobSpatialObject"))
{
unsigned int value = 0;
for(pit = dynamic_cast<BlobType*>((*obj).GetPointer())->GetPoints().begin();
pit != dynamic_cast<BlobType*>((*obj).GetPointer())->GetPoints().end();
pit++)
{
for(unsigned int d=0;d<3;d++)
{
if((*pit).GetPosition()[d]!=value)
{
std::cout<<" [FAILED]"<<std::endl;
return EXIT_FAILURE;
}
// Testing the color of the tube points
if( (*pit).GetRed() != value)
{
std::cout<<" [FAILED] : Red : found " << (*pit).GetRed() << " instead of " << value <<std::endl;
return EXIT_FAILURE;
}
if((*pit).GetGreen()!=value+1)
{
std::cout<<" [FAILED] : Green : found " << (*pit).GetGreen() << " instead of " << value+1 <<std::endl;
return EXIT_FAILURE;
}
if((*pit).GetBlue()!=value+2)
{
std::cout<<" [FAILED] : Blue : found " << (*pit).GetBlue() << " instead of " << value+2 <<std::endl;
return EXIT_FAILURE;
}
if((*pit).GetAlpha()!=value+3)
{
std::cout<<" [FAILED] : Alpha : found " << (*pit).GetAlpha() << " instead of " << value+3 <<std::endl;
return EXIT_FAILURE;
}
}
value++;
}
}
}
std::cout<<" [PASSED]"<<std::endl;
std::cout<<"Testing Surface validity:";
for(obj = mySceneChildren->begin(); obj != mySceneChildren->end(); obj++)
{
SurfaceType::PointListType::const_iterator pit;
if(!strcmp((*obj)->GetTypeName(),"SurfaceSpatialObject"))
{
unsigned int value = 0;
for(pit = dynamic_cast<SurfaceType*>((*obj).GetPointer())->GetPoints().begin();
pit != dynamic_cast<SurfaceType*>((*obj).GetPointer())->GetPoints().end();
pit++)
{
for(unsigned int d=0;d<3;d++)
{
if((*pit).GetPosition()[d]!=value)
{
std::cout << (*pit).GetPosition()[d] << "!=" << value << std::endl;
std::cout<<" [FAILED]"<<std::endl;
return EXIT_FAILURE;
}
if((*pit).GetNormal()[d]!= d)
{
std::cout << "Normal : " << (*pit).GetNormal()[d] << std::endl;
std::cout<<" [FAILED]"<<std::endl;
return EXIT_FAILURE;
}
// Testing the color of the tube points
if( (*pit).GetRed() != value)
{
std::cout<<" [FAILED] : Red : found " << ( *pit).GetRed() << " instead of " << value <<std::endl;
return EXIT_FAILURE;
}
if((*pit).GetGreen()!=value+1)
{
std::cout<<" [FAILED] : Green : found " << ( *pit).GetGreen() << " instead of " << value+1 <<std::endl;
return EXIT_FAILURE;
}
if((*pit).GetBlue()!=value+2)
{
std::cout<<" [FAILED] : Blue : found " << ( *pit).GetBlue() << " instead of " << value+2 <<std::endl;
return EXIT_FAILURE;
}
if((*pit).GetAlpha()!=value+3)
{
std::cout<<" [FAILED] : Alpha : found " << ( *pit).GetAlpha() << " instead of " << value+3 <<std::endl;
return EXIT_FAILURE;
}
}
value++;
}
}
}
std::cout<<" [PASSED]"<<std::endl;
std::cout<<"Testing Line validity:";
for(obj = mySceneChildren->begin(); obj != mySceneChildren->end(); obj++)
{
LineType::PointListType::const_iterator pit;
if(!strcmp((*obj)->GetTypeName(),"LineSpatialObject"))
{
unsigned int value = 0;
for(pit = dynamic_cast<LineType*>((*obj).GetPointer())->GetPoints().begin();
pit != dynamic_cast<LineType*>((*obj).GetPointer())->GetPoints().end();
pit++)
{
for(unsigned int d=0;d<3;d++)
{
if((*pit).GetPosition()[d]!=value)
{
std::cout<<" [FAILED]"<<std::endl;
return EXIT_FAILURE;
}
if(((*pit).GetNormal(0))[d]!= d)
{
std::cout<<" [FAILED]"<<std::endl;
return EXIT_FAILURE;
}
if(((*pit).GetNormal(1))[d]!= 2*d)
{
std::cout<<" [FAILED]"<<std::endl;
return EXIT_FAILURE;
}
// Testing the color of the tube points
if( (*pit).GetRed() != value)
{
std::cout<<" [FAILED] : Red : found " << ( *pit).GetRed() << " instead of " << value <<std::endl;
return EXIT_FAILURE;
}
if((*pit).GetGreen()!=value+1)
{
std::cout<<" [FAILED] : Green : found " << ( *pit).GetGreen() << " instead of " << value+1 <<std::endl;
return EXIT_FAILURE;
}
if((*pit).GetBlue()!=value+2)
{
std::cout<<" [FAILED] : Blue : found " << ( *pit).GetBlue() << " instead of " << value+2 <<std::endl;
return EXIT_FAILURE;
}
if((*pit).GetAlpha()!=value+3)
{
std::cout<<" [FAILED] : Alpha : found " << ( *pit).GetAlpha() << " instead of " << value+3 <<std::endl;
return EXIT_FAILURE;
}
}
value++;
}
}
}
std::cout<<" [PASSED]"<<std::endl;
std::cout<<"Testing Landmark validity:";
for(obj = mySceneChildren->begin(); obj != mySceneChildren->end(); obj++)
{
LandmarkType::PointListType::const_iterator pit;
if(!strcmp((*obj)->GetTypeName(),"LandmarkSpatialObject"))
{
unsigned int value = 0;
for(pit = dynamic_cast<LandmarkType*>((*obj).GetPointer())->GetPoints().begin();
pit != dynamic_cast<LandmarkType*>((*obj).GetPointer())->GetPoints().end();
pit++)
{
for(unsigned int d=0;d<3;d++)
{
if((*pit).GetPosition()[d]!=value)
{
std::cout<<" [FAILED]"<<std::endl;
return EXIT_FAILURE;
}
}
value++;
}
}
}
std::cout<<" [PASSED]"<<std::endl;
std::cout<<"Testing Contour validity:";
for(obj = mySceneChildren->begin(); obj != mySceneChildren->end(); obj++)
{
if(!strcmp((*obj)->GetTypeName(),"ContourSpatialObject"))
{
if(!dynamic_cast<ContourType*>((*obj).GetPointer())->GetClosed())
{
std::cout << "The contour should be closed" << std::endl;
return EXIT_FAILURE;
}
if(dynamic_cast<ContourType*>((*obj).GetPointer())->GetDisplayOrientation() != 2)
{
std::cout << "The contour should have display orientation == 2 instead of"
<< dynamic_cast<ContourType*>((*obj).GetPointer())->GetDisplayOrientation()
<< std::endl;
return EXIT_FAILURE;
}
if(dynamic_cast<ContourType*>((*obj).GetPointer())->GetAttachedToSlice() != 50)
{
std::cout << "The contour should be attached to slice 50 instead of"
<< dynamic_cast<ContourType*>((*obj).GetPointer())->GetAttachedToSlice()
<< std::endl;
return EXIT_FAILURE;
}
ContourType::ControlPointListType::const_iterator ctrl;
int value = 0;
for(ctrl = dynamic_cast<ContourType*>((*obj).GetPointer())->GetControlPoints().begin();
ctrl != dynamic_cast<ContourType*>((*obj).GetPointer())->GetControlPoints().end();
ctrl++)
{
for(unsigned int d=0;d<3;d++)
{
if((*ctrl).GetID() != value)
{
std::cout << "Control ID [FAILED]" << (*ctrl).GetID()
<< " v.s. " << value << std::endl;
return EXIT_FAILURE;
}
if((*ctrl).GetPosition()[d]!=value)
{
std::cout << "Control Position [FAILED]" << std::endl;
return EXIT_FAILURE;
}
if((*ctrl).GetPickedPoint()[d]!=-value)
{
std::cout << "Picked Point [FAILED]" << (*ctrl).GetPickedPoint()
<< " v.s. " << -value << std::endl;
return EXIT_FAILURE;
}
if(((*ctrl).GetNormal())[d]!= value)
{
std::cout << "Normal [FAILED]" << std::endl;
return EXIT_FAILURE;
}
// Testing the color of the tube points
if( (*ctrl).GetRed() != value)
{
std::cout << " [FAILED] : CRed : found " << (*ctrl).GetRed()
<< " instead of " << value <<std::endl;
return EXIT_FAILURE;
}
if((*ctrl).GetGreen()!=value+1)
{
std::cout << " [FAILED] : CGreen : found " << (*ctrl).GetGreen()
<< " instead of " << value+1 <<std::endl;
return EXIT_FAILURE;
}
if((*ctrl).GetBlue()!=value+2)
{
std::cout << " [FAILED] : CBlue : found " << (*ctrl).GetBlue()
<< " instead of " << value+2 <<std::endl;
return EXIT_FAILURE;
}
if((*ctrl).GetAlpha()!=value+3)
{
std::cout << " [FAILED] : CAlpha : found " << (*ctrl).GetAlpha()
<< " instead of " << value+3 <<std::endl;
return EXIT_FAILURE;
}
}
value++;
}
ContourType::InterpolatedPointListType::const_iterator inter;
value = 0;
for(inter = dynamic_cast<ContourType*>((*obj).GetPointer())->GetInterpolatedPoints().begin();
inter != dynamic_cast<ContourType*>((*obj).GetPointer())->GetInterpolatedPoints().end();
inter++)
{
for(unsigned int d=0;d<3;d++)
{
if((*inter).GetID()!=value)
{
std::cout << "Interpolated ID [FAILED]" << std::endl;
return EXIT_FAILURE;
}
if((*inter).GetPosition()[d]!=value)
{
std::cout << "Interpolated Position [FAILED]" << std::endl;
return EXIT_FAILURE;
}
// Testing the color of the tube points
if( (*inter).GetRed() != value)
{
std::cout << " [FAILED] : IRed : found " << (*inter).GetRed()
<< " instead of " << value <<std::endl;
return EXIT_FAILURE;
}
if((*inter).GetGreen()!=value+1)
{
std::cout << " [FAILED] : IGreen : found " << (*inter).GetGreen()
<< " instead of " << value+1 <<std::endl;
return EXIT_FAILURE;
}
if((*inter).GetBlue()!=value+2)
{
std::cout << " [FAILED] : IBlue : found " << (*inter).GetBlue()
<< " instead of " << value+2 <<std::endl;
return EXIT_FAILURE;
}
if((*inter).GetAlpha()!=value+3)
{
std::cout << " [FAILED] : IAlpha : found " << (*inter).GetAlpha()
<< " instead of " << value+3 <<std::endl;
return EXIT_FAILURE;
}
}
value++;
}
}
}
std::cout<<" [PASSED]"<<std::endl;
delete mySceneChildren;
std::cout << " [TEST DONE]" << std::endl;
return EXIT_SUCCESS;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -