[vtkusers] Uneven colors after the vtkButterflySubdivisionFilter
div
div.anand141 at gmail.com
Sun Apr 21 02:11:35 EDT 2013
Bill,
I am not sure I understand how to assigned scalar float, single component
values, and if i use a lookup table will I be able to assign a particular
color for a point(because that will be how I get the input) ? Could you
please give me a sample code of how to assign scalar float value, just that
part n C++ would do..
Thank you for your help.
On Sun, Apr 21, 2013 at 3:21 AM, 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();
>>>
>>>
>>>
>>> --
>>> View this message in context:
>>> http://vtk.1045678.n5.nabble.com/Uneven-colors-after-the-vtkButterflySubdivisionFilter-tp5720205p5720234.html
>>> Sent from the VTK - Users mailing list archive at Nabble.com.
>>> _______________________________________________
>>> Powered by www.kitware.com
>>>
>>> Visit other Kitware open-source projects at
>>> http://www.kitware.com/opensource/opensource.html
>>>
>>> Please keep messages on-topic and check the VTK FAQ at:
>>> http://www.vtk.org/Wiki/VTK_FAQ
>>>
>>> Follow this link to subscribe/unsubscribe:
>>> http://www.vtk.org/mailman/listinfo/vtkusers
>>>
>>
>>
>>
>> --
>> Unpaid intern in BillsBasement at noware dot com
>>
>
>
>
> --
> Unpaid intern in BillsBasement at noware dot com
>
--
*div......*
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20130421/c666faae/attachment.htm>
More information about the vtkusers
mailing list