48#include "selection/HullFinder.hpp"
50#include "math/AlphaHull.hpp"
51#include "math/ConvexHull.hpp"
56 HullFinder::HullFinder(
SimInfo* info) : info_(info) {
57 nObjects_.push_back(info_->getNGlobalAtoms() +
58 info_->getNGlobalRigidBodies());
59 nObjects_.push_back(info_->getNGlobalBonds());
60 nObjects_.push_back(info_->getNGlobalBends());
61 nObjects_.push_back(info_->getNGlobalTorsions());
62 nObjects_.push_back(info_->getNGlobalInversions());
63 nObjects_.push_back(info_->getNGlobalMolecules());
65 stuntdoubles_.resize(nObjects_[STUNTDOUBLE]);
66 bonds_.resize(nObjects_[BOND]);
67 bends_.resize(nObjects_[BEND]);
68 torsions_.resize(nObjects_[TORSION]);
69 inversions_.resize(nObjects_[INVERSION]);
70 molecules_.resize(nObjects_[MOLECULE]);
72 SimInfo::MoleculeIterator mi;
73 Molecule::IntegrableObjectIterator ioi;
74 Molecule::AtomIterator ai;
75 Molecule::RigidBodyIterator rbIter;
76 Molecule::BondIterator bondIter;
77 Molecule::BendIterator bendIter;
78 Molecule::TorsionIterator torsionIter;
79 Molecule::InversionIterator inversionIter;
90 for (mol = info_->beginMolecule(mi); mol != NULL;
91 mol = info_->nextMolecule(mi)) {
92 molecules_[mol->getGlobalIndex()] = mol;
94 for (sd = mol->beginIntegrableObject(ioi); sd != NULL;
95 sd = mol->nextIntegrableObject(ioi)) {
96 localSites_.push_back(sd);
99 for (atom = mol->beginAtom(ai); atom != NULL; atom = mol->nextAtom(ai)) {
100 stuntdoubles_[atom->getGlobalIndex()] = atom;
102 for (rb = mol->beginRigidBody(rbIter); rb != NULL;
103 rb = mol->nextRigidBody(rbIter)) {
104 stuntdoubles_[rb->getGlobalIndex()] = rb;
106 for (bond = mol->beginBond(bondIter); bond != NULL;
107 bond = mol->nextBond(bondIter)) {
108 bonds_[bond->getGlobalIndex()] = bond;
110 for (bend = mol->beginBend(bendIter); bend != NULL;
111 bend = mol->nextBend(bendIter)) {
112 bends_[bend->getGlobalIndex()] = bend;
114 for (torsion = mol->beginTorsion(torsionIter); torsion != NULL;
115 torsion = mol->nextTorsion(torsionIter)) {
116 torsions_[torsion->getGlobalIndex()] = torsion;
118 for (inversion = mol->beginInversion(inversionIter); inversion != NULL;
119 inversion = mol->nextInversion(inversionIter)) {
120 inversions_[inversion->getGlobalIndex()] = inversion;
124 surfaceMesh_ =
new ConvexHull();
128 AlphaHullFinder::AlphaHullFinder(SimInfo* info) : HullFinder(info) {
131 surfaceMesh_ =
new AlphaHull(0.0);
135 void AlphaHullFinder::setAlpha(RealType alpha) {
138 surfaceMesh_ =
new AlphaHull(alpha);
142 HullFinder::~HullFinder() {
148 SelectionSet HullFinder::findHull() {
return findHullImpl(
false); }
150 SelectionSet HullFinder::findHull(
int) {
return findHullImpl(
true); }
152 SelectionSet HullFinder::findHullImpl(
bool computeVolume) {
153 SelectionSet ssResult(nObjects_);
155 surfaceMesh_->computeHull(localSites_);
157 std::vector<Triangle> sMesh = surfaceMesh_->getMesh();
159 for (
auto& face : sMesh) {
160 std::vector<StuntDouble*> vertexSDs = face.getVertices();
161 for (
auto* vertex : vertexSDs) {
162 if (vertex != NULL) {
163 ssResult.bitsets_[
STUNTDOUBLE].setBitOn(vertex->getGlobalIndex());
167 surfaceArea_ = surfaceMesh_->getArea();
168 if (computeVolume) volume_ = surfaceMesh_->getVolume();
170 snprintf(painCave.errMsg, MAX_SIM_ERROR_MSG_LENGTH,
171 "HullFinder : Hull calculation is not possible without libqhull.\n"
172 "\tPlease rebuild OpenMD with qhull enabled.");
173 painCave.severity = OPENMD_ERROR;
174 painCave.isFatal = 1;
One of the heavy-weight classes of OpenMD, SimInfo maintains objects and variables relating to the cu...
This basic Periodic Table class was originally taken from the data.cpp file in OpenBabel.
@ STUNTDOUBLE
StuntDoubles (Atoms & RigidBodies).