DllInterface.cpp 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. #include "stdafx.h"
  2. #include "DllInterface.h"
  3. #include <EIMInterfaceDLL.h>
  4. DllInterface::DllInterface()
  5. : m_isValid( FALSE )
  6. {
  7. Initialize();
  8. }
  9. DllInterface::~DllInterface()
  10. {
  11. if ( hDLL )
  12. {
  13. FreeLibrary( hDLL );
  14. }
  15. if ( eimResult.vect_adventitia )
  16. {
  17. delete[] eimResult.vect_adventitia;
  18. }
  19. if ( eimResult.vect_intima )
  20. {
  21. delete[] eimResult.vect_intima;
  22. }
  23. if ( eimResult.vect_media )
  24. {
  25. delete[] eimResult.vect_media;
  26. }
  27. }
  28. BOOL DllInterface::IsValid()
  29. {
  30. return m_isValid;
  31. }
  32. void DllInterface::Clear()
  33. {
  34. eimResult.imt_max = 0.0;
  35. eimResult.imt_mean = 0.0;
  36. eimResult.imt_standardDeviation = 0.0;
  37. eimResult.intima_mean = 0.0;
  38. eimResult.media_mean = 0.0;
  39. eimResult.qualityIndex = 0.0;
  40. eimResult.distance = 0.0;
  41. eimResult.numberOfPoints = 0;
  42. }
  43. imt::IMTResult* DllInterface::GetResult()
  44. {
  45. return &eimResult;
  46. }
  47. BOOL DllInterface::initializeFromFile( const char* fileName, double mmPerPixelX, double mmPerPixelY )
  48. {
  49. return m_initializeFromFile( fileName, mmPerPixelX, mmPerPixelY );
  50. }
  51. BOOL DllInterface::setFirstPoint( CPoint pt )
  52. {
  53. eimResult.p0.x = pt.x;
  54. eimResult.p0.y = pt.y;
  55. return m_setFirstPoint( pt.x, pt.y );
  56. }
  57. BOOL DllInterface::setSecondPoint( CPoint pt )
  58. {
  59. return m_setSecondPoint( pt.x, pt.y, &eimResult );
  60. }
  61. void DllInterface::Initialize()
  62. {
  63. eimResult.vect_adventitia = NULL;
  64. eimResult.vect_intima = NULL;
  65. eimResult.vect_media = NULL;
  66. Clear();
  67. hDLL = LoadLibrary( _T( "LibIMTDLL.dll" ) );
  68. if ( hDLL )
  69. {
  70. m_isValid = TRUE;
  71. m_initializeFromFile = (dll_initializeFromFile)GetProcAddress( hDLL, "initializeFromFile" );
  72. if ( !m_initializeFromFile )
  73. {
  74. m_isValid = FALSE;
  75. }
  76. initializeFromRaw = (dll_initializeFromRaw)GetProcAddress( hDLL, "initializeFromRaw" );
  77. if ( !initializeFromRaw )
  78. {
  79. m_isValid = FALSE;
  80. }
  81. m_setFirstPoint = (dll_setFirstPoint)GetProcAddress( hDLL, "setFirstPoint" );
  82. if ( !m_setFirstPoint )
  83. {
  84. m_isValid = FALSE;
  85. }
  86. getDistanceToFirstPoint = (dll_getDistanceToFirstPoint)GetProcAddress( hDLL, "getDistanceToFirstPoint" );
  87. if ( !getDistanceToFirstPoint )
  88. {
  89. m_isValid = FALSE;
  90. }
  91. m_setSecondPoint = (dll_setSecondPoint)GetProcAddress( hDLL, "setSecondPoint" );
  92. if ( !m_setSecondPoint )
  93. {
  94. m_isValid = FALSE;
  95. }
  96. getImageWidth = (dll_getImageWidth)GetProcAddress( hDLL, "getImageWidth" );
  97. if ( !getImageWidth )
  98. {
  99. m_isValid = FALSE;
  100. }
  101. getImageHeight = (dll_getImageHeight)GetProcAddress( hDLL, "getImageHeight" );
  102. if ( !getImageHeight )
  103. {
  104. m_isValid = FALSE;
  105. }
  106. getImageBitsPerPixel = (dll_getImageBitsPerPixel)GetProcAddress( hDLL, "getImageBitsPerPixel" );
  107. if ( !getImageBitsPerPixel )
  108. {
  109. m_isValid = FALSE;
  110. }
  111. getPixelArray = (dll_getPixelArray)GetProcAddress( hDLL, "getPixelArray" );
  112. if ( !getPixelArray )
  113. {
  114. m_isValid = FALSE;
  115. }
  116. }
  117. }