Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
OpenWalnut Core
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
44
Issues
44
List
Boards
Labels
Service Desk
Milestones
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
OpenWalnut
OpenWalnut Core
Commits
57ad80c3
Commit
57ad80c3
authored
May 28, 2017
by
Alexander Wiebel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[REFAC] extracted function evaluating transfer function
parent
14bd6de0
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
57 additions
and
48 deletions
+57
-48
src/modules/pickingDVR/WMPickingDVR.cpp
src/modules/pickingDVR/WMPickingDVR.cpp
+48
-48
src/modules/pickingDVR/WMPickingDVR.h
src/modules/pickingDVR/WMPickingDVR.h
+9
-0
No files found.
src/modules/pickingDVR/WMPickingDVR.cpp
View file @
57ad80c3
...
...
@@ -526,77 +526,77 @@ std::vector< std::pair< double, WPosition > > WMPickingDVR::sampleIntensityAlong
return
result
;
}
WPosition
WMPickingDVR
::
getPickedDVRPosition
(
std
::
string
pickingMode
,
bool
*
pickingSuccess
)
double
WMPickingDVR
::
getTFAlpha
(
const
double
scalar
)
const
{
std
::
vector
<
std
::
pair
<
double
,
WPosition
>
>
samples
(
0
);
samples
=
sampleIntensityAlongRay
();
if
(
samples
.
size
()
==
0
)
{
*
pickingSuccess
=
false
;
}
WPosition
posPicking
=
m_posStart
;
double
max
=
0.0
;
double
min
=
0.0
;
double
accAlpha
=
0.0
;
double
accAlphaOld
=
0.0
;
double
pickedAlpha
=
0.0
;
double
maxValue
=
0.0
;
// Get transferfunction data
boost
::
shared_ptr
<
WDataSetSingle
>
transferFunctionData
=
m_transferFunction
->
getData
();
if
(
!
transferFunctionData
)
if
(
!
transferFunctionData
)
{
errorLog
()
<<
"[Invalid transferfunction data]"
;
*
pickingSuccess
=
false
;
return
WPosition
();
WAssert
(
false
,
"Invalid transferfunction data"
);
}
// Get transferfunction values
boost
::
shared_ptr
<
WValueSetBase
>
transferFunctionValues
=
transferFunctionData
->
getValueSet
();
// Get scalar field
boost
::
shared_ptr
<
WDataSetScalar
>
scalarData
=
m_scalarIC
->
getData
();
if
(
!
scalarData
)
{
errorLog
()
<<
"[Invalid scalar field]"
;
return
WPosition
();
WAssert
(
false
,
"Invalid scalar field"
);
}
max
=
scalarData
->
getMax
();
min
=
scalarData
->
getMin
();
maxValue
=
min
;
const
double
max
=
scalarData
->
getMax
();
const
double
min
=
scalarData
->
getMin
();
std
::
vector
<
double
>
vecAlphaAcc
;
// Classification variables
const
double
nominator
=
scalar
-
min
;
double
denominator
=
max
-
min
;
// Sampling loop
for
(
unsigned
int
i
=
0
;
i
<
samples
.
size
();
i
++
)
if
(
denominator
==
0.0
)
{
// Classification variables
double
nominator
=
samples
[
i
].
first
-
min
;
double
denominator
=
max
-
min
;
denominator
=
0.0001
;
}
if
(
denominator
==
0.0
)
{
denominator
=
0.0001
;
}
// Classification: Convert scalar to color
double
scalarPercentage
=
nominator
/
denominator
;
int
colorIdx
=
scalarPercentage
*
transferFunctionValues
->
size
();
WMPickingColor
<
double
>
color
;
// Classification: Convert scalar to color
double
scalarPercentage
=
nominator
/
denominator
;
int
colorIdx
=
scalarPercentage
*
transferFunctionValues
->
size
();
// Get color from transferfunction
color
.
setRed
(
transferFunctionData
->
getSingleRawValue
(
colorIdx
*
4
+
0
)
);
color
.
setGreen
(
transferFunctionData
->
getSingleRawValue
(
colorIdx
*
4
+
1
)
);
color
.
setBlue
(
transferFunctionData
->
getSingleRawValue
(
colorIdx
*
4
+
2
)
);
color
.
setAlpha
(
transferFunctionData
->
getSingleRawValue
(
colorIdx
*
4
+
3
)
);
color
.
normalize
();
WMPickingColor
<
double
>
color
;
return
color
.
getAlpha
();
}
// Get color from transferfunction
color
.
setRed
(
transferFunctionData
->
getSingleRawValue
(
colorIdx
*
4
+
0
)
);
color
.
setGreen
(
transferFunctionData
->
getSingleRawValue
(
colorIdx
*
4
+
1
)
);
color
.
setBlue
(
transferFunctionData
->
getSingleRawValue
(
colorIdx
*
4
+
2
)
);
color
.
setAlpha
(
transferFunctionData
->
getSingleRawValue
(
colorIdx
*
4
+
3
)
);
color
.
normalize
();
double
currentAlpha
=
color
.
getAlpha
();
WPosition
WMPickingDVR
::
getPickedDVRPosition
(
std
::
string
pickingMode
,
bool
*
pickingSuccess
)
{
std
::
vector
<
std
::
pair
<
double
,
WPosition
>
>
samples
(
0
);
samples
=
sampleIntensityAlongRay
();
if
(
samples
.
size
()
==
0
)
{
*
pickingSuccess
=
false
;
return
WPosition
();
}
WPosition
posPicking
=
m_posStart
;
double
accAlpha
=
0.0
;
double
accAlphaOld
=
0.0
;
double
pickedAlpha
=
0.0
;
double
maxValue
=
-
1
*
std
::
numeric_limits
<
double
>::
max
();;
std
::
vector
<
double
>
vecAlphaAcc
;
for
(
unsigned
int
i
=
0
;
i
<
samples
.
size
();
i
++
)
{
const
double
currentAlpha
=
getTFAlpha
(
samples
[
i
].
first
);
double
currentAlphaCorrected
;
if
(
m_opacityCorrectionEnabled
->
get
(
true
)
)
...
...
src/modules/pickingDVR/WMPickingDVR.h
View file @
57ad80c3
...
...
@@ -151,6 +151,15 @@ private:
*/
std
::
vector
<
std
::
pair
<
double
,
WPosition
>
>
sampleIntensityAlongRay
();
/**
* Evaluate transfer function.
*
* \param scalar Evaluate transfer function for this value.
*
* \returnOpacity obtained from transfer function.
*/
double
getTFAlpha
(
const
double
scalar
)
const
;
/**
* Compute the position picked in the DVR
*
...
...
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