45#include "visitors/RigidBodyVisitor.hpp"
53 void LipidHeadVisitor::visit(RigidBody* rb) {
58 std::shared_ptr<GenericData> data;
59 std::shared_ptr<AtomData> atomData;
60 std::shared_ptr<AtomInfo> atomInfo;
64 if (!canVisit(rb->getType()))
return;
66 globalID = rb->getGlobalIndex();
68 rotMatrix = rb->getA();
70 newVec = rotMatrix * u;
72 data = rb->getPropertyByName(
"ATOMDATA");
74 if (data !=
nullptr) {
75 atomData = std::dynamic_pointer_cast<AtomData>(data);
77 if (atomData ==
nullptr) {
78 std::cerr <<
"can not get Atom Data from " << rb->getType()
81 atomData = std::make_shared<AtomData>();
88 atomData = std::make_shared<AtomData>();
92 atomInfo = std::make_shared<AtomInfo>();
93 atomInfo->atomTypeName =
"X";
94 atomInfo->globalID = globalID;
95 atomInfo->pos[0] = pos[0];
96 atomInfo->pos[1] = pos[1];
97 atomInfo->pos[2] = pos[2];
98 atomInfo->vec[0] = newVec[0];
99 atomInfo->vec[1] = newVec[1];
100 atomInfo->vec[2] = newVec[2];
102 atomData->addAtomInfo(atomInfo);
105 atomData->setID(
"ATOMDATA");
106 rb->addProperty(atomData);
110 void LipidHeadVisitor::addLipidHeadName(
const std::string& name) {
111 lipidHeadName.insert(name);
114 bool LipidHeadVisitor::canVisit(
const std::string& name) {
115 return lipidHeadName.find(name) != lipidHeadName.end() ? true :
false;
118 const std::string LipidHeadVisitor::toString() {
121 std::set<std::string>::iterator i;
125 "------------------------------------------------------------------\n");
128 snprintf(buffer, 65535,
"Visitor name: %s\n", visitorName.c_str());
132 snprintf(buffer, 65535,
"lipidHeadName list contains below types:\n");
135 for (i = lipidHeadName.begin(); i != lipidHeadName.end(); ++i) {
136 snprintf(buffer, 65535,
"%s\t", i->c_str());
140 snprintf(buffer, 65535,
"\n");
145 "------------------------------------------------------------------\n");
151 void RBCOMVisitor::visit(RigidBody* rb) {
152 std::shared_ptr<AtomData> atomData;
153 std::shared_ptr<AtomInfo> atomInfo;
157 atomInfo = std::make_shared<AtomInfo>();
158 atomInfo->atomTypeName =
"X";
159 atomInfo->pos[0] = pos[0];
160 atomInfo->pos[1] = pos[1];
161 atomInfo->pos[2] = pos[2];
162 atomInfo->vec[0] = 0;
163 atomInfo->vec[1] = 0;
164 atomInfo->vec[2] = 0;
166 atomData = std::make_shared<AtomData>();
167 atomData->setID(
"ATOMDATA");
168 atomData->addAtomInfo(atomInfo);
170 rb->addProperty(atomData);
173 const std::string RBCOMVisitor::toString() {
179 "------------------------------------------------------------------\n");
182 snprintf(buffer, 65535,
"Visitor name: %s\n", visitorName.c_str());
186 snprintf(buffer, 65535,
187 "Visitor Description: add a pseudo atom at the center of "
194 "------------------------------------------------------------------\n");
This basic Periodic Table class was originally taken from the data.cpp file in OpenBabel.