OpenWalnut  1.5.0dev
WVisiTrace.h
1 //---------------------------------------------------------------------------
2 //
3 // Project: OpenWalnut ( http://www.openwalnut.org )
4 //
5 // Copyright 2017 OpenWalnut Community
6 // For more information see http://www.openwalnut.org/copying
7 //
8 // This file is part of OpenWalnut.
9 //
10 // OpenWalnut is free software: you can redistribute it and/or modify
11 // it under the terms of the GNU Lesser General Public License as published by
12 // the Free Software Foundation, either version 3 of the License, or
13 // (at your option) any later version.
14 //
15 // OpenWalnut is distributed in the hope that it will be useful,
16 // but WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 // GNU Lesser General Public License for more details.
19 //
20 // You should have received a copy of the GNU Lesser General Public License
21 // along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
22 //
23 //---------------------------------------------------------------------------
24 
25 #ifndef WVISITRACE_H
26 #define WVISITRACE_H
27 
28 #include <utility>
29 #include <vector>
30 
31 #include "core/common/math/linearAlgebra/WPosition.h"
32 
33 /**
34  * Class performing graph computations for VisiTrace algorithm.
35  * The algorithm has been published here:
36  * http://dx.doi.org/10.2312/PE.EuroVisShort.EuroVisShort2013.091-095
37  *
38  * The aim is to draw smooth lines on top visible structures in direct volume
39  * renderings.
40  */
42 {
43  friend class WVisiTraceTest; //!< Test class needs private access.
44 public:
45  /**
46  * Simple constructor performing initializations
47  */
48  WVisiTrace();
49 
50  /**
51  * Get the final 3D line a vector of \ref WPosition.
52  * If data has changed since last call a recomputation will be triggered.
53  *
54  * \return 3D line computed by visitrace.
55  */
56  std::vector< WPosition > getLine();
57 
58  /**
59  * Add candidate positions and corresponding opacity jump values
60  * for one viewing ray. These values are the basis for visiTrace
61  * computation.
62  *
63  * \param candidates candidate positions and corresponding opacity jumps
64  */
65  void addCandidatesForRay( const std::vector< std::pair< double, WPosition > > candidates );
66 
67  /**
68  * Erases all data to be able to start a new VisiTrace computation.
69  */
70  void reset();
71 
72 protected:
73 private:
74  /**
75  * Optimization resulting in the desired 3D curve (\ref m_curve3D).
76  */
77  void performVisiTrace();
78 
79  /**
80  * Get an vector with reference ids for all nodes.
81  *
82  * \return vector containing pair of indices referencing \ref m_candidatePositions (\ref m_candidateJumps).
83  */
84  std::vector< std::pair< int, int > > getLinearizedNodesRefs() const;
85 
86  /**
87  * Get ids in the vector of \ref getLinearizedNodesRefs from structure of \ref m_candidatePositions
88  *
89  * \return vector of vectors containing correpsonding ids in linearized vector
90  */
91  std::vector< std::vector< int > > getInverseLinearizedNodesRefs() const;
92 
93  /**
94  * Create weighted graph and find shortest path from according to VisiTrace.
95  */
96  void performDijkstra();
97 
98  std::vector< std::vector< WPosition > > m_candidatePositions; //!< The candidate positions for all rays
99  std::vector< std::vector< double > > m_candidateJumps; //!< The opacity jumps belonging to the intervals of the candidate positions.
100  std::vector< WPosition > m_curve3D; //!< The 3D curve computed by VisiTrace.
101 
102  bool m_dataChanged; //!< Indicates whether new data has been added since last VisiTrace computation.
103 };
104 
105 #endif // WVISITRACE_H
Test for WMWriteMesh.
Class performing graph computations for VisiTrace algorithm.
Definition: WVisiTrace.h:42
std::vector< std::vector< WPosition > > m_candidatePositions
The candidate positions for all rays.
Definition: WVisiTrace.h:98
std::vector< std::vector< double > > m_candidateJumps
The opacity jumps belonging to the intervals of the candidate positions.
Definition: WVisiTrace.h:99
void performVisiTrace()
Optimization resulting in the desired 3D curve (m_curve3D).
Definition: WVisiTrace.cpp:269
std::vector< std::vector< int > > getInverseLinearizedNodesRefs() const
Get ids in the vector of getLinearizedNodesRefs from structure of m_candidatePositions.
Definition: WVisiTrace.cpp:89
std::vector< WPosition > getLine()
Get the final 3D line a vector of WPosition.
Definition: WVisiTrace.cpp:48
void addCandidatesForRay(const std::vector< std::pair< double, WPosition > > candidates)
Add candidate positions and corresponding opacity jump values for one viewing ray.
Definition: WVisiTrace.cpp:59
void reset()
Erases all data to be able to start a new VisiTrace computation.
Definition: WVisiTrace.cpp:274
std::vector< std::pair< int, int > > getLinearizedNodesRefs() const
Get an vector with reference ids for all nodes.
Definition: WVisiTrace.cpp:76
WVisiTrace()
Simple constructor performing initializations.
Definition: WVisiTrace.cpp:40
bool m_dataChanged
Indicates whether new data has been added since last VisiTrace computation.
Definition: WVisiTrace.h:102
std::vector< WPosition > m_curve3D
The 3D curve computed by VisiTrace.
Definition: WVisiTrace.h:100
void performDijkstra()
Create weighted graph and find shortest path from according to VisiTrace.
Definition: WVisiTrace.cpp:105