[vtkusers] Uneven colors after the vtkButterflySubdivisionFilter

Bill Lorensen bill.lorensen at gmail.com
Sun Apr 21 08:00:45 EDT 2013


David,

Butterfly is approximating. The vertices it generates do not lie on the
original surface.


On Sat, Apr 20, 2013 at 6:31 PM, David Gobbi <david.gobbi at gmail.com> wrote:

> The vtkProbeFilter works fine with RGB scalars, doesn't it?  So it
> should be possible to put a probe filter after the subdivision filter
> to re-interpolate the scalars from the original data set.
>
> On Sat, Apr 20, 2013 at 3:51 PM, Bill Lorensen <bill.lorensen at gmail.com>
> wrote:
> > I was able to duplicate your problem. I believe the problem is trying to
> > approximate the unsigned char 3-component colors. Butterfly is an
> > approximating subdivision scheme, while loop is an interpolating scheme.
> I
> > think if you assigned scalar float, single component values and mapper
> them
> > through a lookup table you would get good results. But I'm not sure that
> > would accomplish what you want.
> >
> >
> >
> > On Sat, Apr 20, 2013 at 2:23 PM, Bill Lorensen <bill.lorensen at gmail.com>
> > wrote:
> >>
> >> This better. Just to be sure, I assume this code also produces bad
> >> results?
> >>
> >>
> >>
> >> On Sat, Apr 20, 2013 at 1:39 PM, DivyaS <div.anand141 at gmail.com> wrote:
> >>>
> >>> Sure, please check this code - I have removed all the unnecessary
> code. I
> >>> have added comments for each of the steps.
> >>>
> >>>             //Defining a cylinder source.
> >>>             vtkCylinderSource cylinderSource = vtkCylinderSource.New();
> >>>             cylinderSource.Update();
> >>>
> >>>             vtkTriangleFilter triangles = vtkTriangleFilter.New();
> >>>             triangles.SetInput(cylinderSource.GetOutput());
> >>>             triangles.Update();
> >>>             vtkPolyData originalMesh;
> >>>             originalMesh = triangles.GetOutput();
> >>>
> >>>             vtkUnsignedCharArray colors = vtkUnsignedCharArray.New();
> >>>             colors.SetNumberOfComponents(3);
> >>>             colors.SetNumberOfTuples(originalMesh.GetNumberOfPolys());
> >>>             colors.SetName("Colors");
> >>>
> >>>             //Creating an array to store the values according to which
> >>> the
> >>> colors are selected.
> >>>             //Values are inserted for each of the points in the
> polydata
> >>>             int[] colorAT = new int[originalMesh.GetNumberOfPolys()];
> >>>             for (int i = 0; i < originalMesh.GetNumberOfPolys(); i++)
> >>>             {
> >>>                 colorAT[i] = i;
> >>>             }
> >>>
> >>>             int activationTime;
> >>>             //Loop to select colors for each of the points in the
> >>> polydata.
> >>>             for (int i = 0; i < originalMesh.GetNumberOfPolys(); i++)
> >>>             {
> >>>                 activationTime = colorAT[i];
> >>>                 if (activationTime > 0 && activationTime < 5)
> >>>                 {
> >>>                     //Black
> >>>                     colors.InsertTuple3(i, 255, 255, 0);
> >>>                 }
> >>>                 else if (activationTime > 4 && activationTime < 10)
> >>>                 {
> >>>                     //Blue
> >>>                     colors.InsertTuple3(i, 0, 0, 255);
> >>>                 }
> >>>                 else if (activationTime > 9 && activationTime < 300)
> >>>                 {
> >>>                     //Red
> >>>                     colors.InsertTuple3(i, 255, 0, 0);
> >>>                 }
> >>>             }
> >>>             originalMesh.GetPointData().SetScalars(colors);
> >>>
> >>>             //Subdivision.
> >>>             int numberOfSubdivisions = 4;
> >>>             vtkPolyDataAlgorithm subdivisionFilter =
> >>> vtkButterflySubdivisionFilter.New();
> >>>
> >>>
> >>>
> ((vtkButterflySubdivisionFilter)subdivisionFilter).SetNumberOfSubdivisions(numberOfSubdivisions);
> >>>             subdivisionFilter.SetInput(originalMesh);
> >>>             subdivisionFilter.Update();
> >>>
> >>>             vtkRenderWindow renderWindow =
> >>> renderWindowControl1.RenderWindow;
> >>>             vtkRenderer renderer = vtkRenderer.New();
> >>>
> >>>             //Create a mapper and actor
> >>>             vtkPolyDataMapper mapper = vtkPolyDataMapper.New();
> >>>
> mapper.SetInputConnection(subdivisionFilter.GetOutputPort());
> >>>             vtkActor actor = vtkActor.New();
> >>>             actor.SetMapper(mapper);
> >>>
> >>>             renderer.AddActor(actor);
> >>>             renderer.SetBackground(0, 0, 0);
> >>>             renderer.ResetCamera();
> >>>             renderWindow.AddRenderer(renderer);
> >>>             renderWindow.Render();
> >>>
> >>>
> >>>
>



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


More information about the vtkusers mailing list