1 | /*
|
---|
2 | * Project: MoleCuilder
|
---|
3 | * Description: creates and alters molecular systems
|
---|
4 | * Copyright (C) 2010-2012 University of Bonn. All rights reserved.
|
---|
5 | * Please see the LICENSE file or "Copyright notice" in builder.cpp for details.
|
---|
6 | */
|
---|
7 |
|
---|
8 | /*
|
---|
9 | * AtomOfMoleculeSelectionDescriptor.cpp
|
---|
10 | *
|
---|
11 | * Created on: Dec 11, 2010
|
---|
12 | * Author: heber
|
---|
13 | */
|
---|
14 |
|
---|
15 | // include config.h
|
---|
16 | #ifdef HAVE_CONFIG_H
|
---|
17 | #include <config.h>
|
---|
18 | #endif
|
---|
19 |
|
---|
20 | #include "CodePatterns/MemDebug.hpp"
|
---|
21 |
|
---|
22 | #include "Descriptors/AtomOfMoleculeSelectionDescriptor.hpp"
|
---|
23 | #include "Descriptors/AtomOfMoleculeSelectionDescriptor_impl.hpp"
|
---|
24 |
|
---|
25 | #include "molecule.hpp"
|
---|
26 |
|
---|
27 | #include "Helpers/helpers.hpp"
|
---|
28 |
|
---|
29 |
|
---|
30 | AtomOfMoleculeSelectionDescriptor_impl::AtomOfMoleculeSelectionDescriptor_impl(){}
|
---|
31 |
|
---|
32 | AtomOfMoleculeSelectionDescriptor_impl::~AtomOfMoleculeSelectionDescriptor_impl(){}
|
---|
33 |
|
---|
34 | bool AtomOfMoleculeSelectionDescriptor_impl::predicate(std::pair<atomId_t,atom*> atom){
|
---|
35 | return World::getInstance().isSelected(atom.second->getMolecule());
|
---|
36 | }
|
---|
37 |
|
---|
38 | atom* AtomOfMoleculeSelectionDescriptor_impl::find(){
|
---|
39 | World::MoleculeSet &set = getSelectedMolecules();
|
---|
40 | for (World::MoleculeSet::internal_iterator iter = set.begin_internal();
|
---|
41 | iter != set.end_internal();
|
---|
42 | ++iter) {
|
---|
43 | if (iter->second->begin() != iter->second->end())
|
---|
44 | return *(iter->second->begin());
|
---|
45 | }
|
---|
46 | return 0;
|
---|
47 | }
|
---|
48 |
|
---|
49 | std::vector<atom*> AtomOfMoleculeSelectionDescriptor_impl::findAll(){
|
---|
50 | std::vector<atom*> res;
|
---|
51 | World::MoleculeSet &set = getSelectedMolecules();
|
---|
52 | for (World::MoleculeSet::internal_iterator iter = set.begin_internal();
|
---|
53 | iter != set.end_internal();
|
---|
54 | ++iter) {
|
---|
55 | std::copy(iter->second->begin(), iter->second->end(), res.begin());
|
---|
56 | }
|
---|
57 | return res;
|
---|
58 | }
|
---|
59 |
|
---|
60 | World::MoleculeSet& AtomOfMoleculeSelectionDescriptor_impl::getSelectedMolecules(){
|
---|
61 | return World::getInstance().selectedMolecules;
|
---|
62 | }
|
---|
63 |
|
---|
64 | AtomDescriptor AtomsByMoleculeSelection(){
|
---|
65 | return AtomDescriptor(AtomDescriptor::impl_ptr(new AtomOfMoleculeSelectionDescriptor_impl()));
|
---|
66 | }
|
---|