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


C++ VolumeCollection类代码示例

本文整理汇总了C++中VolumeCollection的典型用法代码示例。如果您正苦于以下问题:C++ VolumeCollection类的具体用法?C++ VolumeCollection怎么用?C++ VolumeCollection使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: VolumeCollection

voreen::VolumeCollection* VolumeCollection::selectOrigin(const VolumeOrigin& origin) const {
    VolumeCollection* collection = new VolumeCollection();
    for (size_t i=0; i<volumeHandles_.size(); ++i) {
        if (volumeHandles_[i]->getOrigin() == origin)
            collection->add(volumeHandles_[i]);
    }
    return collection;
}
开发者ID:alvatar,项目名称:smartmatter,代码行数:8,代码来源:volumecollection.cpp

示例2: VolumeCollection

VolumeCollection* VolumeCollection::subCollection(const std::vector<size_t>& indices) const {
    VolumeCollection* subCollection = new VolumeCollection();
    for (size_t i=0; i<indices.size(); i++) {
        tgtAssert(indices.at(i) < volumeHandles_.size(), "invalid index");
        subCollection->add(volumeHandles_.at(indices.at(i)));
    }
    return subCollection;
}
开发者ID:MKLab-ITI,项目名称:gnorasi,代码行数:8,代码来源:volumecollection.cpp

示例3: VolumeCollection

voreen::VolumeCollection* VolumeCollection::selectOriginTimestep(const VolumeOrigin& origin, float timestep) const {
    VolumeCollection* collection = new VolumeCollection();
    for (size_t i=0; i<volumeHandles_.size(); ++i) {
        VolumeHandle* vh = dynamic_cast<VolumeHandle*>(volumeHandles_[i]);
        if (vh && vh->getOrigin() == origin && vh->getTimestep() == timestep)
            collection->add(volumeHandles_[i]);
    }
    return collection;
}
开发者ID:bsmr-opengl,项目名称:voreen,代码行数:9,代码来源:volumecollection.cpp

示例4: throw

VolumeCollection* RawVoxVolumeReader::read(const std::string &url)
throw (tgt::CorruptedFileException, tgt::IOException, std::bad_alloc)
{
    VolumeURL origin(url);
    std::string fileName = origin.getPath();

    LINFO("Reading file " << fileName);

    std::fstream fin(fileName.c_str(), std::ios::in | std::ios::binary);
    if (!fin.good())
        throw tgt::IOException();

    RawVoxHeader header;
    fin.read(reinterpret_cast<char*>(&header), sizeof(header));
    svec3 dimensions = svec3(header.sizeX_, header.sizeY_, header.sizeZ_);

    if(header.magic_ != 1381388120) {
        throw tgt::CorruptedFileException("Wrong magic number.");
    }

    VolumeRAM* dataset;
    switch(header.bitsPerVoxel_) {
    case 8:
        LINFO("Reading 8 bit dataset");
        dataset = new VolumeRAM_UInt8(dimensions);
        break;
    case 16:
        LINFO("Reading 16 bit dataset");
        dataset = new VolumeRAM_UInt16(dimensions);
        break;
    case 32:
        LINFO("Reading 32 bit (float) dataset");
        dataset = new VolumeRAM_Float(dimensions);
        break;
    default:
        LERROR("Unknown bpp!");
        throw tgt::UnsupportedFormatException("Unexpected bpp.");
    }

    fin.read(reinterpret_cast<char*>(dataset->getData()), dataset->getNumBytes());

    if ( fin.eof() ) {
        delete dataset;
        throw tgt::CorruptedFileException();
    }

    fin.close();

    VolumeCollection* volumeCollection = new VolumeCollection();
    Volume* volumeHandle = new Volume(dataset, vec3(1.0f), vec3(0.0f));
    oldVolumePosition(volumeHandle);
    volumeHandle->setOrigin(fileName);
    volumeCollection->add(volumeHandle);

    return volumeCollection;
}
开发者ID:molsimmsu,项目名称:3mview,代码行数:56,代码来源:rawvoxvolumereader.cpp

示例5: throw

