check number of connected pixels at end
Stefan Schuermans

Stefan Schuermans commited on 2017-05-25 15:54:14
Showing 5 changed files, with 29 additions and 0 deletions.

... ...
@@ -55,3 +55,8 @@ void Chain::writePixels(std::ostream & strm) const
55 55
     itP->writePixel(strm);
56 56
 }
57 57
 
58
+size_t Chain::countPixels() const
59
+{
60
+  return mPixels.size();
61
+}
62
+
... ...
@@ -33,6 +33,7 @@ public:
33 33
                unsigned int width, unsigned int height,
34 34
                unsigned int distriNo, unsigned int chainNo);
35 35
   void writePixels(std::ostream & strm) const;
36
+  size_t countPixels() const;
36 37
   unsigned int mPixelCnt;
37 38
   std::vector<Pixel> mPixels;
38 39
 };
... ...
@@ -73,3 +73,12 @@ void Distri::writePixels(std::ostream & strm) const
73 73
   }
74 74
 }
75 75
 
76
+size_t Distri::countPixels() const
77
+{
78
+  size_t pixels = 0;
79
+  std::vector<Chain>::const_iterator itC;
80
+  for (itC = mChains.begin(); itC != mChains.end(); ++itC)
81
+    pixels += itC->countPixels();
82
+  return pixels;
83
+}
84
+
... ...
@@ -34,6 +34,7 @@ public:
34 34
   void writeDistri(std::ostream & strm) const;
35 35
   void writeMapping(std::ostream & strm) const;
36 36
   void writePixels(std::ostream & strm) const;
37
+  size_t countPixels() const;
37 38
   unsigned int mNo, mChainCnt, mPixelCnt;
38 39
   std::vector<Chain> mChains;
39 40
 };
... ...
@@ -483,6 +483,19 @@ int main(int argc, char *argv[])
483 483
     if (itD->pixCoord(ptPixel0, ptPixelSz, width, height) != 0)
484 484
       err = true;
485 485
 
486
+  // count pixels connected to distributors and compare to total pixels
487
+  size_t distri_pixels = 0;
488
+  for (itD = distris.begin(); itD != distris.end(); ++itD)
489
+    distri_pixels += itD->countPixels();
490
+  std::cout << "pixels connected to distributors: "
491
+            << distri_pixels << std::endl;
492
+  if (distri_pixels != gLayerPixel.mObjects.size()) {
493
+    std::cerr << "number of connected pixels (" << distri_pixels
494
+              << ") does not match total number of pixels ("
495
+              << gLayerPixel.mObjects.size() << ")" << std::endl;
496
+    err = true;
497
+  }
498
+
486 499
   // write config file
487 500
   if (writeCfg(width, height, distris, strCfgFileName) != 0)
488 501
     err = true;
489 502