| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159 |
- #include "CEIMResult.h"
- #include <cstdlib>
- CEIMResult::CEIMResult()
- {
- result = new imt::IMTResult;
- Initialize();
- }
- CEIMResult::~CEIMResult()
- {
- if ( result->vect_intima )
- {
- delete[] result->vect_intima;
- }
- if ( result->vect_media )
- {
- delete[] result->vect_media;
- }
- if ( result->vect_adventitia )
- {
- delete[] result->vect_adventitia;
- }
- delete result;
- }
- void CEIMResult::Initialize()
- {
- result->imt_max = 0.0;
- result->imt_mean = 0.0;
- result->imt_standardDeviation = 0.0;
- result->intima_mean = 0.0;
- result->media_mean = 0.0;
- result->qualityIndex = 0.0;
- result->distance = 0.0;
- result->numberOfPoints = 0;
- result->vect_intima = NULL;
- result->vect_media = NULL;
- result->vect_adventitia = NULL;
- }
- bool CEIMResult::fill( imt::IMTResult* res )
- {
- if ( res )
- {
- if ( res->vect_adventitia )
- {
- delete[] res->vect_adventitia;
- }
-
- if ( res->vect_media )
- {
- delete[] res->vect_media;
- }
-
- if ( res->vect_intima )
- {
- delete[] res->vect_intima;
- }
-
- int n = result->numberOfPoints;
- res->imt_max = result->imt_max;
- res->imt_mean = result->imt_mean;
- res->imt_standardDeviation = result->imt_standardDeviation;
- res->intima_mean = result->intima_mean;
- res->media_mean = result->media_mean;
- res->qualityIndex = result->qualityIndex;
- res->distance = result->distance;
- res->numberOfPoints = n;
- res->p0 = result->p0;
- res->p1 = result->p1;
-
- res->vect_intima = new imt::Point[ n ];
-
- if ( !res->vect_intima )
- {
- return false;
- }
-
- res->vect_media = new imt::Point[ n ];
- if ( !res->vect_media )
- {
- delete[] res->vect_intima;
- res->vect_intima = NULL;
-
- return false;
- }
-
- res->vect_adventitia = new imt::Point[ n ];
- if ( !res->vect_adventitia )
- {
- delete[] res->vect_intima;
- res->vect_intima = NULL;
- delete[] res->vect_media;
- res->vect_media = NULL;
-
- return false;
- }
- int i;
- for ( i = 0; i < n; i++ )
- {
- res->vect_adventitia[ i ] = result->vect_adventitia[ i ];
- res->vect_media[ i ] = result->vect_media[ i ];
- res->vect_intima[ i ] = result->vect_intima[ i ];
- }
- return true;
- }
- return false;
- }
- bool CEIMResult::allocate_vectors( long n_points )
- {
- if ( !n_points )
- {
- return false;
- }
-
- result->numberOfPoints = n_points;
- result->vect_intima = new imt::Point[ n_points ];
-
- if ( !result->vect_intima )
- {
- return false;
- }
-
- result->vect_media = new imt::Point[ n_points ];
-
- if ( !result->vect_media )
- {
- delete[] result->vect_intima;
- result->vect_intima = NULL;
-
- return false;
- }
-
- result->vect_adventitia = new imt::Point[ n_points ];
-
- if ( !result->vect_adventitia )
- {
- delete[] result->vect_intima;
- result->vect_intima = NULL;
- delete[] result->vect_media;
- result->vect_media = NULL;
-
- return false;
- }
- return true;
- }
|