create the source data
| 928 | |
| 929 | // create the source data |
| 930 | static vtkImageData* CreateData( |
| 931 | const std::string& sourceName, const int scalarType, const int size[3]) |
| 932 | { |
| 933 | vtkImageData* output = nullptr; |
| 934 | |
| 935 | if (sourceName == "gaussian") |
| 936 | { |
| 937 | vtkSmartPointer<vtkImageGaussianSource> source = vtkSmartPointer<vtkImageGaussianSource>::New(); |
| 938 | source->SetWholeExtent(0, size[0] - 1, 0, size[1] - 1, 0, size[2] - 1); |
| 939 | source->SetCenter(0.5 * (size[0] - 1), 0.5 * (size[1] - 1), 0.5 * (size[2] - 1)); |
| 940 | int maxdim = (size[0] > size[1] ? size[0] : size[1]); |
| 941 | maxdim = (maxdim > size[2] ? maxdim : size[2]); |
| 942 | source->SetStandardDeviation(0.25 * (maxdim - 1)); |
| 943 | source->SetMaximum(255.0); |
| 944 | |
| 945 | vtkSmartPointer<vtkImageCast> cast = vtkSmartPointer<vtkImageCast>::New(); |
| 946 | cast->SetInputConnection(source->GetOutputPort()); |
| 947 | cast->SetOutputScalarType(scalarType); |
| 948 | cast->Update(); |
| 949 | |
| 950 | output = cast->GetOutput(); |
| 951 | output->Register(nullptr); |
| 952 | } |
| 953 | else if (sourceName == "noise") |
| 954 | { |
| 955 | vtkSmartPointer<vtkImageNoiseSource> source = vtkSmartPointer<vtkImageNoiseSource>::New(); |
| 956 | source->SetMinimum(0.0); |
| 957 | source->SetMinimum(255.0); |
| 958 | source->SetWholeExtent(0, size[0] - 1, 0, size[1] - 1, 0, size[2] - 1); |
| 959 | |
| 960 | vtkSmartPointer<vtkImageCast> cast = vtkSmartPointer<vtkImageCast>::New(); |
| 961 | cast->SetInputConnection(source->GetOutputPort()); |
| 962 | cast->SetOutputScalarType(scalarType); |
| 963 | cast->Update(); |
| 964 | |
| 965 | output = cast->GetOutput(); |
| 966 | output->Register(nullptr); |
| 967 | } |
| 968 | else if (sourceName == "mandelbrot") |
| 969 | { |
| 970 | vtkSmartPointer<vtkImageMandelbrotSource> source = |
| 971 | vtkSmartPointer<vtkImageMandelbrotSource>::New(); |
| 972 | source->SetWholeExtent(0, size[0] - 1, 0, size[1] - 1, 0, size[2] - 1); |
| 973 | |
| 974 | vtkSmartPointer<vtkImageCast> cast = vtkSmartPointer<vtkImageCast>::New(); |
| 975 | cast->SetInputConnection(source->GetOutputPort()); |
| 976 | cast->SetOutputScalarType(scalarType); |
| 977 | cast->Update(); |
| 978 | |
| 979 | output = cast->GetOutput(); |
| 980 | output->Register(nullptr); |
| 981 | } |
| 982 | else if (sourceName == "grid") |
| 983 | { |
| 984 | vtkSmartPointer<vtkImageGridSource> source = vtkSmartPointer<vtkImageGridSource>::New(); |
| 985 | source->SetDataExtent(0, size[0] - 1, 0, size[1] - 1, 0, size[2] - 1); |
| 986 | source->SetLineValue(255.0); |
| 987 | source->SetFillValue(0.0); |
no test coverage detected