[vtkusers] file handling

Mathieu Malaterre mathieu.malaterre at kitware.com
Mon Mar 14 14:07:36 EST 2005


Yala,

	Please use the testing framework. For example: 
VTK/Hybrid/Testing/Cxx/TestPlaneWidget.cxx

  char* fname =
     vtkTestUtilities::ExpandDataFileName(argc, argv, "Data/combxyz.bin");
   char* fname2 =
     vtkTestUtilities::ExpandDataFileName(argc, argv, "Data/combq.bin");

   // Start by loading some data.
   //
   vtkPLOT3DReader *pl3d = vtkPLOT3DReader::New();
   pl3d->SetXYZFileName(fname);
   pl3d->SetQFileName(fname2);
   pl3d->SetScalarFunctionNumber(100);
   pl3d->SetVectorFunctionNumber(202);
   pl3d->Update();

   delete [] fname;
   delete [] fname2;


Therefore you have two options:
1. Execute assuming VTK_DATA_ROOT is set:

./bin/HybridCxxTests TestPlaneWidget

2. You don't want to set the VTK_DATA_ROOT:

./bin/HybridCxxTests TestPlaneWidget -D /tmp/VTKData

This is the recommended way (compare to getenv).

HTH
Mathieu

Sean McInerney wrote:
> // methinks this'll work:
> 
> #include <stdlib.h>
> #include <string.h>
> 
> char*       dataRoot = getenv("VTK_DATA_ROOT");
> const char* fileName = "/Data/masonry.bmp";
> char*       pathName = new char [strlen(dataRoot)+strlen(fileName)+1);
> 
> strcpy(pathName, dataRoot);
> strcat(pathName, fileName);
> 
> // Voila!!! ... don't forget to call delete[] on pathName!!!
> 
> David Cole wrote:
> 
>>>
>>> How would you write the line
>>> reader SetFileName "$VTK_DATA_ROOT/Data/masonry.bmp"
>>>
>>> in C++?
>>
>>
>>
>> $VTK_DATA_ROOT represents the environment variable named 
>> VTK_DATA_ROOT. It should be replaced with the location of the VTKData 
>> folder on your system...
>>
>> A search of the current CVS VTK C++ source files for VTK_DATA_ROOT 
>> yields hits in the source file VTK/Rendering/vtkTesting.cxx. See that 
>> file for an example usage of getenv to extract the value of 
>> VTK_DATA_ROOT.
>>
>>
>> Hope this helps,
>> David
>>
> 
> _______________________________________________
> This is the private VTK discussion list. Please keep messages on-topic. 
> Check the FAQ at: http://www.vtk.org/Wiki/VTK_FAQ
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
> 




More information about the vtkusers mailing list