Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
CamiTK Community Edition
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
17
Issues
17
List
Boards
Labels
Service Desk
Milestones
Merge Requests
2
Merge Requests
2
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
CamiTK
CamiTK Community Edition
Commits
4a4c47ec
Commit
4a4c47ec
authored
Jul 29, 2019
by
Emmanuel Promayon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
FIXED volume rendering for VTK8
modified so that VTK6 and VTK7 version is still available
parent
bda13aa1
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
28 deletions
+21
-28
sdk/actions/image/volumerendering/CMakeLists.txt
sdk/actions/image/volumerendering/CMakeLists.txt
+0
-1
sdk/actions/image/volumerendering/VolumeRenderingAction.cpp
sdk/actions/image/volumerendering/VolumeRenderingAction.cpp
+21
-27
No files found.
sdk/actions/image/volumerendering/CMakeLists.txt
View file @
4a4c47ec
# Note: add flag DISABLED to disable a specific action
camitk_extension
(
ACTION_EXTENSION
NEEDS_QTXML
DEFINES COMPILE_VOLUME_RENDERING_ACTION_API
...
...
sdk/actions/image/volumerendering/VolumeRenderingAction.cpp
View file @
4a4c47ec
...
...
@@ -27,9 +27,15 @@
// -- vtk stuff --
#include <vtkImageCast.h>
#include <vtkVolume.h>
#include <vtkVolumeRayCastMapper.h>
#include <vtkPiecewiseFunction.h>
#if VTK_MAJOR_VERSION == 8
#include <vtkFixedPointVolumeRayCastMapper.h>
#else
#include <vtkVolumeRayCastMapper.h>
#include <vtkVolumeRayCastCompositeFunction.h>
#endif
#include <vtkColorTransferFunction.h>
#include <vtkRenderWindowInteractor.h>
#include <vtkRenderWindow.h>
...
...
@@ -59,12 +65,10 @@ VolumeRenderingAction::VolumeRenderingAction(ActionExtension* extension) : Actio
myWidget
=
nullptr
;
volumeName
=
"volume-rendering"
;
// Setting name, description and input component
setName
(
"Volume Rendering"
);
setEmbedded
(
false
);
setDescription
(
tr
(
"Volume rendering of 3D medical image using ray casting<br/>\
(Use Ctrl+R to render a selected image volume)"
));
setDescription
(
tr
(
"Volume rendering of 3D medical image using ray casting<br/>(Use Ctrl+R to render a selected image volume)"
));
setComponent
(
"ImageComponent"
);
// Setting classification family and tags
...
...
@@ -76,31 +80,14 @@ VolumeRenderingAction::VolumeRenderingAction(ActionExtension* extension) : Actio
// add shortcut
getQAction
()
->
setShortcut
(
QKeySequence
(
Qt
::
CTRL
+
Qt
::
Key_R
));
getQAction
()
->
setShortcutContext
(
Qt
::
ApplicationShortcut
);
/*
// Define default colors
defaultTransparencies.insert( 0, 0.0);
defaultTransparencies.insert(255, 1.0);
defaultColors.insert( 0, QColor(204, 77, 51, 255));
defaultColors.insert(255, QColor(128, 128, 128, 255));
defaultGradientOpacities.insert(0, 0.0);
defaultGradientOpacities.insert(90, 0.5);
defaultGradientOpacities.insert(150, 1.0);
defaultAmbiant = 0.4;
defaultDiffuse = 0.6;
defaultSpecular = 0.2;
*/
}
// --------------- getWidget ---------------
----
// --------------- getWidget ---------------
QWidget
*
VolumeRenderingAction
::
getWidget
()
{
return
nullptr
;
}
// --------------- apply ---------------
----
// --------------- apply ---------------
Action
::
ApplyStatus
VolumeRenderingAction
::
apply
()
{
foreach
(
Component
*
comp
,
getTargets
())
{
ImageComponent
*
input
=
dynamic_cast
<
ImageComponent
*>
(
comp
);
...
...
@@ -109,6 +96,7 @@ Action::ApplyStatus VolumeRenderingAction::apply() {
return
SUCCESS
;
}
// --------------- process ---------------
void
VolumeRenderingAction
::
process
(
ImageComponent
*
comp
)
{
bool
isVisible
=
comp
->
getVolumeRenderingChild
()
->
getVisibility
(
InteractiveViewer
::
get3DViewer
());
bool
existVR
=
(
comp
->
getVolumeRenderingChild
()
->
getProp
(
volumeName
)
!=
NULL
);
...
...
@@ -139,6 +127,7 @@ void VolumeRenderingAction::process(ImageComponent* comp) {
}
// --------------- createVolumeRendering ---------------
void
VolumeRenderingAction
::
createVolumeRendering
(
ImageComponent
*
comp
)
{
// Get the transfer function from the widget
QMap
<
int
,
double
>
transparencies
=
myWidget
->
getTransparencyPoints
();
...
...
@@ -150,8 +139,8 @@ void VolumeRenderingAction::createVolumeRendering(ImageComponent* comp) {
QMap
<
int
,
double
>
gradientOpacities
=
myWidget
->
getOpacityPoints
();
QMap
<
int
,
double
>::
const_iterator
gradientIt
;
double
ambiant
=
myWidget
->
getAmbiant
();
double
diffuse
=
myWidget
->
getDiffuse
();
double
ambiant
=
myWidget
->
getAmbiant
();
double
diffuse
=
myWidget
->
getDiffuse
();
double
specular
=
myWidget
->
getSpecular
();
// FILTER
...
...
@@ -166,16 +155,21 @@ void VolumeRenderingAction::createVolumeRendering(ImageComponent* comp) {
magnitudeFilter
->
Update
();
// MAPPER
#if VTK_MAJOR_VERSION == 8
vtkSmartPointer
<
vtkFixedPointVolumeRayCastMapper
>
volumeMapper
=
vtkSmartPointer
<
vtkFixedPointVolumeRayCastMapper
>::
New
();
volumeMapper
->
SetInputData
(
magnitudeFilter
->
GetOutput
());
#else
vtkSmartPointer
<
vtkVolumeRayCastMapper
>
volumeMapper
=
vtkSmartPointer
<
vtkVolumeRayCastMapper
>::
New
();
volumeMapper
->
SetInputData
(
magnitudeFilter
->
GetOutput
());
// The volume will be displayed by ray-cast alpha compositing.
// A ray-cast mapper is needed to do the ray-casting, and a
// compositing function is needed to do the compositing along the ray.
vtkSmartPointer
<
vtkVolumeRayCastCompositeFunction
>
rayCastFunction
=
vtkSmartPointer
<
vtkVolumeRayCastCompositeFunction
>::
New
();
volumeMapper
->
SetVolumeRayCastFunction
(
rayCastFunction
);
#endif
// RENDERER
// Here, there is only one renderer : the one of the volume, but contains many properties
vtkSmartPointer
<
vtkRenderer
>
renderer
=
vtkSmartPointer
<
vtkRenderer
>::
New
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment