COTSField.cs 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using System.Drawing;
  7. using OTSModelSharp.ImageProcess;
  8. using OTSModelSharp.ServiceCenter;
  9. using OTSDataType;
  10. using OTSCLRINTERFACE;
  11. using System.Xml;
  12. using OTSMeasureApp._0_OTSModel.OTSDataType;
  13. using OTSModelSharp;
  14. namespace OTSDataType
  15. {
  16. using COTSFieldDataList = List<COTSField>;
  17. public class COTSField:ISlo
  18. {
  19. public COTSField leftField=null;
  20. public COTSField upField=null;
  21. public COTSField downField=null;
  22. public COTSField rightField=null;
  23. protected NLog.Logger log ;
  24. // ID
  25. int m_nID;
  26. int measureSequence;
  27. // position (from field center manager)
  28. protected System.Drawing.PointF m_otsPos ;
  29. protected CBSEImgClr m_pBSEImg;
  30. protected double m_pixelSize;
  31. protected CImageHandler m_ImagePro;
  32. //bool leftBorderParticlesBias = true;//true means that when there is overlap to process image the particles on the leftBorder will be included.
  33. //bool rightBorderParticlesBias = true;
  34. //bool upBorderParticlesBias = true;
  35. //bool downBorderParticlesBias = true;
  36. protected List<COTSParticleClr> m_listAllParticles = new List<COTSParticleClr>();//hold up all the particles abstracted from bse image;
  37. protected List<COTSParticleClr> m_listAnalysisParticles = new List<COTSParticleClr>();// according to xraylimit constraint,pick out the first big particles.
  38. protected List<COTSParticleClr> m_listXrayParticles = new List<COTSParticleClr>();//hold up all the particles that needing the xray data.
  39. private int imgheight;
  40. private int imgwidth;
  41. private COTSRect m_otsRect;
  42. private COTSSample m_sample;
  43. public COTSField()
  44. {
  45. log = NLog.LogManager.GetCurrentClassLogger();
  46. Init();
  47. }//only using in xmlserialization
  48. public int ImgHeight { get => imgheight; set => imgheight = value; }
  49. public int ImgWidth { get => imgwidth; set => imgwidth = value; }
  50. public COTSSample Sample { get => m_sample; set => m_sample = value; }
  51. internal COTSRect GetOTSRect()
  52. {
  53. return m_otsRect;
  54. }
  55. internal void SetOTSRect(COTSRect value)
  56. {
  57. m_otsRect = value;
  58. }
  59. //public bool GetLeftBorderParticlesBiasDefine() { return leftBorderParticlesBias; }
  60. //public void SetLeftBorderParticlesBiasDefine(bool ifSelect) { leftBorderParticlesBias = ifSelect; }
  61. //public bool GetRightBorderParticlesBiasDefine() { return rightBorderParticlesBias; }
  62. //public void SetRightBorderParticlesBiasDefine(bool ifSelect) { rightBorderParticlesBias = ifSelect; }
  63. //public bool GetUpBorderParticlesBiasDefine() { return upBorderParticlesBias; }
  64. //public void SetUpBorderParticlesBiasDefine(bool ifSelect) { upBorderParticlesBias = ifSelect; }
  65. //public bool GetDownBorderParticlesBiasDefine() { return downBorderParticlesBias; }
  66. //public void SetDownBorderParticlesBiasDefine(bool ifSelect) { downBorderParticlesBias = ifSelect; }
  67. public int GetMeasureSequence()
  68. {
  69. return measureSequence;
  70. }
  71. public void SetMeasureSequence(int value)
  72. {
  73. measureSequence = value;
  74. }
  75. public List<string> strKeyName;
  76. public bool GetIsMeasureComplete()
  77. {
  78. return isMeasureComplete;
  79. }
  80. public void SetIsMeasureComplete(bool value)
  81. {
  82. isMeasureComplete = value;
  83. }
  84. private bool isMeasureComplete;
  85. public PointF GetSemPos()
  86. {
  87. return m_semPos;
  88. }
  89. public void SetSemPos(PointF value)
  90. {
  91. m_semPos = value;
  92. }
  93. private PointF m_semPos;
  94. public List<COTSParticleClr> GetAllParticles()
  95. {
  96. return m_listAllParticles;
  97. }
  98. public List<COTSParticleClr> GetListAnalysisParticles()
  99. {
  100. return m_listAnalysisParticles;
  101. }
  102. public List<COTSParticleClr> GetListXrayParticles()
  103. {
  104. m_listXrayParticles.Clear();
  105. foreach (var p in m_listAnalysisParticles)
  106. {
  107. if (p.IsXrayParticle())
  108. {
  109. m_listXrayParticles.Add(p);
  110. }
  111. }
  112. return m_listXrayParticles;
  113. }
  114. public void SetListAnalysisParticles(List<COTSParticleClr> value)
  115. {
  116. m_listAnalysisParticles = value;
  117. }
  118. public COTSField(PointF centerPoint, double a_dPixelSize)
  119. {
  120. log = NLog.LogManager.GetCurrentClassLogger();
  121. Init();
  122. //m_pBSEImg = a_pBSEImg;
  123. m_otsPos = centerPoint;
  124. m_pixelSize = a_dPixelSize;
  125. }
  126. public double GetPixelSize()
  127. {
  128. return m_pixelSize;
  129. }
  130. public void SetPixelSize(double size)
  131. {
  132. m_pixelSize = size;
  133. }
  134. // initialization
  135. void Init()
  136. {
  137. // initialization
  138. m_nID = -1;
  139. m_otsPos =new System.Drawing.Point(0, 0);
  140. m_listAllParticles.Clear();
  141. }
  142. public COTSField(COTSField a_poSource)
  143. {
  144. // can't copy itself
  145. if (a_poSource == this)
  146. {
  147. return;
  148. }
  149. Duplicate(a_poSource);
  150. }
  151. public CBSEImgClr GetBSEImage()
  152. {
  153. return m_pBSEImg;
  154. }
  155. public void SetBSEImage(CBSEImgClr a_pBSEImg)
  156. {
  157. if (a_pBSEImg == null)
  158. {
  159. // invalid BSE image.
  160. log.Error("SetBSEImage: invalid BSE image.");
  161. return;
  162. }
  163. m_pBSEImg = a_pBSEImg;
  164. imgwidth = a_pBSEImg.GetWidth();
  165. imgheight = a_pBSEImg.GetHeight();
  166. }
  167. public void RemoveImgBGAndGetParticles(COTSImageProcParam a_pImageProcessParam,double a_pixelSize,bool ifXray)
  168. {
  169. if (m_pBSEImg == null)
  170. return;
  171. CImageHandler imghandler = new CImageHandler();
  172. List<COTSParticleClr> xrayParts = new List<COTSParticleClr>();
  173. imghandler.RemoveBGAndGetParts(this, a_pImageProcessParam, ref xrayParts);
  174. foreach (var p in xrayParts)
  175. {
  176. p.SetIsXrayParticle(ifXray);
  177. m_listAllParticles.Add(p);
  178. }
  179. return ;
  180. }
  181. public void RemoveDuplicateOverlapParticles(int overlap)
  182. {
  183. List<COTSParticleClr> finalparts = new List<COTSParticleClr>();
  184. if (leftField != null && leftField.measureSequence < this.measureSequence)
  185. {
  186. foreach (var p in this.GetSideParticlesByOverlap(SORTING_DIRECTION.LEFT, overlap))
  187. {
  188. int pleft = 0, pright = 0, ptop = 0, pbottom = 0;
  189. p.GetOTSRect(ref pleft, ref ptop, ref pright, ref pbottom);
  190. COTSRect prec = new COTSRect(pleft, ptop, pright, pbottom);
  191. PointF pcenter = prec.GetCenterPoint();
  192. bool findsimilar = false;
  193. var rightsideparts = leftField.GetSideParticlesByOverlap(SORTING_DIRECTION.RIGHT, overlap);
  194. foreach (var p1 in rightsideparts)
  195. {
  196. int p1left = 0, p1right = 0, p1top = 0, p1bottom = 0;
  197. p.GetOTSRect(ref p1left, ref p1top, ref p1right, ref p1bottom);
  198. COTSRect p1rec = new COTSRect(p1left, p1top, p1right, p1bottom);
  199. PointF p1Center = p1rec.GetCenterPoint();
  200. if (Math.Abs(pcenter.X - p1Center.X) < 2 * overlap && Math.Abs(pcenter.Y - p1Center.Y) < 2 * overlap)
  201. {
  202. if (p.CalculateSimilarity(p1) > 0.95)
  203. {
  204. findsimilar = true;
  205. break;
  206. }
  207. }
  208. }
  209. if (findsimilar == false)
  210. {
  211. finalparts.Add(p);
  212. }
  213. }
  214. }
  215. else
  216. {
  217. foreach (var p in this.GetSideParticlesByOverlap(SORTING_DIRECTION.LEFT, overlap))
  218. {
  219. finalparts.Add(p);
  220. }
  221. }
  222. if (upField != null && upField.measureSequence < this.measureSequence)
  223. {
  224. foreach (var p in this.GetSideParticlesByOverlap(SORTING_DIRECTION.UP, overlap))
  225. {
  226. int pleft = 0, pright = 0, ptop = 0, pbottom = 0;
  227. p.GetOTSRect(ref pleft, ref ptop, ref pright, ref pbottom);
  228. COTSRect prec = new COTSRect(pleft, ptop, pright, pbottom);
  229. PointF pcenter = prec.GetCenterPoint();
  230. bool findsimilar = false;
  231. var othersideparts = upField.GetSideParticlesByOverlap(SORTING_DIRECTION.DOWN, overlap);
  232. foreach (var p1 in othersideparts)
  233. {
  234. int p1left = 0, p1right = 0, p1top = 0, p1bottom = 0;
  235. p.GetOTSRect(ref p1left, ref p1top, ref p1right, ref p1bottom);
  236. COTSRect p1rec = new COTSRect(p1left, p1top, p1right, p1bottom);
  237. PointF p1Center = p1rec.GetCenterPoint();
  238. if (Math.Abs(pcenter.X - p1Center.X) < 2 * overlap && Math.Abs(pcenter.Y - p1Center.Y) < 2 * overlap)
  239. {
  240. if (p.CalculateSimilarity(p1) > 0.95)
  241. {
  242. findsimilar = true;
  243. break;
  244. }
  245. }
  246. }
  247. if (findsimilar == false)
  248. {
  249. finalparts.Add(p);
  250. }
  251. }
  252. }
  253. else
  254. {
  255. foreach (var p in this.GetSideParticlesByOverlap(SORTING_DIRECTION.UP, overlap))
  256. {
  257. finalparts.Add(p);
  258. }
  259. }
  260. if (rightField != null && rightField.measureSequence < this.measureSequence)
  261. {
  262. foreach (var p in this.GetSideParticlesByOverlap(SORTING_DIRECTION.RIGHT, overlap))
  263. {
  264. int pleft = 0, pright = 0, ptop = 0, pbottom = 0;
  265. p.GetOTSRect(ref pleft, ref ptop, ref pright, ref pbottom);
  266. COTSRect prec = new COTSRect(pleft, ptop, pright, pbottom);
  267. PointF pcenter = prec.GetCenterPoint();
  268. bool findsimilar = false;
  269. var othersideparts = rightField.GetSideParticlesByOverlap(SORTING_DIRECTION.LEFT, overlap);
  270. foreach (var p1 in othersideparts)
  271. {
  272. int p1left = 0, p1right = 0, p1top = 0, p1bottom = 0;
  273. p.GetOTSRect(ref p1left, ref p1top, ref p1right, ref p1bottom);
  274. COTSRect p1rec = new COTSRect(p1left, p1top, p1right, p1bottom);
  275. PointF p1Center = p1rec.GetCenterPoint();
  276. if (Math.Abs(pcenter.X - p1Center.X) < 2 * overlap && Math.Abs(pcenter.Y - p1Center.Y) < 2 * overlap)
  277. {
  278. if (p.CalculateSimilarity(p1) > 0.95)
  279. {
  280. findsimilar = true;
  281. break;
  282. }
  283. }
  284. }
  285. if (findsimilar == false)
  286. {
  287. finalparts.Add(p);
  288. }
  289. }
  290. }
  291. else
  292. {
  293. foreach (var p in this.GetSideParticlesByOverlap(SORTING_DIRECTION.RIGHT, overlap))
  294. {
  295. finalparts.Add(p);
  296. }
  297. }
  298. if (downField != null && downField.measureSequence < this.measureSequence)
  299. {
  300. foreach (var p in this.GetSideParticlesByOverlap(SORTING_DIRECTION.DOWN, overlap))
  301. {
  302. int pleft = 0, pright = 0, ptop = 0, pbottom = 0;
  303. p.GetOTSRect(ref pleft, ref ptop, ref pright, ref pbottom);
  304. COTSRect prec = new COTSRect(pleft, ptop, pright, pbottom);
  305. PointF pcenter = prec.GetCenterPoint();
  306. bool findsimilar = false;
  307. var othersideparts = rightField.GetSideParticlesByOverlap(SORTING_DIRECTION.UP, overlap);
  308. foreach (var p1 in othersideparts)
  309. {
  310. int p1left = 0, p1right = 0, p1top = 0, p1bottom = 0;
  311. p.GetOTSRect(ref p1left, ref p1top, ref p1right, ref p1bottom);
  312. COTSRect p1rec = new COTSRect(p1left, p1top, p1right, p1bottom);
  313. PointF p1Center = p1rec.GetCenterPoint();
  314. if (Math.Abs(pcenter.X - p1Center.X) < 2 * overlap && Math.Abs(pcenter.Y - p1Center.Y) < 2 * overlap)
  315. {
  316. if (p.CalculateSimilarity(p1) > 0.95)
  317. {
  318. findsimilar = true;
  319. break;
  320. }
  321. }
  322. }
  323. if (findsimilar == false)
  324. {
  325. finalparts.Add(p);
  326. }
  327. }
  328. }
  329. else
  330. {
  331. foreach (var p in this.GetSideParticlesByOverlap(SORTING_DIRECTION.DOWN, overlap))
  332. {
  333. finalparts.Add(p);
  334. }
  335. }
  336. foreach (var p in this.GetSideParticlesByOverlap(SORTING_DIRECTION.CENTER, overlap))
  337. {
  338. finalparts.Add(p);
  339. }
  340. this.SetListAnalysisParticles(finalparts);
  341. }
  342. private List<COTSParticleClr> GetSideParticlesByOverlap(SORTING_DIRECTION direction,int overlap)
  343. {
  344. List<COTSParticleClr> sideparts = new List<COTSParticleClr>();
  345. if (direction == SORTING_DIRECTION.LEFT)
  346. {
  347. foreach (var p in this.GetAllParticles())
  348. {
  349. int left = 0, top = 0, right = 0, bottom = 0;
  350. p.GetOTSRect(ref left, ref top, ref right, ref bottom);
  351. if ((right - this.GetOTSRect().GetTopLeft().X) < 2 * overlap)
  352. {
  353. sideparts.Add(p);
  354. }
  355. }
  356. }
  357. if (direction == SORTING_DIRECTION.RIGHT)
  358. {
  359. foreach (var p in this.GetAllParticles())
  360. {
  361. int left = 0, top = 0, right = 0, bottom = 0;
  362. p.GetOTSRect(ref left, ref top, ref right, ref bottom);
  363. if ((this.GetOTSRect().GetBottomRight().X-left) < 2 * overlap)
  364. {
  365. sideparts.Add(p);
  366. }
  367. }
  368. }
  369. if (direction == SORTING_DIRECTION.UP)
  370. {
  371. foreach (var p in this.GetAllParticles())
  372. {
  373. int left = 0, top = 0, right = 0, bottom = 0;
  374. p.GetOTSRect(ref left, ref top, ref right, ref bottom);
  375. if ((this.GetOTSRect().GetTopLeft().Y - bottom) < 2 * overlap)
  376. {
  377. sideparts.Add(p);
  378. }
  379. }
  380. }
  381. if (direction == SORTING_DIRECTION.DOWN)
  382. {
  383. foreach (var p in this.GetAllParticles())
  384. {
  385. int left = 0, top = 0, right = 0, bottom = 0;
  386. p.GetOTSRect(ref left, ref top, ref right, ref bottom);
  387. if ((top-this.GetOTSRect().GetBottomRight().Y ) < 2 * overlap)
  388. {
  389. sideparts.Add(p);
  390. }
  391. }
  392. }
  393. if (direction == SORTING_DIRECTION.CENTER)
  394. {
  395. foreach (var p in this.GetAllParticles())
  396. {
  397. int left = 0, top = 0, right = 0, bottom = 0;
  398. p.GetOTSRect(ref left, ref top, ref right, ref bottom);
  399. var fldrec = this.GetOTSRect();
  400. int fldleft = (int)fldrec.GetTopLeft().X;
  401. int fldright = (int)fldrec.GetBottomRight().X;
  402. int fldtop = (int)fldrec.GetTopLeft().Y;
  403. int fldbottom = (int)fldrec.GetBottomRight().Y;
  404. if ((top - fldtop > 2 * overlap) && (fldbottom-bottom>2*overlap) && (left-fldleft>2*overlap) && (fldright-right>2*overlap))
  405. {
  406. sideparts.Add(p);
  407. }
  408. }
  409. }
  410. return sideparts;
  411. }
  412. public void GetPartsBySpecialGray(CIntRangeClr grayRange, CDoubleRangeClr diameterRange,double pixelSize, bool ifXray)
  413. {
  414. if (m_pBSEImg == null)
  415. return;
  416. CImageHandler imghandler = new CImageHandler();
  417. List<COTSParticleClr> specialParts = new List<COTSParticleClr>();
  418. imghandler.GetParticlesBySpecialGray(m_pBSEImg, grayRange,diameterRange,pixelSize, ref specialParts);
  419. foreach (var p in specialParts)
  420. {
  421. p.SetIsXrayParticle(ifXray);
  422. m_listAllParticles.Add(p);
  423. }
  424. return;
  425. }
  426. public bool CalParticleImageProp(List<COTSParticleClr> particles)
  427. {
  428. m_ImagePro = new CImageHandler();
  429. foreach (COTSParticleClr part in particles)
  430. {
  431. m_ImagePro.CalParticleImageProp( part, m_pixelSize);
  432. }
  433. return true;
  434. }
  435. public void InitParticles(COTSImageProcParam a_pImageProcessParam,double a_dPixelSize)
  436. {
  437. m_listAnalysisParticles = new List<COTSParticleClr>();
  438. // get area range
  439. CDoubleRange oAreaRange = a_pImageProcessParam.GetIncAreaRange();
  440. double rMin = oAreaRange.GetStart() / 2.0;
  441. double rMax = oAreaRange.GetEnd() / 2.0;
  442. int nTagId = 0;
  443. foreach (COTSParticleClr pParticle in m_listAllParticles)//m_listAllParticles memorize all the particles .
  444. {
  445. pParticle.SetParticleId(nTagId);//give all the conforming particles a unified sequence no.
  446. pParticle.SetFieldId(GetId());
  447. pParticle.SetType((int)otsdataconst.OTS_PARTICLE_TYPE.NO_ANALYSIS_X_RAY);
  448. pParticle.SetTypeName("Not Identified");
  449. pParticle.SetAnalysisId(nTagId); // the same as the tagId no use now.
  450. nTagId++;
  451. }
  452. log.Info("Total Particles: (>" + oAreaRange.GetStart().ToString("f2") + "): "+ "<" + oAreaRange.GetEnd().ToString("f2") + "): " + m_listAllParticles.Count);
  453. }
  454. public bool CreateXrayList(List<COTSParticleClr> a_listParticles)
  455. {
  456. foreach (COTSParticleClr pPart in a_listParticles)
  457. {
  458. System.Drawing.Point poi = (System.Drawing.Point)pPart.GetXRayPos();
  459. CPosXrayClr pPosXray = new CPosXrayClr();
  460. pPosXray.SetPosition(poi);
  461. pPosXray.SetPartTagId(pPart.GetParticleId());
  462. pPosXray.SetIndex(pPart.GetAnalysisId());
  463. pPosXray.SetScanFieldId(pPart.GetFieldId());
  464. pPart.SetXray(pPosXray);
  465. }
  466. return true;
  467. }
  468. public bool NoParticle()
  469. {
  470. if (m_listAllParticles.Count == 0)
  471. {
  472. return true;
  473. }
  474. else
  475. {
  476. return false;
  477. }
  478. }
  479. public bool NoAnalysisParticle()
  480. {
  481. if (m_listAllParticles.Count == 0)
  482. {
  483. return true;
  484. }
  485. else
  486. {
  487. return false;
  488. }
  489. }
  490. public bool PositionEquals(COTSField a_oSource)
  491. {
  492. var xoffSet = imgwidth * m_pixelSize /2;
  493. var yoffSet = imgheight * m_pixelSize/2 ;
  494. if (a_oSource.m_otsPos.X < (m_otsPos.X+xoffSet) && a_oSource.m_otsPos.X>( m_otsPos.X-xoffSet))
  495. {
  496. if (a_oSource.m_otsPos.Y < (m_otsPos.Y + yoffSet) && a_oSource.m_otsPos.Y > (m_otsPos.Y - yoffSet))
  497. {
  498. return true;
  499. }
  500. return false;
  501. }
  502. else
  503. {
  504. return false;
  505. }
  506. }
  507. // ID
  508. public int GetId()
  509. {
  510. return m_nID;
  511. }
  512. public void SetId(int a_nID)
  513. {
  514. m_nID = a_nID;
  515. }
  516. // position (from field center manager)
  517. public System.Drawing.PointF GetOTSPosition()
  518. {
  519. return m_otsPos;
  520. }
  521. public void SetOTSPosition(System.Drawing.PointF a_poiPos)
  522. {
  523. m_otsPos = a_poiPos;
  524. }
  525. public List<COTSParticleClr> GetTopBorderedParticles()
  526. {
  527. List<COTSParticleClr> parts = new List<COTSParticleClr>();
  528. foreach (var p in m_listAllParticles)
  529. {
  530. var segs = p.GetFeature().GetSegmentsList();//COTSSegment
  531. foreach (var seg in segs)
  532. {
  533. if (seg.GetHeight() == 0)
  534. {
  535. parts.Add(p);
  536. break;
  537. }
  538. }
  539. }
  540. return parts;
  541. }
  542. public List< COTSParticleClr > GetBottomBorderedParticles()
  543. {
  544. List<COTSParticleClr> parts = new List<COTSParticleClr>();
  545. foreach (var p in m_listAllParticles)
  546. {
  547. var segs = p.GetFeature().GetSegmentsList();
  548. foreach (var seg in segs)
  549. {
  550. if (seg.GetHeight() == this.ImgHeight - 1)//the lowest height is 767(height-1),cause starting from 0.
  551. {
  552. parts.Add(p);
  553. break;
  554. }
  555. }
  556. }
  557. return parts;
  558. }
  559. public List<COTSParticleClr> GetLeftBorderedParticles()
  560. {
  561. List<COTSParticleClr> parts = new List<COTSParticleClr>();
  562. foreach (var p in m_listAllParticles)
  563. {
  564. var segs = p.GetFeature().GetSegmentsList();
  565. foreach (var seg in segs)
  566. {
  567. if (seg.GetStart() == 0)
  568. {
  569. parts.Add(p);
  570. break;
  571. }
  572. }
  573. }
  574. return parts;
  575. }
  576. public List <COTSParticleClr> GetRightBorderedParticles()
  577. {
  578. List<COTSParticleClr> parts = new List<COTSParticleClr>();
  579. foreach (var p in m_listAllParticles)
  580. {
  581. var segs = p.GetFeature().GetSegmentsList();
  582. foreach (var seg in segs)
  583. {
  584. if (seg.GetStart() + seg.GetLength() == this.ImgWidth)
  585. {
  586. parts.Add(p);
  587. break;
  588. }
  589. }
  590. }
  591. return parts;
  592. }
  593. // is empty
  594. public bool IsEmpty()
  595. {
  596. return m_listAllParticles.Count == 0;
  597. }
  598. void Duplicate( COTSField a_oSource)
  599. {
  600. m_nID = a_oSource.m_nID;
  601. m_otsPos = a_oSource.m_otsPos;
  602. // copy data over
  603. foreach(var pParticle in a_oSource.m_listAllParticles)
  604. {
  605. m_listAllParticles.Add(pParticle);
  606. }
  607. }
  608. public override void Serialize(bool isStoring, XmlDocument classDoc, XmlNode rootNode)
  609. {
  610. xPoint xPos = new xPoint();
  611. Slo slo = new Slo();
  612. slo.Register("OTSPosition", xPos);
  613. if (isStoring)
  614. {
  615. xPos.AssignValue(new System.Drawing.Point((int)m_otsPos.X,(int)m_otsPos.Y));
  616. slo.Serialize(true, classDoc, rootNode);
  617. }
  618. else
  619. {
  620. slo.Serialize(false, classDoc, rootNode);
  621. m_otsPos = xPos.value();
  622. }
  623. }
  624. }
  625. }