--- trunk/src/applications/staticProps/RadialDistrFunc.cpp 2005/02/10 22:37:21 311 +++ trunk/src/applications/staticProps/RadialDistrFunc.cpp 2005/02/15 19:36:07 351 @@ -60,6 +60,19 @@ RadialDistrFunc:: RadialDistrFunc(SimInfo* info seleMan2_.setSelectionSet(evaluator2_.evaluate()); } + if (!evaluator1_.isDynamic() && !evaluator2_.isDynamic()) { + //if all selections are static, we can precompute the number of real pairs + + int nSelected1 = seleMan1_.getSelectionCount(); + int nSelected2 = seleMan2_.getSelectionCount(); + + BitSet bs = seleMan1_.getSelectionSet(); + bs &= seleMan2_.getSelectionSet(); + int nIntersect = bs.countBits(); + + nRealPairs_ = nSelected1 * nSelected2 - (nIntersect +1) * nIntersect/2; + } + } void RadialDistrFunc::process() { @@ -67,11 +80,13 @@ void RadialDistrFunc::process() { RigidBody* rb; SimInfo::MoleculeIterator mi; Molecule::RigidBodyIterator rbIter; + preProcess(); DumpReader reader(info_, dumpFilename_); int nFrames = reader.getNFrames(); - nProcessed_ = nFrames / step_ + 1; + nProcessed_ = nFrames / step_; + for (int i = 0; i < nFrames; i += step_) { reader.readFrame(i); currentSnapshot_ = info_->getSnapshotManager()->getCurrentSnapshot(); @@ -100,7 +115,9 @@ void RadialDistrFunc::process() { StuntDouble* sd2; int k; for (sd2 = seleMan2_.beginSelected(k); sd2 != NULL; sd2 = seleMan2_.nextSelected(k)) { - collectHistogram(sd1, sd2); + if (sd1 != sd2) { + collectHistogram(sd1, sd2); + } } } @@ -113,4 +130,21 @@ void RadialDistrFunc::process() { writeRdf(); } +int RadialDistrFunc::getNRealPairs() { + if (evaluator1_.isDynamic() || evaluator2_.isDynamic()) { + //if one of the selection is dynamic, need to recompute it + + int nSelected1 = seleMan1_.getSelectionCount(); + int nSelected2 = seleMan2_.getSelectionCount(); + + BitSet bs = seleMan1_.getSelectionSet(); + bs &= seleMan2_.getSelectionSet(); + int nIntersect = bs.countBits(); + + nRealPairs_ = nSelected1 * nSelected2 - (nIntersect +1) * nIntersect/2; + } + + return nRealPairs_; } + +}