Skip to content

Commit

Permalink
[#40274] create viewpoint with infinite section boxes
Browse files Browse the repository at this point in the history
- https://community.openproject.org/work_packages/40274
- added new logic to derive center for clipping boxes with infinite
  values
  • Loading branch information
Kharonus committed Dec 10, 2021
1 parent e80e32e commit 9dbd6c8
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 7 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ in https://keepachangelog.com/en/1.0.0/. The versions follow [semantic versionin
- Pre-release versions now are correctly identified as older, when compared to the related release. I.e. when the
version `v2.3.1-beta17` is installed and the version `v2.3.1` is available, the update notification dialog is
displayed.
- Viewpoints with fewer than 6 clipping planes create section boxes with infinite values when applied to Revit. Creating
a viewpoint out of this state no longer produces an error, instead the clipping box center is derived of all available
finite values

## [2.3.3] - 2021-11-04

Expand Down
Binary file not shown.
20 changes: 19 additions & 1 deletion src/OpenProject.Shared/BcfApi/BcfApiExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public static List<Clipping_plane> ToClippingPlanes(
this AxisAlignedBoundingBox clippingBox,
Vector3 clippingCenter = null)
{
Vector3 center = clippingCenter ?? (clippingBox.Min + clippingBox.Max) * 0.5m;
Vector3 center = clippingCenter ?? DeriveClippingCenter(clippingBox.Min, clippingBox.Max);

var planes = new List<Clipping_plane>();

Expand Down Expand Up @@ -122,5 +122,23 @@ public static List<Clipping_plane> ToClippingPlanes(

return planes;
}

private static Vector3 DeriveClippingCenter(Vector3 min, Vector3 max) =>
new Vector3(
GetMeanUnlessInfinite(min.X, max.X),
GetMeanUnlessInfinite(min.Y, max.Y),
GetMeanUnlessInfinite(min.Z, max.Z)
);

private static decimal GetMeanUnlessInfinite(decimal a, decimal b)
{
if (a.IsFinite() && b.IsFinite())
return (a + b) * 0.5m;

if (a.IsFinite())
return a;

return b.IsFinite() ? b : 0;
}
}
}
12 changes: 6 additions & 6 deletions src/OpenProject.Shared/VersionsService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ namespace OpenProject.Shared
[System.CodeDom.Compiler.GeneratedCode("GitVersionBuild", "")]
public static class VersionsService
{
public static string Version => "2.3.3-beta0018";
public static string CommitInfo => "Branch.dev.Sha.d52a81904aad56d88abd4b2ad4d5969d350c52ae";
public static string CommitDate => "2021-11-03";
public static string CommitHash => "d52a81904aad56d88abd4b2ad4d5969d350c52ae";
public static string InformationalVersion => "2.3.3-beta.18+Branch.dev.Sha.d52a81904aad56d88abd4b2ad4d5969d350c52ae";
public static DateTime BuildDateUtc { get; } = new DateTime(2021, 11, 3, 14, 47, 10, DateTimeKind.Utc);
public static string Version => "2.3.4-beta0005";
public static string CommitInfo => "Branch.dev.Sha.e80e32e440760d08aa6e2582fef8c9d4a55a2f32";
public static string CommitDate => "2021-11-09";
public static string CommitHash => "e80e32e440760d08aa6e2582fef8c9d4a55a2f32";
public static string InformationalVersion => "2.3.4-beta.5+Branch.dev.Sha.e80e32e440760d08aa6e2582fef8c9d4a55a2f32";
public static DateTime BuildDateUtc { get; } = new DateTime(2021, 12, 9, 12, 50, 24, DateTimeKind.Utc);
}
}
14 changes: 14 additions & 0 deletions test/OpenProject.Tests/Shared/Math3D/BcfApiExtensionsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,20 @@ public static IEnumerable<object[]> DataForToClippingPlane()
}
};

yield return new object[]
{
new AxisAlignedBoundingBox(new Vector3(2, decimal.MinValue, decimal.MinValue), Vector3.InfiniteMax),
null,
new List<Clipping_plane>
{
new Clipping_plane
{
Direction = new Direction { X = -1, Y = 0, Z = 0 },
Location = new Location { X = 2, Y = 0, Z = 0 }
}
}
};

yield return new object[]
{
new AxisAlignedBoundingBox(Vector3.Zero, new Vector3(1, 1, 1)),
Expand Down

0 comments on commit 9dbd6c8

Please sign in to comment.