[vtkusers] Please, I need help of a C# and vtk user!!!

Vicky bonsai19 at gmx.de
Mon Nov 24 15:29:27 EST 2008


Hallo vtk users,

Basically, I'm trying to model segmented data in VTK, based on the 
tutorial, provided in:
http://www.cs.utah.edu/classes/cs5630/vtk%204.4.2/vtkhtml/applications/segment/segmented16.html

/Now I am trying to use my own segmented data with the above scripts, where 
//they represent 340x234 segmented data, with each pixel represented by an 
//integer.

When I run my C#-project I should get a vtk File /"Volume.vtk"/ and a volume should be 
rendered.// Instead it is //empty and no polygons are generated. I get the following errors:

/ERROR: In m:\dev\cur\vtkdotnet\branch\50\Graphics\vtkDecimatePro.cxx, 
line 161 vtkDecimatePro (04042A88): No data to decimate!

ERROR: In 
m:\dev\cur\vtkdotnet\branch\50\Graphics\vtkSmoothPolyDataFilter.cxx, 
line 212 vtkSmoothPolyDataFilter (04053210): No data to smooth!

ERROR: In 
m:\dev\cur\vtkdotnet\branch\50\Graphics\vtkPolyDataNormals.cxx, line 94
vtkPolyDataNormals (040540D0): No data to generate normals for!

/I am really trying to understand what //is wrong, but I cannot figure it out./

//The script I have written://

public void myvtkpipeline(vtkRenderWindow renWin)
{
            vtkRenderWindow renWin = new vtkRenderWindow();
            renWin.AddRenderer(ren);

            vtkTIFFReader tiffReader = new vtkTIFFReader();
            tiffReader.SetDataExtent(0, 339, 0, 233, 1, 3);
            tiffReader.SetFileDimensionality(2);
            tiffReader.SetFilePattern("C:/Images/labels_%03i.tiff");
            tiffReader.Update();

            vtkDiscreteMarchingCubes marchingCubes = new 
vtkDiscreteMarchingCubes();
            marchingCubes.SetInput(tiffReader.GetOutput());
            marchingCubes.ComputeScalarsOff();
            marchingCubes.ComputeGradientsOff();
            marchingCubes.ComputeNormalsOff();
            marchingCubes.SetValue(0, 7);

            vtkDecimatePro decimate = new vtkDecimatePro();
            decimate.SetInput(marchingCubes.GetOutput());
            decimate.SetFeatureAngle(60.0);
            decimate.SetMaximumError(1);
            decimate.SetTargetReduction(0.9);

            vtkSmoothPolyDataFilter smoother = new 
vtkSmoothPolyDataFilter();
            smoother.SetInput(decimate.GetOutput());
            smoother.SetNumberOfIterations(10);
            smoother.SetRelaxationFactor(0.1);
            smoother.SetFeatureAngle(60.0);
            smoother.FeatureEdgeSmoothingOff();
            smoother.SetConvergence(0);

            vtkPolyDataNormals normals = new vtkPolyDataNormals();
            normals.SetInput(smoother.GetOutput());
            normals.SetFeatureAngle(60.0);

            vtkStripper stripper = new vtkStripper();
            stripper.SetInput(normals.GetOutput());

            vtkPolyDataWriter writer = new vtkPolyDataWriter();
            writer.SetInput(stripper.GetOutput());
            writer.SetFileName("Volume.vtk");
            writer.SetFileType(2);

            writer.Update();

            vtkPolyDataReader reader = new vtkPolyDataReader();
            reader.SetFileName("Volume.vtk");

            vtkPolyDataMapper mapper = new vtkPolyDataMapper();
            mapper.SetInputConnection(reader.GetOutputPort());
            mapper.ScalarVisibilityOff();

            actor.SetMapper(mapper);

            vtkCamera camera = new vtkCamera();
            camera.SetViewUp(0, 0, -1);
            camera.SetPosition(0, 1, 0);
            camera.SetFocalPoint(0, 0, 0);
            camera.ComputeViewPlaneNormal();

            vtkRenderer = new vtkRenderer();
            ren.SetActiveCamera(camera);
            ren.ResetCamera();
            ren.SetBackground(0, 0, 0);
            ren.ResetCameraClippingRange();

            ren.AddActor(actor);
}

I hope somebody helps me!

Best regards,
Vicky



More information about the vtkusers mailing list