Example #1
0
bool EarthModel::setSlotF(const Number* const msg)
{
   bool ok = false;
   if (msg != nullptr) {
      ok = setF( msg->getDouble() );
   }
   return ok;
}
Example #2
0
void enColorC4::scale(float scale)
{
	float f4[4];

	getFloat(f4);

	setF(f4[0] * scale, f4[1] * scale, f4[2] * scale, f4[3] * scale);
}
TransformationMatrix::TransformationMatrix(const CGAffineTransform& t)
{
    setA(t.a);
    setB(t.b);
    setC(t.c);
    setD(t.d);
    setE(t.tx);
    setF(t.ty);
}
Example #4
0
bool Astar::checkOpen(int col, int row, int id)
{
    // 检查open列表中是否有更小的步长,并排序
    for(int i = _open->count() - 1; i > 0; i--) {
        auto item = (AstarItem*)_open->getObjectAtIndex(i);
        if(item->getCol() == col && item->getRow() == row) {
            int tempG = getG(col, row, id);
            if(tempG < item->getG()) {
                item->setG(tempG);
                item->setFid(id);
                item->setF(tempG + item->getH());
                resetSort(i);
            }
            return false;
        }
    }

    return true;
}
Example #5
0
void GenerateDefun (AST* ast)
{
    memory[NextIndex].instruction = DEFUN;
    memory[NextIndex].instruction_ptr = table[memory[NextIndex].instruction];
    NextIndex++;
    Function_Data_t* p = setF (ast->s, ast->LHS->i, &memory[NextIndex],0);
    //printf("%s/n",p->name);
    memory[NextIndex - 1].op[1].c = p->name;
    free(ast->LHS);
    Generate (ast->RHS, 1,ast->s );
    free(ast->s);
    //printf("return\n");
    if (p->value <= 1){
        memory[NextIndex].instruction = RETURN;
        memory[NextIndex].instruction_ptr = table[memory[NextIndex].instruction];
    } else {
        memory[NextIndex].instruction = NRETURN;
        memory[NextIndex].op[0].i = p->value;
        memory[NextIndex].instruction_ptr = table[memory[NextIndex].instruction];
    }
    NextIndex++;
}
Example #6
0
int struct_value_by_ref_callee_write_skip() {
  struct delicious x;
  struct_ptr_skip(&x);
  setF(&x, NULL);
  return *x.ptr; // should report null deref warning
}
Example #7
0
void RNAMencoding(IplImage *img, double epsilon, vector<GrayLevel> &P, vector<char> &Q, vector<CouplePoints> &blks, int &frag_num, int HWratio, int DIRpriority)
{
	CvMat *R = cvCreateMat(img->height, img->width, CV_32FC1);
	CvMat *F = cvCreateMat(img->height, img->width, CV_32FC1);

	cvmSetZero(R);
	cvmSetZero(F);

	int r, c;
	int x1, y1, x2, y2;
	uchar *ptr;
	CouplePoints ps;


	for(r = 0; r < F->rows; r++)
	{
		ptr = (uchar *)(F->data.ptr + r*F->step);

		for(c = 0; c < F->cols; c++)
		{
			x1 = c;
			y1 = r;

			if(ptr[x1] != 0)
				continue;

			x2 = x1;
			y2 = y1;

			setPS(ps, x1, y1, x2, y2);
			if(DIRpriority == DIA_FIRST)//1.对角线搜索
			{
				while(x2<img->width && y2<img->height && IsHomogeneousBlock(img, ps, epsilon) == true && canF(F, ps))
				{
					x2++;
					y2++;
					setPS(ps, x1, y1, x2, y2);
				}
				x2--;
				y2--;

				int temp_x2 = x2 + 1;
				int temp_y2 = y2 + 1;


				//对角线方向停止,横向继续
				setPS(ps, x1, y1, temp_x2, y2);
				while(temp_x2<img->width && IsHomogeneousBlock(img, ps, epsilon) == true && canF(F, ps))
				{
					temp_x2++;
					setPS(ps, x1, y1, temp_x2, y2);
				}
				temp_x2--;
				//对角线方向停止,纵向继续
				setPS(ps, x1, y1, x2, temp_y2);
				while(temp_y2<img->height && IsHomogeneousBlock(img, ps, epsilon) == true && canF(F, ps))
				{
					temp_y2++;
					setPS(ps, x1, y1, x2, temp_y2);
				}
				temp_y2--;

				if(temp_x2 - x2 > temp_y2 - y2)//[对角线 + 横向] 更大
				{
					x2 = temp_x2;
				}
				else//[对角线 + 纵向] 更大
				{
					y2 = temp_y2;
				}
			}
			else
			{

				if(DIRpriority == ROW_FIRST)//行优先
				{
					while(x2<img->width && IsHomogeneousBlock(img, ps, epsilon) == true && canF(F, ps))
					{
						x2++;
						setPS(ps, x1, y1, x2, y2);
					}
					x2--;
					setPS(ps, x1, y1, x2, y2);
					while(y2<img->height && IsHomogeneousBlock(img, ps, epsilon) == true && canF(F, ps))
					{
						y2++;
						setPS(ps, x1, y1, x2, y2);
					}
					y2--;
				}
				else//列优先
				{
					while(y2<img->height && IsHomogeneousBlock(img, ps, epsilon) == true && canF(F, ps))
					{
						y2++;
						setPS(ps, x1, y1, x2, y2);
					}
					y2--;
					setPS(ps, x1, y1, x2, y2);
					while(x2<img->width && IsHomogeneousBlock(img, ps, epsilon) == true && canF(F, ps))
					{
						x2++;
						setPS(ps, x1, y1, x2, y2);
					}
					x2--;
				}

			}

			if(HWratio != NO_LIMIT)//有长宽比例限制
			{
				if( (x2-x1+1)/(y2-y1+1) > HWratio )
				{
					//宽度过大
					x2 = (y2-y1+1)*HWratio + x1-1;
				}
				else
				{
					if( (y2-y1+1)/(x2-x1+1) >HWratio )
					{
						//长度过大
						y2 = (x2-x1+1)*HWratio + y1-1;
					}
				}
			}

			setPS(ps, x1, y1, x2, y2);

			blks.push_back(ps);
			setF(F, ps);
			setR(R, ps);
			setP(P, img, ps);
		}
	}

	frag_num = calFragNum(P, R);

	switch (METHOD)
	{
	case METHOD_NAM:
		CompressCoordinate(R, Q);//坐标矩阵压缩
		break;
	case METHOD_FRAG_NAM:
		Fragment_CompressCoordinate(R, Q, frag_num);//分段编码压缩
		break;
	case METHOD_AC_NAM:
		AC_CompressCoordinate(R, _nsym, _count);
		break;
	case METHOD_AC_FRAG_NAM:
		AC_Fragment_CompressCoordinate(R, _nsym, _count, frag_num);
		break;
	}

	
	//
	//
	//
	//copyMat(cm1, R);
	//dispIline(R, 484);
}
Example #8
0
int thinkt(struct thing *t, int ls, struct tile level[ls][ls], struct thing *heebo)
{

	//Add the starting square (or node) to the open list. 

	struct list open;
	open.first=NULL;
	open.last=NULL;
	struct list closed;
	closed.first=NULL;
	closed.last=NULL;
	struct node nodemap[ls][ls];

	int cx,cy;
	cx=t->x;
	cy=t->y;

	struct node *current;
	current = &nodemap[t->y][t->x];
	listCreat(&open,current);

	current->y=cy;
	current->x=cx;

	current->G=0;
	setF(current,heebo);

	while(1)
	{
		//Look for the lowest F cost square on the open list
		current=listLowest(&open);	
		if(current==NULL)
		{
			break;
		}
		cy=current->y;
		cx=current->x;
		
		int ty,tx;
		int atLeatOneFound=0;

		//Switch it to the closed list. 
		listRemove(&open,current);
		listAdd(&closed,current);

		//For each of the 8 squares adjacent to this current square …
		int i;
		for(i=0;i<4;i++)
		{
			switch(i)
			{
				case 0:
					ty=-1;
					tx=0;
					break;
				case 1:
					ty=1;
					tx=0;
					break;
				case 2:
					ty=0;
					tx=-1;
					break;
				case 3:
					ty=0;
					tx=1;
					break;
			}
			if(cy+ty<=0 || cx+tx <=0) break;
			if(cy+ty>=ls || cx+tx >=ls) break;
			//If it is not walkable or if it is on the closed list, ignore it  
			if(level[cy+ty][cx+tx].solid==0 && !listIsOn(&closed,&nodemap[cy+ty][cx+tx]))
			{
				//If it isn’t on the open list, add it to the open list
				if(!listIsOn(&open,current))
					{
						//Make the current square the parent of this square. . 
						listAdd(&open, &nodemap[cy+ty][cx+tx]);
						nodemap[cy+ty][cx+tx].parent=current;
						nodemap[cy+ty][cx+tx].y=cy+ty;
						nodemap[cy+ty][cx+tx].x=cx+tx;
						
						//Record the F, G, and H costs of the square
						setF(&nodemap[cy+ty][cx+tx],heebo);
						atLeatOneFound=1;
						}
				else
				{
					//If it is on the open list already, check to see if this path to that square is better, using G cost as the measure
					if(nodemap[cy+ty][cx+tx].G < current->G+1)
					{
						//If so, change the parent of the square to the current square, and recalculate the G and F scores of the square
						nodemap[cy+ty][cx+tx].parent=current;
						setF(&nodemap[cy+ty][cx+tx],heebo);
					}
				}
			}
		}

		//Stop when you:

		//Add the target square to the closed list, in which case the path has been found
		if(current->y==heebo->y && current->x==heebo->x)
		{
			break;
		}

		//Fail to find the target square, and the open list is empty. In this case, there is no path.    
		if(!atLeatOneFound && closed.first==NULL)
		{
			break;
		}
	}
	struct node *temp=closed.last;
	int atStart=1;
	while(1)
	{
		//mvprintw(temp->y,temp->x,"x");
		if(temp->parent->parent != NULL )
		{
			if((temp->parent->parent->y==t->y && temp->parent->parent->x==t->x) && atStart)
			{
				return 42;
			}
		}
		if(temp->parent->y==t->y && temp->parent->x==t->x)
		{
			movet(t,temp->y - t->y,temp->x - t->x ,ls,level);
			break;
		}
		atStart=0;
		temp=temp->parent;
	}
}