8 #include "ShapeModelFactory.h"
12 #include "BulletShapeModel.h"
13 #include "BulletTargetShape.h"
16 #include "EllipsoidShape.h"
17 #include "EmbreeShapeModel.h"
18 #include "EmbreeTargetManager.h"
19 #include "EquatorialCylindricalShape.h"
21 #include "IException.h"
23 #include "NaifDskShape.h"
24 #include "NaifStatus.h"
25 #include "PlaneShape.h"
26 #include "Projection.h"
27 #include "Preference.h"
29 #include "PvlFlatMap.h"
31 #include "PvlKeyword.h"
42 ShapeModelFactory::ShapeModelFactory() {
47 ShapeModelFactory::~ShapeModelFactory() {
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"];
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.";
129 else if (shapeModelFilenames ==
"RingPlane") {
132 QString msg =
"Unable to construct a RingPlane shape model.";
147 QString preferred = parameters.
get(
"RayTraceEngine",
"None").toLower();
148 QString onerror = parameters.
get(
"OnError",
"Continue").toLower();
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();
170 QString mess =
"Bullet could not initialize ISIS Cube DEM";
171 throw IException(IException::Unknown, mess, _FILEINFO_);
175 QString b_msg =
"Bullet could not initialize DEM!";
176 throw IException(IException::Unknown, b_msg, _FILEINFO_);
188 PvlContainer::Replace);
194 QString mess =
"Unable to create preferred BulletShapeModel";
196 if (
"fail" == onerror)
throw fileError;
203 if (
"embree" == preferred ) {
206 FileName v_shapefile(shapeModelFilenames);
207 QString ext = v_shapefile.
extension().toLower();
222 PvlContainer::Replace);
224 return ( embreeModel );
228 QString mess =
"Unable to create preferred EmbreeShapeModel";
230 if (
"fail" == onerror)
throw fileError;
238 QString msg =
"The given shape model file is not a valid NAIF DSK file. "
239 "Unable to construct a NAIF DSK shape model.";
240 IException dskError(IException::Unknown, msg, _FILEINFO_);
252 if (shapeModel == NULL) {
255 fileError.
append(dskError);
262 shapeModelCube->
open(
FileName(shapeModelFilenames).expanded(),
"r" );
266 QString msg =
"The given shape model file is not a valid ISIS DEM. "
267 "Unable to open as an ISIS cube.";
269 finalError.
append(fileError);
280 QString msg =
"The given shape model file is not a valid ISIS DEM cube. "
281 "It is not map-projected.";
283 finalError.
append(fileError);
290 QString msg =
"Unable to construct a DEM shape model from the given "
291 "EquatorialCylindrical projected ISIS cube.";
299 finalError.
append(fileError);
308 QString msg =
"Unable to construct a DEM shape model "
309 "from the given projected ISIS cube file.";
312 shapeModel =
new DemShape(target, pvl);
317 finalError.
append(fileError);
324 delete shapeModelCube;
329 finalError.
append(fileError);
334 if (shapeModel == NULL) {