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
Open sidebar
OpenWalnut
OpenWalnut Core
Commits
99b21b1d
Commit
99b21b1d
authored
Aug 13, 2010
by
Alexander Wiebel
Browse files
[---] added changes of f64ff25a729c and fda591666023 as patch to release
branch, as schurade wants to have them in.
parent
98b6d23a
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
198 additions
and
46 deletions
+198
-46
src/graphicsEngine/WGEUtils.cpp
src/graphicsEngine/WGEUtils.cpp
+74
-0
src/graphicsEngine/WGEUtils.h
src/graphicsEngine/WGEUtils.h
+8
-0
src/graphicsEngine/WROIArbitrary.cpp
src/graphicsEngine/WROIArbitrary.cpp
+24
-0
src/graphicsEngine/WROIArbitrary.h
src/graphicsEngine/WROIArbitrary.h
+17
-0
src/modules/atlasSurfaces/WMAtlasSurfaces.cpp
src/modules/atlasSurfaces/WMAtlasSurfaces.cpp
+3
-24
src/modules/paintTexture/WMPaintTexture.cpp
src/modules/paintTexture/WMPaintTexture.cpp
+62
-17
src/modules/paintTexture/WMPaintTexture.h
src/modules/paintTexture/WMPaintTexture.h
+10
-5
No files found.
src/graphicsEngine/WGEUtils.cpp
View file @
99b21b1d
...
...
@@ -45,3 +45,77 @@ osg::Vec3 wge::unprojectFromScreen( const osg::Vec3 screen, osg::ref_ptr< osg::C
{
return
screen
*
osg
::
Matrix
::
inverse
(
camera
->
getViewMatrix
()
*
camera
->
getProjectionMatrix
()
*
camera
->
getViewport
()
->
computeWindowMatrix
()
);
}
WColor
wge
::
createColorFromIndex
(
int
index
)
{
float
r
=
0.0
;
float
g
=
0.0
;
float
b
=
0.0
;
float
mult
=
1.0
;
if
(
index
==
0
)
{
return
WColor
(
0.0
,
0.0
,
0.0
);
}
if
(
(
index
&
1
)
==
1
)
{
b
=
1.0
;
}
if
(
(
index
&
2
)
==
2
)
{
g
=
1.0
;
}
if
(
(
index
&
4
)
==
4
)
{
r
=
1.0
;
}
if
(
(
index
&
8
)
==
8
)
{
mult
-=
0.15
;
if
(
r
<
1.0
&&
g
<
1.0
&&
b
<
1.0
)
{
r
=
1.0
;
g
=
1.0
;
}
}
if
(
(
index
&
16
)
==
16
)
{
mult
-=
0.15
;
if
(
r
<
1.0
&&
g
<
1.0
&&
b
<
1.0
)
{
b
=
1.0
;
g
=
1.0
;
}
}
if
(
(
index
&
32
)
==
32
)
{
mult
-=
0.15
;
if
(
r
<
1.0
&&
g
<
1.0
&&
b
<
1.0
)
{
r
=
1.0
;
b
=
1.0
;
}
}
if
(
(
index
&
64
)
==
64
)
{
mult
-=
0.15
;
if
(
r
<
1.0
&&
g
<
1.0
&&
b
<
1.0
)
{
g
=
1.0
;
}
}
if
(
(
index
&
128
)
==
128
)
{
mult
-=
0.15
;
if
(
r
<
1.0
&&
g
<
1.0
&&
b
<
1.0
)
{
r
=
1.0
;
}
}
r
*=
mult
;
g
*=
mult
;
b
*=
mult
;
return
WColor
(
r
,
g
,
b
);
}
src/graphicsEngine/WGEUtils.h
View file @
99b21b1d
...
...
@@ -85,6 +85,14 @@ namespace wge
* \param v the vector to convert.
*/
osg
::
Vec3
wv3D2ov3
(
wmath
::
WVector3D
v
);
/**
* creates the same color as the atlas colormap shader from the index
*
* \param index unsigned char that indexes the color
* \return the color
*/
WColor
createColorFromIndex
(
int
index
);
}
inline
WColor
wge
::
getRGBAColorFromDirection
(
const
wmath
::
WPosition
&
pos1
,
const
wmath
::
WPosition
&
pos2
)
...
...
src/graphicsEngine/WROIArbitrary.cpp
View file @
99b21b1d
...
...
@@ -65,6 +65,30 @@ WROIArbitrary::WROIArbitrary( size_t nbCoordsX, size_t nbCoordsY, size_t nbCoord
setUpdateCallback
(
osg
::
ref_ptr
<
ROIArbNodeCallback
>
(
new
ROIArbNodeCallback
)
);
}
WROIArbitrary
::
WROIArbitrary
(
size_t
nbCoordsX
,
size_t
nbCoordsY
,
size_t
nbCoordsZ
,
const
wmath
::
WMatrix
<
double
>&
mat
,
const
std
::
vector
<
float
>&
vals
,
float
maxThreshold
,
WColor
color
)
:
WROI
(),
m_nbCoordsVec
(
3
),
m_matrix
(
mat
),
m_vals
(
vals
),
m_threshold
(
0.01
),
m_maxThreshold
(
maxThreshold
),
m_color
(
color
)
{
m_nbCoordsVec
[
0
]
=
nbCoordsX
;
m_nbCoordsVec
[
1
]
=
nbCoordsY
;
m_nbCoordsVec
[
2
]
=
nbCoordsZ
;
updateGFX
();
m_isModified
=
true
;
WGraphicsEngine
::
getGraphicsEngine
()
->
getScene
()
->
addChild
(
this
);
setUserData
(
this
);
setUpdateCallback
(
osg
::
ref_ptr
<
ROIArbNodeCallback
>
(
new
ROIArbNodeCallback
)
);
}
WROIArbitrary
::~
WROIArbitrary
()
{
// std::cout << "destructor called" << std::endl;
...
...
src/graphicsEngine/WROIArbitrary.h
View file @
99b21b1d
...
...
@@ -70,6 +70,23 @@ public:
float
maxThreshold
,
WColor
color
);
/**
* constructor
* \param nbCoordsX number of vertices in X direction
* \param nbCoordsY number of vertices in Y direction
* \param nbCoordsZ number of vertices in Z direction
* \param mat the matrix transforming the vertices from canonical space
* \param vals the values at the vertices
* \param maxThreshold The maximum of the values.
* \param color the color to use for the ROI.
*/
WROIArbitrary
(
size_t
nbCoordsX
,
size_t
nbCoordsY
,
size_t
nbCoordsZ
,
const
wmath
::
WMatrix
<
double
>&
mat
,
const
std
::
vector
<
float
>&
vals
,
float
maxThreshold
,
WColor
color
);
/**
* destructor
*/
...
...
src/modules/atlasSurfaces/WMAtlasSurfaces.cpp
View file @
99b21b1d
...
...
@@ -38,9 +38,9 @@
#include "../../common/WAssert.h"
#include "../../dataHandler/WDataSetScalar.h"
#include "../../kernel/WKernel.h"
#include "../../graphicsEngine/WGEUtils.h"
#include "../../graphicsEngine/algorithms/WMarchingCubesAlgorithm.h"
#include "../../kernel/WKernel.h"
#include "WMAtlasSurfaces.h"
#include "atlas.xpm"
...
...
@@ -314,28 +314,7 @@ void WMAtlasSurfaces::createOSGNode()
// colors
osg
::
Vec4Array
*
colors
=
new
osg
::
Vec4Array
;
float
r
=
0.0
;
float
g
=
0.0
;
float
b
=
0.0
;
if
(
(
(
i
+
1
)
&
1
)
==
1
)
r
=
0.4
;
if
(
(
(
i
+
1
)
&
2
)
==
2
)
g
=
0.4
;
if
(
(
(
i
+
1
)
&
4
)
==
4
)
b
=
0.4
;
if
(
(
(
i
+
1
)
&
8
)
==
8
)
b
+=
0.3
;
if
(
(
(
i
+
1
)
&
16
)
==
16
)
r
+=
0.3
;
if
(
(
(
i
+
1
)
&
32
)
==
32
)
g
+=
0.3
;
if
(
(
(
i
+
1
)
&
64
)
==
64
)
r
+=
0.3
;
if
(
(
(
i
+
1
)
&
128
)
==
128
)
b
+=
0.3
;
colors
->
push_back
(
osg
::
Vec4
(
r
,
g
,
b
,
1.0
f
)
);
colors
->
push_back
(
wge
::
osgColor
(
wge
::
createColorFromIndex
(
i
+
1
)
)
);
surfaceGeometry
->
setColorArray
(
colors
);
surfaceGeometry
->
setColorBinding
(
osg
::
Geometry
::
BIND_OVERALL
);
...
...
src/modules/paintTexture/WMPaintTexture.cpp
View file @
99b21b1d
...
...
@@ -26,12 +26,13 @@
#include <sstream>
#include <vector>
#include "../../
kernel/WKernel
.h"
#include "../../
common/WPropertyHelper
.h"
#include "../../dataHandler/WDataHandler.h"
#include "../../dataHandler/WDataTexture3D.h"
#include "../../dataHandler/WSubject.h"
#include "../../common/WPropertyHelper.h"
#include "../../graphicsEngine/WGEUtils.h"
#include "../../graphicsEngine/WROIArbitrary.h"
#include "../../kernel/WKernel.h"
#include "paintTexture.xpm" // Please put a real icon here.
...
...
@@ -130,6 +131,8 @@ void WMPaintTexture::properties()
m_buttonUpdateOutput
=
m_properties
->
addProperty
(
"Update output"
,
"Updates the output connector"
,
WPVBaseTypes
::
PV_TRIGGER_READY
,
m_propCondition
);
m_buttonCreateRoi
=
m_properties
->
addProperty
(
"Create ROI"
,
"Create a ROI from the currently selected paint value"
,
WPVBaseTypes
::
PV_TRIGGER_READY
,
m_propCondition
);
}
void
WMPaintTexture
::
propertyChanged
(
boost
::
shared_ptr
<
WPropertyBase
>
property
)
...
...
@@ -215,6 +218,12 @@ void WMPaintTexture::moduleMain()
copyFromInput
();
m_buttonCopyFromInput
->
set
(
WPVBaseTypes
::
PV_TRIGGER_READY
,
false
);
}
if
(
m_buttonCreateRoi
->
get
(
true
)
==
WPVBaseTypes
::
PV_TRIGGER_TRIGGERED
)
{
createROI
();
m_buttonCreateRoi
->
set
(
WPVBaseTypes
::
PV_TRIGGER_READY
,
false
);
}
}
else
// case !dataValid
{
...
...
@@ -379,10 +388,11 @@ void WMPaintTexture::doPaint()
void
WMPaintTexture
::
queuePaint
(
WPickInfo
pickInfo
)
{
if
(
!
m_painting
->
get
()
||
(
pickInfo
.
getMouseButton
()
!=
WPickInfo
::
MOUSE_LEFT
)
)
if
(
!
m_painting
->
get
()
||
(
pickInfo
.
getMouseButton
()
!=
WPickInfo
::
MOUSE_LEFT
)
||
(
pickInfo
.
getName
()
==
"unpick"
)
)
{
return
;
}
m_paintQueue
.
push
(
pickInfo
);
m_queueAdded
->
set
(
true
);
}
...
...
@@ -391,17 +401,14 @@ void WMPaintTexture::createTexture()
{
m_grid
=
boost
::
shared_dynamic_cast
<
WGridRegular3D
>
(
m_dataSet
->
getGrid
()
);
m_values
.
resize
(
m_grid
->
size
(),
0
);
m_values
[
0
]
=
255
;
osg
::
ref_ptr
<
osg
::
Image
>
ima
=
new
osg
::
Image
;
ima
->
allocateImage
(
m_grid
->
getNbCoordsX
(),
m_grid
->
getNbCoordsY
(),
m_grid
->
getNbCoordsZ
(),
GL_LUMINANCE
,
GL_UNSIGNED_BYTE
);
unsigned
char
*
data
=
ima
->
data
();
for
(
unsigned
int
i
=
0
;
i
<
m_grid
->
getNbCoordsX
()
*
m_grid
->
getNbCoordsY
()
*
m_grid
->
getNbCoordsZ
();
++
i
)
for
(
unsigned
int
i
=
0
;
i
<
m_grid
->
size
();
++
i
)
{
data
[
i
]
=
m_values
[
i
]
;
data
[
i
]
=
0.0
;
}
m_texture
=
osg
::
ref_ptr
<
osg
::
Texture3D
>
(
new
osg
::
Texture3D
);
...
...
@@ -425,20 +432,18 @@ void WMPaintTexture::updateOutDataset()
WAssert
(
m_dataSet
->
getValueSet
(),
""
);
WAssert
(
m_dataSet
->
getGrid
(),
""
);
boost
::
shared_ptr
<
WGridRegular3D
>
grid
=
boost
::
shared_dynamic_cast
<
WGridRegular3D
>
(
m_dataSet
->
getGrid
()
);
WAssert
(
grid
,
""
);
unsigned
char
*
data
=
m_texture
->
getImage
()
->
data
();
std
::
vector
<
unsigned
char
>
values
(
m_grid
->
size
(),
0.0
);
for
(
unsigned
int
i
=
0
;
i
<
m_grid
->
getNbCoordsX
()
*
m_grid
->
getNbCoordsY
()
*
m_grid
->
getNbCoordsZ
();
++
i
)
for
(
unsigned
int
i
=
0
;
i
<
m_grid
->
size
();
++
i
)
{
m_
values
[
i
]
=
data
[
i
];
values
[
i
]
=
data
[
i
];
}
boost
::
shared_ptr
<
WValueSet
<
unsigned
char
>
>
vs
=
boost
::
shared_ptr
<
WValueSet
<
unsigned
char
>
>
(
new
WValueSet
<
unsigned
char
>
(
0
,
1
,
m_
values
,
W_DT_UINT8
)
);
boost
::
shared_ptr
<
WValueSet
<
unsigned
char
>
>
(
new
WValueSet
<
unsigned
char
>
(
0
,
1
,
values
,
W_DT_UINT8
)
);
m_outData
=
boost
::
shared_ptr
<
WDataSetScalar
>
(
new
WDataSetScalar
(
vs
,
grid
)
);
m_outData
=
boost
::
shared_ptr
<
WDataSetScalar
>
(
new
WDataSetScalar
(
vs
,
m_
grid
)
);
m_output
->
updateData
(
m_outData
);
}
...
...
@@ -451,9 +456,49 @@ void WMPaintTexture::copyFromInput()
boost
::
shared_ptr
<
WValueSet
<
unsigned
char
>
>
vals
;
vals
=
boost
::
shared_dynamic_cast
<
WValueSet
<
unsigned
char
>
>
(
m_dataSet
->
getValueSet
()
);
for
(
unsigned
int
i
=
0
;
i
<
m_grid
->
getNbCoordsX
()
*
m_grid
->
getNbCoordsY
()
*
m_grid
->
getNbCoordsZ
();
++
i
)
for
(
unsigned
int
i
=
0
;
i
<
m_grid
->
size
();
++
i
)
{
data
[
i
]
=
vals
->
getScalar
(
i
);
}
m_texture
->
dirtyTextureObject
();
}
void
WMPaintTexture
::
createROI
()
{
if
(
!
WKernel
::
getRunningKernel
()
->
getRoiManager
()
->
getBitField
()
)
{
wlog
::
warn
(
"WMPaintTexture"
)
<<
"Refused to add ROI, as ROIManager does not have computed its bitfield yet."
;
return
;
}
bool
valid
=
false
;
std
::
vector
<
float
>
roiVals
(
m_grid
->
size
(),
0
);
unsigned
char
index
=
m_paintIndex
->
get
();
unsigned
char
*
data
=
m_texture
->
getImage
()
->
data
();
for
(
size_t
i
=
0
;
i
<
m_grid
->
size
();
++
i
)
{
if
(
data
[
i
]
==
index
)
{
roiVals
[
i
]
=
1.0
;
valid
=
true
;
}
}
if
(
valid
)
{
osg
::
ref_ptr
<
WROI
>
newRoi
=
osg
::
ref_ptr
<
WROI
>
(
new
WROIArbitrary
(
m_grid
->
getNbCoordsX
(),
m_grid
->
getNbCoordsY
(),
m_grid
->
getNbCoordsZ
(),
m_grid
->
getTransformationMatrix
(),
roiVals
,
1.0
,
wge
::
createColorFromIndex
(
index
)
)
);
if
(
WKernel
::
getRunningKernel
()
->
getRoiManager
()
->
getSelectedRoi
()
==
NULL
)
{
WKernel
::
getRunningKernel
()
->
getRoiManager
()
->
addRoi
(
newRoi
);
}
else
{
WKernel
::
getRunningKernel
()
->
getRoiManager
()
->
addRoi
(
newRoi
,
WKernel
::
getRunningKernel
()
->
getRoiManager
()
->
getSelectedRoi
()
->
getROI
()
);
}
}
}
src/modules/paintTexture/WMPaintTexture.h
View file @
99b21b1d
...
...
@@ -148,6 +148,11 @@ private:
*/
void
copyFromInput
();
/**
* creates a ROI from the currently selected paint value
*/
void
createROI
();
/**
* Interpolation?
*/
...
...
@@ -188,11 +193,6 @@ private:
*/
WPropBool
m_queueAdded
;
/**
* field that stores the new values
*/
std
::
vector
<
unsigned
char
>
m_values
;
/**
* new paint coordinates get added here
*/
...
...
@@ -247,6 +247,11 @@ private:
* updates the output connector on demand, as we don't want to do this every paint command
*/
WPropTrigger
m_buttonUpdateOutput
;
/**
* updates the output connector on demand, as we don't want to do this every paint command
*/
WPropTrigger
m_buttonCreateRoi
;
};
#endif // WMPAINTTEXTURE_H
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