VolumeCollection* VvdVolumeReader::read(const std::string &url)
    throw (tgt::FileException, std::bad_alloc)
{
    VolumeURL origin(url);
    std::string fileName = origin.getPath();

    // open file for reading
    std::fstream fileStream(fileName.c_str(), std::ios_base::in);
    if (fileStream.fail()) {
        throw tgt::FileException("Failed to open file '" + tgt::FileSystem::absolutePath(fileName) + "' for reading.");
    }

    // read data stream into deserializer
    XmlDeserializer d(fileName);
    d.setUseAttributes(true);
    try {
        d.read(fileStream);
    }
    catch (SerializationException& e) {
        throw tgt::FileException("SerializationException: Failed to read serialization data stream from file '"
                                     + fileName + "': " + e.what());
    }
    catch (...) {
        throw tgt::FileException("Failed to read serialization data stream from file '"
                                     + fileName + "' (unknown exception).");
    }

    std::vector<VvdObject> vec;
    // deserialize from data stream
    try {
        d.deserialize("Volumes", vec, "Volume");
    }
    catch (std::exception& e) {
        throw tgt::FileException("Deserialization from file '" + fileName + "' failed: " + e.what());
    }
    catch (...) {
        throw tgt::FileException("Deserialization from file '" + fileName + "' failed (unknown exception).");
    }
    if (vec.empty())
        throw tgt::FileException("Deserialization from file '" + fileName + "' failed: no volume found");

    VolumeCollection* vc = new VolumeCollection();
    for(size_t i=0; i<vec.size(); i++) {
        Volume* vh = vec[i].createVolume(tgt::FileSystem::dirName(fileName));
        vh->setOrigin(origin);
        vc->add(vh);
    }

    return vc;
}
开发者ID:MKLab-ITI,项目名称:gnorasi,代码行数:50,代码来源:vvdvolumereader.cpp

示例6: VolumeCollection

VolumeCollection* TransFuncListProperty::getVolumes(bool selectedOnly /*= true*/) const {
    VolumeCollection* collection = new VolumeCollection();
    std::vector<std::string> urls = get();
    for (size_t i=0; i<urls.size(); i++) {
        std::string url = urls.at(i);
        if (handleMap_.find(url) != handleMap_.end()) {
            if (!selectedOnly || (selectionMap_.find(url) != selectionMap_.end() && selectionMap_.find(url)->second == true) ) {
                VolumeBase* handle = handleMap_.find(url)->second;
                tgtAssert(handle, "handleMap_ contains null pointer");
                collection->add(handle);
            }
        }
    }

    return collection;
}
开发者ID:molsimmsu,项目名称:3mview,代码行数:16,代码来源:transfunclistproperty.cpp

示例7: throw

VolumeBase* AnalyzeVolumeReader::read(const VolumeURL& origin)
    throw (tgt::FileException, std::bad_alloc)
{
    VolumeBase* result = 0;

    int volumeId = -1;
    std::string tmp = origin.getSearchParameter("volumeId");
    if (! tmp.empty())
        volumeId = stoi(tmp);

    VolumeCollection* collection = read(origin.getPath(), volumeId);

    if (collection && collection->size() == 1) {
        result = collection->first();
    }
    else if (collection && collection->size() > 1) {
        while(!collection->empty()) {
           VolumeBase* vh = collection->first();
           collection->remove(vh);
           delete vh;
        }
        delete collection;
        throw tgt::FileException("Only one volume expected", origin.getPath());
    }

    delete collection;

    return result;
}
开发者ID:MKLab-ITI,项目名称:gnorasi,代码行数:29,代码来源:analyzevolumereader.cpp

示例8: throw

