本文整理汇总了C++中VolumeCollection::empty方法的典型用法代码示例。如果您正苦于以下问题:C++ VolumeCollection::empty方法的具体用法?C++ VolumeCollection::empty怎么用?C++ VolumeCollection::empty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类VolumeCollection
的用法示例。
在下文中一共展示了VolumeCollection::empty方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: read
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;
}
示例2: 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;
}
示例3: 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());
}
}
示例4: 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;
}
示例5: readAnalyze
//.........这里部分代码省略.........
file.seekg(0, std::ios::end);
std::streamoff fileSize = file.tellg();
file.seekg(0, std::ios::beg);
if(fileSize != 348)
LWARNING("Filesize != 348");
header_key header;
if (!file.read((char*)&header, sizeof(header))) {
throw tgt::CorruptedFileException("Failed to read header!", fileName);
}
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();
}
RawVolumeReader::ReadHints h;
h.dimensions_.x = dimension.dim[1];
h.dimensions_.y = dimension.dim[2];
h.dimensions_.z = dimension.dim[3];
LINFO("Resolution: " << h.dimensions_);
if (hor(lessThanEqual(h.dimensions_, ivec3(0)))) {
LERROR("Invalid resolution or resolution not specified: " << h.dimensions_);
throw tgt::CorruptedFileException("error while reading data", fileName);
}
h.spacing_.x = dimension.pixdim[1];
h.spacing_.y = dimension.pixdim[2];
h.spacing_.z = dimension.pixdim[3];
LINFO("Spacing: " << h.spacing_);
LINFO("Datatype: " << dimension.datatype);
switch(dimension.datatype) {
case DT_UNSIGNED_CHAR:
h.format_ = "UCHAR";
h.objectModel_ = "I";
break;
case DT_SIGNED_SHORT:
h.format_ = "SHORT";
h.objectModel_ = "I";
break;
case DT_SIGNED_INT:
h.format_ = "INT";
h.objectModel_ = "I";
break;
case DT_FLOAT:
h.format_ = "FLOAT";
h.objectModel_ = "I";
break;
case DT_DOUBLE:
h.format_ = "DOUBLE";
h.objectModel_ = "I";
break;
case DT_RGB:
h.format_ = "UCHAR";
h.objectModel_ = "RGB";
break;
case DT_ALL:
case DT_COMPLEX:
case 0: //DT_NONE/DT_UNKNOWN
case DT_BINARY:
default:
throw tgt::UnsupportedFormatException("Unsupported datatype!");
}
h.bigEndianByteOrder_ = bigEndian;
std::string objectType;
std::string gridType;
RawVolumeReader rawReader(getProgressBar());
rawReader.setReadHints(h);
VolumeCollection* volumeCollection = rawReader.read(getRelatedImgFileName(fileName));
if (!volumeCollection->empty()) {
static_cast<VolumeHandle*>(volumeCollection->first())->setOrigin(VolumeOrigin(fileName));
oldVolumePosition(static_cast<VolumeHandle*>(volumeCollection->first()));
}
return volumeCollection;
}
示例6: readNifti
//.........这里部分代码省略.........
h.objectModel_ = "RGB";
}
else
h.objectModel_ = "I";
switch(header.datatype) {
case DT_UNSIGNED_CHAR:
h.format_ = "UCHAR";
h.objectModel_ = "I";
break;
case DT_SIGNED_SHORT:
h.format_ = "SHORT";
h.objectModel_ = "I";
break;
case DT_SIGNED_INT:
h.format_ = "INT";
h.objectModel_ = "I";
break;
case DT_FLOAT:
h.format_ = "FLOAT";
h.objectModel_ = "I";
break;
case DT_DOUBLE:
h.format_ = "DOUBLE";
h.objectModel_ = "I";
break;
case DT_RGB:
h.format_ = "UCHAR";
h.objectModel_ = "RGB";
break;
case DT_RGBA32: /* 4 byte RGBA (32 bits/voxel) */
h.format_ = "UCHAR";
h.objectModel_ = "RGBA";
break;
case DT_INT8: /* signed char (8 bits) */
h.format_ = "CHAR";
h.objectModel_ = "I";
break;
case DT_UINT16: /* unsigned short (16 bits) */
h.format_ = "USHORT";
h.objectModel_ = "I";
break;
case DT_UINT32: /* unsigned int (32 bits) */
h.format_ = "UINT";
h.objectModel_ = "I";
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!");
}
if (header.intent_code == IC_INTENT_SYMMATRIX) {
h.objectModel_ = "TENSOR_FUSION_LOW";
}
h.bigEndianByteOrder_ = bigEndian;
//std::string objectType;
//std::string gridType;
//} else if (type == "ObjectType:") {
//args >> objectType;
//LDEBUG(type << " " << objectType);
//} else if (type == "GridType:") {
//args >> gridType;
//LDEBUG(type << " " << gridType);
//} else if (type == "BitsStored:") {
//args >> h.bitsStored_;
//LDEBUG(type << " " << h.bitsStored_);
//} else if (type == "Unit:") {
//args >> h.unit_;
//LDEBUG(type << " " << h.unit_);
if (standalone)
h.headerskip_ = static_cast<uint16_t>(header.vox_offset);
RawVolumeReader rawReader(getProgressBar());
rawReader.setReadHints(h);
VolumeCollection* volumeCollection = 0;
if(standalone)
volumeCollection = rawReader.read(fileName);
else
volumeCollection = rawReader.read(getRelatedImgFileName(fileName));
if (!volumeCollection->empty()) {
static_cast<VolumeHandle*>(volumeCollection->first())->setOrigin(VolumeOrigin(fileName));
oldVolumePosition(static_cast<VolumeHandle*>(volumeCollection->first()));
}
return volumeCollection;
}