51 ShapeModelFactory::ShapeModelFactory() {}
54 ShapeModelFactory::~ShapeModelFactory() {}
64 bool skyTarget = target->
isSky();
71 QString shapeModelFilenames =
"";
80 else if (kernelsPvlGroup.
hasKeyword(
"ElevationModel") &&
81 !kernelsPvlGroup[
"ElevationModel"].isNull()) {
82 shapeModelFilenames = (QString) kernelsPvlGroup[
"ElevationModel"];
84 else if (kernelsPvlGroup.
hasKeyword(
"ShapeModel") &&
85 !kernelsPvlGroup[
"ShapeModel"].isNull()) {
86 shapeModelFilenames = (QString) kernelsPvlGroup[
"ShapeModel"];
90 ShapeModel *shapeModel = NULL;
97 IException finalError(IException::Programmer,
98 "Unable to create a shape model from given target and pvl.",
101 if (shapeModelFilenames ==
"") {
104 QString msg =
"Unable to construct an Ellipsoid shape model.";
107 shapeModel =
new EllipsoidShape(target);
109 catch (IException &e) {
112 finalError.append(IException(e, IException::Unknown, msg,
_FILEINFO_));
116 finalError.append(IException(IException::Unknown, msg,
_FILEINFO_));
118 else if (shapeModelFilenames ==
"RingPlane") {
121 QString msg =
"Unable to construct a RingPlane shape model.";
124 shapeModel =
new PlaneShape(target, pvl);
126 catch (IException &e) {
128 finalError.append(IException(e, IException::Unknown, msg,
_FILEINFO_));
132 finalError.append(IException(IException::Unknown, msg,
_FILEINFO_));
137 QString fileErrorMsg =
"Invalid shape model file ["
138 + shapeModelFilenames +
"] in Kernels group.";
139 IException fileError(IException::Io, fileErrorMsg,
_FILEINFO_);
145 QString msg =
"The given shape model file is not a valid NAIF DSK file. "
146 "Unable to construct a NAIF DSK shape model.";
147 IException dskError(IException::Unknown, msg,
_FILEINFO_);
151 shapeModel =
new NaifDskShape(target, pvl);
153 catch (IException &e) {
159 if (shapeModel == NULL) {
162 fileError.append(dskError);
169 shapeModelCube->
open(FileName(shapeModelFilenames).expanded(),
"r" );
171 catch (IException &e) {
173 QString msg =
"The given shape model file is not a valid ISIS DEM. "
174 "Unable to open as an ISIS cube.";
175 fileError.append(IException(e, IException::Unknown, msg,
_FILEINFO_));
176 finalError.append(fileError);
180 Projection *projection = NULL;
185 catch (IException &e) {
187 QString msg =
"The given shape model file is not a valid ISIS DEM cube. "
188 "It is not map-projected.";
189 fileError.append(IException(e, IException::Unknown, msg,
_FILEINFO_));
190 finalError.append(fileError);
194 if (projection->IsEquatorialCylindrical()) {
196 delete shapeModelCube;
200 QString msg =
"Unable to construct a DEM shape model from the given "
201 "EquatorialCylindrical projected ISIS cube.";
204 shapeModel =
new EquatorialCylindricalShape(target, pvl);
206 catch (IException &e) {
208 fileError.append(IException(e, IException::Unknown, msg,
_FILEINFO_));
209 finalError.append(fileError);
213 fileError.append(IException(IException::Unknown, msg,
_FILEINFO_));
218 QString msg =
"Unable to construct a DEM shape model "
219 "from the given projected ISIS cube file.";
222 shapeModel =
new DemShape(target, pvl);
224 catch (IException &e) {
226 fileError.append(IException(e, IException::Unknown, msg,
_FILEINFO_));
227 finalError.append(fileError);
231 fileError.append(IException(IException::Unknown, msg,
_FILEINFO_));
237 finalError.append(fileError);
242 if (shapeModel == NULL) {
PvlGroupIterator findGroup(const QString &name, PvlGroupIterator beg, PvlGroupIterator end)
Find a group with the specified name, within these indexes.
Projection * projection()
Contains multiple PvlContainers.
#define _FILEINFO_
Macro for the filename and line number.
void open(const QString &cfile, QString access="r")
This method will open an isis cube for reading or reading/writing.
bool isSky() const
Return if our target is the sky.
Container for cube-like labels.
This class is used to create and store valid Isis3 targets.
Define shapes and provide utilities for Isis3 targets.
bool hasKeyword(const QString &name) const
Check to see if a keyword exists.
IO Handler for Isis Cubes.