Official websites use .gov
A .gov website belongs to an official government organization in the United States.

Secure .gov websites use HTTPS
A lock ( ) or https:// means you’ve safely connected to the .gov website. Share sensitive information only on official, secure websites.

Isis 3 Programmer Reference
NaifDskShape.cpp
1
5
6/* SPDX-License-Identifier: CC0-1.0 */
7#include "NaifDskShape.h"
8
9#include <numeric>
10
11#include <QtGlobal>
12#include <QVector>
13
14#include "IException.h"
15#include "Intercept.h"
16#include "IString.h"
17#include "Latitude.h"
18#include "Longitude.h"
19#include "NaifDskApi.h"
20#include "NaifDskPlateModel.h"
21#include "NaifStatus.h"
22#include "Pvl.h"
23#include "ShapeModel.h"
24#include "SpecialPixel.h"
25#include "Statistics.h"
26#include "SurfacePoint.h"
27#include "Target.h"
28
29
30using namespace std;
31
32namespace Isis {
33
36 // defaults for ShapeModel parent class include:
37 // name = empty string
38 // surfacePoint = null sp
39 // hasIntersection = false
40 // hasNormal = false
41 // normal = (0,0,0)
42 // hasEllipsoidIntersection = false
43 setName("DSK");
44 }
45
46
60 NaifDskShape::NaifDskShape(Target *target, Pvl &pvl) : ShapeModel(target),
61 m_intercept(NULL) {
62
63 // defaults for ShapeModel parent class include:
64 // name = empty string
65 // surfacePoint = null sp
66 // hasIntersection = false
67 // hasNormal = false
68 // normal = (0,0,0)
69 // hasEllipsoidIntersection = false
70
71 setName("DSK"); // Really is used as type in the system at present!
72
73 PvlGroup &kernels = pvl.findGroup("Kernels", Pvl::Traverse);
74
75 QString dskFile;
76 if (kernels.hasKeyword("ElevationModel")) {
77 dskFile = (QString) kernels["ElevationModel"];
78 }
79 else { // if (kernels.hasKeyword("ShapeModel")) {
80 dskFile = (QString) kernels["ShapeModel"];
81 }
82
83 // Attempt to initialize the DSK file - exception ensues if errors occur
84 // error thrown if ShapeModel=Null (i.e. Ellipsoid)
85 m_model = NaifDskPlateModel(dskFile);
86
87 }
88
89
104 m_model(model), m_intercept(NULL) {
105
106 // TODO create valid Target
107 // Using this constructor, ellipsoidNormal(),
108 // calculateSurfaceNormal(), and setLocalNormalFromIntercept()
109 // methods can not be called
110 }
111
112
115
116
135 bool NaifDskShape::intersectSurface(std::vector<double> observerPos,
136 std::vector<double> lookDirection) {
137 NaifVertex obs(3, &observerPos[0]);
138 NaifVector raydir(3, &lookDirection[0]);
139 m_intercept.reset(m_model.intercept(obs, raydir));
140
141 bool success = !m_intercept.isNull();
142 if (success) {
143 SurfacePoint point = m_intercept->location();
144 setSurfacePoint(point); // sets ShapeModel::m_hasIntersection=t, ShapeModel::m_hasNormal=f
145 }
146 return ( success );
147 }
148
149
167 const std::vector<double> &observerPos,
168 const bool &backCheck) {
169
170 std::vector<double> look(3);
171 look[0] = surfpt.GetX().kilometers() - observerPos[0];
172 look[1] = surfpt.GetY().kilometers() - observerPos[1];
173 look[2] = surfpt.GetZ().kilometers() - observerPos[2];
174
175 return intersectSurface(observerPos, look);
176
177 }
178
179
197 const Longitude &lon) {
198 QScopedPointer<SurfacePoint> pnt(m_model.point(lat, lon));
199 if ( !pnt.isNull() ) return (pnt->GetLocalRadius());
200 return (Distance());
201 }
202
203
214
215 // Sanity check
216 if ( !hasIntersection() ) { // hasIntersection() <==> !m_intercept.isNull()
217 QString mess = "Intercept point does not exist - cannot provide normal vector";
218 throw IException(IException::Programmer, mess, _FILEINFO_);
219 }
220
221 // Got it, use the existing intercept point (plate) normal
222 NaifVector norm(m_intercept->normal());
223 setLocalNormal(norm[0], norm[1], norm[2]); // this also takes care of setHasLocalNormal(true);
224 return;
225 }
226
227
235 bool NaifDskShape::isDEM() const {
236 return false;
237 }
238
239
266 // Sanity check
267 if ( !hasIntersection() ) { // hasIntersection() <==> !m_intercept.isNull()
268 QString mess = "Intercept point does not exist - cannot provide normal vector";
269 throw IException(IException::Programmer, mess, _FILEINFO_);
270 }
271
273 return;
274 }
275
276
279 return (m_model);
280 }
281
282
296 return ( m_intercept.data() );
297 }
298
299}; // namespace Isis
double kilometers() const
Get the displacement in kilometers.
Distance measurement, usually in meters.
Definition Distance.h:34
Container for a intercept condition.
Definition Intercept.h:36
This class is designed to encapsulate the concept of a Latitude.
Definition Latitude.h:51
This class is designed to encapsulate the concept of a Longitude.
Definition Longitude.h:40
Implementation interface API for NAIF's DSK plate model.
QScopedPointer< Intercept > m_intercept
Pointer to the shape's intercept.
void setLocalNormalFromIntercept()
Set the local normal vector to the intercept point normal.
const Intercept * intercept() const
Returns a pointer to the current intercept.
NaifDskShape()
Generic constructor sets type to a TIN.
NaifDskPlateModel m_model
Plate model to intersect.
bool intersectSurface(std::vector< double > observerPos, std::vector< double > lookDirection)
Compute a DEM intersection from and observer and look direction.
Distance localRadius(const Latitude &lat, const Longitude &lon)
Determine DEM radius at a given lat/lon grid point.
void calculateLocalNormal(QVector< double * > cornerNeighborPoints)
Compute the normal for a local region of surface points.
bool isDEM() const
Indicates that this shape model is not from a DEM.
~NaifDskShape()
Destructor - cleanup is handled automagically.
const NaifDskPlateModel & model() const
Returns a direct reference to the DSK plate model file interface.
bool hasIntersection()
Returns intersection status.
void setLocalNormal(const std::vector< double >)
Sets the local normal for the currect intersection point.
virtual void setSurfacePoint(const SurfacePoint &surfacePoint)
Set surface intersection point.
ShapeModel()
Default constructor creates ShapeModel object, initializing name to an empty string,...
void setName(QString name)
Sets the shape name.
This class defines a body-fixed surface point.
This class is used to create and store valid Isis targets.
Definition Target.h:63
This is free and unencumbered software released into the public domain.
Definition Apollo.h:16
TNT::Array1D< SpiceDouble > NaifVector
Namespace to contain type definitions of NAIF DSK fundamentals.
Definition NaifDskApi.h:46
TNT::Array1D< SpiceDouble > NaifVertex
1-D Buffer[3]
Definition NaifDskApi.h:47
Namespace for the standard library.