Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reimplemented lod-metric #483

Open
wants to merge 17 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Build.fs
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@
res
*)

let aardiumVersion = "2.0.5"
let aardiumVersion = "2.1.1"
//let versions = getInstalledPackageVersions()
//match Map.tryFind "Aardium" versions with
//| Some v -> v
Expand All @@ -248,7 +248,7 @@
let url = sprintf "https://www.nuget.org/api/v2/package/Aardium-Win32-x64/%s" aardiumVersion
printf "url: %s" url
let tempFile = Path.GetTempFileName()
use c = new System.Net.WebClient()

Check warning on line 251 in Build.fs

View workflow job for this annotation

GitHub Actions / build

This construct is deprecated. WebRequest, HttpWebRequest, ServicePoint, and WebClient are obsolete. Use HttpClient instead.

Check warning on line 251 in Build.fs

View workflow job for this annotation

GitHub Actions / build

This construct is deprecated. WebRequest, HttpWebRequest, ServicePoint, and WebClient are obsolete. Use HttpClient instead.

Check warning on line 251 in Build.fs

View workflow job for this annotation

GitHub Actions / build

This construct is deprecated. WebRequest, HttpWebRequest, ServicePoint, and WebClient are obsolete. Use HttpClient instead.

Check warning on line 251 in Build.fs

View workflow job for this annotation

GitHub Actions / build

This construct is deprecated. WebRequest, HttpWebRequest, ServicePoint, and WebClient are obsolete. Use HttpClient instead.

Check warning on line 251 in Build.fs

View workflow job for this annotation

GitHub Actions / build

This construct is deprecated. WebRequest, HttpWebRequest, ServicePoint, and WebClient are obsolete. Use HttpClient instead.

Check warning on line 251 in Build.fs

View workflow job for this annotation

GitHub Actions / build

This construct is deprecated. WebRequest, HttpWebRequest, ServicePoint, and WebClient are obsolete. Use HttpClient instead.

Check warning on line 251 in Build.fs

View workflow job for this annotation

GitHub Actions / windows

This construct is deprecated. WebRequest, HttpWebRequest, ServicePoint, and WebClient are obsolete. Use HttpClient instead.
c.DownloadFile(url, tempFile)
use a = new ZipArchive(File.OpenRead tempFile)
let t = Path.GetTempPath()
Expand Down Expand Up @@ -433,7 +433,7 @@
}
)

