[vtkusers] Uneven colors after the vtkButterflySubdivisionFilter

Bill Lorensen bill.lorensen at gmail.com
Sat Apr 20 14:23:43 EDT 2013


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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20130420/ec5a4c57/attachment.htm>


More information about the vtkusers mailing list