本文整理汇总了C++中DimensionDescriptor::setOriginalNumber方法的典型用法代码示例。如果您正苦于以下问题:C++ DimensionDescriptor::setOriginalNumber方法的具体用法?C++ DimensionDescriptor::setOriginalNumber怎么用?C++ DimensionDescriptor::setOriginalNumber使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DimensionDescriptor
的用法示例。
在下文中一共展示了DimensionDescriptor::setOriginalNumber方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
vector<ImportDescriptor*> EnviImporter::getImportDescriptors(const string& filename)
{
string headerFile = filename;
string dataFile;
bool bSuccess = parseHeader(headerFile);
if (bSuccess == false)
{
dataFile = filename; // was passed data file name instead of header file name
headerFile = findHeaderFile(headerFile);
if (headerFile.empty() == false)
{
bSuccess = parseHeader(headerFile);
}
}
EnviField* pField = NULL;
vector<ImportDescriptor*> descriptors;
if (bSuccess == true)
{
if (dataFile.empty() == true) // was passed header file name and now need to find the data file name
{
dataFile = findDataFile(headerFile);
}
if (dataFile.empty() == false)
{
ImportDescriptor* pImportDescriptor = mpModel->createImportDescriptor(dataFile, "RasterElement", NULL);
if (pImportDescriptor != NULL)
{
RasterDataDescriptor* pDescriptor =
dynamic_cast<RasterDataDescriptor*>(pImportDescriptor->getDataDescriptor());
if (pDescriptor != NULL)
{
FactoryResource<RasterFileDescriptor> pFileDescriptor;
if (pFileDescriptor.get() != NULL)
{
// Filename
pFileDescriptor->setFilename(dataFile);
// Coordinate offset
int columnOffset = 0;
int rowOffset = 0;
pField = mFields.find("x start");
if (pField != NULL)
{
// ENVI numbers are 1 based vs Opticks being 0 based
columnOffset = atoi(pField->mValue.c_str()) - 1;
}
pField = mFields.find("y start");
if (pField != NULL)
{
rowOffset = atoi(pField->mValue.c_str()) - 1; // ENVI numbers are 1 based vs Opticks being 0 based
}
// Rows
vector<DimensionDescriptor> rows;
pField = mFields.find("lines");
if (pField != NULL)
{
int numRows = atoi(pField->mValue.c_str());
for (int i = 0; i < numRows; ++i)
{
DimensionDescriptor rowDim;
rowDim.setOriginalNumber(static_cast<unsigned int>(rowOffset + i));
rowDim.setOnDiskNumber(static_cast<unsigned int>(i));
rows.push_back(rowDim);
}
pDescriptor->setRows(rows);
pFileDescriptor->setRows(rows);
}
string samplesStr = "samples";
string bandsStr = "bands";
// Special case: if the file type is an ENVI Spectral Library, then swap samples with bands
// If no file type field exists, assume this is a normal ENVI header (not a Spectral Library)
EnviField* pFileTypeField = mFields.find("file type");
if (pFileTypeField != NULL && (pFileTypeField->mValue ==
"ENVI Spectral Library" || pFileTypeField->mValue == "Spectral Library"))
{
samplesStr = "bands";
bandsStr = "samples";
// Since bands and samples are swapped, force the interleave to BIP
pField = mFields.find("interleave");
if (pField != NULL)
{
pField->mValue = "bip";
}
}
// Columns
vector<DimensionDescriptor> columns;
pField = mFields.find(samplesStr);
if (pField != NULL)
{
int numColumns = atoi(pField->mValue.c_str());
//.........这里部分代码省略.........
示例2: pFile
vector<ImportDescriptor*> SioImporter::getImportDescriptors(const string& filename)
{
vector<ImportDescriptor*> descriptors;
if (filename.empty() == false)
{
// Read the header values
FileResource pFile(filename.c_str(), "rb");
SioFile sioFile;
bool bSuccess = sioFile.deserialize(pFile.get());
if (bSuccess == false)
{
return descriptors;
}
if (sioFile.mOriginalVersion == 9)
{
mVersion9Sio = true;
}
// Create the import descriptor
ImportDescriptor* pImportDescriptor = mpModel->createImportDescriptor(filename, "RasterElement", NULL);
if (pImportDescriptor != NULL)
{
RasterDataDescriptor* pDescriptor =
dynamic_cast<RasterDataDescriptor*>(pImportDescriptor->getDataDescriptor());
if (pDescriptor != NULL)
{
FactoryResource<RasterFileDescriptor> pFileDescriptor;
if (pFileDescriptor.get() != NULL)
{
// Filename
pFileDescriptor->setFilename(filename);
// Endian
pFileDescriptor->setEndian(sioFile.mEndian);
// Rows
vector<DimensionDescriptor> rows;
for (int i = 0; i < sioFile.mRows; ++i)
{
DimensionDescriptor rowDim;
// Do not set an active number since the user has not selected the rows to load
if (static_cast<unsigned int>(i) < sioFile.mOrigRowNumbers.size())
{
rowDim.setOriginalNumber(sioFile.mOrigRowNumbers[i]);
}
else
{
rowDim.setOriginalNumber(i);
}
rowDim.setOnDiskNumber(i);
rows.push_back(rowDim);
}
pDescriptor->setRows(rows);
pFileDescriptor->setRows(rows);
// Columns
vector<DimensionDescriptor> columns;
for (int i = 0; i < sioFile.mColumns; ++i)
{
DimensionDescriptor columnDim;
// Do not set an active number since the user has not selected the rows to load
if (static_cast<unsigned int>(i) < sioFile.mOrigColumnNumbers.size())
{
columnDim.setOriginalNumber(sioFile.mOrigColumnNumbers[i]);
}
else
{
columnDim.setOriginalNumber(i);
}
columnDim.setOnDiskNumber(i);
columns.push_back(columnDim);
}
pDescriptor->setColumns(columns);
pFileDescriptor->setColumns(columns);
// Bands
vector<DimensionDescriptor> bands;
for (int i = 0; i < (sioFile.mBands - sioFile.mBadBands); ++i)
{
DimensionDescriptor bandDim;
// Do not set an active number since the user has not selected the rows to load
if (static_cast<unsigned int>(i) < sioFile.mOrigBandNumbers.size())
{
bandDim.setOriginalNumber(sioFile.mOrigBandNumbers[i]);
}
else
{
bandDim.setOriginalNumber(i);
}
bandDim.setOnDiskNumber(i);
//.........这里部分代码省略.........