[vtk-developers] Help with vtkFreeTypeTools::MapTextPropertyToId error...
David Lonie
david.lonie at kitware.com
Wed Mar 25 15:44:28 EDT 2015
On Wed, Mar 25, 2015 at 1:07 PM, Sean McBride <sean at rogue-research.com>
wrote:
> Hi all,
>
> Anyone know vtkFreeTypeTools::MapTextPropertyToId?
>
> This test failure:
> <https://open.cdash.org/testDetails.php?test=314508353&build=3741998>
>
> vtkFreeTypeTools.cxx:634:71: runtime error: left shift of negative value
> -450
>
> Is happening because the author is assuming vtkTextProperty's
> GetOrientation() returns an angle between 0 and 360:
>
> int angle = (vtkMath::Round(tprop->GetOrientation() * 10.0) % 3600) <<
> bits;
>
> when in fact the returned angle can (apparently) be negative.
>
Correct.
> Questions:
>
> 1) vtkTextProperty's GetOrientation() docs say only "Set/Get the text's
> orientation (in degrees)." I guess any range is correct?
>
Yes, values outside of that range should be handled properly.
> 2) is there a utility function somewhere to constrain an angle to 0->360?
> I could not find one...
>
Nor am I. This may need it's own code to handle that, and should fix the
error.
Something like:
int angle = vtkMath::Round(tprop->GetOrientation() * 10. % 3600;
if (angle < 0)
{
angle += 3600;
}
angle << bits;
ought to do the trick without breaking the hash.
Dave
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtk-developers/attachments/20150325/d91792a2/attachment.html>
More information about the vtk-developers
mailing list