Changeset 739 for cpp/frams/_demos/printconvmap.cpp
- Timestamp:
- 02/18/18 02:54:36 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
cpp/frams/_demos/printconvmap.cpp
r732 r739 5 5 #include "printconvmap.h" 6 6 #include <stdio.h> 7 #include <frams/util/multimap.h>8 #include <frams/model/model.h>9 10 #define GEN1MAX 1511 7 12 8 void printN(const char* t, int maxlen) … … 22 18 } 23 19 24 void printmapping(const char* gen1, int len1, const MultiRange &mr, const char* gen2, int len2 )20 void printmapping(const char* gen1, int len1, const MultiRange &mr, const char* gen2, int len2, int left_column_padding) 25 21 { 26 printN(' ', GEN1MAX- len1);22 printN(' ', left_column_padding - len1); 27 23 printN(gen1, len1); 28 24 printf(" : "); … … 43 39 } 44 40 45 void printConvMap(const SString& gen1, const SString& gen2, const MultiMap& map )41 void printConvMap(const SString& gen1, const SString& gen2, const MultiMap& map, int left_column_padding) 46 42 { 47 43 int y, y2, len1; … … 61 57 MultiRange *mr; 62 58 MultiRange emptyrange; 63 printN(' ', GEN1MAX);59 printN(' ', left_column_padding); 64 60 printf(" %s\n", g2.c_str()); 65 61 int begin = map.getBegin(); … … 82 78 y2 = map.getMapping(id + 1)->begin; 83 79 } 84 if ((y2 - y) > GEN1MAX) y2 = y + GEN1MAX;80 if ((y2 - y) > left_column_padding) y2 = y + left_column_padding; 85 81 if (y2 > (y + len1)) y2 = y + len1; 86 printmapping(g + y, y2 - y, *mr, g2.c_str(), g2.len() );82 printmapping(g + y, y2 - y, *mr, g2.c_str(), g2.len(), left_column_padding); 87 83 y = y2; 88 84 } 89 85 } 90 86 91 const MultiMap & getModelDisplayMap() 87 ModelDisplayMap::ModelDisplayMap(Model &m) 88 :model(m) 92 89 { 93 static MultiMap display_map; 94 if (display_map.isEmpty()) 95 { 96 for (int i = 0; i < 10; i++) 97 { 98 display_map.add(Model::partToMap(i), Model::partToMap(i), i, i); 99 display_map.add(Model::jointToMap(i), Model::jointToMap(i), 10 + i, 10 + i); 100 display_map.add(Model::neuroToMap(i), Model::neuroToMap(i), 20 + i, 20 + i); 101 } 102 } 103 return display_map; 90 joint_offset = max(10, (int(9 + model.getPartCount()) / 10) * 10); 91 neuron_offset = joint_offset + max(10, (int(9 + model.getJointCount()) / 10) * 10); 92 max_element = neuron_offset + max(10, (int(9 + model.getNeuroCount()) / 10) * 10); 93 for (int i = 0; i < model.getPartCount(); i++) 94 map.add(Model::partToMap(i), Model::partToMap(i), i, i); 95 for (int i = 0; i < model.getJointCount(); i++) 96 map.add(Model::jointToMap(i), Model::jointToMap(i), joint_offset + i, joint_offset + i); 97 for (int i = 0; i < model.getNeuroCount(); i++) 98 map.add(Model::neuroToMap(i), Model::neuroToMap(i), neuron_offset + i, neuron_offset + i); 104 99 } 105 100 106 void printModelMap(const SString& gen1, const MultiMap& map)101 void ModelDisplayMap::print(int left_column_padding) 107 102 { 108 103 MultiMap combined_map; 109 combined_map.addCombined(map, getModelDisplayMap()); 110 SString g2("012345678901234567890123456789"); 111 printN(' ', GEN1MAX); 112 printf(" Parts Joints Neurons\n"); 113 printConvMap(gen1, g2, combined_map); 104 combined_map.addCombined(model.getMap(), getMap()); 105 static const SString t09("0123456789"); 106 SString g; 107 for (int i = 0; i < max_element; i += 10) 108 g += t09; 109 printN(' ', left_column_padding); 110 printf(" Parts "); 111 printN(' ', joint_offset - 10); 112 printf("Joints "); 113 printN(' ', (neuron_offset - joint_offset) - 10); 114 printf("Neurons\n"); 115 printConvMap(model.getGeno().getGenes(), g, combined_map, left_column_padding); 114 116 }
Note: See TracChangeset
for help on using the changeset viewer.