Esempio n. 1
0
bool checkTeminationConditions(Plan& P, ADDvector& x, ADDvector& lambda, ADDvector& nu, bool phase1) {
	double epsilon_feas = .01;
	double epsilon = .01;
	ADDvector r_t = R_T(P, x, lambda, nu, phase1);
	ADD dist_r_pri = CalcDist(r_t, 0, x.count());
	ADD dist_r_dual = CalcDist(r_t, x.count() + lambda.count(), r_t.count());
	ADD lambdaTest = dotProduct(-P.F(x, phase1), lambda);
	return maximum(dist_r_pri) < epsilon_feas && 
		   maximum(dist_r_dual) < epsilon_feas && 
		   maximum(lambdaTest) < epsilon;
}
Esempio n. 2
0
/*Funcao auxiliar usada internamente para checar se as duas entidades passadas irao colidir no proximo ciclo logico.
  Assume que uma delas esta parada, e a outra se mexendo, entao preve onde essa entidade estara e se estara proxima
  da outra entidade.*/
int checaColisao( Entity entQueMove, Entity entParada, double DeltaTime )
{
	Vetor VetAuxQueMove, VetAuxParada;
	double RaioDoCirculo, dist;

	atualizaPosicao(entQueMove, DeltaTime);
	VetAuxQueMove = getPosicao( entQueMove );

	atualizaPosicao(entParada, DeltaTime);
	VetAuxParada = getPosicao( entParada );

	RaioDoCirculo = /*DeltaTime*VETORmodulo( getVelocidade( entQueMove ) ) +*/ getRaio(entQueMove) + getRaio(entParada) + OFFSET_RAIO;

	dist = CalcDist( VetAuxQueMove, VetAuxParada );

    atualizaPosicao(entParada, -DeltaTime);
	atualizaPosicao(entQueMove, -DeltaTime);


	if (dist <= RaioDoCirculo)
	{
	    if ( checkIntersecaoDeFormas(entQueMove, entParada) == 1)
            return 1;
	}
	return 0;
}
Esempio n. 3
0
void LargeVis::compute_similarity()
{
    printf("Computing similarities ......"); fflush(stdout);
	n_edge = 0;
	head = new long long[n_vertices];
	long long i, x, y, p, q;
	real sum_weight = 0;
	for (i = 0; i < n_vertices; ++i) head[i] = -1;
	for (x = 0; x < n_vertices; ++x)
	{
		for (i = 0; i < knn_vec[x].size(); ++i)
		{
			edge_from.push_back((int)x);
			edge_to.push_back((int)(y = knn_vec[x][i]));
			edge_weight.push_back(CalcDist(x, y));
			next.push_back(head[x]);
			reverse.push_back(-1);
			head[x] = n_edge++;
		}
	}
    delete[] vec; vec = NULL;
    delete[] knn_vec; knn_vec = NULL;
	pthread_t *pt = new pthread_t[n_threads];
	for (int j = 0; j < n_threads; ++j) pthread_create(&pt[j], NULL, LargeVis::compute_similarity_thread_caller, new arg_struct(this, j));
	for (int j = 0; j < n_threads; ++j) pthread_join(pt[j], NULL);
	delete[] pt;

	pt = new pthread_t[n_threads];
	for (int j = 0; j < n_threads; ++j) pthread_create(&pt[j], NULL, LargeVis::search_reverse_thread_caller, new arg_struct(this, j));
	for (int j = 0; j < n_threads; ++j) pthread_join(pt[j], NULL);
	delete[] pt;

	for (x = 0; x < n_vertices; ++x)
	{
		for (p = head[x]; p >= 0; p = next[p])
		{
			y = edge_to[p];
			q = reverse[p];
			if (q == -1)
			{
				edge_from.push_back((int)y);
				edge_to.push_back((int)x);
				edge_weight.push_back(0);
				next.push_back(head[y]);
				reverse.push_back(p);
				q = reverse[p] = head[y] = n_edge++;
			}
			if (x > y){
				sum_weight += edge_weight[p] + edge_weight[q];
				edge_weight[p] = edge_weight[q] = (edge_weight[p] + edge_weight[q]) / 2;
			}
		}
	}
	printf(" Done.\n");
}
Esempio n. 4
0
/*Funcao auxiliar usada internamente para comparar uma entidade com um vetor posicao, retornando 0 caso a entidade passada esteja
  posicionada no mesmo vetor.*/
