[vtkusers] File Type Verification in Batch (Weird Problem)

Matheus Viana vianamp at gmail.com
Mon Oct 29 21:48:39 EDT 2012


Hi David, thanks for replying.

TYPE and filename are just:

int *TYPE = new TYPE[200];
AnsiString *filename = new AnsiString[200];

I guess the problem is not there.

Actually I've just change the code to:

for (i = 0; i < 200; i++) {
      vtkSmartPointer<vtkDataReader> Reader =
vtkSmartPointer<vtkDataReader>::New();
      Reader -> SetFileName(filename[i].c_str());
if (Reader -> IsFileValid ("structured_points")) TYPE[i] = 0;
if (Reader -> IsFileValid ("polydata"))              TYPE[i] = 1;
}

and it is working now.

But still, I have no idea why the first version crashes.

-m
*Matheus Viana*
*Postdoctoral Research Employee*
*Developmental and Cell Biology*
*University of California Irvine*
*
**
*



2012/10/29 David Doria <daviddoria at gmail.com>

> On Mon, Oct 29, 2012 at 9:22 PM, matheus_viana <vianamp at gmail.com> wrote:
> > Hi Guys!
> >
> > I wanna check the file format of a set of .vtk files. They can be either
> > StructuredPoints or PolyData files.
> >
> > So, I wrote this simple code:
> >
> > for (i = 0; i < 200; i++) {
> >         vtkSmartPointer<vtkDataReader> Reader =
> > vtkSmartPointer<vtkDataReader>::New();
> >         Reader -> SetFileName(filename[i].c_str());
> >         Reader -> OpenVTKFile();
> >         if (Reader->IsFileStructuredPoints()) {
> >                 TYPE[i] = 0;
> >         } else {
> >                 TYPE[i] = 1;
> >         }
> >         Reader -> CloseVTKFile();
> > }
> >
> > The program always crashes when i = 46. No problems with the file names.
> >
> > Do you guys have any idea?
> >
> > Thanks in advance,
> > Matheus
>
> You have not shown how you have allocated TYPE. You also have not
> shown how long the filename array is. I would suggest stepping through
> with a debugger to see where it crashes - that might give you a hint
> as to what is wrong.
>
> David
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20121029/c8a30159/attachment.htm>


More information about the vtkusers mailing list