--- trunk/src/applications/staticProps/NanoVolume.cpp 2007/11/22 16:39:45 1188 +++ trunk/src/applications/staticProps/NanoVolume.cpp 2008/10/15 18:26:01 1304 @@ -45,12 +45,13 @@ * * Created by Charles F. Vardeman II on 14 Dec 2006. * @author Charles F. Vardeman II - * @version $Id: NanoVolume.cpp,v 1.2 2007-11-22 16:39:44 chuckv Exp $ + * @version $Id: NanoVolume.cpp,v 1.8 2008-10-15 18:26:01 chuckv Exp $ * */ #include "applications/staticProps/NanoVolume.hpp" #include "math/ConvexHull.hpp" +//#include "math/AlphaShape.hpp" #include "utils/simError.h" #include "io/DumpReader.hpp" #include "primitives/Molecule.hpp" @@ -62,7 +63,7 @@ NanoVolume::NanoVolume(SimInfo* info, const std::string& filename, const std::string& sele) : StaticAnalyser(info, filename), selectionScript_(sele), evaluator_(info), seleMan_(info) { - setOutputName(getPrefix(filename) + ".off"); + setOutputName(getPrefix(filename) + ".avol"); evaluator_.loadScriptString(sele); if (!evaluator_.isDynamic()) { @@ -73,7 +74,7 @@ void NanoVolume::process() { } void NanoVolume::process() { - +#if defined(HAVE_CGAL) || defined(HAVE_QHULL) Molecule* mol; Atom* atom; RigidBody* rb; @@ -85,13 +86,19 @@ void NanoVolume::process() { Vector3d vec; int i,j; - ConvexHull* hull = new ConvexHull(); +#ifdef HAVE_QHULL + ConvexHull* thishull = new ConvexHull(); +#endif +#ifdef HAVE_CGAL + // AlphaShape* hull = new AlphaShape(); + ConvexHull* thishull = new ConvexHull(); +#endif DumpReader reader(info_, dumpFilename_); int nFrames = reader.getNFrames(); frameCounter_ = 0; - pos_.reserve(info_->getNGlobalAtoms()); + theAtoms_.reserve(info_->getNGlobalAtoms()); for (int istep = 0; istep < nFrames; istep += step_) { reader.readFrame(istep); @@ -99,7 +106,7 @@ void NanoVolume::process() { currentSnapshot_ = info_->getSnapshotManager()->getCurrentSnapshot(); // Clear pos vector between each frame. - pos_.clear(); + theAtoms_.clear(); if (evaluator_.isDynamic()) { seleMan_.setSelectionSet(evaluator_.evaluate()); @@ -118,16 +125,43 @@ void NanoVolume::process() { // outer loop is over the selected StuntDoubles: for (sd = seleMan_.beginSelected(i); sd != NULL; - sd = seleMan_.nextSelected(i)) { + sd = seleMan_.nextSelected(i)) { - pos_.push_back(sd->getPos()); + theAtoms_.push_back(sd); myIndex = sd->getGlobalIndex(); } + + /* + for (mol = info_->beginMolecule(mi); mol != NULL; + mol = info_->nextMolecule(mi)) { + for (atom = mol->beginAtom(ai); atom != NULL; + atom = mol->nextAtom(ai)) { + theAtoms_.push_back(atom); + } + } + */ // Generate convex hull for this frame. - hull->genHull(pos_); - totalVolume_ += hull->getVolume(); + thishull->computeHull(theAtoms_); + // totalVolume_ += hull->getVolume(); } - RealType avgVolume = totalVolume_/(RealType) frameCounter_; - std::cout << avgVolume << std::endl; + //RealType avgVolume = totalVolume_/(RealType) frameCounter_; + //std::cout.precision(7); + //std::cout << avgVolume << std::endl; +/* + std::ofstream osq(getOutputFileName().c_str()); + osq.precision(7); + if (osq.is_open()){ + osq << avgVolume << std::endl; + + } + osq.close(); +*/ +#else + sprintf(painCave.errMsg, "NanoVolume: Neither CGAL nor qhull support was compiled in!\n"); + painCave.isFatal = 1; + simError(); + +#endif + }