void increase_triangle_show(increase_triangle_t *increase_triangle) { increase_triangle_t *p_increase_triangle=increase_triangle; if(NULL==p_increase_triangle){ return; } int i=0; int layer_value_sum=0; int layers_value_sum=0; int all_value_sum=0; printf("\n"); printf("layers=[%d],base_value=[%d],multiple=[%d];\n",get_layers(p_increase_triangle),get_base_value(p_increase_triangle),get_multiple(p_increase_triangle)); show_layer_index(p_increase_triangle->layer_index); printf("\n"); for(i=0; i<p_increase_triangle->layers; i++){ layer_value_sum=get_layer_value_sum(p_increase_triangle,i+1); layers_value_sum=get_increase_triangle_layers_value_sum(p_increase_triangle,i+1); printf("layer=%-2d,layer_sum=[%-5d] 2*layer_sum=[%-5d];layers_sum=[%-5d],2*layer_sum-layers_num=[%-5d]\n",i+1,layer_value_sum,2*layer_value_sum,layers_value_sum,2*layer_value_sum-layers_value_sum); } printf("\n"); all_value_sum=get_increase_triangle_all_value_sum(p_increase_triangle); printf("all layers sum=[%-5d]\n", all_value_sum); printf("\n"); return; }
void pms::serialization::spritedesc::node_parser_sprite_declaration ::get_layers_and_size ( const resources::image& image, layout::atlas_page::sprite& s, const tree_node& size_node, const tree_node& layer_list_node ) const { tree_node key_node; if ( size_node.children.empty() ) key_node = size_node; else key_node = size_node.children[0]; const std::string key( key_node.value.begin(), key_node.value.end() ); if ( key == "autosize" ) { s.layers = get_layers( image, layer_list_node ); compute_source_box( s ); } else { if ( key == "image_size" ) s.source_box.set( 0, 0, image.width, image.height ); else // key is the name of a layer { resources::layer layer; get_layer_info( image, layer, key ); s.source_box.set( layer.x, layer.y, layer.width, layer.height ); } s.layers = get_layers( image, layer_list_node ); } crop_sprite_to_image_bounds( image, s ); if ( size_node.children.empty() ) apply_result_box_ratio( s, 1 ); else apply_result_box_ratio( s, size_node.children[ 1 ] ); }
LayerSharedPtr MLNetwork::add_layer(const std::string& name, bool directed) { LayerSharedPtr check = get_layer(name); if (check) return NULL; layer_id id = ++max_layer_id; LayerSharedPtr layer_ptr(new layer(id,name)); layers.insert(id,layer_ptr); cidx_layer_by_name[name] = layer_ptr; for (LayerSharedPtr layer : get_layers()) { sidx_edges_by_layer_pair[layer->id][layer_ptr->id]; // initialize an empty map } set_directed(layer_ptr,layer_ptr,directed); return layer_ptr; }
void pms::serialization::spritedesc::node_parser_sprite_declaration::parse_node ( const resources::image_mapping& images, layout::atlas_page& desc, const tree_node& node ) const { layout::atlas_page::sprite s; s.bleed = false; std::size_t n( 0 ); if ( ( node.children[n].value.id() == grammar::id_properties ) || ( node.children[n].value.id() == grammar::id_identifier ) ) apply_sprite_properties( s, node.children[ n++ ] ); const tree_node name_node( node.children[n++] ); const tree_node size_node( node.children[n++] ); const tree_node image_node( node.children[n++] ); const tree_node layers_node( node.children[n++] ); get_sprite_name( s, name_node ); if ( desc.get_sprite_by_name(s.name) != desc.sprite_end() ) std::cerr << "warning: duplicate sprite entry '" << s.name << "'." << std::endl; get_image_id( s, image_node ); boost::optional< const resources::image& > image ( get_image_from_id( images, desc, s.image_id ) ); if ( !image ) return; get_layers_and_size( *image, s, size_node, layers_node ); if ( n < node.children.size() ) s.mask = get_layers( *image, node.children[n++] ); desc.add_sprite( s ); }
carmen_velodyne_partial_scan_message carmen_laser_ldmrs_convert_laser_scan_to_partial_velodyne_message(carmen_laser_ldmrs_message *msg, double laserscan_timestamp) { carmen_velodyne_partial_scan_message velodyne_message; int layer_1_start, layer_1_size, layer_2_start, layer_2_size, layer_3_start, layer_3_size, layer_4_start, layer_4_size; get_layers(msg, layer_1_start, layer_1_size, layer_2_start, layer_2_size, layer_3_start, layer_3_size, layer_4_start, layer_4_size); double layer_1_start_angle = msg->arraypoints[layer_1_start].horizontal_angle; double layer_1_end_angle = msg->arraypoints[layer_1_start + layer_1_size - 1].horizontal_angle; double layer_2_start_angle = msg->arraypoints[layer_2_start].horizontal_angle; double layer_2_end_angle = msg->arraypoints[layer_2_start + layer_2_size - 1].horizontal_angle; double layer_3_start_angle = msg->arraypoints[layer_3_start].horizontal_angle; double layer_3_end_angle = msg->arraypoints[layer_3_start + layer_3_size - 1].horizontal_angle; double layer_4_start_angle = msg->arraypoints[layer_4_start].horizontal_angle; double layer_4_end_angle = msg->arraypoints[layer_4_start + layer_4_size - 1].horizontal_angle; double largest_angle12 = (layer_1_start_angle > layer_2_start_angle) ? layer_1_start_angle: layer_2_start_angle; double largest_angle34 = (layer_3_start_angle > layer_4_start_angle) ? layer_3_start_angle: layer_4_start_angle; double largest_angle = (largest_angle12 > largest_angle34) ? largest_angle12: largest_angle34; double smallest_angle12 = (layer_1_end_angle < layer_2_end_angle) ? layer_1_end_angle: layer_2_end_angle; double smallest_angle34 = (layer_3_end_angle < layer_4_end_angle) ? layer_3_end_angle: layer_4_end_angle; double smallest_angle = (smallest_angle12 < smallest_angle34) ? smallest_angle12: smallest_angle34; double half_a_degree = carmen_degrees_to_radians(0.5); int number_of_shots = (int) ((largest_angle - smallest_angle) / half_a_degree); velodyne_message.number_of_32_laser_shots = number_of_shots; velodyne_message.partial_scan = (carmen_velodyne_32_laser_shot *) calloc (velodyne_message.number_of_32_laser_shots, sizeof(carmen_velodyne_32_laser_shot)); velodyne_message.timestamp = laserscan_timestamp; velodyne_message.host = carmen_get_host(); for (int i = 0, i1 = 0, i2 = 0, i3 = 0, i4 = 0; i < velodyne_message.number_of_32_laser_shots; i++) { for (int j = 0; j < 4; j++) { velodyne_message.partial_scan[i].distance[j] = 0; velodyne_message.partial_scan[i].intensity[j] = 255; } double angle = largest_angle - ((double) i) * half_a_degree - 0.000005; velodyne_message.partial_scan[i].angle = -carmen_radians_to_degrees(angle); if ((angle <= msg->arraypoints[layer_1_start + i1].horizontal_angle) && (angle >= layer_1_end_angle)) { double distance = msg->arraypoints[layer_1_start + i1].radial_distance; distance = (distance > 130.0)? 0.0: distance; // larger than 130 meters does no fit an unsigned short int distance field of Velodyne... velodyne_message.partial_scan[i].distance[0] = (unsigned short) (round(distance * 500.0)); velodyne_message.partial_scan[i].intensity[0] = 255; i1++; } if ((angle <= msg->arraypoints[layer_2_start + i2].horizontal_angle) && (angle >= layer_2_end_angle)) { double distance = msg->arraypoints[layer_2_start + i2].radial_distance; distance = (distance > 130.0)? 0.0: distance; // larger than 130 meters does no fit an unsigned short int distance field of Velodyne... velodyne_message.partial_scan[i].distance[1] = (unsigned short) (round(distance * 500.0)); velodyne_message.partial_scan[i].intensity[1] = 255; i2++; } if ((angle <= msg->arraypoints[layer_3_start + i3].horizontal_angle) && (angle >= layer_3_end_angle)) { double distance = msg->arraypoints[layer_3_start + i3].radial_distance; distance = (distance > 130.0)? 0.0: distance; // larger than 130 meters does no fit an unsigned short int distance field of Velodyne... velodyne_message.partial_scan[i].distance[2] = (unsigned short) (round(distance * 500.0)); velodyne_message.partial_scan[i].intensity[2] = 255; i3++; } if ((angle <= msg->arraypoints[layer_4_start + i4].horizontal_angle) && (angle >= layer_4_end_angle)) { double distance = msg->arraypoints[layer_4_start + i4].radial_distance; distance = (distance > 130.0)? 0.0: distance; // larger than 130 meters does no fit an unsigned short int distance field of Velodyne... velodyne_message.partial_scan[i].distance[3] = (unsigned short) (round(distance * 500.0)); velodyne_message.partial_scan[i].intensity[3] = 255; i4++; } } return (velodyne_message); }
std::string MLNetwork::to_string() const { return "Multilayer Network (\"" + name + "\": " + std::to_string(get_layers().size()) + " layers, " + std::to_string(get_actors().size()) + " actors, " + std::to_string(get_nodes().size()) + " nodes, " + std::to_string(get_edges().size()) + " edges)"; }