//----------------------------------------------------------------------------- Profile* ProfileManager::GetProfile(const ProfileDeviceKey& deviceKey, const char* user) { Lock::Locker lockScope(&ProfileLock); if (ProfileCache == NULL) { // Load the cache LoadCache(false); if (ProfileCache == NULL) return NULL; } Profile* profile = new Profile(BasePath); if (deviceKey.Valid) { if (!profile->LoadDeviceProfile(deviceKey) && (user == NULL)) { profile->Release(); return NULL; } } if (user) { const char* product_str = deviceKey.ProductName.IsEmpty() ? NULL : deviceKey.ProductName.ToCStr(); const char* serial_str = deviceKey.PrintedSerial.IsEmpty() ? NULL : deviceKey.PrintedSerial.ToCStr(); if (!profile->LoadProfile(ProfileCache.GetPtr(), user, product_str, serial_str)) { profile->Release(); return NULL; } } return profile; }
/** * Creates a Mariner10 Camera Model * * @param lab Pvl label from a Mariner 10 image. * * @throw iException::User - "File does not appear to be a Mariner 10 image. * Invalid InstrumentId." * @throw iException::Programmer - "Unable to create distortion map." * @internal * @history 2011-05-03 Jeannie Walldren - Added NAIF error check. * */ Mariner10Camera::Mariner10Camera(Pvl &lab) : FramingCamera(lab) { NaifStatus::CheckErrors(); // Turn off the aberration corrections for instrument position object instrumentPosition()->SetAberrationCorrection("NONE"); instrumentRotation()->SetFrame(-76000); // Set camera parameters SetFocalLength(); SetPixelPitch(); PvlGroup inst = lab.findGroup("Instrument", Pvl::Traverse); // Get utc start time QString stime = inst["StartTime"]; iTime startTime; startTime.setUtc((QString)inst["StartTime"]); setTime(startTime); // Setup detector map new CameraDetectorMap(this); // Setup focal plane map, and detector origin CameraFocalPlaneMap *focalMap = new CameraFocalPlaneMap(this, naifIkCode()); QString ikernKey = "INS" + toString((int)naifIkCode()) + "_BORESIGHT_SAMPLE"; double sampleBoresight = getDouble(ikernKey); ikernKey = "INS" + toString((int)naifIkCode()) + "_BORESIGHT_LINE"; double lineBoresight = getDouble(ikernKey); focalMap->SetDetectorOrigin(sampleBoresight, lineBoresight); // Setup distortion map which is dependent on encounter, use start time // MOON: 1973-11-08T03:16:26.350 QString spacecraft = (QString)inst["SpacecraftName"]; QString instId = (QString)inst["InstrumentId"]; QString cam; if(instId == "M10_VIDICON_A") { cam = "a"; } else if(instId == "M10_VIDICON_B") { cam = "b"; } else { QString msg = "File does not appear to be a Mariner10 image. InstrumentId [" + instId + "] is invalid Mariner 10 value."; throw IException(IException::User, msg, _FILEINFO_); } QString fname = FileName("$mariner10/reseaus/mar10" + cam + "MasterReseaus.pvl").expanded(); try { new ReseauDistortionMap(this, lab, fname); } catch(IException &e) { string msg = "Unable to create distortion map."; throw IException(e, IException::Programmer, msg, _FILEINFO_); } // Setup the ground and sky map new CameraGroundMap(this); new CameraSkyMap(this); LoadCache(); NaifStatus::CheckErrors(); }
/** * Creates a Hirise Camera Model * * @param lab Pvl label from the iamge * @internal * @history 2011-05-03 Jeannie Walldren - Added NAIF error check. */ HiriseCamera::HiriseCamera(Cube &cube) : LineScanCamera(cube) { NaifStatus::CheckErrors(); // Setup camera characteristics from instrument and frame kernel SetFocalLength(); SetPixelPitch(); //LoadFrameMounting("MRO_SPACECRAFT", "MRO_HIRISE_OPTICAL_AXIS"); instrumentRotation()->SetFrame(-74690); // Get required keywords from instrument group Pvl &lab = *cube.label(); PvlGroup &inst = lab.findGroup("Instrument", Pvl::Traverse); int tdiMode = inst["Tdi"]; double binMode = inst["Summing"]; int chan = inst["ChannelNumber"]; int cpmm = inst["CpmmNumber"]; double deltaLineTimerCount = inst["DeltaLineTimerCount"]; QString stime = inst["SpacecraftClockStartCount"]; // Convert CPMM number to CCD number static int cpmm2ccd[] = {0, 1, 2, 3, 12, 4, 10, 11, 5, 13, 6, 7, 8, 9}; int ccd = cpmm2ccd[cpmm]; // Compute the line rate, convert to seconds, and multiply by the // downtrack summing double unBinnedRate = (74.0 + (deltaLineTimerCount / 16.0)) / 1000000.0; double lineRate = unBinnedRate * binMode; // Convert the spacecraft clock count to ephemeris time SpiceDouble et; // The -74999 is the code to select the transformation from // high-precision MRO SCLK to ET et = getClockTime(stime, -74999).Et(); // Adjust the start time so that it is the effective time for // the first line in the image file. Note that on 2006-03-29, this // time is now subtracted as opposed to adding it. The computed start // time in the EDR is at the first serial line. et -= unBinnedRate * (((double) tdiMode / 2.0) - 0.5); // Effective observation // time for all the TDI lines used for the // first line before doing binning et += unBinnedRate * (((double) binMode / 2.0) - 0.5); // Effective observation time of the first line // in the image file, which is possibly binned // Compute effective line number within the CCD (in pixels) for the // given TDI mode. // This is the "centered" 0-based line number, where line 0 is the // center of the detector array and line numbers decrease going // towards the serial readout. Line number +64 sees a spot // on the ground before line number 0 or -64. double ccdLine_c = -64.0 + ((double) tdiMode / 2.0); // Setup detector map for transform of image pixels to detector position // CameraDetectorMap *detectorMap = // new LineScanCameraDetectorMap(this,et,lineRate); LineScanCameraDetectorMap *detectorMap = new LineScanCameraDetectorMap(this, et, lineRate); detectorMap->SetDetectorSampleSumming(binMode); detectorMap->SetDetectorLineSumming(binMode); if(chan == 0) { detectorMap->SetStartingDetectorSample(1025.0); } // Setup focal plane map for transform of detector position to // focal plane x/y. This will read the appropriate CCD // transformation coefficients from the instrument kernel CameraFocalPlaneMap *focalMap = new CameraFocalPlaneMap(this, -74600 - ccd); focalMap->SetDetectorOrigin(1024.5, 0.0); focalMap->SetDetectorOffset(0.0, ccdLine_c); // Setup distortion map. This will read the optical distortion // coefficients from the instrument kernel CameraDistortionMap *distortionMap = new CameraDistortionMap(this); distortionMap->SetDistortion(naifIkCode()); // Setup the ground and sky map to transform undistorted focal // plane x/y to lat/lon or ra/dec respectively. new LineScanCameraGroundMap(this); new LineScanCameraSkyMap(this); LoadCache(); NaifStatus::CheckErrors(); }
void BuildTable::Init (IAICallback *callback, bool cache) { cb = callback; char cachefn[80]; ReplaceExtension (cb->GetModName (), cachefn, sizeof(cachefn), "modcache"); if (cache) { if (LoadCache (cachefn)) return; } // this is what makes loading times long, because spring will load unit defs only when they're needed. // meaning, GetUnitDefs() will make spring load all the unit defs at once. numDefs = cb->GetNumUnitDefs(); deflist = new UDef[numDefs]; const UnitDef** templist=new const UnitDef*[numDefs]; cb->GetUnitDefList (templist); for (int a=0;a<numDefs;a++) { UDef& d = deflist[a]; d.def = templist[a]; d.cost.energy = d.def->energyCost; d.cost.metal = d.def->metalCost; d.make.energy = d.def->energyMake; d.make.metal = d.def->metalMake; if (d.def->activateWhenBuilt) { // Solars have negative energy upkeep so they can be disabled d.make.energy -= d.def->energyUpkeep; d.make.metal += d.def->makesMetal; d.make.metal -= d.def->metalUpkeep; } d.storage.energy = d.def->energyStorage; d.storage.metal = d.def->metalStorage; d.metalExtractDepth = d.def->extractsMetal; d.buildTime = d.def->buildTime; d.energyUse = d.def->energyUpkeep; d.buildSpeed = d.def->buildSpeed; d.numBuildOptions = d.def->buildOptions.size(); d.flags = 0; if (!d.def->buildOptions.empty ()) d.flags |= CUD_Builder; if (d.def->type == "Building" || d.def->type == "Factory" || d.def->type == "MetalExtractor") d.flags |= CUD_Building; if (d.def->windGenerator) d.flags |= CUD_WindGen; if (d.def->movedata) { d.moveType = d.def->movedata->moveType; d.flags |= CUD_MoveType; } deflist[a].def = templist[a]; deflist[a].name = templist[a]->name; d.weaponDamage = 0.0f; d.weaponRange = 0.0f; for (int b=0;b<d.def->weapons.size();b++) { const WeaponDef* w = d.def->weapons[b].def; if (d.weaponRange < w->range) d.weaponRange = w->range; d.weaponDamage += CalcAverageDamage (&w->damages); } } delete[] templist; table.alloc(numDefs); logPrintf ("Calculating build table for %d build types...\n", numDefs); // convert all string'ed identifiers to id's, which can be used for indexing directly buildby = new std::vector<int>[numDefs]; for (int a=0;a<numDefs;a++) { const UnitDef *def=deflist[a].def; for (map<int,string>::const_iterator i=def->buildOptions.begin();i!=def->buildOptions.end();++i) { const UnitDef *bdef = cb->GetUnitDef (i->second.c_str()); if (bdef) buildby[bdef->id-1].push_back(a); } deflist[a].buildby = &buildby [a]; } for (int a=0;a<numDefs;a++) CalcBuildTable (a, a, 0, ResInfo()); SaveCache (cachefn); /* for (int a=0;a<numDefs;a++) { logPrintf ("%s builds:", deflist[a].name.c_str()); for (int b=0;b<numDefs;b++) { BuildTable::Table::ent& e=table.get(a,b); if (e.id>=0) logPrintf ("%s by building %s (%d), ", deflist[b].name.c_str(), deflist[e.id].name.c_str(), e.depth); } logPrintf ("\n"); }*/ }
static void BuildList( void ) { int numDirs, numDemos; void **dirlist, **demolist; char *cache, *p; unsigned flags; size_t len; int i; // this can be a lengthy process S_StopAllSounds(); m_demos.menu.status = "Building list..."; SCR_UpdateScreen(); // list files flags = ui_listalldemos->integer ? 0 : FS_TYPE_REAL | FS_PATH_GAME; dirlist = FS_ListFiles( m_demos.browse, NULL, flags | FS_SEARCH_DIRSONLY, &numDirs ); demolist = FS_ListFiles( m_demos.browse, DEMO_EXTENSIONS, flags | FS_SEARCH_EXTRAINFO, &numDemos ); // alloc entries m_demos.list.items = UI_Malloc( sizeof( demoEntry_t * ) * ( numDirs + numDemos + 1 ) ); m_demos.list.numItems = 0; m_demos.list.curvalue = 0; m_demos.list.prestep = 0; m_demos.widest_map = 3; m_demos.widest_pov = 3; m_demos.total_bytes = 0; // start with minimum size m_demos.menu.size( &m_demos.menu ); if( m_demos.browse[0] ) { BuildDir( "..", ENTRY_UP ); } // add directories if( dirlist ) { for( i = 0; i < numDirs; i++ ) { BuildDir( dirlist[i], ENTRY_DN ); } FS_FreeList( dirlist ); } m_demos.numDirs = m_demos.list.numItems; // add demos if( demolist ) { CalcHash( demolist ); if( ( cache = LoadCache( demolist ) ) != NULL ) { p = cache + 32 + 1; for( i = 0; i < numDemos; i++ ) { BuildName( demolist[i], &p ); } FS_FreeFile( cache ); } else { for( i = 0; i < numDemos; i++ ) { BuildName( demolist[i], NULL ); if( ( i & 7 ) == 0 ) { m_demos.menu.size( &m_demos.menu ); SCR_UpdateScreen(); } } } WriteCache(); FS_FreeList( demolist ); } // update status line and sort if( m_demos.list.numItems ) { Change( &m_demos.list.generic ); if( m_demos.list.sortdir ) { m_demos.list.sort( &m_demos.list, m_demos.list.sortcol ); } } // resize columns m_demos.menu.size( &m_demos.menu ); // format our extra status line i = m_demos.list.numItems - m_demos.numDirs; len = Q_scnprintf( m_demos.status, sizeof( m_demos.status ), "%d demo%s, ", i, i == 1 ? "" : "s" ); Com_FormatSizeLong( m_demos.status + len, sizeof( m_demos.status ) - len, m_demos.total_bytes ); SCR_UpdateScreen(); }
/** * Constructs a Clementine HiresCamera object using the image labels. * * @param lab Pvl label from a Clementine HIRES image. * * @internal * @history 2011-05-03 Jeannie Walldren - Added NAIF error check. Added * call to ShutterOpenCloseTimes() method. Changed * centertime to add half exposure duration to start * time to maintain consistency with other Clementine * models. */ NirCamera::NirCamera(Cube &cube) : FramingCamera(cube) { NaifStatus::CheckErrors(); // Get the camera characteristics Pvl &lab = *cube.label(); QString filter = (QString)(lab.findGroup("BandBin", Pvl::Traverse))["FilterName"]; filter = filter.toUpper(); if(filter.compare("A") == 0) { SetFocalLength(2548.2642 * 0.038); } else if(filter.compare("B") == 0) { SetFocalLength(2530.8958 * 0.038); } else if(filter.compare("C") == 0) { SetFocalLength(2512.6589 * 0.038); } else if(filter.compare("D") == 0) { SetFocalLength(2509.0536 * 0.038); } else if(filter.compare("E") == 0) { SetFocalLength(2490.7378 * 0.038); } else if(filter.compare("F") == 0) { SetFocalLength(2487.8694 * 0.038); } SetPixelPitch(); // Get the start time in et PvlGroup inst = lab.findGroup("Instrument", Pvl::Traverse); // set variables startTime and exposureDuration double et = iTime((QString)inst["StartTime"]).Et(); // divide exposure duration keyword value by 1000 to convert to seconds double exposureDuration = ((double) inst["ExposureDuration"]) / 1000.0; pair<iTime, iTime> shuttertimes = ShutterOpenCloseTimes(et, exposureDuration); /************************************************************************ * The following line was uncommented to maintain consistency within all * clementine camera models. Not sure why the following was originally * commented out: * 2010-08-05 Jeannie Walldren ***********************************************************************/ // Do not correct time for center of the exposure duration. This is because // the kernels were built to accept the start times of the images. iTime centerTime = shuttertimes.first.Et() + exposureDuration / 2.0; // Setup detector map new CameraDetectorMap(this); // Setup focal plane map CameraFocalPlaneMap *focalMap = new CameraFocalPlaneMap(this, naifIkCode()); focalMap->SetDetectorOrigin( Spice::getDouble("INS" + toString(naifIkCode()) + "_BORESIGHT_SAMPLE"), Spice::getDouble("INS" + toString(naifIkCode()) + "_BORESIGHT_LINE")); // Setup distortion map new RadialDistortionMap(this, -0.0006364); // Setup the ground and sky map new CameraGroundMap(this); new CameraSkyMap(this); setTime(centerTime); LoadCache(); NaifStatus::CheckErrors(); }
//----------------------------------------------------------------------------- bool ProfileManager::SetTaggedProfile(const char** tag_names, const char** tags, int num_tags, Profile* profile) { Lock::Locker lockScope(&ProfileLock); if (ProfileCache == NULL) { // Load the cache LoadCache(true); if (ProfileCache == NULL) return false; // TODO: Generate a new profile DB } JSON* tagged_data = ProfileCache->GetItemByName("TaggedData"); OVR_ASSERT(tagged_data); if (tagged_data == NULL) return false; // Get the cached tagged data section JSON* vals = FindTaggedData(tagged_data, tag_names, tags, num_tags); if (vals == NULL) { JSON* tagged_item = JSON::CreateObject(); JSON* taglist = JSON::CreateArray(); for (int i=0; i<num_tags; i++) { JSON* k = JSON::CreateObject(); k->AddStringItem(tag_names[i], tags[i]); taglist->AddArrayElement(k); } vals = JSON::CreateObject(); tagged_item->AddItem("tags", taglist); tagged_item->AddItem("vals", vals); tagged_data->AddArrayElement(tagged_item); } // Now add or update each profile setting in cache for (unsigned int i=0; i<profile->Values.GetSize(); i++) { JSON* value = profile->Values[i]; bool found = false; JSON* item = vals->GetFirstItem(); while (item) { if (value->Name == item->Name) { // Don't allow a pre-existing type to be overridden OVR_ASSERT(value->Type == item->Type); if (value->Type == item->Type) { // Check for the same value if (value->Type == JSON_Array) { // Update each array item if (item->GetArraySize() == value->GetArraySize()) { // Update each value (assumed to be basic types and not array of objects) JSON* value_element = value->GetFirstItem(); JSON* item_element = item->GetFirstItem(); while (item_element && value_element) { if (value_element->Type == JSON_String) { if (item_element->Value != value_element->Value) { // Overwrite the changed value and mark for file update item_element->Value = value_element->Value; Changed = true; } } else { if (item_element->dValue != value_element->dValue) { // Overwrite the changed value and mark for file update item_element->dValue = value_element->dValue; Changed = true; } } value_element = value->GetNextItem(value_element); item_element = item->GetNextItem(item_element); } } else { // if the array size changed, simply create a new one // TODO: Create the new array } } else if (value->Type == JSON_String) { if (item->Value != value->Value) { // Overwrite the changed value and mark for file update item->Value = value->Value; Changed = true; } } else { if (item->dValue != value->dValue) { // Overwrite the changed value and mark for file update item->dValue = value->dValue; Changed = true; } } } else { return false; } found = true; break; } item = vals->GetNextItem(item); } if (!found) { // Add the new value Changed = true; if (value->Type == JSON_String) vals->AddStringItem(value->Name, value->Value); else if (value->Type == JSON_Bool) vals->AddBoolItem(value->Name, ((int)value->dValue != 0)); else if (value->Type == JSON_Number) vals->AddNumberItem(value->Name, value->dValue); else if (value->Type == JSON_Array) vals->AddItem(value->Name, value->Copy()); else { OVR_ASSERT(false); Changed = false; } } } return true; }
//------------------------------------------------------------------------------ void ProfileManager::Read() { LoadCache(false); }
void InitRecordsDsbl(void) { LoadCache(&chRecordDsbl); }
/** * Constructor for the LRO NAC Camera Model * * @param lab Pvl Label to create the camera model from * * @internal * @history 2011-05-03 Jeannie Walldren - Added NAIF error check. */ LroNarrowAngleCamera::LroNarrowAngleCamera(Cube &cube) : LineScanCamera(cube) { NaifStatus::CheckErrors(); // Set up the camera info from ik/iak kernels SetFocalLength(); SetPixelPitch(); double constantTimeOffset = 0.0, additionalPreroll = 0.0, additiveLineTimeError = 0.0, multiplicativeLineTimeError = 0.0; QString ikernKey = "INS" + toString(naifIkCode()) + "_CONSTANT_TIME_OFFSET"; constantTimeOffset = getDouble(ikernKey); ikernKey = "INS" + toString(naifIkCode()) + "_ADDITIONAL_PREROLL"; additionalPreroll = getDouble(ikernKey); ikernKey = "INS" + toString(naifIkCode()) + "_ADDITIVE_LINE_ERROR"; additiveLineTimeError = getDouble(ikernKey); ikernKey = "INS" + toString(naifIkCode()) + "_MULTIPLI_LINE_ERROR"; multiplicativeLineTimeError = getDouble(ikernKey); // Get the start time from labels Pvl &lab = *cube.label(); PvlGroup &inst = lab.findGroup("Instrument", Pvl::Traverse); QString stime = inst["SpacecraftClockPrerollCount"]; SpiceDouble etStart; if(stime != "NULL") { etStart = getClockTime(stime).Et(); } else { etStart = iTime((QString)inst["PrerollTime"]).Et(); } // Get other info from labels double csum = inst["SpatialSumming"]; double lineRate = (double) inst["LineExposureDuration"] / 1000.0; double ss = inst["SampleFirstPixel"]; ss += 1.0; lineRate *= 1.0 + multiplicativeLineTimeError; lineRate += additiveLineTimeError; etStart += additionalPreroll * lineRate; etStart += constantTimeOffset; setTime(etStart); // Setup detector map LineScanCameraDetectorMap *detectorMap = new LineScanCameraDetectorMap(this, etStart, lineRate); detectorMap->SetDetectorSampleSumming(csum); detectorMap->SetStartingDetectorSample(ss); // Setup focal plane map CameraFocalPlaneMap *focalMap = new CameraFocalPlaneMap(this, naifIkCode()); // Retrieve boresight location from instrument kernel (IK) (addendum?) ikernKey = "INS" + toString(naifIkCode()) + "_BORESIGHT_SAMPLE"; double sampleBoreSight = getDouble(ikernKey); ikernKey = "INS" + toString(naifIkCode()) + "_BORESIGHT_LINE"; double lineBoreSight = getDouble(ikernKey); focalMap->SetDetectorOrigin(sampleBoreSight, lineBoreSight); focalMap->SetDetectorOffset(0.0, 0.0); // Setup distortion map LroNarrowAngleDistortionMap *distMap = new LroNarrowAngleDistortionMap(this); distMap->SetDistortion(naifIkCode()); // Setup the ground and sky map new LineScanCameraGroundMap(this); new LineScanCameraSkyMap(this); LoadCache(); NaifStatus::CheckErrors(); }
/** * @brief Initialize the MDIS camera model for NAC and WAC * * This constructor reads the Messenger/MDIS instrument addendum for many of * its default parameters. * * This camera model does not support subframes of jailbar imaging modes. * An exception is thrown in those cases. * * @param lab Pvl label from a Messenger MDIS image. * * @throws iException::User - "Subframe imaging mode is not supported" * @throws iException::User - "Jail bar observations are not supported" * @throws iException::User - "New MDIS/NAC distortion model invalidates * previous SPICE - you must rerun spiceinit to get new * kernels" * @internal * @history 2011-05-03 Jeannie Walldren - Added NAIF error check. * */ MdisCamera::MdisCamera(Pvl &lab) : FramingCamera(lab) { NaifStatus::CheckErrors(); // Set up detector constants const int MdisWac(-236800); // const int MdisNac(-236820); PvlGroup &inst = lab.findGroup("Instrument", Pvl::Traverse); // Clarification on MDIS subframe image mode provides us the ability to // support this mode now. The entire MDIS frame is geometrically valid // but only portions of the full frame actually contain image data. The // portions outside subframes should be NULL and not interfere in // downstream processing, such as mosaics. #if defined(MDIS_SUBFRAMES_UNSUPPORTED) int subFrameMode = inst["SubFrameMode"]; if(subFrameMode != 0) { string msg = "Subframe imaging mode is not supported!"; throw iException::Message(iException::User, msg, _FILEINFO_); } #endif // According to the MDIS team, this is nothing to be concerned with and // should be treated as other normal observations. So the test to // disallow it has been effectively removed 2007-09-05 (KJB). #if defined(MDIS_JAILBARS_UNSUPPORTED) int jailBars = inst["JailBars"]; if(jailBars != 0) { string msg = "Jail bar observations are not currently supported!"; throw iException::Message(iException::Programmer, msg, _FILEINFO_); } #endif // Determine filter number. Only conditional code required for // NAC and WAC support! int filterNumber(0); // Default appropriate for MDIS-NAC if(naifIkCode() == MdisWac) { PvlGroup &bandBin = lab.findGroup("BandBin", Pvl::Traverse); filterNumber = bandBin["Number"]; } // Set up instrument and filter code strings QString ikCode = toString(naifIkCode()); int fnCode(naifIkCode() - filterNumber); QString filterCode = toString(fnCode); QString ikernKey; // Fetch the frame translations from the instrument kernels ikernKey = "INS" + ikCode + "_REFERENCE_FRAME"; QString baseFrame = getString(ikernKey); ikernKey = "INS" + filterCode + "_FRAME"; QString ikFrame = getString(ikernKey); // Set up the camera info from ik/iak kernels // Turns out (2008-01-17) the WAC has different focal lengths for // each filter. Added to the instrument kernel (IAK) on this date. // Add temperature dependant focal length SetFocalLength(computeFocalLength(filterCode, lab)); SetPixelPitch(); // Removed by Jeff Anderson. The refactor of the SPICE class // uses frames always so this is no longer needed // LoadFrameMounting(baseFrame, ikFrame, false); // Get the start time from labels as the starting image time plus half // the exposure duration (in <MS>) to get pointing attitude. // !!NOTE: The ephemeris time MUST be set prior to creating the // cache (CreateCache) because the kernels are all unloaded // after the cache is done and this operation will fail!! QString stime = inst["SpacecraftClockCount"]; double exposureDuration = ((double) inst["ExposureDuration"]) / 1000.0;// divide by 1000 to convert to seconds iTime etStart = getClockTime(stime); // Setup camera detector map CameraDetectorMap *detMap = new CameraDetectorMap(this); // Setup focal plane map, and detector origin for the instrument that // may have a filter (WAC only!). CameraFocalPlaneMap *focalMap = new CameraFocalPlaneMap(this, fnCode); // Retrieve boresight location from instrument kernel (IK) (addendum?) ikernKey = "INS" + ikCode + "_BORESIGHT_SAMPLE"; double sampleBoreSight = getDouble(ikernKey); ikernKey = "INS" + ikCode + "_BORESIGHT_LINE"; double lineBoreSight = getDouble(ikernKey); // Apply the boresight focalMap->SetDetectorOrigin(sampleBoreSight, lineBoreSight); // Determine summing. MDIS has two sources of summing or binning. // One is performed in the FPU and the in the MP, post-observation, // on-board after coming out of the FPGAs, where the FPU binning is // performed. The FPU binning was programmed incorrectly and the // actual pixels from the detector are peculiar. Hence, I have // designed this camera model such that the offsets can be managed // external to the code. See the MDIS instrument kernel addendum // in $ISIS3DATA/messenger/kernels/iak/mdisAddendum???.ti for the // offsets for *each* detector. Note that an offset is only applied // when FPU binning is performed. int fpuBinMode = inst["FpuBinningMode"]; int pixelBinMode = inst["PixelBinningMode"]; int summing = ((pixelBinMode == 0) ? 1 : pixelBinMode); // FPU binning was performed, retrieve the FPU binning offsets and // apply them to the focal plane mapping. if(fpuBinMode == 1) { #if defined(USE_FPU_BINNING_OFFSETS) ikernKey = "INS" + ikCode + "_FPUBIN_START_SAMPLE"; double fpuStartingSample = getDouble(ikernKey); detMap->SetStartingDetectorSample(fpuStartingSample); ikernKey = "INS" + ikCode + "_FPUBIN_START_LINE"; double fpuStartingLine = getDouble(ikernKey); detMap->SetStartingDetectorLine(fpuStartingLine); #endif summing *= 2; } // Set summing/binning modes as an accumulation of FPU and MP binning. detMap->SetDetectorLineSumming(summing); detMap->SetDetectorSampleSumming(summing); // Setup distortion map. As of 2007/12/06, we now have an actual model. // Note that this model supports distinct distortion for each WAC filter. // See $ISIS3DATA/messenger/kernels/iak/mdisAddendumXXX.ti or possibly // $ISIS3DATA/messenger/kernels/ik/msgr_mdis_vXXX.ti for the *_OD_K // parameters. // NAC has a new implementation of its distortion contributed by // Scott Turner and Lillian Nguyen at JHUAPL. // (2010/10/06) The WAC now uses the same disortion model implementation. // Valid Taylor Series parameters are in versions msgr_mdis_v120.ti IK // and above. Note fnCode works for NAC as well as long as // filterNumber stays at 0 for the NAC only! try { TaylorCameraDistortionMap *distortionMap = new TaylorCameraDistortionMap(this); distortionMap->SetDistortion(fnCode); } catch(IException &ie) { string msg = "New MDIS NAC/WAC distortion models will invalidate previous " "SPICE - you may need to rerun spiceinit to get new kernels"; throw IException(ie, IException::User, msg, _FILEINFO_); } // Setup the ground and sky map new CameraGroundMap(this); new CameraSkyMap(this); // Create a cache and grab spice info since it does not change for // a framing camera (fixed spacecraft position and pointing) after, // of course applying the gimble offset which is handled in the SPICE // kernels (thank you!). Note this was done automagically in the // SetEpheremisTime call above. IMPORTANT that it be done prior to // creating the cache since all kernels are unloaded, essentially // clearing the pool and whacking the frames definitions, required to iTime centerTime = etStart + (exposureDuration / 2.0); setTime(centerTime); LoadCache(); NaifStatus::CheckErrors(); }
GPU_Vulkan::GPU_Vulkan(GraphicsContext *gfxCtx, Draw::DrawContext *draw) : GPUCommon(gfxCtx, draw), vulkan_((VulkanContext *)gfxCtx->GetAPIContext()), drawEngine_(vulkan_, draw), depalShaderCache_(draw, vulkan_), vulkan2D_(vulkan_) { UpdateVsyncInterval(true); CheckGPUFeatures(); shaderManagerVulkan_ = new ShaderManagerVulkan(vulkan_); pipelineManager_ = new PipelineManagerVulkan(vulkan_); framebufferManagerVulkan_ = new FramebufferManagerVulkan(draw, vulkan_); framebufferManager_ = framebufferManagerVulkan_; textureCacheVulkan_ = new TextureCacheVulkan(draw, vulkan_); textureCache_ = textureCacheVulkan_; drawEngineCommon_ = &drawEngine_; shaderManager_ = shaderManagerVulkan_; drawEngine_.SetTextureCache(textureCacheVulkan_); drawEngine_.SetFramebufferManager(framebufferManagerVulkan_); drawEngine_.SetShaderManager(shaderManagerVulkan_); drawEngine_.SetPipelineManager(pipelineManager_); framebufferManagerVulkan_->SetVulkan2D(&vulkan2D_); framebufferManagerVulkan_->Init(); framebufferManagerVulkan_->SetTextureCache(textureCacheVulkan_); framebufferManagerVulkan_->SetDrawEngine(&drawEngine_); framebufferManagerVulkan_->SetShaderManager(shaderManagerVulkan_); textureCacheVulkan_->SetDepalShaderCache(&depalShaderCache_); textureCacheVulkan_->SetFramebufferManager(framebufferManagerVulkan_); textureCacheVulkan_->SetShaderManager(shaderManagerVulkan_); textureCacheVulkan_->SetDrawEngine(&drawEngine_); textureCacheVulkan_->SetVulkan2D(&vulkan2D_); InitDeviceObjects(); // Sanity check gstate if ((int *)&gstate.transferstart - (int *)&gstate != 0xEA) { ERROR_LOG(G3D, "gstate has drifted out of sync!"); } BuildReportingInfo(); // Update again after init to be sure of any silly driver problems. UpdateVsyncInterval(true); textureCacheVulkan_->NotifyConfigChanged(); if (vulkan_->GetFeaturesEnabled().wideLines) { drawEngine_.SetLineWidth(PSP_CoreParameter().renderWidth / 480.0f); } // Load shader cache. std::string discID = g_paramSFO.GetDiscID(); if (discID.size()) { File::CreateFullPath(GetSysDirectory(DIRECTORY_APP_CACHE)); shaderCachePath_ = GetSysDirectory(DIRECTORY_APP_CACHE) + "/" + discID + ".vkshadercache"; shaderCacheLoaded_ = false; std::thread th([&] { LoadCache(shaderCachePath_); shaderCacheLoaded_ = true; }); th.detach(); } }
void InitGaps(void) { LoadCache(&chGapsFlag); LoadCache(&chGaps); }
/** * Constructs an Apollo Metric Camera object using the image labels. * * @param cube An Apollo Metric image. * * @internal * @history 2011-01-14 Travis Addair - Added new CK/SPK accessor methods. * @history 2011-05-03 Jeannie Walldren - Added documentation. */ ApolloMetricCamera::ApolloMetricCamera(Cube &cube) : FramingCamera(cube) { NaifStatus::CheckErrors(); // Get the camera characteristics SetFocalLength(); SetPixelPitch(); // Setup detector map new CameraDetectorMap(this); // Setup focal plane map CameraFocalPlaneMap *focalMap = new CameraFocalPlaneMap(this, naifIkCode()); focalMap->SetDetectorOrigin(ParentSamples() / 2.0, ParentLines() / 2.0); QString ppKey("INS" + toString(naifIkCode()) + "_PP"); QString odkKey("INS" + toString(naifIkCode()) + "_OD_K"); QString decenterKey("INS" + toString(naifIkCode()) + "_DECENTER"); new ApolloMetricDistortionMap(this, getDouble(ppKey, 0), getDouble(ppKey, 1), getDouble(odkKey, 0), getDouble(odkKey, 1), getDouble(odkKey, 2), getDouble(decenterKey, 0), getDouble(decenterKey, 1), getDouble(decenterKey, 2)); // Setup the ground and sky map new CameraGroundMap(this); new CameraSkyMap(this); Pvl &lab = *cube.label(); const PvlGroup &inst = lab.findGroup("Instrument", Pvl::Traverse); // The Spacecraft Name should be either Apollo 15, 16, or 17. The name // itself could be formatted any number of ways, but the number contained // in the name should be unique between the missions QString spacecraft = inst.findKeyword("SpacecraftName")[0]; if (spacecraft.contains("15")) { p_ckFrameId = -915240; p_ckReferenceId = 1400015; p_spkTargetId = -915; } else if (spacecraft.contains("16")) { p_ckFrameId = -916240; p_ckReferenceId = 1400016; p_spkTargetId = -916; } else if (spacecraft.contains("17")) { p_ckFrameId = -917240; p_ckReferenceId = 1400017; p_spkTargetId = -917; } else { QString msg = "File does not appear to be an Apollo image"; throw IException(IException::User, msg, _FILEINFO_); } // Create a cache and grab spice info since it does not change for // a framing camera (fixed spacecraft position and pointing) // Convert the start time to et setTime((QString)inst["StartTime"]); LoadCache(); NaifStatus::CheckErrors(); }