1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
|
#pragma once
#include <cstddef>
#include <vector>
struct AtomInfoType;
struct ObjectMolecule;
/**
* Ring finder
*/
class AbstractRingFinder
{
ObjectMolecule* m_obj = nullptr;
std::vector<int> m_indices;
void recursion(int atm, int depth);
protected:
AbstractRingFinder() = delete;
AbstractRingFinder(unsigned maxringsize)
: m_indices(maxringsize)
{
}
/**
* Optional object preparation.
*/
virtual void prepareObject(ObjectMolecule* obj) {}
/**
* Optional atom filter.
* @return True to exclude an atom, false to include it.
*/
virtual bool atomIsExcluded(const AtomInfoType&) const { return false; }
/**
* Is called when a ring is found.
*
* @param obj Molecule object
* @param indices Ring atom indices
* @param size Ring size
*/
virtual void onRingFound(
ObjectMolecule* obj, const int* indices, size_t size) = 0;
public:
/*
* Does a depth-first search for all paths of length in
* range [3, maxringsize], which lead back to `atm` and
* don't visit any atom twice.
*/
void apply(ObjectMolecule* obj, int atm);
};
|