// snapshots
//// snapshots
"src/PRo3D.Snapshots/PRo3D.Snapshots.fsproj" |> DotNet.publish (fun o ->
{ o with
Framework = Some "net6.0"
Expand Down Expand Up @@ -486,7 +486,7 @@
let url = sprintf "https://www.nuget.org/api/v2/package/Aardium-Win32-x64/%s" aardiumVersion
printf "url: %s" url
let tempFile = Path.GetTempFileName()
use c = new System.Net.WebClient()

Check warning on line 489 in Build.fs

View workflow job for this annotation

GitHub Actions / build

This construct is deprecated. WebRequest, HttpWebRequest, ServicePoint, and WebClient are obsolete. Use HttpClient instead.

Check warning on line 489 in Build.fs

View workflow job for this annotation

GitHub Actions / build

This construct is deprecated. WebRequest, HttpWebRequest, ServicePoint, and WebClient are obsolete. Use HttpClient instead.

Check warning on line 489 in Build.fs

View workflow job for this annotation

GitHub Actions / build

This construct is deprecated. WebRequest, HttpWebRequest, ServicePoint, and WebClient are obsolete. Use HttpClient instead.

Check warning on line 489 in Build.fs

View workflow job for this annotation

GitHub Actions / build

This construct is deprecated. WebRequest, HttpWebRequest, ServicePoint, and WebClient are obsolete. Use HttpClient instead.

Check warning on line 489 in Build.fs

View workflow job for this annotation

GitHub Actions / build

This construct is deprecated. WebRequest, HttpWebRequest, ServicePoint, and WebClient are obsolete. Use HttpClient instead.

Check warning on line 489 in Build.fs

View workflow job for this annotation

GitHub Actions / build

This construct is deprecated. WebRequest, HttpWebRequest, ServicePoint, and WebClient are obsolete. Use HttpClient instead.

Check warning on line 489 in Build.fs

View workflow job for this annotation

GitHub Actions / windows

This construct is deprecated. WebRequest, HttpWebRequest, ServicePoint, and WebClient are obsolete. Use HttpClient instead.
c.DownloadFile(url, tempFile)
use a = new ZipArchive(File.OpenRead tempFile)
let t = Path.GetTempPath()
Expand All @@ -496,7 +496,7 @@
Shell.copyDir (Path.Combine(target, "mac-x64", "tools")) (Path.Combine(tempPath, "tools")) (fun _ -> true)
Shell.copyDir (Path.Combine(target, "win-x64", "tools")) (Path.Combine(tempPath, "tools")) (fun _ -> true)

File.Move("bin/publish/win-x64/PRo3D.Viewer.exe", sprintf "bin/publish/win-x64/PRo3D.Viewer.%s.exe" notes.NugetVersion)
//File.Move("bin/publish/win-x64/PRo3D.Viewer.exe", sprintf "bin/publish/win-x64/PRo3D.Viewer.%s.exe" notes.NugetVersion)
)

"Credits" ==> "Publish" |> ignore
Expand Down
16 changes: 16 additions & 0 deletions TEST_RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
## 4.27.0-prerelease5
- fixed screenshot functionality

## 4.27.0-prerelease4
- reverted polynomial distance decay for lod.

## 4.27.0-prerelease3
- fixed wrong picking when using pivot based transformations

## 4.27.0-prerelease2
- fixed lod when switching surfaces visible/invisible (keep invisible opcs in lod, to make fast switching possible)

## 4.27.0-prerelease1
- coordinate frames as scale bars
- fixed memory leak for high focal length fulcra

## 4.26.0-prerelease2
- fixed surface priority
- improved handling of large trajectories
Expand Down
Binary file modified lib/JR.Wrappers.dll
Binary file not shown.
93 changes: 47 additions & 46 deletions src/OpcViewer/Program.fs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ type Kind = Scene | Annotations | Solarsystem
[<EntryPoint>]
let main argv =

let kind = Scene
let kind = Annotations

let shaler =
{
Expand Down Expand Up @@ -93,7 +93,7 @@ let main argv =
preTransform = Trafo3d.Identity
patchHierarchies =
Seq.delay (fun _ ->
System.IO.Directory.GetDirectories(@"I:\OPC\Shaler_OPCs_2019\Shaler_Navcam")
System.IO.Directory.GetDirectories(@"C:\pro3ddata\Shaler_OPCs_2019\Shaler_Navcam")
|> Seq.collect System.IO.Directory.GetDirectories
)
boundingBox = Box3d.Parse("[[-2490137.664354247, 2285874.562728135, -271408.476700304], [-2490136.248131170, 2285875.658034266, -271406.605430601]]")
Expand All @@ -103,37 +103,37 @@ let main argv =
lodDecider = DefaultMetrics.mars2
}

let scene =
{
useCompressedTextures = true
preTransform = Trafo3d.Identity
patchHierarchies =
Seq.delay (fun _ ->
System.IO.Directory.GetDirectories(@"F:\pro3d\data\20200220_DinosaurQuarry2")
|> Seq.collect System.IO.Directory.GetDirectories
)
boundingBox = Box3d.Parse("[[-15.699694740, 4.338130733, -0.514935397], [-4.960646670, 36.914955133, 5.004174588]]")
near = 0.1
far = 10000.0
speed = 5.0
lodDecider = DefaultMetrics.mars2
}
//let scene =
// {
// useCompressedTextures = true
// preTransform = Trafo3d.Identity
// patchHierarchies =
// Seq.delay (fun _ ->
// System.IO.Directory.GetDirectories(@"F:\pro3d\data\20200220_DinosaurQuarry2")
// |> Seq.collect System.IO.Directory.GetDirectories
// )
// boundingBox = Box3d.Parse("[[-15.699694740, 4.338130733, -0.514935397], [-4.960646670, 36.914955133, 5.004174588]]")
// near = 0.1
// far = 10000.0
// speed = 5.0
// lodDecider = DefaultMetrics.mars2
// }

let scene =
{
useCompressedTextures = true
preTransform = Trafo3d.Identity
patchHierarchies =
Seq.delay (fun _ ->
System.IO.Directory.GetDirectories(@"F:\pro3d\data\20200220_DinosaurQuarry2")
|> Seq.collect System.IO.Directory.GetDirectories
)
boundingBox = Box3d.Parse("[[-15.699694740, 4.338130733, -0.514935397], [-4.960646670, 36.914955133, 5.004174588]]")
near = 0.1
far = 10000.0
speed = 5.0
lodDecider = DefaultMetrics.mars2
}
//let scene =
// {
// useCompressedTextures = true
// preTransform = Trafo3d.Identity
// patchHierarchies =
// Seq.delay (fun _ ->
// System.IO.Directory.GetDirectories(@"F:\pro3d\data\20200220_DinosaurQuarry2")
// |> Seq.collect System.IO.Directory.GetDirectories
// )
// boundingBox = Box3d.Parse("[[-15.699694740, 4.338130733, -0.514935397], [-4.960646670, 36.914955133, 5.004174588]]")
// near = 0.1
// far = 10000.0
// speed = 5.0
// lodDecider = DefaultMetrics.mars2
// }

//let scene =
// {
Expand All @@ -149,20 +149,20 @@ let main argv =
// lodDecider = DefaultMetrics.mars2
// }

let scene =
{
useCompressedTextures = true
preTransform = Trafo3d.Identity
patchHierarchies =
Seq.delay (fun _ ->
System.IO.Directory.GetDirectories(@"F:\pro3d\data\OpcMcz")
)
boundingBox = Box3d.Parse("[[699507.902347501, 3142696.785742886, 1072717.259930025], [699508.165976587, 3142697.102699531, 1072717.505653937]]")
near = 0.1
far = 10000.0
speed = 5.0
lodDecider = DefaultMetrics.mars2
}
//let scene =
// {
// useCompressedTextures = true
// preTransform = Trafo3d.Identity
// patchHierarchies =
// Seq.delay (fun _ ->
// System.IO.Directory.GetDirectories(@"F:\pro3d\data\OpcMcz")
// )
// boundingBox = Box3d.Parse("[[699507.902347501, 3142696.785742886, 1072717.259930025], [699508.165976587, 3142697.102699531, 1072717.505653937]]")
// near = 0.1
// far = 10000.0
// speed = 5.0
// lodDecider = DefaultMetrics.mars2
// }

//let scene =
// {
Expand Down Expand Up @@ -202,6 +202,7 @@ let main argv =
//let annotations = @"F:\pro3d\data\OpcMcz\singleAnno.pro3d.ann"
let annotations = @"F:\pro3d\data\OpcMcz\blub.pro3d.ann"
let annotations = @"F:\pro3d\data\OpcMcz\notworking.pro3d.ann"
let annotations = @"C:\pro3ddata\Shaler_OPCs_2019\Shaler_v2_Mastcam_w_Navcam_v18_merged_measurementsV2.pro3d.ann"
//let annotations = @"F:\pro3d\data\OpcMcz\heavy.pro3d.ann"
//let annotations = @"F:\pro3d\data\dimorphos\singleanno.pro3d.ann"

Expand Down
8 changes: 6 additions & 2 deletions src/PRo3D.Base/OutlineEffect.fs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ module OutlineEffect =
}

