57ea1b866141bd78d028e371ef27bc75f5917342
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;
Stefan Schuermans support decimal and hexadec...

Stefan Schuermans authored 7 years ago

57)   if (strLayerName == "video") {
Stefan Schuermans add config file generator

Stefan Schuermans authored 7 years ago

58)     pLayer = &gLayerVideo;
Stefan Schuermans support decimal and hexadec...

Stefan Schuermans authored 7 years ago

59)   } else if (strLayerName == "pixel") {
Stefan Schuermans add config file generator

Stefan Schuermans authored 7 years ago

60)     pLayer = &gLayerPixel;
Stefan Schuermans support decimal and hexadec...

Stefan Schuermans authored 7 years ago

61)   } else if (strLayerName == "network") {
Stefan Schuermans add config file generator

Stefan Schuermans authored 7 years ago

62)     pLayer = &gLayerNetwork;
Stefan Schuermans support decimal and hexadec...

Stefan Schuermans authored 7 years ago

63)   } else if (strLayerName == "cable") {
64)     pLayer = &gLayerCables[0];
65)   } else if (strLayerName.substr(0, 6) == "cable ") {
66)     unsigned int no = strtoul(strLayerName.substr(6).c_str(), NULL, 0);
Stefan Schuermans add config file generator

Stefan Schuermans authored 7 years ago

67)     pLayer = &gLayerCables[no];
68)   } else if (strLayerName.substr(0, 12) == "distributor ") {
Stefan Schuermans support decimal and hexadec...

Stefan Schuermans authored 7 years ago

69)     unsigned int no = strtoul(strLayerName.substr(12).c_str(), NULL, 0);
Stefan Schuermans add config file generator

Stefan Schuermans authored 7 years ago

70)     pLayer = &gLayerDistributors[no];
Stefan Schuermans support decimal and hexadec...

Stefan Schuermans authored 7 years ago

71)   } else {
Stefan Schuermans add config file generator

Stefan Schuermans authored 7 years ago

72)     return true;
Stefan Schuermans support decimal and hexadec...

Stefan Schuermans authored 7 years ago

73)   }