/*
* Project: MoleCuilder
* Description: creates and alters molecular systems
* Copyright (C) 2013 Frederik Heber. All rights reserved.
* Please see the COPYING file or "Copyright notice" in builder.cpp for details.
*
*
* This file is part of MoleCuilder.
*
* MoleCuilder is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* MoleCuilder is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with MoleCuilder. If not, see .
*/
/*
* CoordinatorFactory.cpp
*
* Created on: 03.09.2013
* Author: heber
*/
// include config.h
#ifdef HAVE_CONFIG_H
#include
#endif
#include "CodePatterns/MemDebug.hpp"
#include "CoordinatorFactory.hpp"
#include "Fragmentation/Homology/HomologyGraph.hpp"
#include "Fragmentation/Homology/FragmentNode.hpp"
#include "CodePatterns/Assert.hpp"
#include "TwoBody_Length.hpp"
#include "ThreeBody_Angle.hpp"
#include "FourBody_ImproperAngle.hpp"
#include "FourBody_TorsionAngle.hpp"
CoordinatorFactory::CoordinatorFactory()
{}
CoordinatorFactory::~CoordinatorFactory()
{}
Coordinator::ptr CoordinatorFactory::create(HomologyGraph &graph) const
{
// for the moment we always return the same coordinator type
Coordinator::ptr coordinator;
const HomologyGraph::nodes_t &nodes = graph.getNodes();
switch (nodes.size()) {
case 2:
coordinator.reset(new TwoBody_Length());
break;
case 3:
coordinator.reset(new ThreeBody_Angle());
break;
case 4:
{
// TODO: Here, we have to actually look at the graph and
// decide whether we have a torsion or improper configuration
// torsion is a single chain
// improper is all connected to one central atom, i.e. there
// is a FragmentNode with connected_edges == 3
bool tripleEdge = false;
for (HomologyGraph::nodes_t::const_iterator nodeiter = nodes.begin();
nodeiter != nodes.end();
++nodeiter) {
if (nodeiter->first.getConnectedEdges() == 3)
tripleEdge = true;
}
if (!tripleEdge)
coordinator.reset(new FourBody_TorsionAngle());
else
coordinator.reset(new FourBody_ImproperAngle());
break;
}
default:
ASSERT( 0, "CoordinatorFactory::create() - I don't have a coordinator for "+
toString(graph)+".");
break;
}
return coordinator;
}