92 lines
3.7 KiB
C#
92 lines
3.7 KiB
C#
using Autodesk.Navisworks.Api;
|
|
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
|
using NavisworksTransport.Core.Animation;
|
|
using NavisworksTransport.Utils.CoordinateSystem;
|
|
|
|
namespace NavisworksTransport.UnitTests.CoordinateSystem
|
|
{
|
|
[TestClass]
|
|
public class RailPreservedPoseTests
|
|
{
|
|
[TestMethod]
|
|
public void ResolvePreservedPoseRotation_ShouldPreferActualGeometryRotationForRealObjects()
|
|
{
|
|
Rotation3D fallbackRotation = new Rotation3D(0.0, 0.0, 0.0, 1.0);
|
|
Rotation3D actualGeometryRotation = new Rotation3D(0.0, 0.70710678, 0.0, 0.70710678);
|
|
|
|
Rotation3D resolved = PathAnimationManager.ResolvePreservedPoseRotation(
|
|
preferActualGeometryRotation: true,
|
|
hasActualGeometryRotation: true,
|
|
actualGeometryRotation: actualGeometryRotation,
|
|
fallbackRotation: fallbackRotation);
|
|
|
|
Assert.AreEqual(actualGeometryRotation.A, resolved.A, 1e-9);
|
|
Assert.AreEqual(actualGeometryRotation.B, resolved.B, 1e-9);
|
|
Assert.AreEqual(actualGeometryRotation.C, resolved.C, 1e-9);
|
|
Assert.AreEqual(actualGeometryRotation.D, resolved.D, 1e-9);
|
|
}
|
|
|
|
[TestMethod]
|
|
public void ResolvePreservedPoseRotation_ShouldFallbackWhenActualGeometryRotationUnavailable()
|
|
{
|
|
Rotation3D fallbackRotation = new Rotation3D(0.0, 0.0, 0.38268343, 0.92387953);
|
|
Rotation3D actualGeometryRotation = new Rotation3D(0.0, 0.70710678, 0.0, 0.70710678);
|
|
|
|
Rotation3D resolved = PathAnimationManager.ResolvePreservedPoseRotation(
|
|
preferActualGeometryRotation: true,
|
|
hasActualGeometryRotation: false,
|
|
actualGeometryRotation: actualGeometryRotation,
|
|
fallbackRotation: fallbackRotation);
|
|
|
|
Assert.AreEqual(fallbackRotation.A, resolved.A, 1e-9);
|
|
Assert.AreEqual(fallbackRotation.B, resolved.B, 1e-9);
|
|
Assert.AreEqual(fallbackRotation.C, resolved.C, 1e-9);
|
|
Assert.AreEqual(fallbackRotation.D, resolved.D, 1e-9);
|
|
}
|
|
|
|
[TestMethod]
|
|
public void ShouldPreservePathRotationForFrames_ShouldEnableHoistingWhenTranslationModeHasLockedRotation()
|
|
{
|
|
bool shouldPreserve = PathAnimationManager.ShouldPreservePathRotationForFrames(
|
|
PathType.Hoisting,
|
|
ObjectStartPlacementMode.PreserveInitialPose,
|
|
hasPreservedRotation: true);
|
|
|
|
Assert.IsTrue(shouldPreserve);
|
|
}
|
|
|
|
[TestMethod]
|
|
public void ShouldPreservePathRotationForFrames_ShouldEnableRailWhenTranslationModeHasLockedRotation()
|
|
{
|
|
bool shouldPreserve = PathAnimationManager.ShouldPreservePathRotationForFrames(
|
|
PathType.Rail,
|
|
ObjectStartPlacementMode.PreserveInitialPose,
|
|
hasPreservedRotation: true);
|
|
|
|
Assert.IsTrue(shouldPreserve);
|
|
}
|
|
|
|
[TestMethod]
|
|
public void ShouldPreservePathRotationForFrames_ShouldDisableGroundEvenInTranslationMode()
|
|
{
|
|
bool shouldPreserve = PathAnimationManager.ShouldPreservePathRotationForFrames(
|
|
PathType.Ground,
|
|
ObjectStartPlacementMode.PreserveInitialPose,
|
|
hasPreservedRotation: true);
|
|
|
|
Assert.IsFalse(shouldPreserve);
|
|
}
|
|
|
|
[TestMethod]
|
|
public void ShouldPreservePathRotationForFrames_ShouldDisableWhenLockedRotationMissing()
|
|
{
|
|
bool shouldPreserve = PathAnimationManager.ShouldPreservePathRotationForFrames(
|
|
PathType.Hoisting,
|
|
ObjectStartPlacementMode.PreserveInitialPose,
|
|
hasPreservedRotation: false);
|
|
|
|
Assert.IsFalse(shouldPreserve);
|
|
}
|
|
}
|
|
}
|