27 #ifndef ABSTRACTELEMENT_XTAL_H
28 #define ABSTRACTELEMENT_XTAL_H
45 typedef typename CC::ATOM_TYPE T;
46 typedef typename CC::PARAM_CONFIG P;
48 R = P::EVENT_WINDOW_RADIUS,
50 BITS = P::BITS_PER_ATOM,
61 static u32 GetIndex(
const SPoint coord)
67 FAIL(ARRAY_INDEX_OUT_OF_BOUNDS);
74 return sites.
ReadBit(GetIndex(coord));
79 sites.
WriteBit(GetIndex(coord), val);
126 T sampleSiteContents;
128 void Sample(
const SPoint & place,
const T & content) {
129 if (random.
OneIn(++count))
132 sampleSiteContents = content;
140 const u32 ourType = this->
GetType();
147 GetSites(
self, xtalSites, window);
150 u32 symi = this->GetSymI(
self, window);
156 u32 totalPointSiteCount = 0;
157 u32 totalConsistentPointSiteCount = 0;
166 u32 totalFieldSiteCount = 0;
174 const SPoint sp = md.GetPoint(idx);
181 bool isPoint = xtalSites.
ReadBit(idx) !=0 ;
184 const u32 otherType = other.GetType();
187 ++totalPointSiteCount;
195 inconsistentEmptyPointSites.Sample(sp, other);
202 inconsistentResPointSites.Sample(sp, other);
207 if (otherType == ourType && this->
IsSameXtal(
self, other, window))
210 ++totalConsistentPointSiteCount;
215 bool isXtal = IsAbstractXtalType(window, otherType);
219 inconsistentXtalPointSites.Sample(sp, other);
223 inconsistentNonxtalPointSites.Sample(sp, other);
233 ++totalFieldSiteCount;
238 resFieldSites.Sample(sp, other);
246 emptyFieldSites.Sample(sp, other);
251 if (otherType == ourType && this->
IsSameXtal(
self, other, window))
253 usFieldSites.Sample(sp, other);
258 bool isXtal = IsAbstractXtalType(window, otherType);
261 nonusXtalFieldSites.Sample(sp, other);
277 if (usFieldSites.count > totalConsistentPointSiteCount)
282 else if (usFieldSites.count > 0 && inconsistentEmptyPointSites.count > 0)
284 window.
SwapAtoms(usFieldSites.sampleSite, inconsistentEmptyPointSites.sampleSite);
287 else if (inconsistentResPointSites.count > 0)
292 else if (resFieldSites.count > 0 && inconsistentEmptyPointSites.count > 0)
294 window.
SwapAtoms(resFieldSites.sampleSite, inconsistentEmptyPointSites.sampleSite);
298 else if (inconsistentXtalPointSites.count > 0 && inconsistentEmptyPointSites.count > 0)
u32 GetFirstIndex(const u32 radius) const
Definition: MDist.h:112
u32 GetType() const
Definition: Element.h:290
Definition: Element_Empty.h:41
u32 GetLastIndex(const u32 radius) const
Definition: MDist.h:129
void SetSymmetry(const PointSymmetry psym)
Definition: EventWindow.h:110
void SetCenterAtom(const T &atom)
Definition: EventWindow.h:220
u32 NoDiffusability(EventWindow< CC > &ew, SPoint nowAt, SPoint maybeAt) const
Definition: Element.h:508
Tile< CC > & GetTile()
Definition: EventWindow.h:132
virtual bool IsSameXtal(T &self, const T &otherAtom, EventWindow< CC > &window) const
Definition: AbstractElement_Xtal.h:92
void WriteBit(u32 idx, bool bit)
Definition: BitVector.tcc:41
bool IsLiveSite(const SPoint &location) const
Definition: EventWindow.h:148
bool OneIn(u32 odds)
Definition: Random.h:96
Random & GetRandom()
Definition: EventWindow.h:122
const T & GetRelativeAtom(const SPoint &offset) const
Definition: EventWindow.tcc:26
s32 FromPoint(const Point< s32 > &offset, u32 radius) const
Definition: MDist.tcc:201
const T & GetCenterAtom() const
Definition: EventWindow.h:209
virtual const T & GetDefaultAtom() const
Definition: Element.h:382
virtual u32 Diffusability(EventWindow< CC > &ew, SPoint nowAt, SPoint maybeAt) const
Definition: AbstractElement_Xtal.h:106
bool IsType(u32 type) const
Definition: Element.h:345
Definition: AbstractElement_Xtal.h:40
static MDist< R > & get()
Definition: MDist.tcc:193
bool ReadBit(u32 idx)
Definition: BitVector.tcc:65
Definition: Element_Res.h:48
Definition: ElementTable.h:43
#define EVENT_WINDOW_SITES(radius)
Definition: MDist.h:46
Definition: AbstractElement_Xtal.h:122
bool SetRelativeAtom(const SPoint &offset, const T &atom)
Definition: EventWindow.tcc:15
virtual u32 PercentMovable(const T &you, const T &me, const SPoint &offset) const
Definition: AbstractElement_Xtal.h:111
virtual void Behavior(EventWindow< CC > &window) const
Definition: AbstractElement_Xtal.h:137
void SwapAtoms(const SPoint &locA, const SPoint &locB)
Definition: EventWindow.tcc:40