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


C++ VolumeCollection::add方法代码示例

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


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

示例1: subCollection

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

示例2: selectOrigin

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

示例3: selectOriginTimestep

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: selectOrigin

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

示例5: selectTimestep

VolumeCollection* VolumeCollection::selectTimestep(float timestep) const {

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

示例6: selectModality

VolumeCollection* VolumeCollection::selectModality(const Modality& modality) const {

    VolumeCollection* collection = new VolumeCollection();
    for (size_t i=0; i<volumeHandles_.size(); ++i) {
        if (volumeHandles_[i]->getModality() == modality)
            collection->add(volumeHandles_[i]);
    }
    return collection;
}
开发者ID:MKLab-ITI,项目名称:gnorasi,代码行数:9,代码来源:volumecollection.cpp

示例7: read

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

示例8: read

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: read

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

示例10: getVolumes

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

示例11: read

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: read


//.........这里部分代码省略.........
        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]));
            fillVolume<int16_t>(targetDataset, data, dim, axes);
        }
        else if (dataType == 2) {
            targetDataset = new VolumeAtomic<float>(ivec3(dim[a], dim[b], dim[c]));
            fillVolume<float>(targetDataset, data, dim, axes);
        }
        else if (dataType == 6) {
            targetDataset = new VolumeAtomic<uint16_t>(ivec3(dim[a], dim[b], dim[c]));
            fillVolume<uint16_t>(targetDataset, data, dim, axes);
        }
        else LERROR("Unsupported data type at MRCVolumeReader::read()");
            
        free(data);
        
        angles[0] *= (PI / 180.);
        angles[1] *= (PI / 180.);
        angles[2] *= (PI / 180.);
        
        float row[3][3];
        
        // X
        row[0][0] = 1;
        row[0][1] = 0;
        row[0][2] = 0;
        
        // Y
        row[1][0] = cos(angles[2]); // cos(gamma)
        row[1][1] = sin(angles[2]); // sin(gamma)
        row[1][2] = 0;
        
        // Z
        row[2][0] = cos(angles[1]); // cos(beta)
        row[2][1] = (cos(angles[0]) - row[2][0] * row[1][0]) / row[1][1];  // [cos(alpha) - cos(beta)*cos(gamma)] / sin(gamma)
        row[2][2] = sqrt(1 - row[2][0] * row[2][0] - row[2][1] * row[2][1]); // squared length is 1
        
        tgt::Matrix4<float> transform
        (
            row[0][0], row[1][0], row[2][0], 0,
            row[0][1], row[1][1], row[2][1], 0,
            row[0][2], row[1][2], row[2][2], 0,
            0.0f, 0.0f, 0.0f, 1.0f
        );
        
        Volume* volumeHandle = new MoleculeVolume(
            targetDataset,                                                 // data
            vec3(scale[a], scale[b], scale[c]),                            // scale
            vec3(start[a]*scale[a], start[b]*scale[b], start[c]*scale[c]), // offset
            transform                                                      // transform
        );
        
        volumeCollection->add(volumeHandle);
    }
    
    if (!volumeCollection->empty())
        volumeCollection->first()->setOrigin(VolumeURL(fileName));
        
    return volumeCollection;
}
开发者ID:molsimmsu,项目名称:3mview,代码行数:101,代码来源:mrcvolumereader.cpp

示例13: readNifti


