[vtk-developers] Automatic input for examples?
Bill Lorensen
bill.lorensen at gmail.com
Wed Jan 13 19:47:05 EST 2010
Looks good, but the testing infrastructure allows the addition of a
trailing -I flag, so you should test argc < 2.
On the other hand, if we start mucking up the examples with test code,
we they start looking more like tests which is something that started
this whole thing.
For now, I would not add the additional code. When the examples are
run as tests, the ADD_TEST command provides the data on the command
line.
ADD_TEST(${KIT}-Finance ${EXECUTABLE_OUTPUT_PATH}/${KIT}CxxTests
TestFinance ${VTK_DATA_ROOT}/Data/financial.txt)
Bill
On Wed, Jan 13, 2010 at 6:35 PM, David Doria <daviddoria+vtk at gmail.com> wrote:
> What do you guys think of using something like this for examples which
> require an input file:
>
> vtkstd::string inputFilename;
>
> bool hasVTKData = false;
> #ifdef VTK_DATA_ROOT
> hasVTKData = true;
> #endif
> if(argc != 2 && !hasVTKData) //if the user did not pass the right arguments
> // and doesn't have VTKData
> {
> cout << "Required arguments: InputFilename" << endl;
> return EXIT_FAILURE;
> }
>
> if(argc != 2 && hasVTKData) // the user didn't pass the right arguments, but
> // does have VTKData
> {
> inputFilename = vtkstd::string(VTK_DATA_ROOT) + "/Data/political.vtp";
> cout << "Using file " << inputFilename << " from VTKData." << endl;
> }
>
> if(argc == 2)//the user passed the correct arguments
> {
> inputFilename = argv[1];
> cout << "Using file " << inputFilename << " from command line." << endl;
> }
>
> This way if the user wants to use his own data file, he can use it,
> but if he does not, it will automatically grab a reasonable file from
> VTKData.
>
> Clearly we wouldn't want to clutter up the examples with all of that
> code, but it could easily be wrapped into a function.
>
> Thoughts?
>
> Thanks,
>
> David
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
>
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtk-developers
>
>
More information about the vtk-developers
mailing list