[vtkusers] Uneven colors after the vtkButterflySubdivisionFilter
div
div.anand141 at gmail.com
Sun Apr 21 01:49:50 EDT 2013
David,
I tried using the vtkProbeFilter,
I used this code right after the subdivision filter,
vtkProbeFilter probe = vtkProbeFilter.New();
probe.SetSource(originalMesh);
probe.SetInput(subdivisionFilter.GetOutput());
probe.Update();
but the result looks like this. Is this really how we need to use the
vtkProbeFilter ?
[image: Inline image 1]
On Sun, Apr 21, 2013 at 4:01 AM, 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();
> >>>
> >>>
> >>>
>
--
*div......*
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20130421/48500352/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: image/png
Size: 7390 bytes
Desc: not available
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20130421/48500352/attachment.png>
More information about the vtkusers
mailing list