Skip to content

Commit

Permalink
ScratchFsharp
Browse files Browse the repository at this point in the history
  • Loading branch information
aszabo314 committed Nov 29, 2023
1 parent aa5115e commit 8389d75
Show file tree
Hide file tree
Showing 4 changed files with 117 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/Aardvark.Algodat.sln
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
90 changes: 90 additions & 0 deletions src/Apps/ScratchFSharp/Program.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
namespace ScratchFSharp

open System
open System.IO
open Aardvark.Base
open Aardvark.Data.Points
open Aardvark.Geometry.Points

module Bla =
[<EntryPoint>]
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<string,obj,Func<byte[]>>(fun (name : string) (value : obj) (create : Func<byte[]>) -> 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
16 changes: 16 additions & 0 deletions src/Apps/ScratchFSharp/ScratchFSharp.fsproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<Compile Include="Program.fs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\Aardvark.Data.E57\Aardvark.Data.E57.csproj" />
<ProjectReference Include="..\..\Aardvark.Data.Points.Base\Aardvark.Data.Points.Base.csproj" />
<ProjectReference Include="..\..\Aardvark.Rendering.PointSet\Aardvark.Rendering.PointSet.fsproj" />
</ItemGroup>
<Import Project="..\..\..\.paket\Paket.Restore.targets" />
</Project>
3 changes: 3 additions & 0 deletions src/Apps/ScratchFSharp/paket.references
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Aardvark.Build
Aardvark.Application.Utilities
FSharp.Core

0 comments on commit 8389d75

Please sign in to comment.