[vtkusers] Uneven colors after the vtkButterflySubdivisionFilter

Bill Lorensen bill.lorensen at gmail.com
Sun Apr 21 15:43:20 EDT 2013


Performance could be an issue.


On Sun, Apr 21, 2013 at 3:39 PM, David Gobbi <david.gobbi at gmail.com> wrote:

> 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.
>



-- 
Unpaid intern in BillsBasement at noware dot com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20130421/62346b63/attachment.htm>


More information about the vtkusers mailing list