[vtkusers] Problem with some frequent error in vtk or maybe in Visual Studio 7 .NET 2003

Łukasz Tutaj ltutaj at wp.pl
Wed Aug 3 08:32:18 EDT 2005


Hi again,
I've also get the same error running this program. It's program taken 
from  
http://public.kitware.com/cgi-bin/viewcvs.cgi/*checkout*/Imaging/Testing/Cxx/ImportExport.cxx?root=VTK&content-type=text/plain
with some my changes. I think that my changes aren't the source of problem.
Thanks for any help.
Łukasz

//////////////////////
#include "vtkImageViewer.h"
#include "vtkImageReader.h"
#include "vtkImageImport.h"
#include "vtkImageExport.h"
#include "vtkWindowToImageFilter.h"
#include "vtkPNMWriter.h"

//#include "vtkTestUtilities.h"
//#include "vtkRegressionTestImage.h"

int main( int argc, char *argv[] )
{
 int i,j,k;
 
 //char* fname = vtkTestUtilities::ExpandDataFileName(argc, argv, 
"Data/headsq/quarter");
 char *fname = "D:\\PRACA MAGISTERSKA\\Data\\headsq\\quarter";
 vtkImageReader *reader = vtkImageReader::New();
 reader->SetDataByteOrderToLittleEndian();
 reader->SetDataExtent(0,63,0,63,1,1);
 reader->SetFilePrefix(fname);
 reader->SetDataMask(0x7fff);
 delete [] fname;
 
 // create exporter
 vtkImageExport *exporter = vtkImageExport::New();
 exporter->SetInput(reader->GetOutput());
 exporter->ImageLowerLeftOn();

 // get info from exporter and create array to hold data
 int memsize = exporter->GetDataMemorySize();
 int *dimensions = exporter->GetDataDimensions();
 
 // export the data into the array
 short *data = new short[memsize/sizeof(short)];
 exporter->Export(data);
 cout << "Dimensions " << dimensions[0] << " " <<
     dimensions[1] << " " <<
     dimensions[2] << endl;
 
 // alternative method for getting data
 // short *data = exporter->GetPointerToData();

 // do a little something to the data

 for (i = 0; i < dimensions[2]; i++)
   {
   for (j = 0; j < dimensions[1]; j++)
     {
     for (k = 0; k < dimensions[0]; k++)
       {
       if (k % 10 == 0)
         {
         data[k + dimensions[0]*(j + dimensions[1]*i)] = 0;
         }
       if (j % 10 == 0)
         {
         data[k + dimensions[0]*(j + dimensions[1]*i)] = 1000;
         }
       }
     }
   }

 // create an importer to read the data back in
 vtkImageImport *importer = vtkImageImport::New();
 importer->SetWholeExtent(1,dimensions[0],1,dimensions[1],1,dimensions[2]);
 importer->SetDataExtentToWholeExtent();
 importer->SetDataScalarTypeToShort();
 importer->SetImportVoidPointer(data);


 vtkImageViewer *viewer = vtkImageViewer::New();
 viewer->SetInput(importer->GetOutput());
 viewer->SetZSlice(45);
 viewer->SetColorWindow(2000);
 viewer->SetColorLevel(1000);

 viewer->Render();

 //int retVal = vtkRegressionTestImage( viewer->GetRenderWindow() );
 
 viewer->Delete();
 importer->Delete();
 exporter->Delete();
 reader->Delete();
 
 delete [] data;

// return !retVal;
 return 0;
}
////////////////////////////////

Łukasz Tutaj wrote:

> Hi vtk Users.
>
>    I use Visual Studio 7 .NET 2003 in my programming work. I write 
> some programs for transforming and displaying medical data. In many 
> different cases I get some error: Unhandled exception at 0x10216393 
> (msvcr71d.dll) in DicomRead2.exe: 0xC0000005: Access violation writing 
> location 0x0b6b1000. After debugging I've got to know that the problem 
> appears always in memcpy.asm file in part of code:
> /////////////////////
>        CopyUp:
>        test    edi,11b         ;U - destination dword aligned?
>        jnz     short CopyLeadUp ;V - if we are not dword aligned 
> already, align
>
>        shr     ecx,2           ;U - shift down to dword count
>        and     edx,11b         ;V - trailing byte count
>
>        cmp     ecx,8           ;U - test if small enough for unwind copy
>        jb      short CopyUnwindUp ;V - if so, then jump
>
>        rep     movsd           ;N - move all of our dwords            
>  * <---- here the error appears*
>
>        jmp     dword ptr TrailUpVec[edx*4] ;N - process trailing bytes
> /////////////////
>
> I have this error in this simple program. Using example data from 
> ...\\Data\\headsq\\quarter directory everything is fine, but using 
> DICOM files from ...\\dane100 I always get mentioned above error. In 
> many cases my programs work for example data 
> ...\\Data\\headsq\\quarter directory (providing by vtk authors) but 
> error appears when I put as input DICOM files.
> Thanks for any help.
>
> Łukasz
>
>
> /////////////////
> #include "vtkImageViewer2.h"
> #include "vtkDICOMImageReader.h"
> #include "vtkImageReader.h"
> #include "vtkRenderWindowInteractor.h"
> #define T 1
>
> //#include "vtkTestUtilities.h"
> //#include "vtkRegressionTestImage.h"
>
> int main( int argc, char *argv[] )
> {
> #if T
>    vtkDICOMImageReader *reader = vtkDICOMImageReader::New();
>        reader->SetDirectoryName("D:\\PRACA MAGISTERSKA\\dane100"); // 
> Some DICOM files
> #else
>    vtkImageReader *reader = vtkImageReader::New();
>        reader->ReleaseDataFlagOff();
>        reader->SetDataByteOrderToLittleEndian();
>        reader->SetDataExtent(0,63,0,63,0,92);
>        reader->SetDataSpacing(3.2,3.2,1.5);
>        reader->SetFilePrefix("D:\\PRACA 
> MAGISTERSKA\\Data\\headsq\\quarter");
>        reader->SetDataMask(0x7fff);
> #endif
>        vtkImageViewer2 *viewer = vtkImageViewer2::New();
>        viewer->SetInput(reader->GetOutput());
>        vtkRenderWindowInteractor *iren = 
> vtkRenderWindowInteractor::New();
>        viewer->SetupInteractor(iren);
>        viewer->SetZSlice(45);
>        viewer->SetColorLevel(1000);
>        viewer->SetColorWindow(2000);
>        iren->Initialize();
>        iren->Start();
>              reader->Delete();
>        iren->Delete();
>        viewer->Delete();
>    return 0;
> }
> //////////////////////
>
>
> _______________________________________________
> 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