51 ShapeModelFactory::ShapeModelFactory() {}
56 ShapeModelFactory::~ShapeModelFactory() {}
68 bool skyTarget = target->
isSky();
75 QString shapeModelFilenames =
"";
84 else if (kernelsPvlGroup.
hasKeyword(
"ElevationModel") &&
85 !kernelsPvlGroup[
"ElevationModel"].isNull()) {
86 shapeModelFilenames = (QString) kernelsPvlGroup[
"ElevationModel"];
88 else if (kernelsPvlGroup.
hasKeyword(
"ShapeModel") &&
89 !kernelsPvlGroup[
"ShapeModel"].isNull()) {
90 shapeModelFilenames = (QString) kernelsPvlGroup[
"ShapeModel"];
94 ShapeModel *shapeModel = NULL;
101 IException finalError(IException::Programmer,
102 "Unable to create a shape model from given target and pvl.",
105 if (shapeModelFilenames ==
"") {
108 QString msg =
"Unable to construct an Ellipsoid shape model.";
111 shapeModel =
new EllipsoidShape(target);
113 catch (IException &e) {
116 finalError.append(IException(e, IException::Unknown, msg,
_FILEINFO_));
120 finalError.append(IException(IException::Unknown, msg,
_FILEINFO_));
122 else if (shapeModelFilenames ==
"RingPlane") {
125 QString msg =
"Unable to construct a RingPlane shape model.";
128 shapeModel =
new PlaneShape(target, pvl);
130 catch (IException &e) {
132 finalError.append(IException(e, IException::Unknown, msg,
_FILEINFO_));
136 finalError.append(IException(IException::Unknown, msg,
_FILEINFO_));
141 QString fileErrorMsg =
"Invalid shape model file ["
142 + shapeModelFilenames +
"] in Kernels group.";
143 IException fileError(IException::Io, fileErrorMsg,
_FILEINFO_);
149 QString msg =
"The given shape model file is not a valid NAIF DSK file. "
150 "Unable to construct a NAIF DSK shape model.";
151 IException dskError(IException::Unknown, msg,
_FILEINFO_);
155 shapeModel =
new NaifDskShape(target, pvl);
157 catch (IException &e) {
163 if (shapeModel == NULL) {
165 fileError.append(dskError);
172 shapeModelCube.
open(FileName(shapeModelFilenames).expanded(),
"r" );
174 catch (IException &e) {
176 QString msg =
"The given shape model file is not a valid ISIS DEM. "
177 "Unable to open as an ISIS cube.";
178 fileError.append(IException(e, IException::Unknown, msg,
_FILEINFO_));
179 finalError.append(fileError);
183 Projection *projection = NULL;
188 catch (IException &e) {
190 QString msg =
"The given shape model file is not a valid ISIS DEM cube. "
191 "It is not map-projected.";
192 fileError.append(IException(e, IException::Unknown, msg,
_FILEINFO_));
193 finalError.append(fileError);
197 if (projection->IsEquatorialCylindrical()) {
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) {