From 0521e1cc06e564c21df7c957b61c51c92c2ba114 Mon Sep 17 00:00:00 2001 From: Jesse Mapel Date: Thu, 24 Jun 2021 11:19:16 -0700 Subject: [PATCH] Changed csm camera to save look on non-intersection --- isis/src/base/objs/CSMCamera/CSMCamera.cpp | 18 +++++++++++------- isis/tests/CSMCameraTests.cpp | 12 ++++++++++++ 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/isis/src/base/objs/CSMCamera/CSMCamera.cpp b/isis/src/base/objs/CSMCamera/CSMCamera.cpp index 5c0d3e6a60..dbe20dce35 100644 --- a/isis/src/base/objs/CSMCamera/CSMCamera.cpp +++ b/isis/src/base/objs/CSMCamera/CSMCamera.cpp @@ -121,11 +121,14 @@ namespace Isis { * @returns @b bool If the image coordinate was set successfully */ bool CSMCamera::SetImage(const double sample, const double line) { + // Save off the line & sample + p_childSample = sample; + p_childLine = line; + csm::ImageCoord imagePt; isisToCsmPixel(p_alphaCube->AlphaLine(line), p_alphaCube->AlphaSample(sample), imagePt); double achievedPrecision = 0; csm::WarningList warnings; - csm::EcefLocus imageLocus; try { imageLocus = m_model->imageToRemoteImagingLocus(imagePt, @@ -156,18 +159,19 @@ namespace Isis { std::vector locusVec = {imageLocus.direction.x, imageLocus.direction.y, imageLocus.direction.z}; - if(!target()->shape()->intersectSurface(obsPosition, locusVec)) { - return false; - } - // If we are here then everything went well so save the pixel and return true + // Save off the look vector m_lookB[0] = locusVec[0]; m_lookB[1] = locusVec[1]; m_lookB[2] = locusVec[2]; m_newLookB = true; + + // Check for a ground intersection + if(!target()->shape()->intersectSurface(obsPosition, locusVec)) { + return false; + } + p_pointComputed = true; - p_childSample = sample; - p_childLine = line; if (!m_et) { m_et = new iTime(); } diff --git a/isis/tests/CSMCameraTests.cpp b/isis/tests/CSMCameraTests.cpp index 4948b43f78..1d57ef6025 100644 --- a/isis/tests/CSMCameraTests.cpp +++ b/isis/tests/CSMCameraTests.cpp @@ -44,6 +44,18 @@ TEST_F(CSMCameraFixture, SetImage) { } +TEST_F(CSMCameraFixture, SetImageNoIntersect) { + csm::Ellipsoid wgs84; + EXPECT_CALL(mockModel, imageToRemoteImagingLocus(MatchImageCoord(csm::ImageCoord(4.5, 4.5)), ::testing::_, ::testing::_, ::testing::_)) + .Times(1) + // looking straight down X-Axis + .WillOnce(::testing::Return(csm::EcefLocus(wgs84.getSemiMajorRadius() + 50000, 0, 0, 0, 1, 0))); + + EXPECT_FALSE(testCam->SetImage(5, 5)); + EXPECT_THAT(testCam->lookDirectionBodyFixed(), ::testing::ElementsAre(0.0, 1.0, 0.0)); +} + + TEST_F(CSMCameraDemFixture, SetImage) { EXPECT_CALL(mockModel, imageToRemoteImagingLocus(MatchImageCoord(csm::ImageCoord(4.5, 4.5)), ::testing::_, ::testing::_, ::testing::_)) .Times(1)