Editing
Software Plugins and Codes
(section)
Jump to navigation
Jump to search
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
====Copy your data to the output, instead of connecting the output to a VTK filter==== I don't understand why this is sometimes required, but using ShallowCopy seems be necessary in certain cases. Note there should in theory be no performance impact to using ShallowCopy (no new copy of the data will be made in memory). Here is an example. <source lang="c"> int vtkAIMReaderPlugin::RequestData (vtkInformation*, vtkInformationVector**, vtkInformationVector* outputVector) { // Make sure FileName is set if (!this->FileName) { vtkErrorMacro("A Filename must be specified"); return 0; } vtkSmartPointer<vtkAIMReader> reader = vtkSmartPointer<vtkAIMReader>::New(); reader->SetFileName (FileName); reader->UpdateInformation(); // Not sure if this is redundant reader->Update(); vtkImageData* data = reader->GetOutput(); vtkImageData* out = vtkImageData::GetData (outputVector); if (!out) { return 0; } // Not sure why we need a temporary object for the caster, but without it, // an error occurs in paraview. vtkSmartPointer<vtkImageData> temp = vtkSmartPointer<vtkImageData>::New(); // Convert to float, regardless of original type vtkSmartPointer<vtkImageCast> caster = vtkSmartPointer<vtkImageCast>::New(); caster->SetInput (data); caster->SetOutput (temp); caster->SetOutputScalarType (VTK_FLOAT); caster->Update(); out->ShallowCopy(temp); // Must have a name for the scalar data otherwise paraview can do nothing // with it. out->GetPointData()->GetScalars()->SetName("AIMData"); return 1; } </source> This is the error that you will get if you fail to use ShallowCopy and just set the output of caster in the above example to 'out': ERROR: In /home/eric/source/paraview-3.6.1/Servers/Common/vtkPVDataInformation.cxx, line 586 vtkPVDataInformation (0x2c391a0): Could not cast object to a known data set: vtkAlgorithmOutput [[Image:Redirect.jpg|15px]] [[#top|''Return to Contents'']] or [[Main_Page|''Return to Main Page'']]
Summary:
Please note that all contributions to bone.wiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
BoneWiki:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Navigation menu
Personal tools
Not logged in
Talk
Contributions
Log in
associated-pages
Page
Discussion
English
Views
Read
Edit
View history
More
Search
Navigation
Main page
Documents
Recent changes
Help
Tools
What links here
Related changes
Page information