Commit 08d3fef4 authored by Alexander Wiebel's avatar Alexander Wiebel

[ADD] included also opacity weights into VisiTrace implementation -->...

[ADD] included also opacity weights into VisiTrace implementation --> VisiTrace should be complete now
parent 949a1705
......@@ -104,7 +104,7 @@ void WMPickingDVR::properties()
m_selectionTypesList = boost::shared_ptr< WItemSelection >( new WItemSelection() );
m_selectionTypesList->addItem( "Position (Picking)" );
m_selectionTypesList->addItem( "Line (First Hit)" );
m_selectionTypesList->addItem( "Line (VisiTrace) [NOT YET CORRECTLY IMPLEMENTED]" );
m_selectionTypesList->addItem( "Line (VisiTrace)" );
m_selectionType = m_properties->addProperty( "Selection type",
"What type of structure is to be selected in the DVR?",
m_selectionTypesList->getSelectorFirst(),
......
......@@ -132,12 +132,15 @@ void WVisiTrace::performDijkstra()
}
std::vector< Edge > edgeVector( 0 );
std::vector< double > weightsV( 0 );
std::vector< double > distanceWeights( 0 );
std::vector< double > opacityWeights( 0 );
// Edges from virtual start node to candidates of first ray
for( auto candi : linearizedInverse[0] )
{
edgeVector.push_back( Edge( startNodeId, candi + numVirtNodes ) );
weightsV.push_back( 1 );
distanceWeights.push_back( 1 );
opacityWeights.push_back( 1 );
}
// Edges from candidates of one ray to those of the next ray
......@@ -152,20 +155,45 @@ void WVisiTrace::performDijkstra()
WPosition firstPos = m_candidatePositions[rayId][firstId];
WPosition secondPos = m_candidatePositions[rayId+1][secondId];
double distance = length( firstPos - secondPos );
weightsV.push_back( distance );
distanceWeights.push_back( distance );
opacityWeights.push_back( 1 - m_candidateJumps[rayId+1][secondId] );
}
}
}
// Normalize distance weights
{
double maxDistance = 0;
for( auto distance : distanceWeights )
{
if( distance > maxDistance )
{
maxDistance = distance;
}
}
for( double& weight : distanceWeights ) // NOLINT
{
weight /= maxDistance;
}
}
// Edges from candidates of last ray to virtual end node
for( auto candi : linearizedInverse[linearizedInverse.size()-1] )
{
edgeVector.push_back( Edge( candi + numVirtNodes, endNodeId ) );
weightsV.push_back( 1 );
distanceWeights.push_back( 1 );
opacityWeights.push_back( 1 );
}
WAssert( distanceWeights.size() == opacityWeights.size(), "Internal error: Need as many opacities as positions." );
std::vector< double > overallWeights( distanceWeights.size() );
for( size_t weightId = 0; weightId < overallWeights.size(); ++weightId )
{
overallWeights[weightId] = opacityWeights[weightId] * distanceWeights[weightId] * distanceWeights[weightId];
}
Edge* edge_array = &edgeVector[0];
double* weights = &weightsV[0];
double* weights = &overallWeights[0];
int num_arcs = edgeVector.size();
graph_t g( edge_array, edge_array + num_arcs, weights, num_nodes );
......
......@@ -86,7 +86,7 @@ public:
TS_ASSERT_EQUALS( order[2], std::make_pair( 0, 2 ) );
TS_ASSERT_EQUALS( order[3], std::make_pair( 0, 3 ) );
TS_ASSERT_EQUALS( order[5], std::make_pair( 1, 1 ) );
TS_ASSERT_EQUALS( order[5], std::make_pair( 1, 1 ) );
TS_ASSERT_EQUALS( order[6], std::make_pair( 2, 0 ) );
TS_ASSERT_EQUALS( order[27], std::make_pair( 5, 5 ) );
......@@ -123,7 +123,7 @@ public:
}
/**
* Check throwing of Dijkstra
* Check throwing of Dijkstra and result according to VisiTrace with constant opacity weights.
*/
void testPerformDijkstraException()
{
......@@ -137,7 +137,7 @@ public:
WPosition( 1, 0, 3 )
}
);
myVisiTrace.m_candidateJumps.push_back( { 1.0, 1.0, 1.0, 1.0 } ); // NOLINT
myVisiTrace.m_candidateJumps.push_back( { 0.5, 0.5, 0.5, 0.5 } ); // NOLINT
myVisiTrace.m_candidatePositions.push_back(
{
......@@ -145,7 +145,7 @@ public:
WPosition( 1, 1, -2.5 )
}
);
myVisiTrace.m_candidateJumps.push_back( { 1.0, 1.0 } ); // NOLINT
myVisiTrace.m_candidateJumps.push_back( { 0.5, 0.5 } ); // NOLINT
myVisiTrace.m_candidatePositions.push_back(
{
......@@ -155,11 +155,11 @@ public:
WPosition( 1, 1.2, 3 )
}
);
myVisiTrace.m_candidateJumps.push_back( { 1.0, 1.0, 1.0, 1.0 } ); // NOLINT
myVisiTrace.m_candidateJumps.push_back( { 0.5, 0.5, 0.5, 0.5 } ); // NOLINT
TS_ASSERT( myVisiTrace.m_candidatePositions.size() != 0 );
TS_ASSERT_EQUALS( myVisiTrace.m_candidatePositions.size(), 3 );
TS_ASSERT_THROWS_NOTHING( myVisiTrace.performDijkstra() );
TS_ASSERT( myVisiTrace.m_curve3D.size() !=0 );
TS_ASSERT_EQUALS( myVisiTrace.m_curve3D.size(), 3 );
TS_ASSERT_EQUALS( myVisiTrace.m_curve3D[0], WPosition( 1, 0, 0 ) );
TS_ASSERT_EQUALS( myVisiTrace.m_curve3D[1], WPosition( 1, 1, -2.5 ) );
TS_ASSERT_EQUALS( myVisiTrace.m_curve3D[2], WPosition( 1, 1.2, 0 ) );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment