[vtkusers] Uneven colors after the vtkButterflySubdivisionFilter

Bill Lorensen bill.lorensen at gmail.com
Sat Apr 20 10:08:08 EDT 2013


I am not a C# person. I can convert it to C++. However, a short program
that illustrates the problem would be better. The smallest that illustrates
the problem.

Otherwise, it will be a few days before I can take the time to translate
your program.



On Sat, Apr 20, 2013 at 2:11 AM, DivyaS <div.anand141 at gmail.com> wrote:

> The code is in C#. I started working in VTK 3 weeks back, please correct me
> if I am wrong with the pipeline. The colors are selected wrt to the
> localActivationTime value. Here I have created a list of keyValuePair
> 'colorLAT' and the localActivationTime value are created and stored in it.
> In the real application, the localActivationTime are given as a different
> input, and the colors need to be selected accordingly.
>
> vtkPoints points = vtkPoints.New();
>             points.InsertNextPoint(1.82, -84.67, 152.78);
>             points.InsertNextPoint(-10.18, -81.77, 175.03);
>             points.InsertNextPoint(-11.65, -32.09, 173.08);
>             points.InsertNextPoint(-6.85, 6, 6);
>             points.InsertNextPoint(0.09, -83.69, 154.23);
>             points.InsertNextPoint(-16.67, -79.95, 150.54);
>             points.InsertNextPoint(-2.74, -89.19, 153.67);
>             points.InsertNextPoint(-38.7, -58.88, 145.54);
>
>
>             points.InsertNextPoint(-43.83, -46.88, 140.94);
>             points.InsertNextPoint(-9.29, -67.59, 149.96);
>             points.InsertNextPoint(-6.33, -72.42, 147.95);
>             points.InsertNextPoint(-6.73, -73.28, 148.64);
>             points.InsertNextPoint(-21.51, -80.61, 148.58);
>             points.InsertNextPoint(2.75, -63.21, 140.98);
>             points.InsertNextPoint(-13.52, -50.61, 165.29);
>             points.InsertNextPoint(-14.67, -48.55, 166.27);
>
>             points.InsertNextPoint(-19.85, -73.21, 134.88);
>             points.InsertNextPoint(-12.08, -79.71, 148.54);
>             points.InsertNextPoint(-20.43, -78.4, 145.79);
>             points.InsertNextPoint(-21.51, -78.74, 149.56);
>             points.InsertNextPoint(-39.36, -61.7, 153.9);
>             points.InsertNextPoint(-28.31, -78.12, 144.73);
>             points.InsertNextPoint(-20.23, -88.43, 155.28);
>             points.InsertNextPoint(-21.87, -72.37, 148.9);
>
>             points.InsertNextPoint(-29.79, -76.02, 128.35);
>             points.InsertNextPoint(-15.34, -70.51, 141.4);
>             points.InsertNextPoint(-21.14, -72.03, 134.04);
>             points.InsertNextPoint(-25.65, -69.4, 138.11);
>             points.InsertNextPoint(-12.7, -70.25, 137.26);
>             points.InsertNextPoint(-19.99, -75.75, 140.2);
>             points.InsertNextPoint(-19.36, -76.19, 134.93);
>             points.InsertNextPoint(-15.33, -73.78, 133.75);
>
>             points.InsertNextPoint(-16.92, -69.18, 134.01);
>             points.InsertNextPoint(-25.94, -76.28, 155.28);
>             points.InsertNextPoint(-25.82, -81.69, 153.39);
>             points.InsertNextPoint(-20.27, -85.45, 146.25);
>             points.InsertNextPoint(-22, -74.8, 128.74);
>             points.InsertNextPoint(-25.68, -75.75, 130.94);
>             points.InsertNextPoint(-13.16, -63.49, 143.67);
>             points.InsertNextPoint(-19.75, -80.75, 145.95);
>             points.InsertNextPoint(-19.11, -83.81, 147.76);
>
>             vtkPolyData polydata = vtkPolyData.New();
>             polydata.SetPoints(points);
>
>             vtkDelaunay3D delaunay = vtkDelaunay3D.New();
>             delaunay.SetInput(polydata);
>             delaunay.SetTolerance(0.001);
>             delaunay.Update();
>
>             vtkDataSetSurfaceFilter surfaceFilter =
> vtkDataSetSurfaceFilter.New();
>             surfaceFilter.SetInputConnection(delaunay.GetOutputPort());
>             surfaceFilter.Update();
>
>             vtkXMLPolyDataWriter outputWriter = vtkXMLPolyDataWriter.New();
>             outputWriter.SetFileName("output.vtp");
>             outputWriter.SetInput(surfaceFilter.GetOutput());
>             outputWriter.Write();
>
>             vtkXMLPolyDataReader reader1 = vtkXMLPolyDataReader.New();
>             reader1.SetFileName("output.vtp");
>             reader1.Update();
>
>             vtkTriangleFilter triangles = vtkTriangleFilter.New();
>             triangles.SetInput(reader1.GetOutput());
>             triangles.Update();
>             vtkPolyData originalMesh;
>             originalMesh = triangles.GetOutput();
>
>             vtkUnsignedCharArray colors = vtkUnsignedCharArray.New();
>             colors.SetNumberOfComponents(3);
>             colors.SetNumberOfTuples(originalMesh.GetNumberOfPolys());
>             colors.SetName("Colors");
>
> //Temporary creation of the localActivationTime values (the colors are
> selected according to this value)
>             List<KeyValuePair&lt;int, int>> colorLAT = new
> List<KeyValuePair&lt;int, int>>();
>             for (int i = 0; i < originalMesh.GetNumberOfPoints(); i++)
>             {
>                 colorLAT.Add(new KeyValuePair<int, int>(i, (i + 2)));
>             }
>
>             int localActivationTime;
>             for (int i = 0; i < originalMesh.GetNumberOfPoints(); i++)
>             {
>                 localActivationTime = colorLAT[i].Value;
>
>                 if (localActivationTime > 0 && localActivationTime < 5)
>                 {
>                     //Yellow
>                     colors.InsertTuple3(i, 255, 255, 0);
>                 }
>                 else if (localActivationTime > 4 && localActivationTime <
> 10)
>                 {
>                     //Blue
>                     colors.InsertTuple3(i, 0, 0, 255);
>                 }
>                 else if (localActivationTime > 9 && localActivationTime <
> 300)
>                 {
>                     //Red
>                     colors.InsertTuple3(i, 255, 0, 0);
>                 }
>             }
>             originalMesh.GetPointData().SetScalars(colors);
>
>             int numberOfViewports = 3;
>             vtkRenderWindow renderWindow =
> renderWindowControl1.RenderWindow;
>             this.Size = new System.Drawing.Size(200 * numberOfViewports +
> 12, 252);
>             this.Text += " - Subdivision";
>             Random rnd = new Random(2);
>             int numberOfSubdivisions = 4;
>
>             // Create one text property for all
>             vtkTextProperty textProperty = vtkTextProperty.New();
>             textProperty.SetFontSize(14);
>             textProperty.SetJustificationToCentered();
>
>
>             for (int i = 0; i < numberOfViewports; i++)
>             {
>                 vtkPolyDataAlgorithm subdivisionFilter;
>                 switch (i)
>                 {
>                     case 0:
>                         subdivisionFilter =
> vtkLinearSubdivisionFilter.New();
>
>
> ((vtkLinearSubdivisionFilter)subdivisionFilter).SetNumberOfSubdivisions(numberOfSubdivisions);
>                         break;
>                     case 1:
>                         subdivisionFilter = vtkLoopSubdivisionFilter.New();
>
>
> ((vtkLoopSubdivisionFilter)subdivisionFilter).SetNumberOfSubdivisions(numberOfSubdivisions);
>                         break;
>                     case 2:
>                         subdivisionFilter =
> vtkButterflySubdivisionFilter.New();
>
>
> ((vtkButterflySubdivisionFilter)subdivisionFilter).SetNumberOfSubdivisions(numberOfSubdivisions);
>                         break;
>                     default:
>                         subdivisionFilter =
> vtkLinearSubdivisionFilter.New();
>
>
> ((vtkLinearSubdivisionFilter)subdivisionFilter).SetNumberOfSubdivisions(numberOfSubdivisions);
>                         break;
>                 }
>                 subdivisionFilter.SetInput(originalMesh);
>                 subdivisionFilter.Update();
>
>                 vtkRenderer renderer = vtkRenderer.New();
>                 renderWindow.AddRenderer(renderer);
>                 renderer.SetViewport((float)i / numberOfViewports, 0,
> (float)(i + 1) / numberOfViewports, 1);
>                 renderer.SetBackground(.2 + rnd.NextDouble() / 8, .3 +
> rnd.NextDouble() / 8, .4 + rnd.NextDouble() / 8);
>
>                 vtkTextMapper textMapper = vtkTextMapper.New();
>                 vtkActor2D textActor = vtkActor2D.New();
>                 textMapper.SetInput(subdivisionFilter.GetClassName());
>                 textMapper.SetTextProperty(textProperty);
>
>                 textActor.SetMapper(textMapper);
>                 textActor.SetPosition(100, 16);
>
>                 //Create a mapper and actor
>                 vtkPolyDataMapper mapper = vtkPolyDataMapper.New();
>
> mapper.SetInputConnection(subdivisionFilter.GetOutputPort());
>                 vtkActor actor = vtkActor.New();
>                 actor.SetMapper(mapper);
>                 renderer.AddActor(actor);
>                 renderer.AddActor(textActor);
>                 renderer.ResetCamera();
>             }
>             renderWindow.Render();
>
>
>
>
>
> --
> View this message in context:
> http://vtk.1045678.n5.nabble.com/Uneven-colors-after-the-vtkButterflySubdivisionFilter-tp5720205p5720226.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/0d65b61f/attachment.htm>


More information about the vtkusers mailing list