[ADD] new module that can draw DVR or MIP projections on planes of the

bounding box of a scalar dataset
parent 183b0fd7
......@@ -2,6 +2,7 @@ Alois Schloegl
Andreas Schwarzkopf
André Reichenbach
Anne Berres
Alexander Otte
Christian Heine
Christof Pieloth
Cornelius Müller
......@@ -11,8 +12,10 @@ Gerald Sommer
Jan Forberg
Marcus Stuber
Mario Hlawitschka
Markus Jankowski
Matthias Berndt
Matthias Klose
Michael Hamburger
Patrick Oesterling
Robert Frohl
Robin Ledig
......
This diff is collapsed.
//---------------------------------------------------------------------------
//
// Project: OpenWalnut ( http://www.openwalnut.org )
//
// Copyright 2013 OpenWalnut Community, BSV-Leipzig and CNCF-CBS
// For more information see http://www.openwalnut.org/copying
//
// This file is part of OpenWalnut.
//
// OpenWalnut is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// OpenWalnut is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
//
//---------------------------------------------------------------------------
#ifndef WMProject_H
#define WMProject_H
#include <string>
#include "core/kernel/WModule.h"
#include "core/common/WItemSelection.h"
#include "core/common/WItemSelectionItem.h"
#include "core/common/WItemSelectionItemTyped.h"
#include "core/common/WItemSelector.h"
#include "core/common/WPropertyHelper.h"
#include <osg/Geode>
#include "core/kernel/WModule.h"
#include "core/kernel/WModuleInputData.h"
#include "core/kernel/WModuleOutputData.h"
enum PlaneType
{
NONE, MIP, COMPOSITING_F2B, COMPOSITING_B2F
};
// forward declarations to reduce compile dependencies
template< class T > class WModuleInputData;
class WDataSetScalar;
class WGEManagedGroupNode;
/**
* Computes contour lines (aka isolines) for the given data and render them on a 2D plane.
* \ingroup modules
*/
class WMProject: public WModule
{
public:
/**
* Creates the module for drawing contour lines.
*/
WMProject();
/**
* Destroys this module.
*/
virtual ~WMProject();
/**
* Gives back the name of this module.
* \return the module's name.
*/
virtual const std::string getName() const;
/**
* Gives back a description of this module.
* \return description to module.
*/
virtual const std::string getDescription() const;
/**
* Due to the prototype design pattern used to build modules, this method returns a new instance of this method. NOTE: it
* should never be initialized or modified in some other way. A simple new instance is required.
*
* \return the prototype used to create every module in OpenWalnut.
*/
virtual boost::shared_ptr< WModule > factory() const;
/**
* Get the icon for this module in XPM format.
*
* \return The icon.
*/
virtual const char** getXPMIcon() const;
protected:
/**
* Entry point after loading the module. Runs in separate thread.
*/
virtual void moduleMain();
/**
* Initialize the connectors this module is using.
*/
virtual void connectors();
/**
* Initialize the properties for this module.
*/
virtual void properties();
/**
* Initialize requirements for this module.
*/
virtual void requirements();
osg::ref_ptr< osg::Geode > m_geode;
private:
/**
* Input connector for scalar data.
*/
boost::shared_ptr< WModuleInputData< WDataSetScalar > > m_scalarIC;
/**
* The transfer function as an input data set
*/
boost::shared_ptr< WModuleInputData< WDataSetSingle > > m_transferFunction;
/**
* The OSG root node for this module. All other geodes or OSG nodes will be attached on this single node.
*/
osg::ref_ptr< WGEManagedGroupNode > m_rootNode;
/**
* Needed for recreating the geometry, incase when resolution changes.
*/
boost::shared_ptr< WCondition > m_propCondition;
typedef WItemSelectionItemTyped< PlaneType > MyItemType;
boost::shared_ptr< WItemSelection > m_possibleSelectionsUsingTypes;
WPropSelection m_singleSelectionAxialTop, m_singleSelectionAxialBottom,
m_singleSelectionCoronalTop, m_singleSelectionCoronalBottom,
m_singleSelectionSagittalTop, m_singleSelectionSagittalBottom;
WPropDouble m_earlyRayTerminationAlpha;
// Output
WPropPosition m_maxCoordsPosition;
WPropPosition m_normalOut;
WPropInt m_planeTypes[6];
osg::ref_ptr< WGEShader > m_shader;
boost::shared_ptr< WDataSetScalar > scalarData;
};
#endif // WMProject_H
/* XPM */
static const char * WMProject_xpm[] = {
"32 32 312 2",
" c None",
". c #FCAF60",
"+ c #F8A859",
"@ c #F6A555",
"# c #F5A351",
"$ c #F4A14E",
"% c #F29F4C",
"& c #F19E4B",
"* c #F09C48",
"= c #F09C47",
"- c #EF9A46",
"; c #EE9945",
"> c #EE9843",
", c #ED9742",
"' c #ED9741",
") c #ED9640",
"! c #EC9640",
"~ c #EB953F",
"{ c #EC953F",
"] c #EC953E",
"^ c #EB953E",
"/ c #EB953D",
"( c #EA943D",
"_ c #EB943D",
": c #EB933D",
"< c #EA923C",
"[ c #E8923C",
"} c #E7913C",
"| c #F8A959",
"1 c #0000FF",
"2 c #F3A14F",
"3 c #F3A04D",
"4 c #F19E4A",
"5 c #F09C49",
"6 c #F09B47",
"7 c #EF9A44",
"8 c #ED9843",
"9 c #EC9741",
"0 c #EC9641",
"a c #EC963F",
"b c #EA943E",
"c c #EA933D",
"d c #E5903C",
"e c #F29F4D",
"f c #F29E4B",
"g c #0604F8",
"h c #2417E0",
"i c #7B4D99",
"j c #E8923F",
"k c #EB943E",
"l c #E9933D",
"m c #E8923D",
"n c #E5913B",
"o c #E38F3B",
"p c #F39F4C",
"q c #F29E4A",
"r c #F19D49",
"s c #EE9944",
"t c #E29045",
"u c #B77369",
"v c #2E1DD8",
"w c #7D4E97",
"x c #E7923C",
"y c #E28F3B",
"z c #E08D3A",
"A c #F4A14F",
"B c #EF9C47",
"C c #EF9944",
"D c #ED9944",
"E c #BE7861",
"F c #2316E0",
"G c #E8933D",
"H c #E08D3B",
"I c #DD8B3A",
"J c #F09D49",
"K c #EF9C48",
"L c #EF9B46",
"M c #E18F44",
"N c #0805F7",
"O c #E5913C",
"P c #DE8C3A",
"Q c #DB8A39",
"R c #EF9B48",
"S c #EF9945",
"T c #ED9842",
"U c #BD7861",
"V c #0C08F3",
"W c #DC8A48",
"X c #D98847",
"Y c #0D08F2",
"Z c #E08E3B",
"` c #DB8939",
" . c #D78738",
".. c #ED9943",
"+. c #E18E44",
"@. c #B77466",
"#. c #2F1ED6",
"$. c #7C4E96",
"%. c #462BC4",
"&. c #6741A8",
"*. c #DB8947",
"=. c #6640A8",
"-. c #462CC2",
";. c #E18E3A",
">. c #D38437",
",. c #EE9A45",
"'. c #EE9844",
"). c #0503F9",
"!. c #2417DF",
"~. c #7A4D98",
"{. c #E7923E",
"]. c #D08351",
"^. c #482DC2",
"/. c #0F09F1",
"(. c #472DC1",
"_. c #CA7F4E",
":. c #E18D3B",
"<. c #D38536",
"[. c #CF8236",
"}. c #EC9540",
"|. c #EB943F",
"1. c #E8933C",
"2. c #DE8C39",
"3. c #DA8A39",
"4. c #CE8336",
"5. c #C87E34",
"6. c #EE9842",
"7. c #ED9641",
"8. c #EA943C",
"9. c #E18E3B",
"0. c #D38537",
"a. c #BD7831",
"b. c #EA933C",
"c. c #E9923D",
"d. c #E48F3B",
"e. c #DF8C39",
"f. c #D38637",
"g. c #C87F34",
"h. c #BE7831",
"i. c #B06F2E",
"j. c #E9923C",
"k. c #E7913D",
"l. c #E48F3C",
"m. c #DB8B39",
"n. c #D78838",
"o. c #D48537",
"p. c #C97F34",
"q. c #BE7832",
"r. c #B16F2E",
"s. c #A0652A",
"t. c #EB9640",
"u. c #EC943E",
"v. c #E9943D",
"w. c #D88838",
"x. c #D48637",
"y. c #A1652A",
"z. c #8D5925",
"A. c #EC9740",
"B. c #E9933C",
"C. c #E5903B",
"D. c #E4903C",
"E. c #CF8336",
"F. c #C97F35",
"G. c #BF7832",
"H. c #B1702E",
"I. c #A1662A",
"J. c #74491E",
"K. c #DC8A39",
"L. c #D88839",
"M. c #D08336",
"N. c #CA8035",
"O. c #B2702E",
"P. c #A2662A",
"Q. c #8E5A25",
"R. c #754A1F",
"S. c #513315",
"T. c #E6913C",
"U. c #DF8C3A",
"V. c #CA7F35",
"W. c #C07932",
"X. c #B2702F",
"Y. c #A3672A",
"Z. c #8F5A26",
"`. c #764A1E",
" + c #523415",
".+ c #000000",
"++ c #EB963F",
"@+ c #E8913C",
"#+ c #DF8D3A",
"$+ c #CA8034",
"%+ c #B3702E",
"&+ c #A3672B",
"*+ c #905A25",
"=+ c #774B1F",
"-+ c #543516",
";+ c #E7923D",
">+ c #E6903B",
",+ c #E4903B",
"'+ c #E28F3A",
")+ c #DC8A3A",
"!+ c #CB8034",
"~+ c #B3712E",
"{+ c #915B26",
"]+ c #784C1F",
"^+ c #553516",
"/+ c #EA953E",
"(+ c #DC8B39",
"_+ c #D98838",
":+ c #CB8035",
"<+ c #C17A32",
"[+ c #B4712F",
"}+ c #A4672A",
"|+ c #563717",
"1+ c #E6913B",
"2+ c #E28E3B",
"3+ c #CC8035",
"4+ c #B4722F",
"5+ c #A5682B",
"6+ c #925C26",
"7+ c #7A4D1F",
"8+ c #573717",
"9+ c #0A0703",
"0+ c #DC8B3A",
"a+ c #D58637",
"b+ c #D18336",
"c+ c #593817",
"d+ c #120C05",
"e+ c #E28E3A",
"f+ c #D98839",
"g+ c #D58638",
"h+ c #D08436",
"i+ c #C27A32",
"j+ c #B5722F",
"k+ c #A5692B",
"l+ c #935D26",
"m+ c #7B4E20",
"n+ c #5A3817",
"o+ c #180F06",
"p+ c #E08C3A",
"q+ c #CC8135",
"r+ c #A6682B",
"s+ c #7C4E20",
"t+ c #5B3918",
"u+ c #1C1208",
"v+ c #D98939",
"w+ c #D18436",
"x+ c #B6722F",
"y+ c #A6692C",
"z+ c #945D27",
"A+ c #7D4F20",
"B+ c #5D3A18",
"C+ c #201508",
"D+ c #E38E3B",
"E+ c #D98938",
"F+ c #D68637",
"G+ c #CD8035",
"H+ c #C37B33",
"I+ c #B6732F",
"J+ c #A7692C",
"K+ c #955D27",
"L+ c #7D4F21",
"M+ c #5D3C19",
"N+ c #241709",
"O+ c #E7913B",
"P+ c #DD8B39",
"Q+ c #D58737",
"R+ c #CD8135",
"S+ c #A86A2C",
"T+ c #955E27",
"U+ c #7E4F21",
"V+ c #5F3C19",
"W+ c #27190A",
"X+ c #B7732F",
"Y+ c #A86A2B",
"Z+ c #965F27",
"`+ c #7F5021",
" @ c #603C19",
".@ c #2A1B0B",
"+@ c #E6923C",
"@@ c #D68738",
"#@ c #D28437",
"$@ c #B87430",
"%@ c #A96B2C",
"&@ c #805121",
"*@ c #613D1A",
"=@ c #2D1C0C",
"-@ c #D28436",
";@ c #C47B33",
">@ c #B8742F",
",@ c #A96A2C",
"'@ c #986027",
")@ c #815122",
"!@ c #623E19",
"~@ c #2F1D0D",
"{@ c #D68638",
"]@ c #C57C33",
"^@ c #AA6A2C",
"/@ c #815222",
"(@ c #633F1A",
"_@ c #311F0D",
":@ c #E38F3A",
"<@ c #DD8C39",
"[@ c #DA8939",
"}@ c #D28536",
"|@ c #CD8136",
"1@ c #C47C33",
"2@ c #B97430",
"3@ c #AA6B2C",
"4@ c #986028",
"5@ c #825222",
"6@ c #64401A",
"7@ c #34200E",
". + @ # $ % & * = - ; > , ' ' ) ! ~ { ] ^ / / ( _ _ ( : : < [ } ",
"| 1 1 2 3 4 5 6 - 7 > 8 ' 9 0 a ~ ] ^ ^ b ( _ ( ( _ c c 1 1 } d ",
"@ 1 2 e f 1 1 1 1 1 8 , 1 1 g h i j ^ k 1 _ ( ( : 1 ( l m 1 n o ",
"# 1 p q r 1 - ; s , , ' 1 a t u v w / k 1 k _ ( _ 1 l [ x 1 y z ",
"A 1 4 r B 1 C D , ' ' 0 1 ~ ] ] E F _ _ 1 ( _ : ( 1 G } n 1 H I ",
"3 1 J K L 1 1 1 1 1 ! ! 1 { ^ k M N _ _ 1 ( _ ( c 1 } O o 1 P Q ",
"& 1 R - S 1 T , 9 0 ! { 1 ~ ^ _ U F _ ( V W ( l X Y n o Z 1 ` .",
"5 1 L ; ..1 ' ' 0 ! ~ { 1 k +.@.#.$._ c %.&.*.X =.-.o ;.P 1 .>.",
"* 1 ,.'.T 1 1 1 1 1 ~ ^ 1 1 ).!.~.{.( : ].^././.(._.:.P Q 1 <.[.",
"L 1 1 8 , 9 ! }.a ~ |.^ / / _ b _ _ : c c 1.x O o z 2.3.1 1 4.5.",
"S s 6.' 7.) ! a { ^ k k _ k _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.+.+.+.+",
"c _ c l [ T.C.y H P+f+g+w+q+H+X+Y+Z+`+ @.@.+.+.+.+.+.+.+.+.+.+.+",
"( b.B.1.+@C.o z 0+_+@@#@R+H+$@%@Z+&@*@=@.+.+.+.+.+.+.+.+.+.+.+.+",
"( b.m } C.e+z 0+E+@@-@R+;@>@,@'@)@!@~@.+.+.+.+.+.+.+.+.+.+.+.+.+",
"l [ } ,+y z P+v+{@-@R+]@$@^@'@/@(@_@.+.+.+.+.+.+.+.+.+.+.+.+.+.+",
"[ x d :@z <@[@@@}@|@1@2@3@4@5@6@7@.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+"};
//---------------------------------------------------------------------------
//
// Project: OpenWalnut ( http://www.openwalnut.org )
//
// Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
// For more information see http://www.openwalnut.org/copying
//
// This file is part of OpenWalnut.
//
// OpenWalnut is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// OpenWalnut is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
//
//---------------------------------------------------------------------------
#version 130
#include "WGEColormapping-fragment.glsl"
// If this uniform is true, the plane should not discard fragments
uniform bool u_showComplete;
uniform vec3 maxCoords; // contains the size of the 3d texture
uniform sampler1D u_transferFunctionSampler; // contains the transfer function histogram
/*
Values are the same as in the enum Type PlaneType
in WMProject.h e. g.
0: None
1: MIP
2: Compositing F2B
3: Compositing B2F
*/
uniform int axialTop;
uniform int axialBottom;
uniform int coronalTop;
uniform int coronalBottom;
uniform int sagittalTop;
uniform int sagittalBottom;
uniform float earlyRayTerminationAlpha;
varying vec3 normal;
void doMIP(vec3 initialPosition, int direction, float maxSize)
{
float maxColor = 0.0;
for(float n = 0.0; n < 1.0; n += 1.0/maxSize)
{
initialPosition[direction] = n;
if(texture3D( u_colormap0Sampler, initialPosition ).r > maxColor)
maxColor = texture3D( u_colormap0Sampler, initialPosition ).r;
}
gl_FragColor = vec4(maxColor,maxColor,maxColor,1.0);
}
void doCompositingF2B(vec3 initialPosition, int direction, float maxSize)
{
vec3 finalColor = texture1D( u_transferFunctionSampler, texture3D( u_colormap0Sampler, initialPosition ).r ).rgb;
float finalAlpha = texture1D( u_transferFunctionSampler, texture3D( u_colormap0Sampler, initialPosition ).r ).a;
bool front = initialPosition[direction] == 0.0;
float n;
bool run = true;
if(front)
{
n = 1.0/maxSize;
}
else
{
n = 1.0 - 1.0/maxSize; // invert
}
while(run)
{
initialPosition[direction] = n;
vec4 nextPlane = texture1D( u_transferFunctionSampler, texture3D( u_colormap0Sampler, initialPosition ).r );
nextPlane = vec4(nextPlane.rgb*nextPlane.a,nextPlane.a);
// C_out = (1 - a_in)*C + C_in
finalColor = (1-finalAlpha)*nextPlane.rgb+finalColor;
// a_out = (1 - a_in)*a + a_in
finalAlpha = (1-finalAlpha)*nextPlane.a+finalAlpha;
if(finalAlpha > earlyRayTerminationAlpha)
{
run = false; // Early Ray Termination
}else{
if(front)
{
n += 1.0/maxSize;
if(n > 1.0)
{
run = false;
}
}
else
{
n -= 1.0/maxSize;
if(n < 0.0)
{
run = false;
}
}
}
}
gl_FragColor = vec4(finalColor, 1.0);
}
void doCompositingB2F(vec3 initialPosition, int direction, float maxSize)
{
bool front = initialPosition[direction] == 0.0;
float n;
bool run = true;
vec3 finalColor =