-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added example how to visualize CLI file
Also added the visualization to VDB to CLI example
- Loading branch information
Showing
2 changed files
with
69 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<oResult.oSlices.nCount(); n++) | ||
{ | ||
PolySlice oSlice = oResult.oSlices.oSliceAt(n); | ||
oSlice.SaveToSvgFile(Path.Combine(strSubDir, strName + $"_{n:00000}.svg"), true); | ||
} | ||
} | ||
|
||
string m_strCLIFile; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters