[vtkusers] Access violation error while writing to vtkXMLPolyDataWriter ! possible problem in vtkDataArray !

M.Salman at surrey.ac.uk M.Salman at surrey.ac.uk
Thu Mar 22 15:42:06 EDT 2007


Hello All,
I wonder if  somebody could help me :(


When I try to write a polydata into  file.vtp, it gives me error of access violation and a very familiar windows message appears :
basic.exe has encountered a problem and needs to close,we are sorry for ....
When I press the debug button on this small message window,it opens up a debug session and takes me to the source code of 
...\Common\vtkDataArray.cxx on Line 73

const char* vtkDataArray::GetName()
{
  return this->Name;
}

when I try to execute return sttement, I get the error message 
"Unhandled exception in main.exe: 0x000005 access violation"
So, I presume this is the place where problem occurs.But, I couldnt work out what the problem is.Can anybody help me what the problem can be.


This is a simple form of my code :

//reading in

	vtkXMLPolyDataReader *reader1 = vtkXMLPolyDataReader::New();
	reader1->SetFileName("conemodel.vtp");
	vtkPolyData *data =reader1->GetOutput();
	


	vtkPoints* pointSet = vtkPoints->New();


//	loaded all the point-data of  data
        vtkPoints * pointSet = vtkPoints::New();
	
	double pointDouble[3];
        float pointfloat[3];
				
//Load pointSet from polydata  
        for ( i =0; i< (data->GetNumberOfPoints());i++)
	 {


           data->GetPoint(i,pointDouble);


	   pointFloat[0]=pointDouble[0];// Note: In the source code available on vtk website, vtkPolyData::GetPoint()takes double                 
                                        //as argument while vtkPoints::InsertPoint() takes float as argument 
           pointFloat[1]=pointDouble[1];
	   pointFloat[2]=pointDouble[2];

	   pointSet->InsertPoint(i,pointFloat);
					
	}

// processing				


       for loop
       {
	replacePoint(newPoint,OldPoint,pointSet);// user defined function, using vtkPoints::setPoints()
	data->SetPoints(pointSet);
       }
	
//writing

	vtkXMLPolyDataWriter *writer = vtkXMLPolyDataWriter::New();
				writer->SetInput(data);
				writer1->SetDataModeToAscii();
				writer1->SetFileName("result.vtp");
				writer1->Write();  ===============================>here the problem occurs



Any thoughts, I am desperately stuck at this point.Any help will be appreciated a lot 

Best Regards,

M.Salman 
University of Surrey,U.K.
                                                                                                     

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20070322/fd860773/attachment.htm>


More information about the vtkusers mailing list