void MemoryMapBuilderCS::processInstanceFromRule(const Instance &parent, const Instance &member, int mbrIdx, MemoryMapNode *node, VariableTypeContainerList *path) { if (!member.isNull()) { // How does the returned instance relate to the given one? switch (parent.embeds(member)) { // Conflict, ignored case orOverlap: case orCover: // No conflict, but no need to handle the same instance twice case orEqual: break; // Process the original, non-dereferenced member instance case orFirstEmbedsSecond: { // Get the unchanged member and process it instead of "member" Instance mOrig(parent.member(mbrIdx, BaseType::trLexical, 0, ksNone)); // Preserve used-defined properties, if any if (!member.properties().isEmpty()) mOrig.setProperties(member.properties()); processInstance(mOrig, node, path); break; } // We followed a pointer case orNoOverlap: // We found the embedding node for an embedded node case orSecondEmbedsFirst: { // Get the unchanged member as well Instance mOrig(parent.member(mbrIdx, BaseType::trLexical, 0, ksNone)); // Dereference exactly once int derefCount = 0; mOrig = mOrig.dereference(BaseType::trLexicalAndPointers, 1, &derefCount); // Preserve used-defined properties, if any if (!member.properties().isEmpty()) mOrig.setProperties(member.properties()); // In case the instance was NOT dereferenced, we can ignore it because // it is embedded within parent if (!derefCount) { _map->addChildIfNotExistend( member, InstanceList(), node, _index, parent.memberAddress(mbrIdx, 0, 0, ksNone)); } else { _map->addChildIfNotExistend( mOrig, InstanceList() << member, node, _index, parent.memberAddress(mbrIdx, 0, 0, ksNone)); } break; } } } if (member.isList()) processInstanceFromRule(parent, member.listNext(), mbrIdx, node, path); }
void MemoryMapBuilderCS::processNode(MemoryMapNode *node) { // Ignore user-land objects if (node->address() < _map->_vmem->memSpecs().pageOffset) return; // Create an instance from the node Instance inst(node->toInstance(false)); processInstance(inst, node); }
void solver(){ int instance; Graph G; instance = 1; G = inputInstance(); while(G != NULL){ outInstance(instance, processInstance(G)); instance++; GRAPHdestroy(G); G = inputInstance(); } }
void MemoryMapBuilderCS::addMembers(const Instance &inst, MemoryMapNode* node, VariableTypeContainerList *path) { const int cnt = inst.memberCount(); // Add all struct members to the stack that haven't been visited for (int i = 0; i < cnt; ++i) { try { int result; // Get member and see if any rules apply Instance mi(inst.member(i, BaseType::trLexical, 0, _map->knowSrc(), &result)); if (!mi.isValid() || mi.isNull()) continue; // Create a copy/new List VariableTypeContainerList l; // Do we have a path yet? if (path) { l.append((*path)); } l.append(VariableTypeContainer(inst.type(), i)); // Did the rules engine decide which instance to use? if (TypeRuleEngine::useMatchedInst(result)) { processInstanceFromRule(inst, mi, i, node, &l); } // Pass the "nested" flag to nested structs/unions else { processInstance(mi, node, &l); } } catch (GenericException&) { // Do nothing } } }
//------------------------------------------------------------------------------ void ofApp::onCalendarWatcherEventStarted(const ICalendarEventInstance& instance) { ofSendMessage("STARTED: " + instance.getEvent().getSummary() ); processInstance(instance); }
//------------------------------------------------------------------------------ void ofApp::onCalendarWatcherEventModified(const ICalendarEventInstance& instance) { ofSendMessage("MODIFIED: " + instance.getEvent().getSummary() ); processInstance(instance); }
void MovieMaker::makeMovie() { if(!initialized){ Initialize(); } if (!stopProcessing) { if (!input->isICMAInstance()) { processInstance(); } else { //Perform ICMA related processing //Output jpeg files unsigned int numFrames = input->getNumberOfFrames(); *frameCounter = numFrames; //Store for xml string description boost::filesystem::path dir(workingDir); boost::filesystem::path odir(outputDir); std::ostringstream ss; try { //Extract Overlay data and get mesh information gdcm::Reader gdcmReader; //Read the dicom file std::string dicomFile(input->getDICOMFile()); gdcmReader.SetFileName(dicomFile.c_str()); if (!gdcmReader.Read()) { std::cout << "Unable to read file " << dicomFile; processInstance(); return; } gdcm::File &file = gdcmReader.GetFile(); gdcm::DataSet &ds = file.GetDataSet(); gdcm::Tag oytag(0x6000, 0x3000); //Overlay data tag const gdcm::DataElement &de = ds.GetDataElement(oytag); const gdcm::ByteValue *bv = de.GetByteValue(); std::ostringstream cpd; cpd.write(bv->GetPointer(), bv->GetLength()); std::string imageViewEncoding = input->getTransducerData(); std::vector<std::string> views; boost::split(views, imageViewEncoding, boost::is_any_of("#")); if (views.size() > 0) { std::string targetDir = (odir / prefix).string(); boost::filesystem::create_directories(targetDir); boost::filesystem::path mydir(targetDir); std::string metaDataFile = ""; try { std::stringstream compressed; compressed << cpd.str(); std::stringstream decompressed; boost::iostreams::filtering_streambuf< boost::iostreams::input> in; in.push(boost::iostreams::gzip_decompressor()); in.push(compressed); boost::iostreams::copy(in, decompressed); metaDataFile = (mydir / "metaData.xml").string(); std::ofstream metaData(metaDataFile.c_str(), std::ios::out); metaData << decompressed.str(); metaData.close(); } catch (std::exception& gzipe) { //Copy of the dicom file is set as meta data metaDataFile = (mydir / "dicom.dcm").string(); boost::filesystem::copy_file( input->getDICOMFile().c_str(), metaDataFile.c_str(), boost::filesystem::copy_option::overwrite_if_exists); } //Create images int imageIndex = 0; for (int i = 0; i < views.size(); i++) { std::string vrec = views[i]; boost::trim(vrec); if (vrec.length() > 0) { int idx = vrec.find('|'); std::string viewName = vrec.substr(0, idx); int frameCount = atoi(vrec.substr(idx + 1).c_str()); std::string viewDir = (mydir / viewName).string(); boost::filesystem::create_directories(viewDir); boost::filesystem::path vdPath(viewDir); for (int j = 0; j < frameCount; j++) { ss.str(""); ss << viewName << std::setfill('0') << std::setw(3) << j << ".jpg"; std::string fn = (vdPath / ss.str()).string(); input->saveFrameAsJpeg(fn, j + imageIndex); } imageIndex += frameCount; } } std::string fn = prefix + ".properties"; std::ofstream properties((odir / fn).string().c_str(), std::ios::out); properties << "ICMA_FEM = TRUE" << std::endl; properties << "METADATAFILE = " << metaDataFile << std::endl; properties << "VIEWENCODING = " << imageViewEncoding << std::endl; properties << "SOPIUID = " << input->getSopInstanceUID() << std::endl; //TODO Add target ED EC data to mark the cardiac cycle times properties.close(); } } catch (std::exception& e) { std::cout << e.what() << std::endl; } } } }