Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/sn4k3/UVtools.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTiago Conceição <Tiago_caza@hotmail.com>2020-06-25 01:37:57 +0300
committerTiago Conceição <Tiago_caza@hotmail.com>2020-06-25 01:37:57 +0300
commit6d401eb774bc4d9a0014e24b2d48c4f5e156d912 (patch)
treef1c248691362d61f2052fc8709df4524f38c0b02 /UVtools.Cmd
parent625b736ad725d8b91576d4a511149a1f8920930e (diff)
Droped Parser and create UVtoolsCmd
Diffstat (limited to 'UVtools.Cmd')
-rw-r--r--UVtools.Cmd/Program.cs205
-rw-r--r--UVtools.Cmd/UVtools.Cmd.csproj40
-rw-r--r--UVtools.Cmd/UVtools.icobin0 -> 124548 bytes
3 files changed, 245 insertions, 0 deletions
diff --git a/UVtools.Cmd/Program.cs b/UVtools.Cmd/Program.cs
new file mode 100644
index 0000000..1b8b7cc
--- /dev/null
+++ b/UVtools.Cmd/Program.cs
@@ -0,0 +1,205 @@
+using System;
+using System.Collections.Generic;
+using System.CommandLine;
+using System.CommandLine.Invocation;
+using System.Diagnostics;
+using System.IO;
+using System.Reflection;
+using System.Threading.Tasks;
+using UVtools.Core;
+
+namespace UVtools.Cmd
+{
+ class Program
+ {
+ public static async Task<int> Main(params string[] args)
+ {
+ Stopwatch sw = new Stopwatch();
+ uint count = 0;
+ var rootCommand = new RootCommand("MSLA/DLP, file analysis, repair, conversion and manipulation")
+ {
+ new Option(new []{"-f", "--file"}, "Input file to read")
+ {
+ Required = true,
+ Argument = new Argument<FileSystemInfo>("filepath").ExistingOnly()
+ },
+ new Option(new []{"-o", "--output"}, "Output file to save the modifications, if aware, it saves to the same input file")
+ {
+ Argument = new Argument<FileSystemInfo>("filepath")
+ },
+ new Option(new []{"-c", "--convert"}, "Converts input into a output file format by it extension")
+ {
+ Argument = new Argument<FileSystemInfo>("filepath")
+ },
+
+ new Option(new []{"-p", "--properties"}, "Print a list of all properties/settings"),
+ new Option(new []{"-i", "--issues"}, "Compute and print a list of all issues"),
+ new Option(new []{"-r", "--repair"}, "Attempt to repair all issues"){
+ Argument = new Argument<int[]>("[start layer index] [end layer index]")
+ },
+
+ new Option(new []{"-mr", "--mut-resize"}, "Resizes layer images in a X and/or Y factor, starting from 100% value")
+ {
+ Argument = new Argument<int[]>("[x%] [y%] [start layer index] [end layer index] [fade 0/1]")
+ },
+ new Option(new []{"-ms", "--mut-solidify"}, "Closes all inner holes")
+ {
+ Argument = new Argument<int[]>("[start layer index] [end layer index]")
+ },
+ new Option(new []{"-me", "--mut-erode"}, "Erodes away the boundaries of foreground object")
+ {
+ Argument = new Argument<int[]>("[start iterations] [end iterations] [start layer index] [end layer index] [fade 0/1]")
+ },
+ new Option(new []{"-md", "--mut-dilate"}, "It is just opposite of erosion")
+ {
+ Argument = new Argument<int[]>("[start iterations] [end iterations] [start layer index] [end layer index] [fade 0/1]")
+ },
+ new Option(new []{"-mc", "--mut-close"}, "Dilation followed by Erosion")
+ {
+ Argument = new Argument<int[]>("[start iterations] [end iterations] [start layer index] [end layer index] [fade 0/1]")
+ },
+ new Option(new []{"-mo", "--mut-open"}, "Erosion followed by Dilation")
+ {
+ Argument = new Argument<int[]>("[start iterations] [end iterations] [start layer index] [end layer index] [fade 0/1]")
+ },
+ new Option(new []{"-mg", "--mut-gradient"}, "The difference between dilation and erosion of an image")
+ {
+ Argument = new Argument<int[]>("[kernel size] [start layer index] [end layer index] [fade 0/1]")
+ },
+
+ new Option(new []{"-mpyr", "--mut-pyr"}, "Performs downsampling step of Gaussian pyramid decomposition")
+ {
+ Argument = new Argument<int[]>("[start layer index] [end layer index]")
+ },
+ new Option(new []{"-mgb", "--mut-gaussian-blur"}, "Each pixel is a sum of fractions of each pixel in its neighborhood")
+ {
+ Argument = new Argument<int[]>("[aperture] [sigmaX] [sigmaY]")
+ },
+ new Option(new []{"-mmb", "--mut-median-blur"}, "Each pixel becomes the median of its surrounding pixels")
+ {
+ Argument = new Argument<ushort>("[aperture]")
+ },
+
+
+
+
+ /*new Option(new []{"-ls", "--layer-start"}, "Specify a start layer index to use with some operations as a range")
+ {
+ Argument = new Argument<uint>("Layer index")
+ },
+
+ new Option(new []{"-le", "--layer-end"}, "Specify a end layer index to use with some operations as a range")
+ {
+ Argument = new Argument<uint>("Layer index")
+ },
+
+ new Option(new []{"-is", "--iteration-start"}, "Specify a start layer index to use with some operations as a range")
+ {
+ Argument = new Argument<uint>("Layer index")
+ },
+
+ new Option(new []{"-fade"}, "Fade a start value towards a end value to use with some operations")*/
+
+ };
+
+ rootCommand.Handler = CommandHandler.Create(
+ (FileSystemInfo file, FileSystemInfo convert, bool properties, bool issues, bool repair, uint layerStartIndex, uint layerEndIndex) =>
+ {
+ Console.WriteLine($"Reading: {file}");
+
+ var fileFormat = FileFormat.FindByExtension(file.FullName, true, true);
+ if (ReferenceEquals(fileFormat, null))
+ {
+ Console.WriteLine($"Error: {file.FullName} is not a known nor valid format.");
+ }
+ else
+ {
+ fileFormat.Decode(file.FullName);
+ }
+
+ if (properties)
+ {
+ count = 0;
+ Console.WriteLine("Listing all properties:");
+ Console.WriteLine("----------------------");
+ foreach (var config in fileFormat.Configs)
+ {
+ Console.WriteLine("******************************");
+ Console.WriteLine($"\t{config.GetType().Name}");
+ Console.WriteLine("******************************");
+ foreach (PropertyInfo propertyInfo in config.GetType()
+ .GetProperties(BindingFlags.Public | BindingFlags.Instance))
+ {
+ count++;
+ if (propertyInfo.Name.Equals("Item")) continue;
+ Console.WriteLine($"{propertyInfo.Name}: {propertyInfo.GetValue(config)}");
+ }
+ }
+
+ Console.WriteLine("----------------------");
+ Console.WriteLine($"Total properties: {count}");
+ }
+
+ if (issues)
+ {
+ Console.WriteLine("Computing Issues, please wait.");
+ sw.Restart();
+ var issuesDict = fileFormat.LayerManager.GetAllIssues();
+ sw.Stop();
+
+ Console.WriteLine("Issues:");
+ Console.WriteLine("----------------------");
+ count = 0;
+ for (uint layerIndex = 0; layerIndex < fileFormat.LayerCount; layerIndex++)
+ {
+ if(!issuesDict.TryGetValue(layerIndex, out var list)) continue;
+ foreach (var issue in list)
+ {
+ Console.WriteLine(issue);
+ count++;
+ }
+ }
+
+ Console.WriteLine("----------------------");
+ Console.WriteLine($"Total Issues: {count} in {sw.ElapsedMilliseconds}ms");
+ }
+
+ if (!ReferenceEquals(convert, null))
+ {
+ var fileConvert = FileFormat.FindByExtension(convert.FullName, true, true);
+ if (ReferenceEquals(fileFormat, null))
+ {
+ Console.WriteLine($"Error: {convert.FullName} is not a known nor valid format.");
+ }
+ else
+ {
+ Console.WriteLine($"Converting {fileFormat.GetType().Name} to {fileConvert.GetType().Name}: {convert.Name}");
+
+ try
+ {
+ sw.Restart();
+ fileFormat.Convert(fileConvert, convert.FullName);
+ sw.Stop();
+ Console.WriteLine($"Convertion done in {sw.ElapsedMilliseconds}ms");
+ }
+ catch (Exception e)
+ {
+ Console.WriteLine(e);
+ }
+
+ }
+
+ }
+
+
+ });
+
+
+ await rootCommand.InvokeAsync(args);
+ //await rootCommand.InvokeAsync("-f body_Tough0.1mm_SL1_5h16m_HOLLOW_DRAIN.sl1 -i");
+
+ return 1;
+
+ }
+ }
+}
diff --git a/UVtools.Cmd/UVtools.Cmd.csproj b/UVtools.Cmd/UVtools.Cmd.csproj
new file mode 100644
index 0000000..a944096
--- /dev/null
+++ b/UVtools.Cmd/UVtools.Cmd.csproj
@@ -0,0 +1,40 @@
+<Project Sdk="Microsoft.NET.Sdk">
+
+ <PropertyGroup>
+ <OutputType>Exe</OutputType>
+ <TargetFramework>netcoreapp3.1</TargetFramework>
+ <AssemblyName>UVtoolsCmd</AssemblyName>
+ <ApplicationIcon>UVtools.ico</ApplicationIcon>
+ <Version>0.1</Version>
+ <Authors>Tiago Conceição</Authors>
+ <Company>PTRTECH</Company>
+ <PackageLicenseFile>LICENSE</PackageLicenseFile>
+ <RepositoryUrl>https://github.com/sn4k3/UVtools</RepositoryUrl>
+ <PackageIcon>UVtools.png</PackageIcon>
+ <PackageProjectUrl>https://github.com/sn4k3/UVtools</PackageProjectUrl>
+ <Description>MSLA/DLP, file analysis, repair, conversion and manipulation</Description>
+ <Copyright>Copyright © 2020 PTRTECH</Copyright>
+ <RepositoryType>Git</RepositoryType>
+ <PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
+ </PropertyGroup>
+
+ <ItemGroup>
+ <PackageReference Include="System.CommandLine" Version="2.0.0-beta1.20303.1" />
+ </ItemGroup>
+
+ <ItemGroup>
+ <ProjectReference Include="..\UVtools.Core\UVtools.Core.csproj" />
+ </ItemGroup>
+
+ <ItemGroup>
+ <None Include="..\LICENSE">
+ <Pack>True</Pack>
+ <PackagePath></PackagePath>
+ </None>
+ <None Include="..\UVtools.GUI\UVtools.png">
+ <Pack>True</Pack>
+ <PackagePath></PackagePath>
+ </None>
+ </ItemGroup>
+
+</Project>
diff --git a/UVtools.Cmd/UVtools.ico b/UVtools.Cmd/UVtools.ico
new file mode 100644
index 0000000..2a642ec
--- /dev/null
+++ b/UVtools.Cmd/UVtools.ico
Binary files differ