本文整理汇总了C++中Spectrum::clear方法的典型用法代码示例。如果您正苦于以下问题:C++ Spectrum::clear方法的具体用法?C++ Spectrum::clear怎么用?C++ Spectrum::clear使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Spectrum
的用法示例。
在下文中一共展示了Spectrum::clear方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getIrradiance
/**
* Get the irradiance at the given point.
* @param origin : the point where we want to know the irradiance.
* @param irradiance : the computed irradiance will be placed into this spectrum.
*/
inline void MultispectralPhotonMap::getIrradiance(const Point& origin, Spectrum& irradiance)
{
//Get the nearest photon
MultispectralPhoton* irradianceValue = _tree.getNearestElement(origin);
if(irradianceValue==NULL)
{
irradiance.clear();
return;
}
//Set the irradiance
for(unsigned int l=0; l<GlobalSpectrum::nbWaveLengths(); l++)
irradiance[l] = irradianceValue->radiance[l];
}
示例2: Medium
/**
* Default constructor
*/
inline Medium::Medium()
: isOpaque(false), hasDispersion(false), hasPhotonDispersion(false), useLambertianModel(false), useFresnelModel(false), useKubelkaMunkModel(false)
{
r.clear();
t.clear();
n.clear();
k.clear();
S.clear();
K.clear();
}
示例3: handleInfiniteLights
Spectrum Integrator::handleInfiniteLights(const Ray& in, const ShaderClosure& sc, RenderThreadContext* context, float& full_pdf)
{
Spectrum full_weight;
full_pdf = 0;
RandomSampler sampler(context->random());
for(IInfiniteLight* e : context->renderer()->scene()->infiniteLights())
{
Spectrum semi_weight;
float semi_pdf = 0;
for(uint32 i = 0;
i < context->renderer()->settings().maxLightSamples() && !std::isinf(semi_pdf);
++i)
{
float pdf;
PM::vec3 rnd = sampler.generate3D(i);
PM::vec3 dir = e->sample(sc, rnd, pdf);
if(pdf <= PM_EPSILON)
continue;
Spectrum weight;
const float NdotL = PM::pm_Max(0.0f, PM::pm_Dot3D(dir, sc.N));
if (NdotL > PM_EPSILON)
{
RenderEntity* entity;
Ray ray = in.next(sc.P, dir);
ray.setFlags(ray.flags() | RF_Light);
weight = handleSpecularPath(ray, sc, context, entity);
if (!entity)
weight *= sc.Material->eval(sc, dir, NdotL) * e->apply(dir) * NdotL;
else
weight.clear();
}
MSI::power(semi_weight, semi_pdf, weight, pdf);
}
MSI::balance(full_weight, full_pdf, semi_weight, std::isinf(semi_pdf) ? 1 : semi_pdf);
}
return full_weight;
}
示例4: DeNoiseD
bool CNoiseReduction::DeNoiseD(Spectrum& sp){
Spectrum tmpSpec;
vector<int> v;
sp.clear();
if(pos==0){
if(cs.scan.iLower>0) {
if(!NewScanAverage(sp,cs.inFile,(int)(cs.boxcar/2),0.1f,cs.scan.iLower)) return false;
} else {
NewScanAverage(sp,cs.inFile,(int)(cs.boxcar/2),0.1f);
}
pos=1;
} else {
NewScanAverage(sp,NULL,(int)(cs.boxcar/2),0.1f);
}
if(sp.getScanNumber()==0) return false;
FirstDerivativePeaks(sp,1);
return true;
}
示例5: NewScanAverage
bool CNoiseReduction::NewScanAverage(Spectrum& sp, char* file, int width, float cutoff, int scanNum){
Spectrum ts;
vector<int> vPos;
int i;
int j;
int k;
int m;
int widthCount=0;
int numScans=1;
double dif;
double prec;
double dt;
double c;
bool bLeft=true;
int posLeft;
int posRight;
int index;
char cFilter1[256];
//char cFilter2[256];
//double slope;
//double intercept;
sp.clear();
Spectrum* specs;
specs = new Spectrum[width*2+1];
//if file is not null, create new buffer
if(file!=NULL){
strcpy(lastFile,file);
bs.clear();
if(scanNum>0) r->readFile(file,ts,scanNum);
else r->readFile(file,ts);
if(ts.getScanNumber()==0) {
delete [] specs;
return false;
}
bs.push_back(ts);
specs[0]=bs[0];
c=CParam(specs[0],3);
posA=0;
} else {
posA++;
if(posA>=(int)bs.size()) { //end of buffer, no more data
delete [] specs;
return false;
}
specs[0]=bs[posA];
c=CParam(specs[0],3);
}
specs[0].getRawFilter(cFilter1,256);
posLeft=posA;
posRight=posA;
while(widthCount<(width*2)){
index=-1;
//Alternate looking left and right
if(bLeft){
bLeft=false;
widthCount++;
while(true){
posLeft--;
if(posLeft<0) { //buffer is too short on left, add spectra
i=bs[0].getScanNumber();
while(true){
i--;
if(i==0) break;
r->readFile(lastFile,ts,i);
if(ts.getScanNumber()==0) continue;
else break;
}
if(i==0) break;
bs.push_front(ts);
posA++;
posRight++;
posLeft=0;
//ts.getRawFilter(cFilter2,256);
if(ts.getMsLevel()==cs.msLevel) {
index=posLeft;
break;
}
} else {
//bs[posLeft].getRawFilter(cFilter2,256);
if(bs[posLeft].getMsLevel()==cs.msLevel) {
index=posLeft;
break;
}
}
}
} else {
bLeft=true;
//.........这里部分代码省略.........
示例6: ScanAverage
bool CNoiseReduction::ScanAverage(Spectrum& sp, char* file, int width, float cutoff){
Spectrum ts;
Spectrum ps=sp;
MSReader r;
int i;
int j;
int k;
int widthCount=0;
int numScans=1;
double dif;
double prec;
double dt;
double c=CParam(ps,3);
bool bLeft=true;
int posLeft=ps.getScanNumber()-1;
int posRight=ps.getScanNumber()+1;
char cFilter1[256];
char cFilter2[256];
ps.getRawFilter(cFilter1,256);
while(widthCount<(width*2)){
//Alternate looking left and right
if(bLeft){
bLeft=false;
widthCount++;
while(posLeft>0){
r.readFile(file,ts,posLeft);
if(ts.getScanNumber()==0) break;
ts.getRawFilter(cFilter2,256);
if(strcmp(cFilter1,cFilter2)==0) break;
posLeft--;
}
} else {
bLeft=true;
widthCount++;
while(true){
r.readFile(file,ts,posRight);
if(ts.getScanNumber()==0) break;
ts.getRawFilter(cFilter2,256);
if(strcmp(cFilter1,cFilter2)==0) break;
posRight++;
}
}
if(ts.getScanNumber()==0) continue;
numScans++;
//Match peaks between pivot scan and temp scan
k=0;
for(i=0;i<ps.size();i++){
dif=100000.0;
prec = c * ps.at(i).mz * ps.at(i).mz / 2;
for(j=k;j<ts.size();j++){
dt=fabs(ps.at(i).mz-ts.at(j).mz);
if(dt<=dif) {
if(dt<prec) {
ps.at(i).intensity+=ts.at(j).intensity;
ts.at(j).mz=-1.0;
k=j+1;
break;
}
dif=dt;
} else {
k=j-1;
break;
}
}
}
//Add unmatched peaks from temp scan
for(i=0;i<ts.size();i++){
if(ts.at(i).mz>-1.0) ps.add(ts.at(i));
}
//Sort pivot scan peaks for fast traversal against next temp scan
ps.sortMZ();
}
//Average points and apply cutoff
sp.clear();
for(i=0;i<ps.size();i++) {
ps.at(i).intensity/=numScans;
if(ps.at(i).intensity>=cutoff) sp.add(ps.at(i));
}
sp.setScanNumber(ps.getScanNumber());
sp.setScanNumber(ps.getScanNumber(true),true);
sp.setRTime(ps.getRTime());
return true;
}
示例7: DeNoise
bool CNoiseReduction::DeNoise(Spectrum& sp){
double ppm;
int i,j,k;
int index;
int matchCount;
char cFilter1[256];
char cFilter2[256];
Spectrum tmpSpec;
vector<int> v;
sp.clear();
if(pos==0){
if((cs.scan.iLower>0)) {
k=cs.scan.iLower;
r->readFile(&cs.inFile[0],tmpSpec,cs.scan.iLower);
} else {
r->readFile(&cs.inFile[0],tmpSpec);
k=tmpSpec.getScanNumber();
}
if(tmpSpec.getScanNumber()==0) return false;
tmpSpec.getRawFilter(cFilter1,256);
//Gather left side of scan
i=1;
j=0;
while( k-i > 0){
r->readFile(&cs.inFile[0],tmpSpec,cs.scan.iLower-i);
if(tmpSpec.getScanNumber()==0) {
i++;
continue;
}
tmpSpec.getRawFilter(cFilter2,256);
//Assume High resolution data at all times
if(!cs.centroid) {
FirstDerivativePeaks(tmpSpec,1);
tmpSpec.setRawFilter(cFilter2);
}
s.push_front(tmpSpec);
if(strcmp(cFilter1,cFilter2)==0){
j++;
if(j==(int)(cs.boxcar/2)) break;
}
i++;
}
//cout << "Done left " << s.size() << " " << cs.rawAvgWidth << endl;
//Get our position again
r->readFile(&cs.inFile[0],tmpSpec,k);
//Assume High resolution data at all times
if(!cs.centroid) {
FirstDerivativePeaks(tmpSpec,1);
tmpSpec.setRawFilter(cFilter1);
}
//Add first target scan
s.push_back(tmpSpec);
pos=s.size()-1;
//Add right side of scan
i=1;
j=0;
while(true){
r->readFile(NULL,tmpSpec);
if(tmpSpec.getScanNumber()==0) break;
tmpSpec.getRawFilter(cFilter2,256);
//Assume High resolution data at all times
if(!cs.centroid) {
FirstDerivativePeaks(tmpSpec,1);
tmpSpec.setRawFilter(cFilter2);
}
s.push_back(tmpSpec);
//cout << tmpSpec.getScanNumber() << " " << cFilter1 << " xx " << cFilter2 << endl;
if(strcmp(cFilter1,cFilter2)==0){
j++;
if(j==(int)(cs.boxcar/2)) break;
}
i++;
}
}
//return false if we reached the end
if(pos>=(int)s.size()) return false;
//Because Deque may have mixed spectra, create list of Deque indexes to compare
//Shrink Deque on the left if some spectra are not needed
//Expand Deque to the right if needed and possible
//cout << "Checking scan " << s[pos].getScanNumber() << endl;
v.clear();
s[pos].getRawFilter(cFilter1,256);
//.........这里部分代码省略.........
示例8: NewScanAveragePlusDeNoise
bool CNoiseReduction::NewScanAveragePlusDeNoise(Spectrum& sp, char* file, int width, float cutoff, int scanNum){
Spectrum ts;
vector<int> vPos;
int i;
int j;
int k;
int m;
int widthCount=0;
int numScans=1;
int match;
double dif;
double prec;
double dt;
double c;
bool bLeft=true;
int posLeft;
int posRight;
int index;
char cFilter1[256];
char cFilter2[256];
sp.clear();
Spectrum* specs;
specs = new Spectrum[width*2+1];
//if file is not null, create new buffer
if(file!=NULL){
strcpy(lastFile,file);
bs.clear();
if(scanNum>0) r->readFile(file,ts,scanNum);
else r->readFile(file,ts);
if(ts.getScanNumber()==0) {
delete [] specs;
return false;
}
bs.push_back(ts);
specs[0]=bs[0];
c=CParam(specs[0],3);
posA=0;
} else {
posA++;
if(posA>=(int)bs.size()) { //end of buffer, no more data
delete [] specs;
return false;
}
specs[0]=bs[posA];
c=CParam(specs[0],3);
}
//set our pivot spectrum
specs[0].getRawFilter(cFilter1,256);
posLeft=posA;
posRight=posA;
while(widthCount<(width*2)){
index=-1;
//Alternate looking left and right
if(bLeft){
bLeft=false;
widthCount++;
while(true){
posLeft--;
if(posLeft<0) { //buffer is too short on left, add spectra
i=bs[0].getScanNumber();
while(true){
i--;
if(i==0) break;
r->readFile(lastFile,ts,i);
if(ts.getScanNumber()==0) continue;
else break;
}
if(i==0) break;
bs.push_front(ts);
posA++;
posRight++;
posLeft=0;
ts.getRawFilter(cFilter2,256);
if(strcmp(cFilter1,cFilter2)==0) {
index=posLeft;
break;
}
} else {
bs[posLeft].getRawFilter(cFilter2,256);
if(strcmp(cFilter1,cFilter2)==0) {
index=posLeft;
break;
}
}
}
} else {
bLeft=true;
//.........这里部分代码省略.........
示例9: ScanAveragePlusDeNoise
bool CNoiseReduction::ScanAveragePlusDeNoise(Spectrum& sp, char* file, int width, float cutoff, int scanNum){
Spectrum ts;
Spectrum ps;
//MSReader r;
vector<int> v;
vector<int> vPos;
int i;
int j;
int k;
int widthCount=0;
int numScans=1;
int match;
double dif;
double prec;
double dt;
double c;
bool bLeft=true;
int posLeft=ps.getScanNumber()-1;
int posRight=ps.getScanNumber()+1;
int index;
char cFilter1[256];
//char cFilter2[256];
sp.clear();
//if file is not null, create new buffer
if(file!=NULL){
strcpy(lastFile,file);
bs.clear();
if(scanNum>0) r->readFile(file,ts,scanNum);
else r->readFile(file,ts);
if(ts.getScanNumber()==0) return false;
bs.push_back(ts);
ps=bs[0];
c=CParam(ps,3);
posA=0;
} else {
posA++;
//cout << "ER: " << posA << " " << bs.size() << endl;
if(posA>=(int)bs.size()) return false; //end of buffer, no more data
ps=bs[posA];
c=CParam(ps,3);
}
//set our pivot spectrum
//ps=bs[posA];
ps.getRawFilter(cFilter1,256);
//cout << "Averaging: " << ps.getScanNumber() << endl;
posLeft=posA;
posRight=posA;
while(widthCount<(width*2)){
index=-1;
//Alternate looking left and right
if(bLeft){
bLeft=false;
widthCount++;
while(true){
posLeft--;
//cout << posLeft << endl;
if(posLeft<0) { //buffer is too short on left, add spectra
i=bs[0].getScanNumber();
while(true){
i--;
//cout << "I: " << i << endl;
if(i==0) break;
r->readFile(lastFile,ts,i);
if(ts.getScanNumber()==0) continue;
else break;
}
if(i==0) break;
bs.push_front(ts);
for(i=0;i<(int)v.size();i++)v[i]++;
posA++;
posRight++;
posLeft=0;
//ts.getRawFilter(cFilter2,256);
if(ts.getMsLevel()==cs.msLevel) {
index=posLeft;
break;
}
} else {
//bs[posLeft].getRawFilter(cFilter2,256);
if(bs[posLeft].getMsLevel()==cs.msLevel) {
index=posLeft;
break;
}
}
}
} else {
bLeft=true;
widthCount++;
//.........这里部分代码省略.........