CEIMResult.cpp 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. #include "CEIMResult.h"
  2. #include <cstdlib>
  3. CEIMResult::CEIMResult()
  4. {
  5. result = new imt::IMTResult;
  6. Initialize();
  7. }
  8. CEIMResult::~CEIMResult()
  9. {
  10. if ( result->vect_intima )
  11. {
  12. delete[] result->vect_intima;
  13. }
  14. if ( result->vect_media )
  15. {
  16. delete[] result->vect_media;
  17. }
  18. if ( result->vect_adventitia )
  19. {
  20. delete[] result->vect_adventitia;
  21. }
  22. delete result;
  23. }
  24. void CEIMResult::Initialize()
  25. {
  26. result->imt_max = 0.0;
  27. result->imt_mean = 0.0;
  28. result->imt_standardDeviation = 0.0;
  29. result->intima_mean = 0.0;
  30. result->media_mean = 0.0;
  31. result->qualityIndex = 0.0;
  32. result->distance = 0.0;
  33. result->numberOfPoints = 0;
  34. result->vect_intima = NULL;
  35. result->vect_media = NULL;
  36. result->vect_adventitia = NULL;
  37. }
  38. bool CEIMResult::fill( imt::IMTResult* res )
  39. {
  40. if ( res )
  41. {
  42. if ( res->vect_adventitia )
  43. {
  44. delete[] res->vect_adventitia;
  45. }
  46. if ( res->vect_media )
  47. {
  48. delete[] res->vect_media;
  49. }
  50. if ( res->vect_intima )
  51. {
  52. delete[] res->vect_intima;
  53. }
  54. int n = result->numberOfPoints;
  55. res->imt_max = result->imt_max;
  56. res->imt_mean = result->imt_mean;
  57. res->imt_standardDeviation = result->imt_standardDeviation;
  58. res->intima_mean = result->intima_mean;
  59. res->media_mean = result->media_mean;
  60. res->qualityIndex = result->qualityIndex;
  61. res->distance = result->distance;
  62. res->numberOfPoints = n;
  63. res->p0 = result->p0;
  64. res->p1 = result->p1;
  65. res->vect_intima = new imt::Point[ n ];
  66. if ( !res->vect_intima )
  67. {
  68. return false;
  69. }
  70. res->vect_media = new imt::Point[ n ];
  71. if ( !res->vect_media )
  72. {
  73. delete[] res->vect_intima;
  74. res->vect_intima = NULL;
  75. return false;
  76. }
  77. res->vect_adventitia = new imt::Point[ n ];
  78. if ( !res->vect_adventitia )
  79. {
  80. delete[] res->vect_intima;
  81. res->vect_intima = NULL;
  82. delete[] res->vect_media;
  83. res->vect_media = NULL;
  84. return false;
  85. }
  86. int i;
  87. for ( i = 0; i < n; i++ )
  88. {
  89. res->vect_adventitia[ i ] = result->vect_adventitia[ i ];
  90. res->vect_media[ i ] = result->vect_media[ i ];
  91. res->vect_intima[ i ] = result->vect_intima[ i ];
  92. }
  93. return true;
  94. }
  95. return false;
  96. }
  97. bool CEIMResult::allocate_vectors( long n_points )
  98. {
  99. if ( !n_points )
  100. {
  101. return false;
  102. }
  103. result->numberOfPoints = n_points;
  104. result->vect_intima = new imt::Point[ n_points ];
  105. if ( !result->vect_intima )
  106. {
  107. return false;
  108. }
  109. result->vect_media = new imt::Point[ n_points ];
  110. if ( !result->vect_media )
  111. {
  112. delete[] result->vect_intima;
  113. result->vect_intima = NULL;
  114. return false;
  115. }
  116. result->vect_adventitia = new imt::Point[ n_points ];
  117. if ( !result->vect_adventitia )
  118. {
  119. delete[] result->vect_intima;
  120. result->vect_intima = NULL;
  121. delete[] result->vect_media;
  122. result->vect_media = NULL;
  123. return false;
  124. }
  125. return true;
  126. }