[vtkusers] Error porting from VTK 5.10 to VTK 6.1
francesco.argese
kekko84 at gmail.com
Thu Nov 5 11:55:21 EST 2015
Hello,
I'm having problems trying to port an application from VTK 5.10 to VTK 6.1.
The application is a simple LSDyna reader which loads the frames of the
animation and stores them in a vector of actors; then it uses them for a
conversion.
The only modification needed to compile the code with VTK 6.1 is the
following one:
#ifdef __VTK_5__
mapper.at(k)->SetInput(myData.at(k).GetPointer());
#else
mapper.at(k)->SetInputData(myData.at(k).GetPointer());
#endif
The error at runtime is generated when I call SetMapper function.
The entire code with a note on the runtime error is below.
What could be the problem?
Francesco
---------------------------- CODE (BEGIN)
-----------------------------------------
int main(int argc, char **argv)
{
// 0) Parse command line arguments. First argument is path of dir
containing LS-DYNA files
if(argc != 2)
{
std::cout << "Usage: " << argv[0] << " directory path" << std::endl;
return EXIT_FAILURE;
}
std::string dir= argv[1]; // Save command-line argument to dir variable
// 1) Use lsDyna reader to read file from lsDyna output
vtkSmartPointer<vtkLSDynaReader> reader =
vtkSmartPointer<vtkLSDynaReader>::New();
reader->SetFileName(dir.c_str());
reader->Update();
// Extract a vector of actors from lsDynaReader
std::vector<std::vector<vtkSmartPointer<vtkActor>>> vectorOfFrames;
// every frame is a vector of actor
for(unsigned int i = 0; i < reader->GetNumberOfTimeSteps(); i++) // loop
over frames
{
// Set frame number and update
reader->SetTimeStep(i);
reader->Update();
vtkMultiBlockDataSet* mbds = reader->GetOutput();
std::vector<vtkSmartPointer<vtkDataSetMapper>> mapper;
std::vector<vtkSmartPointer<vtkDataSet>> myData;
std::vector<vtkSmartPointer<vtkActor>> actorsForThisFrame;
for(unsigned int k=0; k<=mbds->GetNumberOfBlocks(); k++)
{
// Define a new mapper (process object to be related to the new vtkActor)
and add it to vector of mappers
vtkSmartPointer<vtkDataSetMapper> newMapper =
vtkSmartPointer<vtkDataSetMapper>::New();
// newMapper->SetScalarRange(0, 10);
mapper.push_back(newMapper);
// Take vtkDataSet extracted from multiBlockDataset extracted from
lsDynaReader
myData.push_back((vtkDataSet *)mbds->GetBlock(k));
// Set dataset inserted as last mapper input
#ifdef __VTK_5__
mapper.at(k)->SetInput(myData.at(k).GetPointer());
#else
mapper.at(k)->SetInputData(myData.at(k).GetPointer());
#endif
// add a new vtkactor to vector of vtkActors
actorsForThisFrame.push_back(vtkSmartPointer<vtkActor>::New());
// Set mapper created as mapper of the vtkActor
actorsForThisFrame.at(k)->SetMapper(mapper.at(k).GetPointer()); // Here
there is the run time error!!!
}
vectorOfFrames.push_back(actorsForThisFrame);
}
---------------------------- CODE (END)
-----------------------------------------
--
View this message in context: http://vtk.1045678.n5.nabble.com/Error-porting-from-VTK-5-10-to-VTK-6-1-tp5734818.html
Sent from the VTK - Users mailing list archive at Nabble.com.
More information about the vtkusers
mailing list