Sfoglia il codice sorgente

1、新增l 的体积计算

guanxinyi 8 mesi fa
parent
commit
0dd75660d7

+ 24 - 4
lib/process/calcuators/distance.dart

@@ -1,7 +1,4 @@
-import 'package:fis_measure/interfaces/date_types/point.dart';
-import 'package:fis_measure/interfaces/process/calculators/output.dart';
-import 'package:fis_measure/interfaces/process/items/types.dart';
-import 'package:vid/us/vid_us_unit.dart';
+import 'package:fis_measure/process/calcuators/formulas/general.dart';
 
 import '../primitives/straightline.dart';
 import 'calculator.dart';
@@ -26,3 +23,26 @@ class DistanceCal extends Calculator<StraightLine, double> {
     floatValue!.name = ref.displayName;
   }
 }
+
+class VolumeOneDistanceCal extends Calculator<StraightLine, double> {
+  VolumeOneDistanceCal(StraightLine ref) : super(ref);
+
+  @override
+  void calculate() {
+    if (ref.feature == null) return;
+
+    final feature = ref.feature!;
+    // TODO:xxx
+    final viewport = feature.hostVisualArea!.viewport!;
+    final p1 = feature.startPoint;
+    final p2 = feature.endPoint;
+    final pp1 = viewport.convert(p1);
+    final pp2 = viewport.convert(p2);
+
+    final value = (pp2 - pp1).length.abs();
+    double volume = GeneralFormulas.volume(value);
+
+    final floatValue = updateFloatValue(volume);
+    floatValue!.name = ref.displayName;
+  }
+}

+ 11 - 0
lib/process/calcuators/formulas/general.dart

@@ -71,6 +71,7 @@ class GeneralFormulas {
 
   static double medianVelocity(double ps, double ed) =>
       _singleton.medianVelocity(ps, ed);
+  static double volume(double d) => _singleton.volume(d);
 }
 
 abstract class IGeneralFormulaStrategy {
@@ -102,6 +103,7 @@ abstract class IGeneralFormulaStrategy {
   double area(double d1, double d2);
   double flowVolTAMAX(double flowArea, double tamean, double coefficient);
   double perimeter(double d1, double d2);
+  double volume(double d);
 
   /// <summary>
   /// Pulastility Index
@@ -508,6 +510,15 @@ class BaseGeneralFormulas implements IGeneralFormulaStrategy {
     double h = math.pow((k - 1), 2) / math.pow((k + 1), 2);
     return math.pi * (1 + 3 * h / (10 + math.sqrt(4 - 3 * h)));
   }
+
+  @override
+  double volume(double d) {
+    double volume = 0.0;
+    if (!almostEquals(d, 0.0)) {
+      volume = math.pow(d, 3) * math.pi / 6.0;
+    }
+    return volume;
+  }
 }
 
 class AnimalsGeneralFormulas extends BaseGeneralFormulas {}

+ 2 - 0
lib/process/items/factory.dart

@@ -148,6 +148,8 @@ class MeasureItemFactory {
     _singleton._register(MeasureTypes.Distance, StraightLine.createDistance);
     _singleton._register(MeasureTypes.Ray, Ray.createRay);
     _singleton._register(MeasureTypes.LvDpDt, StraightLine.createLvDpDt);
+    _singleton._register(
+        MeasureTypes.VolumeOneDistance, StraightLine.createVolume);
 
     // Three StraightLine
     _singleton._register(

+ 6 - 0
lib/process/primitives/straightline.dart

@@ -66,6 +66,12 @@ class StraightLine extends MeasureItem<StraightLineFeature> {
     return sraightLine;
   }
 
+  static StraightLine createVolume(ItemMeta meta, [IMeasureItem? parent]) {
+    StraightLine sraightLine = StraightLine(meta, parent);
+    sraightLine.calculator = VolumeOneDistanceCal(sraightLine);
+    return sraightLine;
+  }
+
   @override
   bool onExecuteMouse(PointInfo args) {
     if (state == ItemStates.finished) {