//.........这里部分代码省略.........
                denormalize = RealWorldMapping::createDenormalizingMapping<uint16_t>();
                break;
            case DT_UINT32:         /* unsigned int (32 bits)       */
                voreenVoxelType = "uint32";
                denormalize = RealWorldMapping::createDenormalizingMapping<uint32_t>();
                break;
            case DT_INT64:          /* long long (64 bits)          */
            case DT_UINT64:         /* unsigned long long (64 bits) */
            case DT_FLOAT128:       /* long double (128 bits)       */
            case DT_COMPLEX128:     /* double pair (128 bits)       */
            case DT_COMPLEX256:     /* long double pair (256 bits)  */
            case DT_ALL:
            case DT_COMPLEX:
            case 0: //DT_NONE/DT_UNKNOWN
            case DT_BINARY:
            default:
                throw tgt::UnsupportedFormatException("Unsupported datatype!");
        }
    }

    RealWorldMapping rwm(header.scl_slope, header.scl_inter, "");

    int headerskip = static_cast<uint16_t>(header.vox_offset);

    std::string rawFilename = fileName;
    if(!standalone)
        rawFilename = getRelatedImgFileName(fileName);

    mat4 pToW = mat4::identity;

    //Calculate transformation:
    if(header.sform_code > 0) {
        mat4 vToW(header.srow_x[0], header.srow_x[1], header.srow_x[2], header.srow_x[3],
                  header.srow_y[0], header.srow_y[1], header.srow_y[2], header.srow_y[3],
                  header.srow_z[0], header.srow_z[1], header.srow_z[2], header.srow_z[3],
                  0.0f, 0.0f, 0.0f, 1.0f);

        mat4 wToV = mat4::identity;
        if(!vToW.invert(wToV)) {
            LERROR("Failed to invert voxel to world matrix!");
        }

        mat4 vToP = mat4::createScale(spacing); //no offset
        pToW = vToP * wToV;
    }
    else if(header.qform_code > 0) {
        float b = header.quatern_b;
        float c = header.quatern_c;
        float d = header.quatern_d;
        float a = static_cast<float>(sqrt(1.0-(b*b+c*c+d*d)));

        mat4 rot2(a*a+b*b-c*c-d*d,   2*b*c-2*a*d,       2*b*d+2*a*c,     0.0f,
                  2*b*c+2*a*d,       a*a+c*c-b*b-d*d,   2*c*d-2*a*b,     0.0f,
                  2*b*d-2*a*c,       2*c*d+2*a*b,       a*a+d*d-c*c-b*b, 0.0f,
                  0.0f,              0.0f,              0.0f,            1.0f);

        float qfac = header.pixdim[0];
        if(fabs(qfac) < 0.1f)
            qfac = 1.0f;
        mat4 sc = mat4::createScale(vec3(1.0f, 1.0f, qfac));

        mat4 os = mat4::createTranslation(vec3(header.qoffset_x, header.qoffset_y, header.qoffset_z));
        pToW = os * rot2 * sc;
    }

    // Nifti transformations give us the center of the first voxel, we translate to correct:
    pToW = pToW * mat4::createTranslation(-spacing * 0.5f);

    VolumeCollection* vc = new VolumeCollection();
    size_t volSize = hmul(tgt::svec3(dimensions)) * (header.bitpix / 8);

    int start = 0;
    int stop = numVolumes;
    if(volId != -1) {
        //we want to load a single volume:
        start = volId;
        stop = start + 1;
    }

    for(int i=start; i<stop; i++) {
        VolumeRepresentation* volume = new VolumeDisk(rawFilename, voreenVoxelType, dimensions, headerskip + (i * volSize), bigEndian);
        Volume* vh = new Volume(volume, spacing, vec3(0.0f));

        VolumeURL origin(fileName);
        origin.addSearchParameter("volumeId", itos(i));
        vh->setOrigin(origin);

        vh->setPhysicalToWorldMatrix(pToW);
        vh->setMetaDataValue<StringMetaData>("Description", std::string(header.descrip));
        //vh->addMetaData("ActualFrameDuration", new IntMetaData(ih_.frame_duration));
        //vh->addMetaData("FrameTime", new IntMetaData(ih_.frame_start_time));
        vh->setMetaDataValue<IntMetaData>("FrameTime", static_cast<int>(toffset + (i * dt)));
        if(applyRWM)
            vh->setRealWorldMapping(RealWorldMapping::combine(denormalize, rwm));

        vc->add(vh);
    }

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

示例14: readAnalyze


//.........这里部分代码省略.........
    image_dimension dimension;
    if (!file.read((char*)&dimension, sizeof(dimension))) {
        throw tgt::CorruptedFileException("Failed to read dimensions!", fileName);
    }

    data_history history;
    if (!file.read((char*)&history, sizeof(history))) {
        throw tgt::CorruptedFileException("Failed to read history!", fileName);
    }

    bool bigEndian = false;
    //check if swap is necessary:
    if((dimension.dim[0] < 0) || (dimension.dim[0] > 15)) {
        bigEndian = true;
        header.swapEndianess();
        dimension.swapEndianess();
        history.swapEndianess();
    }

    ivec3 dimensions;
    dimensions.x = dimension.dim[1];
    dimensions.y = dimension.dim[2];
    dimensions.z = dimension.dim[3];
    LINFO("Resolution: " << dimensions);

    int numVolumes = dimension.dim[4];
    LINFO("Number of volumes: " << numVolumes);

    if (hor(lessThanEqual(dimensions, ivec3(0)))) {
        LERROR("Invalid resolution or resolution not specified: " << dimensions);
        throw tgt::CorruptedFileException("error while reading data", fileName);
    }

    vec3 spacing;
    spacing.x = dimension.pixdim[1];
    spacing.y = dimension.pixdim[2];
    spacing.z = dimension.pixdim[3];
    LINFO("Spacing: " << spacing);

    LINFO("Datatype: " << dimension.datatype);

    std::string voreenVoxelType;
    switch(dimension.datatype) {
        case DT_UNSIGNED_CHAR:
            voreenVoxelType = "uint8";
            break;
        case DT_SIGNED_SHORT:
            voreenVoxelType = "int16";
            break;
        case DT_SIGNED_INT:
            voreenVoxelType = "int32";
            break;
        case DT_FLOAT:
            voreenVoxelType = "float";
            break;
        case DT_DOUBLE:
            voreenVoxelType = "double";
            break;
        case DT_RGB:
            voreenVoxelType = "Vector3(uint8)";
            break;
        case DT_ALL:
        case DT_COMPLEX:
        case 0: //DT_NONE/DT_UNKNOWN
        case DT_BINARY:
        default:
            throw tgt::UnsupportedFormatException("Unsupported datatype!");
    }

    std::string objectType;
    std::string gridType;

    int start = 0;
    int stop = numVolumes;
    if(volId != -1) {
        //we want to load a single volume:
        start = volId;
        stop = start + 1;
    }

    // Nifti transformations give us the center of the first voxel, we translate to correct:
    mat4 pToW = mat4::createTranslation(-spacing * 0.5f);

    VolumeCollection* vc = new VolumeCollection();
    size_t volSize = hmul(tgt::svec3(dimensions)) * (dimension.bitpix / 8);
    for(int i=start; i<stop; i++) {
        VolumeRepresentation* volume = new VolumeDisk(getRelatedImgFileName(fileName), voreenVoxelType, dimensions, i * volSize, bigEndian);
        Volume* vh = new Volume(volume, spacing, vec3(0.0f));
        vh->setOrigin(VolumeURL(fileName));
        vh->setPhysicalToWorldMatrix(pToW);

        VolumeURL origin(fileName);
        origin.addSearchParameter("volumeId", itos(i));
        vh->setOrigin(origin);

        vc->add(vh);
    }

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

