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
c8aad0ca
Commit
c8aad0ca
authored
May 28, 2017
by
Alexander Wiebel
Browse files
[ADD] now we coompute the candidates for visiTrace
Optimization still missing.
parent
b5112d62
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
102 additions
and
50 deletions
+102
-50
src/modules/pickingDVR/WMPickingDVR.cpp
src/modules/pickingDVR/WMPickingDVR.cpp
+80
-36
src/modules/pickingDVR/WMPickingDVR.h
src/modules/pickingDVR/WMPickingDVR.h
+11
-4
src/modules/pickingDVR/WVisiTrace.cpp
src/modules/pickingDVR/WVisiTrace.cpp
+9
-4
src/modules/pickingDVR/WVisiTrace.h
src/modules/pickingDVR/WVisiTrace.h
+2
-6
No files found.
src/modules/pickingDVR/WMPickingDVR.cpp
View file @
c8aad0ca
...
...
@@ -66,8 +66,8 @@ WModule(),
m_curve3D
(
0
)
{
m_intersected
=
false
;
m_posStart
=
osg
::
Vec3f
(
0.0
,
0.0
,
0.0
);
m_posEnd
=
osg
::
Vec3f
(
0.0
,
0.0
,
0.0
);
m_posStart
=
osg
::
Vec3f
(
0.0
,
0.0
,
0.0
);
m_posEnd
=
osg
::
Vec3f
(
0.0
,
0.0
,
0.0
);
}
WMPickingDVR
::~
WMPickingDVR
()
...
...
@@ -290,8 +290,11 @@ void WMPickingDVR::moduleMain()
bool
pickingSuccessful
=
false
;
const
WPosition
posPicking
=
getPickedDVRPosition
(
pickingMode
,
&
pickingSuccessful
);
#warning need to call actual relvant function here
//m_visiTrace.addCandidatesForRay
std
::
vector
<
std
::
pair
<
double
,
WPosition
>
>
candidates
=
computeVisiTraceCandidates
();
if
(
candidates
.
size
()
)
{
m_visiTrace
.
addCandidatesForRay
(
candidates
);
}
if
(
m_continuousDrawing
->
get
()
||
!
m_pickInProgress
)
...
...
@@ -393,25 +396,49 @@ void WMPickingDVR::updateModuleGUI( std::string pickingMode )
}
}
std
::
pair
<
int
,
int
>
WMPickingDVR
::
getWYSIWYPBounds
(
const
std
::
vector
<
double
>&
vecAlphaAcc
)
{
std
::
vector
<
int
>
dummyVector
;
return
calculateIntervalsWYSIWYP
(
vecAlphaAcc
,
dummyVector
);
std
::
vector
<
int
>
vecIndicesLowerBounds
;
std
::
vector
<
int
>
vecIndicesUpperBounds
;
calculateIntervalsWYSIWYP
(
vecAlphaAcc
,
vecIndicesLowerBounds
,
vecIndicesUpperBounds
);
// Calculate max difference
double
diff
=
0.0
;
double
maxDiff
=
0.0
;
int
sampleLo
=
-
1
;
int
sampleUp
=
-
1
;
for
(
unsigned
int
j
=
0
;
j
<
std
::
min
(
vecIndicesLowerBounds
.
size
(),
vecIndicesUpperBounds
.
size
()
);
j
++
)
{
// Calculate opacity jump of interval
diff
=
vecAlphaAcc
[
vecIndicesUpperBounds
[
j
]]
-
vecAlphaAcc
[
vecIndicesLowerBounds
[
j
]];
//debugLog() << "Interval [" << vecIndicesLowerBounds[j] << "," << vecIndicesUpperBounds[j] << "] = " << diff;
// Is max diff
if
(
diff
>
maxDiff
)
{
maxDiff
=
diff
;
sampleLo
=
vecIndicesLowerBounds
[
j
];
sampleUp
=
vecIndicesUpperBounds
[
j
];
}
}
//debugLog() << "Start of largest interval " << sampleLo;
return
std
::
make_pair
(
sampleLo
,
sampleUp
);
}
std
::
pair
<
int
,
int
>
WMPickingDVR
::
calculateIntervalsWYSIWYP
(
const
std
::
vector
<
double
>&
vecAlphaAcc
,
std
::
vector
<
int
>&
vecIndicesLowerBounds
)
void
WMPickingDVR
::
calculateIntervalsWYSIWYP
(
const
std
::
vector
<
double
>&
vecAlphaAcc
,
std
::
vector
<
int
>&
vecIndicesLowerBounds
,
std
::
vector
<
int
>&
vecIndicesUpperBounds
)
{
std
::
vector
<
double
>
vecFirstDerivative
;
std
::
vector
<
double
>
vecSecondDerivative
;
PickingDVRHelper
::
calculateDerivativesWYSIWYP
(
vecAlphaAcc
,
vecFirstDerivative
,
vecSecondDerivative
);
// Upper bounds temporary variable ... will not be returned
std
::
vector
<
int
>
vecIndicesUpperBounds
;
// Calculate iterval boundaries
// Calculate interval boundaries
double
oldDerivative
;
if
(
vecSecondDerivative
.
size
()
>
0
)
{
...
...
@@ -433,30 +460,6 @@ std::pair<int, int> WMPickingDVR::calculateIntervalsWYSIWYP( const std::vector<d
oldDerivative
=
vecSecondDerivative
[
j
];
}
// Calculate max difference
double
diff
=
0.0
;
double
maxDiff
=
0.0
;
int
sampleLo
=
-
1
;
int
sampleUp
=
-
1
;
for
(
unsigned
int
j
=
0
;
j
<
std
::
min
(
vecIndicesLowerBounds
.
size
(),
vecIndicesUpperBounds
.
size
()
);
j
++
)
{
// Calculate opacity jump of interval
diff
=
vecAlphaAcc
[
vecIndicesUpperBounds
[
j
]]
-
vecAlphaAcc
[
vecIndicesLowerBounds
[
j
]];
//debugLog() << "Interval [" << vecIndicesLowerBounds[j] << "," << vecIndicesUpperBounds[j] << "] = " << diff;
//Is Max Diff
if
(
diff
>
maxDiff
)
{
maxDiff
=
diff
;
sampleLo
=
vecIndicesLowerBounds
[
j
];
sampleUp
=
vecIndicesUpperBounds
[
j
];
}
}
//debugLog() << "Start of largest interval " << sampleLo;
return
std
::
make_pair
(
sampleLo
,
sampleUp
);
}
void
WMPickingDVR
::
updatePositionIndicator
(
osg
::
Vec3f
position
)
...
...
@@ -594,6 +597,47 @@ double WMPickingDVR::compositingStep( double accAlpha, const double currentAlpha
}
std
::
vector
<
std
::
pair
<
double
,
WPosition
>
>
WMPickingDVR
::
computeVisiTraceCandidates
()
{
std
::
vector
<
std
::
pair
<
double
,
WPosition
>
>
samples
(
0
);
samples
=
sampleIntensityAlongRay
();
if
(
samples
.
size
()
==
0
)
{
return
std
::
vector
<
std
::
pair
<
double
,
WPosition
>
>
();
}
WPosition
posPicking
=
m_posStart
;
double
accAlpha
=
0.0
;
std
::
vector
<
double
>
vecAlphaAcc
;
for
(
unsigned
int
i
=
0
;
i
<
samples
.
size
();
i
++
)
{
const
double
currentAlpha
=
getTFAlpha
(
samples
[
i
].
first
);
accAlpha
=
compositingStep
(
accAlpha
,
currentAlpha
);
vecAlphaAcc
.
push_back
(
accAlpha
);
}
std
::
vector
<
int
>
vecIndicesLowerBounds
;
std
::
vector
<
int
>
vecIndicesUpperBounds
;
calculateIntervalsWYSIWYP
(
vecAlphaAcc
,
vecIndicesLowerBounds
,
vecIndicesUpperBounds
);
std
::
vector
<
int
>
opacityJumps
(
0
);
for
(
unsigned
int
j
=
0
;
j
<
std
::
min
(
vecIndicesLowerBounds
.
size
(),
vecIndicesUpperBounds
.
size
()
);
j
++
)
{
opacityJumps
.
push_back
(
vecAlphaAcc
[
vecIndicesUpperBounds
[
j
]]
-
vecAlphaAcc
[
vecIndicesLowerBounds
[
j
]]
);
}
std
::
vector
<
std
::
pair
<
double
,
WPosition
>
>
candidates
(
0
);
std
::
cout
<<
vecIndicesLowerBounds
.
size
()
<<
" - "
<<
opacityJumps
.
size
()
<<
std
::
endl
;
for
(
size_t
id
=
0
;
id
<
opacityJumps
.
size
();
++
id
)
{
candidates
.
push_back
(
std
::
make_pair
(
opacityJumps
[
id
],
samples
[
vecIndicesLowerBounds
[
id
]].
second
)
);
}
return
candidates
;
}
WPosition
WMPickingDVR
::
getPickedDVRPosition
(
std
::
string
pickingMode
,
bool
*
pickingSuccess
)
{
std
::
vector
<
std
::
pair
<
double
,
WPosition
>
>
samples
(
0
);
...
...
src/modules/pickingDVR/WMPickingDVR.h
View file @
c8aad0ca
...
...
@@ -129,11 +129,11 @@ private:
*
* \param vecAlphaAcc The accumulated alpha values at the samples along the viewing ray
* \param vecIndicesLowerBounds Returns the lower bounds of all intervals.
*
* \result lower and upper bounds of the most visible interval
* \param vecIndicesUpperBounds Returns the upper bounds of all intervals.
*/
std
::
pair
<
int
,
int
>
calculateIntervalsWYSIWYP
(
const
std
::
vector
<
double
>&
vecAlphaAcc
,
std
::
vector
<
int
>&
vecIndicesLowerBounds
);
void
calculateIntervalsWYSIWYP
(
const
std
::
vector
<
double
>&
vecAlphaAcc
,
std
::
vector
<
int
>&
vecIndicesLowerBounds
,
std
::
vector
<
int
>&
vecIndicesUpperBounds
);
/**
* Set the new position of the graphical representation
...
...
@@ -170,6 +170,13 @@ private:
*/
double
compositingStep
(
const
double
accAlpha
,
double
currentAlpha
);
/**
* Get the Visitrace candidates
*
* \return Candidates as pairs of opacity jump and location.
*/
std
::
vector
<
std
::
pair
<
double
,
WPosition
>
>
computeVisiTraceCandidates
();
/**
* Compute the position picked in the DVR
*
...
...
src/modules/pickingDVR/WVisiTrace.cpp
View file @
c8aad0ca
...
...
@@ -48,11 +48,16 @@ std::vector<WPosition> WVisiTrace::getLine()
return
m_curve3D
;
}
void
WVisiTrace
::
addCandidatesForRay
(
const
std
::
vector
<
WPosition
>&
positions
,
const
std
::
vector
<
double
>&
opacityJumps
)
void
WVisiTrace
::
addCandidatesForRay
(
const
std
::
vector
<
std
::
pair
<
double
,
WPosition
>
>
candidates
)
{
WAssert
(
positions
.
size
()
==
opacityJumps
.
size
(),
"Each cndidate position needs to have an opacity jump value."
);
std
::
vector
<
double
>
opacityJumps
(
candidates
.
size
()
);
std
::
vector
<
WPosition
>
positions
(
candidates
.
size
()
);
for
(
size_t
id
=
0
;
id
<
candidates
.
size
();
++
id
)
{
opacityJumps
.
push_back
(
candidates
[
id
].
first
);
positions
.
push_back
(
candidates
[
id
].
second
);
}
m_candidatePositions
.
push_back
(
positions
);
m_candidateJumps
.
push_back
(
opacityJumps
);
...
...
src/modules/pickingDVR/WVisiTrace.h
View file @
c8aad0ca
...
...
@@ -57,13 +57,9 @@ public:
* for one viewing ray. These values are the basis for visiTrace
* computation.
*
* Values in both vector are assumed to have the same order.
*
* \param positions candidate positions
* \param opacityJumps opacityJumps for the positions
* \param candidates candidate positions and corresponding opacity jumps
*/
void
addCandidatesForRay
(
const
std
::
vector
<
WPosition
>&
positions
,
const
std
::
vector
<
double
>&
opacityJumps
);
void
addCandidatesForRay
(
const
std
::
vector
<
std
::
pair
<
double
,
WPosition
>
>
candidates
);
/**
* Erases all data to be able to start a new VisiTrace computation.
...
...
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