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"
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.";
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";
174 QString b_msg =
"Bullet could not initialize DEM!";
181 b_model->setTolerance(tolerance);
184 kernelsPvlGroup.addKeyword(
PvlKeyword(
"RayTraceEngine", preferred), PvlContainer::Replace);
185 kernelsPvlGroup.addKeyword(
PvlKeyword(
"OnError", onerror), PvlContainer::Replace);
187 PvlContainer::Replace);
193 fileError.append(ie);
194 QString mess =
"Unable to create preferred BulletShapeModel";
196 if (
"fail" == onerror) {
205 if (
"embree" == preferred ) {
208 FileName v_shapefile(shapeModelFilenames);
209 QString ext = v_shapefile.extension().toLower();
218 embreeModel->setTolerance(tolerance);
221 kernelsPvlGroup.addKeyword(
PvlKeyword(
"RayTraceEngine", preferred), PvlContainer::Replace);
222 kernelsPvlGroup.addKeyword(
PvlKeyword(
"OnError", onerror), PvlContainer::Replace);
224 PvlContainer::Replace);
226 return ( embreeModel );
229 fileError.append(ie);
230 QString mess =
"Unable to create preferred EmbreeShapeModel";
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.";
256 if (shapeModel == NULL) {
259 fileError.append(dskError);
266 shapeModelCube->
open(
FileName(shapeModelFilenames).expanded(),
"r" );
270 QString msg =
"The given shape model file is not a valid ISIS DEM. "
271 "Unable to open as an ISIS cube.";
273 finalError.append(fileError);
280 projection = shapeModelCube->projection();
284 QString msg =
"The given shape model file is not a valid ISIS DEM cube. "
285 "It is not map-projected.";
287 finalError.append(fileError);
294 QString msg =
"Unable to construct a DEM shape model from the given "
295 "EquatorialCylindrical projected ISIS cube.";
303 finalError.append(fileError);
312 QString msg =
"Unable to construct a DEM shape model "
313 "from the given projected ISIS cube file.";
316 shapeModel =
new DemShape(target, pvl);
321 finalError.append(fileError);
328 delete shapeModelCube;
333 finalError.append(fileError);
338 if (shapeModel == NULL) {
Shape model that uses the Bullet library to perform ray tracing.
Bullet Target Shape for planetary bodies.
static BulletTargetShape * load(const QString &dem, const Pvl *conf=0)
Load a DEM file into the target shape.
IO Handler for Isis Cubes.
void open(const QString &cfile, QString access="r")
This method will open an existing isis cube for reading or reading/writing.
Define shapes and provide utilities for targets stored as ISIS maps.
Define shapes and provide utilities for ISIS targets.
General purpose Embree ray tracing model.
Class for managing the construction and destruction of EmbreeTargetShapes.
static EmbreeTargetManager * getInstance()
Retrieve reference to Singleton instance of this object.
Define shapes and provide utilities for shapes stored as ISIS EquatorialCylindrical map.
File name manipulation and expansion.
@ Unknown
A type of error that cannot be classified as any of the other error types.
@ Programmer
This error is for when a programmer made an API call that was illegal.
@ Io
A type of error that occurred when performing an actual I/O operation.
Provides support for NAIF's Digital Shape Kernel (DSK)
Define plane shape model.
Base class for Map Projections.
virtual bool IsEquatorialCylindrical()
This method returns true if the projection is equatorial cylindrical.
Provides a flat map of PvlKeywords.
QString get(const QString &key, const int &index=0) const
Gets the value of a keyword in the PvlFlatMap.
int merge(const PvlFlatMap &other)
Adds the keywords from another PvlFlatMap.
Contains multiple PvlContainers.
Container for cube-like labels.
A single keyword-value pair.
@ Traverse
Search child objects.
ShapeModelFactory()
Constructor is private to avoid instantiating the class.
~ShapeModelFactory()
Destructor.
static ShapeModel * create(Target *target, Pvl &pvl)
Construct a valid shape model from the given target and contents of kernels group.
Define shapes and provide utilities for Isis targets.
This class is used to create and store valid Isis targets.
bool isSky() const
Return if our target is the sky.
This is free and unencumbered software released into the public domain.
QString toString(bool boolToConvert)
Global function to convert a boolean to a string.
double toDouble(const QString &string)
Global function to convert from a string to a double.
Namespace for the standard library.