Beispiel #1
0
///////////////////////////////////////////////////////////////////////////////
// runOne:  Run a single test case
///////////////////////////////////////////////////////////////////////////////
void
ReadPixSanityTest::runOne(ReadPixSanityResult& r, GLEAN::Window& w) {

	// Many (if not most) other tests need to read the contents of
	// the framebuffer to determine if the correct image has been
	// drawn.  Obviously this is a waste of time if the basic
	// functionality of glReadPixels isn't working.
	//
	// This test does a "sanity" check of glReadPixels.  Using as
	// little of the GL as practicable, it writes a random value
	// in the framebuffer, reads it, and compares the value read
	// with the value written.

	glPixelStorei(GL_PACK_SWAP_BYTES, GL_FALSE);
	glPixelStorei(GL_PACK_LSB_FIRST, GL_FALSE);
	glPixelStorei(GL_PACK_ROW_LENGTH, 0);
	glPixelStorei(GL_PACK_SKIP_ROWS, 0);
	glPixelStorei(GL_PACK_SKIP_PIXELS, 0);
	glPixelStorei(GL_PACK_ALIGNMENT, 1);

	glPixelTransferi(GL_MAP_COLOR, GL_FALSE);
	glPixelTransferi(GL_MAP_STENCIL, GL_FALSE);
	glPixelTransferi(GL_INDEX_SHIFT, 0);
	glPixelTransferi(GL_INDEX_OFFSET, 0);
	glPixelTransferf(GL_RED_SCALE, 1.0);
	glPixelTransferf(GL_GREEN_SCALE, 1.0);
	glPixelTransferf(GL_BLUE_SCALE, 1.0);
	glPixelTransferf(GL_ALPHA_SCALE, 1.0);
	glPixelTransferf(GL_DEPTH_SCALE, 1.0);
	glPixelTransferf(GL_RED_BIAS, 0.0);
	glPixelTransferf(GL_GREEN_BIAS, 0.0);
	glPixelTransferf(GL_BLUE_BIAS, 0.0);
	glPixelTransferf(GL_ALPHA_BIAS, 0.0);
	glPixelTransferf(GL_DEPTH_BIAS, 0.0);

	glDisable(GL_SCISSOR_TEST);
	glDisable(GL_DITHER);

	glIndexMask(~0);
	glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
	glDepthMask(GL_TRUE);
	glStencilMask(~0);

	if (r.config->canRGBA)
		checkRGBA(r, w);
	if (r.config->z)
		checkDepth(r, w);
	if (r.config->s)
		checkStencil(r, w);

	r.pass = r.passRGBA & r.passDepth & r.passStencil & r.passIndex;
} // ReadPixSanityTest::runOne
Beispiel #2
0
bool
VolumeInformation::volInfo(QString volfile,
			   VolumeInformation& pvlInfo)
{  
  if (!xmlHeaderFile(volfile))
    {
      QMessageBox::information(0, "Error",
	QString("%1 is not a valid preprocessed volume file").arg(volfile));
      return false;
    }
      
  bool rgba = checkRGB(volfile) || checkRGBA(volfile);

  pvlInfo.pvlFile = volfile;


  std::vector<float> pvlmap;
  std::vector<float> rawmap;

  QDomDocument document;
  QFile f(volfile.toAscii().data());
  if (f.open(QIODevice::ReadOnly))
    {
      document.setContent(&f);
      f.close();
    }
  
  QDomElement main = document.documentElement();
  QDomNodeList dlist = main.childNodes();
  for(int i=0; i<dlist.count(); i++)
    {
      if (dlist.at(i).nodeName() == "rawfile")
	{
	  pvlInfo.rawFile = dlist.at(i).toElement().text();
	}
      else if (dlist.at(i).nodeName() == "description")
	{
	  pvlInfo.description = dlist.at(i).toElement().text();
	}
      else if (dlist.at(i).nodeName() == "voxeltype")
	{
	  QString pvalue = dlist.at(i).toElement().text();
	  if (pvalue == "unsigned char")
	    pvlInfo.voxelType = VolumeInformation::_UChar;
	  else if (pvalue == "char")
	    pvlInfo.voxelType = VolumeInformation::_Char;
	  else if (pvalue == "unsigned short")
	    pvlInfo.voxelType = VolumeInformation::_UShort;
	  else if (pvalue == "short")
	    pvlInfo.voxelType = VolumeInformation::_Short;
	  else if (pvalue == "int")
	    pvlInfo.voxelType = VolumeInformation::_Int;
	  else if (pvalue == "float")
	    pvlInfo.voxelType = VolumeInformation::_Float;
	}
      else if (dlist.at(i).nodeName() == "voxelunit")
	{
	  QString pvalue = dlist.at(i).toElement().text();
	  pvlInfo.voxelUnit = VolumeInformation::Nounit;
	  if (pvalue == "angstrom")
	    pvlInfo.voxelUnit = VolumeInformation::Angstrom;
	  else if (pvalue == "nanometer")
	    pvlInfo.voxelUnit = VolumeInformation::Nanometer;
	  else if (pvalue == "micron")
	    pvlInfo.voxelUnit = VolumeInformation::Micron;
	  else if (pvalue == "millimeter")
	    pvlInfo.voxelUnit = VolumeInformation::Millimeter;
	  else if (pvalue == "centimeter")
	    pvlInfo.voxelUnit = VolumeInformation::Centimeter;
	  else if (pvalue == "meter")
	    pvlInfo.voxelUnit = VolumeInformation::Meter;
	  else if (pvalue == "kilometer")
	    pvlInfo.voxelUnit = VolumeInformation::Kilometer;
	  else if (pvalue == "parsec")
	    pvlInfo.voxelUnit = VolumeInformation::Parsec;
	  else if (pvalue == "kiloparsec")
	    pvlInfo.voxelUnit = VolumeInformation::Kiloparsec;
	}
      else if (dlist.at(i).nodeName() == "voxelsize")
	{
	  QStringList str = (dlist.at(i).toElement().text()).split(" ", QString::SkipEmptyParts);
	  float vx = str[0].toFloat();
	  float vy = str[1].toFloat();
	  float vz = str[2].toFloat();
	  pvlInfo.voxelSize = Vec(vx, vy, vz);
	}
      else if (dlist.at(i).nodeName() == "gridsize")
	{
	  QStringList str = (dlist.at(i).toElement().text()).split(" ", QString::SkipEmptyParts);
	  int d = str[0].toInt();
	  int w = str[1].toInt();
	  int h = str[2].toInt();
	  pvlInfo.dimensions = Vec(d,w,h);
	}
      else if (dlist.at(i).nodeName() == "slabsize")
	{
	  pvlInfo.slabSize = (dlist.at(i).toElement().text()).toInt();
	}
      else if (dlist.at(i).nodeName() == "rawmap")
	{
	  QStringList str = (dlist.at(i).toElement().text()).split(" ", QString::SkipEmptyParts);
	  for(int im=0; im<str.count(); im++)
	    rawmap.push_back(str[im].toFloat());
	}
      else if (dlist.at(i).nodeName() == "pvlmap")
	{
	  QStringList str = (dlist.at(i).toElement().text()).split(" ", QString::SkipEmptyParts);
	  for(int im=0; im<str.count(); im++)
	    pvlmap.push_back(str[im].toInt());
	}
    }

  for(int i=0; i<(int)qMin(rawmap.size(), pvlmap.size()); i++)
    pvlInfo.mapping << QPointF(rawmap[i], pvlmap[i]);
  
  rawmap.clear();
  pvlmap.clear();

  return true;
}