Example #1
0
void BoxVec::step2(int x, int y){
  /* (x,y) is the current cursor position */
  switch(option){
  case RESIZEBOX:
    if(curb==NULL) return;
    curb->xc[xi]=x;
    curb->yc[yi]=y;
    break;
  case MOVEBOX:{
    if(curb==NULL) return;
    int dx=x-pinx, dy=y-piny;
    pinx=x;
    piny=y;
    curb->xc[0]+=dx;
    curb->xc[1]+=dx;
    curb->yc[0]+=dy;
    curb->yc[1]+=dy;
    break;
  }
  case NEWBOX:
    newbox(pinx,piny,pinx,piny,NULL);
    option=RESIZEBOX;
    break;
  }
  YFTcl_EvalEx(itp, 256,
	       "$imgWN marker configure %s -coords {%d %d %d %d %d %d %d %d %d %d}",
	       curb->name,
	       curb->xc[0], curb->yc[0],
	       curb->xc[0], curb->yc[1],
	       curb->xc[1], curb->yc[1],
	       curb->xc[1], curb->yc[0],
	       curb->xc[0], curb->yc[0]
	       );
}
DrBox & DrPDFExtractor::Split_bbox(DrBox &bbox, int i, int n)
{
    DrBox newbox(bbox.m_x0,bbox.m_y0,bbox.m_x1,bbox.m_y1);
	float w = (bbox.m_x1 - bbox.m_x0) / n;
	float x0 = bbox.m_x0;
	newbox.m_x0 = x0 + i * w;
	newbox.m_x1 = x0 + (i + 1) * w;
	return newbox;
}
Example #3
0
void ORRKdTree::extendTreeByOneLevel(char* extdir)
{
	int i, newaxis, dim = this->getDimension();
	Box newbox(dim);
	KdTreeNode *newroot = NULL, *newchild = NULL;
	double boxsize;

	for ( i = 0 ; i < dim ; ++i )
	{
		newaxis = mRoot->getPreviousAxis();
		newbox.copyfrom(mRoot->getSpace());
		boxsize = newbox.getDiameter(newaxis);

		if ( extdir[newaxis] == -1 )
		{
			// Fix the box of the new root and create the root. Extend the lower bound of the box
			newbox.mIntervals[newaxis][0] -= boxsize;
			newroot = new KdTreeNode(newaxis, NULL/*no parent*/, newbox, NULL);
			// Fix the box of the new child and create the new child
			newbox.mIntervals[newaxis][1] = mRoot->getLowerBoxBound(newaxis);
			newchild = new KdTreeNode(mRoot->getAxis(), newroot/*the parent*/, newbox, NULL);
			// Now fix the children of the new root
			newroot->setChildren(newchild, mRoot);
		}
		else if ( extdir[newaxis] == 1 )
		{
			// Fix the box of the new root and create the root. Extend the upper bound of the box
			newbox.mIntervals[newaxis][1] += boxsize;
			newroot = new KdTreeNode(newaxis, NULL/*no parent*/, newbox, NULL);
			// Fix the box of the new child and create the new child
			newbox.mIntervals[newaxis][0] = mRoot->getUpperBoxBound(newaxis);
			newchild = new KdTreeNode(mRoot->getAxis(), newroot/*the parent*/, newbox, NULL);
			// Now fix the children of the new root
			newroot->setChildren(mRoot, newchild);
		}
		else
		{
			fprintf(stderr, "ERROR in 'ORRKdTree::%s()': extension direction for the %i-th axis is %i! Can not extend the tree!\n",
					__func__, newaxis, extdir[newaxis]);
			fflush(stdout);
			return;
		}

		// Set the new root as the parent of the old one
		mRoot->setParent(newroot);
		// Save the new root
		mRoot = newroot;
	}

	// Now we have one level more
	++mNumOfTreeLevels;
}
Example #4
0
BBox BBoxIntersection(const BBox &b1, const BBox &b2) {
  BBox newbox(b1.dimension());

  ThrowAssert(b1.dimension() == b2.dimension());
  for (UInt i = 0; i < b1.dimension(); i++) {
    newbox.setMin(i, std::max(b1.getMin()[i], b2.getMin()[i]));
    newbox.setMax(i, std::min(b1.getMax()[i], b2.getMax()[i]));
  }

  newbox.checkEmpty();

  return newbox;
}
void * newscalarvol(void * intex, vector min, vector max, 
                    int xs, int ys, int zs, char * fname, scalarvol * invol) {
  box * bx;
  texture * tx, * tex;
  scalarvol * vol;

  tex=(texture *)intex;
  tex->shadowcast = 0; /* doesn't cast a shadow */

  tx=(texture *)rt_getmem(sizeof(texture));

  /* is the volume data already loaded? */
  if (invol==NULL) {
    vol=(scalarvol *)rt_getmem(sizeof(scalarvol));
    vol->loaded=0;
    vol->data=NULL;
  }
  else
    vol=invol;

  vol->opacity=tex->opacity;
  vol->xres=xs;
  vol->yres=ys;
  vol->zres=zs;
  strcpy(vol->name, fname);

  tx->ctr.x = 0.0;
  tx->ctr.y = 0.0;
  tx->ctr.z = 0.0;
  tx->rot   = tx->ctr;
  tx->scale = tx->ctr;
  tx->uaxs  = tx->ctr;
  tx->vaxs  = tx->ctr;

  tx->islight = 0;
  tx->shadowcast = 0; /* doesn't cast a shadow */

  tx->col = tex->col;
  tx->ambient  = 1.0;
  tx->diffuse  = 0.0;
  tx->specular = 0.0;
  tx->opacity  = 1.0;
  tx->img = vol;
  tx->texfunc = (color(*)(void *, void *, void *))(scalar_volume_texture);

  bx=newbox(tx, min, max);
  tx->obj = (void *) bx; /* XXX hack! */

  return (void *) bx;
}
Example #6
0
/**
 * mark all places that are reachable
 */
