engine/hand-generations/src/reactions/typical/high_bridge_to_two_bridges.cpp
#include "high_bridge_to_two_bridges.h"
const char HighBridgeToTwoBridges::__name[] = "high bridge incorporates in crystal lattice near another bridge";
double HighBridgeToTwoBridges::RATE()
{
static double value = getRate("HIGH_BRIDGE_STAND_TO_TWO_BRIDGES");
return value;
}
void HighBridgeToTwoBridges::find(HighBridge *target)
{
Atom *anchor = target->atom(1);
eachNeighbour(anchor, &Diamond::front_100, [target](Atom *neighbour) {
if (neighbour->is(5))
{
auto neighbourSpec = neighbour->specByRole<BridgeCRs>(5);
assert(neighbourSpec);
SpecificSpec *targets[2] = {
target,
neighbourSpec
};
create<HighBridgeToTwoBridges>(targets);
}
});
}
void HighBridgeToTwoBridges::find(BridgeCRs *target)
{
Atom *anchor = target->atom(1);
eachNeighbour(anchor, &Diamond::front_100, [target](Atom *neighbour) {
if (neighbour->is(19))
{
auto neighbourSpec = neighbour->specByRole<HighBridge>(19);
assert(neighbourSpec);
SpecificSpec *targets[2] = {
neighbourSpec,
target
};
create<HighBridgeToTwoBridges>(targets);
}
});
}
void HighBridgeToTwoBridges::doIt()
{
SpecificSpec *highBridge = target(0);
SpecificSpec *bridgeCRs = target(1);
assert(highBridge->type() == HighBridge::ID);
assert(bridgeCRs->type() == BridgeCRs::ID);
Atom *atoms[3] = { highBridge->atom(0), highBridge->atom(1), bridgeCRs->atom(1) };
Atom *a = atoms[0], *b = atoms[1], *c = atoms[2];
assert(a->is(18));
assert(b->is(19));
assert(c->is(5));
Handbook::amorph().erase(a);
crystalBy(b)->insert(a, Diamond::front_110_at({ b, c }));
a->unbondFrom(b);
a->bondWith(c);
if (a->is(17)) a->changeType(2);
else if (a->is(16)) a->changeType(1);
else a->changeType(3);
b->changeType(5);
c->changeType(24);
Finder::findAll(atoms, 3);
}