MeVisLabToolboxReference
MeVisLab/Standard/Sources/Inventor/SoCSO/CSOProcessor/CSOLiveWireProcessor/CSOLiveWireGraph.h
Go to the documentation of this file.
00001 // **InsertLicense** code
00002 //----------------------------------------------------------------------------------
00004 
00009 //----------------------------------------------------------------------------------
00010 
00011 #ifndef __CSOLiveWireGraph_H
00012 #define __CSOLiveWireGraph_H
00013 
00014 #include "SoCSOSystem.h"
00015 
00016 #include "CSOLiveWireNode.h"
00017 #include <CSOTools/CSOObjectHeap.h>
00018 
00019 
00020 ML_START_NAMESPACE
00021 
00022 
00024 
00025 const float EULER_FACTOR = 1.0f / (6.0f * 2.718281828459f * 2.718281828459f); 
00026 
00027 const float SQRT_2 = 1.414213562373f; 
00028 
00030 
00031 const unsigned char DIR_N  = 0; 
00032 const unsigned char DIR_E  = 1; 
00033 const unsigned char DIR_S  = 2; 
00034 const unsigned char DIR_W  = 3; 
00035 const unsigned char DIR_NE = 4; 
00036 const unsigned char DIR_SE = 5; 
00037 const unsigned char DIR_SW = 6; 
00038 const unsigned char DIR_NW = 7; 
00039 
00040 
00053 
00054 
00056 enum CSOLiveWireNeighborhoodMode {
00057   CSO_LIVE_WIRE_4_NEIGHBORHOOD = 0, 
00058   CSO_LIVE_WIRE_8_NEIGHBORHOOD = 1  
00059 };
00060 
00062 
00064 class SOCSO_EXPORT CSOLiveWireGraph
00065 {
00066 
00067 public:
00068 
00070   CSOLiveWireGraph();
00072   CSOLiveWireGraph(float* imageData, unsigned int sizex, unsigned int sizey, const bool useCostsDirectly, float voxelSizeX=1.0f, float voxelSizeY=1.0f);
00073 
00075   ~CSOLiveWireGraph();
00076 
00078   void setStartPosition(VoxelPos startVoxelPos);
00079 
00081   void setWeights(float w1, float w2, float w3);
00082 
00084   void setLengthPenalty(float weight) {
00085     _lengthPenalty = weight;
00086   }
00087 
00089   inline void setPathCostThreshold(bool useThreshold, float threshold) { _usePathCostThreshold = useThreshold; _pathConstThreshold = threshold; }
00090 
00095   void getShortestPathToStart(VoxelPos endPos, std::vector<VoxelPos>& intermediatePositions, int neighborhoodMode, bool reverse=true);
00096 
00098   void resetGraphAndHeap();
00099 
00101   void setMaxPathLength(float maxLength) {
00102     _maxPathLength = maxLength;
00103   }
00104 
00106   void updateResultCosts();
00107 
00108 protected:
00109 
00110 
00111   /* MEMBER VARIABLES */
00112 
00114   std::vector< VoxelPos > _lastPathPositions;
00115 
00117   unsigned int _imageSizeX;
00119   unsigned int _imageSizeY;
00121   float _voxelSizeX;
00123   float _voxelSizeY;
00125   CSOLiveWireNode** _lwGraph;
00126 
00128   CSOObjectHeap<CSOLiveWireNode>* _nodeHeap;
00129 
00131   VoxelPos _startVoxelPos;
00132 
00134   int _offsetX[8];
00136   int _offsetY[8];
00137 
00139   float _maxGlobalGradient;
00141   float _w1, _w2, _w3;
00143   float _lengthPenalty;
00144 
00146   bool _usePathCostThreshold;
00149   float _pathConstThreshold;
00150 
00152   bool _useCostsDirectly;
00153 
00155   float _maxPathLength;
00156 
00158   float _directionLengths[8];
00159 
00160   /* DATA STRUCTURES */
00161 
00162   /* METHODS */
00163 
00165   void _computeCosts();
00166 
00168   float _getEdgeCosts(unsigned char direction, int posx, int posy);
00169 
00171   void _computeAdditionalCostsAndNormalizeValues();
00172 
00174   void _normalizeValues();
00175 };
00176 
00178 
00179 
00180 ML_END_NAMESPACE
00181 
00182 #endif // __CSOLiveWireGraph_H
00183 
00184 
00185