| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142 |
- #include "stdafx.h"
- #include "DllInterface.h"
- #include <EIMInterfaceDLL.h>
- DllInterface::DllInterface()
- : m_isValid( FALSE )
- {
- Initialize();
- }
- DllInterface::~DllInterface()
- {
- if ( hDLL )
- {
- FreeLibrary( hDLL );
- }
- if ( eimResult.vect_adventitia )
- {
- delete[] eimResult.vect_adventitia;
- }
- if ( eimResult.vect_intima )
- {
- delete[] eimResult.vect_intima;
- }
- if ( eimResult.vect_media )
- {
- delete[] eimResult.vect_media;
- }
- }
- BOOL DllInterface::IsValid()
- {
- return m_isValid;
- }
- void DllInterface::Clear()
- {
- eimResult.imt_max = 0.0;
- eimResult.imt_mean = 0.0;
- eimResult.imt_standardDeviation = 0.0;
- eimResult.intima_mean = 0.0;
- eimResult.media_mean = 0.0;
- eimResult.qualityIndex = 0.0;
- eimResult.distance = 0.0;
- eimResult.numberOfPoints = 0;
- }
- imt::IMTResult* DllInterface::GetResult()
- {
- return &eimResult;
- }
- BOOL DllInterface::initializeFromFile( const char* fileName, double mmPerPixelX, double mmPerPixelY )
- {
- return m_initializeFromFile( fileName, mmPerPixelX, mmPerPixelY );
- }
- BOOL DllInterface::setFirstPoint( CPoint pt )
- {
- eimResult.p0.x = pt.x;
- eimResult.p0.y = pt.y;
- return m_setFirstPoint( pt.x, pt.y );
- }
- BOOL DllInterface::setSecondPoint( CPoint pt )
- {
- return m_setSecondPoint( pt.x, pt.y, &eimResult );
- }
- void DllInterface::Initialize()
- {
- eimResult.vect_adventitia = NULL;
- eimResult.vect_intima = NULL;
- eimResult.vect_media = NULL;
- Clear();
- hDLL = LoadLibrary( _T( "LibIMTDLL.dll" ) );
- if ( hDLL )
- {
- m_isValid = TRUE;
- m_initializeFromFile = (dll_initializeFromFile)GetProcAddress( hDLL, "initializeFromFile" );
- if ( !m_initializeFromFile )
- {
- m_isValid = FALSE;
- }
- initializeFromRaw = (dll_initializeFromRaw)GetProcAddress( hDLL, "initializeFromRaw" );
- if ( !initializeFromRaw )
- {
- m_isValid = FALSE;
- }
- m_setFirstPoint = (dll_setFirstPoint)GetProcAddress( hDLL, "setFirstPoint" );
- if ( !m_setFirstPoint )
- {
- m_isValid = FALSE;
- }
- getDistanceToFirstPoint = (dll_getDistanceToFirstPoint)GetProcAddress( hDLL, "getDistanceToFirstPoint" );
- if ( !getDistanceToFirstPoint )
- {
- m_isValid = FALSE;
- }
- m_setSecondPoint = (dll_setSecondPoint)GetProcAddress( hDLL, "setSecondPoint" );
- if ( !m_setSecondPoint )
- {
- m_isValid = FALSE;
- }
- getImageWidth = (dll_getImageWidth)GetProcAddress( hDLL, "getImageWidth" );
- if ( !getImageWidth )
- {
- m_isValid = FALSE;
- }
- getImageHeight = (dll_getImageHeight)GetProcAddress( hDLL, "getImageHeight" );
- if ( !getImageHeight )
- {
- m_isValid = FALSE;
- }
- getImageBitsPerPixel = (dll_getImageBitsPerPixel)GetProcAddress( hDLL, "getImageBitsPerPixel" );
- if ( !getImageBitsPerPixel )
- {
- m_isValid = FALSE;
- }
- getPixelArray = (dll_getPixelArray)GetProcAddress( hDLL, "getPixelArray" );
- if ( !getPixelArray )
- {
- m_isValid = FALSE;
- }
- }
- }
|