[vtkusers] ActiViz C# | Display Points as a surface

Matias Montroull matimontg at gmail.com
Tue Jan 21 19:02:39 EST 2014


Hi,

I'm able to show a set of points in screen that have a face form, now, how
can I add the skin to it? I only see a lot of points..

This is my code:

  vtkTesting test = vtkTesting.New();
            string root = test.GetDataRoot();
            string filePath = System.IO.Path.Combine(root,
@"C:/tracker/mesh.poi");
            FileStream fs = null;
            StreamReader sr = null;
            String sLineBuffer;
            String[] sXYZ;
            char[] chDelimiter = new char[] {';'};
            double[] xyz = new double[3];
            vtkPoints points = vtkPoints.New();
            int cnt = 0;

            fs = new FileStream(filePath, FileMode.Open, FileAccess.Read,
FileShare.ReadWrite);
            sr = new StreamReader(fs);
            while (!sr.EndOfStream)
            {
                sLineBuffer = sr.ReadLine();
                cnt++;
                sXYZ = sLineBuffer.Split(chDelimiter,
StringSplitOptions.RemoveEmptyEntries);
                if (sXYZ == null)
                {
                    System.Windows.MessageBox.Show("data seems to be in
wrong format at line " + cnt, "Format Exception");
                    return;
                }
                xyz[0] = double.Parse(sXYZ[0],
CultureInfo.InvariantCulture);
                xyz[1] = double.Parse(sXYZ[1],
CultureInfo.InvariantCulture);
                xyz[2] = double.Parse(sXYZ[2],
CultureInfo.InvariantCulture);
                points.InsertNextPoint(xyz[0], xyz[1], xyz[2]);
            }
            vtkPolyData polydata = vtkPolyData.New();
            polydata.SetPoints(points);

            vtkSurfaceReconstructionFilter surf = new
vtkSurfaceReconstructionFilter();
            surf.SetInput(polydata);
            vtkContourFilter cf = new vtkContourFilter();
            cf.SetInputConnection(surf.GetOutputPort());

            vtkVertexGlyphFilter glyphFilter = vtkVertexGlyphFilter.New();
            glyphFilter.SetInputConnection(polydata.GetProducerPort());
            glyphFilter.Update();

            // Visualize
            vtkPolyDataMapper registracion_mapper = vtkPolyDataMapper.New();


registracion_mapper.SetInputConnection(glyphFilter.GetOutputPort());
            vtkActor actorregistracion = vtkActor.New();
            actorregistracion.SetMapper(registracion_mapper);
            actorregistracion.GetProperty().SetPointSize(3);
            actorregistracion.GetProperty().SetColor(1, 0.5, 0);
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20140121/9fcecd65/attachment.html>


More information about the vtkusers mailing list