AlchemyCaller.as 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. package com.imt.intimamedia.helpers
  2. {
  3. import cmodule.c1.CLibInit;
  4. import com.imt.intimamedia.vo.ImtResultVo;
  5. import flash.display.Sprite;
  6. import flash.geom.Point;
  7. import flash.utils.ByteArray;
  8. import mx.controls.Alert;
  9. public class AlchemyCaller extends Sprite
  10. {
  11. protected static const loader : cmodule.c1.CLibInit = new cmodule.c1.CLibInit();
  12. protected static const lib : * = loader.init();
  13. public function AlchemyCaller()
  14. {
  15. }
  16. public static function imtCalculate( scale : Number, width : int, height : int, startX : int, startY : int, endX : int, endY : int, data : ByteArray, colors : int = 24 ) : ImtResultVo
  17. {
  18. var point : Point;
  19. var diameter: int;
  20. diameter = 0;
  21. // Comment by C. Jacquelin : Appel 2 fois sinon le 1er clic la mesure se fait pas : provisoire
  22. // line below commented by J.Deppe : useless and with it imt calculation fail sometimes
  23. //lib.AlchemyinitializeFromRaw( startX, startY, endX, endY, width, height, colors, 0, scale, scale, data );
  24. var result : Array = lib.AlchemyinitializeFromRaw( diameter, startX, startY, endX, endY, width, height, colors, 0, scale, scale, data );
  25. var imtResultVo : ImtResultVo = new ImtResultVo();
  26. imtResultVo.max = result[0][0];
  27. imtResultVo.mean = result[0][1];
  28. imtResultVo.standardDeviation = result[0][2];
  29. imtResultVo.qualityIndex = result[0][3];
  30. imtResultVo.distance = result[0][4];
  31. imtResultVo.numberOfPoints = result[0][5];
  32. for ( var i : int = 0; i < imtResultVo.numberOfPoints; i++ )
  33. {
  34. point = new Point();
  35. point.x = result[i+1][0];
  36. point.y = result[i+1][1];
  37. imtResultVo.intima.push( point );
  38. point = new Point();
  39. point.x = result[i+1][2];
  40. point.y = result[i+1][3];
  41. imtResultVo.adventitia.push( point );
  42. }
  43. return imtResultVo;
  44. }
  45. public static function initAlchemy( scale : Number, width : int, height : int, startX : int, startY : int, endX : int, endY : int, data : ByteArray, colors : int = 24 ) : void
  46. {
  47. lib.AlchemyinitializeFromRaw( startX, startY, endX, endY, width, height, colors, 0, scale, scale, data );
  48. var result : Array = lib.AlchemyinitializeFromRaw( startX, startY, endX, endY, width, height, colors, 0, scale, scale, data );
  49. }
  50. }
  51. }