[vtkusers] problem with texture mapping

Ankur Deshmukh adeshmuk at uccs.edu
Tue Jan 10 04:46:46 EST 2006


Hey ,

I have a jpg texture and a medical dataset provided by the vtk examples. 
I want to map this texture on to the dataset. Can anyone please help me.

Here is a piece of code I am working with and below it are the erros I 
am getting:

vtkContourFilter *skinExtractor = vtkContourFilter::New();
    skinExtractor->SetInput(imageData);
    skinExtractor->SetValue(0, 500);
  vtkPolyDataNormals *skinNormals = vtkPolyDataNormals::New();
    skinNormals->SetInput(skinExtractor->GetOutput());
    skinNormals->SetFeatureAngle(60.0);
  vtkStripper *skinStripper = vtkStripper::New();
    skinStripper->SetInput(skinNormals->GetOutput());
  vtkPolyDataMapper *skinMapper = vtkPolyDataMapper::New();
    skinMapper->SetInput(skinStripper->GetOutput());
    skinMapper->ScalarVisibilityOff();
  vtkActor *skin = vtkActor::New();
    skin->SetMapper(skinMapper);
    skin->GetProperty()->SetDiffuseColor(1, .49, .25);
    skin->GetProperty()->SetSpecular(.3);
    skin->GetProperty()->SetSpecularPower(20);
    skin->GetProperty()->SetOpacity(1.0);

  /// An isosurface, or contour value of 1150 is known to correspond to the/
  /// skin of the patient. Once generated, a vtkPolyDataNormals filter is/
  /// is used to create normals for smooth surface shading during /
  /// rendering./
  /// The triangle stripper is used to create triangle strips from the/
  /// isosurface; these render much faster on may systems./
  vtkContourFilter *boneExtractor = vtkContourFilter::New();
    boneExtractor->SetInput(imageData);
    boneExtractor->SetValue(0, 1150);
  vtkPolyDataNormals *boneNormals = vtkPolyDataNormals::New();
    boneNormals->SetInput(boneExtractor->GetOutput());
    boneNormals->SetFeatureAngle(60.0);
  vtkStripper *boneStripper = vtkStripper::New();
    boneStripper->SetInput(boneNormals->GetOutput());
  vtkPolyDataMapper *boneMapper = vtkPolyDataMapper::New();
    boneMapper->SetInput(boneStripper->GetOutput());
    boneMapper->ScalarVisibilityOff();
  vtkActor *bone = vtkActor::New();
    bone->SetMapper(boneMapper);
    bone->GetProperty()->SetDiffuseColor(1, 1, .9412);

  /// An outline provides context around the data./
  ////
  vtkOutlineFilter *outlineData = vtkOutlineFilter::New();
    outlineData->SetInput(imageData);
  vtkPolyDataMapper *mapOutline = vtkPolyDataMapper::New();
    mapOutline->SetInput(outlineData->GetOutput());
  vtkActor *outline = vtkActor::New();
    outline->SetMapper(mapOutline);
    outline->GetProperty()->SetColor(0,0,0);
 	
 	vtkTextureMapToPlane *texturePlane = vtkTextureMapToPlane::New();
 		texturePlane->SetInput(skinNormals->GetOutput());
 		
 	vtkTransformTextureCoords *transformTexture = vtkTransformTextureCoords::New();
 		transformTexture->SetInput(texturePlane->GetOutput());
 	
 	vtkPolyDataMapper *textureDataMapper = vtkPolyDataMapper::New();
 		textureDataMapper->SetInput(texturePlane->GetOutput());
 	
 	vtkImageReader2Factory *createReader = vtkImageReader2Factory::New();
 	vtkImageReader2 *textureReader = vtkImageReader2::New();
 		textureReader = createReader->CreateImageReader2(argv[4]);
		textureReader->SetFileName(argv[4]);
		 	
	vtkTexture *texture = vtkTexture::New();
		texture->SetInput(textureReader->GetOutput());
		texture->InterpolateOn();
		
	vtkActor *textureActor = vtkActor::New();
		textureActor->SetMapper(textureDataMapper);
		textureActor->SetTexture(texture);

ERRORS:

rawtoxmlformat.cpp: In function ‘int main(int, char**)’:
rawtoxmlformat.cpp:142: error: no matching function for call to 
‘vtkTextureMapToPlane::SetInput(vtkPolyData*)’
/usr/local/include/vtk/vtkDataSetToDataSetFilter.h:59: note: candidates 
are: void vtkDataSetToDataSetFilter::SetInput(vtkDataSet*)
rawtoxmlformat.cpp:148: error: no matching function for call to 
‘vtkPolyDataMapper::SetInput(vtkDataSet*)’
/usr/local/include/vtk/vtkPolyDataMapper.h:51: note: candidates are: 
void vtkPolyDataMapper::SetInput(vtkPolyData*)
gmake: *** [rawtoxmlformat.o] Error 1
*** Exited with status: 2 ***




More information about the vtkusers mailing list