[vtkusers] vtkInterpolatingSubdivisionFilter

Ajit Rajwadé ajit_v_r at hotmail.com
Fri Jun 13 13:40:22 EDT 2003


Hello,

I need some info on the "vtkInterpolatingSubdivisionFilter". I am rendering 
a 3-D surface using the code given below. However the surface appears rather 
tesselated when i run my program. The surface is that of a face and I need 
to be able to distinguish the fine facial features. (The data that I have 
consists on 3 arrays, one each of the X, Y and Z coordinates respectively).

(1) I was told that use of vtkInterpolatingSubdivisionFilter would help 
improve the data resolution. Could someone give an example of how it is 
used. Being very new to VTK, I am quite overwhelmed by the large number of 
functions and classes, and therefore I am a bit confused. I need to solve 
this problem urgently. Could someone tell me what I must do to the following 
code to fix the problem?

(2) Also how do I speed up the rendering of the surface?

Thanks..


=================================================================

	// Create the VTK renderer
    	vtkRenderer *ren = vtkRenderer::New();
    	vtkRenderWindow *renWin = vtkRenderWindow::New();
    	renWin->AddRenderer(ren);
    	renWin->SetSize (500,500);
    	vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::New();
    	iren->SetRenderWindow(renWin);

    	// Create points
    	vtkPoints *startPoints = vtkPoints::New();

               // CODE TO OPEN THE FILE
    	while (fgets ())
    	{
	            /* Code to read data from the file */
                              point = .....
		startPoints->InsertNextPoint(point);
	}
	fclose (fs);

    	// Create a data set. Load the starting points
    	vtkPolyData *inputDataSet = vtkPolyData::New();
    	inputDataSet->SetPoints(startPoints);
    	startPoints->Delete();

    	// Construct the surface
    	vtkSurfaceReconstructionFilter *surf = 
vtkSurfaceReconstructionFilter::New();
    	surf->SetInput(inputDataSet);

    	// Create isosurface
    	vtkContourFilter *cf = vtkContourFilter::New();
    	cf->SetInput(surf->GetOutput());
    	cf->SetValue(0,0.0);

    	// Create the mapper and actor and finish up the visualization pipeline
    	vtkPolyDataMapper *map = vtkPolyDataMapper::New();
    	map->SetInput(cf->GetOutput());
    	map->ScalarVisibilityOff();

    	// In general you should set Ambient = 1.0 and Diffuse and Specular = 
0.0 to
    	// effectively turn off lighting for an object. The color of the object 
will
    	// then be based on the Color or scalar values passed through a lookup 
table.
    	vtkActor *surfaceActor = vtkActor::New();
    	surfaceActor->SetMapper( map );
    	surfaceActor->GetProperty()->SetDiffuseColor( 1.0000, 0.3882, 0.2784 );
    	surfaceActor->GetProperty()->SetSpecularColor( 1, 1, 1 );
    	surfaceActor->GetProperty()->SetSpecular(0.4);
    	surfaceActor->GetProperty()->SetSpecularPower(50);

    	ren->AddActor(surfaceActor);
    	ren->SetBackground(1,1,1);

	cout << "Surface actor construction done..." << endl;

    	// Update surface description
    	surf->Update();
    	cout << "Surface update done..." << endl;

    	// Interact with data
   	renWin->Render();
    	cout << "Rendering done..." << endl;
    	iren->Start();

    	// Clean up
    	ren->Delete();
    	renWin->Delete();
    	startPoints->Delete();
    	inputDataSet->Delete();
    	surf->Delete();
    	cf->Delete();
    	map->Delete();
    	surfaceActor->Delete();

_________________________________________________________________
MSN Messenger : discutez en direct avec vos amis ! 
http://www.msn.fr/msger/default.asp




More information about the vtkusers mailing list