Example #1
0
int map_pos(const Vector3d& EPoint, const BasicPattern* pPattern, DBL *xcoor, DBL *ycoor)
{
    const ImageData *image = dynamic_cast<const ImagePatternImpl*>(pPattern)->pImage;

    // Now determine which mapper to use.

    switch(image->Map_Type)
    {
        case PLANAR_MAP:
            if(!planar_image_map(EPoint, image, xcoor, ycoor))
                return (1);
            break;
        case SPHERICAL_MAP:
            if(!spherical_image_map(EPoint, image, xcoor, ycoor))
                return (1);
            break;
        case CYLINDRICAL_MAP:
            if(!cylindrical_image_map(EPoint, image, xcoor, ycoor))
                return (1);
            break;
        case TORUS_MAP:
            if(!torus_image_map(EPoint, image, xcoor, ycoor))
                return (1);
            break;
        case ANGULAR_MAP:
            if(!angular_image_map(EPoint, image, xcoor, ycoor))
                return (1);
            break;
        default:
            if(!planar_image_map(EPoint, image, xcoor, ycoor))
                return (1);
            break;
    }

    // Now make sure the point is on the image
    // and apply integer repeats and offsets
    *xcoor += image->Offset[U] + EPSILON;
    *ycoor += image->Offset[V] + EPSILON;

    if(image->Once_Flag)
    {
        if((*xcoor >= image->iwidth) || (*ycoor >= image->iheight) || (*xcoor < 0.0) || (*ycoor <0.0))
            return (1);
    }

    *xcoor = wrap( *xcoor, (DBL)(image->iwidth));
    *ycoor = wrap(-*ycoor, (DBL)(image->iheight)); // (Compensate for y coordinates on the images being upsidedown)

    return (0);
}
Example #2
0
static int map(VECTOR EPoint, TPATTERN *TPattern, DBL *xcoor, DBL  *ycoor)
{
  IMAGE *Image = TPattern->Vals.Image;

  /* Now determine which mapper to use. */

  switch (Image->Map_Type)
  {
    case PLANAR_MAP:

      if (!planar_image_map(EPoint, Image, xcoor, ycoor))
      {
        return (1);
      }

      break;

    case SPHERICAL_MAP:

      if (!spherical_image_map(EPoint, Image, xcoor, ycoor))
      {
        return (1);
      }

      break;

    case CYLINDRICAL_MAP:

      if (!cylindrical_image_map(EPoint, Image, xcoor, ycoor))
      {
        return (1);
      }

      break;

    case TORUS_MAP:

      if (!torus_image_map(EPoint, Image, xcoor, ycoor))
      {
        return (1);
      }

      break;

    default:

      if (!planar_image_map(EPoint, Image, xcoor, ycoor))
      {
        return (1);
      }

      break;
  }

  /* Now make sure the point is on the image */
  /* and apply integer repeats and offsets   */
  *xcoor += Image->Offset[U] + Small_Tolerance;
  *ycoor += Image->Offset[V] + Small_Tolerance;
  
  DBL xx=(*xcoor)/(DBL)(Image->iwidth);
  DBL yy=(*ycoor)/(DBL)(Image->iheight);

  if (Image->Once_Flag)
  {
    if ((xx>1.0) || (yy>1.0) || (xx<0.0) || (yy<0.0))
    {
      return (1);
    }
  }

  *xcoor -= ((int)xx)*Image->iwidth;
  *ycoor -= ((int)yy)*Image->iheight;

  /* Compensate for y coordinates on the images being upsidedown */

	///////////////////////////////////////////////////////////////////////////////
	//                                                                           //
	// @V-REP@                                                                   //
	//                                                                           //
	// Normal images are not upsidedown                                          //
	//                                                                           //
	///////////////////////////////////////////////////////////////////////////////

  // *ycoor = (DBL)Image->iheight - *ycoor;

  if (*xcoor < 0.0)
  {
    *xcoor += (DBL)Image->iwidth;
  }
  else
  {
    if (*xcoor >= (DBL)Image->iwidth)
    {
      *xcoor -= (DBL)Image->iwidth;
    }
  }

  if (*ycoor < 0.0)
  {
    *ycoor += (DBL)Image->iheight;
  }
  else
  {
    if (*ycoor >= (DBL)Image->iheight)
    {
      *ycoor -= (DBL)Image->iheight;
    }
  }

  if ((*xcoor >= (DBL)Image->iwidth) ||
      (*ycoor >= (DBL)Image->iheight) ||
      (*xcoor < 0.0) || (*ycoor < 0.0))
  {
    Error("Picture index out of range.");
  }

  return (0);
}