diff --git a/.vs/CPSO/FileContentIndex/2f2a8f71-d90a-4432-92b5-374047c086e1.vsidx b/.vs/CPSO/FileContentIndex/2f2a8f71-d90a-4432-92b5-374047c086e1.vsidx
deleted file mode 100644
index 1557808..0000000
Binary files a/.vs/CPSO/FileContentIndex/2f2a8f71-d90a-4432-92b5-374047c086e1.vsidx and /dev/null differ
diff --git a/.vs/CPSO/FileContentIndex/72ce9a86-e3d6-459f-9921-c6cb4c0a9ad1.vsidx b/.vs/CPSO/FileContentIndex/72ce9a86-e3d6-459f-9921-c6cb4c0a9ad1.vsidx
deleted file mode 100644
index 50aac97..0000000
Binary files a/.vs/CPSO/FileContentIndex/72ce9a86-e3d6-459f-9921-c6cb4c0a9ad1.vsidx and /dev/null differ
diff --git a/.vs/CPSO/FileContentIndex/78d59333-ed6d-4d23-9b46-a5f46dda5833.vsidx b/.vs/CPSO/FileContentIndex/78d59333-ed6d-4d23-9b46-a5f46dda5833.vsidx
deleted file mode 100644
index b8e1683..0000000
Binary files a/.vs/CPSO/FileContentIndex/78d59333-ed6d-4d23-9b46-a5f46dda5833.vsidx and /dev/null differ
diff --git a/.vs/CPSO/FileContentIndex/9c9d33fa-c8e6-4d48-89d7-d361f3f8699a.vsidx b/.vs/CPSO/FileContentIndex/9c9d33fa-c8e6-4d48-89d7-d361f3f8699a.vsidx
deleted file mode 100644
index b4ff256..0000000
Binary files a/.vs/CPSO/FileContentIndex/9c9d33fa-c8e6-4d48-89d7-d361f3f8699a.vsidx and /dev/null differ
diff --git a/.vs/CPSO/FileContentIndex/bfba5c88-e27d-41bc-86db-1dc643c3ba2d.vsidx b/.vs/CPSO/FileContentIndex/bfba5c88-e27d-41bc-86db-1dc643c3ba2d.vsidx
deleted file mode 100644
index 71d491c..0000000
Binary files a/.vs/CPSO/FileContentIndex/bfba5c88-e27d-41bc-86db-1dc643c3ba2d.vsidx and /dev/null differ
diff --git a/.vs/CPSO/v17/.futdcache.v2 b/.vs/CPSO/v17/.futdcache.v2
index 2311380..b3697e2 100644
Binary files a/.vs/CPSO/v17/.futdcache.v2 and b/.vs/CPSO/v17/.futdcache.v2 differ
diff --git a/.vs/CPSO/v17/.suo b/.vs/CPSO/v17/.suo
index 5dc9c4a..8c1d429 100644
Binary files a/.vs/CPSO/v17/.suo and b/.vs/CPSO/v17/.suo differ
diff --git a/.vs/CPSO/v17/Browse.VC.db b/.vs/CPSO/v17/Browse.VC.db
index b756887..b056361 100644
Binary files a/.vs/CPSO/v17/Browse.VC.db and b/.vs/CPSO/v17/Browse.VC.db differ
diff --git a/.vs/CPSO/v17/fileList.bin b/.vs/CPSO/v17/fileList.bin
index df4e685..06181d7 100644
Binary files a/.vs/CPSO/v17/fileList.bin and b/.vs/CPSO/v17/fileList.bin differ
diff --git a/CPSO/CPSO.csproj b/CPSO/CPSO.csproj
index ae0965b..39ca7c4 100644
--- a/CPSO/CPSO.csproj
+++ b/CPSO/CPSO.csproj
@@ -755,12 +755,6 @@
FrmAnalysisResult.cs
-
- Form
-
-
- FrmAnalysisResultEx.cs
-
Form
@@ -816,8 +810,8 @@
FrmToolPositionViewer.cs
-
-
+
+
@@ -1160,9 +1154,6 @@
FrmAnalysisResult.cs
-
- FrmAnalysisResultEx.cs
-
FrmEditProcessingJobs.cs
diff --git a/CPSO/Controller.cs b/CPSO/Controller.cs
index 2e2839b..277ec47 100644
--- a/CPSO/Controller.cs
+++ b/CPSO/Controller.cs
@@ -86,8 +86,8 @@ namespace CPSO
public List ProcessingJobs => _processingJobs;
[NonSerialized]
- protected List _completedJobs = new List ();
- public List CompletedJobs => _completedJobs;
+ protected List _completedJobs = new List();
+ public List CompletedJobs => _completedJobs;
// Properties
diff --git a/CPSO/Forms/71_Analysis/FrmAnalysis.cs b/CPSO/Forms/71_Analysis/FrmAnalysis.cs
index 4f5d8bb..0b56d37 100644
--- a/CPSO/Forms/71_Analysis/FrmAnalysis.cs
+++ b/CPSO/Forms/71_Analysis/FrmAnalysis.cs
@@ -1,16 +1,8 @@
-using System;
-using System.Collections.Generic;
-using System.ComponentModel;
-using System.Data;
-using System.Drawing;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using System.Windows.Forms;
+using CaeGlobals;
using CaeJob;
-using System.Reflection;
-using System.IO;
-using CaeGlobals;
+using System;
+using System.Linq;
+using System.Windows.Forms;
namespace CPSO.Forms
{
diff --git a/CPSO/Forms/71_Analysis/FrmMonitor.cs b/CPSO/Forms/71_Analysis/FrmMonitor.cs
index 5805e44..1dcb026 100644
--- a/CPSO/Forms/71_Analysis/FrmMonitor.cs
+++ b/CPSO/Forms/71_Analysis/FrmMonitor.cs
@@ -1,14 +1,9 @@
-using System;
-using System.Collections.Generic;
-using System.ComponentModel;
-using System.Data;
-using System.Drawing;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using System.Windows.Forms;
-using CaeGlobals;
+using CaeGlobals;
using CaeJob;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Windows.Forms;
namespace CPSO.Forms
{
diff --git a/CPSO/Forms/92_Knowledge/FrmAnalysisEx.Designer.cs b/CPSO/Forms/92_Knowledge/FrmAnalysisEx.Designer.cs
index c8f80c3..cd9a9c0 100644
--- a/CPSO/Forms/92_Knowledge/FrmAnalysisEx.Designer.cs
+++ b/CPSO/Forms/92_Knowledge/FrmAnalysisEx.Designer.cs
@@ -28,31 +28,10 @@
///
private void InitializeComponent()
{
- this.dataGridView1 = new System.Windows.Forms.DataGridView();
this.btnRun = new System.Windows.Forms.Button();
this.btnCancel = new System.Windows.Forms.Button();
- this.label1 = new System.Windows.Forms.Label();
- this.numericUpDown1 = new System.Windows.Forms.NumericUpDown();
- this.label2 = new System.Windows.Forms.Label();
- this.numericUpDown2 = new System.Windows.Forms.NumericUpDown();
- ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit();
- ((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).BeginInit();
- ((System.ComponentModel.ISupportInitialize)(this.numericUpDown2)).BeginInit();
this.SuspendLayout();
//
- // dataGridView1
- //
- this.dataGridView1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
- | System.Windows.Forms.AnchorStyles.Left)
- | System.Windows.Forms.AnchorStyles.Right)));
- this.dataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
- this.dataGridView1.Location = new System.Drawing.Point(12, 66);
- this.dataGridView1.Name = "dataGridView1";
- this.dataGridView1.RowHeadersWidth = 51;
- this.dataGridView1.RowTemplate.Height = 27;
- this.dataGridView1.Size = new System.Drawing.Size(776, 301);
- this.dataGridView1.TabIndex = 0;
- //
// btnRun
//
this.btnRun.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
@@ -68,88 +47,31 @@
//
this.btnCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
- this.btnCancel.Location = new System.Drawing.Point(439, 387);
+ this.btnCancel.Location = new System.Drawing.Point(470, 387);
this.btnCancel.Name = "btnCancel";
this.btnCancel.Size = new System.Drawing.Size(144, 37);
this.btnCancel.TabIndex = 2;
this.btnCancel.Text = "取消";
this.btnCancel.UseVisualStyleBackColor = true;
//
- // label1
- //
- this.label1.AutoSize = true;
- this.label1.Location = new System.Drawing.Point(22, 25);
- this.label1.Name = "label1";
- this.label1.Size = new System.Drawing.Size(112, 15);
- this.label1.TabIndex = 4;
- this.label1.Text = "开始任务序号:";
- //
- // numericUpDown1
- //
- this.numericUpDown1.Location = new System.Drawing.Point(140, 23);
- this.numericUpDown1.Maximum = new decimal(new int[] {
- 99999,
- 0,
- 0,
- 0});
- this.numericUpDown1.Name = "numericUpDown1";
- this.numericUpDown1.Size = new System.Drawing.Size(120, 25);
- this.numericUpDown1.TabIndex = 5;
- //
- // label2
- //
- this.label2.AutoSize = true;
- this.label2.Location = new System.Drawing.Point(306, 25);
- this.label2.Name = "label2";
- this.label2.Size = new System.Drawing.Size(82, 15);
- this.label2.TabIndex = 6;
- this.label2.Text = "任务数量:";
- //
- // numericUpDown2
- //
- this.numericUpDown2.Location = new System.Drawing.Point(426, 23);
- this.numericUpDown2.Maximum = new decimal(new int[] {
- 99999,
- 0,
- 0,
- 0});
- this.numericUpDown2.Name = "numericUpDown2";
- this.numericUpDown2.Size = new System.Drawing.Size(120, 25);
- this.numericUpDown2.TabIndex = 7;
- //
// FrmAnalysisEx
//
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.CancelButton = this.btnCancel;
this.ClientSize = new System.Drawing.Size(800, 450);
- this.Controls.Add(this.numericUpDown2);
- this.Controls.Add(this.label2);
- this.Controls.Add(this.numericUpDown1);
- this.Controls.Add(this.label1);
this.Controls.Add(this.btnCancel);
this.Controls.Add(this.btnRun);
- this.Controls.Add(this.dataGridView1);
this.Name = "FrmAnalysisEx";
this.ShowInTaskbar = false;
this.Text = "FrmAnalysisEx";
this.Load += new System.EventHandler(this.FrmAnalysisEx_Load);
- ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit();
- ((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).EndInit();
- ((System.ComponentModel.ISupportInitialize)(this.numericUpDown2)).EndInit();
this.ResumeLayout(false);
- this.PerformLayout();
}
#endregion
-
- private System.Windows.Forms.DataGridView dataGridView1;
private System.Windows.Forms.Button btnRun;
private System.Windows.Forms.Button btnCancel;
- private System.Windows.Forms.Label label1;
- private System.Windows.Forms.NumericUpDown numericUpDown1;
- private System.Windows.Forms.Label label2;
- private System.Windows.Forms.NumericUpDown numericUpDown2;
}
}
\ No newline at end of file
diff --git a/CPSO/Forms/92_Knowledge/FrmAnalysisEx.cs b/CPSO/Forms/92_Knowledge/FrmAnalysisEx.cs
index 2c1f02c..f14fd79 100644
--- a/CPSO/Forms/92_Knowledge/FrmAnalysisEx.cs
+++ b/CPSO/Forms/92_Knowledge/FrmAnalysisEx.cs
@@ -1,12 +1,7 @@
using CaeGlobals;
using CaeJob;
-using CaeKnowledge.View;
-using CaeMesh;
-using CaeModel;
using System;
using System.ComponentModel;
-using System.Linq;
-using System.Threading.Tasks;
using System.Windows.Forms;
// ReSharper disable InlineTemporaryVariable
@@ -23,159 +18,26 @@ namespace CPSO.Forms._92_Knowledge
Self = controller;
- dataGridView1.DataSource = new BindingList();
-
Text = @"切削力仿真";
-
- // 计算任务数
- numericUpDown2.Value = 2;
}
public void PrepareForm()
{
- if (Self.CompletedJobs.Count > 0 && dataGridView1.DataSource is BindingList jobs)
- {
- jobs.Clear();
- foreach (var vj in Self.CompletedJobs)
- {
- jobs.Add(vj);
- }
- }
}
private void FrmAnalysisEx_Load(object sender, EventArgs e)
{
- dataGridView1.AllowUserToAddRows = false;
- dataGridView1.AllowUserToDeleteRows = false;
- dataGridView1.EditMode = DataGridViewEditMode.EditProgrammatically;
-
- dataGridView1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
- dataGridView1.RowHeadersVisible = false;
- dataGridView1.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
}
- private async void btnRun_Click(object sender, EventArgs e)
+ private void btnRun_Click(object sender, EventArgs e)
{
try
{
- if (Self.ProcessingJobs.Count <= 0)
- return;
-
- int BeginIndex = (int)numericUpDown1.Value;
- int EndIndex = BeginIndex + (int)numericUpDown2.Value;
-
- if (BeginIndex >= EndIndex)
- throw new CaeException("开始索引小于结束索引!");
-
- Self.Form.SetStateWorking(@"进行切削力分析...");
-
- if (dataGridView1.DataSource is BindingList jobs)
- {
- for (int i = BeginIndex; i < EndIndex; ++i)
- {
- // 作业基础信息
- var processingJob = Self.ProcessingJobs[i];
-
- var jobName = AddTaskAndRun(processingJob, out var stepName, out var surfaceName);
-
- var job = Self.GetJob(jobName);
-
- if (job != null)
- {
- await Task.Run(() =>
- {
- Self.PrepareAndRunJob(job.Name, false, false);
- });
-
- jobs.Add(new ViewJob(job)
- {
- StepName = stepName,
- SurfaceName = surfaceName,
- });
- }
- }
-
- foreach (var job in jobs)
- {
- Self.CompletedJobs.Add(job);
- }
- }
-
- Self.Form.SetStateReady(@"进行切削力分析...");
}
catch (Exception ex)
{
ExceptionTools.Show(this, ex);
}
}
-
- private string AddTaskAndRun(ViewProcessingJob processingJob, out string stepName, out string surfaceName)
- {
- // 1. 先把所有计算步反激活
- var stepList = Self.GetAllSteps().ToList();
- stepList.ForEach(x =>
- {
- Self.ActivateDeactivateStep(x.Name, false);
- });
-
- // 2. 新建一个计算步并激活
- // 复制一分模板计算步
- var newStep = Self.GetStep(processingJob.StepName).DeepClone();
-
- newStep.Name = NamedClass.GetNameWithoutLastValue(newStep.Name);
- newStep.Name = Self.GetStepNames().GetNextNumberedKey(newStep.Name);
-
- Self.AddStep(newStep, false);
-
- stepName = newStep.Name;
-
- // 激活计算步
- Self.ActivateDeactivateStep(newStep.Name, true);
-
- // 2.1 新建用于施加载荷的曲面Surface
- // 新建Surface
- var surface = new FeSurface(Self.Model.Mesh.Surfaces.GetNextNumberedKey("UserSurface"))
- {
- CreatedFrom = FeSurfaceCreatedFrom.Selection,
- // ToDo: 未来修改
- FaceIds = processingJob.Base.Faces.Select(x => x.Id).ToArray()
- };
-
- surfaceName = surface.Name;
-
- Self.AddSurface(surface);
-
- // 2.2 定义载荷
- bool twoD = Self.Model.Properties.ModelSpace.IsTwoD();
- bool complex = newStep is SteadyStateDynamicsStep;
-
- var loadName = newStep.Loads.GetNextNumberedKey("Load");
-
- double area = surface.Area;
-
- if(area <= 0)
- area = 1.0;
-
- double fx = -1.0 * processingJob.Fx / area;
- double fy = -1.0 * processingJob.Fy / area;
- double fz = -1.0 * processingJob.Fz / area;
-
- var stLoad = new STLoad(loadName, surface.Name, RegionTypeEnum.SurfaceName, fx, fy, fz, twoD, complex, 0);
-
- Self.AddLoad(newStep.Name, stLoad);
-
- // 3. 新建一个Analysis Job
- var name = Self.GetJobNames().GetNextNumberedKey("Analysis");
-
- var executable = Self.Settings.Calculix.CalculixExe; // 可执行文件路径
- var argument = name; // 参数
- var workDirectory = Self.Settings.GetWorkDirectory(); // 工作目录
-
- var job = new AnalysisJob(name, executable, argument, workDirectory);
-
- Self.AddJob(job);
-
- return job.Name;
- }
}
}
diff --git a/CPSO/Forms/92_Knowledge/FrmAnalysisResult.Designer.cs b/CPSO/Forms/92_Knowledge/FrmAnalysisResult.Designer.cs
index 86ee12e..51ad915 100644
--- a/CPSO/Forms/92_Knowledge/FrmAnalysisResult.Designer.cs
+++ b/CPSO/Forms/92_Knowledge/FrmAnalysisResult.Designer.cs
@@ -33,8 +33,6 @@
this.toolStrip1 = new System.Windows.Forms.ToolStrip();
this.toolStripLabel1 = new System.Windows.Forms.ToolStripLabel();
this.toolStripComboBox1 = new System.Windows.Forms.ToolStripComboBox();
- this.toolStripLabel2 = new System.Windows.Forms.ToolStripLabel();
- this.toolStripTextBox1 = new System.Windows.Forms.ToolStripTextBox();
this.toolStripButton1 = new System.Windows.Forms.ToolStripButton();
this.dataGridView1 = new System.Windows.Forms.DataGridView();
this.NodeId = new System.Windows.Forms.DataGridViewTextBoxColumn();
@@ -65,8 +63,6 @@
this.toolStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.toolStripLabel1,
this.toolStripComboBox1,
- this.toolStripLabel2,
- this.toolStripTextBox1,
this.toolStripButton1});
this.toolStrip1.Location = new System.Drawing.Point(0, 0);
this.toolStrip1.Name = "toolStrip1";
@@ -83,21 +79,7 @@
// toolStripComboBox1
//
this.toolStripComboBox1.Name = "toolStripComboBox1";
- this.toolStripComboBox1.Size = new System.Drawing.Size(121, 28);
- this.toolStripComboBox1.SelectedIndexChanged += new System.EventHandler(this.toolStripComboBox1_SelectedIndexChanged);
- //
- // toolStripLabel2
- //
- this.toolStripLabel2.Name = "toolStripLabel2";
- this.toolStripLabel2.Size = new System.Drawing.Size(69, 25);
- this.toolStripLabel2.Text = "曲面集:";
- //
- // toolStripTextBox1
- //
- this.toolStripTextBox1.Font = new System.Drawing.Font("Microsoft YaHei UI", 9F);
- this.toolStripTextBox1.Name = "toolStripTextBox1";
- this.toolStripTextBox1.ReadOnly = true;
- this.toolStripTextBox1.Size = new System.Drawing.Size(100, 28);
+ this.toolStripComboBox1.Size = new System.Drawing.Size(480, 28);
//
// toolStripButton1
//
@@ -219,7 +201,6 @@
private System.Windows.Forms.DataGridView dataGridView1;
private System.Windows.Forms.ToolStripLabel toolStripLabel1;
private System.Windows.Forms.ToolStripComboBox toolStripComboBox1;
- private System.Windows.Forms.ToolStripLabel toolStripLabel2;
private System.Windows.Forms.ToolStripButton toolStripButton1;
private System.Windows.Forms.DataGridViewTextBoxColumn NodeId;
private System.Windows.Forms.DataGridViewTextBoxColumn X;
@@ -230,6 +211,5 @@
private System.Windows.Forms.DataGridViewTextBoxColumn W;
private System.Windows.Forms.DataGridViewTextBoxColumn Starin;
private System.Windows.Forms.DataGridViewTextBoxColumn Stress;
- private System.Windows.Forms.ToolStripTextBox toolStripTextBox1;
}
}
\ No newline at end of file
diff --git a/CPSO/Forms/92_Knowledge/FrmAnalysisResult.cs b/CPSO/Forms/92_Knowledge/FrmAnalysisResult.cs
index 0437264..699595c 100644
--- a/CPSO/Forms/92_Knowledge/FrmAnalysisResult.cs
+++ b/CPSO/Forms/92_Knowledge/FrmAnalysisResult.cs
@@ -1,9 +1,13 @@
using CaeGlobals;
+using CaeKnowledge;
using CaeKnowledge.View;
using CaeMesh;
using CaeResults;
+using System;
using System.Collections.Generic;
using System.ComponentModel;
+using System.IO;
+using System.Linq;
using System.Windows.Forms;
namespace CPSO.Forms._92_Knowledge
@@ -26,25 +30,28 @@ namespace CPSO.Forms._92_Knowledge
public Controller Self { get { return _self; } }
- private Dictionary _data = new Dictionary();
-
public void PrepareForm(Controller self)
{
- _data.Clear();
-
if (self != null)
{
_self = self;
toolStripComboBox1.Items.Clear();
- // 分析结果
- foreach (var job in self.CompletedJobs)
- {
- toolStripComboBox1.Items.Add(job.JobName);
+ toolStripComboBox1.Items.Add("None");
- _data.Add(job.JobName, job.SurfaceName);
+ // 分析结果
+ foreach (string name in Self.AllResults.GetResultNames())
+ {
+ var result = Self.AllResults.GetResult(name);
+
+ if (result != null)
+ {
+ toolStripComboBox1.Items.Add(result.FileName);
+ }
}
+
+ toolStripComboBox1.SelectedIndex = 0;
}
}
@@ -54,92 +61,100 @@ namespace CPSO.Forms._92_Knowledge
{
list.Clear();
- if (toolStripComboBox1.SelectedIndex >= 0)
+ if (toolStripComboBox1.SelectedIndex >= 0
+ && toolStripComboBox1.SelectedItem is string resultName
+ && File.Exists(resultName))
{
- var jobName = toolStripComboBox1.SelectedItem as string;
- var surfaceName = toolStripTextBox1.Text;
-
- LoadJob(list, jobName, surfaceName);
+ var results = LoadResult(resultName);
+
+ results.ForEach(x => list.Add(x));
}
else
{
- MessageBox.Show($"没有选择指定作业Job,将提取全部结果!",
- "消息", MessageBoxButtons.OK, MessageBoxIcon.Information);
-
- foreach (var job in Self.CompletedJobs)
- {
- LoadJob(list, job.JobName, job.SurfaceName);
- }
+ MessageBox.Show($"没有指定已完成的分析结果,无法提取结果!",
+ "消息", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
- private void LoadJob(BindingList list, string jobName, string surfaceName)
+ private List LoadResult(string resultName)
{
- var job = Self.GetJob(jobName);
- var surface = Self.GetSurface(surfaceName);
-
- // 读取结果文件
- if (job != null && job.Active && surface != null && surface.Active)
- {
- var loadJobs = LoadResult(jobName, surfaceName);
-
- loadJobs.ForEach(x => list.Add(x));
- }
- }
-
- private List LoadResult(string jobName, string surfaceName)
- {
- var job = Self.Jobs[jobName];
-
- var resultName = job.ResultsFileName; // 分析结果文件名
-
if (resultName.IsNullOrEmptyOrWhiteSpace())
return null;
var list = new List();
// 1. 分析结果文件
- if(!_self.AllResults.ContainsResult(resultName))
+ if (!_self.AllResults.ContainsResult(resultName))
{
FeResults results = FrdFileReader.Read(resultName);
_self.AllResults.Add(resultName, results);
}
+ // 2. 读取映射文件
+ string filePath = Path.GetDirectoryName(resultName);
+ string fileName = Path.GetFileNameWithoutExtension(resultName);
+ string fullPath = Path.Combine(filePath, $"{fileName}.st2");
- FeResults fr = _self.AllResults.GetResult(resultName);
+ var lines = File.ReadAllLines(fullPath, System.Text.Encoding.UTF8).ToList();
- // 2. 对应的曲面集
- FeSurface surface = Self.GetSurface(surfaceName);
+ Dictionary stepNames = new Dictionary();
+ Dictionary surfaceNames = new Dictionary();
- var nodeSet = Self.GetNodeSet(surface.NodeSetName); // 该曲面集对应的内部节点集合
+ // 3. 解析每一行数据
+ foreach (var line in lines)
+ {
+ if (string.IsNullOrWhiteSpace(line)) continue; // 跳过空行
- int[] labels = nodeSet.Labels; // 对应的节点
+ var parts = line.Split(',');
+
+ // 校验列数是否匹配(防止文件格式错误)
+ if (parts.Length != 3)
+ {
+ continue;
+ }
+
+ int id = int.Parse(parts[0]);
+ stepNames.Add(id, parts[1]);
+ surfaceNames.Add(id, parts[2]);
+ }
// 3. 物理场
- var allFieldData = fr.GetAllFieldData();
+ FeResults fr = _self.AllResults.GetResult(resultName);
- // 3.1 位移场
- Field disp = fr.GetField(allFieldData[0]);
+ var allStepIds = fr.GetAllStepIds();
- var allValues = disp.GetComponentValues("ALL");
- var uValues = disp.GetComponentValues("U1");
- var vValues = disp.GetComponentValues("U2");
- var wValues = disp.GetComponentValues("U3");
-
- foreach (var id in labels)
+ foreach (var stepId in allStepIds)
{
- var node = Self.GetNode(id);
- int index = id - 1;
+ // 3.1 对应的曲面集
+ var stepName = stepNames[stepId];
- list.Add(new ViewFeLog(
- jobName, // 作业名称
- id, node.X, node.Y, node.Z, // 节点Id, x, y, z
- allValues[index], // 位移All, u, v, w
- uValues[index],
- vValues[index],
- wValues[index])
- );
+ var surfaceName = surfaceNames[stepId];
+ FeSurface surface = Self.GetSurface(surfaceName);
+
+ var nodeSet = Self.GetNodeSet(surface.NodeSetName); // 该曲面集对应的内部节点集合
+
+ int[] labels = nodeSet.Labels; // 对应的节点
+
+ // 3.2 提取出的位移值
+ var dispAll = fr.GetField(fr.GetFieldData("DISP", "ALL", stepId, 1)).GetComponentValues("ALL");
+ var dispU = fr.GetField(fr.GetFieldData("DISP", "U1", stepId, 1)).GetComponentValues("U1");
+ var dispV = fr.GetField(fr.GetFieldData("DISP", "U2", stepId, 1)).GetComponentValues("U2");
+ var dispW = fr.GetField(fr.GetFieldData("DISP", "U3", stepId, 1)).GetComponentValues("U3");
+
+ foreach ( var label in labels)
+ {
+ int index = label - 1;
+
+ var node = Self.GetNode(label);
+
+ double all = dispAll[index];
+ double u = dispU[index];
+ double v = dispV[index];
+ double w = dispW[index];
+
+ list.Add(new ViewFeLog(stepId, stepName, node.Id, node.X, node.Y, node.Z, all, u, v, w));
+ }
}
return list;
@@ -149,18 +164,8 @@ namespace CPSO.Forms._92_Knowledge
{
dataGridView1.Columns.Clear();
dataGridView1.DataSource = new BindingList();
- }
- private void toolStripComboBox1_SelectedIndexChanged(object sender, System.EventArgs e)
- {
- if (toolStripComboBox1.SelectedIndex >= 0)
- {
- toolStripTextBox1.Text = _data[toolStripComboBox1.SelectedItem as string];
- }
- else
- {
- toolStripTextBox1.Text = null;
- }
+ toolStripComboBox1.SelectedIndex = -1;
}
}
}
diff --git a/CPSO/Forms/92_Knowledge/FrmAnalysisResultEx.Designer.cs b/CPSO/Forms/92_Knowledge/FrmAnalysisResultEx.Designer.cs
deleted file mode 100644
index d841966..0000000
--- a/CPSO/Forms/92_Knowledge/FrmAnalysisResultEx.Designer.cs
+++ /dev/null
@@ -1,106 +0,0 @@
-namespace CPSO.Forms._92_Knowledge
-{
- partial class FrmAnalysisResultEx
- {
- ///
- /// Required designer variable.
- ///
- private System.ComponentModel.IContainer components = null;
-
- ///
- /// Clean up any resources being used.
- ///
- /// true if managed resources should be disposed; otherwise, false.
- protected override void Dispose(bool disposing)
- {
- if (disposing && (components != null))
- {
- components.Dispose();
- }
- base.Dispose(disposing);
- }
-
- #region Windows Form Designer generated code
-
- ///
- /// Required method for Designer support - do not modify
- /// the contents of this method with the code editor.
- ///
- private void InitializeComponent()
- {
- System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FrmAnalysisResultEx));
- this.toolStrip1 = new System.Windows.Forms.ToolStrip();
- this.statusStrip1 = new System.Windows.Forms.StatusStrip();
- this.toolStripLabel1 = new System.Windows.Forms.ToolStripLabel();
- this.toolStripComboBox1 = new System.Windows.Forms.ToolStripComboBox();
- this.toolStripButton1 = new System.Windows.Forms.ToolStripButton();
- this.toolStrip1.SuspendLayout();
- this.SuspendLayout();
- //
- // toolStrip1
- //
- this.toolStrip1.ImageScalingSize = new System.Drawing.Size(20, 20);
- this.toolStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
- this.toolStripLabel1,
- this.toolStripComboBox1,
- this.toolStripButton1});
- this.toolStrip1.Location = new System.Drawing.Point(0, 0);
- this.toolStrip1.Name = "toolStrip1";
- this.toolStrip1.Size = new System.Drawing.Size(800, 31);
- this.toolStrip1.TabIndex = 0;
- this.toolStrip1.Text = "toolStrip1";
- //
- // statusStrip1
- //
- this.statusStrip1.ImageScalingSize = new System.Drawing.Size(20, 20);
- this.statusStrip1.Location = new System.Drawing.Point(0, 428);
- this.statusStrip1.Name = "statusStrip1";
- this.statusStrip1.Size = new System.Drawing.Size(800, 22);
- this.statusStrip1.TabIndex = 1;
- this.statusStrip1.Text = "statusStrip1";
- //
- // toolStripLabel1
- //
- this.toolStripLabel1.Name = "toolStripLabel1";
- this.toolStripLabel1.Size = new System.Drawing.Size(84, 28);
- this.toolStripLabel1.Text = "分析结果:";
- //
- // toolStripComboBox1
- //
- this.toolStripComboBox1.Name = "toolStripComboBox1";
- this.toolStripComboBox1.Size = new System.Drawing.Size(121, 31);
- //
- // toolStripButton1
- //
- this.toolStripButton1.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text;
- this.toolStripButton1.Image = ((System.Drawing.Image)(resources.GetObject("toolStripButton1.Image")));
- this.toolStripButton1.ImageTransparentColor = System.Drawing.Color.Magenta;
- this.toolStripButton1.Name = "toolStripButton1";
- this.toolStripButton1.Size = new System.Drawing.Size(73, 28);
- this.toolStripButton1.Text = "全部提取";
- //
- // FrmAnalysisResultEx
- //
- this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 15F);
- this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
- this.ClientSize = new System.Drawing.Size(800, 450);
- this.Controls.Add(this.statusStrip1);
- this.Controls.Add(this.toolStrip1);
- this.Name = "FrmAnalysisResultEx";
- this.Text = "批量提取分析结果";
- this.toolStrip1.ResumeLayout(false);
- this.toolStrip1.PerformLayout();
- this.ResumeLayout(false);
- this.PerformLayout();
-
- }
-
- #endregion
-
- private System.Windows.Forms.ToolStrip toolStrip1;
- private System.Windows.Forms.StatusStrip statusStrip1;
- private System.Windows.Forms.ToolStripLabel toolStripLabel1;
- private System.Windows.Forms.ToolStripComboBox toolStripComboBox1;
- private System.Windows.Forms.ToolStripButton toolStripButton1;
- }
-}
\ No newline at end of file
diff --git a/CPSO/Forms/92_Knowledge/FrmAnalysisResultEx.cs b/CPSO/Forms/92_Knowledge/FrmAnalysisResultEx.cs
deleted file mode 100644
index 183d79b..0000000
--- a/CPSO/Forms/92_Knowledge/FrmAnalysisResultEx.cs
+++ /dev/null
@@ -1,20 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.ComponentModel;
-using System.Data;
-using System.Drawing;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using System.Windows.Forms;
-
-namespace CPSO.Forms._92_Knowledge
-{
- public partial class FrmAnalysisResultEx : Form
- {
- public FrmAnalysisResultEx()
- {
- InitializeComponent();
- }
- }
-}
diff --git a/CPSO/Forms/92_Knowledge/FrmAnalysisResultEx.resx b/CPSO/Forms/92_Knowledge/FrmAnalysisResultEx.resx
deleted file mode 100644
index f15dfee..0000000
--- a/CPSO/Forms/92_Knowledge/FrmAnalysisResultEx.resx
+++ /dev/null
@@ -1,142 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- text/microsoft-resx
-
-
- 2.0
-
-
- System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
-
-
- System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
-
-
- 17, 17
-
-
-
-
- iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
- YQUAAAAJcEhZcwAAEnQAABJ0Ad5mH3gAAAIDSURBVDhPpZLrS5NhGMb3j4SWh0oRQVExD4gonkDpg4hG
- YKxG6WBogkMZKgPNCEVJFBGdGETEvgwyO9DJE5syZw3PIlPEE9pgBCLZ5XvdMB8Ew8gXbl54nuf63dd9
- 0OGSnwCahxbPRNPAPMw9Xpg6ZmF46kZZ0xSKzJPIrhpDWsVnpBhGkKx3nAX8Pv7z1zg8OoY/cITdn4fw
- bf/C0kYAN3Ma/w3gWfZL5kzTKBxjWyK2DftwI9tyMYCZKXbNHaD91bLYJrDXsYbrWfUKwJrPE9M2M1Oc
- VzOOpHI7Jr376Hi9ogHqFIANO0/MmmmbmSmm9a8ze+I4MrNWAdjtoJgWcx+PSzg166yZZ8xM8XvXDix9
- c4jIqFYAjoriBV9AhEPv1mH/sonogha0afbZMMZz+yreTGyhpusHwtNNCsA5U1zS4BLxzJIfg299qO32
- Ir7UJtZfftyATqeT+8o2D8JSjQrAJblrncYL7ZJ2+bfaFnC/1S1NjL3diRat7qrO7wLRP3HjWsojBeCo
- mDEo5mNjuweFGvjWg2EBhCbpkW78htSHHwRyNdmgAFzPEee2iFkzayy2OLXzT4gr6UdUnlXrullsxxQ+
- kx0g8BTA3aZlButjSTyjODq/WcQcW/B/Je4OQhLvKQDnzN1mp0nnkvAhR8VuMzNrpm1mpjgkoVwB/v8D
- TgDQASA1MVpwzwAAAABJRU5ErkJggg==
-
-
-
- 151, 17
-
-
\ No newline at end of file
diff --git a/CPSO/Forms/92_Knowledge/FrmEditProcessingJobs.Designer.cs b/CPSO/Forms/92_Knowledge/FrmEditProcessingJobs.Designer.cs
index e50d631..6da4c73 100644
--- a/CPSO/Forms/92_Knowledge/FrmEditProcessingJobs.Designer.cs
+++ b/CPSO/Forms/92_Knowledge/FrmEditProcessingJobs.Designer.cs
@@ -33,7 +33,6 @@
this.btnOK = new System.Windows.Forms.Button();
this.btnCancel = new System.Windows.Forms.Button();
this.btnClearAll = new System.Windows.Forms.Button();
- this.btnReorganize = new System.Windows.Forms.Button();
this.tsmiFile = new System.Windows.Forms.ToolStripMenuItem();
this.tsmiOpen = new System.Windows.Forms.ToolStripMenuItem();
this.tsmiSaveAs = new System.Windows.Forms.ToolStripMenuItem();
@@ -108,17 +107,6 @@
this.btnClearAll.UseVisualStyleBackColor = true;
this.btnClearAll.Click += new System.EventHandler(this.btnClearAll_Click);
//
- // btnReorganize
- //
- this.btnReorganize.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
- this.btnReorganize.Location = new System.Drawing.Point(15, 326);
- this.btnReorganize.Name = "btnReorganize";
- this.btnReorganize.Size = new System.Drawing.Size(75, 23);
- this.btnReorganize.TabIndex = 17;
- this.btnReorganize.Text = "显示/隐藏";
- this.btnReorganize.UseVisualStyleBackColor = true;
- this.btnReorganize.Click += new System.EventHandler(this.btnReorganize_Click);
- //
// tsmiFile
//
this.tsmiFile.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
@@ -127,14 +115,14 @@
this.tsmiDividerFile1,
this.tsmiClose});
this.tsmiFile.Name = "tsmiFile";
- this.tsmiFile.Size = new System.Drawing.Size(48, 24);
+ this.tsmiFile.Size = new System.Drawing.Size(48, 26);
this.tsmiFile.Text = "File";
//
// tsmiOpen
//
this.tsmiOpen.Image = global::CPSO.Properties.Resources.Open;
this.tsmiOpen.Name = "tsmiOpen";
- this.tsmiOpen.Size = new System.Drawing.Size(224, 26);
+ this.tsmiOpen.Size = new System.Drawing.Size(148, 26);
this.tsmiOpen.Text = "Open";
this.tsmiOpen.Click += new System.EventHandler(this.tsmiOpen_Click);
//
@@ -142,19 +130,19 @@
//
this.tsmiSaveAs.Image = global::CPSO.Properties.Resources.Save;
this.tsmiSaveAs.Name = "tsmiSaveAs";
- this.tsmiSaveAs.Size = new System.Drawing.Size(224, 26);
+ this.tsmiSaveAs.Size = new System.Drawing.Size(148, 26);
this.tsmiSaveAs.Text = "Save As";
this.tsmiSaveAs.Click += new System.EventHandler(this.tsmiSaveAs_Click);
//
// tsmiDividerFile1
//
this.tsmiDividerFile1.Name = "tsmiDividerFile1";
- this.tsmiDividerFile1.Size = new System.Drawing.Size(221, 6);
+ this.tsmiDividerFile1.Size = new System.Drawing.Size(145, 6);
//
// tsmiClose
//
this.tsmiClose.Name = "tsmiClose";
- this.tsmiClose.Size = new System.Drawing.Size(224, 26);
+ this.tsmiClose.Size = new System.Drawing.Size(148, 26);
this.tsmiClose.Text = "Close";
this.tsmiClose.Click += new System.EventHandler(this.tsmiClose_Click);
//
@@ -165,7 +153,7 @@
this.tsmiFile});
this.msMain.Location = new System.Drawing.Point(0, 0);
this.msMain.Name = "msMain";
- this.msMain.Size = new System.Drawing.Size(784, 28);
+ this.msMain.Size = new System.Drawing.Size(784, 30);
this.msMain.TabIndex = 15;
this.msMain.Text = "menuStrip1";
//
@@ -174,7 +162,6 @@
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
this.CancelButton = this.btnCancel;
this.ClientSize = new System.Drawing.Size(784, 361);
- this.Controls.Add(this.btnReorganize);
this.Controls.Add(this.btnClearAll);
this.Controls.Add(this.btnOK);
this.Controls.Add(this.btnCancel);
@@ -205,7 +192,6 @@
private System.Windows.Forms.Button btnOK;
private System.Windows.Forms.Button btnCancel;
private System.Windows.Forms.Button btnClearAll;
- private System.Windows.Forms.Button btnReorganize;
private System.Windows.Forms.DataGridView dgvCommands;
private System.Windows.Forms.ToolStripMenuItem tsmiFile;
private System.Windows.Forms.ToolStripMenuItem tsmiOpen;
diff --git a/CPSO/Forms/92_Knowledge/FrmEditProcessingJobs.cs b/CPSO/Forms/92_Knowledge/FrmEditProcessingJobs.cs
index 8b7e7ec..13ea9ea 100644
--- a/CPSO/Forms/92_Knowledge/FrmEditProcessingJobs.cs
+++ b/CPSO/Forms/92_Knowledge/FrmEditProcessingJobs.cs
@@ -11,18 +11,18 @@ namespace CPSO.Forms._92_Knowledge
{
public partial class FrmEditProcessingJobs : Form
{
- // Variables
- private readonly Controller _controller;
+ private Controller Self { get; }
private bool _modified;
// Constructors
- public FrmEditProcessingJobs(Controller controller)
+ public FrmEditProcessingJobs(Controller self)
{
InitializeComponent();
+ Text = @"分析模型查看";
dgvCommands.DataBindingComplete += DataBindingComplete;
- _controller = controller;
+ Self = self;
_modified = false;
}
@@ -41,10 +41,6 @@ namespace CPSO.Forms._92_Knowledge
dgvCommands.Rows[e.RowIndex].DefaultCellStyle.BackColor = green;
}
- private void btnReorganize_Click(object sender, EventArgs e)
- {
- }
-
private void btnClearAll_Click(object sender, EventArgs e)
{
dgvCommands.DataSource = null;
@@ -63,10 +59,10 @@ namespace CPSO.Forms._92_Knowledge
DialogResult = DialogResult.OK;
if (_modified && dgvCommands.DataSource is BindingSource source
- && source.DataSource is List list)
+ && source.DataSource is List list)
{
- _controller.ToolPositions.Clear();
- _controller.ToolPositions.AddRange(list);
+ Self.ProcessingJobs.Clear();
+ Self.ProcessingJobs.AddRange(list);
_modified = false;
}
@@ -85,9 +81,9 @@ namespace CPSO.Forms._92_Knowledge
{
_viewProcessingJobs.Clear();
- if (_controller.ProcessingJobs.Count > 0)
+ if (Self.ProcessingJobs.Count > 0)
{
- _viewProcessingJobs.AddRange(_controller.ProcessingJobs);
+ _viewProcessingJobs.AddRange(Self.ProcessingJobs);
}
SetBinding();
@@ -95,8 +91,11 @@ namespace CPSO.Forms._92_Knowledge
private void SetBinding()
{
- BindingSource binding = new BindingSource();
- binding.DataSource = _viewProcessingJobs;
+ BindingSource binding = new BindingSource()
+ {
+ DataSource = _viewProcessingJobs
+ };
+
dgvCommands.DataSource = binding;
}
@@ -124,12 +123,62 @@ namespace CPSO.Forms._92_Knowledge
private void tsmiOpen_Click(object sender, EventArgs e)
{
+ try
+ {
+ using (OpenFileDialog ofd = new OpenFileDialog())
+ {
+ ofd.Filter = "计算任务列表 (*.wdb)|*.wdb|All Files (*.*)|*.*";
+ ofd.FilterIndex = 1;
+ ofd.RestoreDirectory = true;
+ if (ofd.ShowDialog() == DialogResult.OK)
+ {
+ // 1. 从数据读取
+ var list = KnowledgeTools.LoadDatabase(ofd.FileName);
+
+ // 2. 保存到Controller
+ Self.ProcessingJobs.Clear();
+ list.ForEach(x =>
+ {
+ Self.ProcessingJobs.Add(new ViewProcessingJob(x));
+ });
+
+ // 3. 现实到dgv
+ PrepareForm();
+ }
+ }
+ }
+ catch (Exception ex)
+ {
+ ExceptionTools.Show(ex);
+ }
}
private void tsmiSaveAs_Click(object sender, EventArgs e)
{
+ try
+ {
+ using (SaveFileDialog sfd = new SaveFileDialog())
+ {
+ sfd.Filter = "计算任务列表 (*.wdb)|*.wdb|All Files (*.*)|*.*";
+ sfd.FilterIndex = 1;
+ sfd.RestoreDirectory = true;
+ if (sfd.ShowDialog() == DialogResult.OK)
+ {
+ var fullPath = sfd.FileName;
+
+ var jobs = Self.ProcessingJobs.Select(x => x.Base).ToList();
+
+ // 保存到数据库
+ KnowledgeTools.SaveDatabase(fullPath, jobs);
+ }
+ }
+ }
+ catch (Exception ex)
+ {
+ ExceptionTools.Show(ex);
+ }
}
}
}
diff --git a/CPSO/Forms/92_Knowledge/FrmEditToolPositions.cs b/CPSO/Forms/92_Knowledge/FrmEditToolPositions.cs
index dbfc46e..9f357d6 100644
--- a/CPSO/Forms/92_Knowledge/FrmEditToolPositions.cs
+++ b/CPSO/Forms/92_Knowledge/FrmEditToolPositions.cs
@@ -4,10 +4,8 @@ using CaeKnowledge.View;
using System;
using System.Collections.Generic;
using System.Drawing;
-using System.IO;
-using System.Windows.Forms;
using System.Linq;
-using CaeKnowledge.Data;
+using System.Windows.Forms;
namespace CPSO.Forms._92_Knowledge
{
@@ -22,6 +20,8 @@ namespace CPSO.Forms._92_Knowledge
{
InitializeComponent();
+ Text = @"切削力查看";
+
// dgvCommands.EnableDragAndDropRows();
dgvCommands.DataBindingComplete += DataBindingComplete;
_controller = controller;
diff --git a/CPSO/Forms/92_Knowledge/FrmStepsManager.cs b/CPSO/Forms/92_Knowledge/FrmStepsManager.cs
index 57f014c..c5a0291 100644
--- a/CPSO/Forms/92_Knowledge/FrmStepsManager.cs
+++ b/CPSO/Forms/92_Knowledge/FrmStepsManager.cs
@@ -3,12 +3,12 @@ using CaeKnowledge;
using CaeKnowledge.Data;
using CaeKnowledge.View;
using CaeMesh;
+using CaeModel;
using Plankton;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
-using CaeModel;
// ReSharper disable SuggestVarOrType_SimpleTypes
// ReSharper disable SuggestVarOrType_BuiltInTypes
@@ -25,90 +25,149 @@ namespace CPSO.Forms._92_Knowledge
{
InitializeComponent();
Self = self;
+
+ Text = @"分析模型定义";
+ gbProperties.Text = @"定义";
}
public void PrepareForm()
{
- if (propertyGrid.SelectedObject is ViewSteps steps)
+ if (propertyGrid.SelectedObject is ViewJobs jobs)
{
- steps.PopulateDropDownList();
+
}
}
private void FrmAddLoad_Load(object sender, EventArgs e)
{
- var view = new ViewSteps(Self);
+ var jobs = new ViewJobs(Self);
- view.ToolPositionList.Clear();
+ // 初始化下拉菜单
+ jobs.PopulateDropDownList();
+
+ // 初始化刀位文件列表
+ jobs.ToolPositionList.Clear();
if (Self?.ToolPositions != null)
{
- view.ToolPositionList.AddRange(Self.ToolPositions);
+ jobs.ToolPositionList.AddRange(Self.ToolPositions);
}
- propertyGrid.SelectedObject = view;
+ propertyGrid.SelectedObject = jobs;
}
- private readonly Dictionary _nodeToVertexMapping = new Dictionary();
- private readonly Dictionary _vertexToNodeMapping = new Dictionary();
-
- private readonly Dictionary _cellToFaceMapping = new Dictionary();
-
protected override async void OnApply(bool onOkAddNew)
{
try
{
- if (!(propertyGrid.SelectedObject is ViewSteps steps)) return;
+ if (!(propertyGrid.SelectedObject is ViewJobs viewSteps)) return;
- _nodeToVertexMapping.Clear();
- _vertexToNodeMapping.Clear();
- _cellToFaceMapping.Clear();
+ // 基础计算步
+ Step baseStep = Self.GetStep(viewSteps.Step);
+ // Todo: 检查基础计算步
- Step step = Self.GetStep(steps.Step);
- if (step == null)
- throw new CaeException($"无法找到对应的计算步:{steps.Step}");
+ if (baseStep == null)
+ throw new CaeException($"无法找到对应的计算步:{viewSteps.Step}");
- if (!Self.Model.Mesh.Surfaces.TryGetValue(steps.Surface, out var surface))
- throw new CaeException($"无法找到对应的曲面集:{steps.Surface}");
+ if (!Self.Model.Mesh.Surfaces.TryGetValue(viewSteps.Surface, out var surface))
+ throw new CaeException($"无法找到对应的曲面集:{viewSteps.Surface}");
Self.Form.SetStateWorking(@"构建切削力分析模型...");
+ // 先把所有计算步反激活
+ var stepList = Self.GetAllSteps().ToList();
+ stepList.ForEach(x =>
+ {
+ Self.ActivateDeactivateStep(x.Name, false);
+ });
+
List jobs = new List();
await Task.Run(() =>
{
+ // 加载网格
var mesh = LoadMesh(surface);
- Self.ToolPositions.ForEach(tp =>
+ foreach (var tp in Self.ToolPositions)
{
- int vertId = GetClosedVertex(mesh, tp.Base);
+ // 1. 计算最接近的顶点
+ int vertId = GetClosedVertex(mesh, tp.Base); // PlanktonMesh中存储的Id
- if (vertId >= 0)
+ if (vertId < 0)
{
- // 1.最接近节点
- int nodeId = _vertexToNodeMapping[vertId];
- FeNode node = Self.Model.Mesh.Nodes[nodeId];
-
- // 2.最近节点周围的面单元
- List faces = new List();
- foreach (var f in mesh.Vertices.GetVertexFaces(vertId))
- {
- if(_cellToFaceMapping.TryGetValue(f, out var face))
- faces.Add(face);
- }
-
- jobs.Add(new ProcessingJob(step.Name, tp.Base, node, faces.ToArray())
- {
- NewStepName = steps.NewStep
- });
+ continue;
}
- });
- Self.ProcessingJobs.Clear();
- jobs.ForEach(job =>
- {
- Self.ProcessingJobs.Add(new ViewProcessingJob(job));
- });
+ // 2. 最接近节点
+ int nodeId = _vertexToNodeMapping[vertId]; // 全局网格中的Id
+ FeNode node = Self.Model.Mesh.Nodes[nodeId];
+
+ // 3. 最近节点周围的面单元
+ List faces = new List();
+ foreach (var f in mesh.Vertices.GetVertexFaces(vertId))
+ {
+ if (_cellToFaceMapping.TryGetValue(f, out var face))
+ faces.Add(face);
+ }
+
+ // 4. 复制一份基础计算步并激活
+ var newStep = Self.GetStep(baseStep.Name).DeepClone();
+
+ var stepName = viewSteps.NewStepName;
+ newStep.Name = Self.GetStepNames().GetNextNumberedKey(NamedClass.GetNameWithoutLastValue(stepName));
+
+ Self.AddStep(newStep, false, false);
+
+ // 激活计算步
+ Self.ActivateDeactivateStep(newStep.Name, true);
+
+ // 5. 添加载荷
+ // 5.1 新建用于施加载荷的曲面Surface
+ // 新建User Surface
+ var userSurface = new FeSurface(Self.Model.Mesh.Surfaces.GetNextNumberedKey("UserSurface"))
+ {
+ CreatedFrom = FeSurfaceCreatedFrom.Selection,
+ FaceIds = faces.Select(x => x.Id).ToArray(),
+ // ToDo: 未来修改
+ Internal = false,
+ };
+
+ Self.AddSurface(userSurface);
+
+ // 5.2 定义载荷
+ bool twoD = Self.Model.Properties.ModelSpace.IsTwoD();
+ bool complex = newStep is SteadyStateDynamicsStep;
+
+ var loadName = newStep.Loads.GetNextNumberedKey("Load");
+
+ double area = userSurface.Area;
+
+ if (area <= 0)
+ area = 1.0;
+
+ double fx = -1.0 * tp.MaxFx / area;
+ double fy = -1.0 * tp.MaxFx / area;
+ double fz = -1.0 * tp.MaxFz / area;
+
+ var stLoad = new STLoad(loadName, userSurface.Name, RegionTypeEnum.SurfaceName, fx, fy, fz, twoD, complex, 0);
+
+ // 5.3 添加载荷
+ Self.AddLoad(newStep.Name, stLoad);
+
+ // 5.4 添加到 List jobs
+ jobs.Add(new ProcessingJob(tp.Base)
+ {
+ StepName = newStep.Name,
+ SurfaceName = userSurface.Name,
+ });
+ }
+
+ });
+
+ Self.ProcessingJobs.Clear();
+ jobs.ForEach(x =>
+ {
+ Self.ProcessingJobs.Add(new ViewProcessingJob(x));
});
Self.Form.SetStateReady(@"构建切削力分析模型...");
@@ -152,13 +211,17 @@ namespace CPSO.Forms._92_Knowledge
return closedVertexIndex;
}
+ private readonly Dictionary _nodeToVertexMapping = new Dictionary();
+ private readonly Dictionary _vertexToNodeMapping = new Dictionary();
+ private readonly Dictionary _cellToFaceMapping = new Dictionary();
+
private PlanktonMesh LoadMesh(FeSurface surface)
{
// 计算面列表
var faceList = (from faceId in surface.FaceIds
- let element = Self.Model.Mesh.Elements[faceId / 10]
- let faceName = (FeFaceName)(faceId % 10 + 1)
- select new FeFace(element, faceName)).ToList();
+ let element = Self.Model.Mesh.Elements[faceId / 10]
+ let faceName = (FeFaceName)(faceId % 10 + 1)
+ select new FeFace(element, faceName)).ToList();
// 节点列表
var hashSet = new HashSet();
diff --git a/CPSO/Forms/92_Knowledge/ViewJob.cs b/CPSO/Forms/92_Knowledge/ViewJob.cs
deleted file mode 100644
index 4680cec..0000000
--- a/CPSO/Forms/92_Knowledge/ViewJob.cs
+++ /dev/null
@@ -1,51 +0,0 @@
-using CaeJob;
-using System.Collections.Generic;
-using System.ComponentModel;
-using System.Runtime.CompilerServices;
-
-namespace CPSO.Forms._92_Knowledge
-{
- public class ViewJob: INotifyPropertyChanged
- {
- private AnalysisJob Job { get; }
-
- public void UpdateProgress()
- {
- OnPropertyChanged(nameof(Status));
- }
-
- public ViewJob(AnalysisJob job)
- {
- Job = job;
- }
-
- [DisplayName("Job名称")]
- public string JobName => Job.Name;
-
- private string _stepName;
- [DisplayName("Step名称")]
- public string StepName { get => _stepName; set => SetField(ref _stepName, value); }
-
- private string _surfaceName;
- [DisplayName("Surface名称")]
- public string SurfaceName { get => _surfaceName; set => SetField(ref _surfaceName, value); }
-
- [DisplayName("状态")]
- public JobStatus Status => Job.JobStatus;
-
- public event PropertyChangedEventHandler PropertyChanged;
-
- protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
- {
- PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
- }
-
- protected bool SetField(ref T field, T value, [CallerMemberName] string propertyName = null)
- {
- if (EqualityComparer.Default.Equals(field, value)) return false;
- field = value;
- OnPropertyChanged(propertyName);
- return true;
- }
- }
-}
\ No newline at end of file
diff --git a/CPSO/Forms/92_Knowledge/ViewSteps.cs b/CPSO/Forms/92_Knowledge/ViewSteps.cs
deleted file mode 100644
index 77ede71..0000000
--- a/CPSO/Forms/92_Knowledge/ViewSteps.cs
+++ /dev/null
@@ -1,71 +0,0 @@
-using CaeGlobals;
-using CaeKnowledge.View;
-using DynamicTypeDescriptor;
-using System.Collections.Generic;
-using System.ComponentModel;
-using System.Drawing.Design;
-using System.Linq;
-
-namespace CPSO.Forms._92_Knowledge
-{
- public class ViewSteps
- {
- private readonly DynamicCustomTypeDescriptor _dctd;
-
- private readonly Controller _controller;
-
- [Category("1数据")]
- [OrderedDisplayName(0, 3, "计算步Step")]
- [Description("选择要继承的计算步")]
- public string Step { get; set; }
-
- [Category("1数据")]
- [OrderedDisplayName(1, 3, "曲面集")]
- [Description("选择要载荷所在的曲面集")]
- public string Surface { get; set; }
-
- [Category("1数据")]
- [OrderedDisplayName(2, 3, "切削力")]
- [Editor(typeof(MyCollectionEditor), typeof(UITypeEditor))]
- public List ToolPositionList { get; set; } = new List();
-
- [Category("2分析")]
- [DisplayName("新计算步名称")]
- public string NewStep { get; set; } = "new_step";
-
- public ViewSteps(Controller self)
- {
- _controller = self;
-
- _dctd = ProviderInstaller.Install(this);
-
- PopulateDropDownList();
- }
-
- public void PopulateDropDownList()
- {
- // ReSharper disable once JoinDeclarationAndInitializer
- CustomPropertyDescriptor cpd;
-
- // Steps
- cpd = _dctd.GetProperty(nameof(Step));
- cpd.StatandardValues.Clear();
-
- _controller.Model.StepCollection.StepsList.ForEach(x =>
- {
- cpd.StatandardValues.Add(new StandardValueAttribute(x.Name));
- });
-
- // Surface
- cpd = _dctd.GetProperty(nameof(Surface));
- cpd.StatandardValues.Clear();
-
- foreach (var surfaceName in _controller.Model.Mesh.Surfaces.Values
- .Where(x => !x.Internal)
- .Select(x => x.Name))
- {
- cpd.StatandardValues.Add(new StandardValueAttribute(surfaceName));
- }
- }
- }
-}
\ No newline at end of file
diff --git a/CPSO/Forms/FrmMain.Designer.cs b/CPSO/Forms/FrmMain.Designer.cs
index 5dc57b9..957020c 100644
--- a/CPSO/Forms/FrmMain.Designer.cs
+++ b/CPSO/Forms/FrmMain.Designer.cs
@@ -594,7 +594,6 @@ namespace CPSO
this.splitContainer2.SuspendLayout();
this.toolStripContainer2.BottomToolStripPanel.SuspendLayout();
this.toolStripContainer2.ContentPanel.SuspendLayout();
- this.toolStripContainer2.TopToolStripPanel.SuspendLayout();
this.toolStripContainer2.SuspendLayout();
this.toolStripContainer3.SuspendLayout();
this.toolStripContainer4.ContentPanel.SuspendLayout();
@@ -954,9 +953,9 @@ namespace CPSO
this.tsSymbols.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.tslSymbols,
this.tscbSymbols});
- this.tsSymbols.Location = new System.Drawing.Point(4, 0);
+ this.tsSymbols.Location = new System.Drawing.Point(768, 0);
this.tsSymbols.Name = "tsSymbols";
- this.tsSymbols.Size = new System.Drawing.Size(197, 28);
+ this.tsSymbols.Size = new System.Drawing.Size(236, 28);
this.tsSymbols.TabIndex = 9;
//
// tslSymbols
@@ -995,9 +994,9 @@ namespace CPSO
this.tscbComplex,
this.tslAngle,
this.tstbAngle});
- this.tsResultDeformation.Location = new System.Drawing.Point(4, 0);
+ this.tsResultDeformation.Location = new System.Drawing.Point(556, 0);
this.tsResultDeformation.Name = "tsResultDeformation";
- this.tsResultDeformation.Size = new System.Drawing.Size(921, 28);
+ this.tsResultDeformation.Size = new System.Drawing.Size(876, 29);
this.tsResultDeformation.TabIndex = 8;
//
// tslResultName
@@ -1086,14 +1085,14 @@ namespace CPSO
// tslAngle
//
this.tslAngle.Name = "tslAngle";
- this.tslAngle.Size = new System.Drawing.Size(52, 25);
+ this.tslAngle.Size = new System.Drawing.Size(52, 20);
this.tslAngle.Text = "Angle";
//
// tstbAngle
//
this.tstbAngle.Font = new System.Drawing.Font("Segoe UI", 9F);
this.tstbAngle.Name = "tstbAngle";
- this.tstbAngle.Size = new System.Drawing.Size(45, 28);
+ this.tstbAngle.Size = new System.Drawing.Size(45, 27);
this.tstbAngle.Text = "0 °";
this.tstbAngle.TextBoxTextAlign = System.Windows.Forms.HorizontalAlignment.Right;
this.tstbAngle.UnitConverter = null;
@@ -1122,7 +1121,7 @@ namespace CPSO
this.tsbLastStepIncrement,
this.tsbAnimate,
this.toolStripSeparator2});
- this.tsResults.Location = new System.Drawing.Point(4, 28);
+ this.tsResults.Location = new System.Drawing.Point(4, 0);
this.tsResults.Name = "tsResults";
this.tsResults.Size = new System.Drawing.Size(552, 28);
this.tsResults.TabIndex = 7;
@@ -4808,7 +4807,7 @@ namespace CPSO
this.panelControl.Dock = System.Windows.Forms.DockStyle.Fill;
this.panelControl.Location = new System.Drawing.Point(0, 0);
this.panelControl.Name = "panelControl";
- this.panelControl.Size = new System.Drawing.Size(1159, 693);
+ this.panelControl.Size = new System.Drawing.Size(1159, 747);
this.panelControl.TabIndex = 1;
//
// aeAnnotationTextEditor
@@ -4946,13 +4945,13 @@ namespace CPSO
// toolStripContainer1.ContentPanel
//
this.toolStripContainer1.ContentPanel.Controls.Add(this.splitContainer1);
- this.toolStripContainer1.ContentPanel.Size = new System.Drawing.Size(1432, 846);
+ this.toolStripContainer1.ContentPanel.Size = new System.Drawing.Size(1432, 900);
this.toolStripContainer1.Dock = System.Windows.Forms.DockStyle.Fill;
this.toolStripContainer1.LeftToolStripPanelVisible = false;
this.toolStripContainer1.Location = new System.Drawing.Point(0, 0);
this.toolStripContainer1.Name = "toolStripContainer1";
this.toolStripContainer1.RightToolStripPanelVisible = false;
- this.toolStripContainer1.Size = new System.Drawing.Size(1432, 871);
+ this.toolStripContainer1.Size = new System.Drawing.Size(1432, 925);
this.toolStripContainer1.TabIndex = 4;
this.toolStripContainer1.Text = "toolStripContainer";
//
@@ -4968,7 +4967,7 @@ namespace CPSO
//
this.splitContainer1.Panel2.Controls.Add(this.splitContainer2);
this.splitContainer1.Panel2MinSize = 250;
- this.splitContainer1.Size = new System.Drawing.Size(1432, 846);
+ this.splitContainer1.Size = new System.Drawing.Size(1432, 900);
this.splitContainer1.SplitterDistance = 269;
this.splitContainer1.TabIndex = 2;
//
@@ -4987,8 +4986,8 @@ namespace CPSO
// splitContainer2.Panel2
//
this.splitContainer2.Panel2.Controls.Add(this.tbOutput);
- this.splitContainer2.Size = new System.Drawing.Size(1159, 846);
- this.splitContainer2.SplitterDistance = 693;
+ this.splitContainer2.Size = new System.Drawing.Size(1159, 900);
+ this.splitContainer2.SplitterDistance = 747;
this.splitContainer2.TabIndex = 2;
//
// tbOutput
@@ -5026,29 +5025,24 @@ namespace CPSO
//
this.toolStripContainer2.ContentPanel.AutoScroll = true;
this.toolStripContainer2.ContentPanel.Controls.Add(this.toolStripContainer1);
- this.toolStripContainer2.ContentPanel.Size = new System.Drawing.Size(1432, 871);
+ this.toolStripContainer2.ContentPanel.Size = new System.Drawing.Size(1432, 925);
this.toolStripContainer2.Dock = System.Windows.Forms.DockStyle.Fill;
this.toolStripContainer2.Location = new System.Drawing.Point(0, 0);
this.toolStripContainer2.Name = "toolStripContainer2";
- this.toolStripContainer2.Size = new System.Drawing.Size(1432, 955);
+ this.toolStripContainer2.Size = new System.Drawing.Size(1432, 953);
this.toolStripContainer2.TabIndex = 5;
this.toolStripContainer2.Text = "toolStripContainer2";
//
- // toolStripContainer2.TopToolStripPanel
- //
- this.toolStripContainer2.TopToolStripPanel.Controls.Add(this.tsSymbols);
- this.toolStripContainer2.TopToolStripPanel.Controls.Add(this.tsResults);
- //
// toolStripContainer3
//
//
// toolStripContainer3.ContentPanel
//
- this.toolStripContainer3.ContentPanel.Size = new System.Drawing.Size(1432, 983);
+ this.toolStripContainer3.ContentPanel.Size = new System.Drawing.Size(1432, 982);
this.toolStripContainer3.Dock = System.Windows.Forms.DockStyle.Fill;
this.toolStripContainer3.Location = new System.Drawing.Point(0, 0);
this.toolStripContainer3.Name = "toolStripContainer3";
- this.toolStripContainer3.Size = new System.Drawing.Size(1432, 1008);
+ this.toolStripContainer3.Size = new System.Drawing.Size(1432, 1007);
this.toolStripContainer3.TabIndex = 6;
this.toolStripContainer3.Text = "toolStripContainer3";
//
@@ -5059,17 +5053,18 @@ namespace CPSO
//
this.toolStripContainer4.ContentPanel.AutoScroll = true;
this.toolStripContainer4.ContentPanel.Controls.Add(this.toolStripContainer2);
- this.toolStripContainer4.ContentPanel.Size = new System.Drawing.Size(1432, 955);
+ this.toolStripContainer4.ContentPanel.Size = new System.Drawing.Size(1432, 953);
this.toolStripContainer4.Dock = System.Windows.Forms.DockStyle.Fill;
this.toolStripContainer4.Location = new System.Drawing.Point(0, 0);
this.toolStripContainer4.Name = "toolStripContainer4";
- this.toolStripContainer4.Size = new System.Drawing.Size(1432, 983);
+ this.toolStripContainer4.Size = new System.Drawing.Size(1432, 982);
this.toolStripContainer4.TabIndex = 7;
this.toolStripContainer4.Text = "toolStripContainer4";
//
// toolStripContainer4.TopToolStripPanel
//
this.toolStripContainer4.TopToolStripPanel.Controls.Add(this.tsResultDeformation);
+ this.toolStripContainer4.TopToolStripPanel.Controls.Add(this.tsResults);
//
// toolStripContainer5
//
@@ -5078,11 +5073,11 @@ namespace CPSO
//
this.toolStripContainer5.ContentPanel.AutoScroll = true;
this.toolStripContainer5.ContentPanel.Controls.Add(this.toolStripContainer4);
- this.toolStripContainer5.ContentPanel.Size = new System.Drawing.Size(1432, 983);
+ this.toolStripContainer5.ContentPanel.Size = new System.Drawing.Size(1432, 982);
this.toolStripContainer5.Dock = System.Windows.Forms.DockStyle.Fill;
this.toolStripContainer5.Location = new System.Drawing.Point(0, 0);
this.toolStripContainer5.Name = "toolStripContainer5";
- this.toolStripContainer5.Size = new System.Drawing.Size(1432, 1008);
+ this.toolStripContainer5.Size = new System.Drawing.Size(1432, 1007);
this.toolStripContainer5.TabIndex = 8;
this.toolStripContainer5.Text = "toolStripContainer5";
//
@@ -5094,7 +5089,7 @@ namespace CPSO
this.toolStripContainer6.ContentPanel.AutoScroll = true;
this.toolStripContainer6.ContentPanel.Controls.Add(this.toolStripContainer5);
this.toolStripContainer6.ContentPanel.Controls.Add(this.toolStripContainer3);
- this.toolStripContainer6.ContentPanel.Size = new System.Drawing.Size(1432, 1008);
+ this.toolStripContainer6.ContentPanel.Size = new System.Drawing.Size(1432, 1007);
this.toolStripContainer6.Dock = System.Windows.Forms.DockStyle.Fill;
this.toolStripContainer6.Location = new System.Drawing.Point(0, 0);
this.toolStripContainer6.Name = "toolStripContainer6";
@@ -5104,6 +5099,7 @@ namespace CPSO
//
// toolStripContainer6.TopToolStripPanel
//
+ this.toolStripContainer6.TopToolStripPanel.Controls.Add(this.tsSymbols);
this.toolStripContainer6.TopToolStripPanel.Controls.Add(this.tsFile);
this.toolStripContainer6.TopToolStripPanel.Controls.Add(this.tsViews);
//
@@ -5172,8 +5168,6 @@ namespace CPSO
this.splitContainer2.ResumeLayout(false);
this.toolStripContainer2.BottomToolStripPanel.ResumeLayout(false);
this.toolStripContainer2.ContentPanel.ResumeLayout(false);
- this.toolStripContainer2.TopToolStripPanel.ResumeLayout(false);
- this.toolStripContainer2.TopToolStripPanel.PerformLayout();
this.toolStripContainer2.ResumeLayout(false);
this.toolStripContainer2.PerformLayout();
this.toolStripContainer3.ResumeLayout(false);
diff --git a/CPSO/Forms/FrmMain.cs b/CPSO/Forms/FrmMain.cs
index 562baaa..14bc4bc 100644
--- a/CPSO/Forms/FrmMain.cs
+++ b/CPSO/Forms/FrmMain.cs
@@ -593,30 +593,9 @@ namespace CPSO
tsmiProcessingSim.DropDownItems.Add(tsmiAnalysisViewer);
- // Add by Luke at 2025-11-22
- tsmiAnalysisEx = new ToolStripMenuItem(@"切削力仿真");
-
- tsmiAnalysisEx.Click += (sender, argc) =>
- {
- try
- {
- if (!_frmAnalysisEx.Visible)
- {
- _frmAnalysisEx.PrepareForm();
- _frmAnalysisEx.ShowDialog();
- }
- }
- catch (Exception ex)
- {
- ExceptionTools.Show(this, ex);
- }
- };
-
- tsmiProcessingSim.DropDownItems.Add(tsmiAnalysisEx);
-
// Add by Luke
tsmiAnalysisChecker = new ToolStripMenuItem(@"分析结果提取");
-
+
tsmiAnalysisChecker.Click += (sender, argc) =>
{
try
@@ -630,7 +609,7 @@ namespace CPSO
}
};
- tsmiProcessingResult.DropDownItems.Add(tsmiAnalysisChecker);
+ tsmiProcessingSim.DropDownItems.Add(tsmiAnalysisChecker);
tsmiTest.Text = @"测试";
tsmiTest.Click += TsmiTest_Click;
@@ -646,9 +625,9 @@ namespace CPSO
tsmiDividerTools2.Visible = false;
// 优化工具栏显示
- tsResultDeformation.Visible = false;
- tsResults.Visible = false;
- tsSymbols.Visible = false;
+ tsResultDeformation.Visible = true;
+ tsResults.Visible = true;
+ tsSymbols.Visible = true;
}
// By Luke 2025-11-22
@@ -1028,7 +1007,7 @@ namespace CPSO
AddFormToAllForms(_frmEditProcessingJobs);
_frmAnalysisResult = new FrmAnalysisResult();
- AddFormToAllForms( _frmAnalysisResult);
+ AddFormToAllForms(_frmAnalysisResult);
// Deformation toolstrip
InitializeDeformationComboBoxes();
@@ -7939,28 +7918,73 @@ namespace CPSO
{
RunAnalysis(jobName, true);
}
+
+ // 修改by Luke 2026-3-26
private void RunAnalysis(string jobName, bool onlyCheckModel)
{
// Check validity
if (CheckValidity())
{
+ // 检查工作目录是否存在
string workDirectory = _controller.Settings.GetWorkDirectory();
- //
if (workDirectory == null || !Directory.Exists(workDirectory))
+ {
throw new Exception("The work directory of the analysis does not exist.");
- //
+ }
+
+ // 获取分析任务
AnalysisJob job = _controller.GetJob(jobName);
if (job.JobStatus != JobStatus.Running)
{
string inputFileName = _controller.GetCalculiXInpFileName(jobName);
+
if (File.Exists(inputFileName))
{
- if (MessageBoxes.ShowWarningQuestionOKCancel("Overwrite existing analysis files?") != DialogResult.OK) return;
+ if (MessageBoxes.ShowWarningQuestionOKCancel("Overwrite existing analysis files?") != DialogResult.OK)
+ {
+ return;
+ }
+ }
+
+ // Add by Luke
+ // 将全部活跃Step按照序号保存
+ if (_controller.ProcessingJobs.Count > 0)
+ {
+ var dataLines = new List { };
+
+ int id = 1;
+ _controller.ProcessingJobs.ForEach(x =>
+ {
+ var step = _controller.GetStep(x.StepName);
+
+ var surface = _controller.GetSurface(x.SurfaceName);
+
+ if (step != null && step.Active && surface != null)
+ {
+ var line = $"{id},{step.Name},{surface.Name}";
+ dataLines.Add(line);
+
+ id++;
+ }
+ });
+
+ // 3. 写入文件(UTF-8编码,避免中文/特殊字符乱码
+ string filePath = Path.Combine(job.WorkDirectory, $"{job.Name}.st2");
+ File.WriteAllLines(filePath, dataLines, System.Text.Encoding.UTF8);
+ }
+ // Add by Luke
+
+ // 执行命令
+ if (_controller.PrepareAndRunJobCommand(jobName, onlyCheckModel))
+ {
+ // 打开监控界面
+ MonitorAnalysis(jobName);
}
- //
- if (_controller.PrepareAndRunJobCommand(jobName, onlyCheckModel)) MonitorAnalysis(jobName);
}
- else MessageBoxes.ShowError("The analysis is already running or is in queue.");
+ else
+ {
+ MessageBoxes.ShowError("The analysis is already running or is in queue.");
+ }
}
}
private void MonitorAnalysis(string jobName)
diff --git a/CPSO/Forms/frmMain.resx b/CPSO/Forms/frmMain.resx
index 9305b4a..26bc45b 100644
--- a/CPSO/Forms/frmMain.resx
+++ b/CPSO/Forms/frmMain.resx
@@ -291,9 +291,6 @@
1088, 17
-
- 684, 63
-
110
diff --git a/CPSO/bin/x64/Debug/CPSO.exe b/CPSO/bin/x64/Debug/CPSO.exe
index 7f1120c..fd83004 100644
Binary files a/CPSO/bin/x64/Debug/CPSO.exe and b/CPSO/bin/x64/Debug/CPSO.exe differ
diff --git a/CPSO/bin/x64/Debug/CPSO.pdb b/CPSO/bin/x64/Debug/CPSO.pdb
index e24ccfc..ab27812 100644
Binary files a/CPSO/bin/x64/Debug/CPSO.pdb and b/CPSO/bin/x64/Debug/CPSO.pdb differ
diff --git a/CPSO/bin/x64/Debug/CaeKnowledge.dll b/CPSO/bin/x64/Debug/CaeKnowledge.dll
index 8e7af7f..7125cda 100644
Binary files a/CPSO/bin/x64/Debug/CaeKnowledge.dll and b/CPSO/bin/x64/Debug/CaeKnowledge.dll differ
diff --git a/CPSO/bin/x64/Debug/CaeKnowledge.pdb b/CPSO/bin/x64/Debug/CaeKnowledge.pdb
index 1f177a6..e655629 100644
Binary files a/CPSO/bin/x64/Debug/CaeKnowledge.pdb and b/CPSO/bin/x64/Debug/CaeKnowledge.pdb differ
diff --git a/CPSO/bin/x64/Debug/settings.bin b/CPSO/bin/x64/Debug/settings.bin
index c8dca81..9d885c8 100644
Binary files a/CPSO/bin/x64/Debug/settings.bin and b/CPSO/bin/x64/Debug/settings.bin differ
diff --git a/CPSO/obj/x64/Debug/CPSO.Forms._92_Knowledge.FrmAnalysisResultEx.resources b/CPSO/obj/x64/Debug/CPSO.Forms._92_Knowledge.FrmAnalysisResultEx.resources
deleted file mode 100644
index 6e8dd05..0000000
Binary files a/CPSO/obj/x64/Debug/CPSO.Forms._92_Knowledge.FrmAnalysisResultEx.resources and /dev/null differ
diff --git a/CPSO/obj/x64/Debug/CPSO.csproj.AssemblyReference.cache b/CPSO/obj/x64/Debug/CPSO.csproj.AssemblyReference.cache
index cb26626..5cd1ae4 100644
Binary files a/CPSO/obj/x64/Debug/CPSO.csproj.AssemblyReference.cache and b/CPSO/obj/x64/Debug/CPSO.csproj.AssemblyReference.cache differ
diff --git a/CPSO/obj/x64/Debug/CPSO.csproj.CoreCompileInputs.cache b/CPSO/obj/x64/Debug/CPSO.csproj.CoreCompileInputs.cache
index 5869ce0..dfb6996 100644
--- a/CPSO/obj/x64/Debug/CPSO.csproj.CoreCompileInputs.cache
+++ b/CPSO/obj/x64/Debug/CPSO.csproj.CoreCompileInputs.cache
@@ -1 +1 @@
-19003a4e0e82520802967bdb6aadcca3703f27ee4e8b187ae42cd3a6db8beae2
+3bc573ccf27fb67219e68c2c21aa1b1e3c6d6acc2d2935f1eb7cc6af24b8c2a6
diff --git a/CPSO/obj/x64/Debug/CPSO.csproj.FileListAbsolute.txt b/CPSO/obj/x64/Debug/CPSO.csproj.FileListAbsolute.txt
index ac497d0..3df3a23 100644
--- a/CPSO/obj/x64/Debug/CPSO.csproj.FileListAbsolute.txt
+++ b/CPSO/obj/x64/Debug/CPSO.csproj.FileListAbsolute.txt
@@ -508,10 +508,8 @@ D:\wg_cpso\CPSO\obj\x64\Debug\CPSO.Forms.FrmRBFMorphNodeEditor.resources
D:\wg_cpso\CPSO\obj\x64\Debug\CPSO.Forms._92_Knowledge.FrmAddCutter.resources
D:\wg_cpso\CPSO\obj\x64\Debug\CPSO.Forms._92_Knowledge.FrmAnalysisEx.resources
D:\wg_cpso\CPSO\obj\x64\Debug\CPSO.Forms._92_Knowledge.FrmAnalysisResult.resources
-D:\wg_cpso\CPSO\obj\x64\Debug\CPSO.Forms._92_Knowledge.FrmAnalysisResultEx.resources
D:\wg_cpso\CPSO\obj\x64\Debug\CPSO.Forms._92_Knowledge.FrmEditProcessingJobs.resources
D:\wg_cpso\CPSO\obj\x64\Debug\CPSO.Forms._92_Knowledge.FrmEditToolPositions.resources
-D:\wg_cpso\CPSO\obj\x64\Debug\CPSO.Forms._92_Knowledge.FrmStepsManager.resources
D:\wg_cpso\CPSO\obj\x64\Debug\CPSO.Forms.FrmCutter.resources
D:\wg_cpso\CPSO\obj\x64\Debug\CPSO.Forms._92_Knowledge.FrmCuttingForceCalc.resources
D:\wg_cpso\CPSO\obj\x64\Debug\CPSO.Forms._92_Knowledge.FrmProcessingParameter.resources
@@ -528,3 +526,4 @@ D:\wg_cpso\CPSO\obj\x64\Debug\CPSO.exe
D:\wg_cpso\CPSO\obj\x64\Debug\CPSO.pdb
D:\wg_cpso\CPSO\bin\x64\Debug\ToolPathParser.dll
D:\wg_cpso\CPSO\bin\x64\Debug\ToolPathParser.pdb
+D:\wg_cpso\CPSO\obj\x64\Debug\CPSO.Forms._92_Knowledge.FrmStepsManager.resources
diff --git a/CPSO/obj/x64/Debug/CPSO.csproj.GenerateResource.cache b/CPSO/obj/x64/Debug/CPSO.csproj.GenerateResource.cache
index 7bd9427..e5e0e41 100644
Binary files a/CPSO/obj/x64/Debug/CPSO.csproj.GenerateResource.cache and b/CPSO/obj/x64/Debug/CPSO.csproj.GenerateResource.cache differ
diff --git a/CPSO/obj/x64/Debug/CPSO.exe b/CPSO/obj/x64/Debug/CPSO.exe
index 7f1120c..fd83004 100644
Binary files a/CPSO/obj/x64/Debug/CPSO.exe and b/CPSO/obj/x64/Debug/CPSO.exe differ
diff --git a/CPSO/obj/x64/Debug/CPSO.pdb b/CPSO/obj/x64/Debug/CPSO.pdb
index e24ccfc..ab27812 100644
Binary files a/CPSO/obj/x64/Debug/CPSO.pdb and b/CPSO/obj/x64/Debug/CPSO.pdb differ
diff --git a/CPSO/obj/x64/Debug/DesignTimeResolveAssemblyReferences.cache b/CPSO/obj/x64/Debug/DesignTimeResolveAssemblyReferences.cache
index e21ce80..07959dc 100644
Binary files a/CPSO/obj/x64/Debug/DesignTimeResolveAssemblyReferences.cache and b/CPSO/obj/x64/Debug/DesignTimeResolveAssemblyReferences.cache differ
diff --git a/CPSO/obj/x64/Debug/DesignTimeResolveAssemblyReferencesInput.cache b/CPSO/obj/x64/Debug/DesignTimeResolveAssemblyReferencesInput.cache
index e2c16b7..d204eff 100644
Binary files a/CPSO/obj/x64/Debug/DesignTimeResolveAssemblyReferencesInput.cache and b/CPSO/obj/x64/Debug/DesignTimeResolveAssemblyReferencesInput.cache differ
diff --git a/CaeCuttingForce/bin/Debug/CaeKnowledge.dll b/CaeCuttingForce/bin/Debug/CaeKnowledge.dll
index 8e7af7f..7125cda 100644
Binary files a/CaeCuttingForce/bin/Debug/CaeKnowledge.dll and b/CaeCuttingForce/bin/Debug/CaeKnowledge.dll differ
diff --git a/CaeCuttingForce/bin/Debug/CaeKnowledge.pdb b/CaeCuttingForce/bin/Debug/CaeKnowledge.pdb
index 1f177a6..e655629 100644
Binary files a/CaeCuttingForce/bin/Debug/CaeKnowledge.pdb and b/CaeCuttingForce/bin/Debug/CaeKnowledge.pdb differ
diff --git a/CaeCuttingForce/obj/Debug/CaeCuttingForce.csproj.AssemblyReference.cache b/CaeCuttingForce/obj/Debug/CaeCuttingForce.csproj.AssemblyReference.cache
index 7def662..b066225 100644
Binary files a/CaeCuttingForce/obj/Debug/CaeCuttingForce.csproj.AssemblyReference.cache and b/CaeCuttingForce/obj/Debug/CaeCuttingForce.csproj.AssemblyReference.cache differ
diff --git a/CaeKnowledge/Data/ProcessingJob.cs b/CaeKnowledge/Data/ProcessingJob.cs
index c5e6a1c..367cfbc 100644
--- a/CaeKnowledge/Data/ProcessingJob.cs
+++ b/CaeKnowledge/Data/ProcessingJob.cs
@@ -1,55 +1,38 @@
-using CaeMesh;
-// ReSharper disable SuggestVarOrType_BuiltInTypes
-// ReSharper disable ConvertToAutoProperty
+using LiteDB;
namespace CaeKnowledge.Data
{
public class ProcessingJob
{
- private readonly ToolPosition _toolPosition;
- private readonly FeNode _feNode;
+ public ObjectId Id { get; set; }
- // 要继承的计算步
- public string StepName { get; }
+ // 计算步名称
+ public string StepName { get; set; }
- public string NewStepName { get; set; }
+ // StepId
+ public int StepId {get; set; }
+
+ // 曲面集名称
+ public string SurfaceName {get; set; }
// 刀位点位置坐标
- public double X => _toolPosition.X;
- public double Y => _toolPosition.Y;
- public double Z => _toolPosition.Z;
+ public double X {get; set;}
+ public double Y {get; set;}
+ public double Z {get; set;}
// 切削力
- public double Fx => _toolPosition.MaxFx;
- public double Fy => _toolPosition.MaxFy;
- public double Fz => _toolPosition.MaxFz;
+ public double Fx {get; set;}
+ public double Fy {get; set;}
+ public double Fz {get; set;}
- // 最接近的节点
- public FeNode Node => _feNode;
+ public ProcessingJob()
+ { }
- public FeFace[] Faces { get; }
-
- // 刀位点到网格最近节点的距离
- public double MinimumDistance { get; } = 0;
-
- public ProcessingJob(string stepName, ToolPosition tp, FeNode node, FeFace[] faces)
+ public ProcessingJob(ToolPosition tp)
{
- _toolPosition = tp;
- _feNode = node;
+ X = tp.X; Y = tp.Y; Z = tp.Z;
- StepName = stepName;
-
- double x1 = _toolPosition.X;
- double y1 = _toolPosition.Y;
- double z1 = _toolPosition.Z;
-
- double x2 = node.X;
- double y2 = node.Y;
- double z2 = node.Z;
-
- Faces = faces;
-
- MinimumDistance = MeshTools.Distance(x1, y1, z1, x2, y2, z2);
+ Fx = tp.MaxFx; Fy = tp.MaxFy; Fz = tp.MaxFz;
}
}
}
\ No newline at end of file
diff --git a/CaeKnowledge/KnowledgeTools.cs b/CaeKnowledge/KnowledgeTools.cs
index 21320a9..0eb8377 100644
--- a/CaeKnowledge/KnowledgeTools.cs
+++ b/CaeKnowledge/KnowledgeTools.cs
@@ -317,5 +317,43 @@ namespace CaeKnowledge
}
public static Type ObjectIdType => typeof(ObjectId);
+
+ // Luke 2026-3-25
+ public static void SaveDatabase(string fullPath, List jobs)
+ {
+ try
+ {
+ using (var db = new LiteDatabase(fullPath))
+ {
+ var col = db.GetCollection("jobs");
+ col.DeleteAll();
+ col.InsertBulk(jobs);
+ }
+ }
+ catch (Exception ex)
+ {
+ ExceptionTools.Show(ex);
+ }
+ }
+
+ public static List LoadDatabase(string fullPath)
+ {
+ try
+ {
+ using (var db = new LiteDatabase(fullPath))
+ {
+ var col = db.GetCollection("jobs");
+ // Fetch all documents in the collection and return as a list
+ return col.FindAll().ToList();
+ }
+ }
+ catch (Exception ex)
+ {
+ // Handle exceptions (e.g., log or display an error)
+ // Console.Error.WriteLine($"Error loading data from LiteDB: {ex.Message}");
+ // Return an empty list on error
+ return new List();
+ }
+ }
}
}
\ No newline at end of file
diff --git a/CaeKnowledge/View/ViewFeLog.cs b/CaeKnowledge/View/ViewFeLog.cs
index e8a96a2..bef5356 100644
--- a/CaeKnowledge/View/ViewFeLog.cs
+++ b/CaeKnowledge/View/ViewFeLog.cs
@@ -7,11 +7,13 @@ namespace CaeKnowledge.View
public class ViewFeLog : INotifyPropertyChanged
{
public ViewFeLog(
- string jobName,
+ int stepId,
+ string stepName,
int id, double x, double y, double z,
double all= 0.0, double u = 0.0, double v = 0.0, double w = 0.0)
{
- _jobName = jobName;
+ _stepId = stepId;
+ _stepName = stepName;
_id = id;
_x = x;
_y = y;
@@ -22,14 +24,26 @@ namespace CaeKnowledge.View
_w = w;
}
- private string _jobName;
- [DisplayName("Job名称")]
- public string JobName
+ private int _stepId;
+ [DisplayName("Step ID")]
+ public int StepId
{
- get => _jobName;
+ get => _stepId;
set
{
- _jobName = value;
+ _stepId =value;
+ OnPropertyChanged();
+ }
+ }
+
+ private string _stepName;
+ [DisplayName("Step名称")]
+ public string StepName
+ {
+ get => _stepName;
+ set
+ {
+ _stepName = value;
OnPropertyChanged();
}
}
diff --git a/CaeKnowledge/View/ViewProcessingJob.cs b/CaeKnowledge/View/ViewProcessingJob.cs
index f5220bd..35139aa 100644
--- a/CaeKnowledge/View/ViewProcessingJob.cs
+++ b/CaeKnowledge/View/ViewProcessingJob.cs
@@ -16,11 +16,11 @@ namespace CaeKnowledge.View
_base = @base;
}
- [DisplayName("基准Step名称")]
+ [DisplayName("Step名称")]
public string StepName => _base.StepName;
- [DisplayName("新Step名称")]
- public string NewStepName => _base.NewStepName;
+ [DisplayName("Surface名称")]
+ public string SurfaceName => _base.SurfaceName;
public double X => _base.X;
@@ -34,12 +34,6 @@ namespace CaeKnowledge.View
public double Fz => _base.Fz;
- [DisplayName("最近节点Id")]
- public int NodeId=> _base.Node.Id;
-
- [DisplayName("最近距离")]
- public double MinimumDistance => _base.MinimumDistance;
-
[Browsable(false)]
public ProcessingJob Base => _base;
diff --git a/CaeKnowledge/bin/Debug/CaeKnowledge.dll b/CaeKnowledge/bin/Debug/CaeKnowledge.dll
index 8e7af7f..7125cda 100644
Binary files a/CaeKnowledge/bin/Debug/CaeKnowledge.dll and b/CaeKnowledge/bin/Debug/CaeKnowledge.dll differ
diff --git a/CaeKnowledge/bin/Debug/CaeKnowledge.pdb b/CaeKnowledge/bin/Debug/CaeKnowledge.pdb
index 1f177a6..e655629 100644
Binary files a/CaeKnowledge/bin/Debug/CaeKnowledge.pdb and b/CaeKnowledge/bin/Debug/CaeKnowledge.pdb differ
diff --git a/CaeKnowledge/obj/Debug/CaeKnowledge.csproj.AssemblyReference.cache b/CaeKnowledge/obj/Debug/CaeKnowledge.csproj.AssemblyReference.cache
index 58d7c45..adece65 100644
Binary files a/CaeKnowledge/obj/Debug/CaeKnowledge.csproj.AssemblyReference.cache and b/CaeKnowledge/obj/Debug/CaeKnowledge.csproj.AssemblyReference.cache differ
diff --git a/CaeKnowledge/obj/Debug/CaeKnowledge.dll b/CaeKnowledge/obj/Debug/CaeKnowledge.dll
index 8e7af7f..7125cda 100644
Binary files a/CaeKnowledge/obj/Debug/CaeKnowledge.dll and b/CaeKnowledge/obj/Debug/CaeKnowledge.dll differ
diff --git a/CaeKnowledge/obj/Debug/CaeKnowledge.pdb b/CaeKnowledge/obj/Debug/CaeKnowledge.pdb
index 1f177a6..e655629 100644
Binary files a/CaeKnowledge/obj/Debug/CaeKnowledge.pdb and b/CaeKnowledge/obj/Debug/CaeKnowledge.pdb differ
diff --git a/ConsoleAppCuttingForce/bin/Debug/CaeKnowledge.dll b/ConsoleAppCuttingForce/bin/Debug/CaeKnowledge.dll
index 8e7af7f..e387a23 100644
Binary files a/ConsoleAppCuttingForce/bin/Debug/CaeKnowledge.dll and b/ConsoleAppCuttingForce/bin/Debug/CaeKnowledge.dll differ
diff --git a/ConsoleAppCuttingForce/bin/Debug/CaeKnowledge.pdb b/ConsoleAppCuttingForce/bin/Debug/CaeKnowledge.pdb
index 1f177a6..49b8e45 100644
Binary files a/ConsoleAppCuttingForce/bin/Debug/CaeKnowledge.pdb and b/ConsoleAppCuttingForce/bin/Debug/CaeKnowledge.pdb differ
diff --git a/ConsoleAppCuttingForce/obj/Debug/ConsoleAppCuttingForce.csproj.AssemblyReference.cache b/ConsoleAppCuttingForce/obj/Debug/ConsoleAppCuttingForce.csproj.AssemblyReference.cache
index d7690a6..41e7cd8 100644
Binary files a/ConsoleAppCuttingForce/obj/Debug/ConsoleAppCuttingForce.csproj.AssemblyReference.cache and b/ConsoleAppCuttingForce/obj/Debug/ConsoleAppCuttingForce.csproj.AssemblyReference.cache differ
diff --git a/DynamicDescriptors/obj/Debug/net40/DynamicDescriptors.assets.cache b/DynamicDescriptors/obj/Debug/net40/DynamicDescriptors.assets.cache
index fe546e6..0b8d6ee 100644
Binary files a/DynamicDescriptors/obj/Debug/net40/DynamicDescriptors.assets.cache and b/DynamicDescriptors/obj/Debug/net40/DynamicDescriptors.assets.cache differ
diff --git a/ToolPathParser/bin/Debug/CaeKnowledge.dll b/ToolPathParser/bin/Debug/CaeKnowledge.dll
index 8e7af7f..7125cda 100644
Binary files a/ToolPathParser/bin/Debug/CaeKnowledge.dll and b/ToolPathParser/bin/Debug/CaeKnowledge.dll differ
diff --git a/ToolPathParser/bin/Debug/CaeKnowledge.pdb b/ToolPathParser/bin/Debug/CaeKnowledge.pdb
index 1f177a6..e655629 100644
Binary files a/ToolPathParser/bin/Debug/CaeKnowledge.pdb and b/ToolPathParser/bin/Debug/CaeKnowledge.pdb differ
diff --git a/ToolPathParser/obj/Debug/ToolPathParser.csproj.AssemblyReference.cache b/ToolPathParser/obj/Debug/ToolPathParser.csproj.AssemblyReference.cache
index 6a92c0d..2b41661 100644
Binary files a/ToolPathParser/obj/Debug/ToolPathParser.csproj.AssemblyReference.cache and b/ToolPathParser/obj/Debug/ToolPathParser.csproj.AssemblyReference.cache differ