// NOTE: sg MUST only hold pure Sg without any modes or shaders!
let createForSg (outlineGroup: int) (pass: RenderPass) (color: C4f) sg =
let createForSg' (lineWidth : aval<float>) (outlineGroup: int) (pass: RenderPass) (color: C4f) (sg : ISg<_>) =
let sg = sg |> Sg.uniform "Color" (AVal.constant color)

let mask =
Expand All @@ -79,7 +79,7 @@ module OutlineEffect =
|> Sg.blendMode (AVal.init BlendMode.Blend)
|> Sg.fillMode (AVal.init FillMode.Fill)
|> Sg.pass pass
|> Sg.uniform "LineWidth" (AVal.constant 5.0)
|> Sg.uniform "LineWidth" lineWidth
|> Sg.shader {
do! DefaultSurfaces.stableTrafo
do! Shader.lines
Expand All @@ -89,6 +89,10 @@ module OutlineEffect =
}

[ mask; outline ] |> Sg.ofList

// NOTE: sg MUST only hold pure Sg without any modes or shaders!
let createForSg (outlineGroup: int) (pass: RenderPass) (color: C4f) (sg : ISg<_>) =
createForSg' (AVal.constant 5.0) outlineGroup pass color sg

let createForLine
(points: aval<V3d[]>)
Expand Down
2 changes: 1 addition & 1 deletion src/PRo3D.Base/WebClientDeprecation.fs
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ module Helpers =
}

member x.DownloadFile(uri : string, filename : string) =
x.DownloadFileAsync(uri, filename).RunSynchronously()
x.DownloadFileAsync(uri, filename).Wait()
20 changes: 10 additions & 10 deletions src/PRo3D.Core/Drawing/Drawing-App.fs
Original file line number Diff line number Diff line change
Expand Up @@ -636,17 +636,17 @@ module DrawingApp =
pickingTolerance = msmallConfig.getPickingTolerance mbigConfig
}

let annoSet =
let labels =
model.annotations.flat
|> AMap.choose (fun _ y -> y |> tryToAnnotation) // TODO v5: here we collapsed some avals - check correctness
|> AMap.toASet

