revert to VB and update to new project file format
This commit is contained in:
@@ -1,15 +0,0 @@
|
||||
using System;
|
||||
|
||||
namespace Pilz.S3DFileParser.Exceptions
|
||||
{
|
||||
public class MaterialException : Exception
|
||||
{
|
||||
public MaterialException() : base()
|
||||
{
|
||||
}
|
||||
|
||||
public MaterialException(string message) : base(message)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
14
Pilz.Simple3DFileParser/Other/Exceptions.vb
Normal file
14
Pilz.Simple3DFileParser/Other/Exceptions.vb
Normal file
@@ -0,0 +1,14 @@
|
||||
Namespace Exceptions
|
||||
|
||||
Public Class MaterialException
|
||||
Inherits Exception
|
||||
|
||||
Public Sub New()
|
||||
MyBase.New
|
||||
End Sub
|
||||
Public Sub New(message As String)
|
||||
MyBase.New(message)
|
||||
End Sub
|
||||
End Class
|
||||
|
||||
End Namespace
|
||||
@@ -1,30 +0,0 @@
|
||||
using System.Drawing;
|
||||
|
||||
namespace Pilz.S3DFileParser
|
||||
{
|
||||
internal static class Extensions
|
||||
{
|
||||
public static object GetPropertyValue(this object @base, string propertyName)
|
||||
{
|
||||
return @base?.GetType().GetProperty(propertyName, System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Static)?.GetValue(@base);
|
||||
}
|
||||
|
||||
public static bool IsTheSameAs(this Bitmap @base, Bitmap image)
|
||||
{
|
||||
if (@base.Size != image.Size)
|
||||
return false;
|
||||
for (int y = 0, loopTo = @base.Height - 1; y <= loopTo; y++)
|
||||
{
|
||||
for (int x = 0, loopTo1 = @base.Width - 1; x <= loopTo1; x++)
|
||||
{
|
||||
var p1 = @base.GetPixel(x, y);
|
||||
var p2 = image.GetPixel(x, y);
|
||||
if (p1 != p2)
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
26
Pilz.Simple3DFileParser/Other/Extensions.vb
Normal file
26
Pilz.Simple3DFileParser/Other/Extensions.vb
Normal file
@@ -0,0 +1,26 @@
|
||||
Imports System.IO
|
||||
Imports System.Runtime.CompilerServices
|
||||
|
||||
Friend Module Extensions
|
||||
|
||||
<Extension>
|
||||
Public Function GetPropertyValue(base As Object, propertyName As String) As Object
|
||||
Return base?.GetType.GetProperty(propertyName, Reflection.BindingFlags.Public Or Reflection.BindingFlags.NonPublic Or Reflection.BindingFlags.Instance Or Reflection.BindingFlags.Static)?.GetValue(base)
|
||||
End Function
|
||||
|
||||
<Extension>
|
||||
Public Function IsTheSameAs(base As Bitmap, image As Bitmap) As Boolean
|
||||
If base.Size <> image.Size Then Return False
|
||||
|
||||
For y As Integer = 0 To base.Height - 1
|
||||
For x As Integer = 0 To base.Width - 1
|
||||
Dim p1 As Color = base.GetPixel(x, y)
|
||||
Dim p2 As Color = image.GetPixel(x, y)
|
||||
If p1 <> p2 Then Return False
|
||||
Next
|
||||
Next
|
||||
|
||||
Return True
|
||||
End Function
|
||||
|
||||
End Module
|
||||
@@ -1,144 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using global::Assimp.Unmanaged;
|
||||
|
||||
namespace Pilz.S3DFileParser
|
||||
{
|
||||
public class File3DLoaderModule
|
||||
{
|
||||
public delegate Object3D LoaderAction(string fileName, LoaderOptions options);
|
||||
|
||||
public delegate void ExporterAction(Object3D obj, string fileName);
|
||||
|
||||
private static File3DLoaderModule[] _LoaderModules = null;
|
||||
private static File3DLoaderModule[] _ExporterModules = null;
|
||||
private readonly Delegate method = null;
|
||||
|
||||
public string Name { get; private set; }
|
||||
public IReadOnlyDictionary<string, string> SupportedFormats { get; private set; }
|
||||
|
||||
public File3DLoaderModule(string name, LoaderAction method, IReadOnlyDictionary<string, string> supportedFormats)
|
||||
{
|
||||
Name = name;
|
||||
this.method = method;
|
||||
SupportedFormats = supportedFormats;
|
||||
}
|
||||
|
||||
public File3DLoaderModule(string name, ExporterAction method, IReadOnlyDictionary<string, string> supportedFormats)
|
||||
{
|
||||
Name = name;
|
||||
this.method = method;
|
||||
SupportedFormats = supportedFormats;
|
||||
}
|
||||
|
||||
public Task InvokeAsync(Object3D obj, string fileName)
|
||||
{
|
||||
return Task.Run(() => Invoke(obj, fileName));
|
||||
}
|
||||
|
||||
public void Invoke(Object3D obj, string fileName)
|
||||
{
|
||||
method.Method.Invoke(null, new object[] { obj, fileName });
|
||||
}
|
||||
|
||||
public Task<Object3D> InvokeAsync(string fileName, LoaderOptions options)
|
||||
{
|
||||
return Task.Run(() => Invoke(fileName, options));
|
||||
}
|
||||
|
||||
public Object3D Invoke(string fileName, LoaderOptions options)
|
||||
{
|
||||
return (Object3D)method.Method.Invoke(null, new object[] { fileName, options });
|
||||
}
|
||||
|
||||
public static File3DLoaderModule[] LoaderModules
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_LoaderModules is null)
|
||||
{
|
||||
_LoaderModules = GetLoaderModules();
|
||||
}
|
||||
|
||||
return _LoaderModules;
|
||||
}
|
||||
}
|
||||
|
||||
public static File3DLoaderModule[] ExporterModules
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_ExporterModules is null)
|
||||
{
|
||||
_ExporterModules = GetExporterModules();
|
||||
}
|
||||
|
||||
return _ExporterModules;
|
||||
}
|
||||
}
|
||||
|
||||
private static File3DLoaderModule[] GetLoaderModules()
|
||||
{
|
||||
var list = new List<File3DLoaderModule>();
|
||||
list.Add(new File3DLoaderModule("Simple File Parser", LoadViaSimpleFileParser, new Dictionary<string, string>() { { "obj", "OBJ" } }));
|
||||
AssimpModule.AssimpLoader.LoadAssimpLibs();
|
||||
var exts = new Dictionary<string, string>();
|
||||
foreach (Assimp.ExportFormatDescription fd in AssimpLibrary.Instance.GetExportFormatDescriptions())
|
||||
{
|
||||
if (!exts.ContainsKey(fd.FileExtension))
|
||||
{
|
||||
exts.Add(fd.FileExtension, fd.FormatId + " - " + fd.Description);
|
||||
}
|
||||
}
|
||||
|
||||
exts.Add("blend", "Blender");
|
||||
list.Add(new File3DLoaderModule("Assimp", LoadViaAssimp, exts));
|
||||
list.Add(new File3DLoaderModule("Aspose.3D", LoadViaAspose3D, new Dictionary<string, string>() { { "obj", "OBJ" }, { "dae", "DAE" }, { "fbx", "FBX" }, { "stl", "STL" }, { "3ds", "3DS" }, { "3d", "3D" }, { "gltf", "glTF" }, { "drc", "DRC" }, { "rvm", "RVM" }, { "pdf", "PDF" }, { "x", "X" }, { "jt", "JT" }, { "dfx", "DFX" }, { "ply", "PLY" }, { "3mf", "3MF" }, { "ase", "ASE" } }));
|
||||
return list.ToArray();
|
||||
}
|
||||
|
||||
private static File3DLoaderModule[] GetExporterModules()
|
||||
{
|
||||
var list = new List<File3DLoaderModule>();
|
||||
list.Add(new File3DLoaderModule("Simple File Parser", ExportViaSimpleFileParser, new Dictionary<string, string>() { { "obj", "OBJ" } }));
|
||||
AssimpModule.AssimpLoader.LoadAssimpLibs();
|
||||
var exts = new Dictionary<string, string>();
|
||||
foreach (Assimp.ExportFormatDescription fd in AssimpLibrary.Instance.GetExportFormatDescriptions())
|
||||
{
|
||||
if (!exts.ContainsKey(fd.FileExtension))
|
||||
exts.Add(fd.FileExtension, fd.FormatId + " - " + fd.Description);
|
||||
}
|
||||
|
||||
list.Add(new File3DLoaderModule("Assimp", ExportViaAssimp, exts));
|
||||
return list.ToArray();
|
||||
}
|
||||
|
||||
private static Object3D LoadViaSimpleFileParser(string fileName, LoaderOptions options)
|
||||
{
|
||||
return ObjModule.ObjFile.FromFile(fileName, options.LoadMaterials, options.UpAxis);
|
||||
}
|
||||
|
||||
private static Object3D LoadViaAssimp(string fileName, LoaderOptions options)
|
||||
{
|
||||
AssimpModule.AssimpLoader.LoadAssimpLibs();
|
||||
return AssimpModule.AssimpLoader.FromFile(fileName, options.LoadMaterials, options.UpAxis);
|
||||
}
|
||||
|
||||
private static Object3D LoadViaAspose3D(string fileName, LoaderOptions options)
|
||||
{
|
||||
return Aspose3DModule.Aspose3DLoader.FromFile(fileName, options.LoadMaterials, options.UpAxis);
|
||||
}
|
||||
|
||||
private static void ExportViaSimpleFileParser(Object3D o, string fileName)
|
||||
{
|
||||
ObjModule.ObjFile.ToFile(fileName, o);
|
||||
}
|
||||
|
||||
private static void ExportViaAssimp(Object3D o, string fileName)
|
||||
{
|
||||
AssimpModule.AssimpLoader.LoadAssimpLibs();
|
||||
AssimpModule.AssimpLoader.ToFile(fileName, o);
|
||||
}
|
||||
}
|
||||
}
|
||||
147
Pilz.Simple3DFileParser/Other/LoaderModule.vb
Normal file
147
Pilz.Simple3DFileParser/Other/LoaderModule.vb
Normal file
@@ -0,0 +1,147 @@
|
||||
Imports System.Reflection
|
||||
Imports Assimp.Unmanaged
|
||||
|
||||
Public Class File3DLoaderModule
|
||||
|
||||
Public Delegate Function LoaderAction(fileName As String, options As LoaderOptions) As Object3D
|
||||
Public Delegate Sub ExporterAction(obj As Object3D, fileName As String)
|
||||
|
||||
Private Shared _LoaderModules As File3DLoaderModule() = Nothing
|
||||
Private Shared _ExporterModules As File3DLoaderModule() = Nothing
|
||||
|
||||
Private ReadOnly method As [Delegate] = Nothing
|
||||
Public ReadOnly Property Name As String
|
||||
Public ReadOnly Property SupportedFormats As IReadOnlyDictionary(Of String, String)
|
||||
|
||||
Public Sub New(name As String, method As LoaderAction, supportedFormats As IReadOnlyDictionary(Of String, String))
|
||||
Me.Name = name
|
||||
Me.method = method
|
||||
Me.SupportedFormats = supportedFormats
|
||||
End Sub
|
||||
|
||||
Public Sub New(name As String, method As ExporterAction, supportedFormats As IReadOnlyDictionary(Of String, String))
|
||||
Me.Name = name
|
||||
Me.method = method
|
||||
Me.SupportedFormats = supportedFormats
|
||||
End Sub
|
||||
|
||||
Public Function InvokeAsync(obj As Object3D, fileName As String) As Task
|
||||
Return Task.Run(Sub() Invoke(obj, fileName))
|
||||
End Function
|
||||
|
||||
Public Sub Invoke(obj As Object3D, fileName As String)
|
||||
method.Method.Invoke(Nothing, {obj, fileName})
|
||||
End Sub
|
||||
|
||||
Public Function InvokeAsync(fileName As String, options As LoaderOptions) As Task(Of Object3D)
|
||||
Return Task.Run(Function() Invoke(fileName, options))
|
||||
End Function
|
||||
|
||||
Public Function Invoke(fileName As String, options As LoaderOptions) As Object3D
|
||||
Return method.Method.Invoke(Nothing, {fileName, options})
|
||||
End Function
|
||||
|
||||
Public Shared ReadOnly Property LoaderModules As File3DLoaderModule()
|
||||
Get
|
||||
If _LoaderModules Is Nothing Then
|
||||
_LoaderModules = GetLoaderModules()
|
||||
End If
|
||||
Return _LoaderModules
|
||||
End Get
|
||||
End Property
|
||||
|
||||
Public Shared ReadOnly Property ExporterModules As File3DLoaderModule()
|
||||
Get
|
||||
If _ExporterModules Is Nothing Then
|
||||
_ExporterModules = GetExporterModules()
|
||||
End If
|
||||
Return _ExporterModules
|
||||
End Get
|
||||
End Property
|
||||
|
||||
Private Shared Function GetLoaderModules() As File3DLoaderModule()
|
||||
Dim list As New List(Of File3DLoaderModule)
|
||||
|
||||
list.Add(New File3DLoaderModule("Simple File Parser",
|
||||
AddressOf LoadViaSimpleFileParser,
|
||||
New Dictionary(Of String, String) From {{"obj", "OBJ"}}))
|
||||
|
||||
AssimpModule.AssimpLoader.LoadAssimpLibs()
|
||||
Dim exts As New Dictionary(Of String, String)
|
||||
For Each fd As Assimp.ExportFormatDescription In AssimpLibrary.Instance.GetExportFormatDescriptions
|
||||
If Not exts.ContainsKey(fd.FileExtension) Then
|
||||
exts.Add(fd.FileExtension, fd.FormatId & " - " & fd.Description)
|
||||
End If
|
||||
Next
|
||||
exts.Add("blend", "Blender")
|
||||
|
||||
list.Add(New File3DLoaderModule("Assimp",
|
||||
AddressOf LoadViaAssimp,
|
||||
exts))
|
||||
|
||||
list.Add(New File3DLoaderModule("Aspose.3D",
|
||||
AddressOf LoadViaAspose3D,
|
||||
New Dictionary(Of String, String) From {
|
||||
{"obj", "OBJ"},
|
||||
{"dae", "DAE"},
|
||||
{"fbx", "FBX"},
|
||||
{"stl", "STL"},
|
||||
{"3ds", "3DS"},
|
||||
{"3d", "3D"},
|
||||
{"gltf", "glTF"},
|
||||
{"drc", "DRC"},
|
||||
{"rvm", "RVM"},
|
||||
{"pdf", "PDF"},
|
||||
{"x", "X"},
|
||||
{"jt", "JT"},
|
||||
{"dfx", "DFX"},
|
||||
{"ply", "PLY"},
|
||||
{"3mf", "3MF"},
|
||||
{"ase", "ASE"}}))
|
||||
|
||||
Return list.ToArray
|
||||
End Function
|
||||
|
||||
Private Shared Function GetExporterModules() As File3DLoaderModule()
|
||||
Dim list As New List(Of File3DLoaderModule)
|
||||
|
||||
list.Add(New File3DLoaderModule("Simple File Parser",
|
||||
AddressOf ExportViaSimpleFileParser,
|
||||
New Dictionary(Of String, String) From {{"obj", "OBJ"}}))
|
||||
|
||||
AssimpModule.AssimpLoader.LoadAssimpLibs()
|
||||
Dim exts As New Dictionary(Of String, String)
|
||||
For Each fd As Assimp.ExportFormatDescription In AssimpLibrary.Instance.GetExportFormatDescriptions
|
||||
If Not exts.ContainsKey(fd.FileExtension) Then exts.Add(fd.FileExtension, fd.FormatId & " - " & fd.Description)
|
||||
Next
|
||||
|
||||
list.Add(New File3DLoaderModule("Assimp",
|
||||
AddressOf ExportViaAssimp,
|
||||
exts))
|
||||
|
||||
Return list.ToArray
|
||||
End Function
|
||||
|
||||
Private Shared Function LoadViaSimpleFileParser(fileName As String, options As LoaderOptions) As Object3D
|
||||
Return ObjModule.ObjFile.FromFile(fileName, options.LoadMaterials, options.UpAxis)
|
||||
End Function
|
||||
|
||||
Private Shared Function LoadViaAssimp(fileName As String, options As LoaderOptions) As Object3D
|
||||
AssimpModule.AssimpLoader.LoadAssimpLibs()
|
||||
Return AssimpModule.AssimpLoader.FromFile(fileName, options.LoadMaterials, options.UpAxis)
|
||||
End Function
|
||||
|
||||
Private Shared Function LoadViaAspose3D(fileName As String, options As LoaderOptions) As Object3D
|
||||
Return Aspose3DModule.Aspose3DLoader.FromFile(fileName, options.LoadMaterials, options.UpAxis)
|
||||
End Function
|
||||
|
||||
Private Shared Sub ExportViaSimpleFileParser(o As Object3D, fileName As String)
|
||||
ObjModule.ObjFile.ToFile(fileName, o)
|
||||
End Sub
|
||||
|
||||
Private Shared Sub ExportViaAssimp(o As Object3D, fileName As String)
|
||||
AssimpModule.AssimpLoader.LoadAssimpLibs()
|
||||
AssimpModule.AssimpLoader.ToFile(fileName, o)
|
||||
End Sub
|
||||
|
||||
End Class
|
||||
@@ -1,19 +0,0 @@
|
||||
|
||||
namespace Pilz.S3DFileParser
|
||||
{
|
||||
public class LoaderOptions
|
||||
{
|
||||
public bool LoadMaterials { get; set; } = false;
|
||||
public UpAxis UpAxis { get; set; } = UpAxis.Y;
|
||||
|
||||
public LoaderOptions()
|
||||
{
|
||||
}
|
||||
|
||||
public LoaderOptions(bool loadMaterials, UpAxis upAxis)
|
||||
{
|
||||
LoadMaterials = loadMaterials;
|
||||
UpAxis = upAxis;
|
||||
}
|
||||
}
|
||||
}
|
||||
14
Pilz.Simple3DFileParser/Other/LoaderOptions.vb
Normal file
14
Pilz.Simple3DFileParser/Other/LoaderOptions.vb
Normal file
@@ -0,0 +1,14 @@
|
||||
Public Class LoaderOptions
|
||||
|
||||
Public Property LoadMaterials As Boolean = False
|
||||
Public Property UpAxis As UpAxis = False
|
||||
|
||||
Public Sub New()
|
||||
End Sub
|
||||
|
||||
Public Sub New(loadMaterials As Boolean, upAxis As UpAxis)
|
||||
Me.LoadMaterials = loadMaterials
|
||||
Me.UpAxis = upAxis
|
||||
End Sub
|
||||
|
||||
End Class
|
||||
Reference in New Issue
Block a user