VolumeCollection* MultiVolumeReader::read(const std::string& url)
    throw (tgt::FileException, std::bad_alloc)
{
    LINFO("Loading multi volume file " << url);
    VolumeURL urlOrigin(url);

    std::vector<VolumeURL> origins = listVolumes(url);
    if (origins.empty())
        throw tgt::FileException("No volumes listed in multi-volume file", url);

    VolumeCollection* volumeCollection = new VolumeCollection();

    std::string refFile = urlOrigin.getSearchParameter("file");
    if (refFile == "") {
        // no particular file specified in URL => load all listed ones
        for (size_t i=0; i<origins.size(); i++) {
            VolumeBase* handle = read(origins.at(i));
            if (handle)
                volumeCollection->add(handle);
        }
    }
    else {
        // load specified file
        for (size_t i=0; i<origins.size(); i++) {
            if (origins.at(i).getSearchParameter("file") == refFile) {
                VolumeBase* handle = read(origins.at(i));
                if (handle) {
                    volumeCollection->add(handle);
                    break;
                }
            }
        }

        if (volumeCollection->empty()) {
            delete volumeCollection;
            throw tgt::FileException("File '" + refFile + "' not listed in multi-volume file", urlOrigin.getPath());
        }
    }

    return volumeCollection;
}
开发者ID:MKLab-ITI,项目名称:gnorasi,代码行数:41,代码来源:multivolumereader.cpp

示例9: adjustFilteredCollection

void VolumeCollectionModalityFilter::adjustFilteredCollection() {
    VolumeCollection* collection = inport_.getData();
    if ((collection == 0) || (collection->empty() == true)) {
        filteredCollection_.clear();
        outport_.setData(0);
        return;
    }

    if (currentModality_.getName() != modalityProp_.get()) {
        currentModality_ = *(modalityProp_.getValue());
        filteredCollection_.clear();
        if (currentModality_ != Modality::MODALITY_ANY) {
            for (size_t i = 0; i < collection->size(); ++i) {
                if (collection->at(i)->getModality() == currentModality_)
                    filteredCollection_.add(collection->at(i));
            }
            outport_.setData(&filteredCollection_);
        } else
            outport_.setData(inport_.getData());
    }
}
开发者ID:alvatar,项目名称:smartmatter,代码行数:21,代码来源:volumecollectionmodalityfilter.cpp

示例10: throw

