Пример #1
0
void
Renderer::SaveState(std::string name)
{
  Document doc;
  doc.Parse("{}");

  Value state(kObjectType);

  state.AddMember("Volume", Value().SetString("volname", doc.GetAllocator()), doc.GetAllocator());

	getCamera().saveState(doc, state);
	getRenderProperties().saveState(doc, state);
	getTransferFunction().saveState(doc, state);
	getColorMap().saveState(doc, state["TransferFunction"]);
	getSlices().saveState(doc, state);
	getIsos().saveState(doc, state);

  doc.AddMember("State", state, doc.GetAllocator());

  StringBuffer sbuf;
  PrettyWriter<StringBuffer> writer(sbuf);
  doc.Accept(writer);

  std::ofstream out;
  out.open(name.c_str(), std::ofstream::out);
  out << sbuf.GetString() << "\n";
  out.close();
}
Пример #2
0
void
Renderer::LoadVolume(std::string volumeName)
{
	LoadDataFromFile(volumeName);

	int x, y, z;
  volume.GetDimensions(x, y, z);

  int m = x > y ? x > z ? x : z : y > z ? y : z;

  osp::vec3f eye((x-1)/2.0, (y-1)/2.0, -(3*m - (z-1)/2.0));
  osp::vec3f center((x-1)/2.0, (y-1)/2.0, (z-1)/2.0);
  osp::vec3f up(0.0, 1.0, 0.0);

  getCamera().setupFrame(eye, center, up);
  getCamera().commit();

	getLights().commit(getRenderer());
	getTransferFunction().commit(getRenderer());
	getTransferFunction().showColors();
	getSlices().commit(getRenderer(), &volume);
	getIsos().commit(&volume);
	renderProperties.commit();
	
}
Пример #3
0
void Torus::print()
{
	cout << "| | - Torus" << endl;
	cout << "| | | - inner: " << getInner() << endl;
	cout << "| | | - outer: " << getOuter() << endl;
	cout << "| | | - slices: " << getSlices() << endl;
	cout << "| | | - loops: " << getLoops() << endl;
}
Пример #4
0
// Draw function
void Arc::drawFunc()
{
   BEGIN_DLIST
   GLUquadricObj* qobj = gluNewQuadric();
   if (isFilled()) {
      gluQuadricDrawStyle(qobj, GLU_FILL);
   }
   else {
      gluQuadricDrawStyle(qobj, GLU_SILHOUETTE);
   }
   if (connected) {
      gluPartialDisk(qobj, 0, getRadius(), getSlices(), 2, startAngle, arcLength);
   }
   else {
      gluPartialDisk(qobj, getRadius(), getRadius(), getSlices(), 2, startAngle, arcLength);
   }
   gluDeleteQuadric(qobj);
   END_DLIST
}
Пример #5
0
// Draw function
void OcclusionCircle::drawFunc()
{
   BEGIN_DLIST
   GLUquadricObj* qobj = gluNewQuadric();
   if (isFilled()) {
      gluQuadricDrawStyle(qobj, GLU_FILL);
   }
   else {
      gluQuadricDrawStyle(qobj, GLU_SILHOUETTE);
   }
   gluDisk( qobj, getRadius(),  outerRadius, getSlices(), 1);
   gluDeleteQuadric(qobj);
   END_DLIST
}
Пример #6
0
// Draw function
void OcclusionArc::drawFunc()
{
   BEGIN_DLIST
   GLUquadricObj* qobj = gluNewQuadric();
   if (isFilled()) {
      gluQuadricDrawStyle(qobj, GLU_FILL);
   }
   else {
      gluQuadricDrawStyle(qobj, GLU_SILHOUETTE);
   }

   gluPartialDisk(qobj, getRadius(), outerRadius, getSlices(), 2, getStartAngle(), getArcLength());

   gluDeleteQuadric(qobj);
   END_DLIST
}
Пример #7
0
//------------------------------------------------------------------------------
// drawFunc() -- draws the object(s)
//------------------------------------------------------------------------------
void DialArcSegment::drawFunc()
{
    // get our data from our base class
    double startAngle = getStartAngle();
    double radius = getRadius();
    double sweepAngle = getSweepAngle();

    GLint curSlices = getSlices();
    // our slice amount should go up as we get more of a sweep, if not, it will
    // look funny.  Pretty much one slice per degree sweep
    double y = std::fabs(static_cast<double>(sweepAngle));
    curSlices = curSlices + static_cast<GLint>(y * 0.05f);

    // draw our arc
    glPushMatrix();
        GLUquadric* qobj = gluNewQuadric();
        if (filled) gluQuadricDrawStyle(qobj, GL_FILL);
        else gluQuadricDrawStyle(qobj, GLU_SILHOUETTE);
        gluPartialDisk(qobj, radius, outerRadius, curSlices, 1, startAngle, sweepAngle);
        gluDeleteQuadric(qobj);
    glPopMatrix();
}
Пример #8
0
void
Renderer::LoadState(std::string statefile, bool with_data)
{
  Document doc;

  std::ifstream in;
  in.open(statefile.c_str(), std::istream::in);
  in.seekg(0, std::ios::end);
  std::streamsize size = in.tellg();
  in.seekg(0, std::ios::beg);

  in.read(xyzzy, size);
  doc.Parse(xyzzy);
  in.close();

	if (! doc.IsObject() ||  ! doc.HasMember("State"))
  {
    std::cerr << "invalud state file\n";
    return;
  }

	if (doc["State"].HasMember("Camera")) 
	{
		getCamera().loadState(doc["State"]["Camera"]);
		getCamera().commit();
	}

	if (doc["State"].HasMember("Lights")) 
	{
		getLights().loadState(doc["State"]["Lights"]);
		getLights().commit(getRenderer());
	}

	if (doc["State"].HasMember("TransferFunction")) 
	{
		getTransferFunction().loadState(doc["State"]["TransferFunction"]);
		if (doc["State"]["TransferFunction"].HasMember("Colormap"))
		{
			getColorMap().loadState(doc["State"]["TransferFunction"]["Colormap"]);
			getColorMap().commit(getTransferFunction());
		}
		getTransferFunction().commit(getRenderer());
	}

	if (doc["State"].HasMember("Slices")) 
	{
		getSlices().loadState(doc["State"]["Slices"]);
		getSlices().commit(getRenderer(), &volume);
	}
	
	if (doc["State"].HasMember("Isosurfaces")) 
	{
		getIsos().loadState(doc["State"]["Isosurfaces"]);
		getIsos().commit(&volume);
	}

	if (with_data)
		LoadDataFromFile(doc["State"]["Volume"].GetString());
	
	in.close();
}