23 #include <vtkAbstractVolumeMapper.h>
25 #include <vtkProperty.h>
26 #include <vtkColorTransferFunction.h>
27 #include <vtkConfigure.h>
28 #include <vtkDoubleArray.h>
29 #include <vtkGPUVolumeRayCastMapper.h>
30 #include <vtkObjectFactory.h>
31 #include <vtkOpenGLGPUVolumeRayCastMapper.h>
32 #include <vtkOutlineCornerFilter.h>
33 #include <vtkOutlineFilter.h>
34 #include <vtkImageData.h>
36 #include <vtkPiecewiseFunction.h>
37 #include <vtkPointData.h>
38 #include <vtkPolyData.h>
39 #include <vtkPolyDataMapper.h>
40 #include <vtkProp3DCollection.h>
41 #include <vtkSmartPointer.h>
42 #include <vtkSmartVolumeMapper.h>
44 #include <vtkVolume.h>
45 #include <vtkVolumeProperty.h>
47 #include <vtkCommand.h>
49 #include <vtkVersion.h>
62 virtual void Execute(vtkObject *caller,
unsigned long event,
void *)
159 class axlActorVolumeDiscretePrivate
165 vtkSmartPointer<vtkVolume> vol;
166 vtkSmartPointer<vtkVolumeProperty> volProperty;
167 vtkSmartPointer<vtkColorTransferFunction> colorFunction;
168 vtkSmartPointer<vtkPiecewiseFunction> opacityTransferFunction;
169 vtkSmartPointer<vtkSmartVolumeMapper> mapper;
172 vtkSmartPointer<vtkOutlineCornerFilter> outline_corner;
173 vtkSmartPointer<vtkOutlineFilter> outline_box;
174 vtkSmartPointer<vtkOutlineFilter> outline_contour;
176 vtkSmartPointer<vtkPolyDataMapper> outline_corner_mapper;
177 vtkSmartPointer<vtkPolyDataMapper> outline_box_mapper;
178 vtkSmartPointer<vtkPolyDataMapper> outline_contour_mapper;
180 vtkSmartPointer<vtkActor> outline_corner_actor;
181 vtkSmartPointer<vtkActor> outline_box_actor;
182 vtkSmartPointer<vtkActor> outline_contour_actor;
185 vtkImageData * image;
186 #if(VTK_VERSION_MINOR >= 10)
187 vtkImageResize *filter;
194 #if (VTK_MAJOR_VERSION <= 5)
202 if (!dynamic_cast<axlVolumeDiscrete *>(volume)) {
203 dtkWarn() <<
"No volume, can't set volume!";
208 vtkSmartVolumeMapper *
mapper = d->mapper;
210 d->image =
static_cast<vtkImageData *
>(d->volume->data());
212 int spacing_x = d->image->GetSpacing()[0];
222 #if(VTK_VERSION_MINOR >= 10)
223 d->filter = vtkImageResize::New();
224 #if (VTK_MAJOR_VERSION <= 5)
225 d->filter->SetInput(d->image);
227 d->filter->SetInputData(d->image);
229 d->filter->SetResizeMethodToOutputDimensions();
230 d->filter->SetOutputDimensions(spacing_x*dim_x, spacing_y*dim_y, spacing_z*dim_z);
231 d->filter->SetOutputSpacing(1, 1, 1);
233 #if (VTK_MAJOR_VERSION <= 5)
234 mapper->SetInput(d->filter->GetOutput());
236 mapper->SetInputData(d->filter->GetOutput());
241 #if (VTK_MAJOR_VERSION <= 5)
242 mapper->SetInput(d->image);
244 mapper->SetInputData(d->image);
248 double min = d->volume->minValue();
249 double mid = d->volume->midValue();
250 double max = d->volume->maxValue();
252 d->colorFunction = vtkSmartPointer<vtkColorTransferFunction>::New();
253 d->colorFunction->SetColorSpaceToRGB();
254 d->colorFunction->AddRGBPoint(min, 0.0, 0.0, 1.0);
255 d->colorFunction->AddRGBPoint(mid, 0.0, 1.0, 0.0);
256 d->colorFunction->AddRGBPoint(max, 1.0, 0.0, 0.0);
258 d->opacityTransferFunction = vtkSmartPointer<vtkPiecewiseFunction>::New();
259 d->opacityTransferFunction->AddPoint(min, 0.5);
260 d->opacityTransferFunction->AddPoint(mid, 0.5);
261 d->opacityTransferFunction->AddPoint(max, 0.5);
263 d->volProperty = vtkSmartPointer<vtkVolumeProperty>::New();
264 d->volProperty->SetColor(d->colorFunction);
265 d->volProperty->SetScalarOpacity(d->opacityTransferFunction);
266 d->volProperty->ShadeOn();
267 d->volProperty->SetSpecular(1.0);
269 d->vol = vtkSmartPointer<vtkVolume>::New();
270 d->vol->SetMapper(d->mapper);
271 d->vol->SetProperty(d->volProperty);
273 d->vol->SetVisibility(1);
278 if(!d->outline_corner)
279 d->outline_corner = vtkSmartPointer<vtkOutlineCornerFilter>::New();
280 #if (VTK_MAJOR_VERSION <= 5)
281 d->outline_corner->SetInput(d->image);
283 d->outline_corner->SetInputData(d->image);
285 d->outline_corner->Update();
287 if(!d->outline_corner_mapper)
288 d->outline_corner_mapper = vtkSmartPointer<vtkPolyDataMapper>::New();
289 d->outline_corner_mapper->SetInputConnection(d->outline_corner->GetOutputPort());
291 if(!d->outline_corner_actor)
292 d->outline_corner_actor = vtkSmartPointer<vtkActor>::New();
293 d->outline_corner_actor->SetMapper(d->outline_corner_mapper);
294 d->outline_corner_actor->GetProperty()->SetColor(1, 0, 0);
300 d->outline_box = vtkSmartPointer<vtkOutlineFilter>::New();
301 #if (VTK_MAJOR_VERSION <= 5)
302 d->outline_box->SetInput(d->image);
304 d->outline_box->SetInputData(d->image);
306 d->outline_box->Update();
308 if(!d->outline_box_mapper)
309 d->outline_box_mapper = vtkSmartPointer<vtkPolyDataMapper>::New();
310 d->outline_box_mapper->SetInputConnection(d->outline_box->GetOutputPort());
312 if(!d->outline_box_actor)
313 d->outline_box_actor = vtkSmartPointer<vtkActor>::New();
314 d->outline_box_actor->SetMapper(d->outline_box_mapper);
315 d->outline_box_actor->GetProperty()->SetColor(1, 0, 0);
320 if(!d->outline_contour)
321 d->outline_contour = vtkSmartPointer<vtkOutlineFilter>::New();
322 #if (VTK_MAJOR_VERSION <= 5)
323 d->outline_contour->SetInput(d->image);
325 d->outline_contour->SetInputData(d->image);
327 d->outline_contour->Update();
329 if(!d->outline_contour_mapper)
330 d->outline_contour_mapper = vtkSmartPointer<vtkPolyDataMapper>::New();
331 d->outline_contour_mapper->SetInputConnection(d->outline_contour->GetOutputPort());
333 if(!d->outline_contour_actor)
334 d->outline_contour_actor = vtkSmartPointer<vtkActor>::New();
335 d->outline_contour_actor->SetMapper(d->outline_contour_mapper);
336 d->outline_contour_actor->GetProperty()->SetColor(1, 0, 0);
339 d->outline_contour_actor->SetVisibility(1);
340 d->outline_box_actor->SetVisibility(1);
341 d->outline_corner_actor->SetVisibility(1);
343 this->AddPart(d->outline_corner_actor);
344 this->AddPart(d->outline_box_actor);
345 this->AddPart(d->outline_contour_actor);
347 this->
setActor(vtkSmartPointer<vtkActor>::New());
363 #if(VTK_VERSION_MINOR >= 10)
369 d->volProperty->Modified();
370 d->colorFunction->Modified();
371 d->opacityTransferFunction->Modified();
372 d->mapper->Modified();
384 if(!this->GetParts()->IsItemPresent(d->vol))
385 this->AddPart(d->vol);
388 if (this->GetParts()->IsItemPresent(d->vol))
389 this->RemovePart(d->vol);
409 QColor color =
data->color();
410 this->
getActor()->GetProperty()->SetColor(color.redF(), color.greenF(), color.blueF());
419 vtkProperty *prop = this->
getActor()->GetProperty();
423 QColor color =
data->color();
424 qreal *h =
new qreal(0.0);
425 qreal *s =
new qreal(0.0);
426 qreal *l =
new qreal(0.0);
427 color.getHslF(h, s, l);
428 color.setHslF(*h, *s, *l + (1.0 - *l) / 2.0);
429 prop->SetColor(color.redF(), color.greenF(), color.blueF());
440 vtkProperty *prop = this->
getActor()->GetProperty();
443 QColor color =
data->color();
444 qreal *h =
new qreal(0.0);
445 qreal *s =
new qreal(0.0);
446 qreal *l =
new qreal(0.0);
447 color.getHslF(h, s, l);
448 color.setHslF(*h, *s, *l + (1.0 - *l)/2.0);
449 prop->SetColor(color.redF(), color.greenF(), color.blueF());
475 d->outline_corner_actor->SetVisibility(0);
476 d->outline_box_actor->SetVisibility(0);
477 d->outline_contour_actor->SetVisibility(0);
482 d->outline_corner_actor->SetVisibility(1);
483 d->outline_box_actor->SetVisibility(0);
484 d->outline_contour_actor->SetVisibility(0);
489 d->outline_corner_actor->SetVisibility(0);
490 d->outline_box_actor->SetVisibility(1);
491 d->outline_contour_actor->SetVisibility(0);
496 d->outline_corner_actor->SetVisibility(0);
497 d->outline_box_actor->SetVisibility(0);
498 d->outline_contour_actor->SetVisibility(1);
503 return d->colorFunction;
508 return d->opacityTransferFunction;
523 return d->volProperty;
534 #if(VTK_VERSION_MINOR >= 10)
537 d->mapper = vtkSmartVolumeMapper::New();
538 d->mapper->SetRequestedRenderMode(vtkSmartVolumeMapper::TextureRenderMode);
dtkAbstractData * data(void)
static axlActorVolumeDiscreteObserver * New(void)
void outlineCorners(void)
void onModeChanged(int state)
void * volumeProperty(void)
void stateChanged(dtkAbstractData *data, int mode)
vtkStandardNewMacro(axlActorVolumeDiscrete)
virtual void setState(int state)
void setData(dtkAbstractData *volume)
void * colorTransferFunction(void)
axlActorVolumeDiscrete(void)
void setDisplay(bool display)
~axlActorVolumeDiscrete(void)
virtual void Execute(vtkObject *caller, unsigned long event, void *)
void setActor(vtkSmartPointer< vtkActor > actor)
vtkSmartPointer< vtkActor > getActor(void)
vtkSmartPointer< vtkPolyDataMapper > getMapper(void)
axlActorVolumeDiscrete * observerDataAssembly
vtkCxxRevisionMacro(axlActorVolumeDiscrete,"$Revision: 0.0.1 $")
void outlineContour(void)
axlVolumeDiscrete * observerData_volume
Class axlAbstractData defines an API for all type of axel data.
vtkCellPicker * axlVolumePicker
void * opacityTransferFunction(void)