66 PvlGroup &kernelsPvlGroup = pvl.findGroup(
"Kernels", Pvl::Traverse);
70 if ( Preference::Preferences().hasGroup(
"ShapeModel") ) {
71 parameters.
merge(
PvlFlatMap(Preference::Preferences().findGroup(
"ShapeModel")));
75 bool skyTarget = target->
isSky();
82 QString shapeModelFilenames =
"";
91 else if (kernelsPvlGroup.hasKeyword(
"ElevationModel") &&
92 !kernelsPvlGroup[
"ElevationModel"].isNull()) {
93 shapeModelFilenames = (QString) kernelsPvlGroup[
"ElevationModel"];
95 else if (kernelsPvlGroup.hasKeyword(
"ShapeModel") &&
96 !kernelsPvlGroup[
"ShapeModel"].isNull()) {
97 shapeModelFilenames = (QString) kernelsPvlGroup[
"ShapeModel"];
108 IException finalError(IException::Programmer,
109 "Unable to create a shape model from given target and pvl.",
112 if (shapeModelFilenames ==
"") {
115 QString msg =
"Unable to construct an Ellipsoid shape model.";
120 catch (IException &e) {
123 finalError.append(IException(e, IException::Unknown, msg, _FILEINFO_));
127 finalError.append(IException(IException::Unknown, msg, _FILEINFO_));
129 else if (shapeModelFilenames ==
"RingPlane") {
132 QString msg =
"Unable to construct a RingPlane shape model.";
137 catch (IException &e) {
139 finalError.append(IException(e, IException::Unknown, msg, _FILEINFO_));
143 finalError.append(IException(IException::Unknown, msg, _FILEINFO_));
147 QString preferred = parameters.
get(
"RayTraceEngine",
"None").toLower();
148 QString onerror = parameters.
get(
"OnError",
"Continue").toLower();
149 double tolerance = toDouble(parameters.
get(
"Tolerance",
toString(DBL_MAX)));
152 QString fileErrorMsg =
"Invalid shape model file ["
153 + shapeModelFilenames +
"] in Kernels group.";
154 IException fileError(IException::Io, fileErrorMsg, _FILEINFO_);
157 if (
"bullet" == preferred ) {
159 FileName v_shapefile(shapeModelFilenames);
160 QString ext = v_shapefile.extension().toLower();
169 QString mess =
"Bullet could not initialize ISIS Cube DEM";
170 throw IException(IException::Unknown, mess, _FILEINFO_);
174 QString b_msg =
"Bullet could not initialize DEM!";
175 throw IException(IException::Unknown, b_msg, _FILEINFO_);
184 kernelsPvlGroup.addKeyword(PvlKeyword(
"RayTraceEngine", preferred), PvlContainer::Replace);
185 kernelsPvlGroup.addKeyword(PvlKeyword(
"OnError", onerror), PvlContainer::Replace);
186 kernelsPvlGroup.addKeyword(PvlKeyword(
"Tolerance",
toString(tolerance)),
187 PvlContainer::Replace);
192 catch (IException &ie) {
193 fileError.append(ie);
194 QString mess =
"Unable to create preferred BulletShapeModel";
195 fileError.append(IException(IException::Unknown, mess, _FILEINFO_));
196 if (
"fail" == onerror) {
205 if (
"embree" == preferred ) {
208 FileName v_shapefile(shapeModelFilenames);
209 QString ext = v_shapefile.extension().toLower();
221 kernelsPvlGroup.addKeyword(PvlKeyword(
"RayTraceEngine", preferred), PvlContainer::Replace);
222 kernelsPvlGroup.addKeyword(PvlKeyword(
"OnError", onerror), PvlContainer::Replace);
223 kernelsPvlGroup.addKeyword(PvlKeyword(
"Tolerance",
toString(tolerance)),
224 PvlContainer::Replace);
226 return ( embreeModel );
228 }
catch (IException &ie) {
229 fileError.append(ie);
230 QString mess =
"Unable to create preferred EmbreeShapeModel";
231 fileError.append(IException(IException::Unknown, mess, _FILEINFO_));
232 if (
"fail" == onerror) {
242 QString msg =
"The given shape model file is not a valid NAIF DSK file. "
243 "Unable to construct a NAIF DSK shape model.";
244 IException dskError(IException::Unknown, msg, _FILEINFO_);
250 catch (IException &e) {
256 if (shapeModel == NULL) {
259 fileError.append(dskError);
266 shapeModelCube->
open(FileName(shapeModelFilenames).expanded(),
"r" );
268 catch (IException &e) {
270 QString msg =
"The given shape model file is not a valid ISIS DEM. "
271 "Unable to open as an ISIS cube.";
272 fileError.append(IException(e, IException::Unknown, msg, _FILEINFO_));
273 finalError.append(fileError);
282 catch (IException &e) {
284 QString msg =
"The given shape model file is not a valid ISIS DEM cube. "
285 "It is not map-projected.";
286 fileError.append(IException(e, IException::Unknown, msg, _FILEINFO_));
287 finalError.append(fileError);
294 QString msg =
"Unable to construct a DEM shape model from the given "
295 "EquatorialCylindrical projected ISIS cube.";
300 catch (IException &e) {
302 fileError.append(IException(e, IException::Unknown, msg, _FILEINFO_));
303 finalError.append(fileError);
307 fileError.append(IException(IException::Unknown, msg, _FILEINFO_));
312 QString msg =
"Unable to construct a DEM shape model "
313 "from the given projected ISIS cube file.";
316 shapeModel =
new DemShape(target, pvl);
318 catch (IException &e) {
320 fileError.append(IException(e, IException::Unknown, msg, _FILEINFO_));
321 finalError.append(fileError);
325 fileError.append(IException(IException::Unknown, msg, _FILEINFO_));
328 delete shapeModelCube;
333 finalError.append(fileError);
338 if (shapeModel == NULL) {