本文整理汇总了C++中DataAccessor::isValid方法的典型用法代码示例。如果您正苦于以下问题:C++ DataAccessor::isValid方法的具体用法?C++ DataAccessor::isValid怎么用?C++ DataAccessor::isValid使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DataAccessor
的用法示例。
在下文中一共展示了DataAccessor::isValid方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: bilinear_height
double bilinear_height(DataAccessor pSrcAcc, double I, double J)
{
double z1=0,z2=0,z3=0,z4=0;
pSrcAcc->toPixel(int(J),int(I));
VERIFY(pSrcAcc.isValid());
z1 = pSrcAcc->getColumnAsDouble();
pSrcAcc->toPixel(int(J)+1,int(I));
VERIFY(pSrcAcc.isValid());
z2 = pSrcAcc->getColumnAsDouble();
pSrcAcc->toPixel(int(J),int(I)+1);
VERIFY(pSrcAcc.isValid());
z3 = pSrcAcc->getColumnAsDouble();
pSrcAcc->toPixel(int(J)+1,int(I)+1);
VERIFY(pSrcAcc.isValid());
z4 = pSrcAcc->getColumnAsDouble();
double a=0,b=0,c=0,d=0;
d = z1;
a = (z2-z1);
b = (z3-z1);
c = (z4+z1-z2-z3);
double H = a*(J-int(J))+b*(I-int(I))+c*(I-int(I))*(J-int(J))+d;
return H;
}
示例2: copyImage
bool bilinear_bayer::copyImage(RasterElement * pRaster,
RasterElement * dRaster, int i,
Progress * pProgress)
{
VERIFY(pRaster != NULL);
RasterDataDescriptor *pDesc =
dynamic_cast < RasterDataDescriptor * >(pRaster->getDataDescriptor());
VERIFY(dRaster != NULL);
RasterDataDescriptor *rDesc =
dynamic_cast < RasterDataDescriptor * >(dRaster->getDataDescriptor());
DimensionDescriptor thirdBand = pDesc->getActiveBand(i); // get active
// band
// source
FactoryResource < DataRequest > pRequest;
pRequest->setInterleaveFormat(BSQ);
pRequest->setBands(thirdBand, thirdBand);
DataAccessor thirdBandDa = pRaster->getDataAccessor(pRequest.release());
thirdBand = rDesc->getActiveBand(i);
// destination
FactoryResource < DataRequest > pResultRequest;
pResultRequest->setWritable(true);
pRequest->setInterleaveFormat(BSQ);
pResultRequest->setBands(thirdBand, thirdBand);
DataAccessor pDestAcc = dRaster->getDataAccessor(pResultRequest.release());
VERIFY(thirdBandDa.isValid());
VERIFY(pDestAcc.isValid());
for (unsigned int curRow = 0; curRow < pDesc->getRowCount(); ++curRow)
{
for (unsigned int curCol = 0; curCol < pDesc->getColumnCount();
++curCol)
{
switchOnEncoding(pDesc->getDataType(), bilinear,
pDestAcc->getColumn(), thirdBandDa, curRow,
curCol, pDesc->getRowCount(),
pDesc->getColumnCount(), i, pRaster);
pDestAcc->nextColumn();
}
pDestAcc->nextRow();
}
return true;
}
示例3: preprocess
bool BackgroundSuppressionShell::preprocess()
{
if(mpRaster == NULL)
{
return false;
}
RasterDataDescriptor *pDesc = static_cast<RasterDataDescriptor*>(mpRaster->getDataDescriptor());
if(mpTemporaryBuffer.get() == NULL)
{
mpTemporaryBuffer.reset(new char[pDesc->getRowCount() * pDesc->getColumnCount() * pDesc->getBytesPerElement()]);
if(mpTemporaryBuffer.get() == NULL)
{
return false;
}
}
DataAccessor frameAccessor = getCurrentFrameAccessor();
size_t rowSize = pDesc->getColumnCount() * pDesc->getBytesPerElement();
for(unsigned int row = 0; row < pDesc->getRowCount(); row++)
{
if(!frameAccessor.isValid())
{
return false;
}
memcpy(mpTemporaryBuffer.get() + row * rowSize, frameAccessor->getRow(), rowSize);
frameAccessor->nextColumn();
}
return true;
}
示例4: getResampledSignatureValues
bool SpectralLibraryManager::getResampledSignatureValues(const RasterElement* pRaster, const Signature* pSignature,
std::vector<double>& values)
{
values.clear();
if (pRaster == NULL || pSignature == NULL)
{
return false;
}
const RasterElement* pLibData = getResampledLibraryData(pRaster);
if (pLibData == NULL)
{
return false;
}
int index = getSignatureIndex(pSignature);
if (index < 0)
{
return false;
}
const RasterDataDescriptor* pLibDesc = dynamic_cast<const RasterDataDescriptor*>(pLibData->getDataDescriptor());
VERIFY(pLibDesc != NULL);
unsigned int numBands = pLibDesc->getBandCount();
values.reserve(numBands);
FactoryResource<DataRequest> pRqt;
unsigned int row = static_cast<unsigned int>(index);
pRqt->setInterleaveFormat(BIP);
pRqt->setRows(pLibDesc->getActiveRow(row), pLibDesc->getActiveRow(row), 1);
DataAccessor acc = pLibData->getDataAccessor(pRqt.release());
VERIFY(acc.isValid());
double* pDbl = reinterpret_cast<double*>(acc->getColumn());
for (unsigned int band = 0; band < numBands; ++band)
{
values.push_back(*pDbl);
++pDbl;
}
return true;
}
示例5: process
bool Orthorectification::process(int type, RasterElement *pDSM, GRID DSMGrid, double Geoid_Offset, int DSM_resampling)
{
StepResource pStep("Orthorectification Process", "app", "B4D426EC-E06D-11E1-83C8-42E56088709B");
pStep->addStep("Start","app", "B4D426EC-E06D-11E1-83C8-42E56088709B");
boxsize=0;
res_type = type;
if (res_type == 0)
{
boxsize=0;
}
else if (res_type == 1)
{
boxsize=1;
}
else if (res_type == 2)
{
boxsize=2;
}
else if (res_type == 3)
{
boxsize=3;
}
ProgressResource pResource("ProgressBar");
Progress *pProgress=pResource.get();
pProgress->setSettingAutoClose(false);
RasterDataDescriptor* pDesc = static_cast<RasterDataDescriptor*>(Image->getDataDescriptor());
FactoryResource<DataRequest> pRequest;
DataAccessor pSrcAcc = Image->getDataAccessor(pRequest.release());
RasterDataDescriptor* pDescDSM = static_cast<RasterDataDescriptor*>(pDSM->getDataDescriptor());
FactoryResource<DataRequest> pRequestDSM;
DataAccessor pDSMAcc = pDSM->getDataAccessor(pRequestDSM.release());
unsigned int N_Row = int(OrthoGrid.Y_Dim)+1;
unsigned int N_Col = int(OrthoGrid.X_Dim)+1;
// Check name of raster element //
Service<ModelServices> pModel;
vector<string> mCubeNames = pModel->getElementNames("RasterElement");
int NameIndex = 0, control=0;
stringstream out;
string OutputName=Image->getName();
string OutputName1 = OutputName.substr(0,OutputName.find_last_of("."));
while (control == 0)
{
control = 1;
OutputName = OutputName1+"_ortho_";
out << NameIndex;
OutputName.append(out.str()+".tiff");
for (unsigned int k=0; k<mCubeNames.size(); k++)
{
if (OutputName.compare(mCubeNames[k]) == 0) control = 0;
}
NameIndex++;
out.str("");
out.clear();
}
// Create output raster element and assoiciated descriptor and accessor //
ModelResource<RasterElement> pResultCube(RasterUtilities::createRasterElement(OutputName,N_Row ,N_Col, FLT4BYTES));
RasterDataDescriptor* pResultDesc = static_cast<RasterDataDescriptor*> (pResultCube->getDataDescriptor());
FactoryResource<DataRequest> pResultRequest;
pResultRequest->setWritable(true);
DataAccessor pDestAcc = pResultCube->getDataAccessor(pResultRequest.release());
double NodeLat, NodeLon, H_IJ=0;
//int DSM_I, DSM_J;
for (unsigned int row = 0; row < N_Row; ++row)
{
if (pProgress != NULL)
{
pProgress->updateProgress("Calculating result", row * 100 / N_Row, NORMAL);
}
if (!pDestAcc.isValid())
{
std::string msg = "Unable to access the cube data.";
pProgress->updateProgress(msg, 0, ERRORS);
pStep->finalize(Message::Failure, msg);
return false;
}
//.........这里部分代码省略.........
示例6: generateResampledLibrary
bool SpectralLibraryManager::generateResampledLibrary(const RasterElement* pRaster)
{
VERIFY(pRaster != NULL);
// check that lib sigs are in same units as the raster element
const RasterDataDescriptor* pDesc = dynamic_cast<const RasterDataDescriptor*>(pRaster->getDataDescriptor());
VERIFY(pDesc != NULL);
const Units* pUnits = pDesc->getUnits();
if (pDesc->getUnits()->getUnitType() != mLibraryUnitType)
{
if (Service<DesktopServices>()->showMessageBox("Mismatched Units", "The data are not in the "
"same units as the spectral library.\n Do you want to continue anyway?", "Yes", "No") == 1)
{
return false;
}
}
FactoryResource<Wavelengths> pWavelengths;
pWavelengths->initializeFromDynamicObject(pRaster->getMetadata(), false);
// populate the library with the resampled signatures
PlugInResource pPlugIn("Resampler");
Resampler* pResampler = dynamic_cast<Resampler*>(pPlugIn.get());
VERIFY(pResampler != NULL);
if (pWavelengths->getNumWavelengths() != pDesc->getBandCount())
{
mpProgress->updateProgress("Wavelength information in metadata does not match the number of bands "
"in the raster element", 0, ERRORS);
return false;
}
// get resample suitable signatures - leave out signatures that don't cover the spectral range of the data
std::vector<std::vector<double> > resampledData;
resampledData.reserve(mSignatures.size());
std::vector<Signature*> resampledSignatures;
resampledSignatures.reserve(mSignatures.size());
std::vector<std::string> unsuitableSignatures;
std::vector<double> sigValues;
std::vector<double> sigWaves;
std::vector<double> rasterWaves = pWavelengths->getCenterValues();
std::vector<double> rasterFwhm = pWavelengths->getFwhm();
std::vector<double> resampledValues;
std::vector<int> bandIndex;
DataVariant data;
for (std::vector<Signature*>::const_iterator it = mSignatures.begin(); it != mSignatures.end(); ++it)
{
data = (*it)->getData(SpectralLibraryMatch::getNameSignatureWavelengthData());
VERIFY(data.isValid());
VERIFY(data.getValue(sigWaves));
resampledValues.clear();
data = (*it)->getData(SpectralLibraryMatch::getNameSignatureAmplitudeData());
VERIFY(data.isValid());
VERIFY(data.getValue(sigValues));
double scaleFactor = (*it)->getUnits(
SpectralLibraryMatch::getNameSignatureAmplitudeData())->getScaleFromStandard();
for (std::vector<double>::iterator sit = sigValues.begin(); sit != sigValues.end(); ++sit)
{
*sit *= scaleFactor;
}
std::string msg;
if (pResampler->execute(sigValues, resampledValues, sigWaves, rasterWaves, rasterFwhm, bandIndex, msg) == false
|| resampledValues.size() != rasterWaves.size())
{
unsuitableSignatures.push_back((*it)->getName());
continue;
}
resampledData.push_back(resampledValues);
resampledSignatures.push_back(*it);
}
if (resampledSignatures.empty())
{
std::string errMsg = "None of the signatures in the library cover the spectral range of the data.";
if (mpProgress != NULL)
{
mpProgress->updateProgress(errMsg, 0, ERRORS);
return false;
}
}
if (unsuitableSignatures.empty() == false)
{
std::string warningMsg = "The following library signatures do not cover the spectral range of the data:\n";
for (std::vector<std::string>::iterator it = unsuitableSignatures.begin();
it != unsuitableSignatures.end(); ++it)
{
warningMsg += *it + "\n";
}
warningMsg += "These signatures will not be searched for in the data.";
Service<DesktopServices>()->showMessageBox("SpectralLibraryManager", warningMsg);
StepResource pStep("Spectral LibraryManager", "spectral", "64B6C87A-A6C3-4378-9B6E-221D89D8707B");
pStep->finalize(Message::Unresolved, warningMsg);
}
std::string libName = "Resampled Spectral Library";
// Try to get the resampled lib element in case session was restored. If NULL, create a new raster element with
// num rows = num valid signatures, num cols = 1, num bands = pRaster num bands
//.........这里部分代码省略.........
示例7: execute
//.........这里部分代码省略.........
QString value3 = QInputDialog::getItem(Service<DesktopServices>()->getMainWidget(),
"Input the size of the gaurd width", "Input the size of the guard width in terms of the number of pixels (eg. 1)", Names3);
std::string strAoi3 = value3.toStdString();
std::istringstream stm3;
stm3.str(strAoi3);
//stm3 >> DEPTH3;
DEPTH3=::atof(strAoi3.c_str());
QStringList Names4("1");
QString value4 = QInputDialog::getItem(Service<DesktopServices>()->getMainWidget(),
"Input the size of the guard height", "Input the size of the guard height in terms of the number of pixels (eg. 1)", Names4);
std::string strAoi4 = value4.toStdString();
std::istringstream stm4;
stm4.str(strAoi4);
stm4 >> DEPTH4;
DEPTH4=::atof(strAoi4.c_str());
for (int row = 0; row < rowSize; ++row)
{
if (isAborted())
{
std::string msg = getName() + " has been aborted.";
pStep->finalize(Message::Abort, msg);
if (pProgress != NULL)
{
pProgress->updateProgress(msg, 0, ABORT);
}
return false;
}
if (!pAcc.isValid())
{
std::string msg = "Unable to access the cube data.";
pStep->finalize(Message::Failure, msg);
if (pProgress != NULL)
{
pProgress->updateProgress(msg, 0, ERRORS);
}
return false;
}
if (pProgress != NULL)
{
pProgress->updateProgress("Calculating statistics", row * 100 / pDesc->getRowCount(), NORMAL);
}
for (int col = 0; col < colSize; ++col)
{
//p[col]=pAcc2->getColumnAsInteger();
westCol=max(col-DEPTH1,zero);
northRow=max(row-DEPTH2,zero);
eastCol=min(colSize-1,col+DEPTH1);
southRow=min(rowSize-1,row+DEPTH2);
prevCol=max(col-DEPTH3,zero);
prevRow=max(row-DEPTH4,zero);
nextCol=min(col+DEPTH3,colSize-1);
nextRow=min(row+DEPTH4,rowSize-1);
pAcc2->toPixel(northRow,westCol);
示例8: execute
bool conservative_filter::execute(PlugInArgList* pInArgList, PlugInArgList* pOutArgList)
{
StepResource pStep("Conservative", "Filter", "5EA0CC75-9E0B-4c3d-BA23-6DB7157BBD55"); //what is this?
if (pInArgList == NULL || pOutArgList == NULL)
{
return false;
}
Service <DesktopServices> pDesktop;
conservative_filter_ui dialog(pDesktop->getMainWidget());
int status = dialog.exec();
if (status == QDialog::Accepted)
{
int radius = dialog.getRadiusValue();
Progress* pProgress = pInArgList->getPlugInArgValue<Progress>(Executable::ProgressArg());
RasterElement* pCube = pInArgList->getPlugInArgValue<RasterElement>(Executable::DataElementArg());
if (pCube == NULL)
{
std::string msg = "A raster cube must be specified.";
pStep->finalize(Message::Failure, msg);
if (pProgress != NULL)
{
pProgress->updateProgress(msg, 0, ERRORS);
}
return false;
}
RasterDataDescriptor* pDesc = static_cast<RasterDataDescriptor*>(pCube->getDataDescriptor());
VERIFY(pDesc != NULL);
if (pDesc->getDataType() == INT4SCOMPLEX || pDesc->getDataType() == FLT8COMPLEX)
{
std::string msg = "Conservative Filter cannot be performed on complex types.";
pStep->finalize(Message::Failure, msg);
if (pProgress != NULL)
{
pProgress->updateProgress(msg, 0, ERRORS);
}
return false;
}
FactoryResource<DataRequest> pRequest;
pRequest->setInterleaveFormat(BSQ);
DataAccessor pSrcAcc = pCube->getDataAccessor(pRequest.release());
ModelResource<RasterElement> pResultCube(RasterUtilities::createRasterElement(pCube->getName() + "_Conservative_Filter_Result", pDesc->getRowCount(), pDesc->getColumnCount(), pDesc->getDataType()));
if (pResultCube.get() == NULL)
{
std::string msg = "A raster cube could not be created.";
pStep->finalize(Message::Failure, msg);
if (pProgress != NULL)
{
pProgress->updateProgress(msg, 0, ERRORS);
}
return false;
}
FactoryResource<DataRequest> pResultRequest;
pResultRequest->setWritable(true);
DataAccessor pDestAcc = pResultCube->getDataAccessor(pResultRequest.release());
for (unsigned int row = 0; row < pDesc->getRowCount(); ++row)
{
if (pProgress != NULL)
{
pProgress->updateProgress("Applying Conservative Filter", row * 100 / pDesc->getRowCount(), NORMAL);
}
if (isAborted())
{
std::string msg = getName() + " has been aborted.";
pStep->finalize(Message::Abort, msg);
if (pProgress != NULL)
{
pProgress->updateProgress(msg, 0, ABORT);
}
return false;
}
if (!pDestAcc.isValid())
{
std::string msg = "Unable to access the cube data.";
pStep->finalize(Message::Failure, msg);
if (pProgress != NULL)
{
pProgress->updateProgress(msg, 0, ERRORS);
}
return false;
}
for (unsigned int col = 0; col < pDesc->getColumnCount(); ++col)
{
switchOnEncoding(pDesc->getDataType(), verifyRange, pDestAcc->getColumn(), pSrcAcc, row, col, pDesc->getRowCount(), pDesc->getColumnCount(), radius);
pDestAcc->nextColumn();
}
pDestAcc->nextRow();
}
if (!isBatch())
{
Service<DesktopServices> pDesktop;
SpatialDataWindow* pWindow = static_cast<SpatialDataWindow*>(pDesktop->createWindow(pResultCube->getName(),
//.........这里部分代码省略.........
示例9: ComputeSam
void SamThread::ComputeSam(const T* pDummyData)
{
int reSamBan_index = 0, row_index = 0, col_index = 0;
float* pResultsData = NULL;
int oldPercentDone = -1;
double spectrumMag = 0.0;
const T* pData=NULL;
const RasterDataDescriptor* pDescriptor = static_cast<const RasterDataDescriptor*>(
mInput.mpCube->getDataDescriptor());
unsigned int numCols = pDescriptor->getColumnCount();
unsigned int numBands = pDescriptor->getBandCount();
unsigned int numRows = (mRowRange.mLast - mRowRange.mFirst + 1);
int numResultsCols = 0;
//Sets area to apply the SAM algortihm to. Either
//the entire cube, or a selected ROI.
if (mInput.mIterCheck.useAllPixels())
{
//Total number of Columns in cube.
numResultsCols = numCols;
}
else
{
numResultsCols = mInput.mIterCheck.getNumSelectedColumns();
}
if (mInput.mpResultsMatrix == NULL)
{
return;
}
const RasterDataDescriptor* pResultDescriptor = static_cast<const RasterDataDescriptor*>(
mInput.mpResultsMatrix->getDataDescriptor());
// Gets results matrix that was initialized in ProcessAll()
mRowRange.mFirst = std::max(0, mRowRange.mFirst);
mRowRange.mLast = std::min(mRowRange.mLast, static_cast<int>(pDescriptor->getRowCount()) - 1);
FactoryResource<DataRequest> pResultRequest;
pResultRequest->setRows(pResultDescriptor->getActiveRow(mRowRange.mFirst),
pResultDescriptor->getActiveRow(mRowRange.mLast));
pResultRequest->setColumns(pResultDescriptor->getActiveColumn(0),
pResultDescriptor->getActiveColumn(numResultsCols - 1));
pResultRequest->setWritable(true);
DataAccessor resultAccessor = mInput.mpResultsMatrix->getDataAccessor(pResultRequest.release());
if (!resultAccessor.isValid())
{
return;
}
// Resamples and sets search signature
for (reSamBan_index = 0; reSamBan_index < (int) mInput.mResampledBands.size(); ++reSamBan_index)
{
spectrumMag += mInput.mSpectrum[reSamBan_index] * mInput.mSpectrum[reSamBan_index];
}
spectrumMag = sqrt(spectrumMag);
int rowOffset = mInput.mIterCheck.getOffset().mY;
int startRow = (mRowRange.mFirst + rowOffset);
int stopRow = (mRowRange.mLast + rowOffset);
int columnOffset = mInput.mIterCheck.getOffset().mX;
int startColumn = columnOffset;
int stopColumn = (numResultsCols + columnOffset - 1);
FactoryResource<DataRequest> pRequest;
pRequest->setInterleaveFormat(BIP);
pRequest->setRows(pDescriptor->getActiveRow(startRow), pDescriptor->getActiveRow(stopRow));
pRequest->setColumns(pDescriptor->getActiveColumn(startColumn), pDescriptor->getActiveColumn(stopColumn));
DataAccessor accessor = mInput.mpCube->getDataAccessor(pRequest.release());
if (!accessor.isValid())
{
return;
}
for (row_index = startRow; row_index <= stopRow; ++row_index)
{
int percentDone = mRowRange.computePercent(row_index-rowOffset);
if (percentDone > oldPercentDone)
{
oldPercentDone = percentDone;
getReporter().reportProgress(getThreadIndex(), percentDone);
}
if (mInput.mpAbortFlag != NULL && *mInput.mpAbortFlag)
{
break;
}
for (col_index = startColumn; col_index <= stopColumn; ++col_index)
{
VERIFYNRV(resultAccessor.isValid());
VERIFYNRV(accessor.isValid());
// Pointer to results data
pResultsData = reinterpret_cast<float*>(resultAccessor->getColumn());
if (pResultsData == NULL)
{
return;
}
if (mInput.mIterCheck.getPixel(col_index, row_index))
{
//Pointer to cube/sensor data
pData = reinterpret_cast<T*>(accessor->getColumn());
//.........这里部分代码省略.........
示例10: execute
bool pagauss::execute(PlugInArgList* pInArgList, PlugInArgList* pOutArgList)
{
StepResource pStep("Tutorial 5", "app", "5EA0CC75-9E0B-4c3d-BA23-6DB7157BBD54");
if (pInArgList == NULL || pOutArgList == NULL)
{
return false;
}
Progress* pProgress = pInArgList->getPlugInArgValue<Progress>(Executable::ProgressArg());
RasterElement* pCube = pInArgList->getPlugInArgValue<RasterElement>(Executable::DataElementArg());
if (pCube == NULL)
{
std::string msg = "A raster cube must be specified.";
pStep->finalize(Message::Failure, msg);
if (pProgress != NULL)
{
pProgress->updateProgress(msg, 0, ERRORS);
}
return false;
}
RasterDataDescriptor* pDesc = static_cast<RasterDataDescriptor*>(pCube->getDataDescriptor());
VERIFY(pDesc != NULL);
if (pDesc->getDataType() == INT4SCOMPLEX || pDesc->getDataType() == FLT8COMPLEX)
{
std::string msg = "Edge detection cannot be performed on complex types.";
pStep->finalize(Message::Failure, msg);
if (pProgress != NULL)
{
pProgress->updateProgress(msg, 0, ERRORS);
}
return false;
}
FactoryResource<DataRequest> pRequest;
pRequest->setInterleaveFormat(BSQ);
DataAccessor pSrcAcc = pCube->getDataAccessor(pRequest.release());
ModelResource<RasterElement> pResultCube(RasterUtilities::createRasterElement(pCube->getName() +
"_Edge_Detection_Result", pDesc->getRowCount(), pDesc->getColumnCount(), pDesc->getDataType()));
if (pResultCube.get() == NULL)
{
std::string msg = "A raster cube could not be created.";
pStep->finalize(Message::Failure, msg);
if (pProgress != NULL)
{
pProgress->updateProgress(msg, 0, ERRORS);
}
return false;
}
FactoryResource<DataRequest> pResultRequest;
pResultRequest->setWritable(true);
DataAccessor pDestAcc = pResultCube->getDataAccessor(pResultRequest.release());
for (long signed int row = 0; row < pDesc->getRowCount(); ++row)
{
if (pProgress != NULL)
{
pProgress->updateProgress("Calculating result", row * 100 / pDesc->getRowCount(), NORMAL);
}
if (isAborted())
{
std::string msg = getName() + " has been aborted.";
pStep->finalize(Message::Abort, msg);
if (pProgress != NULL)
{
pProgress->updateProgress(msg, 0, ABORT);
}
return false;
}
if (!pDestAcc.isValid())
{
std::string msg = "Unable to access the cube data.";
pStep->finalize(Message::Failure, msg);
if (pProgress != NULL)
{
pProgress->updateProgress(msg, 0, ERRORS);
}
return false;
}
for (long signed int col = 0; col < pDesc->getColumnCount(); ++col)
{
switchOnEncoding(pDesc->getDataType(), gauss, pDestAcc->getColumn(), pSrcAcc, row, col,
pDesc->getRowCount(), pDesc->getColumnCount());
pDestAcc->nextColumn();
}
pDestAcc->nextRow();
}
if (!isBatch())
{
Service<DesktopServices> pDesktop;
SpatialDataWindow* pWindow = static_cast<SpatialDataWindow*>(pDesktop->createWindow(pResultCube->getName(),
SPATIAL_DATA_WINDOW));
//.........这里部分代码省略.........
示例11:
bool adaptive_median::copyImage4(RasterElement * pRaster,
RasterElement * dRaster, int i,
Progress * pProgress)
{
int flag = 0;
int size = 3;
int sizeMax = MAX_SIZE;
VERIFY(pRaster != NULL);
RasterDataDescriptor *pDesc =
dynamic_cast < RasterDataDescriptor * >(pRaster->getDataDescriptor());
VERIFY(dRaster != NULL);
RasterDataDescriptor *rDesc =
dynamic_cast < RasterDataDescriptor * >(dRaster->getDataDescriptor());
DimensionDescriptor thirdBand = pDesc->getActiveBand(i); // get active
// band
// source
FactoryResource < DataRequest > pRequest;
pRequest->setInterleaveFormat(BSQ);
pRequest->setBands(thirdBand, thirdBand);
DataAccessor thirdBandDa = pRaster->getDataAccessor(pRequest.release());
thirdBand = rDesc->getActiveBand(i);
// destination
FactoryResource < DataRequest > pResultRequest;
pResultRequest->setWritable(true);
pRequest->setInterleaveFormat(BSQ);
pResultRequest->setBands(thirdBand, thirdBand);
DataAccessor pDestAcc = dRaster->getDataAccessor(pResultRequest.release());
VERIFY(thirdBandDa.isValid());
VERIFY(pDestAcc.isValid());
for (unsigned int curRow = 0; curRow < pDesc->getRowCount(); ++curRow)
{
for (unsigned int curCol = 0; curCol < pDesc->getColumnCount();
++curCol)
{
VERIFY(pDestAcc.isValid());
switchOnEncoding(pDesc->getDataType(), adaptivemedian,
pDestAcc->getColumn(), thirdBandDa, curRow,
curCol, pDesc->getRowCount(),
pDesc->getColumnCount(), size, sizeMax, pProgress,
&flag);
if (flag == 1 && size <= sizeMax)
{
// increase window size
size = size + 2;
curCol--;
}
else
{
pDestAcc->nextColumn();
size = 3;
flag = 0;
}
}
pDestAcc->nextRow();
}
return true;
}
示例12: execute
//.........这里部分代码省略.........
mExpression = frmASIT.getExpression(true).toStdString();
mbDegrees = frmASIT.isDegrees();
mbCubeMath = frmASIT.isMultiCube();
mbAsLayerOnExistingView = frmASIT.isResultsMatrix();
}
else
{
mbCubeMath = false;
//check for cube math
unsigned int pos = mExpression.find_first_of(string("cC"));
if ((pos >= 0) && (pos < (mExpression.length() - 1)) && ((mExpression[pos + 1] > '0') &&
(mExpression[pos + 1] < '9')))
{
mbCubeMath = true;
}
}
if (!createReturnValue(mExpression))
{
mstrProgressString = "Could not allocate space for results.";
meGabbiness = ERRORS;
displayErrorMessage();
return false;
}
{
StepResource pResultStep("Compute result", "app", "CDCC12AC-32DD-4831-BC6B-225538C92053");
mpStep = pResultStep.get();
pResultStep->addProperty("Expression", mExpression);
FactoryResource<DataRequest> pReturnRequest;
pReturnRequest->setInterleaveFormat(BIP);
pReturnRequest->setWritable(true);
DataAccessor returnDa = mpResultData->getDataAccessor(pReturnRequest.release());
if (!returnDa.isValid())
{
mstrProgressString = "Could not access the result data.";
meGabbiness = ERRORS;
displayErrorMessage();
return false;
}
if (!mbCubeMath)
{
FactoryResource<DataRequest> pCubeRequest;
pCubeRequest->setInterleaveFormat(BIP);
DataAccessor cubeDa = mpCube->getDataAccessor(pCubeRequest.release());
if (!cubeDa.isValid())
{
mstrProgressString = "Reading this cube format is not supported.";
meGabbiness = ERRORS;
displayErrorMessage();
return false;
}
vector<DataAccessor> accessors(1, cubeDa);
vector<EncodingType> types(1, pDescriptor->getDataType());
char* mutableExpression = new char[mExpression.size() + 1];
strcpy(mutableExpression, mExpression.c_str());
errorCode = eval(mpProgress, accessors, types, mCubeRows, mCubeColumns,
mCubeBands, mutableExpression, returnDa, mbDegrees, errorVal, mbCubeMath, mbInteractive);
delete [] mutableExpression;
}
else // cube math
示例13: execute
//.........这里部分代码省略.........
colLoops = pDesc->getColumnCount()/colBlocks;
}
else
{
colLoops = pDesc->getColumnCount()/colBlocks + 1;
}
for (unsigned int i = 0; i < rowLoops; i++)
{
if ( rowIndex + rowBlocks > pDesc->getRowCount())
{
rowIndex = pDesc->getRowCount() - rowBlocks;
}
colIndex = 0;
for (unsigned int j = 0; j < colLoops; j++)
{
if ( colIndex + colBlocks > pDesc->getColumnCount())
{
colIndex = pDesc->getColumnCount() - colBlocks;
}
if (pProgress != NULL)
{
pProgress->updateProgress("Remove result", (i*colLoops+j) / (rowLoops*colLoops), NORMAL);
}
if (isAborted())
{
std::string msg = getName() + " has been aborted.";
pStep->finalize(Message::Abort, msg);
if (pProgress != NULL)
{
pProgress->updateProgress(msg, 0, ABORT);
}
return false;
}
//Process the data in current block
ProcessData(pSrcAcc, pBuffer, rowIndex, colIndex, rowBlocks, colBlocks, ScaleKValue, pDesc->getDataType());
//Output the value
for (unsigned int m = 0; m < rowBlocks; m++)
{
for (unsigned int n = 0; n < colBlocks; n++)
{
if (!pDestAcc.isValid())
{
std::string msg = "Unable to access the cube data.";
pStep->finalize(Message::Failure, msg);
if (pProgress != NULL)
{
pProgress->updateProgress(msg, 0, ERRORS);
}
return false;
}
pDestAcc->toPixel(rowIndex+m, colIndex+n);
switchOnEncoding(ResultType, speckleNoiseRemove, pDestAcc->getColumn(), (pBuffer+m*colBlocks+n));
}
}
colIndex += colBlocks;
}
rowIndex += rowBlocks;
}
if (!isBatch())
{
Service<DesktopServices> pDesktop;
SpatialDataWindow* pWindow = static_cast<SpatialDataWindow*>(pDesktop->createWindow(pResultCube->getName(),
SPATIAL_DATA_WINDOW));
SpatialDataView* pView = (pWindow == NULL) ? NULL : pWindow->getSpatialDataView();
if (pView == NULL)
{
std::string msg = "Unable to create view.";
pStep->finalize(Message::Failure, msg);
if (pProgress != NULL)
{
pProgress->updateProgress(msg, 0, ERRORS);
}
return false;
}
pView->setPrimaryRasterElement(pResultCube.get());
pView->createLayer(RASTER, pResultCube.get());
}
if (pProgress != NULL)
{
pProgress->updateProgress("Noise removal is compete.", 100, NORMAL);
}
pOutArgList->setPlugInArgValue("Noise removal Result", pResultCube.release());
pStep->finalize();
return true;
}
示例14: getPage
RasterPage* ConvertToBsqPager::getPage(DataRequest* pOriginalRequest, DimensionDescriptor startRow,
DimensionDescriptor startColumn, DimensionDescriptor startBand)
{
VERIFYRV(pOriginalRequest != NULL, NULL);
if (pOriginalRequest->getWritable())
{
return NULL;
}
InterleaveFormatType requestedType = pOriginalRequest->getInterleaveFormat();
DimensionDescriptor stopRow = pOriginalRequest->getStopRow();
DimensionDescriptor stopColumn = pOriginalRequest->getStopColumn();
DimensionDescriptor stopBand = pOriginalRequest->getStopBand();
unsigned int concurrentRows = std::min(pOriginalRequest->getConcurrentRows(),
stopRow.getActiveNumber() - startRow.getActiveNumber() + 1);
unsigned int concurrentBands = pOriginalRequest->getConcurrentBands();
VERIFY(requestedType == BSQ);
VERIFY(startBand == stopBand && concurrentBands == 1);
VERIFY(mpRaster != NULL);
const RasterDataDescriptor* pDd = dynamic_cast<const RasterDataDescriptor*>(mpRaster->getDataDescriptor());
VERIFY(pDd != NULL);
InterleaveFormatType interleave = pDd->getInterleaveFormat();
VERIFY(interleave == BIL || interleave == BIP);
unsigned int numRows = pDd->getRowCount();
unsigned int numCols = pDd->getColumnCount();
unsigned int numBands = pDd->getBandCount();
if (startRow.getActiveNumber() >= numRows || stopRow.getActiveNumber() >= numRows ||
startColumn.getActiveNumber() >= numCols || stopColumn.getActiveNumber() >= numCols ||
startBand.getActiveNumber() >= numBands || stopBand.getActiveNumber() >= numBands)
{
return NULL;
}
unsigned int cols = stopColumn.getActiveNumber() - startColumn.getActiveNumber() + 1;
std::auto_ptr<ConvertToBsqPage> pPage(new ConvertToBsqPage(concurrentRows, cols, mBytesPerElement));
unsigned char* pDst = reinterpret_cast<unsigned char*>(pPage->getRawData());
if (pDst == NULL)
{
return NULL;
}
FactoryResource<DataRequest> pRequest;
pRequest->setRows(startRow, stopRow);
pRequest->setColumns(startColumn, stopColumn, cols);
pRequest->setBands(startBand, startBand, 1);
DataAccessor da = mpRaster->getDataAccessor(pRequest.release());
if (interleave == BIP)
{
for (unsigned int row = 0; row < concurrentRows; ++row)
{
for (unsigned int col = 0; col < cols; ++col)
{
if (da.isValid() == false)
{
return NULL;
}
memcpy(pDst, da->getColumn(), mBytesPerElement);
pDst += mBytesPerElement;
da->nextColumn();
}
da->nextRow();
}
}
else if (interleave == BIL)
{
for (unsigned int row = 0; row < concurrentRows; ++row)
{
if (da.isValid() == false)
{
return NULL;
}
memcpy(pDst, da->getRow(), mBytesPerElement * cols);
pDst += mBytesPerElement * cols;
da->nextRow();
}
}
return pPage.release();
}
示例15: execute
bool HIGHPASS::execute(PlugInArgList* pInArgList, PlugInArgList* pOutArgList)
{
StepResource pStep("Tutorial 5", "app", "219F1882-A59F-4835-BE2A-E83C0C8111EB");
if (pInArgList == NULL || pOutArgList == NULL)
{
return false;
}
Progress* pProgress = pInArgList->getPlugInArgValue<Progress>(Executable::ProgressArg());
RasterElement* pCube = pInArgList->getPlugInArgValue<RasterElement>(Executable::DataElementArg());
if (pCube == NULL)
{
std::string msg = "A raster cube must be specified.";
pStep->finalize(Message::Failure, msg);
if (pProgress != NULL)
{
pProgress->updateProgress(msg, 0, ERRORS);
}
return false;
}
RasterDataDescriptor* pDesc = static_cast<RasterDataDescriptor*>(pCube->getDataDescriptor());
VERIFY(pDesc != NULL);
FactoryResource<DataRequest> pRequest;
pRequest->setInterleaveFormat(BSQ);
DataAccessor pSrcAcc = pCube->getDataAccessor(pRequest.release());
ModelResource<RasterElement> pResultCube(RasterUtilities::createRasterElement(pCube->getName() +
"DResult", pDesc->getRowCount(), pDesc->getColumnCount(), pDesc->getDataType()));
if (pResultCube.get() == NULL)
{
std::string msg = "A raster cube could not be created.";
pStep->finalize(Message::Failure, msg);
if (pProgress != NULL)
{
pProgress->updateProgress(msg, 0, ERRORS);
}
return false;
}
FactoryResource<DataRequest> pResultRequest;
pResultRequest->setWritable(true);
DataAccessor pDestAcc = pResultCube->getDataAccessor(pResultRequest.release());
int rowSize= pDesc->getRowCount();
int colSize = pDesc->getColumnCount();
int zero=0;
int prevCol = 0;
int prevRow = 0;
int nextCol = 0;
int nextRow = 0;
int prevCol1 = 0;
int prevRow1= 0;
int nextCol1= 0;
int nextRow1= 0;
for (unsigned int row = 0; row < pDesc->getRowCount(); ++row)
{
if (pProgress != NULL)
{
pProgress->updateProgress("Calculating result", row * 100 / pDesc->getRowCount(), NORMAL);
}
if (isAborted())
{
std::string msg = getName() + " has been aborted.";
pStep->finalize(Message::Abort, msg);
if (pProgress != NULL)
{
pProgress->updateProgress(msg, 0, ABORT);
}
return false;
}
if (!pDestAcc.isValid())
{
std::string msg = "Unable to access the cube data.";
pStep->finalize(Message::Failure, msg);
if (pProgress != NULL)
{
pProgress->updateProgress(msg, 0, ERRORS);
}
return false;
}
for (unsigned int col = 0; col < pDesc->getColumnCount(); ++col)
{
double value=edgeDetection7(pSrcAcc, row, col, pDesc->getRowCount(), pDesc->getColumnCount());
switchOnEncoding(pDesc->getDataType(), conversion, pDestAcc->getColumn(), value);
pDestAcc->nextColumn();
}
pDestAcc->nextRow();
}
if (!isBatch())
{
Service<DesktopServices> pDesktop;
SpatialDataWindow* pWindow = static_cast<SpatialDataWindow*>(pDesktop->createWindow(pResultCube->getName(),
SPATIAL_DATA_WINDOW));
//.........这里部分代码省略.........