0e2d779263ff44b9802d44fbe21ce524964304d1
Stefan Schuermans add config file generator

Stefan Schuermans authored 7 years ago

1) /*
2)  * FlexiPix config file generator
3)  *
4)  * Copyright 2010 Stefan Schuermans <stefan schuermans info>
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 <algorithm>
21) #include <dime/entities/Entity.h>
22) #include <dime/Input.h>
23) #include <dime/Model.h>
24) #include <dime/State.h>
25) #include <fstream>
26) #include <iostream>
27) #include <map>
28) #include <string>
29) 
30) #include "chain.h"
31) #include "constants.h"
32) #include "distri.h"
33) #include "layer.h"
34) #include "line.h"
35) #include "pixel.h"
36) #include "point.h"
37) 
38) Layer gLayerVideo, gLayerPixel, gLayerNetwork;
39) std::map<unsigned int, Layer> gLayerCables, gLayerDistributors;
40) Layer gLayerCable;
41) 
42) /**
43)  * @brief enumerate a entitiy in the DXF file
44)  * @param[in] state current state of libdime
45)  * @param[in] entity pointer to entity
46)  * @param[in] vp_ctx context pointer
47)  * @return if to continue enumeration
48)  */
49) bool cbEntity(const class dimeState * const state, class dimeEntity *entity,
50)             void *vp_ctx)
51) {
52)   (void)vp_ctx;
53) 
54)   // get layer
55)   std::string strLayerName = entity->getLayerName();
56)   Layer * pLayer;
57)   if (strLayerName == "video")
58)     pLayer = &gLayerVideo;
59)   else if (strLayerName == "pixel")
60)     pLayer = &gLayerPixel;
61)   else if (strLayerName == "network")
62)     pLayer = &gLayerNetwork;
63)   else if (strLayerName.substr(0, 6) == "cable ") {
64)     unsigned int no = 0;
Stefan Schuermans adaptions for gcc 5

Stefan Schuermans authored 7 years ago

65)     if (sscanf(strLayerName.substr(6).c_str(), "%x", &no) != 1)
66)       no = 0; // cable 0 by default
Stefan Schuermans add config file generator

Stefan Schuermans authored 7 years ago

67)     pLayer = &gLayerCables[no];
68)   } else if (strLayerName.substr(0, 12) == "distributor ") {
69)     unsigned int no = 0;
Stefan Schuermans adaptions for gcc 5

Stefan Schuermans authored 7 years ago

70)     if (sscanf(strLayerName.substr(12).c_str(), "%x", &no) != 1)
71)       no = 0; // distributor 0 by default