diff --git a/paket.dependencies b/paket.dependencies index ff7a923a9..76e1d2b34 100644 --- a/paket.dependencies +++ b/paket.dependencies @@ -43,12 +43,11 @@ nuget Silk.NET.GLFW = 2.15.0 nuget Silk.NET.Core = 2.15.0 nuget Silk.NET.Direct3D9 = 2.15.0 -nuget SharpZipLib ~> 1.4.1 - // Examples nuget Aardvark.PixImage.DevIL ~> 5.2.33 nuget Aardvark.PixImage.ImageSharp ~> 2.0.1 nuget Aardvark.Data.GLTF ~> 1.0.0 +nuget Aardvark.Data.Opc ~> 0.9.0 group Test framework: net8.0 diff --git a/paket.lock b/paket.lock index 957f497b0..cb8832244 100644 --- a/paket.lock +++ b/paket.lock @@ -56,6 +56,11 @@ NUGET Aardvark.Rendering.Common (>= 5.5) FSharp.Core (>= 8.0) glTF2Loader (>= 1.1.4-alpha < 1.2.0-alpha) + Aardvark.Data.Opc (0.9) + Aardvark.Base.Tensors (>= 5.3.2 < 5.4) + Aardvark.Rendering.Common (>= 5.5) + FSharp.Core (>= 8.0) + SharpZipLib (>= 1.4.1 < 1.5) Aardvark.FontProvider (0.1) Aardvark.Base.Fonts (>= 5.3) FSharp.Core (>= 8.0.100) diff --git a/src/Aardvark.Rendering.NoExamples.NonWindows.slnf b/src/Aardvark.Rendering.NoExamples.NonWindows.slnf index b59abb3bb..12f5ab6d8 100644 --- a/src/Aardvark.Rendering.NoExamples.NonWindows.slnf +++ b/src/Aardvark.Rendering.NoExamples.NonWindows.slnf @@ -11,7 +11,6 @@ "Aardvark.Rendering\\Aardvark.Rendering.fsproj", "Aardvark.SceneGraph.Browser\\Aardvark.SceneGraph.Browser.fsproj", "Aardvark.SceneGraph.Assimp\\Aardvark.SceneGraph.Assimp.fsproj", - "Aardvark.SceneGraph.Opc\\Aardvark.SceneGraph.Opc.fsproj", "Aardvark.SceneGraph\\Aardvark.SceneGraph.fsproj", "Application\\Aardvark.Application.OpenVR.GL\\Aardvark.Application.OpenVR.GL.fsproj", "Application\\Aardvark.Application.OpenVR.Vulkan\\Aardvark.Application.OpenVR.Vulkan.fsproj", diff --git a/src/Aardvark.Rendering.NoExamples.slnf b/src/Aardvark.Rendering.NoExamples.slnf index d2ce23dcb..c853b294b 100644 --- a/src/Aardvark.Rendering.NoExamples.slnf +++ b/src/Aardvark.Rendering.NoExamples.slnf @@ -11,7 +11,6 @@ "Aardvark.Rendering\\Aardvark.Rendering.fsproj", "Aardvark.SceneGraph.Browser\\Aardvark.SceneGraph.Browser.fsproj", "Aardvark.SceneGraph.Assimp\\Aardvark.SceneGraph.Assimp.fsproj", - "Aardvark.SceneGraph.Opc\\Aardvark.SceneGraph.Opc.fsproj", "Aardvark.SceneGraph\\Aardvark.SceneGraph.fsproj", "Application\\Aardvark.Application.OpenVR.GL\\Aardvark.Application.OpenVR.GL.fsproj", "Application\\Aardvark.Application.OpenVR.Vulkan\\Aardvark.Application.OpenVR.Vulkan.fsproj", diff --git a/src/Aardvark.Rendering.NonWindows.slnf b/src/Aardvark.Rendering.NonWindows.slnf index cfa55eeeb..036e8ae9c 100644 --- a/src/Aardvark.Rendering.NonWindows.slnf +++ b/src/Aardvark.Rendering.NonWindows.slnf @@ -11,7 +11,6 @@ "Aardvark.Rendering\\Aardvark.Rendering.fsproj", "Aardvark.SceneGraph.Assimp\\Aardvark.SceneGraph.Assimp.fsproj", "Aardvark.SceneGraph.Browser\\Aardvark.SceneGraph.Browser.fsproj", - "Aardvark.SceneGraph.Opc\\Aardvark.SceneGraph.Opc.fsproj", "Aardvark.SceneGraph\\Aardvark.SceneGraph.fsproj", "Application\\Aardvark.Application.OpenVR.GL\\Aardvark.Application.OpenVR.GL.fsproj", "Application\\Aardvark.Application.OpenVR.Vulkan\\Aardvark.Application.OpenVR.Vulkan.fsproj", diff --git a/src/Aardvark.Rendering.sln b/src/Aardvark.Rendering.sln index ad62b1502..0c7035fed 100644 --- a/src/Aardvark.Rendering.sln +++ b/src/Aardvark.Rendering.sln @@ -172,8 +172,6 @@ Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "Aardvark.Application.Slim.V EndProject Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "17 - TextureArrays", "Examples (netcore)\17 - TextureArrays\17 - TextureArrays.fsproj", "{2C25EACD-8E56-4BE5-8BB7-0CB9ED004096}" EndProject -Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "Aardvark.SceneGraph.Opc", "Aardvark.SceneGraph.Opc\Aardvark.SceneGraph.Opc.fsproj", "{97CF1A7D-9858-4552-8EBF-ADBD6FF68FFA}" -EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Scratch (netcore)", "Scratch (netcore)", "{29CA9CA1-CC31-4B5D-8DB0-2FEA748C09D8}" ProjectSection(SolutionItems) = preProject Scratch (netcore)\new.fsx = Scratch (netcore)\new.fsx @@ -552,10 +550,6 @@ Global {2C25EACD-8E56-4BE5-8BB7-0CB9ED004096}.Debug|Any CPU.Build.0 = Debug|Any CPU {2C25EACD-8E56-4BE5-8BB7-0CB9ED004096}.Release|Any CPU.ActiveCfg = Release|Any CPU {2C25EACD-8E56-4BE5-8BB7-0CB9ED004096}.Release|Any CPU.Build.0 = Release|Any CPU - {97CF1A7D-9858-4552-8EBF-ADBD6FF68FFA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {97CF1A7D-9858-4552-8EBF-ADBD6FF68FFA}.Debug|Any CPU.Build.0 = Debug|Any CPU - {97CF1A7D-9858-4552-8EBF-ADBD6FF68FFA}.Release|Any CPU.ActiveCfg = Release|Any CPU - {97CF1A7D-9858-4552-8EBF-ADBD6FF68FFA}.Release|Any CPU.Build.0 = Release|Any CPU {73D82892-93D0-402C-B561-F25B5D1804B0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {73D82892-93D0-402C-B561-F25B5D1804B0}.Debug|Any CPU.Build.0 = Debug|Any CPU {73D82892-93D0-402C-B561-F25B5D1804B0}.Release|Any CPU.ActiveCfg = Release|Any CPU diff --git a/src/Aardvark.SceneGraph.Opc/Aara.fs b/src/Aardvark.SceneGraph.Opc/Aara.fs deleted file mode 100644 index ee2fd10ee..000000000 --- a/src/Aardvark.SceneGraph.Opc/Aara.fs +++ /dev/null @@ -1,329 +0,0 @@ -#nowarn "9" -#if INTERACTIVE -#r "../../bin/Debug/Aardvark.Base.dll" -#r "../../bin/Debug/Aardvark.Base.TypeProviders.dll" -#r "../../bin/Debug/Aardvark.Base.FSharp.dll" -#r "System.Xml.Linq.dll" -#else -namespace Aardvark.SceneGraph.Opc -#endif - -open System -open System.IO -open System.Runtime.InteropServices - -open Aardvark.Base -open Aardvark.Rendering -open Aardvark.Prinziple -open FSharp.Data.Adaptive - -[] -module Aara = - - let readerChars2String (f : Stream) = - let cnt = f.ReadByte() - - let target = Array.zeroCreate cnt - let read = f.Read(target,0,cnt) - if cnt <> read then failwith "" - System.Text.Encoding.Default.GetString target - - let loadRaw<'a when 'a : unmanaged> (elementCount : int) (f : Stream) = - let result = Array.zeroCreate<'a> elementCount - let buffer = Array.zeroCreate (1 <<< 22) - - let gc = GCHandle.Alloc(result, GCHandleType.Pinned) - try - let mutable ptr = gc.AddrOfPinnedObject() - let mutable remaining = sizeof<'a> * result.Length - while remaining > 0 do - let s = f.Read(buffer, 0, buffer.Length) - Marshal.Copy(buffer, 0, ptr, s) - ptr <- ptr + nativeint s - remaining <- remaining - s - finally - gc.Free() - result - - [] - let loadRaw2<'a when 'a : unmanaged> (elementCount : int) (f : Stream) : 'a[] = - loadRaw elementCount f - - let loadFromStream<'a when 'a : unmanaged> (f : Stream) = - let binaryReader = new BinaryReader(f,Text.Encoding.ASCII, true) - let typeName = readerChars2String f - let dimensions = f.ReadByte() |> int - let sizes = [| for d in 0 .. dimensions - 1 do yield binaryReader.ReadInt32() |] - - let elementCount = sizes |> Array.fold ((*)) 1 - - let result = - if typeof<'a>.Name = typeName then - loadRaw<'a> elementCount f - else - match typeName with - | "V3d" -> f |> loadRaw elementCount |> PrimitiveValueConverter.arrayConverter typeof - | "V3f" -> f |> loadRaw elementCount |> PrimitiveValueConverter.arrayConverter typeof - | "V2d" -> f |> loadRaw elementCount |> PrimitiveValueConverter.arrayConverter typeof - | "double" -> f |> loadRaw elementCount |> PrimitiveValueConverter.arrayConverter typeof - | "float" -> f |> loadRaw elementCount |> PrimitiveValueConverter.arrayConverter typeof - | _ -> failwith ("Aara.fs: No support for loading type " + typeName) - - let dim = - match sizes with - | [| x |] -> V3i(x,1,1) - | [| x; y |] -> V3i(x,y,1) - | [| x; y; z |] -> V3i(x,y,z) - | _ -> failwith "" - - Volume<'a>(result, dim) - - let fromFile<'a when 'a : unmanaged and 'a : (new : unit -> 'a) and 'a : struct and 'a :> ValueType> (s : string) = - use fs = Prinziple.openRead s - loadFromStream<'a> fs - - let inline isNan (v : V3f) = - v.X.IsNaN() || v.Y.IsNaN() || v.Z.IsNaN() - - let createIndex (vi : Matrix) = - let dx = vi.Info.DX - let dy = vi.Info.DY - let dxy = dx + dy - let mutable arr = Array.zeroCreate (int (vi.SX - 1L) * int (vi.SY - 1L) * 6) - let mutable cnt = 0 - - vi.SubMatrix(V2l.Zero,vi.Size-V2l.II).ForeachXYIndex(fun x y index -> - let i00 = index - let i10 = index + dy - let i01 = index + dx - let i11 = index + dxy - - arr.[cnt + 0] <- (int i00) - arr.[cnt + 1] <- (int i10) - arr.[cnt + 2] <- (int i11) - arr.[cnt + 3] <- (int i00) - arr.[cnt + 4] <- (int i11) - arr.[cnt + 5] <- (int i01) - cnt <- cnt + 6 - ) - Array.Resize(&arr, cnt) - arr - - let createIndex2 (vi : Matrix) (invalids : int64[])= - - let invalids = invalids |> Array.map (fun x -> (x, x)) |> HashMap.ofArray - - let dx = vi.Info.DX - let dy = vi.Info.DY - let dxy = dx + dy - let mutable arr = Array.zeroCreate (int (vi.SX - 1L) * int (vi.SY - 1L) * 6) - let mutable cnt = 0 - - vi.SubMatrix(V2l.Zero,vi.Size-V2l.II).ForeachXYIndex(fun x y index -> - - let inv = invalids |> HashMap.tryFind index - - match inv with - | Some _ -> - arr.[cnt + 0] <- 0 - arr.[cnt + 1] <- 0 - arr.[cnt + 2] <- 0 - arr.[cnt + 3] <- 0 - arr.[cnt + 4] <- 0 - arr.[cnt + 5] <- 0 - cnt <- cnt + 6 - | None -> - let i00 = index - let i10 = index + dy - let i01 = index + dx - let i11 = index + dxy - - arr.[cnt + 0] <- (int i00) - arr.[cnt + 1] <- (int i10) - arr.[cnt + 2] <- (int i11) - arr.[cnt + 3] <- (int i00) - arr.[cnt + 4] <- (int i11) - arr.[cnt + 5] <- (int i01) - cnt <- cnt + 6 - ) - Array.Resize(&arr, cnt) - arr - - // Patch Size to index array (faces with invalid points will be degenerated or skipped) - let computeIndexArray (size : V2i) (degenerateInvalids : bool) (invalidPoints : int Set) = - // vertex x/y to point index of face - let getFaceIndices y x sizeX = - let pntA = y * sizeX + x - let pntB = (y + 1) * sizeX + x - let pntC = pntA + 1 - let pntD = pntB + 1 - - [| pntA; pntB; pntC; - pntC; pntB; pntD |] - - // replace invalid faces with another array (invalidReplacement) - let getFaceIndicesWReplacedInvalids invalidReplacement y x sizeX = - let faceIndices = getFaceIndices y x sizeX - if faceIndices |> Array.exists (fun i -> Set.contains i invalidPoints) then - invalidReplacement - else - faceIndices - - // choose function to use - let f = - match (invalidPoints.IsEmptyOrNull(), degenerateInvalids) with - | (true, _) -> getFaceIndices - // skip faces with invalid points - | (false, false) -> getFaceIndicesWReplacedInvalids Array.empty - // replace invalid faces with degenerated face - | (false, true) -> - // find first valid point - let p = [| 0..(size.X * size.Y - 1) |] |> Array.find (fun i -> not (Set.contains i invalidPoints)) - getFaceIndicesWReplacedInvalids [| p; p; p; p; p; p |] - - // step through all vertices to get index-array per face - let indexArray = - [| - for y in [| 0..(size.Y-2) |] do - for x in [| 0..(size.X-2) |] do - yield f y x size.X - |] - - let invalidFaceCount = indexArray |> Array.filter (fun a -> a.IsEmpty()) |> Array.length - if invalidFaceCount > 0 then - Report.Line(5, "Invalid faces found: " + invalidFaceCount.ToString()) - - indexArray |> Array.concat - - let getInvalidIndices (positions : V3d[]) = - positions |> Array.mapi (fun i x -> if x.AnyNaN then Some i else None) |> Array.choose id - - // load triangles from aaraFile and transform them with matrix - let loadTrianglesFromFile' (aaraFile : string)(indexComputation : V2i -> int[] -> int[]) (matrix : M44d) = - let positions = aaraFile |> fromFile - - let data = - positions.Data |> Array.map (fun x -> x.ToV3d() |> matrix.TransformPos) - - let invalidIndices = getInvalidIndices data - let index = indexComputation (positions.Size.XY.ToV2i()) invalidIndices //computeIndexArray (positions.Size.XY.ToV2i()) false (Set.ofArray invalidIndices) - - let triangles = - index - |> Seq.map(fun x -> data.[x]) - |> Seq.chunkBySize 3 - |> Seq.map(fun x -> Triangle3d(x)) - |> Seq.toArray - - triangles - - // load triangles from aaraFile and transform them with matrix - let loadTrianglesFromFile (aaraFile : string) (matrix : M44d) = - loadTrianglesFromFile' aaraFile (fun size invalids -> computeIndexArray size false (Set.ofArray invalids)) matrix - - module Offset = - - let loadRawWithOffset<'a when 'a : (new : unit -> 'a) and 'a : struct and 'a :> ValueType> (offset : int) (elementCount : int) (f : Stream) = - let result = Array.zeroCreate<'a> elementCount - let buffer = Array.zeroCreate (1 <<< 22) - - let gc = GCHandle.Alloc(result, GCHandleType.Pinned) - try - let mutable ptr = gc.AddrOfPinnedObject() - let mutable remaining = sizeof<'a> * result.Length - while remaining > 0 do - let s = f.Read(buffer, offset, buffer.Length) - Marshal.Copy(buffer, 0, ptr, s) - ptr <- ptr + nativeint s - remaining <- remaining - s - finally - gc.Free() - result - - let loadRawColumnWithOffset<'a when 'a : (new : unit -> 'a) and 'a : struct and 'a :> ValueType> (offset : int) (elementCount : int) (f : Stream) = - let result = Array.zeroCreate<'a> elementCount - let buffer = Array.zeroCreate sizeof<'a> - let startPos = f.Position - let mutable counter = 1 - let byteOffset = offset*sizeof<'a> - - let gc = GCHandle.Alloc(result, GCHandleType.Pinned) - try - let mutable ptr = gc.AddrOfPinnedObject() - while counter <= elementCount do - f.Seek((startPos + (int64(byteOffset * counter))), SeekOrigin.Begin) |> ignore - let s = f.Read(buffer, 0, buffer.Length) - Marshal.Copy(buffer, 0, ptr, s) - ptr <- ptr + nativeint s - counter <- counter+1 - finally - gc.Free() - result - - let loadFromStreamWithOffset<'a when 'a : unmanaged> (offset : int) (size : int) (f : Stream) : 'a[]= - let binaryReader = new BinaryReader(f,Text.Encoding.ASCII, true) - let typeName = readerChars2String f - let dimensions = f.ReadByte() |> int - let sizes = [| for d in 0 .. dimensions - 1 do yield binaryReader.ReadInt32() |] - - let elementCount = sizes |> Array.fold ((*)) 1 - - let result = - match typeName with - | "V3d" -> f |> loadRawWithOffset offset elementCount |> PrimitiveValueConverter.arrayConverter typeof - | "V3f" -> f |> loadRawWithOffset offset elementCount |> PrimitiveValueConverter.arrayConverter typeof - | "V2d" -> f |> loadRawWithOffset offset elementCount |> PrimitiveValueConverter.arrayConverter typeof - | "double" -> f |> loadRawWithOffset offset elementCount |> PrimitiveValueConverter.arrayConverter typeof - | "float" -> f |> loadRawWithOffset offset elementCount |> PrimitiveValueConverter.arrayConverter typeof - | _ -> failwith ("Aara.fs: No support for loading type " + typeName) - - result - - let loadFromStreamWithOffset'<'a when 'a : unmanaged> (offset : int) (size : int) (f : Stream) : 'a[]= - let binaryReader = new BinaryReader(f,Text.Encoding.ASCII, true) - let typeName = readerChars2String f - let dimensions = f.ReadByte() |> int - let sizes = [| for d in 0 .. dimensions - 1 do yield binaryReader.ReadInt32() |] - - //let elementCount = sizes |> Array.fold ((*)) 1 - - let result = - match typeName with - | "V3d" -> f |> loadRawWithOffset offset size |> PrimitiveValueConverter.arrayConverter typeof - | "V3f" -> f |> loadRawWithOffset offset size |> PrimitiveValueConverter.arrayConverter typeof - | "V2d" -> f |> loadRawWithOffset offset size |> PrimitiveValueConverter.arrayConverter typeof - | "double" -> f |> loadRawWithOffset offset size |> PrimitiveValueConverter.arrayConverter typeof - | "float" -> f |> loadRawWithOffset offset size |> PrimitiveValueConverter.arrayConverter typeof - | _ -> failwith ("Aara.fs: No support for loading type " + typeName) - - result - - let loadFromStreamColumnsWithOffset<'a when 'a : unmanaged> (offset : int) (size : int) (f : Stream) : 'a[]= - f.Seek ((int64 0), SeekOrigin.Begin) |> ignore - - let binaryReader = new BinaryReader(f,Text.Encoding.ASCII, true) - let typeName = readerChars2String f - let dimensions = f.ReadByte() |> int - let sizes = [| for d in 0 .. dimensions - 1 do yield binaryReader.ReadInt32() |] - - let elementCount = sizes |> Array.fold ((*)) 1 - - let result = - match typeName with - | "V3d" -> f |> loadRawColumnWithOffset offset sizes.[1] |> PrimitiveValueConverter.arrayConverter typeof - | "V3f" -> f |> loadRawColumnWithOffset offset sizes.[1] |> PrimitiveValueConverter.arrayConverter typeof - | "V2d" -> f |> loadRawColumnWithOffset offset sizes.[1] |> PrimitiveValueConverter.arrayConverter typeof - | "double" -> f |> loadRawColumnWithOffset offset sizes.[1] |> PrimitiveValueConverter.arrayConverter typeof - | "float" -> f |> loadRawColumnWithOffset offset sizes.[1] |> PrimitiveValueConverter.arrayConverter typeof - | _ -> failwith ("Aara.fs: No support for loading type " + typeName) - - - result - - let fromFileWithOffsetAndSize<'a when 'a : unmanaged and 'a : (new : unit -> 'a) and 'a : struct and 'a :> ValueType> (offset : int) (size : int) (fileName : string) = - let stream = Prinziple.openRead fileName - loadFromStreamWithOffset<'a> offset size stream - - let fromFileColumnsWithOffsetAndSize<'a when 'a : unmanaged and 'a : (new : unit -> 'a) and 'a : struct and 'a :> ValueType> (offset : int) (size : int) (fileName : string) = - let stream = Prinziple.openRead fileName - loadFromStreamColumnsWithOffset<'a> offset size stream \ No newline at end of file diff --git a/src/Aardvark.SceneGraph.Opc/Aardvark.SceneGraph.Opc.fsproj b/src/Aardvark.SceneGraph.Opc/Aardvark.SceneGraph.Opc.fsproj deleted file mode 100644 index 7c0137fea..000000000 --- a/src/Aardvark.SceneGraph.Opc/Aardvark.SceneGraph.Opc.fsproj +++ /dev/null @@ -1,33 +0,0 @@ - - - - netstandard2.0 - Aardvark.SceneGraph.Opc - Library - true - true - 3389;3390;3395 - - - ..\..\bin\Debug\ - DEBUG;TRACE - - - ..\..\bin\Release - - - - - - - - - - - - - - - - - diff --git a/src/Aardvark.SceneGraph.Opc/AssemblyInfo.fs b/src/Aardvark.SceneGraph.Opc/AssemblyInfo.fs deleted file mode 100644 index 785e140a8..000000000 --- a/src/Aardvark.SceneGraph.Opc/AssemblyInfo.fs +++ /dev/null @@ -1,41 +0,0 @@ -namespace Aardvark.Data.Opc.AssemblyInfo - -open System.Reflection -open System.Runtime.CompilerServices -open System.Runtime.InteropServices - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[] -[] -[] -[] -[] -[] -[] -[] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [] -[] -[] - -do - () \ No newline at end of file diff --git a/src/Aardvark.SceneGraph.Opc/OpcPaths.fs b/src/Aardvark.SceneGraph.Opc/OpcPaths.fs deleted file mode 100644 index 3658c5673..000000000 --- a/src/Aardvark.SceneGraph.Opc/OpcPaths.fs +++ /dev/null @@ -1,75 +0,0 @@ -namespace Aardvark.SceneGraph.Opc - -open System -open System.IO -open Aardvark.Base - -type OpcPaths = OpcPaths of string - -[] -module OpcPaths = - - // patches/ - let Patches_DirNames = ["patches"; "Patches"] - - // obsolete in favor of robust handling for: https://github.com/pro3d-space/PRo3D/issues/280 - [] - let Patches_DirName = "patches" - - let PatchHierarchy_FileName = "patchhierarchy.xml" - let PatchHierarchyCache_FileName = "hierarchy.cache" - let ProfilLut_FileName = "profilelut8.bin" - - // per patch - // Patch.xml - // .aara files: Normals, Offset, Positions, Positions2d..... - let PatchFileInfo_FileName = "Patch.xml" - - // KdTrees in root-patch directory - let KdTree_Ext = "aakd" - let KdTreeMaster_Ext = "cache" - - // images/ - let Images_DirNames = ["images"; "Images"] - // obsolete in favor of robust handling for: https://github.com/pro3d-space/PRo3D/issues/280 - [] - let Images_DirName = "images" - - let ImagePyramid_FileName = "imagepyramid.xml" - - let value (OpcPaths opc_DirAbsPath) = opc_DirAbsPath - -[] -module PathCombineOperator = - let (+/) path1 path2 = Path.Combine(path1, path2) - -type OpcPaths with - member this.Opc_DirAbsPath = OpcPaths.value this - - // ?? for debug output - member this.ShortName = Directory.GetParent(this.Opc_DirAbsPath).Name +/ Path.GetFileName(this.Opc_DirAbsPath) - - // Patches. Note: this throws if no patches dir is found given current OpcPaths - member this.Patches_DirAbsPath = - let probingDirs = - OpcPaths.Patches_DirNames |> List.map (fun patchSuffix -> this.Opc_DirAbsPath +/ patchSuffix) - match probingDirs |> List.tryFind Directory.Exists with - | None -> failwithf "patches dir not found. Probing directories: %A" probingDirs - | Some d -> d - - member this.PatchHierarchy_FileAbsPath = this.Patches_DirAbsPath +/ OpcPaths.PatchHierarchy_FileName - member this.PatchHierarchyCache_FileAbsPath = this.Patches_DirAbsPath +/ OpcPaths.PatchHierarchyCache_FileName - member this.profileLut_FileAbsPath = this.Patches_DirAbsPath +/ OpcPaths.ProfilLut_FileName - - // Images. Note: this throws if no patches dir is found given current OpcPaths - member this.Images_DirAbsPath = - let probingDirs = - OpcPaths.Images_DirNames |> List.map (fun imageSuffix -> this.Opc_DirAbsPath +/ imageSuffix) - match probingDirs |> List.tryFind Directory.Exists with - | None -> failwithf "images dir not found. Probing directories: %A" probingDirs - | Some d -> d - - - member this.ImagePyramid_FileAbsPaths = - Directory.GetDirectories(this.Images_DirAbsPath) - |> Array.map (fun images_DirPath -> this.Images_DirAbsPath +/ images_DirPath +/ OpcPaths.ImagePyramid_FileName) \ No newline at end of file diff --git a/src/Aardvark.SceneGraph.Opc/Patch.fs b/src/Aardvark.SceneGraph.Opc/Patch.fs deleted file mode 100644 index e04457546..000000000 --- a/src/Aardvark.SceneGraph.Opc/Patch.fs +++ /dev/null @@ -1,80 +0,0 @@ -namespace Aardvark.SceneGraph.Opc - -open System -open Aardvark.Base -open Aardvark.Rendering -open Aardvark.Prinziple - -type ViewerModality = XYZ | SvBR - -[] -module ViewerModality = - let matchy threeD twoD (modality : ViewerModality)= - match modality with - | XYZ -> threeD - | SvBR -> twoD - -type Patch = - { - level : int - info : PatchFileInfo - triangleSize : float - } - -[] -module Patch = - let ofInfo (level : int) (size: float) (p : PatchFileInfo) = { level = level; info = p; triangleSize = size } - - let load (opcPaths : OpcPaths) (mode : ViewerModality) (p : PatchFileInfo) = - let sw = System.Diagnostics.Stopwatch() - sw.Start() - let patch_DirAbsPath = opcPaths.Patches_DirAbsPath +/ p.Name - - let pos = - match mode, p.Positions2d with - | ViewerModality.SvBR, Some p2 -> p2 - | _ -> p.Positions - - let positions = patch_DirAbsPath +/ pos |> fromFile - let coordinates = patch_DirAbsPath +/ (List.head p.Coordinates) |> fromFile - - sw.Stop() - - let coordinates = coordinates.Data |> Array.map (fun v -> V2f(v.X, 1.0f-v.Y)) - - let index = createIndex (positions.AsMatrix()) - - let a : float = 0.0 - - let indexAttributes = - let def = [ - DefaultSemantic.Positions, positions.Data :> Array - DefaultSemantic.DiffuseColorCoordinates, coordinates :> Array - ] - - def |> SymDict.ofList - - let geometry = - IndexedGeometry( - Mode = IndexedGeometryMode.TriangleList, - IndexArray = index, - IndexedAttributes = indexAttributes - ) - - geometry, sw.MicroTime - - let extractTexturePath (opcPaths : OpcPaths) (patchInfo : PatchFileInfo) (texNumber : int) = - let t = patchInfo.Textures |> List.item texNumber - let fn = t.fileName.Replace('\\',System.IO.Path.DirectorySeparatorChar) - let sourcePath = opcPaths.Images_DirAbsPath +/ fn - let extensions = [ ".dds"; ".tif"; ".tiff"] - - let rec tryFindTex exts path = - match exts with - | x::xs -> - let current = System.IO.Path.ChangeExtension(path,x) - if Prinziple.exists current then current else tryFindTex xs path - | [] -> failwithf "texture not found: %s" path - - tryFindTex extensions sourcePath - diff --git a/src/Aardvark.SceneGraph.Opc/PatchFileInfo.fs b/src/Aardvark.SceneGraph.Opc/PatchFileInfo.fs deleted file mode 100644 index dd435e492..000000000 --- a/src/Aardvark.SceneGraph.Opc/PatchFileInfo.fs +++ /dev/null @@ -1,271 +0,0 @@ -#if INTERACTIVE -#r "../../bin/Debug/Aardvark.Base.dll" -#r "../../bin/Debug/Aardvark.Base.TypeProviders.dll" -#r "../../bin/Debug/Aardvark.Base.FSharp.dll" -#r "System.Xml.Linq.dll" -#else -namespace Aardvark.SceneGraph.Opc -#endif - -open System -open System.Xml -open System.Xml.Linq - -open Aardvark.Base -open Aardvark.Base.IO - -module private XmlHelpers = - - let xname str = XName.op_Implicit str - let xattr (elem: XElement) sname = elem.Attribute(xname sname).Value - let elem name (v : XElement) = - match v.Elements(xname name) |> Seq.toList with - | []-> failwithf "could not get value: %s" name - | [x] -> x - | _ -> failwithf "could not get value (not unique): %s" name - let elem' name (v : XElement) = - match v.Elements(xname name) |> Seq.toList with - | []-> None - | [x] -> Some x - | _ -> None - let elems name (p : XElement) = - p.Elements (xname name) - - let children name (p : XElement) = - p.Descendants (xname name) - - let xvalue (p : XElement) = p.Value.Trim() - - let prop name (p : XElement) = - (elem name p).Value.Trim() - -type Texture = { fileName : string; weights : string } -type VertexOrder = RowMajor | ColumnMajor -type GeometryType = QuadList -type DiffuseColorCoordinates = string - -type PatchFileInfo = - { - Name : string - TagList : list - GeometryType : GeometryType - QuadVertexSortOrder : VertexOrder - - Local2Global : Trafo3d - GlobalBoundingBox : Box3d - LocalBoundingBox : Box3d - - Local2Global2d : Trafo3d - GlobalBoundingBox2d : Box3d - LocalBoundingBox2d : Box3d - - Positions : string - Positions2d : option - Normals : string - Offsets : string - - Coordinates : list - Textures : list - Attributes : list - } - -[] -module PatchFileInfo = - open XmlHelpers - open Aardvark.Prinziple - - - [] - module Parsers = - let majority = function - | "RowMajor" -> RowMajor - | "ColumnMajor" -> ColumnMajor - | s -> failwithf "could not parse majority: %s" s - - let geomtryType = function - | "QuadList" -> QuadList - | s -> failwithf "could not parse geometry type: %s" s - - let (|Int32|_|) (s : string) = - match System.Int32.TryParse ( s.Trim() ) with - | (true,v) -> Some v - | _ -> None - - let tup2V2i (s : string) = - match s.Split(',') with - | [|Int32 x; Int32 y|] -> V2i(x,y) - | _ -> failwithf "Could not parse: %A" s - - let node (name : string) (node : XmlNode) = - node.SelectSingleNode(name) - - let nodes (name : string) (node : XmlNode) = - node.SelectNodes(name) |> Seq.cast - - let childNodes (name : string) (node : XmlNode) = - node.SelectSingleNode(name).ChildNodes |> Seq.cast - - let childNodes' (name : string) (node : XmlNode) = - let n = node.SelectSingleNode(name) - if (n = null) then - [] |> Seq.cast - else - n.ChildNodes |> Seq.cast - - let get (name : string) (node : XmlNode)= - node.SelectSingleNode(name).InnerText.Trim() - - let tryGet (name : string) (node : XmlNode)= - let n = node.SelectSingleNode(name) - if (n = null) then - None - else - Some (n.InnerText.Trim()) - - let xvalue (p : XmlNode) = p.Value.Trim() - - let inner (node : XmlNode) = - node.InnerText.Trim() - - let private ofXDoc (doc : XmlDocument) (name : string) (hasDeviations : bool) = - - let trafo (m : M44d) = - Trafo3d(m, m.Inverse) - - let mkTexture t = - let name = (inner t).Replace('\\',System.IO.Path.DirectorySeparatorChar) - { fileName = name; weights = "" } - - let patch = - doc.SelectSingleNode "/Aardvark" - |> Seq.cast - |> Seq.head - - let textures = - patch - |> childNodes "Textures" - |> Seq.map mkTexture - |> Seq.toList - - let coords = - patch - |> nodes "Coordinates" - |> Seq.toList - |> List.map (string << get "DiffuseColor1Coordinates") - - let attributes = - //if hasDeviations then - patch - |> childNodes' "Attributes" - |> Seq.map inner - |> Seq.toList - - let pos2d = patch |> tryGet "Positions2D" - let attributes = - match pos2d with - | Some _ -> "Positions2d.aara" :: attributes - | None -> attributes - - let local2Global2d = patch |> tryGet "Local2Global2D" - let local2Global2d = - match local2Global2d with - | Some x -> x |> M44d.Parse |> trafo - | None -> Trafo3d.Identity - - let globalBoundingBox2d = patch |> tryGet "GlobalBoundingBox2D" - let globalBoundingBox2d = - match globalBoundingBox2d with - | Some x -> x |> Box3d.Parse - | None -> Box3d.Invalid - - let localBoundingBox2d = patch |> tryGet "LocalBoundingBox2d" - let localBoundingBox2d = - match localBoundingBox2d with - | Some x -> x |> Box3d.Parse - | None -> Box3d.Invalid - - let split (s:string) = - (s.Split ' ') |> Array.toList - - { - Name = name - TagList = patch |> get "TagList" |> split - - GeometryType = patch |> get "GeometryType" |> geomtryType - QuadVertexSortOrder = patch |> tryGet "QuadVertexSortOrder" |> Option.map majority |> Option.defaultValue VertexOrder.ColumnMajor - - Local2Global = patch |> get "Local2Global" |> M44d.Parse |> trafo - GlobalBoundingBox = patch |> get "GlobalBoundingBox" |> Box3d.Parse - LocalBoundingBox = patch |> get "LocalBoundingBox" |> Box3d.Parse - - Local2Global2d = local2Global2d - GlobalBoundingBox2d = globalBoundingBox2d - LocalBoundingBox2d = localBoundingBox2d - - Positions = patch |> get "Positions" - Positions2d = pos2d - Normals = "" //patch |> get "Normals" - Offsets = "" - Textures = textures - Coordinates = coords - Attributes = attributes - } - - let load (opcPaths : OpcPaths) (patchName : string) = - let path = opcPaths.Patches_DirAbsPath +/ patchName +/ OpcPaths.PatchFileInfo_FileName - let doc = Prinziple.readXmlDoc path - ofXDoc doc patchName false - - /// - /// Loads patchfileinfo with positions2d.aara as attribute - /// - let load' (opcPaths : OpcPaths) (patchName : string) = - let path = opcPaths.Patches_DirAbsPath +/ patchName +/ OpcPaths.PatchFileInfo_FileName - let doc = Prinziple.readXmlDoc path - ofXDoc doc patchName true - -type QTree<'a> = Node of 'a * array> - | Leaf of 'a - -[] -module QTree = - let rec map (f : 'a->'a0) (tree : QTree<'a>) = - match tree with - | Leaf v -> Leaf (f v) - | Node(v,children) -> - Node(f v, children |> Array.map (map f)) - - let mapLevel (f : int->'a->'a0) (tree : QTree<'a>) = - let rec mapLevel lvl f t = - match t with - | Leaf v -> Leaf (f lvl v) - | Node(v,children) -> - Node(f lvl v, children |> Array.map (mapLevel (lvl + 1) f)) - mapLevel 0 f tree - - let rec getLeaves (tree : QTree<'a>) = - match tree with - | Leaf v -> Seq.singleton v - | Node(v,children) -> children |> Seq.collect getLeaves - - let getRoot (tree : QTree<'a>) = - match tree with - | Leaf v -> v - | Node(v,_) -> v - - let rec flatten (tree : QTree<'a>) = - match tree with - | Leaf v -> [|v|] - | Node(v,children) -> - let cs = children |> Array.map flatten |> Array.concat - Array.append [|v|] cs - - let height (tree : QTree<'a>) = - let rec height lvl tree = - match tree with - | Leaf _ -> lvl - | Node (_, children) -> - children - |> Array.map (height (lvl+1)) - |> Array.max - height 0 tree \ No newline at end of file diff --git a/src/Aardvark.SceneGraph.Opc/PatchHierarchy.fs b/src/Aardvark.SceneGraph.Opc/PatchHierarchy.fs deleted file mode 100644 index c956cdbc7..000000000 --- a/src/Aardvark.SceneGraph.Opc/PatchHierarchy.fs +++ /dev/null @@ -1,144 +0,0 @@ -namespace Aardvark.SceneGraph.Opc - -open System -open Aardvark.Base -open Aardvark.Prinziple - -type PatchHierarchy = - { - opcPaths : OpcPaths - tree : QTree - } - -[] -module PatchHierarchy = - open XmlHelpers - open System.Xml.Linq - - let parseDouble d = - let mutable r = 0.0 - if Double.TryParse(d,Globalization.NumberStyles.Float, Globalization.CultureInfo.InvariantCulture, &r) then r - else failwithf "could not parse int double:" - - let private ofDoc (x : XDocument) = - let hierarchy = x.Descendants(xname "PatchHierarchy") |> Seq.head - let rootPatch = hierarchy |> elem "RootPatch" |> xvalue - - let geometrySizes = hierarchy |> elem "AvgGeometrySizes" |> xvalue - let avgSizes = ((geometrySizes.[1..(geometrySizes.Length-2)]).Replace(" ","").Split [|','|]) |> Array.map parseDouble - Log.line "avgSizes %A" avgSizes - - let map = hierarchy |> elem' "SubPatchMap" - let items = - match map with - | Some subs -> subs.Descendants(xname "item") |> Seq.toList - | None -> [] - - let children = - items |> List.map (fun e -> - let key = elem "key" e |> xvalue - let values = elem "val" e - let nw = elem' "nw" values |> Option.map xvalue - let ne = elem' "ne" values |> Option.map xvalue - let sw = elem' "sw" values |> Option.map xvalue - let se = elem' "se" values |> Option.map xvalue - key, Array.choose id [|nw;ne;sw;se |] - ) |> Dictionary.ofList - - let rec mkTree (name : string) = - match children.TryGetValue name with - | (true,v) -> - QTree.Node(name, v |> Array.map mkTree) - | _ -> Leaf name - - let tree = mkTree rootPatch - tree, avgSizes |> Array.rev - - let loadAndCache (opcPaths : OpcPaths) (pickle : QTree -> byte[]) = - Log.startTimed "loading from hierarchy" - let xml = opcPaths.PatchHierarchy_FileAbsPath - let cache = opcPaths.PatchHierarchyCache_FileAbsPath - - let tree, sizes = - XDocument.Load(xml) |> ofDoc - let hierarchy = - tree - |> QTree.mapLevel (fun level p -> - p |> PatchFileInfo.load opcPaths |> Patch.ofInfo level sizes.[level] - ) - hierarchy |> pickle |> File.writeAllBytes cache - Log.stop() - { opcPaths = opcPaths; tree = hierarchy } - - let load (pickle : QTree -> byte[]) (unpickle : byte[] -> QTree) (opcPaths : OpcPaths) = - let cachefile = opcPaths.PatchHierarchyCache_FileAbsPath - - try - if Prinziple.exists cachefile then - Log.startTimed "loading from cache file" - - let readFile = Prinziple.readAllBytes cachefile - - let r = { opcPaths = opcPaths; tree = readFile |> unpickle } - Log.stop() - r - else - loadAndCache opcPaths pickle - with e -> - Log.warn "could not parse cache file. recomputing." - loadAndCache opcPaths pickle - - let getLevelFromResolution (resolution : float) (patchTree : QTree) = - let (lvl, _) = - patchTree - |> QTree.flatten - |> Array.map (fun patch -> (patch.level, patch.triangleSize)) - |> Array.distinct - |> Array.sortByDescending (fun (lvl, _) -> lvl) - |> Array.find (fun (_, triSize) -> resolution >= triSize) - lvl - - let kdTree_FileName (patch_Name : string) (patch_Level : int) (posType : ViewerModality) = - let lvl_Sub = - match patch_Level > -1 with - | true -> sprintf "-%i" patch_Level - | false -> "" - let pos_Sub = - match posType with - | XYZ -> "" - | SvBR -> "-2d" - sprintf "%s%s%s.%s" patch_Name lvl_Sub pos_Sub OpcPaths.KdTree_Ext - -type PatchHierarchy with - - // == Patch methods == - member this.rootPatch_DirName = - let rootpatch = this.tree |> QTree.getRoot - rootpatch.info.Name - - member this.rootPatch_DirAbsPath = - this.opcPaths.Patches_DirAbsPath +/ this.rootPatch_DirName - - // == PatchTree methods == - member this.patchTree_DirAbsPaths = - let patches_DirAbsPath = this.opcPaths.Patches_DirAbsPath - this.tree |> QTree.map (fun patch -> patches_DirAbsPath +/ patch.info.Name) - - // == KdTree methods == - member this.kdTree_FileAbsPath patch_Name patch_Level posType = - this.rootPatch_DirAbsPath +/ (PatchHierarchy.kdTree_FileName patch_Name patch_Level posType) - - member this.kdTreeAgg_FileAbsPath (lvl:int) (posType:ViewerModality) = - this.kdTree_FileAbsPath this.rootPatch_DirName lvl posType - - member this.kdTreeN_FileAbsPath = - this.kdTreeAgg_FileAbsPath -1 XYZ - - member this.kdTreeN2d_FileAbsPath = - this.kdTreeAgg_FileAbsPath -1 SvBR - - member this.kdTreeAggZero_FileAbsPath = - this.kdTreeAgg_FileAbsPath 0 XYZ - - member this.kdTreeAggZero2d_FileAbsPath = - this.kdTreeAgg_FileAbsPath 0 SvBR \ No newline at end of file diff --git a/src/Aardvark.SceneGraph.Opc/PrinZiple.fs b/src/Aardvark.SceneGraph.Opc/PrinZiple.fs deleted file mode 100644 index af2f9f9fb..000000000 --- a/src/Aardvark.SceneGraph.Opc/PrinZiple.fs +++ /dev/null @@ -1,130 +0,0 @@ -namespace Aardvark.Prinziple - -open System -open System.IO -open System.Xml -open System.Xml.Linq -open Aardvark.Base -open FSharp.Data.Adaptive -open ICSharpCode.SharpZipLib -open ICSharpCode.SharpZipLib.Zip - -module Prinziple = - // TODO @thomasortner: check this!!!! - let private codec = - lazy - try StringCodec.FromCodePage(StringCodec.ZipSpecCodePage) - with e -> - Log.warn "[Prinziple]: %A" e - StringCodec.Default - - let private readAllBytes' (reader : BinaryReader) = - - let bufferSize = 4096; - use ms = new MemoryStream() - - let buffer : byte[] = Array.zeroCreate bufferSize //(fun _ -> byte(0)) - let mutable count = 0 - - while (count <- reader.Read(buffer, 0, buffer.Length); count <> 0) do - ms.Write(buffer, 0, count); - - ms.ToArray() - - //"D:\_WORK\Aardwork\Exomars\_Scenes\_NEWVIEWER\TestScene\Surfaces\Cape_Desire_RGB\OPC_000_000" - //"hierarchy.cache" - //check if path contains zipfile (lookup in zipTable) - //yes: - //split path in zipfile and entry - //no: - //normal file read - - let mutable private zipTable : HashMap = HashMap.empty - - let splitPath (path : string) = - let p = zipTable |> HashMap.filter(fun _ v -> path.StartsWith v) |> HashMap.toList |> List.map snd |> List.tryHead - match p with - | Some zipped -> Some (Path.ChangeExtension(zipped, ".opc"), path.[zipped.Length+1..path.Length-1]) - | None -> None - - let registerIfZipped dir = - let dir = Path.GetFullPath(dir) - let zPath = Path.ChangeExtension(dir, ".opc") - if File.Exists zPath then - zipTable <- HashMap.add dir dir zipTable - dir - - let openRead path = - let split = path |> Path.GetFullPath |> splitPath - match split with - | Some(zip,entry) -> - let entryPath = entry.Replace("\\","/") - let file = new ZipFile(File.OpenRead(zip), false, stringCodec = codec.Value) - let e = file.GetEntry(entryPath) - file.GetInputStream(e) - | None -> - File.OpenRead(path) :> Stream - - let loadBytesFromZip zipPath (entryPath:string) = - let entryPath = entryPath.Replace("\\","/") - let file = new ZipFile(File.OpenRead(zipPath), false, stringCodec = codec.Value) - let e = file.GetEntry(entryPath) - use s = file.GetInputStream(e) - use r = new BinaryReader(s) - r |> readAllBytes' - - let loadXmlFromZip zipPath (entryPath : string) = - let entryPath = entryPath.Replace("\\","/") - let file = new ZipFile(File.OpenRead(zipPath), false, stringCodec = codec.Value) - let e = file.GetEntry(entryPath) - use s = file.GetInputStream(e) - XDocument.Load(s) - - let loadXmlFromZip' zipPath (entryPath : string) = - let xDoc = loadXmlFromZip zipPath entryPath - let x = new XmlDocument() - use reader = xDoc.CreateReader() - x.Load(reader) - x - - - let readXDoc path = - let split = path |> Path.GetFullPath |> splitPath - match split with - | Some(zip,entry) -> loadXmlFromZip zip entry - | None -> XDocument.Load(path) - - let readXmlDoc (path:string) = - let split = path |> Path.GetFullPath |> splitPath - match split with - | Some(zip,entry) -> loadXmlFromZip' zip entry - | None -> - let doc = new XmlDocument() - doc.Load path; doc - - let readAllBytes path = - let split = path |> Path.GetFullPath |> splitPath - match split with - | Some(zip,entry) -> loadBytesFromZip zip entry - | None -> File.readAllBytes path - - let exists path = - let split = path |> Path.GetFullPath |> splitPath - match split with - | Some(zip,entry) -> - let entryPath = entry.Replace("\\","/") - let file = new ZipFile(File.OpenRead(zip), false, stringCodec = codec.Value) - let e = file.GetEntry(entryPath) - e <> Unchecked.defaultof<_> - | None -> File.Exists path - - - //let loadFromZip' path = - // let file = new ZipFile(File.OpenRead(@"D:\_WORK\Aardwork\Exomars\_Scenes\_NEWVIEWER\TestScene\Surfaces\Cape_Desire_RGB\OPC_000_000.zip")) - // let e = file.GetEntry("hierarchy.cache") - // use s = file.GetInputStream(e) - // //s.Seek(2L, SeekOrigin.Begin) |> ignore - - // use r = new BinaryReader(s) - // r |> readAllBytes' - diff --git a/src/Aardvark.SceneGraph.Opc/Sg.fs b/src/Aardvark.SceneGraph.Opc/Sg.fs deleted file mode 100644 index ca3935a75..000000000 --- a/src/Aardvark.SceneGraph.Opc/Sg.fs +++ /dev/null @@ -1,47 +0,0 @@ -namespace Aardvark.SceneGraph.Opc - -open Aardvark.Base -open Aardvark.Rendering -open FSharp.Data.Adaptive -open Aardvark.SceneGraph - -module Sg2 = - - - let createFlatISg' pickle unpickle (patchHierarchies) (trafos : list) : ISg = - - let mode = ViewerModality.XYZ - - let patchHierarchies = - patchHierarchies |> List.map(fun x -> PatchHierarchy.load pickle unpickle x) |> List.zip trafos - - let leaves = - patchHierarchies - |> List.collect(fun (trafo,x) -> - x.tree - |> QTree.getLeaves - |> Seq.toList - |> List.map(fun y -> (x.opcPaths, y, trafo))) - - let sg = - let config = { wantMipMaps = true; wantSrgb = false; wantCompressed = false } - - leaves - |> List.map(fun (opcPaths,patch,trafo) -> (Patch.load opcPaths mode patch.info, opcPaths, patch.info, trafo)) - |> List.map(fun ((a,_),c,d,e) -> (a,c,d,e)) - |> List.map (fun (g,opcPaths,info,trafo) -> - - let texPath = Patch.extractTexturePath opcPaths info 0 - let tex = FileTexture(texPath,config) :> ITexture - - Sg.ofIndexedGeometry g - |> Sg.trafo (AVal.constant (info.Local2Global * trafo)) - |> Sg.diffuseTexture (AVal.constant tex) - ) - |> Sg.ofList - - sg - - let createFlatISg pickle unpickle (patchHierarchies : list) = - let trafos = List.init patchHierarchies.Length (fun _ -> Trafo3d.Identity) - createFlatISg' pickle unpickle (patchHierarchies) trafos diff --git a/src/Aardvark.SceneGraph.Opc/paket.references b/src/Aardvark.SceneGraph.Opc/paket.references deleted file mode 100644 index ec08de566..000000000 --- a/src/Aardvark.SceneGraph.Opc/paket.references +++ /dev/null @@ -1,6 +0,0 @@ -Aardvark.Base -Aardvark.Base.IO -Aardvark.Base.Incremental -FSharp.Core -SharpZipLib -Aardvark.Build \ No newline at end of file diff --git a/src/Aardvark.SceneGraph.Opc/paket.template b/src/Aardvark.SceneGraph.Opc/paket.template deleted file mode 100644 index c584298a3..000000000 --- a/src/Aardvark.SceneGraph.Opc/paket.template +++ /dev/null @@ -1,11 +0,0 @@ -type project -id Aardvark.SceneGraph.Opc -authors Aardvark Platform Team -owners Aardvark Platform Team -projectUrl http://github.com/aardvark-platform -licenseUrl http://www.apache.org/licenses/LICENSE-2.0.txt -repositoryType git -repositoryUrl https://github.com/aardvark-platform/aardvark.rendering -description - Aardvark is an open-source platform for visual computing, real-time graphics and visualization. -include-pdbs true \ No newline at end of file diff --git a/src/Examples (netcore)/33 - Opc/33 - Opc.fsproj b/src/Examples (netcore)/33 - Opc/33 - Opc.fsproj index 4f230032b..49fcb7412 100644 --- a/src/Examples (netcore)/33 - Opc/33 - Opc.fsproj +++ b/src/Examples (netcore)/33 - Opc/33 - Opc.fsproj @@ -22,7 +22,6 @@ - diff --git a/src/Examples (netcore)/33 - Opc/Program.fs b/src/Examples (netcore)/33 - Opc/Program.fs index 07bfa68fd..9cf589c80 100644 --- a/src/Examples (netcore)/33 - Opc/Program.fs +++ b/src/Examples (netcore)/33 - Opc/Program.fs @@ -5,7 +5,7 @@ open FSharp.Data.Adaptive open Aardvark.SceneGraph open Aardvark.Application open System.Runtime.InteropServices -open Aardvark.SceneGraph.Opc +open Aardvark.Data.Opc open MBrace.FsPickler @@ -59,8 +59,8 @@ type PatchLodTree(globalCenter : V3d, opc : OpcPaths, root : option p, true - | Node(p,_) -> p, false + | QTree.Leaf p -> p, true + | QTree.Node(p,_) -> p, false let cell = Cell patch.info.GlobalBoundingBox @@ -101,7 +101,7 @@ type PatchLodTree(globalCenter : V3d, opc : OpcPaths, root : option + | QTree.Node(_, cs) -> cs |> Array.map (fun c -> let root = match root with @@ -109,7 +109,7 @@ type PatchLodTree(globalCenter : V3d, opc : OpcPaths, root : option this :> ILodTreeNode PatchLodTree(globalCenter, opc, Some root, Some (this :> ILodTreeNode), level + 1, c) :> ILodTreeNode ) - | Leaf _ -> + | QTree.Leaf _ -> Array.empty //) diff --git a/src/Examples (netcore)/33 - Opc/paket.references b/src/Examples (netcore)/33 - Opc/paket.references index e87bb6a16..1eee4da69 100644 --- a/src/Examples (netcore)/33 - Opc/paket.references +++ b/src/Examples (netcore)/33 - Opc/paket.references @@ -1,2 +1,3 @@ FShade.Core +Aardvark.Data.Opc Aardvark.PixImage.DevIL \ No newline at end of file diff --git a/src/Scratch (net471)/00 - HelloWorld (net471)/00 - HelloWorld (net471).fsproj b/src/Scratch (net471)/00 - HelloWorld (net471)/00 - HelloWorld (net471).fsproj index 401cafda9..b3d67f383 100644 --- a/src/Scratch (net471)/00 - HelloWorld (net471)/00 - HelloWorld (net471).fsproj +++ b/src/Scratch (net471)/00 - HelloWorld (net471)/00 - HelloWorld (net471).fsproj @@ -27,7 +27,6 @@ - diff --git a/src/Scratch (net471)/05 - HickupTest/05 - HickupTest.fsproj b/src/Scratch (net471)/05 - HickupTest/05 - HickupTest.fsproj index 33c3a69f2..e5ce1567e 100644 --- a/src/Scratch (net471)/05 - HickupTest/05 - HickupTest.fsproj +++ b/src/Scratch (net471)/05 - HickupTest/05 - HickupTest.fsproj @@ -25,7 +25,6 @@ - diff --git a/src/Scratch (net471)/06 - MemoryLeakTest/06 - MemoryLeakTest.fsproj b/src/Scratch (net471)/06 - MemoryLeakTest/06 - MemoryLeakTest.fsproj index 33c3a69f2..e5ce1567e 100644 --- a/src/Scratch (net471)/06 - MemoryLeakTest/06 - MemoryLeakTest.fsproj +++ b/src/Scratch (net471)/06 - MemoryLeakTest/06 - MemoryLeakTest.fsproj @@ -25,7 +25,6 @@ - diff --git a/src/Scratch (net471)/07 - RenderTaskCustom/07 - RenderTaskCustom.fsproj b/src/Scratch (net471)/07 - RenderTaskCustom/07 - RenderTaskCustom.fsproj index 33c3a69f2..e5ce1567e 100644 --- a/src/Scratch (net471)/07 - RenderTaskCustom/07 - RenderTaskCustom.fsproj +++ b/src/Scratch (net471)/07 - RenderTaskCustom/07 - RenderTaskCustom.fsproj @@ -25,7 +25,6 @@ - diff --git a/src/Scratch (net471)/08 - DerivedAttributePerformance/08 - DerivedAttributePerformance.fsproj b/src/Scratch (net471)/08 - DerivedAttributePerformance/08 - DerivedAttributePerformance.fsproj index 33c3a69f2..e5ce1567e 100644 --- a/src/Scratch (net471)/08 - DerivedAttributePerformance/08 - DerivedAttributePerformance.fsproj +++ b/src/Scratch (net471)/08 - DerivedAttributePerformance/08 - DerivedAttributePerformance.fsproj @@ -25,7 +25,6 @@ - diff --git a/src/Scratch (net471)/09 - MappedBufferPerformance/09 - MappedBufferPerformance.fsproj b/src/Scratch (net471)/09 - MappedBufferPerformance/09 - MappedBufferPerformance.fsproj index 33c3a69f2..e5ce1567e 100644 --- a/src/Scratch (net471)/09 - MappedBufferPerformance/09 - MappedBufferPerformance.fsproj +++ b/src/Scratch (net471)/09 - MappedBufferPerformance/09 - MappedBufferPerformance.fsproj @@ -25,7 +25,6 @@ - diff --git a/src/Scratch (netcore)/02 - OpcDemo/02 - OpcDemo.fsproj b/src/Scratch (netcore)/02 - OpcDemo/02 - OpcDemo.fsproj index 5f4af0cdf..ff53bb42b 100644 --- a/src/Scratch (netcore)/02 - OpcDemo/02 - OpcDemo.fsproj +++ b/src/Scratch (netcore)/02 - OpcDemo/02 - OpcDemo.fsproj @@ -13,6 +13,7 @@ ..\..\..\bin\Release + @@ -20,7 +21,6 @@ - diff --git a/src/Scratch (netcore)/02 - OpcDemo/Program.fs b/src/Scratch (netcore)/02 - OpcDemo/Program.fs index 2263dd963..45035c97d 100644 --- a/src/Scratch (netcore)/02 - OpcDemo/Program.fs +++ b/src/Scratch (netcore)/02 - OpcDemo/Program.fs @@ -3,7 +3,7 @@ open Aardvark.Rendering open FSharp.Data.Adaptive open Aardvark.SceneGraph open Aardvark.Application -open Aardvark.SceneGraph.Opc +open Aardvark.Data.Opc open MBrace.FsPickler //open MBrace.FsPickler.Json diff --git a/src/Scratch (netcore)/02 - OpcDemo/Sg.fs b/src/Scratch (netcore)/02 - OpcDemo/Sg.fs new file mode 100644 index 000000000..ada065631 --- /dev/null +++ b/src/Scratch (netcore)/02 - OpcDemo/Sg.fs @@ -0,0 +1,44 @@ +module Sg2 + +open Aardvark.Base +open Aardvark.Rendering +open FSharp.Data.Adaptive +open Aardvark.SceneGraph +open Aardvark.Data.Opc + +let createFlatISg' pickle unpickle (patchHierarchies) (trafos : list) : ISg = + let mode = ViewerModality.XYZ + + let patchHierarchies = + patchHierarchies |> List.map(fun x -> PatchHierarchy.load pickle unpickle x) |> List.zip trafos + + let leaves = + patchHierarchies + |> List.collect(fun (trafo,x) -> + x.tree + |> QTree.getLeaves + |> Seq.toList + |> List.map(fun y -> (x.opcPaths, y, trafo))) + + let sg = + let config = { wantMipMaps = true; wantSrgb = false; wantCompressed = false } + + leaves + |> List.map(fun (opcPaths,patch,trafo) -> (Patch.load opcPaths mode patch.info, opcPaths, patch.info, trafo)) + |> List.map(fun ((a,_),c,d,e) -> (a,c,d,e)) + |> List.map (fun (g,opcPaths,info,trafo) -> + + let texPath = Patch.extractTexturePath opcPaths info 0 + let tex = FileTexture(texPath,config) :> ITexture + + Sg.ofIndexedGeometry g + |> Sg.trafo (AVal.constant (info.Local2Global * trafo)) + |> Sg.diffuseTexture (AVal.constant tex) + ) + |> Sg.ofList + + sg + +let createFlatISg pickle unpickle (patchHierarchies : list) = + let trafos = List.init patchHierarchies.Length (fun _ -> Trafo3d.Identity) + createFlatISg' pickle unpickle (patchHierarchies) trafos \ No newline at end of file diff --git a/src/Scratch (netcore)/02 - OpcDemo/paket.references b/src/Scratch (netcore)/02 - OpcDemo/paket.references index 0e6b13da4..72e564234 100644 --- a/src/Scratch (netcore)/02 - OpcDemo/paket.references +++ b/src/Scratch (netcore)/02 - OpcDemo/paket.references @@ -1,5 +1,6 @@ Aardvark.Base.Essentials Aardvark.Base.Incremental +Aardvark.Data.Opc AssimpNet FShade.Core