[vtkusers] Problem with vtkcolor transfer function

Albert King albert.king84 at yahoo.com
Tue Jul 7 08:04:28 EDT 2009


Hi All,
 
I am new to vtk and I am trying to incorporate color transferfunction to the volume rendering .I have pasted the code snippet.Is it a proper method to incoporate color transfer function after the skin mapper.Can I pipeline color transfer funtion directly to the dicom image reader.Pl Help.Thanks in Advance.
 
 
 
#include"vtkRenderer.h"#include"vtkRenderWindow.h"#include"vtkRenderWindowInteractor.h"#include"vtkDICOMImageReader.h"//#include "vtkStructuredPointsReader.h"#include"vtkColorTransferFunction..h"#include"vtkVolumeProperty.h"#include"vtkPolyDataMapper.h"#include"vtkActor.h"#include"vtkProperty.h"#include"vtkOutlineFilter.h"#include"vtkCamera.h"#include"vtkPolyDataMapper.h"#include"vtkStripper.h"#include"vtkPolyDataNormals.h"#include"vtkContourFilter.h"int
{
if (argc < 2)
{
cout << "Usage: " << argv[0] << " quad\renal" << endl;
return 1;
}
vtkRenderer *aRenderer = vtkRenderer::New();
vtkRenderWindow *renWin = vtkRenderWindow::New();
renWin->AddRenderer(aRenderer);
vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::New();
iren->SetRenderWindow(renWin);
 
vtkDICOMImageReader *v16 = vtkDICOMImageReader::New();
v16->SetDirectoryName(argv[1]);
vtkContourFilter *skinExtractor = vtkContourFilter::New();
skinExtractor->SetInputConnection(v16->GetOutputPort());
skinExtractor->SetValue(0, 500);
vtkPolyDataNormals *skinNormals = vtkPolyDataNormals::New();
skinNormals->SetInputConnection(skinExtractor->GetOutputPort());
skinNormals->SetFeatureAngle(60.0);
vtkStripper *skinStripper = vtkStripper::New();
skinStripper->SetInputConnection(skinNormals->GetOutputPort());
vtkPolyDataMapper *skinMapper = vtkPolyDataMapper::New();
skinMapper->SetInputConnection(skinStripper->GetOutputPort());
skinMapper->ScalarVisibilityOff();
vtkColorTransferFunction* skinFunc =vtkColorTransferFunction::New();
skinFunc->SetInputConnection(skinMapper->GetOutputPort());
skinFunc->AddRGBPoint(110.0 .6 .6 .6);
vtkVolumeProperty * skinProp = vtkVolumeProperty::New();
skinProp->SetInputConnection(skinFunc->GetOutputPort());
skinProp->SetColor(ColorTransferFunction);
skinProp->ShadeOn();
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);
vtkContourFilter *boneExtractor = vtkContourFilter::New();
boneExtractor->SetInputConnection(v16->GetOutputPort());
boneExtractor->SetValue(0, 1150);
vtkPolyDataNormals *boneNormals = vtkPolyDataNormals::New();
boneNormals->SetInputConnection(boneExtractor->GetOutputPort());
boneNormals->SetFeatureAngle(60.0);
vtkStripper *boneStripper = vtkStripper::New();
boneStripper->SetInputConnection(boneNormals->GetOutputPort());
vtkPolyDataMapper *boneMapper = vtkPolyDataMapper::New();
boneMapper->SetInputConnection(boneStripper->GetOutputPort());
boneMapper->ScalarVisibilityOff();
vtkActor *bone = vtkActor::New();
bone->SetMapper(boneMapper);
bone->GetProperty()->SetDiffuseColor(1, 1, .9412);
vtkOutlineFilter *outlineData = vtkOutlineFilter::New();
outlineData->SetInputConnection(v16->GetOutputPort());
vtkPolyDataMapper *mapOutline = vtkPolyDataMapper::New();
mapOutline->SetInputConnection(outlineData->GetOutputPort());
vtkActor *outline = vtkActor::New();
outline->SetMapper(mapOutline);
outline->GetProperty()->SetColor(0,0,0);
vtkCamera *aCamera = vtkCamera::New();
aCamera->SetViewUp (0, 0, -1);
aCamera->SetPosition (0, 1, 0);
aCamera->SetFocalPoint (0, 0, 0);
aCamera->ComputeViewPlaneNormal();
aRenderer->AddActor(outline);
aRenderer->AddActor(skin);
aRenderer->AddActor(bone);
aRenderer->SetActiveCamera(aCamera);
aRenderer->ResetCamera ();
aCamera->Dolly(1.5);
aRenderer->SetBackground(1,1,1);
renWin->SetSize(640, 480);
aRenderer->ResetCameraClippingRange ();
iren->Initialize();
iren->Start(); 
v16->Delete();
skinExtractor->Delete();
skinNormals->Delete();
skinStripper->Delete();
skinMapper->Delete();
skin->Delete();
boneExtractor->Delete();
boneNormals->Delete();
boneStripper->Delete();
boneMapper->Delete();
bone->Delete();
outlineData->Delete();
mapOutline->Delete();
outline->Delete();
aCamera->Delete();
aRenderer->Delete();
renWin->Delete();
iren->Delete();
return 0;
}
 
 
>..\..\..\..\..\vtksrc\Examples\Medical\Cxx\Medical2.cxx(88) : error C2039: 'SetInputConnection' : is not a member of 'vtkColorTransferFunction'
1> F:\OSP\VTK\vtksrc\Filtering\vtkColorTransferFunction.h(45) : see declaration of 'vtkColorTransferFunction'
1>..\..\..\..\..\vtksrc\Examples\Medical\Cxx\Medical2.cxx(89) : error C2143: syntax error : missing ')' before 'constant'
1>..\..\..\..\..\vtksrc\Examples\Medical\Cxx\Medical2.cxx(89) : error C2661: 'vtkColorTransferFunction::AddRGBPoint' : no overloaded function takes 1 arguments
1>..\..\..\..\...\vtksrc\Examples\Medical\Cxx\Medical2.cxx(89) : error C2059: syntax error : ')'
1>..\..\..\..\..\vtksrc\Examples\Medical\Cxx\Medical2.cxx(92) : error C2039: 'SetInputConnection' : is not a member of 'vtkVolumeProperty'
1> F:\OSP\VTK\vtksrc\Rendering\vtkVolumeProperty.h(50) : see declaration of 'vtkVolumeProperty'
1>..\..\..\...\..\vtksrc\Examples\Medical\Cxx\Medical2.cxx(92) : error C2039: 'GetOutputPort' : is not a member of 'vtkColorTransferFunction'
1> F:\OSP\VTK\vtksrc\Filtering\vtkColorTransferFunction.h(45) : see declaration of 'vtkColorTransferFunction'
1>..\..\..\...\..\vtksrc\Examples\Medical\Cxx\Medical2.cxx(93) : error C2065: 'ColorTransferFunction' : undeclared identifier
 
 
 
regards
 
Albert
 
 
 
 
 
 main (int argc, char **argv)


      
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20090707/3d41266c/attachment.htm>


More information about the vtkusers mailing list