[vtkusers] Uneven colors after the vtkButterflySubdivisionFilter
David Gobbi
david.gobbi at gmail.com
Sun Apr 21 15:39:27 EDT 2013
Hi Bill,
I traced the code that is interpolating the scalars, and it led me to
the following function in vtkDataArray.cxx, which is called from
vtkDataArray::InterpolateTuple(). In fact, that is the only place
this function is called from.
template <class T>
inline void vtkDataArrayRoundIfNecessary(double val, T* retVal)
{
*retVal = static_cast<T>((val>=0.0)?(val + 0.5):(val - 0.5));
}
It might be good for us to add a clamp here immediately before the
cast, rather than to trust that the weights will never sum to a value
greater than one.
Either that, or vtkButterflySubdivisionFilter can be modified so that
it normalizes the weights before it interpolates the scalars (i.e. it
would be approximating when computing the points, but would use
normalized weights when computing the scalars). My preference,
though, would be to modify vtkDataArray in order to make the fix more
general.
- David
On Sun, Apr 21, 2013 at 10:12 AM, Bill Lorensen <bill.lorensen at gmail.com> wrote:
> Maybe I have it this time.
>
> Multiple problems:
> 1) First number of points must be used, not number of ploys
> 2) I think color interpolation is overflowing/underflowing the unsigned char
>
> Solution. Use FloatArray for colors. After subdivision, convert the floats
> to unsigned chars, clamping between 0 and 255.
>
> Attached is an example c++ that seems to work.
>
>
>
> On Sun, Apr 21, 2013 at 11:46 AM, Bill Lorensen <bill.lorensen at gmail.com>
> wrote:
>>
>> Oops. I still see problems after that change.
>>
>>
>>
>> On Sun, Apr 21, 2013 at 11:45 AM, Bill Lorensen <bill.lorensen at gmail.com>
>> wrote:
>>>
>>> Found the problem.
>>>
>>> You want to set the point data, but your colors array is filled for
>>> NumberOfPolys. Replace NumberOfPolys with NumberOfPoints and the results
>>> look good.
>>>
>>>
>>>
>>> On Sun, Apr 21, 2013 at 10:43 AM, DivyaS <div.anand141 at gmail.com> wrote:
>>>>
>>>> Bill,
>>>>
>>>> Butterfly subdivision gives me better results(shape) to the actual data
>>>> i'm
>>>> working on. Is there no other way we can get this working? you were
>>>> talking
>>>> about assigned scalar float, single component values, I would like to
>>>> give
>>>> it a try.. could you please give me some details on that.
More information about the vtkusers
mailing list