[vtkusers] how to use SetSampleDistance
Lacko
thedlacko at gmail.com
Sat Aug 2 06:24:44 EDT 2014
hello. i'm new to vtk. i have a project about volume rendering and i want to
be able to change sample distance for dataset. i understand that i should
use SetSampleDistance but i can't understand how to use it.
i would appreciate some help. here is my code:
#include "vtkSmartPointer.h"
#include "vtkSLCReader.h"
#include "vtkExtractVOI.h"
#include "vtkContourFilter.h"
#include "vtkPolyDataMapper.h"
#include "vtkActor.h"
#include "vtkProperty.h"
#include "vtkOutlineFilter.h"
#include "vtkRenderer.h"
#include "vtkRenderWindow.h"
#include "vtkRenderWindowInteractor.h"
#include "vtkInteractorStyleTrackballCamera.h"
#include "pathconfig.h"
#include "vtkStructuredPointsReader.h"
#include "vtkLookupTable.h"
#include "vtkImageMapToColors.h"
#include "vtkImageAlgorithm.h"
#include "vtkProbeFilter.h"
#include "vtkVolumeRayCastMapper.h"
#include "vtkPolyDataPointSampler.h"
#include "vtkVolume.h"
#include "vtkVolumeRayCastIsosurfaceFunction.h"
#define VTK_CREATE(type ,name) vtkSmartPointer<type> name =
vtkSmartPointer<type>::New()
int main()
{
filePathBuilder fpath;
VTK_CREATE(vtkStructuredPointsReader, reader);
reader->SetFileName(fpath.filePath("mummy.128.vtk"));
VTK_CREATE(vtkLookupTable, lut_bone);
lut_bone->SetNumberOfColors(256);
lut_bone->SetTableRange(0, 255);
lut_bone->SetHueRange(0,1);
lut_bone->SetSaturationRange(0, 0);
lut_bone->SetValueRange (0.0, 1.0);
lut_bone->SetAlphaRange(1,1);
lut_bone->Build();
VTK_CREATE(vtkLookupTable, lut_skin);
lut_skin->SetNumberOfColors(256);
lut_skin->SetTableRange(0, 255);
lut_skin->SetHueRange(0,0);
lut_skin->SetSaturationRange(0, 1);
lut_skin->SetValueRange (0.0, 1);
lut_skin->SetAlphaRange(0.6, 0.6);//0,6
lut_skin->Build();
VTK_CREATE(vtkImageMapToColors, iMtc_bone);
iMtc_bone->SetLookupTable(lut_bone);
iMtc_bone->SetInputConnection(reader->GetOutputPort());
VTK_CREATE(vtkImageMapToColors, iMtc_skin);
iMtc_skin->SetLookupTable(lut_skin);
iMtc_skin->SetInputConnection(reader->GetOutputPort());
VTK_CREATE(vtkContourFilter, bone_filter);
bone_filter->SetInputConnection(reader->GetOutputPort());
bone_filter->SetNumberOfContours(1);
bone_filter->SetValue(0,110.0);//110
VTK_CREATE(vtkContourFilter, skin_filter);
skin_filter->SetInputConnection(reader->GetOutputPort());
skin_filter->SetNumberOfContours(1);
skin_filter->SetValue(0,95.0);
VTK_CREATE(vtkProbeFilter, probe_bone);
probe_bone->SetInputConnection(bone_filter->GetOutputPort());
probe_bone->SetSourceConnection(iMtc_bone->GetOutputPort());
VTK_CREATE(vtkProbeFilter, probe_skin);
probe_skin->SetInputConnection(skin_filter->GetOutputPort());
probe_skin->SetSourceConnection(iMtc_skin->GetOutputPort());
VTK_CREATE(vtkPolyDataMapper, skin_mapper);
skin_mapper->SetInputConnection(skin_filter->GetOutputPort());
skin_mapper->ScalarVisibilityOff();
VTK_CREATE(vtkPolyDataMapper, bone_mapper);
bone_mapper->SetInputConnection(probe_bone->GetOutputPort());
bone_mapper->SetLookupTable(lut_bone);
bone_mapper->SetColorModeToMapScalars();
VTK_CREATE(vtkPolyDataMapper, skin_mapper);
skin_mapper->SetInputConnection(probe_skin->GetOutputPort());
skin_mapper->SetLookupTable(lut_skin);
skin_mapper->SetColorModeToMapScalars();
VTK_CREATE(vtkActor, bone_actor);
bone_actor->SetMapper(bone_mapper);
VTK_CREATE(vtkActor, skin_actor);
skin_actor->SetMapper(skin_mapper);
VTK_CREATE(vtkRenderer,ren);
ren->AddActor(bone_actor);
ren->AddActor(skin_actor);
ren->SetBackground(0.2,0.2,0.2);
VTK_CREATE(vtkRenderWindow,renw);
renw->AddRenderer(ren);
renw->SetSize(800,600);
VTK_CREATE(vtkInteractorStyleTrackballCamera, style);
VTK_CREATE(vtkRenderWindowInteractor, iren);
iren->SetRenderWindow(renw);
iren->SetInteractorStyle(style);
iren->Initialize();
iren->Start();
return 0;
}
--
View this message in context: http://vtk.1045678.n5.nabble.com/how-to-use-SetSampleDistance-tp5728070.html
Sent from the VTK - Users mailing list archive at Nabble.com.
More information about the vtkusers
mailing list