/* * Project: MoleCuilder * Description: creates and alters molecular systems * Copyright (C) 2010-2012 University of Bonn. All rights reserved. * * * 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 . */ /* * AtomSelectionDescriptor.cpp * * Created on: Jul 16, 2010 * Author: crueger */ // include config.h #ifdef HAVE_CONFIG_H #include #endif #include "CodePatterns/MemDebug.hpp" #include "Descriptors/AtomSelectionDescriptor.hpp" #include "Descriptors/AtomSelectionDescriptor_impl.hpp" #include "Helpers/helpers.hpp" AtomSelectionDescriptor_impl::AtomSelectionDescriptor_impl(){} AtomSelectionDescriptor_impl::~AtomSelectionDescriptor_impl(){} bool AtomSelectionDescriptor_impl::predicate(std::pair atom){ return getSelectedAtoms().count(atom.first); } atom* AtomSelectionDescriptor_impl::find(){ World::AtomSet &set = getSelectedAtoms(); World::AtomSet::internal_iterator begin = set.begin_internal(); return (begin!=set.end_internal())?(begin->second):0; } std::vector AtomSelectionDescriptor_impl::findAll(){ std::vector res; World::AtomSet &set = getSelectedAtoms(); transform(set.begin_internal(), set.end_internal(), back_inserter(res), _take::get); return res; } World::AtomSet& AtomSelectionDescriptor_impl::getSelectedAtoms(){ return World::getInstance().selectedAtoms; } AtomDescriptor AtomsBySelection(){ return AtomDescriptor(AtomDescriptor::impl_ptr(new AtomSelectionDescriptor_impl())); }