int compareEntityPos(Item arg, Item ent_i)
{
	Vetor pos, entPos;
	Entity ent;

	pos = (Vetor)arg;
	ent = (Entity)ent_i;
	entPos = getPosicao(ent);

	if ( CalcDist( pos, entPos) <= getRaio(ent)+10 )
		return 0;
	return 1;
}
Esempio n. 5
0
void LargeVis::propagation_thread(int id)
{
	long long lo = id * n_vertices / n_threads;
	long long hi = (id + 1) * n_vertices / n_threads;
	int *check = new int[n_vertices];
	std::priority_queue< pair<real, int> > heap;
	long long x, y, i, j, l1, l2;
	for (x = 0; x < n_vertices; ++x) check[x] = -1;
	for (x = lo; x < hi; ++x)
	{
		check[x] = x;
		std::vector<int> &v1 = old_knn_vec[x];
		l1 = v1.size();
		for (i = 0; i < l1; ++i)
		{
			y = v1[i];
			check[y] = x;
			heap.push(std::make_pair(CalcDist(x, y), y));
			if (heap.size() == n_neighbors + 1) heap.pop();
		}
		for (i = 0; i < l1; ++i)
		{
			std::vector<int> &v2 = old_knn_vec[v1[i]];
			l2 = v2.size();
			for (j = 0; j < l2; ++j) if (check[y = v2[j]] != x)
			{
				check[y] = x;
				heap.push(std::make_pair(CalcDist(x, y), (int)y));
				if (heap.size() == n_neighbors + 1) heap.pop();
			}
		}
		while (!heap.empty())
		{
			knn_vec[x].push_back(heap.top().second);
			heap.pop();
		}
	}
	delete[] check;
}
int BodyCalib::CalcInlierCount(cv::Mat RT, float threshold, float *averError){
	int iCount = 0;
	*averError = 0.0f;

	for(int i = 0; i < DataSet.size(); i++){
		float DataDist = CalcDist(RT, i);
		*averError += DataDist;

		if(DataDist < threshold)
			iCount++;
	}

	*averError /= (float)DataSet.size();

	return iCount;
}
int CalcDistAzimuth( double hostLat,
                    double hostLon,
                    double hostHeading,
                    double povLat,
                    double povLon,
                    double povHeading,
                    double *pRange,
                    double *pAzimuth )
{
	int	   iResult = 0 ;

	iResult |= CalcDist( hostLat, hostLon, povLat, povLon, pRange ) ;

	iResult |= CalcAzimuth( hostLat, hostLon, hostHeading, povLat, povLon, povHeading, pAzimuth ) ;

	return iResult ;
}
Esempio n. 8
0
void LargeVis::test_accuracy()
{
	long long test_case = 100;
	std::priority_queue< pair<real, int> > *heap = new std::priority_queue< pair<real, int> >;
	long long hit_case = 0, i, j, x, y;
	for (i = 0; i < test_case; ++i)
	{
		x = floor(gsl_rng_uniform(gsl_r) * (n_vertices - 0.1));
		for (y = 0; y < n_vertices; ++y) if (x != y)
		{
			heap->push(std::make_pair(CalcDist(x, y), y));
			if (heap->size() == n_neighbors + 1) heap->pop();
		}
		while (!heap->empty())
		{
			y = heap->top().second;
			heap->pop();
			for (j = 0; j < knn_vec[x].size(); ++j) if (knn_vec[x][j] == y)
				++hit_case;
		}
	}
    delete heap;
	printf("Test knn accuracy : %.2f%%\n", hit_case * 100.0 / (test_case * n_neighbors));
}
/* Take candiate with best error */
void CalcSqrDifferenceAndTakeBest( int *pCurrFiltImgs_A16s, int *pCurrFiltImgs_B16s,
                                   unsigned int *pBestErrorsImg32u, unsigned int *pBestMapping32u, 
                                   unsigned int nCurrCandMapping32u,unsigned int nCurIterOffset32u,  
                                   int nKernels, int hA , int wA , int kOfKNN) 
{
      unsigned int nCurError32u , ReminderBestError;
      int index, worstInd;
      unsigned int A_FiltersPtr , B_FiltersPtr;
      unsigned int worstError , CurrIterrationConv , Temp;

      // 1) a] check if candidate already appears in list - if so we don't bother calculating its error
      //      b] find the index of the current worst candidate. (this is the candidate we will replace)

	  Temp = CurrIterrationConv = CONV_TO_LINEAR_MAPPING(nCurIterOffset32u,kOfKNN);
      
	  for (index = 0; index < kOfKNN; index++) 
      {
            if (pBestMapping32u[Temp++] == nCurrCandMapping32u)
                return;
	  }
	
	  Temp = CurrIterrationConv;
      worstError = 0; worstInd = 1;
	  nCurError32u = 0;
	  for (index = 0; index < kOfKNN; index++) 
      {
            if (pBestErrorsImg32u[Temp] > worstError)
            {
                worstError = pBestErrorsImg32u[Temp];
                worstInd = index;
            }
			Temp++;
      }

      // 2) calculate the estimated error 
      A_FiltersPtr = nKernels * nCurIterOffset32u;
      B_FiltersPtr = nKernels * nCurrCandMapping32u;
	  ReminderBestError = worstError;
      // first WH kernel (DC)
      nCurError32u = CalcDist(pCurrFiltImgs_A16s,pCurrFiltImgs_B16s,A_FiltersPtr, B_FiltersPtr);
      if (nCurError32u > ReminderBestError)
         return;
      
      A_FiltersPtr++; B_FiltersPtr++;
	  ReminderBestError -= nCurError32u;
      // all the rest (in pairs)
      for (index = 1; (index < nKernels-1); index = index + 2)
      {
            nCurError32u = CalcDist(pCurrFiltImgs_A16s,pCurrFiltImgs_B16s,A_FiltersPtr, B_FiltersPtr);
            A_FiltersPtr++; B_FiltersPtr++;
            nCurError32u += CalcDist(pCurrFiltImgs_A16s,pCurrFiltImgs_B16s,A_FiltersPtr, B_FiltersPtr);
            A_FiltersPtr++; B_FiltersPtr++;
            if (nCurError32u > ReminderBestError)
                  return;
			ReminderBestError -= nCurError32u;
      }          
      if ((nKernels & 1) == 0) //Even number of kernels, check lust o
      {
            nCurError32u = CalcDist(pCurrFiltImgs_A16s,pCurrFiltImgs_B16s,A_FiltersPtr, B_FiltersPtr);
            if (nCurError32u > ReminderBestError)
                  return;
      }
      
	  Temp = CurrIterrationConv + worstInd;
      // 3)  move the contents of the first candidate to the worst position
      pBestErrorsImg32u[Temp] = pBestErrorsImg32u[CurrIterrationConv] ;
      pBestMapping32u[Temp]   = pBestMapping32u[CurrIterrationConv];


      // 4) place the new error and candidate in the first  position (which is vacant now)
      pBestErrorsImg32u[CurrIterrationConv]   =  (worstError - ReminderBestError);
      pBestMapping32u[CurrIterrationConv]     = nCurrCandMapping32u;
/*	
	  // Make sure not to check inverse on the boundaries
	  Temp = nCurIterOffset32u % hA;
      if ((nCurIterOffset32u < hA) || (nCurIterOffset32u > hA*(wA-1)) || (Temp == 1) || (Temp == 0))
		  return;
	  // 5) For this version, the assumption is that both A and B images are the same
	  //    Therefore if b is the match for patch a, than also a is a match for patch b, since this is the same image
	  CompareDistToInverseCandidate(nCurError32u, pBestErrorsImg32u, pBestMapping32u, nCurIterOffset32u , nCurrCandMapping32u ,kOfKNN);
*/
}
Esempio n. 10
0
/* Route une piste du BOARD.
	Parametres:
		1 face / 2 faces ( 0 / 1)
		coord source (row,col)
		coord destination (row,col)
		net_code
		pointeur sur le chevelu de reference

	Retourne :
		SUCCESS si route trouvee
		TRIVIAL_SUCCESS si pads connectes par superposition ( pas de piste a tirer)
		NOSUCCESS si echec
		STOP_FROM_ESC si Escape demande
		ERR_MEMORY defaut alloc RAM
*/
static int Route_1_Trace(WinEDA_PcbFrame * pcbframe, wxDC * DC,
				int two_sides, int row_source,int col_source,
				int row_target,int col_target, CHEVELU * pt_chevelu )
{
int  r, c, side , d, apx_dist, nr, nc;
int result, skip;
int i;
LISTE_PAD * ptr;
long curcell, newcell, buddy, lastopen, lastclos, lastmove;
int newdist, olddir, _self;
int current_net_code;
int marge, via_marge;
int pad_masque_layer_s; /* Masque des couches appartenant au pad de depart */
int pad_masque_layer_e; /* Masque des couches appartenant au pad d'arrivee */
int masque_layer_TOP = g_TabOneLayerMask[Route_Layer_TOP];
int masque_layer_BOTTOM = g_TabOneLayerMask[Route_Layer_BOTTOM];
int masque_layers;		/* Masque des 2 couches de routage */
int tab_mask[2];		/* permet le calcul du Masque de la couche en cours
							de tst (side = TOP ou BOTTOM)*/
int start_mask_layer = 0;
wxString msg;
	
	result = NOSUCCESS;

	marge = g_DesignSettings.m_TrackClearence + (g_DesignSettings.m_CurrentTrackWidth / 2);
	via_marge = g_DesignSettings.m_TrackClearence + (g_DesignSettings.m_CurrentViaSize / 2);

	/* clear direction flags */
	i = Nrows * Ncols * sizeof(char);
	memset(Board.m_DirSide[TOP], FROM_NOWHERE, i );
	memset(Board.m_DirSide[BOTTOM], FROM_NOWHERE, i );

	lastopen = lastclos = lastmove = 0;

	/* Init tab_masque[side] pour tests de fin de routage */
	tab_mask[TOP] = masque_layer_TOP;
	tab_mask[BOTTOM] = masque_layer_BOTTOM;
	/* Init masque des couches actives */
	masque_layers = masque_layer_TOP | masque_layer_BOTTOM;

	pt_cur_ch = pt_chevelu;
	current_net_code = pt_chevelu->m_NetCode;
	pad_masque_layer_s = pt_cur_ch->pad_start->m_Masque_Layer;
	pad_masque_layer_e = pt_cur_ch->pad_end->m_Masque_Layer;

	/* Test 1 Si routage possible c.a.d si les pads sont accessibles
			sur les couches de routage */

	if( (masque_layers & pad_masque_layer_s) == 0 ) goto end_of_route;
	if( (masque_layers & pad_masque_layer_e) == 0 ) goto end_of_route;

	/* Test 2 Si routage possible c.a.d si les pads sont accessibles
		sur la grille de routage ( 1 point de grille doit etre dans le pad)*/
	{
	int cX = (pas_route * col_source) + pcbframe->m_Pcb->m_BoundaryBox.m_Pos.x;
	int cY = (pas_route * row_source) + pcbframe->m_Pcb->m_BoundaryBox.m_Pos.y;
	int dx = pt_cur_ch->pad_start->m_Size.x / 2;
	int dy = pt_cur_ch->pad_start->m_Size.y / 2;
	int px = pt_cur_ch->pad_start->m_Pos.x;
	int py = pt_cur_ch->pad_start->m_Pos.y;

	if ( ((pt_cur_ch->pad_start->m_Orient/900)&1) != 0 ) EXCHG(dx,dy) ;
	if ( (abs(cX - px) > dx ) || (abs(cY - py) > dy) ) goto end_of_route;

	cX = (pas_route * col_target) + pcbframe->m_Pcb->m_BoundaryBox.m_Pos.x;
	cY = (pas_route * row_target) + pcbframe->m_Pcb->m_BoundaryBox.m_Pos.y;
	dx = pt_cur_ch->pad_end->m_Size.x / 2;
	dy = pt_cur_ch->pad_end->m_Size.y / 2;
	px = pt_cur_ch->pad_end->m_Pos.x;
	py = pt_cur_ch->pad_end->m_Pos.y;
	if ( ((pt_cur_ch->pad_end->m_Orient/900)&1) != 0 ) EXCHG(dx,dy) ;

	if ( (abs(cX - px) > dx ) || (abs(cY - py) > dy) ) goto end_of_route;
	}

	/* Test du cas trivial: connection directe par superposition des pads */
	if( (row_source == row_target) && (col_source == col_target)
		&& ( pad_masque_layer_e & pad_masque_layer_s & g_TabAllCopperLayerMask[g_DesignSettings.m_CopperLayerCount-1]) )
	{
		result = TRIVIAL_SUCCESS;
		goto end_of_route;
	}



	/* Placement du bit de suppression d'obstacle relative aux 2 pads a relier */
	pcbframe->Affiche_Message( wxT("Gen Cells") );

	Place_1_Pad_Board(pcbframe->m_Pcb, pt_cur_ch->pad_start,CURRENT_PAD ,marge,WRITE_OR_CELL);
	Place_1_Pad_Board(pcbframe->m_Pcb, pt_cur_ch->pad_end, CURRENT_PAD ,marge,WRITE_OR_CELL);

	/* Regenere les barrieres restantes (qui peuvent empieter sur le placement
		des bits precedents) */
	ptr = (LISTE_PAD*) pcbframe->m_Pcb->m_Pads; i = pcbframe->m_Pcb->m_NbPads;
	for( ; i > 0 ; i-- , ptr++)
		{
		if((pt_cur_ch->pad_start != *ptr) && (pt_cur_ch->pad_end != *ptr) )
			{
			Place_1_Pad_Board(pcbframe->m_Pcb, *ptr, ~CURRENT_PAD,marge,WRITE_AND_CELL);
			}
		}

	InitQueue(); /* initialize the search queue */
	apx_dist = GetApxDist( row_source, col_source, row_target, col_target );

	/* Init 1ere recherche */
	if(two_sides)	/* orientation preferentielle */
		{
		if( abs(row_target-row_source) > abs(col_target-col_source) )
			{
			if( pad_masque_layer_s & masque_layer_TOP )
				{
				start_mask_layer = 2;
				if(SetQueue( row_source, col_source, TOP, 0, apx_dist,
							row_target, col_target ) == 0)
 					{
					return(ERR_MEMORY);
					}
				}
			if( pad_masque_layer_s & masque_layer_BOTTOM )
				{
				start_mask_layer |= 1;

				if( SetQueue( row_source, col_source, BOTTOM, 0, apx_dist,
							row_target, col_target ) == 0 )
					{
					return(ERR_MEMORY);
					}
				}
			}
		else
			{
			if( pad_masque_layer_s & masque_layer_BOTTOM )
				{
				start_mask_layer = 1;
				if( SetQueue( row_source, col_source, BOTTOM, 0, apx_dist,
							row_target, col_target ) == 0 )
					{
					return(ERR_MEMORY);
					}
				}
			if( pad_masque_layer_s & masque_layer_TOP )
				{
				start_mask_layer |= 2;

				if (SetQueue( row_source, col_source, TOP, 0, apx_dist,
							row_target, col_target ) == 0 )
					{
					return(ERR_MEMORY);
					}
				}
			}
		}

	else
		if( pad_masque_layer_s & masque_layer_BOTTOM )
			{
			start_mask_layer = 1;

			if( SetQueue( row_source, col_source, BOTTOM, 0, apx_dist,
							row_target, col_target ) == 0 )
				{
				return(ERR_MEMORY);
				}
			}

	/* search until success or we exhaust all possibilities */
	GetQueue( &r, &c, &side, &d, &apx_dist );
	for ( ; r != ILLEGAL; GetQueue( &r, &c, &side, &d, &apx_dist ) )
		{
		curcell = GetCell( r, c, side );
		if(curcell & CURRENT_PAD) curcell &= ~HOLE ;
		if( (r == row_target) && (c == col_target)  /* success si layer OK */
			&& ( tab_mask[side] & pad_masque_layer_e) )
			{
			/* Efface Liaison */
			GRSetDrawMode(DC, GR_XOR);
			GRLine(&pcbframe->DrawPanel->m_ClipBox, DC, segm_oX, segm_oY, segm_fX, segm_fY, WHITE);

			/* Generation de la trace */
			if( Retrace(pcbframe, DC, row_source, col_source,
						 row_target, col_target, side, current_net_code) )
				{
				result = SUCCESS;	/* Success : Route OK */
				}
			break;	/* Fin du routage */
			}
		/* report every 300 new nodes or so */
		if( (OpenNodes-lastopen > 300) || (ClosNodes-lastclos > 300) || (MoveNodes - lastmove > 300))
			{
			lastopen = (OpenNodes/300)*300; lastclos = (ClosNodes/300)*300;
			lastmove = (MoveNodes/300)*300;

			if( pcbframe->DrawPanel->m_AbortRequest )
				{
				result = STOP_FROM_ESC; break;
				}
			AFFICHE_ACTIVITE_ROUTE;
			}

		_self = 0;
		if (curcell & HOLE)
			{
			_self = 5;
			/* set 'present' bits */
			for (i = 0; i < 8; i++)
				{
				selfok2[i].present = 0;
				if( (curcell & selfok2[i].trace) ) selfok2[i].present = 1;
				}
			}

		for (i = 0; i < 8; i++) /* consider neighbors */
			{
			nr = r+delta[i][0]; nc = c+delta[i][1];

			/* off the edge? */
			if( nr < 0 || nr >= Nrows || nc < 0 || nc >= Ncols)
				continue; /* off the edge */

			if (_self == 5 && selfok2[i].present) continue;
			newcell = GetCell( nr, nc, side );
			if(newcell & CURRENT_PAD) newcell &= ~HOLE;

			/* check for non-target hole */
			if (newcell & HOLE)
				{
				if (nr != row_target || nc != col_target) continue;
				}

			/* check for traces */
			else if (newcell & HOLE & ~(newmask[i])) continue;

			/* check blocking on corner neighbors */
			if (delta[i][0] && delta[i][1])
				{
				/* check first buddy */
				buddy = GetCell( r+blocking[i].r1, c+blocking[i].c1, side );
				if(buddy & CURRENT_PAD) buddy &= ~HOLE;
				if (buddy & HOLE) continue;
//				if (buddy & (blocking[i].b1)) continue;
				/* check second buddy */
				buddy = GetCell( r+blocking[i].r2, c+blocking[i].c2, side );
				if(buddy & CURRENT_PAD) buddy &= ~HOLE;
				if (buddy & HOLE) continue;
//				if (buddy & (blocking[i].b2)) continue;
				}

			olddir = GetDir( r, c, side );
			newdist = d + CalcDist( ndir[i], olddir,
				(olddir == FROM_OTHERSIDE) ? GetDir( r, c, 1-side ) : 0 , side);

			/* if (a) not visited yet, or (b) we have */
			/* found a better path, add it to queue */
			if (!GetDir( nr, nc, side ))
				{
				SetDir( nr, nc, side, ndir[i] );
				SetDist( nr, nc, side, newdist );
				if( SetQueue( nr, nc, side, newdist,
					GetApxDist( nr, nc, row_target, col_target ),
						row_target, col_target ) == 0 )
					{
					return(ERR_MEMORY);
					}
				}

			else if (newdist < GetDist( nr, nc, side ))
				{
				SetDir( nr, nc, side, ndir[i] );
				SetDist( nr, nc, side, newdist );
				ReSetQueue( nr, nc, side, newdist,
					GetApxDist( nr, nc, row_target, col_target ),
					row_target, col_target );
				}
			}

		/** etude de l'autre couche **/
		if( (two_sides) && ! g_No_Via_Route )
			{
			olddir = GetDir( r, c, side );
			if (olddir == FROM_OTHERSIDE)
				continue; /* useless move, so don't bother */
			if (curcell) /* can't drill via if anything here */
				continue;
			/* check for holes or traces on other side */
			if( (newcell = GetCell( r, c, 1-side )) != 0 )
				continue;
			/* check for nearby holes or traces on both sides */
			for (skip = 0, i = 0; i < 8; i++)
				{
				nr = r + delta[i][0]; nc = c + delta[i][1];

				if (nr < 0 || nr >= Nrows || nc < 0 || nc >= Ncols)
					continue;  /* off the edge !! */

				if (GetCell( nr, nc, side )/* & blocking2[i]*/)
					{
					skip = 1; /* can't drill via here */
					break;
					}

				if (GetCell( nr, nc, 1-side )/* & blocking2[i]*/)
					{
					skip = 1; /* can't drill via here */
					break;
					}
				}

			if (skip) /* neighboring hole or trace? */
				continue; /* yes, can't drill via here */

			newdist = d + CalcDist( FROM_OTHERSIDE, olddir, 0 , side);

			/*  if (a) not visited yet,
				or (b) we have found a better path,
				add it to queue */
			if (!GetDir( r, c, 1-side ))
				{
				SetDir( r, c, 1-side, FROM_OTHERSIDE );
				SetDist( r, c, 1-side, newdist );
				if( SetQueue( r, c, 1-side, newdist, apx_dist, row_target,
								 col_target ) == 0 )
					{
					return(ERR_MEMORY);
					}
				}
			else if (newdist < GetDist( r, c, 1-side ))
				{
				SetDir( r, c, 1-side, FROM_OTHERSIDE );
				SetDist( r, c, 1-side, newdist );
				ReSetQueue( r, c, 1-side, newdist, apx_dist, row_target, col_target );
				}
			} /* Fin de l'exploration de l'autre couche */
		}

end_of_route:
	Place_1_Pad_Board(pcbframe->m_Pcb, pt_cur_ch->pad_start,~CURRENT_PAD ,marge,WRITE_AND_CELL);
	Place_1_Pad_Board(pcbframe->m_Pcb, pt_cur_ch->pad_end, ~CURRENT_PAD ,marge,WRITE_AND_CELL);

	AFFICHE_ACTIVITE_ROUTE;
	return(result);
}
Esempio n. 11
0
void Htile( bmpman &BMP1, bmpman &BMP2, bmpman &BMP24bpp, char tipe, bool rail, bool curves, float wr )
{
    int x, y;
    int perctg1, dist, changpixels1, changpixels2;
    RGBQUAD rgb_aux1, rgb_aux2, rgb_auxRES;

    //COPY BMP2 on BMP24bpp
    for( x = 0; x < BMP2.GetWidth(); x++) {
        for( y = 0; y < BMP2.GetWidth(); y++) {
            BMP24bpp.EnterRGBdata( x, y, BMP2.GetClr( x, y ) );
        }
    }
    cout << "Htile(" << tipe << ")";

    for( x = 0; x < BMP1.GetWidth(); x++) {
        for( y = 0; y < BMP1.GetWidth(); y++) {
            dist = CalcDist( x, y, tipe, BMP1, BMP2, curves, wr );

            if( rail ) {
                perctg1 = 100;
                if( (((BMP2.GetWidth()/2)) >= dist) || ( dist > (BMP2.GetWidth()/2)) ) {
                    rgb_aux1 = BMP1.GetClr( x, y );
                    rgb_aux2 = BMP2.GetClr( x, y );
                    rgb_auxRES.rgbRed = char(int(((int((rgb_aux1.rgbRed))*perctg1)/100)+((int((rgb_aux2.rgbRed))*(100-perctg1))/100)));
                    rgb_auxRES.rgbGreen = char(int(((int((rgb_aux1.rgbGreen))*perctg1)/100)+((int((rgb_aux2.rgbGreen))*(100-perctg1))/100)));
                    rgb_auxRES.rgbBlue = char(int(((int((rgb_aux1.rgbBlue))*perctg1)/100)+((int((rgb_aux2.rgbBlue))*(100-perctg1))/100)));
                    BMP24bpp.EnterRGBdata( x, y, rgb_auxRES );
                }
            }


            perctg1 = 80;
            if( (((BMP2.GetWidth()/2)-(1*wr)) >= dist) || ( dist > (BMP2.GetWidth()/2)+(1*wr)) ) {
                rgb_aux1 = BMP1.GetClr( x, y );
                rgb_aux2 = BMP2.GetClr( x, y );
                rgb_auxRES.rgbRed = char(int(((int((rgb_aux1.rgbRed))*perctg1)/100)+((int((rgb_aux2.rgbRed))*(100-perctg1))/100)));
                rgb_auxRES.rgbGreen = char(int(((int((rgb_aux1.rgbGreen))*perctg1)/100)+((int((rgb_aux2.rgbGreen))*(100-perctg1))/100)));
                rgb_auxRES.rgbBlue = char(int(((int((rgb_aux1.rgbBlue))*perctg1)/100)+((int((rgb_aux2.rgbBlue))*(100-perctg1))/100)));
                BMP24bpp.EnterRGBdata( x, y, rgb_auxRES );
            }
            perctg1 = 35;
            if( (((BMP2.GetWidth()/2)-(3*wr)) >= dist) || ( dist > (BMP2.GetWidth()/2)+(3*wr)) ) {
                rgb_aux1 = BMP1.GetClr( x, y );
                rgb_aux2 = BMP2.GetClr( x, y );
                rgb_auxRES.rgbRed = char(int(((int((rgb_aux1.rgbRed))*perctg1)/100)+((int((rgb_aux2.rgbRed))*(100-perctg1))/100)));
                rgb_auxRES.rgbGreen = char(int(((int((rgb_aux1.rgbGreen))*perctg1)/100)+((int((rgb_aux2.rgbGreen))*(100-perctg1))/100)));
                rgb_auxRES.rgbBlue = char(int(((int((rgb_aux1.rgbBlue))*perctg1)/100)+((int((rgb_aux2.rgbBlue))*(100-perctg1))/100)));
                BMP24bpp.EnterRGBdata( x, y, rgb_auxRES );
            }

            perctg1 = 15;
            if( (((BMP2.GetWidth()/2)-(5*wr)) >= dist) || ( dist > (BMP2.GetWidth()/2)+(5*wr)) ) {
                rgb_aux1 = BMP1.GetClr( x, y );
                rgb_aux2 = BMP2.GetClr( x, y );
                rgb_auxRES.rgbRed = char(int(((int((rgb_aux1.rgbRed))*perctg1)/100)+((int((rgb_aux2.rgbRed))*(100-perctg1))/100)));
                rgb_auxRES.rgbGreen = char(int(((int((rgb_aux1.rgbGreen))*perctg1)/100)+((int((rgb_aux2.rgbGreen))*(100-perctg1))/100)));
                rgb_auxRES.rgbBlue = char(int(((int((rgb_aux1.rgbBlue))*perctg1)/100)+((int((rgb_aux2.rgbBlue))*(100-perctg1))/100)));
                BMP24bpp.EnterRGBdata( x, y, rgb_auxRES );
            }

            perctg1 = 0;
            if( !(((BMP2.GetWidth()/2)-(5*wr)) < dist) ) {
                rgb_aux1 = BMP1.GetClr( x, y );
                rgb_aux2 = BMP2.GetClr( x, y );
                rgb_auxRES.rgbRed = char(int(((int((rgb_aux1.rgbRed))*perctg1)/100)+((int((rgb_aux2.rgbRed))*(100-perctg1))/100)));
                rgb_auxRES.rgbGreen = char(int(((int((rgb_aux1.rgbGreen))*perctg1)/100)+((int((rgb_aux2.rgbGreen))*(100-perctg1))/100)));
                rgb_auxRES.rgbBlue = char(int(((int((rgb_aux1.rgbBlue))*perctg1)/100)+((int((rgb_aux2.rgbBlue))*(100-perctg1))/100)));
                BMP24bpp.EnterRGBdata( x, y, rgb_auxRES );
            }
            if( !(((BMP2.GetWidth()/2)+(5*wr)) > dist) ) {
                rgb_aux1 = BMP1.GetClr( x, y );
                rgb_aux2 = BMP2.GetClr( x, y );
                rgb_auxRES.rgbRed = char(int(((int((rgb_aux1.rgbRed))*perctg1)/100)+((int((rgb_aux2.rgbRed))*(100-perctg1))/100)));
                rgb_auxRES.rgbGreen = char(int(((int((rgb_aux1.rgbGreen))*perctg1)/100)+((int((rgb_aux2.rgbGreen))*(100-perctg1))/100)));
                rgb_auxRES.rgbBlue = char(int(((int((rgb_aux1.rgbBlue))*perctg1)/100)+((int((rgb_aux2.rgbBlue))*(100-perctg1))/100)));
                BMP24bpp.EnterRGBdata( x, y, rgb_auxRES );
            }


        }
    }

    cout << "........";
    cout << "Done\n";
}