cb8a96f08c4fe625d87d0ae165fe7e4d06991f60
Stefan Schuermans add config file generator

Stefan Schuermans authored 7 years ago

1) /*
Stefan Schuermans rename "FlexiPix" to "Ether...

Stefan Schuermans authored 7 years ago

2)  * EtherPix config file generator
Stefan Schuermans add config file generator

Stefan Schuermans authored 7 years ago

3)  *
Stefan Schuermans update copyright year

Stefan Schuermans authored 7 years ago

4)  * Copyright 2010-2017 Stefan Schuermans <stefan schuermans info>
Stefan Schuermans add config file generator

Stefan Schuermans authored 7 years ago

5)  *
6)  * This program is free software: you can redistribute it and/or modify
7)  * it under the terms of the GNU General Public License as published by
8)  * the Free Software Foundation, version 3 of the License.
9)  *
10)  *
11)  * This program is distributed in the hope that it will be useful,
12)  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13)  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14)  * GNU General Public License for more details.
15)  *
16)  * You should have received a copy of the GNU Lesser General Public License
17)  * along with this program. If not, see <http://www.gnu.org/licenses/>.
18)  */
19) 
20) #include <iostream>
21) #include <vector>
22) 
23) #include "chain.h"
24) #include "pixel.h"
25) #include "point.h"
26) 
27) Chain::Chain(unsigned int pixelCnt):
28)   mPixelCnt(pixelCnt)
29) {
30) }
31) 
32) int Chain::pixCoord(const Point &pix0, const Point &pixSz,
33)                     unsigned int width, unsigned int height,
34)                     unsigned int distriNo, unsigned int chainNo)
35) {
36)   bool err = false;
37)   if (mPixels.size() > mPixelCnt) {
38)     std::cerr << "too many pixels (" << mPixels.size() << "/"
39)               << mPixelCnt << ") for distributor "
40)               << std::hex << distriNo << " chain "
41)               << std::dec << chainNo << std::endl;
42)     err = true;
43)   }
44)   std::vector<Pixel>::iterator itP;
45)   for (itP = mPixels.begin(); itP != mPixels.end(); ++itP)
46)     if (itP->pixCoord(pix0, pixSz, width, height) != 0)
47)       err = true;
48)   return err ? -1 : 0;
49) }
50) 
51) void Chain::writePixels(std::ostream & strm) const
52) {
53)   std::vector<Pixel>::const_iterator itP;
54)   for (itP = mPixels.begin(); itP != mPixels.end(); ++itP)
55)     itP->writePixel(strm);
56) }
57)