[vtkusers] Scalar value minima in PolyData
Kevin H. Hobbs
hobbsk at ohiou.edu
Wed Nov 21 09:54:32 EST 2007
On Wed, 2007-11-21 at 08:40 -0500, Kevin H. Hobbs wrote:
> Is there a better way to find all of the positions of the scalar value
> minima in a PolyData than to :
> loop over all of the points
> loop over all of the cells the point is in
> loop over all of the other points in the cell
> compare the values of the other points to the first points value
> save the points location if it is value is less than all of its neighbor's values.
>
For example the code below is rather confusing because it is so loopy.
// Find minima in sphere cut
vtkPolyData * sphere_poly = sphere_cutter->GetOutput();
sphere_poly->BuildLinks();
vtkPoints * sphere_points = sphere_poly->GetPoints();
vtkIdType num_points = sphere_points->GetNumberOfPoints();
vtkDataArray * point_scalars
= sphere_poly->GetPointData()->GetScalars();
vtkIdType point;
vtkIdList * point_cells = vtkIdList::New();
vtkIdList * cell_points = vtkIdList::New();
for (point = 0; point < num_points; ++point )
{
// What is the points value?
double value;
point_scalars->GetTuple(point, &value);
// Assume the point is a minima.
int minima = 1;
// What cells is this point in.
sphere_poly->GetPointCells( point, point_cells );
vtkIdType num_cells
= point_cells->GetNumberOfIds();
vtkIdType cell;
for ( cell = 0; cell < num_cells; ++cell )
{
vtkIdType neighbor_cell;
neighbor_cell = point_cells->GetId( cell );
sphere_poly->GetCellPoints(
neighbor_cell,
cell_points );
vtkIdType num_cell_points
= cell_points->GetNumberOfIds();
vtkIdType neighbor_point;
for (
neighbor_point = 0;
neighbor_point < num_cell_points;
++neighbor_point )
{
vtkIdType neighbor_point_id
= cell_points->GetId(neighbor_point);
double neighbor_value;
point_scalars->GetTuple(neighbor_point_id, &neighbor_value);
if ( neighbor_value < value )
minima = 0;
}
}
// Is the point actually a minima?
if ((value < stop_time) && ( minima == 1 ))
{
// What is the point's location?
double * pcoord;
pcoord = sphere_poly->GetPoint( point );
std::cout
<< pcoord[0] << " "
<< pcoord[1] << " "
<< pcoord[2] << std::endl;
}
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20071121/9b0f4773/attachment.pgp>
More information about the vtkusers
mailing list