update ISO coordinate rendering for 3+2axis machine.

This commit is contained in:
2026-04-06 15:08:59 +08:00
parent 8dd5309e0e
commit 0fe9497552
219 changed files with 23941 additions and 12629 deletions
@@ -121,42 +121,40 @@ using System.Collections.Generic;
using Hi.Geom;
using Hi.Mech.Topo;
namespace Sample.Geom
namespace Sample.Geom;
/// <summary>
/// Demonstrates the creation and manipulation of geometric objects in HiAPI.
/// Shows how to create and transform various geometry types including boxes, cylindroids, and STL files.
/// </summary>
/// <remarks>
/// ### Source Code
/// [!code-csharp[SampleCode](~/../Hi.Sample/Geom/DemoBuildGeom.cs)]
/// </remarks>
public static class DemoBuildGeom
{
/// <summary>
/// Demonstrates the creation and manipulation of geometric objects in HiAPI.
/// Shows how to create and transform various geometry types including boxes, cylindroids, and STL files.
/// Generates a collection of geometric objects for demonstration purposes.
/// Creates various geometry types including boxes, cylindroids, STL files, and transformed geometries.
/// </summary>
/// <remarks>
/// ### Source Code
/// [!code-csharp[SampleCode](~/../Hi.Sample/Geom/DemoBuildGeom.cs)]
/// </remarks>
public static class DemoBuildGeom
/// <returns>A list of geometries implementing the IGetStl interface</returns>
public static List<IGetStl> GenGeoms()
{
/// <summary>
/// Generates a collection of geometric objects for demonstration purposes.
/// Creates various geometry types including boxes, cylindroids, STL files, and transformed geometries.
/// </summary>
/// <returns>A list of geometries implementing the IGetStl interface</returns>
public static List<IGetStl> GenGeoms()
{
Box3d box = new Box3d(0, 0, -50, 70, 50, 0);
Cylindroid cylindroid = new Cylindroid([ new PairZr(0,12),new PairZr(20,12),
Box3d box = new Box3d(0, 0, -50, 70, 50, 0);
Cylindroid cylindroid = new Cylindroid([ new PairZr(0,12),new PairZr(20,12),
new PairZr(20,16),new PairZr(30,16)]);
Stl stl = new Stl("geom.stl");
StlFile stlFile = new StlFile("geom.stl");
TransformationGeom transformationGeom = new TransformationGeom()
{
Transformer = new GeneralTransform(1,
new StaticRotation(new Vec3d(0, 0, 1), MathUtil.ToRad(15), new Vec3d(0, 0, 0)),
new StaticTranslation(new Vec3d(0, 0, 0))),
Geom = stl
};
GeomCombination geomCombination = new GeomCombination(stlFile, transformationGeom);
return new List<IGetStl>([box, cylindroid, stl, stlFile, transformationGeom]);
}
Stl stl = new Stl("geom.stl");
StlFile stlFile = new StlFile("geom.stl");
TransformationGeom transformationGeom = new TransformationGeom()
{
Transformer = new GeneralTransform(1,
new StaticRotation(new Vec3d(0, 0, 1), MathUtil.ToRad(15), new Vec3d(0, 0, 0)),
new StaticTranslation(new Vec3d(0, 0, 0))),
Geom = stl
};
GeomCombination geomCombination = new GeomCombination(stlFile, transformationGeom);
return new List<IGetStl>([box, cylindroid, stl, stlFile, transformationGeom]);
}
}
</code></pre>
</article>
@@ -89,13 +89,13 @@
<p>This document describes the common patterns and conventions used throughout the HiNC GUI codebase.</p>
<h2 id="message-and-exception-handling">Message and Exception Handling</h2>
<p>The HiNC applications use <a class="xref" href="../../api/Hi.Common.Messages.MessageHost.html">MessageHost</a> to display user-facing messages, and <a class="xref" href="../../api/Hi.Common.ExceptionUtil.html">ExceptionUtil</a>.<a class="xref" href="../../api/Hi.Common.ExceptionUtil.html#Hi_Common_ExceptionUtil_ShowException_System_Exception_System_Object_">ShowException(Exception, object)</a> to handle exceptions with detailed treatment. All messages are displayed in the <a href="message-section-on-main-panel.html">Message Section on Main Panel</a>.</p>
<p>The HiNC applications use &lt;xref:Hi.Common.Messages.MessageHost&gt; to display user-facing messages, and <a class="xref" href="../../api/Hi.Common.ExceptionUtil.html">ExceptionUtil</a>.<a class="xref" href="../../api/Hi.Common.ExceptionUtil.html#Hi_Common_ExceptionUtil_ShowException_System_Exception_System_Object_">ShowException(Exception, object)</a> to handle exceptions with detailed treatment. All messages are displayed in the <a href="message-section-on-main-panel.html">Message Section on Main Panel</a>.</p>
<p>For examples of message and exception handling patterns:</p>
<ol>
<li>Normal message handling:</li>
</ol>
<pre><code class="lang-csharp" name="Normal Messages">MessageHost.ReportMessage(&quot;Operation completed successfully.&quot;);
MessageHost.ReportWarning(&quot;Please check your input.&quot;);
<pre><code class="lang-csharp" name="Normal Messages">MessageUtil.ReportMessage(&quot;Operation completed successfully.&quot;);
MessageUtil.ReportWarning(&quot;Please check your input.&quot;);
</code></pre>
<ol start="2">
<li>Exception handling in synchronous code:</li>
@@ -183,10 +183,10 @@ Users can refresh the log content or download the current day's log file for off
</tr>
</tbody>
</table>
<p>All operation results (success or exception) are displayed via <a class="xref" href="../../api/Hi.Common.Messages.MessageHost.html">MessageHost</a>. When a project is loaded, the Player Panel's RenderingCanvas is set to isometric view using <a class="xref" href="../../api/Hi.Disp.DispEngine.html#Hi_Disp_DispEngine_SetViewToIsometricView">SetViewToIsometricView()</a>.</p>
<p>All operation results (success or exception) are displayed via &lt;xref:Hi.Common.Messages.MessageHost&gt;. When a project is loaded, the Player Panel's RenderingCanvas is set to isometric view using <a class="xref" href="../../api/Hi.Disp.DispEngine.html#Hi_Disp_DispEngine_SetViewToIsometricView">SetViewToIsometricView()</a>.</p>
<div class="NOTE">
<h5>Note</h5>
<p>The implementation uses static functions of <a class="xref" href="../../api/Hi.Common.Messages.MessageHost.html">MessageHost</a> for message handling. Async operations ensure smooth user experience during file I/O.</p>
<p>The implementation uses static functions of &lt;xref:Hi.Common.Messages.MessageHost&gt; for message handling. Async operations ensure smooth user experience during file I/O.</p>
</div>
<h2 id="platform-specific-differences">Platform-Specific Differences</h2>
<h3 id="wpf-application">WPF Application</h3>
@@ -89,7 +89,7 @@
<p>The Message Section displays application messages and logs at the bottom of the Main Panel.</p>
<h2 id="message-handling">Message Handling</h2>
<p>The Message Section is connected to <a class="xref" href="../../api/Hi.Common.Messages.MessageHost.html">MessageHost</a>.<a class="xref" href="../../api/Hi.Common.Messages.MessageHost.html#Hi_Common_Messages_MessageHost_Default">Default</a> through the <code>ProgressChanged</code> event. When a message is reported:</p>
<p>The Message Section is connected to &lt;xref:Hi.Common.Messages.MessageHost&gt;.&lt;xref:Hi.Common.Messages.MessageHost.Default&gt; through the <code>ProgressChanged</code> event. When a message is reported:</p>
<ol>
<li>The <code>Brief Message Text Field</code> content is updated</li>
<li>The message is appended to the daily log file at <code>logs/log-{DateTime.Now:yyyy-MM-dd}.txt</code></li>
@@ -87,7 +87,7 @@
<article data-uid="">
<h1 id="session-message-panel">Session Message Panel</h1>
<p>The model is <a class="xref" href="../../../api/Hi.MachiningProcs.LocalProjectService.html#Hi_MachiningProcs_LocalProjectService_SessionMessageHost">SessionMessageHost</a>.</p>
<p>The model is &lt;xref:Hi.MachiningProcs.LocalProjectService.SessionMessageHost&gt;.</p>
<p><a class="xref" href="../../../api/Hi.MachiningProcs.LocalProjectService.html">LocalProjectService</a> is obtained via dependency injection.</p>
<h2 id="layout">Layout</h2>
<ul>
@@ -112,16 +112,16 @@
<li>Central Message Table</li>
</ul>
<h2 id="central-message-table">Central Message Table</h2>
<p>The model of Central Message Table is <a class="xref" href="../../../api/Hi.MachiningProcs.SessionMessageHost.html">SessionMessageHost</a>.<a class="xref" href="../../../api/Hi.MachiningProcs.SessionMessageHost.html#Hi_MachiningProcs_SessionMessageHost_MessageCollection">MessageCollection</a>.</p>
<p>Only take last 1000 filtered elements in the <a class="xref" href="../../../api/Hi.MachiningProcs.SessionMessageHost.html#Hi_MachiningProcs_SessionMessageHost_MessageCollection">MessageCollection</a> by <a class="xref" href="../../../api/Hi.MachiningProcs.SessionMessageHost.html#Hi_MachiningProcs_SessionMessageHost_GetFliteredList_Hi_MachiningProcs_SessionMessageHost_FilterFlag_System_String_">GetFliteredList(FilterFlag, string)</a> to show for user experience. Find the usage example in the code:</p>
<p>The model of Central Message Table is &lt;xref:Hi.MachiningProcs.SessionMessageHost&gt;.&lt;xref:Hi.MachiningProcs.SessionMessageHost.MessageCollection&gt;.</p>
<p>Only take last 1000 filtered elements in the &lt;xref:Hi.MachiningProcs.SessionMessageHost.MessageCollection&gt; by &lt;xref:Hi.MachiningProcs.SessionMessageHost.GetFliteredList(Hi.MachiningProcs.SessionMessageHost.FilterFlag,System.String)&gt; to show for user experience. Find the usage example in the code:</p>
<pre><code class="lang-csharp" name="Demo_UseSessionMessageHost">internal static void DemoUseSessionMessageHost(LocalProjectService localProjectService)
{
SessionMessageHost sessionMessageHost = localProjectService.SessionMessageHost;
SessionProgress sessionMessageHost = localProjectService.SessionProgress;
SessionMessageHost.FilterFlag filterFlags =
SessionMessageHost.FilterFlag.NC |
SessionMessageHost.FilterFlag.Progress |
SessionMessageHost.FilterFlag.Error;
SessionProgress.FilterFlag filterFlags =
SessionProgress.FilterFlag.NC |
SessionProgress.FilterFlag.Progress |
SessionProgress.FilterFlag.Error;
string filterText = null;
var filteredSessionMessageList = sessionMessageHost
.GetFliteredList(filterFlags, filterText);
@@ -150,7 +150,7 @@
}
</code></pre>
<p>In the table, show the columns: <code>Role</code>, <code>NC/Message</code>.</p>
<p>Add update table event to <a class="xref" href="../../../api/Hi.MachiningProcs.SessionMessageHost.html#Hi_MachiningProcs_SessionMessageHost_CollectionItemChanged">CollectionItemChanged</a>. The updating process has to be called by <a href="../general-rules.html">Loose Manner</a> for user experience.</p>
<p>Add update table event to &lt;xref:Hi.MachiningProcs.SessionMessageHost.CollectionItemChanged&gt;. The updating process has to be called by <a href="../general-rules.html">Loose Manner</a> for user experience.</p>
<div class="TIP">
<h5>Tip</h5>
<p>On window desktop application (WPF), consider use textarea instead of datagrid to MessageTable for better performance. Use padding to show the different columns. And use the font in the textarea that with consistent width.</p>
@@ -160,9 +160,9 @@
<p>The message display should be real-time.</p>
</div>
<h2 id="behavior-of-export-button">Behavior of Export Button</h2>
<p>Export ALL filtered elements in the <a class="xref" href="../../../api/Hi.MachiningProcs.SessionMessageHost.html#Hi_MachiningProcs_SessionMessageHost_MessageCollection">MessageCollection</a> by <a class="xref" href="../../../api/Hi.MachiningProcs.SessionMessageHost.html#Hi_MachiningProcs_SessionMessageHost_GetFliteredList_Hi_MachiningProcs_SessionMessageHost_FilterFlag_System_String_">GetFliteredList(FilterFlag, string)</a>.</p>
<p>Export ALL filtered elements in the &lt;xref:Hi.MachiningProcs.SessionMessageHost.MessageCollection&gt; by &lt;xref:Hi.MachiningProcs.SessionMessageHost.GetFliteredList(Hi.MachiningProcs.SessionMessageHost.FilterFlag,System.String)&gt;.</p>
<h2 id="signalr-implementation-webapi-only">SignalR Implementation (Webapi Only)</h2>
<p><code>SessionMessageHub</code> provides real-time message updates with method <code>GetSessionMessages(string filterFlags, string filterText, int limit)</code> and event <code>SessionMessagesUpdated</code>. <code>SessionMessageService</code> monitors <a class="xref" href="../../../api/Hi.MachiningProcs.SessionMessageHost.html#Hi_MachiningProcs_SessionMessageHost_CollectionItemChanged">CollectionItemChanged</a> and broadcasts updates. The service uses <a class="xref" href="../../../api/Hi.Common.LooseRunner.html">LooseRunner</a> for non-blocking async operations. The JavaScript component connects to <code>/sessionMessageHub</code> to receive real-time message updates.</p>
<p><code>SessionMessageHub</code> provides real-time message updates with method <code>GetSessionMessages(string filterFlags, string filterText, int limit)</code> and event <code>SessionMessagesUpdated</code>. <code>SessionMessageService</code> monitors &lt;xref:Hi.MachiningProcs.SessionMessageHost.CollectionItemChanged&gt; and broadcasts updates. The service uses <a class="xref" href="../../../api/Hi.Common.LooseRunner.html">LooseRunner</a> for non-blocking async operations. The JavaScript component connects to <code>/sessionMessageHub</code> to receive real-time message updates.</p>
<h2 id="source-code-path">Source Code Path</h2>
<p>See <a href="../index.html">this page</a> for git repository.</p>
<h3 id="wpf-application-source-code-path">WPF Application Source Code Path</h3>
@@ -307,7 +307,7 @@ namespace HiNC_2025_win_desktop.Geom
}
catch (Exception ex)
{
MessageHost.ReportError(string.Format(Application.Current.FindResource(&quot;Vec3d_Update_Error&quot;).ToString(), ex.Message));
MessageUtil.ReportError(string.Format(Application.Current.FindResource(&quot;Vec3d_Update_Error&quot;).ToString(), ex.Message));
ex.ShowException(this);
}
finally
@@ -398,7 +398,7 @@ namespace HiNC_2025_win_desktop.Geom
}
catch (Exception ex)
{
MessageHost.ReportError(string.Format(Application.Current.FindResource(&quot;Vec3d_Update_Error&quot;).ToString(), ex.Message));
MessageUtil.ReportError(string.Format(Application.Current.FindResource(&quot;Vec3d_Update_Error&quot;).ToString(), ex.Message));
ex.ShowException(this);
}
finally
@@ -555,7 +555,7 @@ namespace HiNC_2025_win_desktop.Geom
catch (Exception ex)
{
// 记录异常但不中断用户操作
MessageHost.ReportError(string.Format(Application.Current.FindResource(&quot;Vec3d_Update_Error&quot;).ToString(), ex.Message));
MessageUtil.ReportError(string.Format(Application.Current.FindResource(&quot;Vec3d_Update_Error&quot;).ToString(), ex.Message));
ex.ShowException(this);
}
finally
@@ -143,7 +143,7 @@
</ul>
<p>The <a class="xref" href="../../api/Hi.MachiningProcs.LocalProjectService.html#Hi_MachiningProcs_LocalProjectService_PacePlayer">PacePlayer</a> controls the execution pace of the simulation, allowing you to observe the machining process in detail or run it at full speed.</p>
<h3 id="view-the-analysis-during-process-or-result">View the Analysis During Process or Result</h3>
<p><a class="xref" href="../../api/Hi.MachiningProcs.SessionMessageHost.html">SessionMessageHost</a> contains a sequence of simulation messages and step data, which can be used to monitor and analyze the simulation process and results.</p>
<p>&lt;xref:Hi.MachiningProcs.SessionMessageHost&gt; contains a sequence of simulation messages and step data, which can be used to monitor and analyze the simulation process and results.</p>
<h2 id="ui-pattern">UI Pattern</h2>
<p>The user interface navigation bar matches the workflow. Top-level navigation items include:</p>
<ul>
@@ -117,7 +117,7 @@
<ul>
<li>Add cubetree geometry defect scanning (<a class="xref" href="../../api/Hi.MachiningProcs.RuntimeApi.html#Hi_MachiningProcs_RuntimeApi_ScanRuntimeGeomInfDefect_">ScanRuntimeGeomInfDefect</a>) and clearing (<a class="xref" href="../../api/Hi.MachiningProcs.RuntimeApi.html#Hi_MachiningProcs_RuntimeApi_ClearDefectDisplayee_">ClearDefectDisplayee</a>) for detecting and visualizing geometry anomalies in workpieces (see <a href="../../user-guide/zh-Hant/script/GeomDefect/index.html">幾何缺陷掃描</a>)</li>
<li>Upgrade internal fraction representation to float128 precision for improved cubetree geometry accuracy and numerical stability</li>
<li>Refactor messaging system from <code>IMessageHost</code> to standard <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.iprogress-1">IProgress&lt;T&gt;</a> pattern; <a class="xref" href="../../api/Hi.MachiningProcs.SessionMessageHost.html">SessionMessageHost</a> now implements <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.iprogress-1">IProgress&lt;T&gt;</a>, and all messaging methods renamed from <code>Add*</code> to <code>Report*</code> (e.g., <code>AddProgress</code><a class="xref" href="../../api/Hi.Common.Messages.MultiTagMessageUtil.html#Hi_Common_Messages_MultiTagMessageUtil_ReportProgress_">ReportProgress</a>)</li>
<li>Refactor messaging system from <code>IMessageHost</code> to standard <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.iprogress-1">IProgress&lt;T&gt;</a> pattern; &lt;xref:Hi.MachiningProcs.SessionMessageHost&gt; now implements <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.iprogress-1">IProgress&lt;T&gt;</a>, and all messaging methods renamed from <code>Add*</code> to <code>Report*</code> (e.g., <code>AddProgress</code><a class="xref" href="../../api/Hi.Common.Messages.MultiTagMessageUtil.html#Hi_Common_Messages_MultiTagMessageUtil_ReportProgress_">ReportProgress</a>)</li>
<li>Fix cubetree initialization crash</li>
<li>Improve postprocess precision by applying sincos parameterization instead of direct angle-based formulation for rotary axis numerical solving in <a class="xref" href="../../api/Hi.Numerical.Xyzabc.XyzabcSolver.html">XyzabcSolver</a></li>
<li>Add asynchronous anchor solid preparation on project load for improved startup performance</li>