void main(int argc, char *argv[]) { int i; if (argc != 1) { printf ("Sorry, i don't take command line arguments.\n"); exit(-1); } else { t_node n; // well heluuu there :) init(); get_distances(); n = (t_node)malloc(sizeof(struct s_node)); n->path =(int *)malloc (d * sizeof (int)); n->path[1] = 1; n->level = 1 ; n->bound = get_bound(n); get_paths(n); } ////printf ( "\n"); // printf ("\n"); // printf ("# of tours %d\n",count_tours); // printf ("* represents a non-recursive call.\n"); // printf ("** represents a recursive call.\n"); printf ( "%f\n",best_length); for (i=1;i<=d;i++) { printf("%f %f\n",f1[best_path[i]],f2[best_path[i]]) ; } //echo best path }
int ObSSTableBlockIndexMgr::search_one_block_by_key( const ObRowkey& key, const SearchMode mode, ObBlockPositionInfo& pos_info) const { int ret = OB_SUCCESS; Bound bound; const_iterator find_it = NULL; if (is_regular_mode(mode) && NULL == key.ptr()) { TBSYS_LOG(ERROR, "INVALID ARGUMENT"); ret = OB_INVALID_ARGUMENT; } else if (OB_SUCCESS != (ret = get_bound(bound))) { TBSYS_LOG(ERROR, "get bound error"); } else if (OB_SUCCESS != (ret = find_by_key(key, mode, bound, find_it))) { TBSYS_LOG(ERROR, "find by key error"); } else { if (NULL != find_it && find_it < bound.end_ && find_it >= bound.begin_) { pos_info.offset_ = find_it->block_data_offset_; pos_info.size_ = (find_it + 1)->block_data_offset_ - find_it->block_data_offset_; } } return ret; }
int ObSSTableBlockIndexMgr::search_batch_blocks_by_key( const ObRowkey& key, const SearchMode mode, ObBlockPositionInfos& pos_info) const { int ret = OB_SUCCESS; Bound bound; const_iterator find_it = NULL; ObRowkey end_key; if (is_regular_mode(mode) && NULL == key.ptr()) { TBSYS_LOG(ERROR, "is regular mode, but key==NULL"); ret = OB_INVALID_ARGUMENT; } else if (OB_SUCCESS != (ret = get_bound(bound))) { TBSYS_LOG(ERROR, "get bound error"); } else if (OB_SUCCESS != (ret = find_by_key(key, mode, bound, find_it))) { TBSYS_LOG(ERROR, "find by key error"); } else if (OB_SUCCESS != (ret = store_block_position_info( find_it, bound, mode, end_key, pos_info))) { TBSYS_LOG(ERROR, "store block position info error"); } else { } return ret; }
BOOL BackgroundObject::shrink_to_fit() { BOOL shrunk = FALSE; /* // Get the graphic record. */ GraphicPtr graphic; ERRORCODE error; PBOX org_bound = get_bound(); if ((graphic = (GraphicPtr)database->get_record(get_graphic_record(), &error, RECORD_TYPE_Graphic)) != NULL) { if (graphic->record.type == GRAPHIC_TYPE_CGM) { CGMHelperPtr helper = (CGMHelperPtr)graphic->my_little_helper(); USHORT dx, dy; PCOORD bdx, bdy; CGM_POINT ext_min = helper->record.extended_min; CGM_POINT ext_max = helper->record.extended_max; CGM_POINT min = helper->record.metafile_min; CGM_POINT max = helper->record.metafile_max; dx = ext_max.x - ext_min.x; dy = ext_max.y - ext_min.y; bdx = org_bound.x1 - org_bound.x0; bdy = org_bound.y1 - org_bound.y0; if (dx != 0 && dy != 0) { /* Renormalize for extended space. */ max.x -= (ext_min.x + min.x); min.x = -ext_min.x; max.y -= (ext_min.y + min.y); min.y = -ext_min.y; /* The extended min and max are normalized by the metafile min. */ PBOX bound; bound.x1 = org_bound.x0 + scale_pcoord(max.x, bdx, dx); bound.x0 = org_bound.x0 + scale_pcoord(min.x, bdx, dx); bound.y1 = org_bound.y0 + scale_pcoord(max.y, bdy, dy); bound.y0 = org_bound.y0 + scale_pcoord(min.y, bdy, dy); set_bound(bound); shrunk = TRUE; } } graphic->release(); } return shrunk; }
t_node give_birth(t_node parent) { t_node n; n=(t_node)malloc(sizeof(struct s_node)); n->level = parent->level+1 ; // printf ( "parentn->level = %d\n",parent->level ) ; // printf ( "n->level = %d\n",n->level ) ; n->bound = get_bound(n); n->path =(int *)malloc ((d)*sizeof(int)); return n; }
void get_paths(t_node node) { int i,j; //printf ("*"); if (is_promising(node)) { //printf ("<is promising> " ); if (is_tour(node)) { count_tours++; //printf ("<is a tour> " ); node->level = node->level+1; // dr. delcher, i completed the path. node->path[node->level] = node->path[1]; get_best_path(node); // keep track of the best path // for (i = 1 ; i <= node->level; i++) { printf ("%d ",node->path[i]); } printf (" \n"); } else // for each child of n { for (i = 2; i <= d ; i ++ ) { if (!in_path(i,node)) { t_node child; child=give_birth(node); child->bound = get_bound(node) ; // child->level = node->level+1 ; child=give_path(node,child); child->path[child->level] = i; // add this node to the path for (j=1;j<=( child->level );j++) { //printf ("%d ",child->path[j]); } // //printf ("\n"); //printf ("\n"); //printf ("**"); if (is_promising(child)) { // printf ("IN "); get_paths(child); // printf ("OUT "); } } } } } }
int ObSSTableBlockIndexMgr::search_batch_blocks_by_range( const ObNewRange& range, const bool is_reverse_scan, ObBlockPositionInfos& pos_info) const { int ret = OB_SUCCESS; Bound bound; const_iterator find_it = NULL; common::ObRowkey search_key; common::ObRowkey end_key; SearchMode mode = OB_SEARCH_MODE_MIN_VALUE; if (OB_SUCCESS != (ret = get_bound(bound))) { TBSYS_LOG(ERROR, "get bound error"); } else if (OB_SUCCESS != (ret = trans_range_to_search_key( range, is_reverse_scan, search_key, mode))) {//基准key TBSYS_LOG(ERROR, "trans range to search key error"); } else if (OB_SUCCESS != (ret = find_by_key(search_key, mode, bound, find_it))) { //TBSYS_LOG(ERROR, "find by key error"); } else { if (is_reverse_scan && (!range.border_flag_.is_min_value())) { end_key = range.start_key_; } else if (!is_reverse_scan && (!range.border_flag_.is_max_value())) { end_key = range.end_key_; } if (OB_SUCCESS != (ret = store_block_position_info( find_it, bound, mode, end_key, pos_info))) { TBSYS_LOG(WARN, "stroe block position info error:ret=%d", ret); } } return ret; }
UpdateStatePtr PatternObject::update(RedisplayContextPtr rc, PBOX_PTR extent, LPRECT clip, UpdateStatePtr ustate, REFRESH_TYPE refresh_type) { PBOX bound; RECT r; HDC hdc = rc->destination_hdc; if (rc->want_update_names()) { rc->update_name(this, NULL); } /* Convert the bound to destination coordinates. */ bound = get_bound(); rc->pbox_to_screen(&bound, TRUE); if (rc->convert_pbox(&bound, &r, clip)) { HBRUSH hBrush; RGBCOLOR color = rgbcolor_from_color(precord.bcolor); SHORT red = RED_COMPONENT_OF(color), green = GREEN_COMPONENT_OF(color), blue = BLUE_COMPONENT_OF(color); if (precord.pattern > 100) { /* Special pattern. */ hBrush = CreateHatchBrush(precord.pattern == 101 ? HS_VERTICAL /* Horizontal cut pattern */ : HS_HORIZONTAL, /* Vertical cut pattern */ RGB(red, green, blue)); /* Color */ } else { SHORT pattern = 100 - precord.pattern; /* // Handle the pattern: // // precord.pattern color // --------------- ----- // 0 bcolor (default) // 100 WHITE // the rest lerp() // // It is the INTENSITY of color, in a CMYK sense. // // (Note that 'pattern' equals 100-precord.pattern at this point.) */ if (pattern != 100) { red = 255-scale_number(255-red, pattern, 100); green = 255-scale_number(255-green, pattern, 100); blue = 255-scale_number(255-blue, pattern, 100); } hBrush = CreateSolidBrush(RGB(red, green, blue)); } HBRUSH hOldBrush = (HBRUSH)SelectObject(hdc, hBrush); rc->toggle(FALSE, &r); PatBlt(hdc, r.left, r.top, r.right-r.left, r.bottom-r.top, PATCOPY); rc->toggle(TRUE, &r); DeleteObject(SelectObject(hdc, hOldBrush)); } return NULL; }
void n3d_raster_rgb_raster( const n3d_rasterizer_t::state_t& s, const n3d_rasterizer_t::triangle_t& t, void* user) { // bin / triangle intersection boundary const aabb_t bound = get_bound(s, t); const float offsetx = s.offset_.x + bound.x0; const float offsety = s.offset_.y + bound.y0; const uint32_t pitch = s.pitch_; // ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- // barycentric interpolants vec3f_t bc_vy = { t.v_ [e_attr_b0], t.v_ [e_attr_b1], t.v_ [e_attr_b2] }; const vec3f_t bc_sx = { t.sx_[e_attr_b0], t.sx_[e_attr_b1], t.sx_[e_attr_b2] }; const vec3f_t bc_sy = { t.sy_[e_attr_b0], t.sy_[e_attr_b1], t.sy_[e_attr_b2] }; // shift to offset bc_vy += bc_sx * offsetx; bc_vy += bc_sy * offsety; // ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- // colour interpolants vec3f_t cl_vy = { t.v_ [6], t.v_ [7], t.v_ [8] }; const vec3f_t cl_sx = { t.sx_[6], t.sx_[7], t.sx_[8] }; const vec3f_t cl_sy = { t.sy_[6], t.sy_[7], t.sy_[8] }; // shift to offset cl_vy += cl_sx * offsetx; cl_vy += cl_sy * offsety; // ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- // 1/w interpolants float w_vy = t.v_ [e_attr_w]; const float w_sx = t.sx_[e_attr_w]; const float w_sy = t.sy_[e_attr_w]; // shift to offset w_vy += w_sx * offsetx; w_vy += w_sy * offsety; // ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- uint32_t* dst = s.target_[n3d_target_pixel].uint32_; float* depth = s.target_[n3d_target_depth].float_; // pre step the buffers to x/y location dst += pitch * bound.y0; depth += pitch * bound.y0; // y axis for (int32_t y = bound.y0; y < bound.y1; ++y) { vec3f_t bc_vx = bc_vy; vec3f_t cl_vx = cl_vy; float w_vx = w_vy; // x axis for (int32_t x = bound.x0; x < bound.x1; ++x) { // check if inside triangle if (bc_vx.x >= 0.f && bc_vx.y >= 0.f && bc_vx.z >= 0.f) { // depth test (w buffering) if (w_vx > depth[x]) { // find fragment colour const float r = cl_vx.x / w_vx; const float g = cl_vx.y / w_vx; const float b = cl_vx.z / w_vx; // update colour buffer dst[x] = rgb(r, g, b); // update (w) depth buffer depth[x] = w_vx; } } // step on x axis bc_vx += bc_sx; cl_vx += cl_sx; w_vx += w_sx; } // for (x axis) // step on y axis bc_vy += bc_sy; cl_vy += cl_sy; w_vy += w_sy; // step the buffers dst += pitch; depth += pitch; } // for (y axis) }
int ObSSTableBlockIndexMgr::search_batch_blocks_by_offset( const int64_t offset, const SearchMode mode, ObBlockPositionInfos& pos_info) const { int ret = OB_SUCCESS; Bound bound; ObRowkey key; if (0 > offset) { ret = OB_INVALID_ARGUMENT; TBSYS_LOG(WARN, "invalid argument"); } else if (OB_SUCCESS != (ret = get_bound(bound))) { TBSYS_LOG(WARN, "get bound error:ret=%d", ret); } else { ObSSTableBlockIndex item; item.block_data_offset_ = offset; item.block_endkey_offset_ = 0; const_iterator find_it = std::lower_bound(bound.begin_, bound.end_, item); if (OB_SUCCESS != (ret = check_border(find_it, bound, mode))) {//check right border //TBSYS_LOG(WARN, "check border error"); } else { switch (mode) { case OB_SEARCH_MODE_GREATER_THAN: if (*find_it == item) { ++ find_it; } if (find_it >= bound.end_) { ret = OB_BEYOND_THE_RANGE; } break; case OB_SEARCH_MODE_EQUAL: if (*find_it == item) { pos_info.block_count_ = 1; } else { ret = OB_BEYOND_THE_RANGE; } break; case OB_SEARCH_MODE_GREATER_EQUAL: break; case OB_SEARCH_MODE_LESS_THAN: find_it --; case OB_SEARCH_MODE_LESS_EQUAL: if (*find_it != item) { find_it --; } if (find_it < bound.begin_) { ret = OB_BEYOND_THE_RANGE; } break; default: ret = OB_SEARCH_MODE_NOT_IMPLEMENT; break; }//end switch } if (OB_SUCCESS == ret) { ret = store_block_position_info(find_it, bound, mode, key, pos_info); } } return ret; }