Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

MGShockGraph.h

Go to the documentation of this file.
00001 
00037 #ifndef __MG_SHOCKGRAPH_H__
00038 #define __MG_SHOCKGRAPH_H__
00039 
00040 extern "C" {
00041 #include <Shock.h>
00042 #include <Branches.h>
00043 #include <Graphs.h>
00044 }
00045 
00046 struct Pixmap
00047 {
00048         int rows;
00049         int cols;
00050         char* data;
00051     const char* name;
00052 
00053     Pixmap() { name = "pixmap"; }
00054 };
00055 
00062 class MGShockGraph : public Graph
00063 {
00064 
00065         Graph* m_pGraph;        //<! Ponter to the warpped Graph object.
00066 
00067 public:
00069         class SGPoint : public BPoint
00070         {
00071         public:
00072 
00073                 friend ostream& operator<<(ostream& stream, const SGPoint& p );
00074         };
00075 
00077         class SGSegment
00078         {
00079                 Shock* m_pShock;        //<! Ponter to the warpped Shock object.
00080 
00081         public:
00082 
00083                 const SGPoint& operator[](int i) const;
00084                 friend ostream& operator<<(ostream& os, const SGSegment& s);
00085 
00086                 SGSegment(Shock* pShock)  { m_pShock = pShock; }
00087                 int GetPointCount() const { return (m_pShock && m_pShock->points) ? m_pShock->points->ncells:0; }
00088 
00089                 const char* GetId() const { return m_pShock->id; }
00090                 int GetType() const           { return m_pShock->shock_type; }
00091 
00092                 void GetContourLength(double& seg1, double& seg2) const 
00093                 { 
00094                         seg1 = m_pShock->cseg1_length; 
00095                         seg2 = m_pShock->cseg2_length; 
00096                 }               
00097         };
00098 
00099 public:
00100 
00101         SGSegment operator[](int i) const;
00102         SGSegment GetSegment(const Vertex* pNode) const;
00103         const Vertex* GetNode(int i) const;
00104         const Edge* GetEdge(int i) const;
00105 
00106 #ifdef XML_READING
00107         bool ReadFromXMLFile(const char* szFileNumber);
00108 #endif //XML_READING
00109         bool ComputeFromPPMFile(const char* szFileName, 
00110                 double cutoff, double sigma, double range);
00111 
00112         bool ComputeFromMemory(Pixmap& image, 
00113                 double cutoff, double sigma, double range);
00114 
00115         MGShockGraph(Graph* pGraph = NULL)  { m_pGraph = pGraph; }
00116         ~MGShockGraph() { Empty(); }
00117         
00118         int GetNodeCount() const { return (m_pGraph) ? m_pGraph->vertices->ncells:0; }
00119         int GetEdgeCount() const { return (m_pGraph) ? m_pGraph->edges->ncells:0; }
00120 
00121         void Empty()  { if (m_pGraph) { freeGraph(m_pGraph); m_pGraph = NULL; } }
00122 };
00123 
00124 #endif //__MG_SHOCKGRAPH_H__

Generated on Sat Nov 13 11:21:24 2004 for Noisy DAG Matcher by doxygen1.2.18