当前位置: 首页>>代码示例>>C++>>正文


C++ FactoryResource::setAttributeByPath方法代码示例

本文整理汇总了C++中FactoryResource::setAttributeByPath方法的典型用法代码示例。如果您正苦于以下问题:C++ FactoryResource::setAttributeByPath方法的具体用法?C++ FactoryResource::setAttributeByPath怎么用?C++ FactoryResource::setAttributeByPath使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在FactoryResource的用法示例。


在下文中一共展示了FactoryResource::setAttributeByPath方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: if


//.........这里部分代码省略.........
                              char* pPtr = strtok(pBuffer, ",");
                              while (pPtr != NULL)
                              {
                                 double dWavelength = 0.0;
                                 if (sscanf(pPtr, "%lf", &dWavelength) == 1)
                                 {
                                    if (dWavelength > 50.0)    // Assumed to be in nanometers
                                    {
                                       uiNanometerValues++;
                                    }

                                    // Restrict the number of wavelengths to the number of samples in the header file
                                    if (numWavelengthsRead < numWavelengths)
                                    {
                                       // Only write the wavelength if the value is valid
                                       // Since the bands are in descending order,
                                       // goodBands.back() always holds the next good band.
                                       if (pBblField == NULL ||
                                          (goodBands.empty() == false && goodBands.back() == numWavelengthsRead))
                                       {
                                          if (goodBands.empty() == false)
                                          {
                                             goodBands.pop_back();
                                          }

                                          wavelengths.push_back(dWavelength);
                                       }
                                    }

                                    ++numWavelengthsRead;
                                 }

                                 pPtr = strtok(NULL, ",");
                              }
                           }
                        }

                        VERIFYNR(goodBands.empty() == true);
                     }

                     // Wavelength units
                     bool bConvertWavelengths = false;
                     bool bDetermineUnits = true;

                     EnviField* pUnitsField = mFields.find("wavelength units");
                     if (pUnitsField != NULL)
                     {
                        if (pUnitsField->mValue == "Micrometers")
                        {
                           bDetermineUnits = false;
                        }
                        else if (pUnitsField->mValue == "Nanometers")
                        {
                           bDetermineUnits = false;
                           bConvertWavelengths = true;
                        }
                     }

                     if (bDetermineUnits)
                     {
                        if ((uiNanometerValues * 100) / wavelengths.size() > 50)
                        {
                           bConvertWavelengths = true;
                        }
                     }

                     if (bConvertWavelengths == true)
                     {
                        for (vector<double>::size_type i = 0; i < wavelengths.size(); i++)
                        {
                           wavelengths[i] *= 0.001;
                        }
                     }

                     string pCenterPath[] = { SPECIAL_METADATA_NAME, BAND_METADATA_NAME, 
                        CENTER_WAVELENGTHS_METADATA_NAME, END_METADATA_NAME };
                     pMetadata->setAttributeByPath(pCenterPath, wavelengths);
                  }

                  if (pMetadata->getNumAttributes() > 0)
                  {
                     pDescriptor->setMetadata(pMetadata.get());
                  }

                  // Create the file descriptor
                  FactoryResource<SignatureFileDescriptor> pFileDescriptor;
                  if (pFileDescriptor.get() != NULL)
                  {
                     pFileDescriptor->setFilename(dataFile);
                     pDescriptor->setFileDescriptor(pFileDescriptor.get());
                  }
               }
               descriptors.push_back(pImportDescriptor);
            }
         }
      }
   }

   return descriptors;
}
开发者ID:Siddharthk,项目名称:opticks,代码行数:101,代码来源:EnviLibraryImporter.cpp

示例2: pFile

