From d05606ac0c43ab1056042578171c44f2c2ef2f6b Mon Sep 17 00:00:00 2001 From: acpaquette Date: Thu, 16 Nov 2023 12:12:25 -0700 Subject: [PATCH 01/11] Adds local normal member variable to shapemodel --- .../BulletShapeModel/BulletShapeModel.cpp | 2 +- isis/src/base/objs/Camera/Camera.cpp | 4 +- isis/src/base/objs/DemShape/DemShape.cpp | 12 +-- .../objs/EllipsoidShape/EllipsoidShape.cpp | 4 +- .../base/objs/NaifDskShape/NaifDskShape.cpp | 6 +- isis/src/base/objs/ShapeModel/ShapeModel.cpp | 91 ++++++++++++++++++- isis/src/base/objs/ShapeModel/ShapeModel.h | 11 ++- 7 files changed, 112 insertions(+), 18 deletions(-) diff --git a/isis/src/base/objs/BulletShapeModel/BulletShapeModel.cpp b/isis/src/base/objs/BulletShapeModel/BulletShapeModel.cpp index 68e3a9866d..263f797a64 100644 --- a/isis/src/base/objs/BulletShapeModel/BulletShapeModel.cpp +++ b/isis/src/base/objs/BulletShapeModel/BulletShapeModel.cpp @@ -442,7 +442,7 @@ namespace Isis { } btVector3 normal = m_intercept.normal(); - setNormal(normal[0], normal[1], normal[2]); + setLocalNormal(normal[0], normal[1], normal[2]); } diff --git a/isis/src/base/objs/Camera/Camera.cpp b/isis/src/base/objs/Camera/Camera.cpp index edf22c4bba..7a5e571c74 100644 --- a/isis/src/base/objs/Camera/Camera.cpp +++ b/isis/src/base/objs/Camera/Camera.cpp @@ -1628,7 +1628,7 @@ namespace Isis { } // restore input state if calculation failed and clean up. - if (!shapeModel->hasNormal()) { + if (!shapeModel->hasLocalNormal()) { p_pointComputed = false; return; } @@ -1640,7 +1640,7 @@ namespace Isis { // Set the method normal values std::vector localNormal(3); - localNormal = shapeModel->normal(); + localNormal = shapeModel->localNormal(); memcpy(normal, (double *) &localNormal[0], sizeof(double) * 3); } diff --git a/isis/src/base/objs/DemShape/DemShape.cpp b/isis/src/base/objs/DemShape/DemShape.cpp index d6cc67d745..87b1b58f87 100644 --- a/isis/src/base/objs/DemShape/DemShape.cpp +++ b/isis/src/base/objs/DemShape/DemShape.cpp @@ -369,8 +369,8 @@ namespace Isis { std::vector normal(3); if (neighborPoints.isEmpty()) { normal[0] = normal[1] = normal[2] = 0.0; - setNormal(normal); - setHasNormal(false); + setLocalNormal(normal); + setHasLocalNormal(false); return; } @@ -389,12 +389,12 @@ namespace Isis { if (mag == 0.0) { normal[0] = normal[1] = normal[2] = 0.0; - setNormal(normal); - setHasNormal(false); + setLocalNormal(normal); + setHasLocalNormal(false); return; } else { - setHasNormal(true); + setHasLocalNormal(true); } // Check to make sure that the normal is pointing outward from the planet @@ -410,7 +410,7 @@ namespace Isis { vminus_c((SpiceDouble *) &normal[0], (SpiceDouble *) &normal[0]); } - setNormal(normal); + setLocalNormal(normal); } diff --git a/isis/src/base/objs/EllipsoidShape/EllipsoidShape.cpp b/isis/src/base/objs/EllipsoidShape/EllipsoidShape.cpp index 305fcd2741..1089fe42f0 100644 --- a/isis/src/base/objs/EllipsoidShape/EllipsoidShape.cpp +++ b/isis/src/base/objs/EllipsoidShape/EllipsoidShape.cpp @@ -129,8 +129,8 @@ namespace Isis { surfnm_c(a, b, c, pB, (SpiceDouble *) &normal[0]); NaifStatus::CheckErrors(); - setNormal(normal); - setHasNormal(true); + setLocalNormal(normal); + setHasLocalNormal(true); } diff --git a/isis/src/base/objs/NaifDskShape/NaifDskShape.cpp b/isis/src/base/objs/NaifDskShape/NaifDskShape.cpp index ef2ca901da..5bc2cd6e23 100755 --- a/isis/src/base/objs/NaifDskShape/NaifDskShape.cpp +++ b/isis/src/base/objs/NaifDskShape/NaifDskShape.cpp @@ -202,7 +202,7 @@ namespace Isis { /** - * @brief Set the normal vector to the intercept point normal + * @brief Set the local normal vector to the intercept point normal * * This method will reassign the ShapeModel normal to the current intecept point * shape (which is a triangular plate) normal. If an intercept point is not @@ -220,7 +220,7 @@ namespace Isis { // Got it, use the existing intercept point (plate) normal NaifVector norm(m_intercept->normal()); - setNormal(norm[0], norm[1], norm[2]); // this also takes care of setHasNormal(true); + setLocalNormal(norm[0], norm[1], norm[2]); // this also takes care of setHasLocalNormal(true); return; } @@ -281,7 +281,7 @@ namespace Isis { } - /** Return the surface normal of the ellipsi=oud */ + /** Return the surface normal of the ellipsoid */ void NaifDskShape::calculateSurfaceNormal() { // ShapeModel (parent class) throws error if no intersection setNormal(ellipsoidNormal().toStdVector());// this takes care of setHasNormal(true); diff --git a/isis/src/base/objs/ShapeModel/ShapeModel.cpp b/isis/src/base/objs/ShapeModel/ShapeModel.cpp index 7112177da5..04c3355e4f 100644 --- a/isis/src/base/objs/ShapeModel/ShapeModel.cpp +++ b/isis/src/base/objs/ShapeModel/ShapeModel.cpp @@ -232,7 +232,7 @@ namespace Isis { double ShapeModel::incidenceAngle(const std::vector &illuminatorBodyFixedPosition) { // Calculate the surface normal if we haven't yet. - if (!m_hasNormal) calculateDefaultNormal(); + if (!hasNormal()) calculateDefaultNormal(); // Get vector from center of body to surface point SpiceDouble pB[3]; @@ -380,6 +380,16 @@ namespace Isis { } + /** + * Returns surface point local normal status. + * + * @return @b Indicates whether this ShapeModel has a surface normal. + */ + bool ShapeModel::hasLocalNormal() const { + return m_hasLocalNormal; + } + + /** * Clears or resets the current surface point. */ @@ -390,7 +400,7 @@ namespace Isis { /** - * Returns the local surface normal at the current intersection point. + * Returns the surface normal at the current intersection point. * Note: This method will throw an error if the normal doesn't exist. Use the * hasNormal() method to verify before calling this method. * @@ -403,10 +413,28 @@ namespace Isis { return m_normal; } else { - QString message = "The local normal has not been computed."; + QString message = "The normal has not been computed."; throw IException(IException::Unknown, message, _FILEINFO_); } + } + /** + * Returns the local surface normal at the current intersection point. + * Note: This method will throw an error if the normal doesn't exist. Use the + * hasLocalNormal() method to verify before calling this method. + * + * @see hasLocalNormal() + * + * @return A local surface normal vector, if it exists. + */ + std::vector ShapeModel::localNormal() { + if (m_hasLocalNormal ) { + return m_localNormal; + } + else { + QString message = "The local normal has not been computed."; + throw IException(IException::Unknown, message, _FILEINFO_); + } } /** @@ -495,6 +523,28 @@ namespace Isis { } } + /** + * Sets the normal for the currect intersection point. + * Note: This method will throw an error if this ShapeModel doesn't have + * and intersection. Use the hasIntersection() method to verify before + * calling this method. + * + * @see hasIntersection() + * + * @param normal Three dimensional surface normal vector. + * + */ + void ShapeModel::setLocalNormal(const std::vector normal) { + if (m_hasIntersection) { + m_localNormal = normal; + m_hasLocalNormal = true; + } + else { + QString message = "No intersection point in known. A local normal can not be set."; + throw IException(IException::Unknown, message, _FILEINFO_); + } + } + /** * Sets the normal for the currect intersection point. @@ -522,6 +572,31 @@ namespace Isis { } } + /** + * Sets the normal for the currect intersection point. + * Note: This method will throw an error if this ShapeModel doesn't have and + * intersection. Use the hasIntersection() method to verify before calling + * this method. + * + * @see hasIntersection() + * + * @param a First coordinate value for the three dimensional surface normal. + * @param b Second coordinate value for the three dimensional surface normal. + * @param c Third coordinate value for the three dimensional surface normal. + * + */ + void ShapeModel::setLocalNormal(const double a, const double b, const double c) { + if (m_hasIntersection) { + m_localNormal[0] = a; + m_localNormal[1] = b; + m_localNormal[2] = c; + m_hasLocalNormal = true; + } + else { + QString message = "No intersection point in known. A local normal can not be set."; + throw IException(IException::Unknown, message, _FILEINFO_); + } + } /** * Sets the shape name. @@ -582,6 +657,16 @@ namespace Isis { m_hasNormal = status; } + /** + * Sets the flag to indicate whether this ShapeModel has a surface normal. + * + * @param b Indicates whether there is a normal. + * + */ + void ShapeModel::setHasLocalNormal(bool status) { + m_hasLocalNormal = status; + } + /** * Convenience method to get pixel resolution (m/pix) at current intersection diff --git a/isis/src/base/objs/ShapeModel/ShapeModel.h b/isis/src/base/objs/ShapeModel/ShapeModel.h index 991333c9d8..2a020ed71f 100644 --- a/isis/src/base/objs/ShapeModel/ShapeModel.h +++ b/isis/src/base/objs/ShapeModel/ShapeModel.h @@ -93,6 +93,7 @@ namespace Isis { bool hasIntersection(); bool hasNormal() const; + bool hasLocalNormal() const; // Calculate the default normal of the current intersection point virtual void calculateDefaultNormal() = 0; @@ -140,9 +141,12 @@ namespace Isis { // Set current surface point virtual void setSurfacePoint(const SurfacePoint &surfacePoint); - // Return the normal (surface or local) of the current intersection point + // Return the surface normal of the current intersection point virtual std::vector normal(); + // Return the local normal of the current intersection point + virtual std::vector localNormal(); + // Determine if the internal intercept is occluded from the observer/lookdir virtual bool isVisibleFrom(const std::vector observerPos, const std::vector lookDirection); @@ -152,6 +156,8 @@ namespace Isis { // Set the normal (surface or local) of the current intersection point void setNormal(const std::vector); void setNormal(const double a, const double b, const double c); + void setLocalNormal(const std::vector); + void setLocalNormal(const double a, const double b, const double c); // Set shape name void setName(QString name); @@ -165,13 +171,16 @@ namespace Isis { bool hasValidTarget() const; std::vector targetRadii() const; void setHasNormal(bool status); + void setHasLocalNormal(bool status); double resolution(); private: bool m_hasEllipsoidIntersection; //!< Indicates the ellipsoid was successfully intersected bool m_hasIntersection; //!< indicates good intersection exists bool m_hasNormal; //!< indicates normal has been computed + bool m_hasLocalNormal; //!< indicates normal has been computed std::vector m_normal; //!< Local normal of current intersection point + std::vector m_localNormal; //!< Local normal of current intersection point QString *m_name; //! < Name of the shape SurfacePoint *m_surfacePoint; //!< Current intersection point From dc983170d250f110a641a37c7c49eb0c6c8d7e77 Mon Sep 17 00:00:00 2001 From: acpaquette Date: Fri, 17 Nov 2023 14:41:11 -0700 Subject: [PATCH 02/11] Fixes variable initialization and sets local normal properly in bullet --- isis/src/base/objs/BulletShapeModel/BulletShapeModel.cpp | 4 ++-- isis/src/base/objs/ShapeModel/ShapeModel.cpp | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/isis/src/base/objs/BulletShapeModel/BulletShapeModel.cpp b/isis/src/base/objs/BulletShapeModel/BulletShapeModel.cpp index 263f797a64..a48e657918 100644 --- a/isis/src/base/objs/BulletShapeModel/BulletShapeModel.cpp +++ b/isis/src/base/objs/BulletShapeModel/BulletShapeModel.cpp @@ -719,11 +719,11 @@ namespace Isis { ShapeModel::setSurfacePoint( makeSurfacePoint(m_intercept.point()) ); // sets ShapeModel::m_hasIntersection=t, ShapeModel::m_hasNormal=f btVector3 normal = m_intercept.normal(); - setNormal(normal[0], normal[1], normal[2]); + setLocalNormal(normal[0], normal[1], normal[2]); } else { ShapeModel::clearSurfacePoint(); - setHasNormal(false); + setHasLocalNormal(false); } return; diff --git a/isis/src/base/objs/ShapeModel/ShapeModel.cpp b/isis/src/base/objs/ShapeModel/ShapeModel.cpp index 04c3355e4f..92aaffcd6f 100644 --- a/isis/src/base/objs/ShapeModel/ShapeModel.cpp +++ b/isis/src/base/objs/ShapeModel/ShapeModel.cpp @@ -67,7 +67,9 @@ namespace Isis { m_surfacePoint = new SurfacePoint(); m_hasIntersection = false; m_hasNormal = false; + m_hasLocalNormal = false; m_normal.resize(3,0.); + m_localNormal.resize(3, 0.); m_hasEllipsoidIntersection = false; } From 19733cdf5cc95f89d5ff4e3353baad6be5b74b70 Mon Sep 17 00:00:00 2001 From: acpaquette Date: Fri, 17 Nov 2023 14:41:35 -0700 Subject: [PATCH 03/11] Update tests and truth data --- isis/src/base/objs/BulletShapeModel/unitTest.cpp | 8 ++++---- isis/src/base/objs/NaifDskShape/unitTest.cpp | 8 ++++---- isis/src/base/objs/ShapeModel/ShapeModel.truth | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/isis/src/base/objs/BulletShapeModel/unitTest.cpp b/isis/src/base/objs/BulletShapeModel/unitTest.cpp index 9c11035b8d..5116679ae6 100644 --- a/isis/src/base/objs/BulletShapeModel/unitTest.cpp +++ b/isis/src/base/objs/BulletShapeModel/unitTest.cpp @@ -222,10 +222,10 @@ void outputModelStatus(BulletShapeModel &bulletModel) { << intersection->GetY().kilometers() << ", " << intersection->GetZ().kilometers() << ")"; } - qDebug() << "Model has normal? " << bulletModel.hasNormal(); + qDebug() << "Model has normal? " << bulletModel.hasLocalNormal(); std::vector normal; - if ( bulletModel.hasNormal() ) { - normal = bulletModel.normal(); + if ( bulletModel.hasLocalNormal() ) { + normal = bulletModel.localNormal(); qDebug() << " Local Normal: (" << normal[0] << ", " << normal[1] << ", " @@ -238,7 +238,7 @@ void outputModelStatus(BulletShapeModel &bulletModel) { << normal[1] << ", " << normal[2] << ")"; bulletModel.setLocalNormalFromIntercept(); - normal = bulletModel.normal(); + normal = bulletModel.localNormal(); qDebug() << " Recalculated Local Normal: (" << normal[0] << ", " << normal[1] << ", " diff --git a/isis/src/base/objs/NaifDskShape/unitTest.cpp b/isis/src/base/objs/NaifDskShape/unitTest.cpp index f3874961b8..c840c84ef9 100755 --- a/isis/src/base/objs/NaifDskShape/unitTest.cpp +++ b/isis/src/base/objs/NaifDskShape/unitTest.cpp @@ -157,9 +157,9 @@ int main(int argc, char *argv[]) { qDebug() << "Try to calculate norms using valid shape model..."; shapeModelFromPvlElevation.setLocalNormalFromIntercept(); - qDebug() << "Has intercept normal? " << shapeModelFromPvlElevation.hasNormal(); + qDebug() << "Has intercept normal? " << shapeModelFromPvlElevation.hasLocalNormal(); qDebug() << "Normal set from Intercept: " - << QVector::fromStdVector(shapeModelFromPvlElevation.normal()); + << QVector::fromStdVector(shapeModelFromPvlElevation.localNormal()); // no need to call calculateSurfaceNormal() or ellipsoidNormal() // directly. these methods are called by calculateDefaultNormal() shapeModelFromPvlElevation.calculateDefaultNormal(); @@ -172,9 +172,9 @@ int main(int argc, char *argv[]) { point[0] = 1.0; point[1] = 0.0; point[2] = 0.0; cornerNeighborPoints.push_back(point); shapeModelFromPvlElevation.calculateLocalNormal(cornerNeighborPoints); - qDebug() << "Has local normal? " << shapeModelFromPvlElevation.hasNormal(); + qDebug() << "Has local normal? " << shapeModelFromPvlElevation.hasLocalNormal(); qDebug() << "Local normal from neighbor points: " - << QVector::fromStdVector(shapeModelFromPvlElevation.normal()); + << QVector::fromStdVector(shapeModelFromPvlElevation.localNormal()); qDebug() << ""; qDebug() << "================================= Error Throws =================================="; diff --git a/isis/src/base/objs/ShapeModel/ShapeModel.truth b/isis/src/base/objs/ShapeModel/ShapeModel.truth index 2fb53500f2..3b72b85a81 100644 --- a/isis/src/base/objs/ShapeModel/ShapeModel.truth +++ b/isis/src/base/objs/ShapeModel/ShapeModel.truth @@ -21,7 +21,7 @@ Begin testing Shape Model base class.... Testing class method normal() when no normal exists... Do we have a normal? 0 -**ERROR** The local normal has not been computed. +**ERROR** The normal has not been computed. Testing photometric angle calculations before normal computation... Do we have a normal? 0 From 7b6a84b7b741ec9c89e1fca4c78b9e800549d8d9 Mon Sep 17 00:00:00 2001 From: acpaquette Date: Fri, 17 Nov 2023 14:53:41 -0700 Subject: [PATCH 04/11] Fixed up documentation in ShapeModel.h --- isis/src/base/objs/ShapeModel/ShapeModel.h | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/isis/src/base/objs/ShapeModel/ShapeModel.h b/isis/src/base/objs/ShapeModel/ShapeModel.h index 2a020ed71f..b86f3ce521 100644 --- a/isis/src/base/objs/ShapeModel/ShapeModel.h +++ b/isis/src/base/objs/ShapeModel/ShapeModel.h @@ -58,6 +58,10 @@ namespace Isis { * setSurfacePoint() & clearSurfacePoint() virtual * to give some hope of a consistent internal state * in derived models. + * @history 2023-11-17 Adam Paquette - Added new localNormal variable with same interface + * as the surface normal. This ensures that the currently + * stored m_normal is always the surface normal, and that + * the local normal is always stored in m_localNormal. */ class ShapeModel { public: @@ -153,9 +157,11 @@ namespace Isis { protected: - // Set the normal (surface or local) of the current intersection point + // Set the surface normal of the current intersection point void setNormal(const std::vector); void setNormal(const double a, const double b, const double c); + + // Set the local normal of the current intersection point void setLocalNormal(const std::vector); void setLocalNormal(const double a, const double b, const double c); @@ -178,8 +184,8 @@ namespace Isis { bool m_hasEllipsoidIntersection; //!< Indicates the ellipsoid was successfully intersected bool m_hasIntersection; //!< indicates good intersection exists bool m_hasNormal; //!< indicates normal has been computed - bool m_hasLocalNormal; //!< indicates normal has been computed - std::vector m_normal; //!< Local normal of current intersection point + bool m_hasLocalNormal; //!< indicates local normal has been computed + std::vector m_normal; //!< Surface normal of current intersection point std::vector m_localNormal; //!< Local normal of current intersection point QString *m_name; //! < Name of the shape SurfacePoint *m_surfacePoint; //!< Current intersection point From 608164a5a0b2a84ef77c6b334dc9373678025474 Mon Sep 17 00:00:00 2001 From: acpaquette Date: Fri, 17 Nov 2023 15:22:00 -0700 Subject: [PATCH 05/11] Handled cases where the hasLocalNormal flag should be set to false --- .../EmbreeShapeModel/EmbreeShapeModel.cpp | 1 + isis/src/base/objs/ShapeModel/ShapeModel.cpp | 26 ++++++++++--------- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/isis/src/base/objs/EmbreeShapeModel/EmbreeShapeModel.cpp b/isis/src/base/objs/EmbreeShapeModel/EmbreeShapeModel.cpp index 26066aa5c6..385dd9bc75 100644 --- a/isis/src/base/objs/EmbreeShapeModel/EmbreeShapeModel.cpp +++ b/isis/src/base/objs/EmbreeShapeModel/EmbreeShapeModel.cpp @@ -385,6 +385,7 @@ namespace Isis { void EmbreeShapeModel::clearSurfacePoint() { ShapeModel::clearSurfacePoint(); setHasNormal(false); + setHasLocalNormal(false); return; } diff --git a/isis/src/base/objs/ShapeModel/ShapeModel.cpp b/isis/src/base/objs/ShapeModel/ShapeModel.cpp index 92aaffcd6f..f53ef1c0c7 100644 --- a/isis/src/base/objs/ShapeModel/ShapeModel.cpp +++ b/isis/src/base/objs/ShapeModel/ShapeModel.cpp @@ -504,7 +504,7 @@ namespace Isis { /** - * Sets the normal for the currect intersection point. + * Sets the surface normal for the currect intersection point. * Note: This method will throw an error if this ShapeModel doesn't have * and intersection. Use the hasIntersection() method to verify before * calling this method. @@ -526,14 +526,14 @@ namespace Isis { } /** - * Sets the normal for the currect intersection point. + * Sets the local normal for the currect intersection point. * Note: This method will throw an error if this ShapeModel doesn't have * and intersection. Use the hasIntersection() method to verify before * calling this method. * * @see hasIntersection() * - * @param normal Three dimensional surface normal vector. + * @param normal Three dimensional local normal vector. * */ void ShapeModel::setLocalNormal(const std::vector normal) { @@ -549,7 +549,7 @@ namespace Isis { /** - * Sets the normal for the currect intersection point. + * Sets the surface normal for the currect intersection point. * Note: This method will throw an error if this ShapeModel doesn't have and * intersection. Use the hasIntersection() method to verify before calling * this method. @@ -575,16 +575,16 @@ namespace Isis { } /** - * Sets the normal for the currect intersection point. + * Sets the local normal for the currect intersection point. * Note: This method will throw an error if this ShapeModel doesn't have and * intersection. Use the hasIntersection() method to verify before calling * this method. * * @see hasIntersection() * - * @param a First coordinate value for the three dimensional surface normal. - * @param b Second coordinate value for the three dimensional surface normal. - * @param c Third coordinate value for the three dimensional surface normal. + * @param a First coordinate value for the three dimensional local normal. + * @param b Second coordinate value for the three dimensional local normal. + * @param c Third coordinate value for the three dimensional local normal. * */ void ShapeModel::setLocalNormal(const double a, const double b, const double c) { @@ -630,7 +630,8 @@ namespace Isis { */ void ShapeModel::setHasIntersection(bool b) { m_hasIntersection = b; - m_hasNormal = false; + setHasNormal(false); + setHasLocalNormal(false); } @@ -646,13 +647,14 @@ namespace Isis { m_hasIntersection = true; // Set normal as not calculated setHasNormal(false); + setHasLocalNormal(false); } /** * Sets the flag to indicate whether this ShapeModel has a surface normal. * - * @param b Indicates whether there is a normal. + * @param status Indicates whether there is a normal. * */ void ShapeModel::setHasNormal(bool status) { @@ -660,9 +662,9 @@ namespace Isis { } /** - * Sets the flag to indicate whether this ShapeModel has a surface normal. + * Sets the flag to indicate whether this ShapeModel has a local normal. * - * @param b Indicates whether there is a normal. + * @param status Indicates whether there is a normal. * */ void ShapeModel::setHasLocalNormal(bool status) { From 5cad3946cd0b42f942e1ed2eaa4692f33a2c53ca Mon Sep 17 00:00:00 2001 From: acpaquette Date: Mon, 20 Nov 2023 16:23:33 -0700 Subject: [PATCH 06/11] Fixed tests --- isis/src/base/objs/DemShape/unitTest.cpp | 6 +++--- isis/src/base/objs/EllipsoidShape/EllipsoidShape.cpp | 5 +++-- isis/src/base/objs/EllipsoidShape/unitTest.cpp | 2 +- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/isis/src/base/objs/DemShape/unitTest.cpp b/isis/src/base/objs/DemShape/unitTest.cpp index 3c3183c347..7e40ade076 100644 --- a/isis/src/base/objs/DemShape/unitTest.cpp +++ b/isis/src/base/objs/DemShape/unitTest.cpp @@ -137,7 +137,7 @@ int main() { shape.calculateLocalNormal(neighborPoints); vector myNormal(3); - myNormal = shape.normal(); + myNormal = shape.localNormal(); cout << " local normal = (" << myNormal[0] << ", " << myNormal[1] << ", " << myNormal[2] << endl; cout << endl << " Testing class method calculateSurfaceNormal..." << endl; @@ -212,7 +212,7 @@ int main() { neighborPoints[3][2] = 1193.88; cout << endl << " Testing method calculateLocalNormal with vector pointing outward" << endl; shape.calculateLocalNormal(neighborPoints); - myNormal = shape.normal(); + myNormal = shape.localNormal(); cout << " local normal = (" << myNormal[0] << ", " << myNormal[1] << ", " << myNormal[2] << endl; // Test calculateLocalNormal with magnitude = 0 @@ -221,7 +221,7 @@ int main() { neighborPoints[3][1] = -2380.59; cout << endl << " Testing method calculateLocalNormal with magnitude = 0" << endl; shape.calculateLocalNormal(neighborPoints); - myNormal = shape.normal(); + myNormal = shape.localNormal(); cout << " local normal = (" << myNormal[0] << ", " << myNormal[1] << ", " << myNormal[2] << ")" << endl; } catch(Isis::IException &e) { diff --git a/isis/src/base/objs/EllipsoidShape/EllipsoidShape.cpp b/isis/src/base/objs/EllipsoidShape/EllipsoidShape.cpp index 1089fe42f0..7f2a195524 100644 --- a/isis/src/base/objs/EllipsoidShape/EllipsoidShape.cpp +++ b/isis/src/base/objs/EllipsoidShape/EllipsoidShape.cpp @@ -60,8 +60,7 @@ namespace Isis { * */ void EllipsoidShape::calculateDefaultNormal() { - QVector points; - calculateLocalNormal(points); + calculateSurfaceNormal(); } @@ -71,6 +70,8 @@ namespace Isis { void EllipsoidShape::calculateSurfaceNormal() { QVector points; calculateLocalNormal(points); + + setNormal(localNormal()); } diff --git a/isis/src/base/objs/EllipsoidShape/unitTest.cpp b/isis/src/base/objs/EllipsoidShape/unitTest.cpp index fd06abd9f9..d76d03afce 100644 --- a/isis/src/base/objs/EllipsoidShape/unitTest.cpp +++ b/isis/src/base/objs/EllipsoidShape/unitTest.cpp @@ -119,7 +119,7 @@ int main() { shape.calculateLocalNormal(notUsed); vector myNormal(3); - myNormal = shape.normal(); + myNormal = shape.localNormal(); //Hand-calculated truth value: [-0.6196003462957385, -0.7004971412244801, 0.3541174466282787] From 43973acff3bc086d93bf7cb380a263a0bc98beee Mon Sep 17 00:00:00 2001 From: acpaquette Date: Tue, 28 Nov 2023 16:20:28 -0700 Subject: [PATCH 07/11] Fixed gtests --- isis/tests/FunctionalTestsCaminfo.cpp | 48 +++++++++++++------------- isis/tests/FunctionalTestsCamstats.cpp | 16 ++++----- 2 files changed, 32 insertions(+), 32 deletions(-) diff --git a/isis/tests/FunctionalTestsCaminfo.cpp b/isis/tests/FunctionalTestsCaminfo.cpp index 3edcef1e0e..b92e5f15b5 100644 --- a/isis/tests/FunctionalTestsCaminfo.cpp +++ b/isis/tests/FunctionalTestsCaminfo.cpp @@ -266,14 +266,14 @@ TEST_F(DefaultCube, FunctionalTestCaminfoDefault) { EXPECT_NEAR(camstats.findKeyword("PhaseMaximum"), 81.304900313013, 0.001 ); EXPECT_NEAR(camstats.findKeyword("PhaseAverage"), 80.529097153288, 0.001 ); EXPECT_NEAR(camstats.findKeyword("PhaseStandardDeviation"), 0.44420861263609, 0.001 ); - EXPECT_NEAR(camstats.findKeyword("EmissionMinimum"), 6.5875955784639002, 0.001 ); - EXPECT_NEAR(camstats.findKeyword("EmissionMaximum"), 26.933702102375999, 0.001 ); - EXPECT_NEAR(camstats.findKeyword("EmissionAverage"), 14.577804851994999, 0.001 ); - EXPECT_NEAR(camstats.findKeyword("EmissionStandardDeviation"), 1.9856896435092, 0.001 ); - EXPECT_NEAR(camstats.findKeyword("IncidenceMinimum"), 53.332095294516002, 0.001 ); - EXPECT_NEAR(camstats.findKeyword("IncidenceMaximum"), 73.850710962080996, 0.001 ); - EXPECT_NEAR(camstats.findKeyword("IncidenceAverage"), 66.178552657137004, 0.001 ); - EXPECT_NEAR(camstats.findKeyword("IncidenceStandardDeviation"), 1.7434735102028001, 0.001 ); + EXPECT_NEAR(camstats.findKeyword("EmissionMinimum"), 10.798462835458, 0.001 ); + EXPECT_NEAR(camstats.findKeyword("EmissionMaximum"), 13.502630463571, 0.001); + EXPECT_NEAR(camstats.findKeyword("EmissionAverage"), 12.15148695101, 0.001); + EXPECT_NEAR(camstats.findKeyword("EmissionStandardDeviation"), 0.56543791358689, 0.001); + EXPECT_NEAR(camstats.findKeyword("IncidenceMinimum"), 69.941096124192, 0.001); + EXPECT_NEAR(camstats.findKeyword("IncidenceMaximum"), 70.311944975377, 0.001); + EXPECT_NEAR(camstats.findKeyword("IncidenceAverage"), 70.127459134075, 0.001); + EXPECT_NEAR(camstats.findKeyword("IncidenceStandardDeviation"), 0.10249039125851, 0.001 ); EXPECT_NEAR(camstats.findKeyword("LocalSolarTimeMinimum"), 7.7698055422189, 0.001 ); EXPECT_NEAR(camstats.findKeyword("LocalSolarTimeMaximum"), 7.8031735959943, 0.001 ); EXPECT_NEAR(camstats.findKeyword("LocalSolarTimeAverage"), 7.7863626216564, 0.001 ); @@ -433,10 +433,10 @@ TEST_F(DefaultCube, FunctionalTestCaminfoBoundary) { EXPECT_NEAR(camstats.findKeyword("ResolutionMaximum"), 18.985953877821999, 0.001 ); EXPECT_NEAR(camstats.findKeyword("PhaseMinimum"), 79.756145388578005, 0.001 ); EXPECT_NEAR(camstats.findKeyword("PhaseMaximum"), 81.304900313013, 0.001 ); - EXPECT_NEAR(camstats.findKeyword("EmissionMinimum"), 7.4919183637178, 0.001 ); - EXPECT_NEAR(camstats.findKeyword("EmissionMaximum"), 21.091782435858001, 0.001 ); - EXPECT_NEAR(camstats.findKeyword("IncidenceMinimum"), 60.113879909235997, 0.001 ); - EXPECT_NEAR(camstats.findKeyword("IncidenceMaximum"), 72.470329236867997, 0.001 ); + EXPECT_NEAR(camstats.findKeyword("EmissionMinimum"), 10.798462835458, 0.001); + EXPECT_NEAR(camstats.findKeyword("EmissionMaximum"), 13.502630463571, 0.001 ); + EXPECT_NEAR(camstats.findKeyword("IncidenceMinimum"), 69.941096124192, 0.001 ); + EXPECT_NEAR(camstats.findKeyword("IncidenceMaximum"), 70.311944975377, 0.001); EXPECT_NEAR(camstats.findKeyword("LocalSolarTimeMinimum"), 7.7698055422189, 0.001 ); EXPECT_NEAR(camstats.findKeyword("LocalSolarTimeMaximum"), 7.8031735959943, 0.001 ); } @@ -503,10 +503,10 @@ TEST_F(DefaultCube, FunctionalTestCaminfoCamStatsTable) { EXPECT_NEAR(camstats.findKeyword("MaximumResolution"), 18.985953877821999, 0.001 ); EXPECT_NEAR(camstats.findKeyword("MinimumPhase"), 79.756145388578005, 0.001 ); EXPECT_NEAR(camstats.findKeyword("MaximumPhase"), 81.304900313013, 0.001 ); - EXPECT_NEAR(camstats.findKeyword("MinimumEmission"), 9.8943199851049997, 0.001 ); - EXPECT_NEAR(camstats.findKeyword("MaximumEmission"), 19.639762075680999, 0.001 ); - EXPECT_NEAR(camstats.findKeyword("MinimumIncidence"), 61.658112222808001, 0.001 ); - EXPECT_NEAR(camstats.findKeyword("MaximumIncidence"), 71.417244415552005, 0.001 ); + EXPECT_NEAR(camstats.findKeyword("MinimumEmission"), 10.798462835458, 0.001); + EXPECT_NEAR(camstats.findKeyword("MaximumEmission"), 13.502630463571, 0.001); + EXPECT_NEAR(camstats.findKeyword("MinimumIncidence"), 69.941096124192, 0.001); + EXPECT_NEAR(camstats.findKeyword("MaximumIncidence"), 70.311944975377, 0.001); EXPECT_NEAR(camstats.findKeyword("LocalTimeMinimum"), 7.7698055422189, 0.001 ); EXPECT_NEAR(camstats.findKeyword("LocalTimeMaximum"), 7.8031735959943, 0.001 ); EXPECT_NEAR(camstats.findKeyword("ObliqueResolutionMinimum"), 19.183652922680999, 0.001 ); @@ -562,15 +562,15 @@ TEST_F(DefaultCube, FunctionalTestCaminfoCamStatsTable) { EXPECT_NEAR(camstats.findKeyword("PhaseAngleAverage"), 80.556249549336, 0.001 ); EXPECT_NEAR(camstats.findKeyword("PhaseAngleStandardDeviation"), 0.496128069014, 0.001 ); - EXPECT_NEAR(camstats.findKeyword("EmissionAngleMinimum"), 9.8943199851049997, 0.001 ); - EXPECT_NEAR(camstats.findKeyword("EmissionAngleMaximum"), 19.639762075680999, 0.001 ); - EXPECT_NEAR(camstats.findKeyword("EmissionAngleAverage"), 14.638344628861001, 0.001 ); - EXPECT_NEAR(camstats.findKeyword("EmissionAngleStandardDeviation"), 1.9665305080041, 0.001 ); + EXPECT_NEAR(camstats.findKeyword("EmissionAngleMinimum"), 10.798462835458, 0.001); + EXPECT_NEAR(camstats.findKeyword("EmissionAngleMaximum"), 13.502630463571, 0.001); + EXPECT_NEAR(camstats.findKeyword("EmissionAngleAverage"), 12.222241624466, 0.001); + EXPECT_NEAR(camstats.findKeyword("EmissionAngleStandardDeviation"), 0.63393199155819, 0.001); - EXPECT_NEAR(camstats.findKeyword("IncidenceAngleMinimum"), 61.658112222808001, 0.001 ); - EXPECT_NEAR(camstats.findKeyword("IncidenceAngleMaximum"), 71.417244415552005, 0.001 ); - EXPECT_NEAR(camstats.findKeyword("IncidenceAngleAverage"), 66.194841491336007, 0.001 ); - EXPECT_NEAR(camstats.findKeyword("IncidenceAngleStandardDeviation"), 1.7313642198304, 0.001 ); + EXPECT_NEAR(camstats.findKeyword("IncidenceAngleMinimum"), 69.941096124192, 0.001); + EXPECT_NEAR(camstats.findKeyword("IncidenceAngleMaximum"), 70.311944975377, 0.001); + EXPECT_NEAR(camstats.findKeyword("IncidenceAngleAverage"), 70.121640864056, 0.001); + EXPECT_NEAR(camstats.findKeyword("IncidenceAngleStandardDeviation"), 0.1144744474437, 0.001); EXPECT_NEAR(camstats.findKeyword("LocalSolarTimeMinimum"), 7.7698055422189, 0.001 ); EXPECT_NEAR(camstats.findKeyword("LocalSolarTimeMaximum"), 7.8031735959943, 0.001 ); diff --git a/isis/tests/FunctionalTestsCamstats.cpp b/isis/tests/FunctionalTestsCamstats.cpp index b0a05d894a..a0ec58d7be 100644 --- a/isis/tests/FunctionalTestsCamstats.cpp +++ b/isis/tests/FunctionalTestsCamstats.cpp @@ -86,16 +86,16 @@ TEST_F(DefaultCube, FunctionalTestCamstatsDefaultParameters) { EXPECT_NEAR( (double) group.findKeyword("PhaseStandardDeviation"), 0.444208835, 1e-8); group = appLog.findGroup("EmissionAngle"); - EXPECT_NEAR( (double) group.findKeyword("EmissionMinimum"), 6.5873899396236997, 1e-8); - EXPECT_NEAR( (double) group.findKeyword("EmissionMaximum"), 26.933666690235, 1e-8); - EXPECT_NEAR( (double) group.findKeyword("EmissionAverage"), 14.577805010258, 1e-8); - EXPECT_NEAR( (double) group.findKeyword("EmissionStandardDeviation"), 1.9856899871104, 1e-8); + EXPECT_NEAR( (double) group.findKeyword("EmissionMinimum"), 10.798462835, 1e-8); + EXPECT_NEAR( (double) group.findKeyword("EmissionMaximum"), 13.502630463, 1e-8); + EXPECT_NEAR( (double) group.findKeyword("EmissionAverage"), 12.15148695101, 1e-8); + EXPECT_NEAR( (double) group.findKeyword("EmissionStandardDeviation"), 0.565437913, 1e-8); group = appLog.findGroup("IncidenceAngle"); - EXPECT_NEAR( (double) group.findKeyword("IncidenceMinimum"), 53.332129677822003, 1e-8); - EXPECT_NEAR( (double) group.findKeyword("IncidenceMaximum"), 73.850688487919996, 1e-8); - EXPECT_NEAR( (double) group.findKeyword("IncidenceAverage"), 66.178552584920993, 1e-8); - EXPECT_NEAR( (double) group.findKeyword("IncidenceStandardDeviation"), 1.7434736991333, 1e-8); + EXPECT_NEAR( (double) group.findKeyword("IncidenceMinimum"), 69.941096124, 1e-8); + EXPECT_NEAR( (double) group.findKeyword("IncidenceMaximum"), 70.311944975, 1e-8); + EXPECT_NEAR( (double) group.findKeyword("IncidenceAverage"), 70.127459134, 1e-8); + EXPECT_NEAR( (double) group.findKeyword("IncidenceStandardDeviation"), 0.102490391, 1e-8); group = appLog.findGroup("LocalSolarTime"); EXPECT_NEAR( (double) group.findKeyword("LocalSolarTimeMinimum"), 7.7698055422, 1e-8); From 19e3c6e0a2b7ed6985975c9bf77dfbb5821a34fc Mon Sep 17 00:00:00 2001 From: acpaquette Date: Tue, 28 Nov 2023 16:31:53 -0700 Subject: [PATCH 08/11] Addressed PR feedback --- isis/src/base/objs/ShapeModel/ShapeModel.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/isis/src/base/objs/ShapeModel/ShapeModel.cpp b/isis/src/base/objs/ShapeModel/ShapeModel.cpp index f53ef1c0c7..54578b27a6 100644 --- a/isis/src/base/objs/ShapeModel/ShapeModel.cpp +++ b/isis/src/base/objs/ShapeModel/ShapeModel.cpp @@ -506,7 +506,7 @@ namespace Isis { /** * Sets the surface normal for the currect intersection point. * Note: This method will throw an error if this ShapeModel doesn't have - * and intersection. Use the hasIntersection() method to verify before + * an intersection. Use the hasIntersection() method to verify before * calling this method. * * @see hasIntersection() @@ -520,7 +520,7 @@ namespace Isis { m_hasNormal = true; } else { - QString message = "No intersection point in known. A normal can not be set."; + QString message = "No intersection point is known. A normal cannot be set."; throw IException(IException::Unknown, message, _FILEINFO_); } } @@ -528,7 +528,7 @@ namespace Isis { /** * Sets the local normal for the currect intersection point. * Note: This method will throw an error if this ShapeModel doesn't have - * and intersection. Use the hasIntersection() method to verify before + * an intersection. Use the hasIntersection() method to verify before * calling this method. * * @see hasIntersection() @@ -542,7 +542,7 @@ namespace Isis { m_hasLocalNormal = true; } else { - QString message = "No intersection point in known. A local normal can not be set."; + QString message = "No intersection point is known. A local normal cannot be set."; throw IException(IException::Unknown, message, _FILEINFO_); } } From 1ea78835836105ad9a6d069e4cb568de0ee7cf27 Mon Sep 17 00:00:00 2001 From: acpaquette Date: Wed, 29 Nov 2023 00:11:04 -0700 Subject: [PATCH 09/11] Fixed more typos --- isis/src/base/objs/ShapeModel/ShapeModel.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/isis/src/base/objs/ShapeModel/ShapeModel.cpp b/isis/src/base/objs/ShapeModel/ShapeModel.cpp index 54578b27a6..243f1918b8 100644 --- a/isis/src/base/objs/ShapeModel/ShapeModel.cpp +++ b/isis/src/base/objs/ShapeModel/ShapeModel.cpp @@ -569,7 +569,7 @@ namespace Isis { m_hasNormal = true; } else { - QString message = "No intersection point in known. A normal can not be set."; + QString message = "No intersection point is known. A normal cannot be set."; throw IException(IException::Unknown, message, _FILEINFO_); } } @@ -595,7 +595,7 @@ namespace Isis { m_hasLocalNormal = true; } else { - QString message = "No intersection point in known. A local normal can not be set."; + QString message = "No intersection point is known. A local normal cannot be set."; throw IException(IException::Unknown, message, _FILEINFO_); } } From 8a45bf84d7be0ff3652cc92f4cef5c4c338f88ce Mon Sep 17 00:00:00 2001 From: acpaquette Date: Mon, 4 Dec 2023 10:10:44 -0700 Subject: [PATCH 10/11] Further adjusted truth data for test --- isis/src/base/objs/ShapeModel/ShapeModel.truth | 4 ++-- isis/tests/FunctionalTestsCamstats.cpp | 16 ++++++++-------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/isis/src/base/objs/ShapeModel/ShapeModel.truth b/isis/src/base/objs/ShapeModel/ShapeModel.truth index 3b72b85a81..e7b3249233 100644 --- a/isis/src/base/objs/ShapeModel/ShapeModel.truth +++ b/isis/src/base/objs/ShapeModel/ShapeModel.truth @@ -6,9 +6,9 @@ Begin testing Shape Model base class.... Test resolution() error message when there is no intersection: **PROGRAMMER ERROR** No valid intersection point for computing resolution. Test setNormal(double,double,double) error message when there is no intersection: -**ERROR** No intersection point in known. A normal can not be set. +**ERROR** No intersection point is known. A normal cannot be set. Test setNormal(vector) error message when there is no intersection: -**ERROR** No intersection point in known. A normal can not be set. +**ERROR** No intersection point is known. A normal cannot be set. Set a pixel in the image and check again. Testing pure virtual method intersectSurface... diff --git a/isis/tests/FunctionalTestsCamstats.cpp b/isis/tests/FunctionalTestsCamstats.cpp index a0ec58d7be..e92852f9fb 100644 --- a/isis/tests/FunctionalTestsCamstats.cpp +++ b/isis/tests/FunctionalTestsCamstats.cpp @@ -86,16 +86,16 @@ TEST_F(DefaultCube, FunctionalTestCamstatsDefaultParameters) { EXPECT_NEAR( (double) group.findKeyword("PhaseStandardDeviation"), 0.444208835, 1e-8); group = appLog.findGroup("EmissionAngle"); - EXPECT_NEAR( (double) group.findKeyword("EmissionMinimum"), 10.798462835, 1e-8); - EXPECT_NEAR( (double) group.findKeyword("EmissionMaximum"), 13.502630463, 1e-8); - EXPECT_NEAR( (double) group.findKeyword("EmissionAverage"), 12.15148695101, 1e-8); - EXPECT_NEAR( (double) group.findKeyword("EmissionStandardDeviation"), 0.565437913, 1e-8); + EXPECT_NEAR( (double) group.findKeyword("EmissionMinimum"), 10.79846217733, 1e-8); + EXPECT_NEAR( (double) group.findKeyword("EmissionMaximum"), 13.502631152501, 1e-8); + EXPECT_NEAR( (double) group.findKeyword("EmissionAverage"), 12.151486966752, 1e-8); + EXPECT_NEAR( (double) group.findKeyword("EmissionStandardDeviation"), 0.56543820137524, 1e-8); group = appLog.findGroup("IncidenceAngle"); - EXPECT_NEAR( (double) group.findKeyword("IncidenceMinimum"), 69.941096124, 1e-8); - EXPECT_NEAR( (double) group.findKeyword("IncidenceMaximum"), 70.311944975, 1e-8); - EXPECT_NEAR( (double) group.findKeyword("IncidenceAverage"), 70.127459134, 1e-8); - EXPECT_NEAR( (double) group.findKeyword("IncidenceStandardDeviation"), 0.102490391, 1e-8); + EXPECT_NEAR( (double) group.findKeyword("IncidenceMinimum"), 69.941096029946, 1e-8); + EXPECT_NEAR( (double) group.findKeyword("IncidenceMaximum"), 70.311945067319, 1e-8); + EXPECT_NEAR( (double) group.findKeyword("IncidenceAverage"), 70.127459134001, 1e-8); + EXPECT_NEAR( (double) group.findKeyword("IncidenceStandardDeviation"), 0.10249044009735, 1e-8); group = appLog.findGroup("LocalSolarTime"); EXPECT_NEAR( (double) group.findKeyword("LocalSolarTimeMinimum"), 7.7698055422, 1e-8); From 7568d962e17a46227f3397caa758abba84f9b68e Mon Sep 17 00:00:00 2001 From: acpaquette Date: Mon, 4 Dec 2023 15:21:01 -0700 Subject: [PATCH 11/11] Added changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4f13b038ca..679663c19c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -46,6 +46,7 @@ release. outputsuffix, both, or neither for naming convention purposes. [#5162](https://github.com/DOI-USGS/ISIS3/pull/5162) - Changed the default PCK load behavior to try and load mission specific PCKs, if that fails we default to the base PCKs [#5335](https://github.com/DOI-USGS/ISIS3/pull/5335) - Disabled option to use web=true when running spiceinit with HRSC images. [#5223](https://github.com/DOI-USGS/ISIS3/issues/5223) +- Seperated `normal` and `localNormal` in ISIS shapemodels, now the local normal is stored in its own member variable with setters and getters. [#5345](https://github.com/DOI-USGS/ISIS3/pull/5345) ### Added - Added rclone to run dependencies in meta.yaml [#5183](https://github.com/DOI-USGS/ISIS3/issues/5183)