From f93806eb90fa2d1fa41044e3cfd6b6fbf2b0b4c6 Mon Sep 17 00:00:00 2001 From: Lin Kayser Date: Wed, 31 Jul 2024 15:48:51 +0400 Subject: [PATCH] Added example how to visualize CLI file Also added the visualization to VDB to CLI example --- Examples/Ex_ShowCLIFile.cs | 56 ++++++++++++++++++++++++++++++++++++++ Examples/Ex_VDBtoCLI.cs | 15 ++++++++-- 2 files changed, 69 insertions(+), 2 deletions(-) create mode 100644 Examples/Ex_ShowCLIFile.cs diff --git a/Examples/Ex_ShowCLIFile.cs b/Examples/Ex_ShowCLIFile.cs new file mode 100644 index 0000000..2c1f956 --- /dev/null +++ b/Examples/Ex_ShowCLIFile.cs @@ -0,0 +1,56 @@ +// +// SPDX-License-Identifier: CC0-1.0 +// +// This example code file is released to the public under Creative Commons CC0. +// See https://creativecommons.org/publicdomain/zero/1.0/legalcode +// +// To the extent possible under law, LEAP 71 has waived all copyright and +// related or neighboring rights to this PicoGK example code file. +// +// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +// + +using PicoGK; + +namespace PicoGKExamples +{ + class ShowCLI + { + public ShowCLI(string strCLIFile) + { + m_strCLIFile = strCLIFile; + } + + public void Task() + { + // Load all CLI slices + CliIo.Result oResult = CliIo.oSlicesFromCliFile(m_strCLIFile); + + // Add all slices to the viewer + oResult.oSlices.AddToViewer(Library.oViewer()); + + // Write out all slice as SVGs + // Create a subdirectory, to not spam the CLI file folder + + string strDir = Path.GetDirectoryName(m_strCLIFile) ?? Library.strLogFolder; + string strName = Path.GetFileNameWithoutExtension(m_strCLIFile); + string strSubDir = Path.Combine(strDir, strName + "_SVGs"); + Directory.CreateDirectory(strSubDir); + + // Iterate throug all slices and save as SVGs + for (int n=0; n