VolumeCollection* MRCVolumeReader::read(const std::string &url)
    throw (tgt::FileException, tgt::IOException, std::bad_alloc)
{
    VolumeCollection* volumeCollection = new VolumeCollection();

    VolumeURL origin(url);
    std::string fileName = origin.getPath();
    LINFO(fileName);
    
    std::ifstream mrc;
    mrc.open(fileName.c_str(), std::ios::binary);
    if (!mrc.is_open()) {
        LWARNING("Can't open stream");
    }
    else {
        int dim[3]; // grid dimensions i.e. numbers of voxels for each dimension
        mrc.read((char*)(&dim), sizeof(dim));
        std::cout << "X: " << dim[0] << std::endl; // number of columns (fastest changing in map)
        std::cout << "Y: " << dim[1] << std::endl; // number of rows
        std::cout << "Z: " << dim[2] << std::endl; // number of sections (slowest changing in map)
        
        int numVoxels = dim[0] * dim[1] * dim[2]; // total number of voxels in volume
        std::cout << "numVoxels: " << numVoxels << std::endl;
        
        int dataType; // see below
        mrc.read((char*)(&dataType), sizeof(dataType));
        std::cout << "dataType: " << dataType << std::endl;
        
        int dataSize = 0; // i.e. 8-bit, 16-bit or 32-bit
             if (dataType == 0) dataSize = 1; // signed 8-bit bytes range -128 to 127
        else if (dataType == 1) dataSize = 2; // 16-bit halfwords
        else if (dataType == 2) dataSize = 4; // 32-bit reals
        else if (dataType == 6) dataSize = 2; // unsigned 16-bit range 0 to 65535
        
        tgtAssert(dataSize, "Datasize is 0 at MRCVolumeReader::read()");
        
        int totalDataSize = dataSize * numVoxels;
        
        int start[3]; // numbers of first columns i.e. offset of the volume origin in voxel coordinates
        mrc.read((char*)(&start), sizeof(start));
        std::cout << "startX: " << start[0] << std::endl; // number of columns (fastest changing in map)
        std::cout << "startY: " << start[1] << std::endl; // number of rows
        std::cout << "startZ: " << start[2] << std::endl; // number of sections (slowest changing in map)

        int gridSize[3];
        mrc.read((char*)(&gridSize), sizeof(gridSize));
        std::cout << "gridSizeX: " << gridSize[0] << std::endl;
        std::cout << "gridSizeY: " << gridSize[1] << std::endl; 
        std::cout << "gridSizeZ: " << gridSize[2] << std::endl;
     
        float cellDimensions[3]; // cell dimensions in angstroms
        mrc.read((char*)(&cellDimensions), sizeof(cellDimensions));
        std::cout << "cellX: " << cellDimensions[0] << std::endl; 
        std::cout << "cellY: " << cellDimensions[1] << std::endl; 
        std::cout << "cellZ: " << cellDimensions[2] << std::endl; 
        
        float scale[3]; // pixelSpacing i.e. scale from voxel to real-word coordinates
        scale[0] = cellDimensions[0] / gridSize[0];
        scale[1] = cellDimensions[1] / gridSize[1];
        scale[2] = cellDimensions[2] / gridSize[2];
        std::cout << "pixelSpacingX: " << scale[0] << std::endl; 
        std::cout << "pixelSpacingY: " << scale[1] << std::endl; 
        std::cout << "pixelSpacingZ: " << scale[2] << std::endl; 
        
        float angles[3]; // cell angles in degrees
        mrc.read((char*)(&angles), sizeof(angles));
        std::cout << "cellAngleX: " << angles[0] << std::endl;
        std::cout << "cellAngleY: " << angles[1] << std::endl;
        std::cout << "cellAngleZ: " << angles[2] << std::endl;
        
        int axes[3]; // Which axis corresponds to columns, rows and sections (1,2,3 for X,Y,Z)
        mrc.read((char*)(&axes), sizeof(axes));
        std::cout << "axesX: " << axes[0] << std::endl;
        std::cout << "axesY: " << axes[1] << std::endl; 
        std::cout << "axesZ: " << axes[2] << std::endl; 
        
        float origin[3];
        mrc.seekg(4*49, std::ios::beg);
        mrc.read((char*)(&origin), sizeof(origin));
        std::cout << "originX: " << origin[0] << std::endl; 
        std::cout << "originY: " << origin[1] << std::endl; 
        std::cout << "originZ: " << origin[2] << std::endl; 
        
        void* data = malloc(totalDataSize);
        mrc.seekg(1024, std::ios::beg);
        mrc.read((char*)data, totalDataSize);
        mrc.close();
        
        VolumeRAM* targetDataset;
        
        int a = axes[0]-1;
        int b = axes[1]-1;
        int c = axes[2]-1;
        
        /**/ if (dataType == 0) {
            targetDataset = new VolumeAtomic<int8_t>(ivec3(dim[a], dim[b], dim[c]));
            fillVolume<int8_t>(targetDataset, data, dim, axes);
        }
        else if (dataType == 1) {
            targetDataset = new VolumeAtomic<int16_t>(ivec3(dim[a], dim[b], dim[c]));
//.........这里部分代码省略.........
开发者ID:molsimmsu,项目名称:3mview,代码行数:101,代码来源:mrcvolumereader.cpp

示例11: throw

VolumeCollection* FlowReader::read(const std::string& url)
    throw(tgt::FileException, std::bad_alloc)
{
    VolumeOrigin origin(url);
    std::string fileName = origin.getPath();

    LINFO("reading flow file '" << fileName << "'...");

    // try to open the file
    //
    std::fstream ifs(fileName.c_str(), std::ios_base::in | std::ios_base::binary);
    if (ifs.good() == false)
        throw tgt::IOException("Unable to open flow file for reading", fileName);

    // read the magic number (string "VOREENFLOW")
    //
    char magicNumber[11] = {0};
    ifs.read(magicNumber, 11);
    std::string temp(magicNumber);
    if (temp != "VOREENFLOW")
        throw tgt::IOException("Missing magic number in flow file", fileName);

    // read file version (must currently be 1 or 2)
    //
    unsigned int fileVersion = 0;
    ifs.read(reinterpret_cast<char*>(&fileVersion), sizeof(unsigned int));
    LINFO("file version: " << fileVersion);
    if ((fileVersion < 1) || (fileVersion > 2))
        throw tgt::IOException("Unsupported file version of flow file", fileName);

    // read flow dimension (usually 3 for 3D flows)
    //
    unsigned int flowDimension = 0;
    ifs.read(reinterpret_cast<char*>(&flowDimension), sizeof(unsigned int));
    LINFO("flow dimension: " << flowDimension << "D");
    if (flowDimension != 3)
        throw tgt::IOException("Unsupported flow dimension in flow file", fileName);

    unsigned char dataOrientation = 0;
    unsigned char reverseSlicesMask = 0;

    ifs.read(reinterpret_cast<char*>(&dataOrientation), sizeof(unsigned char));
    if (fileVersion > 1) {
        ifs.read(reinterpret_cast<char*>(&reverseSlicesMask), sizeof(unsigned char));
    }

    // read the dimension of the volume data containing the flow
    //
    tgt::ivec3 dimensions;
    ifs.read(reinterpret_cast<char*>(&dimensions), sizeof(tgt::ivec3));
    LINFO("volume dimensions: " << dimensions);

    unsigned int byteSize = 0;
    ifs.read(reinterpret_cast<char*>(&byteSize), sizeof(unsigned int));
    LINFO("expected size of vector field: " << byteSize << " byte");

    VolumeFlow3D* volume = readConvert(dimensions, dataOrientation, ifs);
    ifs.close();

    if (volume == 0) {
        LERROR("an error occured during reading flow data! Proceeding impossible.");
        return 0;
    }

    if (reverseSlicesMask != 0)
        reverseSlices(volume, reverseSlicesMask);

    // TODO: volume container merge
    /*VolumeSet* volumeSet = new VolumeSet(fileName);
    VolumeSeries* volumeSeries = new VolumeSeries(Modality::MODALITY_FLOW.getName(),
                                                  Modality::MODALITY_FLOW);
    volumeSet->addSeries(volumeSeries);
    VolumeHandle* volumeHandle = new VolumeHandle(volume, 0.0f);

    volumeSeries->addVolumeHandle(volumeHandle); */

    VolumeCollection* collection = new VolumeCollection();
    VolumeHandle* volumeHandle = new VolumeHandle(volume, tgt::vec3(1.0f), tgt::vec3(0.0f));//FIXME: spacing?
    oldVolumePosition(volumeHandle);
    volumeHandle->setModality(Modality::MODALITY_FLOW);
    collection->add(volumeHandle);

    // TODO: origin does not save series and timestamp anymore
    //volumeHandle->setOrigin(fileName, Modality::MODALITY_FLOW.getName(), 0.0f);
    volumeHandle->setOrigin(fileName);

    return collection;
}
开发者ID:bsmr-opengl,项目名称:voreen,代码行数:88,代码来源:flowreader.cpp

示例12: VolumeCollection

void
VolumeCollectionTester::Test ( Tcl_Interp* iInterp ) {

  stringstream ssError;

  try {

    string fnMRI = "test_data/bertT1.mgz";
    VolumeCollection* vol = new VolumeCollection();
    vol->SetFileName( fnMRI );
    MRI* mri = const_cast<MRI*>(vol->GetMRI());

    Assert( (vol->GetTypeDescription() == "Volume"),
            "GetTypeDescription didn't return Volume" );

    DataManager dataMgr = DataManager::GetManager();
    MRILoader mriLoader = dataMgr.GetMRILoader();
    Assert( 1 == mriLoader.CountLoaded(),
            "CountLoaded didn't return 1" );
    Assert( 1 == mriLoader.CountReferences(mri),
            "CountReferences didn't return 1" );

    char* fnMRIC = strdup( fnMRI.c_str() );
    MRI* mriComp = MRIread( fnMRIC );

    Assert( (MRImatch( mriComp, mri )), "MRImatch failed for load" );

    MRIfree( &mriComp );


    // Save it in /tmp, load it, and match it again.
    string fnSave( "/tmp/test.mgz" );
    vol->Save( fnSave );

    VolumeCollection* testVol = new VolumeCollection();
    testVol->SetFileName( fnSave );
    MRI* testMri = const_cast<MRI*>(testVol->GetMRI());
    Assert( (MRImatch( testMri, mri )), "MRImatch failed for load after save");



    // Make an ROI and make sure it's a volume ROI.
    try {
      int roiID = vol->NewROI();
      ScubaROIVolume* roi =
        dynamic_cast<ScubaROIVolume*>(&ScubaROI::FindByID( roiID ));
      roi = NULL;
    } catch (...) {
      throw( runtime_error("typecast failed for NewROI") );
    }


    // Try our conversions.
    Point3<float> world;
    Point3<float> data;
    Point3<int> index;
    world.Set( -50, 0, -80 );
    vol->RASToMRIIndex( world.xyz(), index.xyz() );
    {
      stringstream ssError;
      ssError << "RASToMRIIndex failed. world "
      << world << " index " << index;
      Assert( (index.x() == 178 && index.y() == 208 && index.z() == 128),
              ssError.str() );
    }

    // Set a transform that scales the volume up by 2x in the world.
    ScubaTransform dataTransform;
    dataTransform.SetMainTransform( 2, 0, 0, 0,
                                    0, 2, 0, 0,
                                    0, 0, 2, 0,
                                    0, 0, 0, 1 );
    vol->SetDataToWorldTransform( dataTransform.GetID() );

    world.Set( -50, 0, -80 );
    vol->RASToDataRAS( world.xyz(), data.xyz() );
    {
      stringstream ssError;
      ssError << "RASToDataRAS failed. world "
      << world << " data " << data;
      Assert( ((FEQUAL(data.x(),-25)) &&
               (FEQUAL(data.y(),0)) &&
               (FEQUAL(data.z(),-40))),
              ssError.str() );
    }

    vol->RASToMRIIndex( world.xyz(), index.xyz() );

    if ( index.x() != 153 || index.y() != 168 || index.z() != 128 ) {
      cerr << "RASToMRIIndex with data transform failed. world "
      << world << " index " << index << endl;
      throw( runtime_error( "failed" ) );
    }


    world.Set( -50, 0, -80 );
    VolumeLocation loc( vol->MakeVolumeLocationFromRAS( world.xyz() ) );
    if ( !vol->IsInBounds( loc ) ) {
      stringstream ssError;
      ssError << "IsInBounds failed. world " << world;
//.........这里部分代码省略.........
开发者ID:ewong718,项目名称:freesurfer,代码行数:101,代码来源:test_VolumeCollection.cpp

示例13: runtime_error

void
SegmentationVolumeReportTester::Test ( Tcl_Interp* iInterp ) {

  try {


    // Load our seg volume.
    string fnSegVolume = "test_data/testSegmentationVolumeReportData-Seg.mgz";
    VolumeCollection seg;
    seg.SetFileName( fnSegVolume );
    seg.LoadVolume();
    seg.SetLabel( "Seg" );

    // Load our intensity volume.
    string fnIntVolume = "test_data/testSegmentationVolumeReportData-Int.mgz";
    VolumeCollection vol;
    vol.SetFileName( fnIntVolume );
    vol.LoadVolume();
    vol.SetLabel( "Int" );


    // Load our LUT.
    string fnLUT = "test_data/TestLUT.txt";
    ScubaColorLUT lut;
    lut.UseFile( fnLUT );

    // Set up the report.
    SegmentationVolumeReport& report =
      SegmentationVolumeReport::GetReport();

    report.SetSegmentation( seg );
    if ( NULL == report.mSegVol ) {
      stringstream ssError;
      ssError << "Error on SetSegmentation, mSegVol was NULL";
      throw runtime_error( ssError.str() );
    }
    if ( report.mSegVol->GetID() != seg.GetID() ) {
      stringstream ssError;
      ssError << "Error on SetSegmentation, mSegVol was the wrong volume (should be ID " << seg.GetID() << " but was " << report.mSegVol->GetID();
      throw runtime_error( ssError.str() );
    }

    report.DontUseROI();
    if ( report.mbUseROI ) {
      stringstream ssError;
      ssError << "Error on DontUseROI, mbUseROI was true";
      throw runtime_error( ssError.str() );
    }


    report.SetColorLUT( lut );
    if ( NULL == report.mLUT ) {
      stringstream ssError;
      ssError << "Error on SetColorLUT, mROI was NULL";
      throw runtime_error( ssError.str() );
    }
    if ( report.mLUT->GetID() != lut.GetID() ) {
      stringstream ssError;
      ssError << "Error on SetColorLUT, id didn't match";
      throw runtime_error( ssError.str() );
    }

    // Add 1-5 but not 3.
    report.AddSegmentationStructure( 1 );
    report.AddSegmentationStructure( 2 );
    report.AddSegmentationStructure( 4 );
    report.AddSegmentationStructure( 5 );
    map<int,bool> structureMap;
    list<int>::iterator tStructure;
    for ( tStructure = report.mlStructures.begin();
          tStructure != report.mlStructures.end(); ++tStructure ) {
      int nStructure = *tStructure;
      if ( nStructure != 1 && nStructure != 2 &&
           nStructure != 4 && nStructure != 5 ) {
        stringstream ssError;
        ssError << "Error on AddSegmentationStructure, added an unknown structure " << nStructure;
        throw runtime_error( ssError.str() );
      }
      structureMap[nStructure] = true;
    }
    if ( !(structureMap[1] && structureMap[2] &&
           structureMap[4] && structureMap[5]) ) {
      stringstream ssError;
      ssError << "Error in AddSegmentationStructure, didn't add all structures";
      throw runtime_error( ssError.str() );
    }

    // Test handling of undefined structures.
    report.AddSegmentationStructure( 200 );

    // Add the intensity volume. Also add the seg vol as an additional
    // intensity volume.
    report.AddIntensityVolume( vol );
    report.AddIntensityVolume( seg );
    map<int,bool> volsLoadedMap;
    list<VolumeCollection*>::iterator tVolume;
    for ( tVolume = report.mlIntVols.begin();
          tVolume != report.mlIntVols.end(); ++tVolume ) {
      VolumeCollection* testVol = *tVolume;
      int volID = testVol->GetID();
//.........这里部分代码省略.........
开发者ID:ewong718,项目名称:freesurfer,代码行数:101,代码来源:test_SegmentationVolumeReport.cpp

示例14: main

int main( int argc, char **argv ) {
    try {

        QApplication a( argc, argv );


        string fnMRI = "/Users/kteich/work/subjects/bert/mri/orig";

        char* sSubjectsDir = getenv("SUBJECTS_DIR");

        if ( NULL != sSubjectsDir ) {
            fnMRI = string(sSubjectsDir) + "/bert/mri/orig";
        }

        if ( argc == 2 ) {
            fnMRI = argv[1];
        }

        VolumeCollection vol;
        vol.SetFileName( fnMRI );
        MRI* mri = vol.GetMRI();
        if ( NULL == mri )
            exit( 1 );

        QtVolumeHistogram* histogram;
        histogram = new QtVolumeHistogram( 0, (const char*) "QtVolumeHistogram" );
        histogram->SetVolumeSource( &vol );
        histogram->SetNumberOfBins( 255 );
        histogram->SetMinIgnore( 0 );
        histogram->SetMaxIgnore( 20 );
        histogram->SetNumberOfMarkers( 4 );
        histogram->SetMarkerColor( 0, Qt::red );
        histogram->SetMarkerValue( 0, 10 );
        histogram->SetMarkerColor( 1, Qt::green );
        histogram->SetMarkerValue( 1, 30 );
        histogram->SetMarkerColor( 2, Qt::blue );
        histogram->SetMarkerValue( 2, 50 );
        histogram->SetMarkerColor( 3, Qt::yellow );
        histogram->SetMarkerValue( 3, 70 );

        histogram->resize( 600, 200 );

        a.setMainWidget( histogram );
        histogram->show();

        QApplication::setGlobalMouseTracking( true );

        return a.exec();
    } catch ( runtime_error& e ) {
        cerr << "failed with exception: " << e.what() << endl;
        exit( 1 );
    } catch ( exception& e ) {
        cerr << "failed with exception: " << e.what() << endl;
        exit( 1 );
    } catch (...) {
        cerr << "failed" << endl;
        exit( 1 );
    }


    exit( 0 );
}
开发者ID:guo2004131,项目名称:freesurfer,代码行数:62,代码来源:test_VolumeHistogram.cpp

示例15: throw

VolumeCollection* ITKVolumeReader::read(const std::string &url)
    throw (tgt::CorruptedFileException, tgt::IOException, std::bad_alloc)
{
    VolumeURL origin(url);
    std::string fileName = origin.getPath();

    LINFO("Reading file " << fileName);

    //Get OutputInformation of an arbitrary reader to find out pixel type etc:
    typedef itk::Image<char,3> TestImageType; // pixel type doesn't matter for current purpose
    typedef itk::ImageFileReader<TestImageType> TestFileReaderType; // reader for testing a file
    TestFileReaderType::Pointer onefileReader = TestFileReaderType::New();
    onefileReader->SetFileName(fileName.c_str());
    try
    {
        onefileReader->GenerateOutputInformation();
    }
    catch(itk::ExceptionObject& excp)
    {
        throw tgt::CorruptedFileException("Failed to read OutputInformation! " + std::string(excp.GetDescription()), fileName);
    }

    // grab the ImageIO instance for the reader
    itk::ImageIOBase *imageIO = onefileReader->GetImageIO();

    unsigned int NumberOfDimensions =  imageIO->GetNumberOfDimensions();
    LINFO("Number of Dimensions: " << NumberOfDimensions);
    if(NumberOfDimensions != 3) {
        throw tgt::UnsupportedFormatException("Unsupported number of dimensions!");
    }

    // PixelType is SCALAR, RGB, RGBA, VECTOR, COVARIANTVECTOR, POINT, INDEX
    itk::ImageIOBase::IOPixelType pixelType = imageIO->GetPixelType();
    LINFO("PixelType: " << imageIO->GetPixelTypeAsString(pixelType));

    // IOComponentType is UCHAR, CHAR, USHORT, SHORT, UINT, INT, ULONG, LONG, FLOAT, DOUBLE
    itk::ImageIOBase::IOComponentType componentType = imageIO->GetComponentType();
    LINFO("ComponentType: " << imageIO->GetComponentTypeAsString(componentType));

    // NumberOfComponents is usually one, but for non-scalar pixel types, it can be anything
    unsigned int NumberOfComponents = imageIO->GetNumberOfComponents();
    LINFO("Number of Components: " << NumberOfComponents);
    if(NumberOfComponents != 1) {
        throw tgt::UnsupportedFormatException("Unsupported number of components!");
    }

    //-------Info we don't need here:---------------
    //unsigned dims[32];   // almost always no more than 4 dims, but ...
    //unsigned origin[32];
    double spacing[32];
    //std::vector<double> directions[32];
    for(unsigned i = 0; i < NumberOfDimensions && i < 32; i++)
    {
        //dims[i] = imageIO->GetDimensions(i);
        //origin[i] = imageIO->GetOrigin(i);
        spacing[i] = imageIO->GetSpacing(i);
        //directions[i] = imageIO->GetDirection(i);
    }

    Volume* dataset;
    switch(pixelType) {
        case itk::ImageIOBase::SCALAR:
            switch(componentType) {
                case itk::ImageIOBase::UCHAR:
                    dataset = readScalarVolume<uint8_t>(fileName);
                    break;
                case itk::ImageIOBase::CHAR:
                    dataset = readScalarVolume<int8_t>(fileName);
                    break;
                case itk::ImageIOBase::USHORT:
                    dataset = readScalarVolume<uint16_t>(fileName);
                    break;
                case itk::ImageIOBase::SHORT:
                    dataset = readScalarVolume<int16_t>(fileName);
                    break;
                case itk::ImageIOBase::UINT:
                    dataset = readScalarVolume<uint32_t>(fileName);
                    break;
                case itk::ImageIOBase::INT:
                    dataset = readScalarVolume<int32_t>(fileName);
                    break;
#ifndef WIN32
                case itk::ImageIOBase::ULONG:
                    dataset = readScalarVolume<uint64_t>(fileName);
                    break;
                case itk::ImageIOBase::LONG:
                    dataset = readScalarVolume<int64_t>(fileName);
                    break;
#endif
                case itk::ImageIOBase::FLOAT:
                    dataset = readScalarVolume<float>(fileName);
                    break;
                case itk::ImageIOBase::DOUBLE:
                    dataset = readScalarVolume<double>(fileName);
                    break;
                default:
                    throw tgt::UnsupportedFormatException("Unsupported component type!");
            }
            break;
        case itk::ImageIOBase::RGB:
//.........这里部分代码省略.........
开发者ID:MKLab-ITI,项目名称:gnorasi,代码行数:101,代码来源:itkvolumereader.cpp


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