let labels =
annoSet
|> ASet.map(fun (_,a) ->
Sg.finishedAnnotationText a config view
)
|> Sg.set
|> AMap.toASetValues
|> ASet.chooseA (fun anno ->
match anno |> tryToAnnotation with
| None -> AVal.constant None
| Some v ->
Sg.shouldTextBeRendered v
|> AVal.map (function | true -> Some (Sg.drawText view config v) | _ -> None)
)
|> Sg.set

labels

Expand Down
23 changes: 6 additions & 17 deletions src/PRo3D.Core/Drawing/Drawing.Sg.fs
Original file line number Diff line number Diff line change
Expand Up @@ -413,15 +413,11 @@ module Sg =
dotsAndText
] |> optional anno.visible

let finishedAnnotationText
(anno : AdaptiveAnnotation)
(config : innerViewConfig)
(view : aval<CameraView>) =

anno.text
|> AVal.map3 (fun show visible text -> (String.IsNullOrEmpty text) || (show && visible) ) anno.showText anno.visible
|> optionalSet (drawText view config anno)
|> Sg.set

let shouldTextBeRendered (anno : AdaptiveAnnotation) =
(anno.text, anno.visible, anno.showText)
|||> AVal.map3 (fun text visible show -> show && visible && not (String.IsNullOrEmpty text))


let finishedAnnotation
(anno : AdaptiveAnnotation)
Expand All @@ -443,14 +439,7 @@ module Sg =
// anno.geometry
// config.offset
// )

let texts =
anno.text
|> AVal.map2 (fun show text -> (String.IsNullOrEmpty text) || show ) anno.showText
|> optionalSet (drawText view config anno)

let dotsAndText = texts |> Sg.set //ASet.union' [dots; texts] |> Sg.set


//let selectionColor = AVal.map2(fun x color -> if x then C4b.VRVisGreen else color) picked c
let pickingAllowed = // for this particular annotation // whether should fire pick actions
AVal.map2 (&&) pickingAllowed anno.visible
Expand Down
27 changes: 18 additions & 9 deletions src/PRo3D.Core/ScaleBars-Model.fs
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,12 @@ type scSegment with
do! Json.write "color" (x.color.ToString())
}

type ScaleRepresentation =
| ScaleBar = 0
| CoordinateFrame = 1

[<ModelType>]
type ScaleBar = {
type ScaleVisualization = {
version : int
guid : System.Guid
name : string
Expand All @@ -120,6 +124,8 @@ type ScaleBar = {
transformation : Transformations
preTransform : Trafo3d
//direction : V3d

representation : ScaleRepresentation
}

[<ModelType>]
Expand Down Expand Up @@ -175,6 +181,10 @@ module ScaleBar =

let orientation = orientation |> enum<Orientation>

let! representation =
Json.tryRead "representation"


//let! direction = Json.tryRead "direction"

return
Expand All @@ -200,14 +210,12 @@ module ScaleBar =
view = view
transformation = transformation
preTransform = preTransform |> Trafo3d.Parse
//direction = match direction with
// | Some d -> d |> V3d.Parse
// | None -> getDirectionVec orientation view
representation = representation |> Option.map enum<ScaleRepresentation> |> Option.defaultValue ScaleRepresentation.ScaleBar
}
}

type ScaleBar with
static member FromJson(_ : ScaleBar) =
type ScaleVisualization with
static member FromJson(_ : ScaleVisualization) =
json {
let! v = Json.read "version"
match v with
Expand All @@ -217,7 +225,7 @@ type ScaleBar with
|> sprintf "don't know version %A of ScaleBar"
|> Json.error
}
static member ToJson(x : ScaleBar) =
static member ToJson(x : ScaleVisualization) =
json {
do! Json.write "version" x.version
do! Json.write "guid" x.guid
Expand All @@ -242,14 +250,15 @@ type ScaleBar with
do! Json.write "view" camView
do! Json.write "transformation" x.transformation
do! Json.write "preTransform" (x.preTransform.ToString())
do! Json.write "representation" (int x.representation)
//do! Json.write "direction" (x.direction.ToString())
}


[<ModelType>]
type ScaleBarsModel = {
version : int
scaleBars : HashMap<Guid,ScaleBar>
scaleBars : HashMap<Guid,ScaleVisualization>
selectedScaleBar : Option<Guid>
}

Expand All @@ -259,7 +268,7 @@ module ScaleBarsModel =
let read0 =
json {
let! scaleBars = Json.read "scaleBars"
let scaleBars = scaleBars |> List.map(fun (a : ScaleBar) -> (a.guid, a)) |> HashMap.ofList
let scaleBars = scaleBars |> List.map(fun (a : ScaleVisualization) -> (a.guid, a)) |> HashMap.ofList

let! selected = Json.read "selectedScaleBar"
return
Expand Down
Loading
Loading