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

Added intersectSurface to NaifDskShape so the intercept point would b… #4997

Merged
merged 5 commits into from
Jul 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ release.
- Fixed CNetCombinePt logging functionality such that only merged points are included in the log. [#4973](https://github.com/USGS-Astrogeology/ISIS3/issues/4973)
- Removed SpkCenterId functions in Cassini camera models due to spkwriter writing positions of Cassini relative to Titan but labeling
it in the kernel as the position relative to the Saturn Barycenter. [#4942](https://github.com/USGS-Astrogeology/ISIS3/issues/4942)
- Corrected issue where footprintinit would fail with a segmentation error. [4943](https://github.com/USGS-Astrogeology/ISIS3/issues/4943)


## [7.0.0] - 2022-02-11
Expand Down
41 changes: 39 additions & 2 deletions isis/src/base/objs/NaifDskShape/NaifDskShape.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ namespace Isis {
setName("DSK");
}


/**
* @brief Constructor provided for instantiation from an ISIS cube
*
Expand Down Expand Up @@ -85,6 +86,7 @@ namespace Isis {

}


/**
* @brief Constructor for creating new shape model from the same DSK file
*
Expand Down Expand Up @@ -144,6 +146,37 @@ namespace Isis {
return ( success );
}


/**
* @brief Compute surface intersection with optional occlusion check
*
* This method sets the surface point at the given latitude, longitude. The
* derived model is called to get the radius at that location to complete the
* accuracy of the surface point, them the derived method is called to complete
* the intersection.
*
* @author 2022-07-14 Stuart Sides, Jesse Mapel
*
* @param surfpt Absolute point on the surface to check
* @param observerPos Position of the observer
* @param backCheck Flag to indicate occlusion check
*
* @return bool True if the intersection point is valid (visable)
*/
bool NaifDskShape::intersectSurface(const SurfacePoint &surfpt,
const std::vector<double> &observerPos,
const bool &backCheck) {

std::vector<double> look(3);
look[0] = surfpt.GetX().kilometers() - observerPos[0];
look[1] = surfpt.GetY().kilometers() - observerPos[1];
look[2] = surfpt.GetZ().kilometers() - observerPos[2];

return intersectSurface(observerPos, look);

}


/**
* @brief Determine DEM radius at a given lat/lon grid point
*
Expand All @@ -167,6 +200,7 @@ namespace Isis {
return (Distance());
}


/**
* @brief Set the normal vector to the intercept point normal
*
Expand Down Expand Up @@ -229,7 +263,6 @@ namespace Isis {
* @param neighborPoints Input body-fixed points to compute normal for
*/
void NaifDskShape::calculateLocalNormal(QVector<double *> neighborPoints) {

// Sanity check
if ( !hasIntersection() ) { // hasIntersection() <==> !m_intercept.isNull()
QString mess = "Intercept point does not exist - cannot provide normal vector";
Expand All @@ -247,13 +280,15 @@ namespace Isis {
calculateSurfaceNormal();
}


/** Return the surface normal of the ellipsi=oud */
void NaifDskShape::calculateSurfaceNormal() {
// ShapeModel (parent class) throws error if no intersection
setNormal(ellipsoidNormal().toStdVector());// this takes care of setHasNormal(true);
return;
}


/**
* @brief Compute the true surface normal vector of an ellipsoid
*
Expand Down Expand Up @@ -300,11 +335,13 @@ namespace Isis {
return (norm);
}


/** Returns a direct reference to the DSK plate model file interface */
const NaifDskPlateModel &NaifDskShape::model() const {
return (m_model);
}


/**
* @brief Returns a pointer to the current intercept
*
Expand All @@ -321,4 +358,4 @@ namespace Isis {
return ( m_intercept.data() );
}

}; // namespace Isis
}; // namespace Isis
5 changes: 5 additions & 0 deletions isis/src/base/objs/NaifDskShape/NaifDskShape.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ namespace Isis {
bool intersectSurface(std::vector<double> observerPos,
std::vector<double> lookDirection);

bool intersectSurface(const SurfacePoint &surfpt,
const std::vector<double> &observerPos,
const bool &backCheck=true);

// Calculate the default normal of the current intersection point
void calculateDefaultNormal();

Expand All @@ -73,6 +77,7 @@ namespace Isis {
const NaifDskPlateModel &model() const;
const Intercept *intercept() const;


private:
// Disallow copying because ShapeModel is not copyable
NaifDskShape(const NaifDskShape &model);
Expand Down
6 changes: 5 additions & 1 deletion isis/src/base/objs/NaifDskShape/NaifDskShape.truth
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ Intersection successful? "No"
Construct NaifDskShape object from cube labels with ShapeModel=DSK file.
Try to intersect surface at obsPos (0,0,1000) and lookDir (0,-1,-1)
Intersection successful? "No"
Try to intersect surface at obsPos (1000,0,0) and lookDir (-1,0,0)
Intercept X = 0.28911
Intercept Y = 0
Intercept Z = 0
Intersection successful? "Yes"

Construct NaifDskShape object from cube labels with ElevationModel=DSK file.
Try to intersect surface at obsPos (1000,0,0) and lookDir (-1,0,0)
Expand Down Expand Up @@ -49,7 +54,6 @@ Construct NaifDskShape object from cube labels with ShapeModel=Null.
**USER ERROR** NAIF DSK file [Null] does not exist.

Thrown by setLocalNormalFromIntercept() - Failed to find intercept.
**PROGRAMMER ERROR** Intercept point does not exist - cannot provide normal vector.

Thrown by calculateLocalNormal() - Failed to find intercept for normal vector.
**PROGRAMMER ERROR** Intercept point does not exist - cannot provide normal vector.
Expand Down
17 changes: 16 additions & 1 deletion isis/src/base/objs/NaifDskShape/unitTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ find files of those names at the top level of this repository. **/

#include "Angle.h"
#include "Cube.h"
#include "Displacement.h"
#include "Distance.h"
#include "FileName.h"
#include "IException.h"
Expand Down Expand Up @@ -80,6 +81,21 @@ int main(int argc, char *argv[]) {
success = shapeModelFromPvlShape.intersectSurface(obsPos, lookDir);
qDebug() << "Intersection successful? " << toString(success);

qDebug() << "Try to intersect surface at obsPos (1000,0,0) and ground point (1,0,0)";
Displacement x(1.0, Displacement::Meters);
Displacement y(0.0, Displacement::Meters);
Displacement z(0.0, Displacement::Meters);
SurfacePoint SurfPt(x, y, z);
obsPos[0] = 1000.0; obsPos[1] = 0.0; obsPos[2] = 0.0;
success = shapeModelFromPvlShape.intersectSurface(SurfPt, obsPos);
if (success) {
SurfacePoint *point = shapeModelFromPvlShape.surfaceIntersection();
qDebug() << "Intercept X = " << point->DisplacementToDouble(point->GetX(), SurfacePoint::Kilometers);
qDebug() << "Intercept Y = " << point->DisplacementToDouble(point->GetY(), SurfacePoint::Kilometers);
qDebug() << "Intercept Z = " << point->DisplacementToDouble(point->GetZ(), SurfacePoint::Kilometers);
}
qDebug() << "Intersection successful? " << toString(success);

qDebug() << "";
qDebug() << "Construct NaifDskShape object from cube labels with ElevationModel=DSK file.";
Pvl pvlWithElevation("./st_2530292409_v_DskElevationModel.lbl");
Expand Down Expand Up @@ -161,7 +177,6 @@ int main(int argc, char *argv[]) {
<< QVector<double>::fromStdVector(shapeModelFromPvlElevation.normal());
qDebug() << "";


qDebug() << "================================= Error Throws ==================================";
qDebug() << "Construct NaifDskShape object from cube labels with ShapeModel=Null.";
try {
Expand Down