void pullAndMark(vector<string> &mark, Position b, Position p)
{
	if (outOfBoundary(mark, p) || outOfBoundary(mark, b)) {
		return;
	}
	if (mark[b.x][b.y] == 'V')
		return;
	if (isWall(mark[b.x][b.y]) || isWall(mark[p.x][p.y]))
		return;
	mark[b.x][b.y] = 'V';
	for (int i = 0; i < 4; ++i) {
		Position newbox(b.x + direction[i][0], b.y + direction[i][1]);
		Position newperson(newbox.x + direction[i][0], newbox.y + direction[i][1]);
		pullAndMark(mark, newbox, newperson);
	}
}
Example #7
0
BBox BBoxParUnion(const BBox &b1) {
  double val, valres;
  BBox newbox(b1.dimension());


  for (UInt i = 0; i < b1.dimension(); i++) {
    // Find max 
    val = b1.getMax()[i];
    MPI_Allreduce(&val, &valres, 1, MPI_DOUBLE, MPI_MAX, Par::Comm());
    newbox.setMax(i, valres);
    val = b1.getMin()[i];
    MPI_Allreduce(&val, &valres, 1, MPI_DOUBLE, MPI_MIN, Par::Comm());
    newbox.setMin(i, valres);
  }

  newbox.checkEmpty();

  return newbox;
}
Example #8
0
File: lauxlib.c Project: goolic/tup
/*
** returns a pointer to a free area with at least 'sz' bytes
*/
LUALIB_API char *luaL_prepbuffsize (luaL_Buffer *B, size_t sz) {
  lua_State *L = B->L;
  if (B->size - B->n < sz) {  /* not enough space? */
    char *newbuff;
    size_t newsize = B->size * 2;  /* double buffer size */
    if (newsize - B->n < sz)  /* not big enough? */
      newsize = B->n + sz;
    if (newsize < B->n || newsize - B->n < sz)
      luaL_error(L, "buffer too large");
    /* create larger buffer */
    if (buffonstack(B))
      newbuff = (char *)resizebox(L, -1, newsize);
    else {  /* no buffer yet */
      newbuff = (char *)newbox(L, newsize);
      memcpy(newbuff, B->b, B->n * sizeof(char));  /* copy original content */
    }
    B->b = newbuff;
    B->size = newsize;
  }
  return &B->b[B->n];
}
Example #9
0
File: lauxlib.c Project: lua/lua
/*
** Returns a pointer to a free area with at least 'sz' bytes in buffer
** 'B'. 'boxidx' is the relative position in the stack where the
** buffer's box is or should be.
*/
static char *prepbuffsize (luaL_Buffer *B, size_t sz, int boxidx) {
  if (B->size - B->n >= sz)  /* enough space? */
    return B->b + B->n;
  else {
    lua_State *L = B->L;
    char *newbuff;
    size_t newsize = newbuffsize(B, sz);
    /* create larger buffer */
    if (buffonstack(B))  /* buffer already has a box? */
      newbuff = (char *)resizebox(L, boxidx, newsize);  /* resize it */
    else {  /* no box yet */
      lua_pushnil(L);  /* reserve slot for final result */
      newbox(L);  /* create a new box */
      /* move box (and slot) to its intended position */
      lua_rotate(L, boxidx - 1, 2);
      lua_toclose(L, boxidx);
      newbuff = (char *)resizebox(L, boxidx, newsize);
      memcpy(newbuff, B->b, B->n * sizeof(char));  /* copy original content */
    }
    B->b = newbuff;
    B->size = newsize;
    return newbuff + B->n;
  }
}
Example #10
0
void rt_box(void * tex, vector min, vector max) {
  add_object((object *) newbox(tex, (vector)min, (vector)max));
} 
Example #11
0
void rt_box(SceneHandle scene, void * tex, apivector min, apivector max) {
  add_bounded_object((scenedef *) scene, (object *) newbox(tex, min, max));
} 
Example #12
0
File: file.c Project: kahrs/cda
Line *
inlist(FILE *fp)
{
	int c,i;
	char *s;
	Point p;
	Line *l=0;
	while (1) {
		c=fgetc(fp);
		switch (c) {
		case '\n':
			break;
		default:
			do
				c = fgetc(fp);
			while (c != '\n');
			break;
		case 'w':
		case 'l':
			l = newline(inpoint(fp),l);
			l->Q = inpoint(fp);
			break;
		case 'b':
			l = newbox(inpoint(fp),l);
			l->Q = inpoint(fp);
			break;
		case 'd':
			l = newdots(inpoint(fp),l);
			l->Q = inpoint(fp);
			break;
		case 'z':
			l = newmacro(inpoint(fp),l);
			l->Q = inpoint(fp);
			break;
		case 's':
			s = instring(fp);
			i = inint(fp);
			p = inpoint(fp);
			if (*s != 0) {
				l = newstring(p,i,l);
				setstring((String *)l,s);
			}
			break;
		case 't':		/* turn a jraw text into two graw strings */
			s = instring(fp);
			i = jtog(inint(fp));
			p = Pt(0,(showgrey ? GRID*2 : GRID));
			l = newstring(p,i,l);
			setstring((String *)l,s);
			s = instring(fp);
			inint(fp);
			p = inpoint(fp);
			if (*s != 0) {		/* gad, what a mess */
				l = newstring(add(p,l->P),i,l);
				setstring((String *)l,s);
				l->next->P = p;
			}
			else			/* watch carefully */
				l->P = p;
			break;
		case 'r':
			l = newref(intern(instring(fp)),l);
			break;
		case 'i':
			s = intern(instring(fp));
			l = newinst(inpoint(fp),s,l);
			break;
		case 'm':
			nest = 1;
			l = newmaster(intern(instring(fp)),l);
			((Master *)l)->dl = inlist(fp);
			break;
		case 'e':
			if (nest == 0)
				dprint("found end of no macro\n");
			nest = 0;
		case -1:
			return l;
		}
	}
}
Example #13
0
bool Collision::collideP(const BBox &box0, const Matrix4D &b0mat, const BBox &box1)
{
	BBox newbox(box0, b0mat);
	return collideP(newbox, box1);
}