32 #ifndef RingExtractor_INCLUDE_ONCE 33 #define RingExtractor_INCLUDE_ONCE 73 std::vector< ref<Atom> > current_path;
80 if ( !atom->
visited() || current_path.empty())
83 current_path.push_back(atom);
86 current_path.pop_back();
93 for(
size_t i = current_path.size()-1; i--; )
95 if ( current_path[i] == atom )
97 std::vector< ref<Atom> > cycle;
98 for(; i<current_path.size(); ++i)
99 cycle.push_back( current_path[i] );
100 if (cycle.size() > 2)
110 std::vector< std::vector< ref<Atom> > > kept_cycles;
111 for(
unsigned icycle=0; icycle<
molecule()->
cycles().size(); ++icycle)
114 for(
unsigned iatom=0; iatom<
molecule()->
cycle(icycle).size(); ++iatom)
128 kept_cycles.push_back(
molecule()->cycle(icycle));
135 for(
unsigned icycle=0; icycle<
molecule()->
cycles().size(); ++icycle)
138 for(
unsigned iatom=0; iatom<cycle.size()-1; ++iatom)
140 Atom* atom = cycle[iatom].get();
141 for(
unsigned j=iatom+1; j<cycle.size(); ++j)
145 Atom* tmp = cycle[iatom+1].get();
146 cycle[iatom+1] = cycle[j];
157 std::vector< std::vector< ref<Atom> > > kept_cycles;
158 for(
unsigned icycle=0; icycle<
molecule()->
cycles().size(); ++icycle)
161 for(
unsigned iatom=0; iatom<
molecule()->
cycle(icycle).size(); ++iatom)
166 for(
unsigned iatom=0; iatom<
molecule()->
cycle(icycle).size(); ++iatom)
173 normal +=
cross(v1, v2);
178 for(
unsigned iatom=0; iatom<
molecule()->
cycle(icycle).size(); ++iatom)
181 float dist =
dot(normal, v1);
182 if (fabs(dist)>epsilon)
188 if (ok &&
molecule()->cycle(icycle).size())
189 kept_cycles.push_back(
molecule()->cycle(icycle));
196 for(
unsigned icycle=0; icycle<
molecule()->
cycles().size(); ++icycle)
199 std::vector< std::vector< ref<Atom> > >::iterator new_end = std::unique(
molecule()->cycles().begin(),
molecule()->cycles().end());
200 std::vector< std::vector< ref<Atom> > > unique_cycles;
201 for(std::vector< std::vector<
ref<Atom> > >::iterator it =
molecule()->cycles().begin(); it != new_end; ++it)
202 unique_cycles.push_back(*it);
208 std::vector< std::vector< ref<Atom> > > sub_cycles;
210 std::map<Atom*, bool> my_atom;
214 for(
unsigned icycle=0; icycle<
molecule()->
cycles().size(); ++icycle)
220 bool is_sup_cycle =
false;
225 unsigned shared_atoms = 0;
227 shared_atoms += my_atom[
molecule()->
cycles()[j][k].get() ] ? 1 : 0;
228 if ( shared_atoms ==
molecule()->cycles()[j].size() )
235 sub_cycles.push_back(
molecule()->cycles()[icycle] );
The Molecule class is used to manage and render 3D molecular structures.
const Vector3 & normalize(T_Scalar *len=NULL)
Vector3< float > fvec3
A 3 components vector with float precision.
const std::vector< ref< Atom > > & cycle(int i) const
Returns the i-th cycle.
const Atom * atom(int index) const
vec3 center() const
Returns the center of the AABB.
const std::vector< std::vector< ref< Atom > > > & cycles() const
Returns the list of cycles.
const std::vector< ref< Atom > > & atoms() const
fvec3 cross(const fvec3 &v1, const fvec3 &v2)
bool isAtomAdjacent(Atom *atom) const
const fvec3 & coordinates() const
Visualization Library main namespace.
float dot(float a, float b)
void setVisited(bool visited)
EBondType bondType() const
The AABB class implements an axis-aligned bounding box using vl::real precision.
Implements the OpenGL Shading Language convenience functions for scalar and vector operations...
const std::vector< Atom *> & adjacentAtoms() const
const Bond * bond(int index) const
void computeAtomAdjacency()
The Bond class represents a bond to be used with the Molecule class.
The ref<> class is used to reference-count an Object.
The Atom class represents an atom to be used with the Molecule class.