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 2 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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ release.
- Added check to determine if poles were a valid projection point in ImagePolygon when generating footprint for a map projected image. [#4390](https://github.com/USGS-Astrogeology/ISIS3/issues/4390)
- Updated the LRO photometry application Lronacpho, to use by default the current 2019 photometric model (LROC_Empirical). The model's coefficients are found in the PVL file that exists in the LRO data/mission/calibration directory. If the old parameter file is provided, the old algorithm(2014) will be used. This functionality is desired for calculation comparisons. Issue: [#4512](https://github.com/USGS-Astrogeology/ISIS3/issues/4512), PR: [#4519](https://github.com/USGS-Astrogeology/ISIS3/pull/4519)
- Added a new application, framestitch, for stitching even and odd push frame images back together prior to processing in other applications. [4924](https://github.com/USGS-Astrogeology/ISIS3/issues/4924)
- Corrected issue where footprintinit would fail with a segmentation error. [4943](https://github.com/USGS-Astrogeology/ISIS3/issues/4943)
- Added changes to lronaccal to use time-dependent dark files for dark correction and use of specific dark files for images with exp code of zero. Also added GTests for lronaccal and refactored code to make callable. Added 3 truth cubes to testing directory. PR[#4520](https://github.com/USGS-Astrogeology/ISIS3/pull/4520)

### Changed
- Updated the LRO calibration application Lrowaccal to add a units label to the RadiometricType keyword of the Radiometry group in the output cube label if the RadiometricType parameter is Radiance. No functionality is changed if the RadiometricType parameter is IOF. Lrowaccal has also been refactored to be callable for testing purposes. Issue: [#4939](https://github.com/USGS-Astrogeology/ISIS3/issues/4939), PR: [#4940](https://github.com/USGS-Astrogeology/ISIS3/pull/4940)

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
13 changes: 12 additions & 1 deletion isis/src/base/objs/NaifDskShape/unitTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,18 @@ 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 lookDir (-1,0,0)";
obsPos[0] = 1000.0; obsPos[1] = 0.0; obsPos[2] = 0.0;
lookDir[0] = -1.0; lookDir[1] = 0.0; lookDir[2] = 0.0;
success = shapeModelFromPvlShape.intersectSurface(obsPos, lookDir);
scsides marked this conversation as resolved.
Show resolved Hide resolved
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 +173,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