[vtkusers] How to get the IDs of min and max from a GetRange() ?

Cory Quammen cory.quammen at kitware.com
Tue Jul 7 17:39:55 EDT 2015


You can use the LookupValue() member function, e.g.,

// Assuming vtkScalars is a subclass of vtkDataArray
minIndex = vtkScalars.LookupValue(minValue)
maxIndex = vtkScalars.LookupValue(maxValue)

This will do the scanning David mentioned and return (probably) the first
index that matches the value you are querying.

There is even a variant that puts all the IDs with the query value in a
vtkIdList. See

http://www.vtk.org/doc/release/6.2/html/classvtkDataArrayTemplate.html#aefa527440fb06df9da217831f2bf3704

Hope that helps,
Cory

On Tue, Jul 7, 2015 at 3:35 PM, David Cole via vtkusers <vtkusers at vtk.org>
wrote:

> 0 0 1 2 8 9 10 9 0 0 0 9 10 9 8 6 4 3 0 0
>
>   What's the index of 10?
>
> :-P
>
>
> You'll have to scan looking for the first or last index, I think,
> since, in general, the min and max may occur any number of times in a
> data set.
>
> HTH,
> David C.
>
>
>
>
> On Tue, Jul 7, 2015 at 4:30 PM, mightos <mightos at gmail.com> wrote:
> > Hello
> >
> > Let's say I have a vtkScalars with 100000 values.
> > I would like to know the minimum and maximum values and their position in
> > the vtkScalars.
> >
> > I currently use vtkScalars.GetRange()[0] to get the minimum value and
> > vtkScalars.GetRange()[1] for the maximum. However, I was wondering how I
> > could get the indexes from that.
> >
> > Any help is welcome :)
> >
> >
> >
> > --
> > View this message in context:
> http://vtk.1045678.n5.nabble.com/How-to-get-the-IDs-of-min-and-max-from-a-GetRange-tp5732756.html
> > Sent from the VTK - Users mailing list archive at Nabble.com.
> > _______________________________________________
> > Powered by www.kitware.com
> >
> > Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
> >
> > Please keep messages on-topic and check the VTK FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
> >
> > Search the list archives at: http://markmail.org/search/?q=vtkusers
> >
> > Follow this link to subscribe/unsubscribe:
> > http://public.kitware.com/mailman/listinfo/vtkusers
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the VTK FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
>
> Search the list archives at: http://markmail.org/search/?q=vtkusers
>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/vtkusers
>



-- 
Cory Quammen
R&D Engineer
Kitware, Inc.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20150707/4e50de0a/attachment.html>


More information about the vtkusers mailing list