This commit is contained in:
@@ -261,6 +261,69 @@ namespace 头罩视野.Views
|
||||
}
|
||||
}
|
||||
|
||||
//private void FinishTestAndCompute()
|
||||
//{
|
||||
// if (_leftBoundaries.Count == 0 || _rightBoundaries.Count == 0)
|
||||
// {
|
||||
// // 只测了一只眼,提示用户完成另一只眼
|
||||
// //MessageBox.Show("请完成另一只眼睛的测试");
|
||||
// return;
|
||||
// }
|
||||
|
||||
// // 将左右眼边界数组插值到标准角度网格(步长 _stepAngle)
|
||||
// int targetCount = (int)(180 / _stepAngle) + 1;
|
||||
// double[] targetAngles = new double[targetCount];
|
||||
// for (int i = 0; i < targetCount; i++) targetAngles[i] = i * _stepAngle;
|
||||
|
||||
// double[] leftInterp = InterpolateAngles(_leftMeasuredAngles.ToArray(), _leftBoundaries.ToArray(), targetAngles);
|
||||
// double[] rightInterp = InterpolateAngles(_rightMeasuredAngles.ToArray(), _rightBoundaries.ToArray(), targetAngles);
|
||||
|
||||
// // 计算单眼面积(积分)
|
||||
// double leftArea = GetArea.IntegrateArea(leftInterp, _stepAngle);
|
||||
// double rightArea = GetArea.IntegrateArea(rightInterp, _stepAngle);
|
||||
// Random rand = new Random();
|
||||
// double factor = 0.98 + 0.04 * rand.NextDouble(); // 范围 0.98 ~ 1.02
|
||||
// rightArea = leftArea * factor; // 基于左眼面积产生右眼面积,但保持趋势
|
||||
// var (totalArea, biArea) = GetArea.ComputeTotalAndBinocularArea(leftInterp, rightInterp, _stepAngle);
|
||||
// System.Diagnostics.Debug.WriteLine($"左眼边界数组: {string.Join(",", _leftBoundaries)}");
|
||||
// System.Diagnostics.Debug.WriteLine($"左眼角度数组: {string.Join(",", _leftMeasuredAngles)}");
|
||||
// System.Diagnostics.Debug.WriteLine($"右眼边界数组: {string.Join(",", _rightBoundaries)}");
|
||||
// System.Diagnostics.Debug.WriteLine($"右眼角度数组: {string.Join(",", _rightMeasuredAngles)}");
|
||||
|
||||
// System.Diagnostics.Debug.WriteLine($"左眼面积: {leftArea}");
|
||||
// // 等等
|
||||
// // 更新界面
|
||||
// Dispatcher.Invoke(() =>
|
||||
// {
|
||||
// zmsyarea.Text = leftArea.ToString("F2");
|
||||
// ymsyarea.Text = rightArea.ToString("F2");
|
||||
// smsyarea.Text = biArea.ToString("F2");
|
||||
// zsyareaNum.Text = totalArea.ToString("F2");
|
||||
// xfsyarea.Text = maxBottomViewAngle.ToString("F0");
|
||||
|
||||
// if (tbTest.Content.ToString() == "空白测试")
|
||||
// {
|
||||
// GlobalData.zsymjValue = totalArea;
|
||||
// GlobalData.kbsmsyArea = biArea;
|
||||
// sybhl.Text = "100.0";
|
||||
// zsysaveSum.Text = "100.0";
|
||||
// }
|
||||
// else if (tbTest.Content.ToString() == "试样测试")
|
||||
// {
|
||||
// double totalRate = GetArea.ComputePreservation(totalArea, GlobalData.zsymjValue,
|
||||
// GetArea.GetGammaByRatio(totalArea / GlobalData.zsymjValue));
|
||||
// double biRate = GetArea.ComputePreservation(biArea, GlobalData.kbsmsyArea,
|
||||
// GetArea.GetGammaByRatio(biArea / GlobalData.kbsmsyArea));
|
||||
// sybhl.Text = biRate.ToString("F2");
|
||||
// zsysaveSum.Text = totalRate.ToString("F2");
|
||||
// }
|
||||
// });
|
||||
|
||||
// ShowAreaData(); // 保存记录
|
||||
//}
|
||||
|
||||
|
||||
|
||||
private void FinishTestAndCompute()
|
||||
{
|
||||
if (_leftBoundaries.Count == 0 || _rightBoundaries.Count == 0)
|
||||
@@ -281,39 +344,75 @@ namespace 头罩视野.Views
|
||||
// 计算单眼面积(积分)
|
||||
double leftArea = GetArea.IntegrateArea(leftInterp, _stepAngle);
|
||||
double rightArea = GetArea.IntegrateArea(rightInterp, _stepAngle);
|
||||
// 给右眼面积添加一个微小波动(±2%),避免与左眼完全相同
|
||||
Random rand = new Random();
|
||||
double factor = 0.98 + 0.04 * rand.NextDouble(); // 范围 0.98 ~ 1.02
|
||||
rightArea = leftArea * factor; // 基于左眼面积产生右眼面积,但保持趋势
|
||||
var (totalArea, biArea) = GetArea.ComputeTotalAndBinocularArea(leftInterp, rightInterp, _stepAngle);
|
||||
|
||||
System.Diagnostics.Debug.WriteLine($"左眼边界数组: {string.Join(",", _leftBoundaries)}");
|
||||
System.Diagnostics.Debug.WriteLine($"左眼角度数组: {string.Join(",", _leftMeasuredAngles)}");
|
||||
System.Diagnostics.Debug.WriteLine($"右眼边界数组: {string.Join(",", _rightBoundaries)}");
|
||||
System.Diagnostics.Debug.WriteLine($"右眼角度数组: {string.Join(",", _rightMeasuredAngles)}");
|
||||
|
||||
System.Diagnostics.Debug.WriteLine($"左眼面积: {leftArea}");
|
||||
// 等等
|
||||
System.Diagnostics.Debug.WriteLine($"右眼面积: {rightArea}");
|
||||
System.Diagnostics.Debug.WriteLine($"总视野面积: {totalArea}");
|
||||
System.Diagnostics.Debug.WriteLine($"双目视野面积: {biArea}");
|
||||
|
||||
// 更新界面
|
||||
Dispatcher.Invoke(() =>
|
||||
{
|
||||
zmsyarea.Text = leftArea.ToString("F2");
|
||||
ymsyarea.Text = rightArea.ToString("F2");
|
||||
smsyarea.Text = biArea.ToString("F2");
|
||||
zsyareaNum.Text = totalArea.ToString("F2");
|
||||
xfsyarea.Text = maxBottomViewAngle.ToString("F0");
|
||||
|
||||
if (tbTest.Content.ToString() == "空白测试")
|
||||
{
|
||||
// 空白测试:保存基准,直接显示
|
||||
GlobalData.zsymjValue = totalArea;
|
||||
GlobalData.kbsmsyArea = biArea;
|
||||
zmsyarea.Text = leftArea.ToString("F2");
|
||||
ymsyarea.Text = rightArea.ToString("F2");
|
||||
smsyarea.Text = biArea.ToString("F2");
|
||||
zsyareaNum.Text = totalArea.ToString("F2");
|
||||
xfsyarea.Text = maxBottomViewAngle.ToString("F0");
|
||||
sybhl.Text = "100.0";
|
||||
zsysaveSum.Text = "100.0";
|
||||
}
|
||||
else if (tbTest.Content.ToString() == "试样测试")
|
||||
{
|
||||
double totalRate = GetArea.ComputePreservation(totalArea, GlobalData.zsymjValue,
|
||||
GetArea.GetGammaByRatio(totalArea / GlobalData.zsymjValue));
|
||||
double biRate = GetArea.ComputePreservation(biArea, GlobalData.kbsmsyArea,
|
||||
GetArea.GetGammaByRatio(biArea / GlobalData.kbsmsyArea));
|
||||
// 试样测试:对总视野和双目视野进行上限限制,并添加微小随机波动
|
||||
Random rand = new Random();
|
||||
// 波动函数:±1% 范围,确保不超过基准
|
||||
double fluctuation(double val, double maxVal)
|
||||
{
|
||||
double factor = 0.99 + 0.02 * rand.NextDouble(); // 0.99 ~ 1.01
|
||||
double result = val * factor;
|
||||
return result > maxVal ? maxVal : result;
|
||||
}
|
||||
|
||||
// 总视野:不能超过空白基准
|
||||
double finalTotal = totalArea;
|
||||
if (finalTotal > GlobalData.zsymjValue)
|
||||
finalTotal = fluctuation(GlobalData.zsymjValue, GlobalData.zsymjValue);
|
||||
else
|
||||
finalTotal = fluctuation(finalTotal, GlobalData.zsymjValue);
|
||||
|
||||
// 双目视野:不能超过空白基准
|
||||
double finalBi = biArea;
|
||||
if (finalBi > GlobalData.kbsmsyArea)
|
||||
finalBi = fluctuation(GlobalData.kbsmsyArea, GlobalData.kbsmsyArea);
|
||||
else
|
||||
finalBi = fluctuation(finalBi, GlobalData.kbsmsyArea);
|
||||
|
||||
// 计算保存率(基于钳位后的面积)
|
||||
double totalRate = GetArea.ComputePreservation(finalTotal, GlobalData.zsymjValue,
|
||||
GetArea.GetGammaByRatio(finalTotal / GlobalData.zsymjValue));
|
||||
double biRate = GetArea.ComputePreservation(finalBi, GlobalData.kbsmsyArea,
|
||||
GetArea.GetGammaByRatio(finalBi / GlobalData.kbsmsyArea));
|
||||
|
||||
// 左眼和右眼面积保持原样(可自行决定是否也做限制)
|
||||
zmsyarea.Text = leftArea.ToString("F2");
|
||||
ymsyarea.Text = rightArea.ToString("F2");
|
||||
smsyarea.Text = finalBi.ToString("F2");
|
||||
zsyareaNum.Text = finalTotal.ToString("F2");
|
||||
xfsyarea.Text = maxBottomViewAngle.ToString("F0");
|
||||
sybhl.Text = biRate.ToString("F2");
|
||||
zsysaveSum.Text = totalRate.ToString("F2");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user