[vtkusers] Retrieve vector data from a cell.
Karl Mårtensson
karma140 at student.liu.se
Thu Apr 28 05:17:01 EDT 2005
Abstract:
i want to retrieve a vector from a specific position in a vector field..
Concret:
We have read data using vktStructuredPoints (example data found below)
I now want to get the data from a specific point for instance (2.8, 2.2,
0.0)
To do this I use:
vtkCell * cell = structuredPoints->FindAndGetCell(x, NULL, -1, tol2, subId,
pcoords, weights);
the retrieve the cell that contains the data. This far there it works fine.
As long as I specify a position
within our vector field I will retrieve a valid cell.
Now I want to access the data from either one of the points in the cell
(closes neighbor) or by interpolation the data from all the points in the
cell using the point weights. Could anyone give me a hint here?
I guess this is pretty basic for most of you but we havent managed to
figure it out.
I would be glad for any suggestion!
Best regards
/ Karl Mårtensson
KODSNUTT:
vtkStructuredPoints * structuredPoints = reader->GetOutput();
int numberOfPoints = structuredPoints->GetNumberOfPoints();
double x[3];
x[0] = position.x();
x[1] = position.y();
x[2] = position.z();
double tol2 = 1;
int subId;
double pcoords[3];
double weights[3];
vtkCell * cell = structuredPoints->FindAndGetCell(x, NULL, -1, tol2,
subId, pcoords, weights);
int numberOfPointsInCell;
vtkPoints* points;
vtkDataArray * dataArray;
int numberOfComponents;
int dataType;
double * tuple0;
double * tuple1;
double * tuple2;
double * tuple3;
if (cell){
numberOfPointsInCell = cell->GetNumberOfPoints ();
points = cell->GetPoints();
dataArray = points->GetData();
numberOfComponents = dataArray->GetNumberOfComponents ();
dataType = dataArray->GetDataType();
// hur få vi ut datan från cellen på ett användbart sätt t.ex.
double[3]
}
DATASNUTT:
# vtk DataFile Version 1.0
Kristin Lilja & Karl Martensson 050421, Andreas Sundelöf "strömdata till
vtk-format"
ASCII
DATASET STRUCTURED_POINTS
DIMENSIONS 10 10 1
ORIGIN 0.0 0.0 0.0
ASPECT_RATIO 1.0 1.0 1.0
POINT_DATA 100
VECTORS vectors float
1.0000 2.0000 3.0000
1.0000 2.0000 3.0000
1.0000 2.0000 3.0000
1.0000 2.0000 3.0000
1.0000 2.0000 3.0000
1.0000 2.0000 3.0000
1.0000 2.0000 3.0000
1.0000 2.0000 3.0000
1.0000 2.0000 3.0000
1.0000 2.0000 3.0000
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20050428/dd2cc81a/attachment.htm>
More information about the vtkusers
mailing list