std::vector<ImportDescriptor*> FitsImporter::getImportDescriptors(const std::string& fname)
{
   std::string filename = fname;
   std::vector<std::vector<std::string> >& errors = mErrors[fname];
   std::vector<std::vector<std::string> >& warnings = mWarnings[fname];
   errors.clear();
   warnings.clear();
   int status=0;
   std::vector<ImportDescriptor*> descriptors;

   FitsFileResource pFile(filename);
   if (!pFile.isValid())
   {
      errors.resize(1);
      errors[0].push_back(pFile.getStatus());
      RETURN_DESCRIPTORS;
   }

   int hduCnt = 0;
   int specificHdu = 0;
   int hdu = 1;
   if (!splitFilename(filename, hduCnt, specificHdu, hdu, pFile, errors, warnings))
   {
      RETURN_DESCRIPTORS;
   }
   errors.resize(hduCnt+1);
   warnings.resize(hduCnt+1);

   for(; hdu <= hduCnt; ++hdu)
   {
      std::string datasetName = filename + "[" + StringUtilities::toDisplayString(hdu) + "]";
      int hduType;
      CHECK_FITS(fits_movabs_hdu(pFile, hdu, &hduType, &status), hdu, false, continue);
      ImportDescriptorResource pImportDescriptor(static_cast<ImportDescriptor*>(NULL));
      FactoryResource<DynamicObject> pMetadata;
      VERIFYRV(pMetadata.get() != NULL, descriptors);
      { // scope
         std::vector<std::string> comments;
         char pCard[81];
         char pValue[81];
         char pComment[81];
         int nkeys = 0;
         CHECK_FITS(fits_get_hdrspace(pFile, &nkeys, NULL, &status), hdu, true, ;);
         for(int keyidx = 1; keyidx <= nkeys; ++keyidx)
         {
            CHECK_FITS(fits_read_keyn(pFile, keyidx, pCard, pValue, pComment, &status), hdu, true, continue);
            std::string name = StringUtilities::stripWhitespace(std::string(pCard));
            std::string val = StringUtilities::stripWhitespace(std::string(pValue));
            std::string comment = StringUtilities::stripWhitespace(std::string(pComment));
            if (!val.empty())
            {
               pMetadata->setAttributeByPath("FITS/" + name, val);
            }
            else if (!comment.empty())
            {
               comments.push_back(comment);
            }
         }
         if (!comments.empty())
         {
            // ideally, this would add a multi-line string but Opticks doesn't display this properly
            // pMetadata->setAttributeByPath("FITS/COMMENT", StringUtilities::join(comments, "\n"));
            for(unsigned int idx = 0; idx < comments.size(); ++idx)
            {
               pMetadata->setAttributeByPath("FITS/COMMENT/" + StringUtilities::toDisplayString(idx), comments[idx]);
            }
         }
      }
      switch(hduType)
      {
      case IMAGE_HDU:
      {
         pImportDescriptor = ImportDescriptorResource(datasetName, TypeConverter::toString<RasterElement>());
         VERIFYRV(pImportDescriptor.get() != NULL, descriptors);

         EncodingType fileEncoding;
         InterleaveFormatType interleave(BSQ);
         unsigned int rows=0;
         unsigned int cols=0;
         unsigned int bands=1;

         int bitpix;
         int naxis;
         long axes[3];
         CHECK_FITS(fits_get_img_param(pFile, 3, &bitpix, &naxis, axes, &status), hdu, false, continue);
         switch(bitpix)
         {
         case BYTE_IMG:
            fileEncoding = INT1UBYTE;
            break;
         case SHORT_IMG:
            fileEncoding = INT2SBYTES;
            break;
         case LONG_IMG:
            fileEncoding = INT4SBYTES;
            break;
         case FLOAT_IMG:
            fileEncoding = FLT4BYTES;
            break;
         case DOUBLE_IMG:
//.........这里部分代码省略.........
开发者ID:Tom-VdE,项目名称:opticks,代码行数:101,代码来源:FitsImporter.cpp

示例3: pImportDescriptor

std::vector<ImportDescriptor*> DicomImporter::getImportDescriptors(const std::string &filename)
{
   mErrors.clear();
   mWarnings.clear();
   std::vector<ImportDescriptor*> descriptors;

   DcmFileFormat fileformat;
   OFCondition status;
   if((status = fileformat.loadFile(filename.c_str())).bad())
   {
      return descriptors;
   }

   ImportDescriptorResource pImportDescriptor(filename, TypeConverter::toString<RasterElement>());
   VERIFYRV(pImportDescriptor.get() != NULL, descriptors);
   descriptors.push_back(pImportDescriptor.release());

   DicomImage img(fileformat.getDataset(), fileformat.getDataset()->getOriginalXfer());
   if(img.getStatus() != EIS_Normal)
   {
      mErrors.push_back(std::string("Unable to decode image: ") + DicomImage::getString(img.getStatus()));
      pImportDescriptor->setDataDescriptor(RasterUtilities::generateRasterDataDescriptor(filename, NULL, 0, 0, INT1UBYTE, IN_MEMORY));
      return descriptors;
   }
   InterleaveFormatType interleave(BSQ);
   EncodingType encoding(INT4UBYTES);
   bool rgb = false;
   unsigned long rows = img.getHeight(), columns = img.getWidth(), frames = img.getFrameCount();
   int imgDepth = img.getDepth();
   switch(img.getPhotometricInterpretation())
   {
   case EPI_Monochrome1:
   case EPI_Monochrome2:
      // do nothing special....this is single or multi-frame grayscale, 1 or 2 byte
      break;
   case EPI_RGB:
   case EPI_PaletteColor:
      // supported if there's only 1 frame
      if(frames == 1)
      {
         frames = 3;
         rgb = true;
      }
      else
      {
         mWarnings.push_back("RGB and palette color not supported when multiple frames are present. Converting to grayscale.");
      }
      break;
   default:
      mWarnings.push_back(std::string(DicomImage::getString(img.getPhotometricInterpretation())) +
         " not supported. Attempting to convert to grayscale.");
   }

   if(imgDepth <= 8)
   {
      encoding = INT1UBYTE;
   }
   else if(imgDepth <= 16)
   {
      encoding = INT2UBYTES;
   }
   else if(imgDepth <= 32)
   {
      encoding = INT4UBYTES;
   }
   else
   {
      mWarnings.push_back("Bit depth " + StringUtilities::toDisplayString(imgDepth) + " not supported. Downgrading to 32 bits.");
      encoding = INT4UBYTES;
   }

   RasterDataDescriptor *pDescriptor = RasterUtilities::generateRasterDataDescriptor(
      filename, NULL, rows, columns, frames, interleave, encoding, IN_MEMORY);
   if(pDescriptor != NULL)
   {
      if(rgb)
      {
         pDescriptor->setDisplayBand(RED, pDescriptor->getBands()[0]);
         pDescriptor->setDisplayBand(GREEN, pDescriptor->getBands()[1]);
         pDescriptor->setDisplayBand(BLUE, pDescriptor->getBands()[2]);
         pDescriptor->setDisplayMode(RGB_MODE);
      }
      pImportDescriptor->setDataDescriptor(pDescriptor);
      FactoryResource<DynamicObject> pMeta;
      int idx = 0;
      DcmElement *pElmnt;
      while((pElmnt = fileformat.getDataset()->getElement(idx++)) != NULL)
      {
         if(pElmnt->error().bad())
         {
            continue;
         }
         const DcmTag &tag = pElmnt->getTag();
         std::string name = const_cast<DcmTag&>(tag).getTagName();
         if(name.empty())
         {
            name = QString("(%1,%2)").arg(pElmnt->getGTag(), 4, 16, QChar('0')).arg(pElmnt->getETag(), 4, 16, QChar('0')).toStdString();
         }
         pMeta->setAttributeByPath(std::string("DICOM/") + name, dcmElementToDataVariant(*pElmnt));
      }
//.........这里部分代码省略.........
开发者ID:Siddharthk,项目名称:coan,代码行数:101,代码来源:DicomImporter.cpp


注:本文中的FactoryResource::setAttributeByPath方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。