示例15: read


//.........这里部分代码省略.........

    uint8_t* data;
    uint8_t* tmpData;

    unsigned int width, height, depth, components;
    float scalex, scaley, scalez;
    unsigned char *description;
    unsigned char *courtesy;
    unsigned char *parameter;
    unsigned char *comment;

    LINFO("Reading PVM volume " << fileName);

    /*
        TODO This subroutine returns an array created with malloc but it should
        be created with 'new[]' because this chunk of data will be deleted with 'delete[]'.
        This can cause hard to find errors.

        As a temporary workaround the data are copied over into a new array
        and the c-array is deleted with 'free'.
        Because of some c-pointer vodoo done in ddsbase.cpp free must be invoked
        after the use of all other returned pointers. (roland)
    */
    tmpData = readPVMvolume(const_cast<char*>(fileName.c_str()), getProgressBar(),
                            &width, &height, &depth, &components,
                            &scalex, &scaley, &scalez, &description, &courtesy,
                            &parameter, &comment);

    if (!tmpData) {
        LERROR("PVM Reading failed");
        return 0;
    }

    data = new uint8_t[width * height * depth * components];
    memcpy(data, tmpData, width * height * depth * components);

    Volume* dataset = 0;

    if (!data) {
        throw tgt::IOException();
    }
    else {
        LINFO("Size: " << width << " x " << height << " x " << depth);
        LINFO("Spacing: " << scalex << " x " << scaley << " x " << scalez);
        LINFO("Components: " << components);
        if (description)
            LINFO("Description: " << description);
        if (courtesy)
            LINFO("Courtesy: " << courtesy);
        if (parameter)
            LINFO("Parameter: " << parameter);
        if (comment)
            LINFO("Comment: " << comment);
        if (components == 1) {
            LINFO("Create 8 bit data set.");
            dataset = new VolumeUInt8(data, tgt::ivec3(width, height, depth),
                                      tgt::vec3(scalex, scaley, scalez));
        }
        else if (components == 2) {
            // the endianness conversion in ddsbase.cpp seem to be broken,
            // so we perform it here instead
            uint16_t* data16 = reinterpret_cast<uint16_t*>(data);
            int numElements = width * height * depth;
            uint16_t maxValue = 0;
            for (int i=0; i < numElements; i++) {
                endian_swap(data16[i]);
                if (data16[i] > maxValue)
                    maxValue = data16[i];
            }

            int bits;
            if (maxValue < 4096) {
                LINFO("Create 12 bit data set.");
                bits = 12;
            } else {
                LINFO("Create 16 bit data set.");
                bits = 16;
            }
            dataset = new VolumeUInt16((uint16_t*)data,
                                       tgt::ivec3(width, height, depth),
                                       tgt::vec3(scalex, scaley, scalez),
                                       tgt::mat4::identity,
                                       bits);

        }
        else LERROR("Bit depth not supported.");
    }

    // TODO now it is safe to free
    free(tmpData);

    VolumeCollection* volumeCollection = new VolumeCollection();
    if (dataset) {
        VolumeHandle* volumeHandle = new VolumeHandle(dataset, 0.0f);
        volumeHandle->setOrigin(VolumeOrigin(fileName));
        volumeCollection->add(volumeHandle);
    }

    return volumeCollection;
}
开发者ID:alvatar,项目名称:smartmatter,代码行数:101,代码来源:pvmvolumereader.cpp


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