VTKExamples icon indicating copy to clipboard operation
VTKExamples copied to clipboard

Possible error on python ElevationBandsWithGlyphs example

Open NahomKidane opened this issue 6 years ago • 3 comments

VTKExamples/Python/Visualization/ElevationBandsWithGlyphs

On ReverseLUT, I think we also need to reverse the annotations. Fixed by add the line "revList = reversed(list(range(t + 1))) after the second t assignment.

def ReverseLUT(lut): """ Create a lookup table with the colors reversed. :param: lut - An indexed lookup table. :return: The reversed indexed lookup table. """ lutr = vtk.vtkLookupTable() lutr.DeepCopy(lut) t = lut.GetNumberOfTableValues() - 1 revList = reversed(list(range(t + 1))) for i in revList: rgba = [0, 0, 0] v = float(i) lut.GetColor(v, rgba) rgba.append(lut.GetOpacity(v)) lutr.SetTableValue(t - i, rgba) t = lut.GetNumberOfAnnotatedValues() - 1
------>revList = reversed(list(range(t + 1)))<------------- for i in revList: lutr.SetAnnotation(t - i, lut.GetAnnotation(i)) return lutr

NahomKidane avatar Mar 14 '18 03:03 NahomKidane

Thanks, we'll take a look.

On Mar 13, 2018 8:34 PM, "Nahom Kidane" [email protected] wrote:

VTKExamples/Python/Visualization/ElevationBandsWithGlyphs

On ReverseLUT, I think we also need to reverse the annotations. Fixed by add the line "revList = reversed(list(range(t + 1))) after the second t assignment.

def ReverseLUT(lut): """ Create a lookup table with the colors reversed. :param: lut - An indexed lookup table. :return: The reversed indexed lookup table. """ lutr = vtk.vtkLookupTable() lutr.DeepCopy(lut) t = lut.GetNumberOfTableValues() - 1 revList = reversed(list(range(t + 1))) for i in revList: rgba = [0, 0, 0] v = float(i) lut.GetColor(v, rgba) rgba.append(lut.GetOpacity(v)) lutr.SetTableValue(t - i, rgba) t = lut.GetNumberOfAnnotatedValues() - 1 ------>revList = reversed(list(range(t + 1)))<------------- for i in revList: lutr.SetAnnotation(t - i, lut.GetAnnotation(i)) return lutr

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/lorensen/VTKExamples/issues/140, or mute the thread https://github.com/notifications/unsubscribe-auth/AAUFDHIo5xNQUmXjVgItUN2VhYpxlHrGks5teI-pgaJpZM4SpyYY .

lorensen avatar Mar 14 '18 05:03 lorensen

I'll check it out sometime tomorrow.

Andrew

Andrew Maclean

On Wed, 14 Mar 2018, 16:23 Bill Lorensen [email protected] wrote:

Thanks, we'll take a look.

On Mar 13, 2018 8:34 PM, "Nahom Kidane" [email protected] wrote:

VTKExamples/Python/Visualization/ElevationBandsWithGlyphs

On ReverseLUT, I think we also need to reverse the annotations. Fixed by add the line "revList = reversed(list(range(t + 1))) after the second t assignment.

def ReverseLUT(lut): """ Create a lookup table with the colors reversed. :param: lut - An indexed lookup table. :return: The reversed indexed lookup table. """ lutr = vtk.vtkLookupTable() lutr.DeepCopy(lut) t = lut.GetNumberOfTableValues() - 1 revList = reversed(list(range(t + 1))) for i in revList: rgba = [0, 0, 0] v = float(i) lut.GetColor(v, rgba) rgba.append(lut.GetOpacity(v)) lutr.SetTableValue(t - i, rgba) t = lut.GetNumberOfAnnotatedValues() - 1 ------>revList = reversed(list(range(t + 1)))<------------- for i in revList: lutr.SetAnnotation(t - i, lut.GetAnnotation(i)) return lutr

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/lorensen/VTKExamples/issues/140, or mute the thread < https://github.com/notifications/unsubscribe-auth/AAUFDHIo5xNQUmXjVgItUN2VhYpxlHrGks5teI-pgaJpZM4SpyYY

.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/lorensen/VTKExamples/issues/140#issuecomment-372908285, or mute the thread https://github.com/notifications/unsubscribe-auth/AIJ4OyTO75HRxp8QuZpYEFsyouwl7kqJks5teKk8gaJpZM4SpyYY .

ajpmaclean avatar Mar 14 '18 07:03 ajpmaclean

@NahomKidane All fixed, please see: https://github.com/lorensen/VTKExamples/pull/142

Thankyou so much for finding this. The C++ code was correct, however I must have forgotten to update the Python code.

ajpmaclean avatar Mar 14 '18 22:03 ajpmaclean