Stefan Schuermans commited on 2017-05-25 16:02:51
Showing 6 changed files, with 32 additions and 5 deletions.
... | ... |
@@ -29,6 +29,11 @@ Chain::Chain(unsigned int pixelCnt): |
29 | 29 |
{ |
30 | 30 |
} |
31 | 31 |
|
32 |
+void Chain::addPixel(Pixel const &pixel) |
|
33 |
+{ |
|
34 |
+ mPixels.push_back(pixel); |
|
35 |
+} |
|
36 |
+ |
|
32 | 37 |
int Chain::pixCoord(const Point &pix0, const Point &pixSz, |
33 | 38 |
unsigned int width, unsigned int height, |
34 | 39 |
unsigned int distriNo, unsigned int chainNo) |
... | ... |
@@ -29,11 +29,13 @@ |
29 | 29 |
class Chain { |
30 | 30 |
public: |
31 | 31 |
Chain(unsigned int pixelCnt); |
32 |
+ void addPixel(Pixel const &pixel); |
|
32 | 33 |
int pixCoord(const Point &pix0, const Point &pixSz, |
33 | 34 |
unsigned int width, unsigned int height, |
34 | 35 |
unsigned int distriNo, unsigned int chainNo); |
35 | 36 |
void writePixels(std::ostream & strm) const; |
36 | 37 |
size_t countPixels() const; |
38 |
+private: |
|
37 | 39 |
unsigned int mPixelCnt; |
38 | 40 |
std::vector<Pixel> mPixels; |
39 | 41 |
}; |
... | ... |
@@ -31,6 +31,21 @@ Distri::Distri(unsigned int no, unsigned int chainCnt, unsigned int pixelCnt): |
31 | 31 |
{ |
32 | 32 |
} |
33 | 33 |
|
34 |
+unsigned int Distri::getNo() const |
|
35 |
+{ |
|
36 |
+ return mNo; |
|
37 |
+} |
|
38 |
+ |
|
39 |
+void Distri::addChain(Chain const &chain) |
|
40 |
+{ |
|
41 |
+ mChains.push_back(chain); |
|
42 |
+} |
|
43 |
+ |
|
44 |
+Chain & Distri::accessLastChain() |
|
45 |
+{ |
|
46 |
+ return mChains.back(); |
|
47 |
+} |
|
48 |
+ |
|
34 | 49 |
int Distri::pixCoord(const Point &pix0, const Point &pixSz, |
35 | 50 |
unsigned int width, unsigned int height) |
36 | 51 |
{ |
... | ... |
@@ -29,12 +29,16 @@ |
29 | 29 |
class Distri { |
30 | 30 |
public: |
31 | 31 |
Distri(unsigned int no, unsigned int chainCnt, unsigned int pixelCnt); |
32 |
+ unsigned int getNo() const; |
|
33 |
+ void addChain(Chain const &chain); |
|
34 |
+ Chain & accessLastChain(); |
|
32 | 35 |
int pixCoord(const Point &pix0, const Point &pixSz, |
33 | 36 |
unsigned int width, unsigned int height); |
34 | 37 |
void writeDistri(std::ostream & strm) const; |
35 | 38 |
void writeMapping(std::ostream & strm) const; |
36 | 39 |
void writePixels(std::ostream & strm) const; |
37 | 40 |
size_t countPixels() const; |
41 |
+private: |
|
38 | 42 |
unsigned int mNo, mChainCnt, mPixelCnt; |
39 | 43 |
std::vector<Chain> mChains; |
40 | 44 |
}; |
... | ... |
@@ -252,7 +252,7 @@ int createChain(Chain &chain, const Object *pObjCable) |
252 | 252 |
pObjPixel = intersectsPixels[0].pObj; |
253 | 253 |
|
254 | 254 |
// add pixel to chain |
255 |
- chain.mPixels.push_back(Pixel(pObjPixel)); |
|
255 |
+ chain.addPixel(Pixel(pObjPixel)); |
|
256 | 256 |
|
257 | 257 |
// find cables connected to pixel |
258 | 258 |
std::vector<Layer::Intersection> intersectsCables; |
... | ... |
@@ -305,7 +305,7 @@ int createDistri(Distri &distri, const Layer *pLayer, unsigned int pixels) |
305 | 305 |
{ |
306 | 306 |
// must have exactly one object |
307 | 307 |
if (pLayer->mObjects.size() != 1) { |
308 |
- std::cerr << "layer of distributor " << std::hex << distri.mNo |
|
308 |
+ std::cerr << "layer of distributor " << std::hex << distri.getNo() |
|
309 | 309 |
<< "contains no object or multiple objects" << std::endl; |
310 | 310 |
return -1; |
311 | 311 |
} |
... | ... |
@@ -315,7 +315,7 @@ int createDistri(Distri &distri, const Layer *pLayer, unsigned int pixels) |
315 | 315 |
std::vector<Layer::Intersection> intersectsNet; |
316 | 316 |
gLayerNetwork.getIntersections(pObjDistri, intersectsNet); |
317 | 317 |
if (intersectsNet.size() != 1) { |
318 |
- std::cerr << "distributor " << std::hex << distri.mNo |
|
318 |
+ std::cerr << "distributor " << std::hex << distri.getNo() |
|
319 | 319 |
<< "has no network connection or multiple network connections" |
320 | 320 |
<< std::endl; |
321 | 321 |
return -1; |
... | ... |
@@ -338,8 +338,8 @@ int createDistri(Distri &distri, const Layer *pLayer, unsigned int pixels) |
338 | 338 |
bool err = false; |
339 | 339 |
for (itIntersect = intersectsCables.begin(); |
340 | 340 |
itIntersect != intersectsCables.end(); ++itIntersect) { |
341 |
- distri.mChains.push_back(Chain(pixels)); |
|
342 |
- if (createChain(distri.mChains.back(), itIntersect->pObj) != 0) |
|
341 |
+ distri.addChain(Chain(pixels)); |
|
342 |
+ if (createChain(distri.accessLastChain(), itIntersect->pObj) != 0) |
|
343 | 343 |
err = true; |
344 | 344 |
} |
345 | 345 |
|