urm.dart 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683
  1. // import 'dart:math';
  2. // import 'dart:ui';
  3. // import 'package:fis_common/logger/logger.dart';
  4. // import 'package:fis_jsonrpc/rpc.dart';
  5. // import 'package:fis_measure/interfaces/date_types/point.dart';
  6. // import 'package:fis_measure/interfaces/process/calculators/values.dart';
  7. // import 'package:fis_measure/process/items/item.dart';
  8. // import 'package:fis_measure/process/primitives/area_abstract.dart';
  9. // import 'package:fis_measure/process/primitives/combos/urm_sr_roi_rect_combo.dart';
  10. // import 'package:fis_measure/process/primitives/location.dart';
  11. // import 'package:fis_measure/process/primitives/urm_measure/urm_rect_measure.dart';
  12. // // import 'package:fis_measure/process/primitives/urm_straightline.dart';
  13. // import 'package:fis_measure/process/workspace/urm/application.dart';
  14. // import 'calculator.dart';
  15. // class URMRectCal extends Calculator<URMRectMeasure, double> {
  16. // URMRectCal(
  17. // URMRectMeasure ref, {
  18. // required this.type,
  19. // }) : super(ref);
  20. // final String type;
  21. // @override
  22. // void calculate() {}
  23. // @override
  24. // Future<void> calculateAsync() async {
  25. // if (ref.feature == null) return;
  26. // Size urmResultSize = const Size(0, 0);
  27. // try {
  28. // if (ref.application is! URMApplication) {
  29. // return;
  30. // }
  31. // final URMApplication urmApplication = ref.application as URMApplication;
  32. // urmResultSize = Size(urmApplication.resultWidth.toDouble(),
  33. // urmApplication.resultHeight.toDouble());
  34. // final p1 = ref.feature!.startPoint;
  35. // final p2 = ref.feature!.endPoint;
  36. // //左上顶点
  37. // final leftTopPercent =
  38. // DPoint(p1.x < p2.x ? p1.x : p2.x, p1.y < p2.y ? p1.y : p2.y);
  39. // //右下顶点
  40. // final rightBottomPercent =
  41. // DPoint(p1.x > p2.x ? p1.x : p2.x, p1.y > p2.y ? p1.y : p2.y);
  42. // final startPoint = leftTopPercent.scale2Size(urmResultSize);
  43. // final endPoint = rightBottomPercent.scale2Size(urmResultSize);
  44. // String description = "URM\n Calculating...";
  45. // updateStringValue(description);
  46. // // switch (type) {
  47. // // case MeasureTypes.DensitySR:
  48. // // case MeasureTypes.SRRoiDensity:
  49. // // case MeasureTypes.Roi1:
  50. // // case MeasureTypes.Roi2:
  51. // // await getSRRoiDensityResult(urmApplication, startPoint, endPoint);
  52. // // break;
  53. // // case MeasureTypes.FractalDimSR:
  54. // // case MeasureTypes.SRROIFractalDim:
  55. // // await getSRRoiFractalDimResult(urmApplication, startPoint, endPoint);
  56. // // break;
  57. // // case MeasureTypes.SRRoiVel:
  58. // // await getSRRoiVelResult(urmApplication, startPoint, endPoint);
  59. // // break;
  60. // // case MeasureTypes.URMVelMeasure:
  61. // // await getURMVelMeasureResult(urmApplication, startPoint, endPoint);
  62. // // break;
  63. // // default:
  64. // // }
  65. // } catch (e) {
  66. // logger.e('URM Measure error: $e');
  67. // return;
  68. // }
  69. // }
  70. // // //✅ URM 测量项 2
  71. // // Future<void> getSRRoiDensityResult(
  72. // // URMApplication app, DPoint startPoint, DPoint endPoint) async {
  73. // // String description = "URM\n Measuring";
  74. // // try {
  75. // // GetSRRoiVelResult? result =
  76. // // await app.getSRRoiVelResult(startPoint, endPoint);
  77. // // if (result != null) {
  78. // // print("URM Measure output: ${result.output} ");
  79. // // final feature = ref.feature!;
  80. // // for (var output in ref.meta.outputs) {
  81. // // if ([MeasureTerms.URMDenROI, MeasureTerms.URMDenFractalDim]
  82. // // .contains(output.name)) {
  83. // // output.unit = VidUsUnit.percent;
  84. // // feature.updateFloatValue(output, result.output, output.unit);
  85. // // }
  86. // // }
  87. // // } else {
  88. // // throw Exception("URM Measure API error");
  89. // // }
  90. // // } catch (e) {
  91. // // description = " ";
  92. // // updateStringValue(description);
  93. // // return;
  94. // // }
  95. // // ref.application.updateRenderReady.emit(this, null);
  96. // // }
  97. // // //✅ URM 测量项 3 未验证需要组合测量项
  98. // // Future<void> getSRRoiFractalDimResult(
  99. // // URMApplication app, DPoint startPoint, DPoint endPoint) async {
  100. // // String description = "URM\n Measuring";
  101. // // try {
  102. // // GetSRRoiFractalDimResult? result =
  103. // // await app.getSRRoiFractalDimResult(startPoint, endPoint);
  104. // // if (result != null) {
  105. // // print("URM Measure output: ${result.output} ");
  106. // // final feature = ref.feature!;
  107. // // for (var output in ref.meta.outputs) {
  108. // // if (output.name == MeasureTerms.URMDenFractalDim) {
  109. // // output.unit = VidUsUnit.None;
  110. // // feature.updateFloatValue(output, result.output, output.unit);
  111. // // }
  112. // // }
  113. // // } else {
  114. // // throw Exception("URM Measure API error");
  115. // // }
  116. // // } catch (e) {
  117. // // description = " ";
  118. // // updateStringValue(description);
  119. // // return;
  120. // // }
  121. // // ref.application.updateRenderReady.emit(this, null);
  122. // // }
  123. // // //✅ URM 测量项 7 未验证需要组合测量项
  124. // // Future<void> getSRRoiVelResult(
  125. // // URMApplication app, DPoint startPoint, DPoint endPoint) async {
  126. // // String description = "URM\n Measuring";
  127. // // try {
  128. // // GetSRRoiVelResult? result =
  129. // // await app.getSRRoiVelResult(startPoint, endPoint);
  130. // // if (result != null) {
  131. // // print("URM Measure output: ${result.output} ");
  132. // // final feature = ref.feature!;
  133. // // for (var output in ref.meta.outputs) {
  134. // // if (output.name == MeasureTerms.SRRoiVel) {
  135. // // output.unit = VidUsUnit.percent;
  136. // // feature.updateFloatValue(output, result.output, output.unit);
  137. // // }
  138. // // }
  139. // // } else {
  140. // // throw Exception("URM Measure API error");
  141. // // }
  142. // // } catch (e) {
  143. // // description = " ";
  144. // // updateStringValue(description);
  145. // // return;
  146. // // }
  147. // // ref.application.updateRenderReady.emit(this, null);
  148. // // }
  149. // // //✅ URM 测量项 9
  150. // // Future<void> getURMVelMeasureResult(
  151. // // URMApplication app, DPoint startPoint, DPoint endPoint) async {
  152. // // String description = "URM\n Measuring";
  153. // // try {
  154. // // GetURMVelMeasureResult? result =
  155. // // await app.getURMVelMeasureResult(startPoint, endPoint);
  156. // // if (result != null) {
  157. // // // TODO 全部内容展示
  158. // // print("URM Measure inMaxVel: ${result.inMaxVel} ");
  159. // // final feature = ref.feature!;
  160. // // for (var output in ref.meta.outputs) {
  161. // // if (output.name == MeasureTerms.URMVelMax) {
  162. // // output.unit = VidUsUnit.mms;
  163. // // feature.updateFloatValue(
  164. // // output, result.maxVel + app.urmMinVel, VidUsUnit.mms);
  165. // // }
  166. // // if (output.name == MeasureTerms.URMVelMin) {
  167. // // output.unit = VidUsUnit.mms;
  168. // // feature.updateFloatValue(
  169. // // output, result.minVel + app.urmMinVel, VidUsUnit.mms);
  170. // // }
  171. // // if (output.name == MeasureTerms.URMVelMean) {
  172. // // output.unit = VidUsUnit.mms;
  173. // // feature.updateFloatValue(
  174. // // output, result.meanVel + app.urmMinVel, VidUsUnit.mms);
  175. // // }
  176. // // if (output.name == MeasureTerms.URMVelStd) {
  177. // // output.unit = VidUsUnit.mms;
  178. // // feature.updateFloatValue(
  179. // // output, sqrt(result.varianceVel), VidUsUnit.mms);
  180. // // }
  181. // // if (output.name == MeasureTerms.Area) {
  182. // // output.unit = VidUsUnit.cm2;
  183. // // feature.updateFloatValue(output, result.roiArea, VidUsUnit.cm2);
  184. // // }
  185. // // }
  186. // // } else {
  187. // // throw Exception("URM Measure API error");
  188. // // }
  189. // // } catch (e) {
  190. // // description = " ";
  191. // // updateStringValue(description);
  192. // // return;
  193. // // }
  194. // // ref.application.updateRenderReady.emit(this, null);
  195. // // }
  196. // }
  197. // class URMLocationCal extends Calculator<Location, double> {
  198. // URMLocationCal(Location ref) : super(ref);
  199. // @override
  200. // void calculate() {}
  201. // @override
  202. // Future<void> calculateAsync() async {
  203. // if (ref.feature == null) return;
  204. // Size urmResultSize = const Size(0, 0);
  205. // try {
  206. // if (ref.application is! URMApplication) {
  207. // return;
  208. // }
  209. // final URMApplication urmApplication = ref.application as URMApplication;
  210. // urmResultSize = Size(urmApplication.resultWidth.toDouble(),
  211. // urmApplication.resultHeight.toDouble());
  212. // // urmResultWidth = urmApplication.resultWidth;
  213. // // urmResultHeight = urmApplication.resultHeight;
  214. // final point = ref.feature!.point.clone();
  215. // final startPoint = point.scale2Size(urmResultSize);
  216. // print("URM Measure startPoint: $startPoint");
  217. // // await getSRLoactionVelResult(urmApplication, startPoint);
  218. // return;
  219. // } catch (e) {
  220. // logger.e('URM Measure error: $e');
  221. // return;
  222. // }
  223. // }
  224. // // ✅ URM 测量项 6
  225. // // Future<void> getSRLoactionVelResult(
  226. // // URMApplication app, DPoint startPoint) async {
  227. // // String description = "URM\n Measuring";
  228. // // try {
  229. // // GetSRLoactionVelResult? result =
  230. // // await app.getSRLoactionVelResult(startPoint);
  231. // // if (result != null) {
  232. // // print("URM Measure output: ${result.output}");
  233. // // final feature = ref.feature!;
  234. // // for (var output in ref.meta.outputs) {
  235. // // if (output.name == MeasureTerms.SRVel) {
  236. // // output.unit = VidUsUnit.mms;
  237. // // feature.updateFloatValue(output, result.output, output.unit);
  238. // // }
  239. // // }
  240. // // } else {
  241. // // throw Exception("URM Measure API error");
  242. // // }
  243. // // } catch (e) {
  244. // // description = " ";
  245. // // updateStringValue(description);
  246. // // return;
  247. // // }
  248. // // ref.application.updateRenderReady.emit(this, null);
  249. // // }
  250. // }
  251. // /// 自动弯曲度测量
  252. // // class URMAutoLineLineCal extends Calculator<StraightLine, double> {
  253. // // URMAutoLineLineCal(
  254. // // StraightLine ref, {
  255. // // required this.type,
  256. // // }) : super(ref);
  257. // // final String type;
  258. // // @override
  259. // // void calculate() {}
  260. // // @override
  261. // // Future<void> calculateAsync() async {
  262. // // try {
  263. // // if (ref.feature == null) return;
  264. // // if (ref.application is! URMApplication) return;
  265. // // Size urmResultSize = const Size(0, 0);
  266. // // final URMApplication urmApplication = ref.application as URMApplication;
  267. // // urmResultSize = Size(urmApplication.resultWidth.toDouble(),
  268. // // urmApplication.resultHeight.toDouble());
  269. // // final p1 = ref.feature!.startPoint;
  270. // // final p2 = ref.feature!.endPoint;
  271. // // // final startPoint = leftTopPercent.scale2Size(urmResultSize);
  272. // // // final endPoint = rightBottomPercent.scale2Size(urmResultSize);
  273. // // // final startPoint = DPoint(0.478335, 0.315384);
  274. // // // final endPoint = DPoint(0.538395, 0.526373);
  275. // // switch (type) {
  276. // // case MeasureTypes.SRCurvature:
  277. // // await getSRCurvatureResult(urmApplication, p1, p2);
  278. // // break;
  279. // // // case MeasureTypes.URMDensityMeasure:
  280. // // // await getURMDenMeasureResult(urmApplication, startPoint, endPoint);
  281. // // // break;
  282. // // // case MeasureTypes.URMVesselMeasure:
  283. // // // final feature = ref.feature!;
  284. // // // final viewport = feature.hostVisualArea!.viewport!;
  285. // // // final p1 = feature.startPoint;
  286. // // // final p2 = feature.endPoint;
  287. // // // final pp1 = viewport.convert(p1);
  288. // // // final pp2 = viewport.convert(p2);
  289. // // // final cmlength = (pp2 - pp1).length.abs();
  290. // // // await getURMVessMeasureResult(
  291. // // // urmApplication, startPoint, endPoint, cmlength);
  292. // // // break;
  293. // // default:
  294. // // }
  295. // // } catch (e) {
  296. // // logger.e('URM Measure error: $e');
  297. // // return;
  298. // // }
  299. // // }
  300. // // // // ✅ URM 测量项 1
  301. // // Future<void> getSRCurvatureResult(
  302. // // URMApplication app, DPoint startPoint, DPoint endPoint) async {
  303. // // String description = "URM\n Measuring";
  304. // // try {
  305. // // URMMeasureProcessResult? result = await app.getURMMeasureResult(
  306. // // urmMeasureType: URMMeasureType.URMCurvature,
  307. // // rOIType: URMROIType.placeHolder_0,
  308. // // srcDPoints: [
  309. // // UrmPoint(x: startPoint.x, y: startPoint.y),
  310. // // UrmPoint(x: endPoint.x, y: endPoint.y)
  311. // // ],
  312. // // );
  313. // // if (result != null) {
  314. // // print(
  315. // // "URM Measure curvature: ${result} nums: ${result.resultDPoints?.length}");
  316. // // // TODO 将返回的视图百分比区域的点集转换为全图百分比点集,然会然后绘制
  317. // // final feature = ref.feature!;
  318. // // if (feature is! StraightCurvatureFeature) return;
  319. // // feature.autoLinePoints = urmPointsToDPoints(result.resultDPoints);
  320. // // /// TODO 只转数据类型还不够,需要将 视图区域百分比坐标转为全图百分比坐标
  321. // // for (var output in ref.meta.outputs) {
  322. // // if (output.name == MeasureTerms.SRCurvature) {
  323. // // output.unit = VidUsUnit.None;
  324. // // feature.updateFloatValue(output, result.resultData, output.unit);
  325. // // }
  326. // // }
  327. // // } else {
  328. // // throw Exception("URM Measure API error");
  329. // // }
  330. // // } catch (e) {
  331. // // description = " ";
  332. // // updateStringValue(description);
  333. // // return;
  334. // // }
  335. // // ref.application.updateRenderReady.emit(this, null);
  336. // // }
  337. // // // //✅ URM 测量项 8
  338. // // // Future<void> getURMDenMeasureResult(
  339. // // // URMApplication app, DPoint startPoint, DPoint endPoint) async {
  340. // // // String description = "URM\n Measuring";
  341. // // // try {
  342. // // // GetURMDenMeasureResult? result =
  343. // // // await app.getURMDenMeasureResult(startPoint, endPoint);
  344. // // // if (result != null) {
  345. // // // print(
  346. // // // "URM Measure inMaxDensity: ${result.inMaxDensity} inMeanDensity: ${result.inMeanDensity}");
  347. // // // // description = "${(result.inMaxDensity).toStringAsFixed(2)}mm/s ...";
  348. // // // final feature = ref.feature!;
  349. // // // for (var output in ref.meta.outputs) {
  350. // // // if (output.name == MeasureTerms.URMDenROI) {
  351. // // // output.unit = VidUsUnit.percent;
  352. // // // feature.updateFloatValue(
  353. // // // output, result.roiDen * 100, VidUsUnit.percent);
  354. // // // }
  355. // // // if (output.name == MeasureTerms.URMDenFractalDim) {
  356. // // // output.unit = VidUsUnit.None;
  357. // // // feature.updateFloatValue(
  358. // // // output, result.roiFractalDim, VidUsUnit.None);
  359. // // // }
  360. // // // if (output.name == MeasureTerms.URMDenMax) {
  361. // // // output.unit = VidUsUnit.None;
  362. // // // feature.updateFloatValue(output, result.maxDensity, VidUsUnit.None);
  363. // // // }
  364. // // // if (output.name == MeasureTerms.URMDenMin) {
  365. // // // output.unit = VidUsUnit.None;
  366. // // // feature.updateFloatValue(output, result.minDensity, VidUsUnit.None);
  367. // // // }
  368. // // // if (output.name == MeasureTerms.URMDenMean) {
  369. // // // output.unit = VidUsUnit.None;
  370. // // // feature.updateFloatValue(
  371. // // // output, result.meanDensity, VidUsUnit.None);
  372. // // // }
  373. // // // if (output.name == MeasureTerms.URMDenStd) {
  374. // // // output.unit = VidUsUnit.None;
  375. // // // feature.updateFloatValue(
  376. // // // output, sqrt(result.varianceDensity), VidUsUnit.None);
  377. // // // }
  378. // // // if (output.name == MeasureTerms.Area) {
  379. // // // output.unit = VidUsUnit.cm2;
  380. // // // feature.updateFloatValue(output, result.roiArea, VidUsUnit.cm2);
  381. // // // }
  382. // // // }
  383. // // // } else {
  384. // // // throw Exception("URM Measure API error");
  385. // // // }
  386. // // // } catch (e) {
  387. // // // description = " ";
  388. // // // updateStringValue(description);
  389. // // // return;
  390. // // // }
  391. // // // ref.application.updateRenderReady.emit(this, null);
  392. // // // }
  393. // // // //✅ URM 测量项 10
  394. // // // Future<void> getURMVessMeasureResult(URMApplication app, DPoint startPoint,
  395. // // // DPoint endPoint, double cmlength) async {
  396. // // // String description = "URM\n Measuring";
  397. // // // try {
  398. // // // GetUrmVessMeasureResult? result =
  399. // // // await app.getURMVessMeasureResult(startPoint, endPoint, cmlength);
  400. // // // if (result != null) {
  401. // // // app.onUpdateChart?.call(
  402. // // // URMChartParams(
  403. // // // cmlength: cmlength,
  404. // // // minPointIndex: result.minPos,
  405. // // // maxPointIndex: result.maxPos,
  406. // // // points: convertPoints(result.outputPoints),
  407. // // // ),
  408. // // // );
  409. // // // print(
  410. // // // "URM Measure inMaxDensity: ${result.maxVessDiameter} inMeanDensity: ${result.meanVessDistacne}");
  411. // // // final feature = ref.feature!;
  412. // // // for (var output in ref.meta.outputs) {
  413. // // // if (output.name == MeasureTerms.MaxVessDistance) {
  414. // // // output.unit = VidUsUnit.mm;
  415. // // // feature.updateFloatValue(
  416. // // // output, result.maxVessDistance, VidUsUnit.mm);
  417. // // // }
  418. // // // if (output.name == MeasureTerms.MinVessDistance) {
  419. // // // output.unit = VidUsUnit.mm;
  420. // // // feature.updateFloatValue(
  421. // // // output, result.minVessDistance, VidUsUnit.mm);
  422. // // // }
  423. // // // if (output.name == MeasureTerms.MeanVessDistacne) {
  424. // // // output.unit = VidUsUnit.mm;
  425. // // // feature.updateFloatValue(
  426. // // // output, result.meanVessDistacne, VidUsUnit.mm);
  427. // // // }
  428. // // // if (output.name == MeasureTerms.StdVessDistance) {
  429. // // // output.unit = VidUsUnit.mm;
  430. // // // feature.updateFloatValue(
  431. // // // output, sqrt(result.varianceVessDistance), VidUsUnit.mm);
  432. // // // }
  433. // // // if (output.name == MeasureTerms.MaxVessDiameter) {
  434. // // // output.unit = VidUsUnit.mm;
  435. // // // feature.updateFloatValue(
  436. // // // output, result.maxVessDiameter, VidUsUnit.mm);
  437. // // // }
  438. // // // if (output.name == MeasureTerms.MinVessDiameter) {
  439. // // // output.unit = VidUsUnit.mm;
  440. // // // feature.updateFloatValue(
  441. // // // output, result.minVessDiameter, VidUsUnit.mm);
  442. // // // }
  443. // // // if (output.name == MeasureTerms.MeanVessDiameter) {
  444. // // // output.unit = VidUsUnit.mm;
  445. // // // feature.updateFloatValue(
  446. // // // output, result.meanVessDiameter, VidUsUnit.mm);
  447. // // // }
  448. // // // if (output.name == MeasureTerms.StdVessDiameter) {
  449. // // // output.unit = VidUsUnit.mm;
  450. // // // feature.updateFloatValue(
  451. // // // output, sqrt(result.varianceVessDiameter), VidUsUnit.mm);
  452. // // // }
  453. // // // }
  454. // // // } else {
  455. // // // throw Exception("URM Measure API error");
  456. // // // }
  457. // // // } catch (e) {
  458. // // // description = " ";
  459. // // // updateStringValue(description);
  460. // // // return;
  461. // // // }
  462. // // // ref.application.updateRenderReady.emit(this, null);
  463. // // // }
  464. // // List<DPoint> urmPointsToDPoints(List<UrmPoint>? points) {
  465. // // if (points == null) return [];
  466. // // List<DPoint> urmPoints = [];
  467. // // for (var point in points) {
  468. // // urmPoints.add(DPoint(point.x, point.y));
  469. // // }
  470. // // return urmPoints;
  471. // // }
  472. // // //
  473. // // }
  474. // class URMTraceCal extends Calculator<AreaItemAbstract, double> {
  475. // URMTraceCal(
  476. // AreaItemAbstract ref, {
  477. // required this.type,
  478. // }) : super(ref);
  479. // final String type;
  480. // @override
  481. // void calculate() {}
  482. // @override
  483. // Future<void> calculateAsync() async {
  484. // if (ref.feature == null) return;
  485. // final feature = ref.feature!;
  486. // try {
  487. // if (ref.application is! URMApplication) {
  488. // return;
  489. // }
  490. // Size urmResultSize = const Size(0, 0);
  491. // final URMApplication urmApplication = ref.application as URMApplication;
  492. // urmResultSize = Size(urmApplication.resultWidth.toDouble(),
  493. // urmApplication.resultHeight.toDouble());
  494. // final List<DPoint> points =
  495. // feature.innerPoints.map((e) => e.scale2Size(urmResultSize)).toList();
  496. // // switch (type) {
  497. // // case MeasureTypes.SRTraceDensity:
  498. // // await getSRTraceVelResult(urmApplication, convertPoints(points));
  499. // // break;
  500. // // case MeasureTypes.SRTraceFractalDim:
  501. // // await getSRTraceFractalDimResult(
  502. // // urmApplication, convertPoints(points));
  503. // // break;
  504. // // default:
  505. // // }
  506. // } catch (e) {
  507. // logger.e('URM Measure error: $e');
  508. // return;
  509. // }
  510. // }
  511. // // //✅ URM 测量项 4
  512. // // Future<void> getSRTraceVelResult(
  513. // // URMApplication app, List<UrmPoint> points) async {
  514. // // String description = "URM\n Measuring";
  515. // // try {
  516. // // GetSRTraceVelResult? result = await app.getSRTraceVelResult(points);
  517. // // if (result != null) {
  518. // // print("URM Measure output: ${result.output} ");
  519. // // final feature = ref.feature!;
  520. // // for (var output in ref.meta.outputs) {
  521. // // if (output.name == MeasureTerms.URMDenROI) {
  522. // // output.unit = VidUsUnit.percent;
  523. // // feature.updateFloatValue(output, result.output, output.unit);
  524. // // }
  525. // // }
  526. // // } else {
  527. // // throw Exception("URM Measure API error");
  528. // // }
  529. // // } catch (e) {
  530. // // description = " ";
  531. // // updateStringValue(description);
  532. // // return;
  533. // // }
  534. // // ref.application.updateRenderReady.emit(this, null);
  535. // // }
  536. // // //✅ URM 测量项 5
  537. // // Future<void> getSRTraceFractalDimResult(
  538. // // URMApplication app, List<UrmPoint> points) async {
  539. // // String description = "URM\n Measuring";
  540. // // try {
  541. // // GetSRTraceFractalDimResult? result =
  542. // // await app.getSRTraceFractalDimResult(points);
  543. // // if (result != null) {
  544. // // print("URM Measure output: ${result.output} ");
  545. // // final feature = ref.feature!;
  546. // // for (var output in ref.meta.outputs) {
  547. // // if (output.name == MeasureTerms.URMDenFractalDim) {
  548. // // output.unit = VidUsUnit.None;
  549. // // feature.updateFloatValue(output, result.output, output.unit);
  550. // // }
  551. // // }
  552. // // } else {
  553. // // throw Exception("URM Measure API error");
  554. // // }
  555. // // } catch (e) {
  556. // // description = " ";
  557. // // updateStringValue(description);
  558. // // return;
  559. // // }
  560. // // ref.application.updateRenderReady.emit(this, null);
  561. // // }
  562. // List<UrmPoint> convertPoints(List<DPoint> points) {
  563. // List<UrmPoint> urmPoints = [];
  564. // for (var point in points) {
  565. // urmPoints.add(UrmPoint(x: point.x, y: point.y));
  566. // }
  567. // return urmPoints;
  568. // }
  569. // }
  570. // // class URMVelCal extends Calculator<URMVelAbstract, double> {
  571. // // URMVelCal(URMVelAbstract ref) : super(ref);
  572. // // @override
  573. // // void calculate() {
  574. // // if (ref.feature == null) return;
  575. // // final a1 = _pickChildValue(ref.child1);
  576. // // final a2 = _pickChildValue(ref.child2);
  577. // // final a3 = _pickChildValue(ref.child2);
  578. // // final feature = ref.feature!;
  579. // // final viewport = feature.hostVisualArea!.viewport!;
  580. // // // if (a1 != null && a2 != null) {
  581. // // // final value = GeneralFormulas.countStenosis(
  582. // // // a1,
  583. // // // a2,
  584. // // // );
  585. // // // updateFloatValue(value);
  586. // // // }
  587. // // }
  588. // // double? _pickChildValue(MeasureItem item) {
  589. // // if (item.calculator == null) return null;
  590. // // ValueBase? value;
  591. // // if (item.measuredFeatures.isNotEmpty) {
  592. // // value = item.measuredFeatures.first.value;
  593. // // } else if (item.feature != null) {
  594. // // value = item.feature!.value;
  595. // // }
  596. // // if (value != null && value is FloatValue) {
  597. // // return (value).value ?? 0;
  598. // // }
  599. // // return null;
  600. // // }
  601. // // }
  602. // class URMSrDensityCal extends Calculator<URMTwoSRRoiRectAbstract, double> {
  603. // URMSrDensityCal(URMTwoSRRoiRectAbstract ref) : super(ref);
  604. // @override
  605. // void calculate() {
  606. // if (ref.feature == null) return;
  607. // final a1 = _pickChildValue(ref.child1);
  608. // final a2 = _pickChildValue(ref.child2);
  609. // final a3 = _pickChildValue(ref.child2);
  610. // final feature = ref.feature!;
  611. // final viewport = feature.hostVisualArea!.viewport!;
  612. // // if (a1 != null && a2 != null) {
  613. // // final value = GeneralFormulas.countStenosis(
  614. // // a1,
  615. // // a2,
  616. // // );
  617. // // updateFloatValue(value);
  618. // // }
  619. // }
  620. // double? _pickChildValue(MeasureItem item) {
  621. // if (item.calculator == null) return null;
  622. // ValueBase? value;
  623. // if (item.measuredFeatures.isNotEmpty) {
  624. // value = item.measuredFeatures.first.value;
  625. // } else if (item.feature != null) {
  626. // value = item.feature!.value;
  627. // }
  628. // if (value != null && value is FloatValue) {
  629. // return (value).value ?? 0;
  630. // }
  631. // return null;
  632. // }
  633. // }