Commit f9c6f9cd authored by Dave Pugmire's avatar Dave Pugmire Committed by Robert Maynard
Browse files

cleanup of code.

parent 693b98b9
......@@ -86,12 +86,10 @@ public:
VTKM_CONT_EXPORT
virtual void StartScene()
{
std::cout<<__LINE__<<": TODO"<<std::endl;
}
VTKM_CONT_EXPORT
virtual void EndScene()
{
std::cout<<__LINE__<<": TODO"<<std::endl;
}
protected:
......
......@@ -41,13 +41,7 @@ class SceneRendererOSMesa : public SceneRenderer
{
public:
VTKM_CONT_EXPORT
SceneRendererOSMesa()
{
ctx = NULL;
width = 1024;
height = 1024;
rgba.resize(width*height*4);
}
SceneRendererOSMesa() {}
VTKM_CONT_EXPORT
virtual void RenderCells(const vtkm::cont::DynamicCellSet &cellset,
......@@ -56,23 +50,18 @@ public:
const vtkm::rendering::ColorTable &colorTable,
vtkm::Float64 *scalarBounds)
{
//Doesn't work if you take the Init() out......
//Init();
SetupView();
vtkm::cont::DynamicArrayHandleCoordinateSystem dcoords = coords.GetData();
if (!dcoords.IsSameType(vtkm::cont::ArrayHandleUniformPointCoordinates()))
{
std::cout<<"NOT UNIFORM!"<<std::endl;
std::cout<<"Only uniform coordinates supported..."<<std::endl;
return;
}
std::cout<<"RenderCells()"<<std::endl;
vtkm::cont::ArrayHandle< vtkm::Vec<vtkm::Id, 4> > indices;
vtkm::Id numTri;
Triangulator<DeviceAdapter> triangulator;
triangulator.run(cellset, indices, numTri);
std::cout<<"NumTris= "<<numTri<<std::endl;
//std::cout<<"NumTris= "<<numTri<<std::endl;
//printSummary_ArrayHandle(indices, std::cout);
vtkm::cont::ArrayHandle<vtkm::Float32> sf;
......@@ -103,7 +92,7 @@ public:
vtkm::Float32 sn = (s-sMin)/sDiff;
//Color color = ct.MapRGB(s);
Color color = colorTable.MapRGB(s);
std::cout<<i<<": "<<i1<<" "<<i2<<" "<<i3<<" si= "<<si<<" sn= "<<sn<<std::endl;
//std::cout<<i<<": "<<i1<<" "<<i2<<" "<<i3<<" si= "<<si<<" sn= "<<sn<<std::endl;
//std::cout<<" color= "<<color.Components[0]<<" "<<color.Components[1]<<" "<<color.Components[2]<<std::endl;
s = sf.GetPortalConstControl().Get(i1);
......@@ -134,81 +123,6 @@ public:
}
private:
VTKM_CONT_EXPORT
virtual void Init()
{
ctx = OSMesaCreateContextExt(OSMESA_RGBA, 32, 0, 0, NULL);
if (!ctx) std::cout<<"ERROR 0"<<std::endl;
rgba.resize(width*height*4);
if (!OSMesaMakeCurrent(ctx, &rgba[0], GL_UNSIGNED_BYTE, width, height))
std::cout<<"ERROR 1"<<std::endl;
SetupView();
}
VTKM_CONT_EXPORT
void SetupView()
{
vtkm::Float32 oglV[16], oglP[16];
vtkm::Matrix<vtkm::Float32,4,4> vm = GetView().CreateViewMatrix();
vtkm::Matrix<vtkm::Float32,4,4> pm = GetView().CreateProjectionMatrix();
oglP[ 0] = pm[0][0];
oglP[ 1] = pm[1][0];
oglP[ 2] = pm[2][0];
oglP[ 3] = pm[3][0];
oglP[ 4] = pm[0][1];
oglP[ 5] = pm[1][1];
oglP[ 6] = pm[2][1];
oglP[ 7] = pm[3][1];
oglP[ 8] = pm[0][2];
oglP[ 9] = pm[1][2];
oglP[10] = pm[2][2];
oglP[11] = pm[3][2];
oglP[12] = pm[0][3];
oglP[13] = pm[1][3];
oglP[14] = pm[2][3];
oglP[15] = pm[3][3];
glMatrixMode(GL_PROJECTION);
glLoadMatrixf(oglP);
oglV[ 0] = vm[0][0];
oglV[ 1] = vm[1][0];
oglV[ 2] = vm[2][0];
oglV[ 3] = vm[3][0];
oglV[ 4] = vm[0][1];
oglV[ 5] = vm[1][1];
oglV[ 6] = vm[2][1];
oglV[ 7] = vm[3][1];
oglV[ 8] = vm[0][2];
oglV[ 9] = vm[1][2];
oglV[10] = vm[2][2];
oglV[11] = vm[3][2];
oglV[12] = vm[0][3];
oglV[13] = vm[1][3];
oglV[14] = vm[2][3];
oglV[15] = vm[3][3];
glMatrixMode(GL_MODELVIEW);
glLoadMatrixf(oglV);
}
VTKM_CONT_EXPORT
void DumpImage()
{
std::ofstream of("output.pnm");
of<<"P6"<<std::endl<<width<<" "<<height<<std::endl<<255<<std::endl;
for (int i=height-1; i>=0; i--)
for (int j=0; j < width; j++)
{
const unsigned char *tuple = &(rgba[i*width*4 + j*4]);
of<<tuple[0]<<tuple[1]<<tuple[2];
}
of.close();
}
OSMesaContext ctx;
std::vector<unsigned char> rgba;
std::vector<float> zbuff;
int width, height;
};
}} //namespace vtkm::rendering
......
......@@ -66,9 +66,6 @@ void TestSceneRendererOSMesa()
vtkm::rendering::ColorTable colorTable("thermal");
sceneRenderer.SetActiveColorTable(colorTable);
std::cout<<"pos: "<<view.Position<<std::endl;
std::cout<<"at_: "<<view.LookAt<<std::endl;
sceneRenderer.SetView(view);
//sceneRenderer.RenderCells(regularGrid.GetCellSet(), coords, scalarField, colorTable);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment