コード例 #1
0
ファイル: vc.cpp プロジェクト: pranamibhatt/booksim
void VC::AddFlit( Flit *f )
{
  assert(f);

  if(_expected_pid >= 0) {
    if(f->pid != _expected_pid) {
      ostringstream err;
      err << "Received flit " << f->id << " with unexpected packet ID: " << f->pid 
	  << " (expected: " << _expected_pid << ")";
      Error(err.str());
    } else if(f->tail) {
      _expected_pid = -1;
    }
  } else if(!f->tail) {
    _expected_pid = f->pid;
  }
    
  // update flit priority before adding to VC buffer
  if(_pri_type == local_age_based) {
    f->pri = numeric_limits<int>::max() - GetSimTime();
    assert(f->pri >= 0);
  } else if(_pri_type == hop_count_based) {
    f->pri = f->hops;
    assert(f->pri >= 0);
  }

  _buffer.push_back(f);
  UpdatePriority();
}
コード例 #2
0
bool inpainting::Process(void) {
  char path[200];
  char temp[30];
  Convert2Gray();
  DrawBoundary();
  DrawSource();
  memset(m_pri, 0, m_width*m_height*sizeof(double));
  for(int j= m_top; j <= m_bottom; ++j) {
      for(int i = m_left; i <= m_right; ++i) {
        if(m_mark[j * m_width + i] ==  SOURCE) {
            number_to_fill_y[j] += 1;
            number_to_fill_x[i] += 1;
          if(number_to_fill_y[j]>max_width) {
             max_width=number_to_fill_y[j];
          }
          if(number_to_fill_x[i]>max_height) {
             max_height=number_to_fill_x[i];
          }
         }
        if(m_mark[j * m_width + i] == BOUNDARY) {
            m_pri[j * m_width + i] = ComputePriority(i,j);
            number_to_fill_y[j] += 1;
            number_to_fill_x[i] += 1;
        }
    }
  }
  int count=0;
  while(TargetExist()) {
    count++;
    double max_pri = 0;
    int pri_x,pri_y;
    for(int j= m_top; j <= m_bottom; ++j) {
                for(int i = m_left; i <= m_right; ++i) {
                  if(m_mark[j * m_width + i] == BOUNDARY&&m_pri[j * m_width + i]>max_pri) {
                    pri_x = i;
                    pri_y = j;
                    max_pri = m_pri[j * m_width + i];
                  }
                }
    }
    int patch_x, patch_y;
    PatchTexture(pri_x, pri_y, patch_x, patch_y);
    FillTarget(pri_x, pri_y, patch_x,patch_y, ComputeConfidence(pri_x,pri_y));
    UpdateBoundary(pri_x, pri_y);
    UpdatePriority(pri_x, pri_y);
  }
  strcpy(path, save_path);
  strcat(path, ".bmp");
  Image->Save(path);
  return true;
}
コード例 #3
0
ファイル: vc.cpp プロジェクト: pranamibhatt/booksim
Flit *VC::RemoveFlit( )
{
  Flit *f = NULL;
  if ( !_buffer.empty( ) ) {
    f = _buffer.front( );
    _buffer.pop_front( );
    _last_id = f->id;
    _last_pid = f->pid;
    UpdatePriority();
  } else {
    Error("Trying to remove flit from empty buffer.");
  }
  return f;
}
コード例 #4
0
ファイル: SpriteSystem.cpp プロジェクト: RichardMarks/Pixie
void SpriteSystem::AddSpriteManager(SpriteManager* spriteManager)
	{
	// Check if the specified sprite manager is already in the manager list
	ArrayIterator<SpriteManager*> it(spriteManagers_);
	if (it.Find(spriteManager))
		{
		// Yes, it already exists, so just make sure the priority is correct
		UpdatePriority(spriteManager);
		return;
		}

	// No, it's not already in the manager list, so insert it now
	spriteManagers_.Add(spriteManager);

	// And make sure the priorities are correct
	UpdatePriority(spriteManager);


	// If there's no default sprite manager, make this one the default
	if (!defaultSpriteManager_)
		{
		defaultSpriteManager_=spriteManager;
		}
	}
コード例 #5
0
void ImposterNode::UpdateState()
{
	if(GetChildrenCount() > 0)
	{
		DVASSERT(GetChildrenCount() == 1);
		AABBox3 bbox = GetChild(0)->GetWTMaximumBoundingBoxSlow();
		Vector3 bboxCenter = bbox.GetCenter();
		float32 distanceSquare = (scene->GetCurrentCamera()->GetPosition() - bboxCenter).SquareLength();
		distanceSquare *= scene->GetCurrentCamera()->GetZoomFactor() * scene->GetCurrentCamera()->GetZoomFactor();
		
		Vector3 newDirection = scene->GetCurrentCamera()->GetPosition()-center;
		newDirection.Normalize();
		float32 dotProduct = newDirection.DotProduct(direction);

		switch(state)
		{
		case STATE_3D:
		{
			if(distanceSquare > TOGGLE_SQUARE_DISTANCE)
			{
				UpdatePriority(distanceSquare, 0);
				AskForRedraw();
			}
			else
			{
				isReady = false;
			}
		}
		break;

		case STATE_QUEUED:
		{
			if(IsAngleOrRangeChangedEnough(distanceSquare, dotProduct))
			{
				UpdatePriority(distanceSquare, dotProduct);
				manager->UpdateQueue(this);
			}
		}
		break;

		case STATE_IMPOSTER:
		{
			if(distanceSquare < TOGGLE_SQUARE_DISTANCE)
			{
				isReady = false;
				state = STATE_3D;
				manager->RemoveFromQueue(this);
				break;
			}

			if(IsAngleOrRangeChangedEnough(distanceSquare, dotProduct))
			{
				UpdatePriority(distanceSquare, dotProduct);
				AskForRedraw();
			}
		}
		break;

		case STATE_REDRAW_APPROVED:
		{
		}
		break;
		}
	}
}
コード例 #6
0
std::string inpainting::Process(void) {
  char path[200];
  char temp[30];
  pix_to_inpaint = 0;
  pix_been_inpainted = 0;
  Convert2Gray();
  DrawBoundary();
  DrawSource();
  memset(m_pri, 0, m_width*m_height*sizeof(double));
  for (int j= m_top; j <= m_bottom; ++j) {
      for (int i = m_left; i <= m_right; ++i) {
        if (m_mark[j * m_width + i] == BOUNDARY) {
          m_pri[j * m_width + i] = ComputePriority(i, j);
        }
    }
  }
  int count = 0;
  count_pic =1;
  int temp_color = 0;
  int temp_color2 = 0;
  int *temp_colors = new int[LOOKUP];
  int *temp_colors_2 = new int[LOOKUP];
  int **most_similar_patch = new int*[LOOKUP];
  for (int o = 0; o < LOOKUP; ++o) {
      most_similar_patch[o] = new int[2];
  }
  int **most_similar_patch_2 = new int*[LOOKUP];
  for (int o = 0; o < LOOKUP; ++o) {
      most_similar_patch_2[o] = new int[2];
  }
  int start = clock();
  int *colum_in_height = new int[m_height];
  for (int i = 0; i < m_height; ++i) {
    colum_in_height[i] = 0;
  }
  int *colum_in_width = new int[m_width];
  for (int i = 0; i < m_width; ++i) {
    colum_in_width[i] = 0;
  }
  double max_pri = 0;
  int pri_x, pri_y;
  int patch_x, patch_y;
  while (TargetExist()) {
    count++;
    count_pic++;
    max_pri = 0;
    for (int j= 0; j < m_height; ++j) {
      for (int i = 0; i < m_width; ++i) {
        colum_in_height[j]++;
        colum_in_width[i]++;
        if (m_mark[j * m_width + i] == BOUNDARY && m_pri[j * m_width + i] > max_pri) {
            pri_x = i;
            pri_y = j;
            max_pri = m_pri[j * m_width + i];
            colum_in_height[j]--;
            colum_in_width[i]--;
        }
        if (m_mark[j * m_width + i] == TARGET) {
            colum_in_height[j]--;
            colum_in_width[i]--;
        }
      }
    }
  height_diff = m_bottom - m_top + 1;
  width_diff = m_right - m_left + 1;
  //  缩小搜索框
  for (int i = m_top; i <= m_bottom; ++i) {
    if (colum_in_height[i] == width_diff) {
      m_top++;
    } else {
      break;
    }
  }
  for (int i = m_bottom-1; i >= m_top; --i) {
     if (colum_in_height[i] == width_diff) {
       m_bottom--;
     } else {
       break;
     }
  }
  for (int i = m_left; i <= m_right; ++i) {
    if (colum_in_width[i] == height_diff) {
      m_left++;
    } else {
      break;
    }
  }
  for (int i = m_right; i >= m_left; --i) {
    if (colum_in_width[i] == height_diff) {
      m_right--;
    } else {
      break;
    }
  }
    PatchTexture(pri_x, pri_y, patch_x, patch_y, most_similar_patch, most_similar_patch_2);
    FillTarget(pri_x, pri_y, patch_x, patch_y, ComputeConfidence(pri_x, pri_y));
    UpdateBoundary(pri_x, pri_y);
    UpdatePriority(pri_x, pri_y);
    char str[10];
    sprintf(str, "%d", count);
    strcpy(path, save_path);
    strcat(path, str);
    strcat(path, ".bmp");
    //  cout<<" path = "<<path<<endl;
    //  Image -> save(path);

    //  下面的是为了画出最匹配的20个点的图片的中间步骤
    /*temp_color = Image->pixel(pri_x,pri_y);
    temp_color2 = Image->pixel(patch_x,patch_y);
    for(int o=0;o<LOOKUP;++o) {
        temp_colors[o]=Image->pixel(most_similar_patch[o][0],most_similar_patch[o][1]);
       // temp_colors_2[o]=Image->pixel(most_similar_patch_2[o][0],most_similar_patch_2[o][1]);
        Image -> setPixel(most_similar_patch[o][0],most_similar_patch[o][1],MARK);
       // Image -> setPixel(most_similar_patch_2[o][0],most_similar_patch_2[o][1],MARK2);

    }
    Image -> setPixel(pri_x,pri_y,RED);
    Image -> setPixel(patch_x,patch_y,BLUE);
    //cout<<" patch_x = "<<patch_x<<endl;
    //cout<<" patch_y = "<<patch_y<<endl;
    Image -> save(path);

    for(int o=0;o<LOOKUP;++o) {
        Image -> setPixel(most_similar_patch[o][0],most_similar_patch[o][1],temp_colors[o]);
      //  Image -> setPixel(most_similar_patch_2[o][0],most_similar_patch_2[o][1],temp_colors_2[o]);

    }
    Image -> setPixel(pri_x,pri_y,temp_color);
    Image -> setPixel(patch_x,patch_y,temp_color2);*/
  }
  int end = clock();
  strcpy(path, save_path);
  strcat(path, ".bmp");
  //  Image->Save(path);
  std::string res = path;
  return res;
}
コード例 #7
0
void ControlGroup::Disable()
{
    MojLogTrace(s_log);
    UpdatePriority();
}