[vtkusers] VTK C++ : How to perform a velocity interpolation computation from a vtkMultiBlockDataSet with celldata?
Guillaume Jacquenot
guillaume.jacquenot at gmail.com
Thu Jan 19 06:32:25 EST 2012
Dear all,
My objective is to retrieve a velocity vector from an interpolation
computation from a vtkMultiBlockDataSet with vtkUnstructuredGrid containing
velocity vectors.
My velocity vectors are located at the center of cells, not the points.
I managed to retrieve the velocity vector from a cell with vtkCellLocator.
However I want more accurate results, and thus perform data interpolation,
depending on the requested point.
For this, I want to use the class vtkInterpolatedVelocityField or
vtkCellLocatorInterpolatedVelocityField
To do so, I see that i have to create an instance of
vtkInterpolatedVelocityField
or vtkCellLocatorInterpolatedVelocityField and use the method addDataSet to
feed this instance.
I have tried to do so with dataSet contained in my vtkMultiBlockDataSet.
However, the method FunctionValues always returned "Can't evaluate
dataset". I figured out that message was sent because my data are located
at cell-centered not point-centered.
Therefore I want to convert my cell-centered data to point-centered data.
I know that I have to use the class *vtkCellDataToPointData*, but I don't
manage to retrieve the result and send it as input to an instance of
vtkInterpolatedVelocityField
or vtkCellLocatorInterpolatedVelocityField.
*vtkCellDataToPointData is a sub-class of vtkAlgorithm*, and I have seen it
is nice to work with inputport, outputport methods.
However, class vtkInterpolatedVelocityField is a sub-class of vtkFiltering,
and does not have such connexion methods.
The general question is how to pass result from an instance of
vtkCellDataToPointData
to an instance of vtkInterpolatedVelocityField
I have tried unsuccessfully the method GetOutputDataObject and
GetUnstructuredGridOutput
on a instance of vtkCellDataToPointData . Cause the program to crash.
dataObj = c2p->GetOutputDataObject(0);
unstructuredGrid = c2p->GetUnstructuredGridOutput();
More precisely, my questions are the followings:
- Can I add "inplace" point data to a vtkMultiBlockDataSet from the cell
data? That means that I add point data to my
vtkMultiBlockDataSetcontaining cell data, with algorithm
vtkCellDataToPointData. If possible, I guess I can use the method
addDataset from vtkInterpolatedVelocityField.
- Can I work directy on a vtkMultiBlockDataSet with vtkCellDataToPointData on
my function presented below, ie use c2p->SetInput(vtkMultiBlockDataSet)
where c2p is a vtkCellDataToPointData?
Below is the function I want to develop with VTK 5.8. It compiles, but
crashes at run time.
The vtkOuputWindow reports a problem with vtkExecutive at line 756.cxx
vtkStreamingDemandDrivenPipeline : Algorithm vtkCellDataToPointData ...
However on Windows, I cant read all the error message, and report it here.
For time being, the function does not return anything. I don't know for
time being, if it will return a modified version of multiBlockDataSet, with
cell data, or if it will return an instance of vtkInterpolatedVelocityField
void convertCellDataToPointData(vtkSmartPointer<vtkMultiBlockDataSet> &
multiBlockDataSet)
{
vtkSmartPointer<vtkCellDataToPointData> c2p =
vtkSmartPointer<vtkCellDataToPointData>::New();
c2p->DebugOn();
c2p->SetInput(multiBlockDataSet);
c2p->PassCellDataOff();
c2p->Update();
std::cout<<"c2p->Print(std::cout)"<<std::endl;
c2p->Print(std::cout);
c2p->UpdateInformation();
c2p->UpdateWholeExtent();
std::cout << "c2p->GetTotalNumberOfInputConnections = " <<
c2p->GetTotalNumberOfInputConnections()<<std::endl;
std::cout << "c2p->GetNumberOfInputPorts = " <<
c2p->GetNumberOfInputPorts()<<std::endl;
std::cout << "c2p->GetNumberOfOutputPorts = " <<
c2p->GetNumberOfOutputPorts()<<std::endl;
vtkSmartPointer<vtkDataObject> dataObj =
vtkSmartPointer<vtkDataObject>::New();
std::cout <<"H1"<<std::endl;
dataObj = c2p->GetOutputDataObject(0);
std::cout <<"H2"<<std::endl;
dataObj->Print(std::cout); // Crash vtkStreamingDemandDrivenPipeline :
Algorithm vtkCellDataToPointData ...
vtkSmartPointer<vtkUnstructuredGrid> unstructuredGrid =
vtkSmartPointer<vtkUnstructuredGrid>::New();
unstructuredGrid = c2p->GetUnstructuredGridOutput();
std::cout <<"H3"<<std::endl;
std::cout<<"unstructuredGrid->GetNumberOfCells =
"<<unstructuredGrid->GetNumberOfCells()<<std::endl; // Crash
vtkStreamingDemandDrivenPipeline : Algorithm vtkCellDataToPointData ...
std::cout<<"unstructuredGrid->GetNumberOfPoints =
"<<unstructuredGrid->GetNumberOfPoints()<<std::endl;
std::cout <<"H4"<<std::endl;
unstructuredGrid->Print(std::cout);
std::cout <<"H5"<<std::endl;
}
I work with version 5.8 of VTK. I use Win32.
Thanks for considering my problem.
Maybe an example can be generated on the VTK wiki from my problem.
Guillaume Jacquenot
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20120119/e8b6b295/attachment.htm>
More information about the vtkusers
mailing list