From 8389d75f52b32c8c2e8e9d7c30778ae143d80111 Mon Sep 17 00:00:00 2001 From: aszabo314 Date: Wed, 29 Nov 2023 15:31:59 +0100 Subject: [PATCH] ScratchFsharp --- src/Aardvark.Algodat.sln | 9 ++- src/Apps/ScratchFSharp/Program.fs | 90 +++++++++++++++++++++ src/Apps/ScratchFSharp/ScratchFSharp.fsproj | 16 ++++ src/Apps/ScratchFSharp/paket.references | 3 + 4 files changed, 117 insertions(+), 1 deletion(-) create mode 100644 src/Apps/ScratchFSharp/Program.fs create mode 100644 src/Apps/ScratchFSharp/ScratchFSharp.fsproj create mode 100644 src/Apps/ScratchFSharp/paket.references diff --git a/src/Aardvark.Algodat.sln b/src/Aardvark.Algodat.sln index 619ed5d2..f46776aa 100644 --- a/src/Aardvark.Algodat.sln +++ b/src/Aardvark.Algodat.sln @@ -79,6 +79,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Unofficial.laszip.netstanda EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "import", "import\import.csproj", "{000B3CDA-C67B-4F6A-B6F8-69A1B5052343}" EndProject +Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "ScratchFSharp", "Apps\ScratchFSharp\ScratchFSharp.fsproj", "{E5B3A633-A8F4-4D56-BB64-4A885E22B3B2}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -193,6 +195,10 @@ Global {000B3CDA-C67B-4F6A-B6F8-69A1B5052343}.Debug|Any CPU.Build.0 = Debug|Any CPU {000B3CDA-C67B-4F6A-B6F8-69A1B5052343}.Release|Any CPU.ActiveCfg = Release|Any CPU {000B3CDA-C67B-4F6A-B6F8-69A1B5052343}.Release|Any CPU.Build.0 = Release|Any CPU + {E5B3A633-A8F4-4D56-BB64-4A885E22B3B2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E5B3A633-A8F4-4D56-BB64-4A885E22B3B2}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E5B3A633-A8F4-4D56-BB64-4A885E22B3B2}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E5B3A633-A8F4-4D56-BB64-4A885E22B3B2}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -205,9 +211,10 @@ Global {85F64ED4-AAA6-4EEF-BC97-ED5E65839FD7} = {6CA9BC7A-0123-43E9-A26B-5FF0B9E01B08} {5CA8E4F4-E30B-4FC8-A510-A0FFD8A9880B} = {6CA9BC7A-0123-43E9-A26B-5FF0B9E01B08} {000B3CDA-C67B-4F6A-B6F8-69A1B5052343} = {6CA9BC7A-0123-43E9-A26B-5FF0B9E01B08} + {E5B3A633-A8F4-4D56-BB64-4A885E22B3B2} = {6CA9BC7A-0123-43E9-A26B-5FF0B9E01B08} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {E996B5E6-49B2-4479-9DDE-455A40509F43} EnterpriseLibraryConfigurationToolBinariesPathV6 = packages\EnterpriseLibrary.TransientFaultHandling.6.0.1304.0\lib\portable-net45+win+wp8;packages\EnterpriseLibrary.TransientFaultHandling.Data.6.0.1304.1\lib\NET45 + SolutionGuid = {E996B5E6-49B2-4479-9DDE-455A40509F43} EndGlobalSection EndGlobal diff --git a/src/Apps/ScratchFSharp/Program.fs b/src/Apps/ScratchFSharp/Program.fs new file mode 100644 index 00000000..69ed1124 --- /dev/null +++ b/src/Apps/ScratchFSharp/Program.fs @@ -0,0 +1,90 @@ +namespace ScratchFSharp + +open System +open System.IO +open Aardvark.Base +open Aardvark.Data.Points +open Aardvark.Geometry.Points + +module Bla = + [] + let main a = + //let b = Box3d.Unit + //let o = V3d.III*0.5 + //let d = V3d.IOO + //let r = Ray3d(o+999.0*d,-d) + //let rf = FastRay3d(o,d) + //let mutable t = 0.0 + //let mutable tMin = 0.0 + //let mutable tMax = 0.0 + //let i = b.Intersects(r,&t) + //let i2 = rf.Intersects(b,&tMin,&tMax) + //Log.line "%A %A %A %A %A" i2 i t tMin tMax + + + + let storePath = @"C:\bla\store\teststore\data.uds" + let key = "3d9654b1-c37a-4d41-ba83-393d58a9bdce" + + let bounds = Box3d(V3d.III*2.0, V3d.III*20.0) + let rnd = RandomSystem() + + let rec genPoints loc = + let mutable phi = 0.0 + let mutable theta = 0.0 + let dPhi = 1.0 * Constant.RadiansPerDegree + let dTheta = 1.1 * Constant.RadiansPerDegree + let ps = System.Collections.Generic.List() + while phi < Constant.PiTimesTwo do + theta <- 0.0 + while theta < Constant.PiTimesTwo do + let d = V2d(phi,theta).CartesianFromSpherical() + let r = Ray3d(loc+999.0*d,-d) + let mutable t = 0.0 + if bounds.Intersects(r,&t) then + let p = r.GetPointOnRay(t) + ps.Add p |> ignore + theta <- theta+dTheta + phi <- phi+dPhi + ps |> CSharpList.toArray + + let locations = Array.init 5 (fun _ -> rnd.UniformV3d(Box3d.FromCenterAndSize(bounds.Center,bounds.Size*0.8))) + + let chunks = + locations |> Array.mapi (fun i loc -> + let pts = genPoints loc + Chunk(pts,null,null,null,null,i,Range1i(i),bounds) + ) + + let store = + new Uncodium.SimpleStore.SimpleDiskStore(storePath,System.Action<_>(fun ss -> ss |> Array.iter (printfn "%A"))) + + let add = + Action>(fun (name : string) (value : obj) (create : Func) -> store.Add(name, create.Invoke())) + let get s = store.Get s + let getSlice k o i = store.GetSlice(k,o,i) + let remove k = store.Remove k + let dispose() = store.Dispose() + let flush() = store.Flush() + let dict = LruDictionary(1<<<30) + let storage = + new Storage( + add, + get, + getSlice, + remove, + dispose, + flush, + dict + ) + + let config = + ImportConfig.Default + .WithStorage(storage) + .WithKey(key) + .WithOctreeSplitLimit(8192) + + let pc = PointCloud.Chunks(chunks,config) + File.WriteAllText(Path.Combine(Path.GetDirectoryName(storePath),"key.txt"),key) + Log.line "done %A %A" pc.PointCount pc.Id + 0 \ No newline at end of file diff --git a/src/Apps/ScratchFSharp/ScratchFSharp.fsproj b/src/Apps/ScratchFSharp/ScratchFSharp.fsproj new file mode 100644 index 00000000..8669595a --- /dev/null +++ b/src/Apps/ScratchFSharp/ScratchFSharp.fsproj @@ -0,0 +1,16 @@ + + + + Exe + net6.0 + + + + + + + + + + + \ No newline at end of file diff --git a/src/Apps/ScratchFSharp/paket.references b/src/Apps/ScratchFSharp/paket.references new file mode 100644 index 00000000..cbf8092b --- /dev/null +++ b/src/Apps/ScratchFSharp/paket.references @@ -0,0 +1,3 @@ +Aardvark.Build +Aardvark.Application.Utilities +FSharp.Core \ No newline at end of file