Commit 27f23480 authored by Robert Maynard's avatar Robert Maynard
Browse files

Correct more warnings and formatting issues with vtkm::rendering.

parent 4269e007
......@@ -36,7 +36,7 @@ class RenderSurface
{
public:
VTKM_CONT_EXPORT
RenderSurface(int w=1024, int h=1024,
RenderSurface(std::size_t w=1024, std::size_t h=1024,
const vtkm::rendering::Color &c=vtkm::rendering::Color(0.0f,0.0f,0.0f,1.0f))
: width(w), height(h), bgColor(c)
{
......@@ -61,8 +61,8 @@ public:
VTKM_CONT_EXPORT
virtual void SaveAs(const std::string &) {}
std::size_t width, height;
vtkm::rendering::Color bgColor;
int width, height;
std::vector<vtkm::Float32> rgba;
std::vector<vtkm::Float32> zbuff;
};
......@@ -71,7 +71,7 @@ class RenderSurfaceOSMesa : public RenderSurface
{
public:
VTKM_CONT_EXPORT
RenderSurfaceOSMesa(int w=1024, int h=1024,
RenderSurfaceOSMesa(std::size_t w=1024, std::size_t h=1024,
const vtkm::rendering::Color &c=vtkm::rendering::Color(0.0f,0.0f,0.0f,1.0f))
: RenderSurface(w,h,c)
{
......@@ -104,10 +104,10 @@ public:
unsigned int *raw_zbuff;
int zbytes, w, h;
OSMesaGetDepthBuffer(ctx, &w, &h, &zbytes, (void**)&raw_zbuff);
if (w!=width || h!=height)
if ( w!=int(width) || h!= int(height) )
throw vtkm::cont::ErrorControlBadValue("Wrong width/height in ZBuffer");
int npixels = width*height;
for (int i=0; i<npixels; i++)
std::size_t npixels = width*height;
for (std::size_t i=0; i<npixels; i++)
zbuff[i] = float(raw_zbuff[i]) / float(UINT_MAX);
}
......@@ -136,10 +136,10 @@ public:
{
vtkm::Float32 vl, vr, vt, vb;
v.GetRealViewport(vl,vr,vt,vb);
const vtkm::Float32 x = vtkm::Float32(v.Width)*(1.+vl)/2.;
const vtkm::Float32 y = vtkm::Float32(v.Height)*(1.+vb)/2.;
const vtkm::Float32 a = vtkm::Float32(v.Width)*(vr-vl)/2.;
const vtkm::Float32 b = vtkm::Float32(v.Height)*(vt-vb)/2.;
const vtkm::Float32 x = vtkm::Float32(v.Width)*(1.f + vl)/2.f;
const vtkm::Float32 y = vtkm::Float32(v.Height)*(1.f + vb)/2.f;
const vtkm::Float32 a = vtkm::Float32(v.Width)*(vr-vl)/2.f;
const vtkm::Float32 b = vtkm::Float32(v.Height)*(vt-vb)/2.f;
glViewport(int(x), int(y), int(a), int(b));
}
......@@ -176,8 +176,8 @@ public:
{
std::ofstream of(fileName.c_str());
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++)
for (std::size_t i=height-1; i>=0; i--)
for (std::size_t j=0; j < width; j++)
{
const vtkm::Float32 *tuple = &(rgba[i*width*4 + j*4]);
of<<(unsigned char)(tuple[0]*255);
......
......@@ -48,49 +48,49 @@ public:
VTKM_CONT_EXPORT
virtual void RenderCells(const vtkm::cont::DynamicCellSet &cellset,
const vtkm::cont::CoordinateSystem &coords,
vtkm::cont::Field &scalarField,
const vtkm::rendering::ColorTable &colorTable,
vtkm::Float64 *scalarBounds)
vtkm::cont::Field &scalarField,
const vtkm::rendering::ColorTable &colorTable,
vtkm::Float64 *scalarBounds)
{
vtkm::cont::ArrayHandle< vtkm::Vec<vtkm::Id, 4> > indices;
vtkm::Id numTri;
Triangulator<DeviceAdapter> triangulator;
triangulator.run(cellset, indices, numTri);
vtkm::cont::ArrayHandle<vtkm::Float32> sf;
sf = scalarField.GetData().Cast<vtkm::cont::ArrayHandle<vtkm::Float32> >();
vtkm::cont::DynamicArrayHandleCoordinateSystem dcoords = coords.GetData();
vtkm::cont::ArrayHandleUniformPointCoordinates uVerts;
vtkm::cont::ArrayHandle< vtkm::Vec<vtkm::Float32,3> > eVerts;
if(dcoords.IsSameType(vtkm::cont::ArrayHandleUniformPointCoordinates()))
{
uVerts = dcoords.Cast<vtkm::cont::ArrayHandleUniformPointCoordinates>();
RenderTriangles(numTri, uVerts, indices, sf, colorTable, scalarBounds);
}
else if(dcoords.IsSameType(vtkm::cont::ArrayHandle< vtkm::Vec<vtkm::Float32,3> >()))
{
eVerts = dcoords.Cast<vtkm::cont::ArrayHandle< vtkm::Vec<vtkm::Float32,3> > > ();
RenderTriangles(numTri, eVerts, indices, sf, colorTable, scalarBounds);
}
else if(dcoords.IsSameType(vtkm::cont::ArrayHandleCartesianProduct<
vtkm::cont::ArrayHandle<vtkm::FloatDefault>,
vtkm::cont::ArrayHandle<vtkm::FloatDefault>,
vtkm::cont::ArrayHandle<vtkm::FloatDefault> >()))
{
vtkm::cont::ArrayHandleCartesianProduct<
vtkm::cont::ArrayHandle<vtkm::FloatDefault>,
vtkm::cont::ArrayHandle<vtkm::FloatDefault>,
vtkm::cont::ArrayHandle<vtkm::FloatDefault> > rVerts;
rVerts = dcoords.Cast<vtkm::cont::ArrayHandleCartesianProduct<
vtkm::cont::ArrayHandle<vtkm::FloatDefault>,
vtkm::cont::ArrayHandle<vtkm::FloatDefault>,
vtkm::cont::ArrayHandle<vtkm::FloatDefault> > > ();
RenderTriangles(numTri, rVerts, indices, sf, colorTable, scalarBounds);
}
glFinish();
glFlush();
vtkm::cont::ArrayHandle< vtkm::Vec<vtkm::Id, 4> > indices;
vtkm::Id numTri;
Triangulator<DeviceAdapter> triangulator;
triangulator.run(cellset, indices, numTri);
vtkm::cont::ArrayHandle<vtkm::Float32> sf;
sf = scalarField.GetData().Cast<vtkm::cont::ArrayHandle<vtkm::Float32> >();
vtkm::cont::DynamicArrayHandleCoordinateSystem dcoords = coords.GetData();
vtkm::cont::ArrayHandleUniformPointCoordinates uVerts;
vtkm::cont::ArrayHandle< vtkm::Vec<vtkm::Float32,3> > eVerts;
if(dcoords.IsSameType(vtkm::cont::ArrayHandleUniformPointCoordinates()))
{
uVerts = dcoords.Cast<vtkm::cont::ArrayHandleUniformPointCoordinates>();
RenderTriangles(numTri, uVerts, indices, sf, colorTable, scalarBounds);
}
else if(dcoords.IsSameType(vtkm::cont::ArrayHandle< vtkm::Vec<vtkm::Float32,3> >()))
{
eVerts = dcoords.Cast<vtkm::cont::ArrayHandle< vtkm::Vec<vtkm::Float32,3> > > ();
RenderTriangles(numTri, eVerts, indices, sf, colorTable, scalarBounds);
}
else if(dcoords.IsSameType(vtkm::cont::ArrayHandleCartesianProduct<
vtkm::cont::ArrayHandle<vtkm::FloatDefault>,
vtkm::cont::ArrayHandle<vtkm::FloatDefault>,
vtkm::cont::ArrayHandle<vtkm::FloatDefault> >()))
{
vtkm::cont::ArrayHandleCartesianProduct<
vtkm::cont::ArrayHandle<vtkm::FloatDefault>,
vtkm::cont::ArrayHandle<vtkm::FloatDefault>,
vtkm::cont::ArrayHandle<vtkm::FloatDefault> > rVerts;
rVerts = dcoords.Cast<vtkm::cont::ArrayHandleCartesianProduct<
vtkm::cont::ArrayHandle<vtkm::FloatDefault>,
vtkm::cont::ArrayHandle<vtkm::FloatDefault>,
vtkm::cont::ArrayHandle<vtkm::FloatDefault> > > ();
RenderTriangles(numTri, rVerts, indices, sf, colorTable, scalarBounds);
}
glFinish();
glFlush();
}
template <typename PtType>
......@@ -101,46 +101,40 @@ public:
const vtkm::rendering::ColorTable &ct,
vtkm::Float64 *scalarBounds)
{
vtkm::Float32 sMin = vtkm::Float32(scalarBounds[0]);
vtkm::Float32 sMax = vtkm::Float32(scalarBounds[1]);
vtkm::Float32 sDiff = sMax-sMin;
glBegin(GL_TRIANGLES);
for (int i = 0; i < numTri; i++)
{
vtkm::Vec<vtkm::Id, 4> idx = indices.GetPortalConstControl().Get(i);
vtkm::Id si = indices.GetPortalConstControl().Get(i)[0];
vtkm::Id i1 = indices.GetPortalConstControl().Get(i)[1];
vtkm::Id i2 = indices.GetPortalConstControl().Get(i)[2];
vtkm::Id i3 = indices.GetPortalConstControl().Get(i)[3];
vtkm::Vec<vtkm::Float32, 3> p1 = verts.GetPortalConstControl().Get(i1);
vtkm::Vec<vtkm::Float32, 3> p2 = verts.GetPortalConstControl().Get(i2);
vtkm::Vec<vtkm::Float32, 3> p3 = verts.GetPortalConstControl().Get(i3);
vtkm::Float32 s = scalar.GetPortalConstControl().Get(i1);
s = (s-sMin)/sDiff;
Color color = ct.MapRGB(s);
glColor3fv(color.Components);
glVertex3f(p1[0],p1[1],p1[2]);
s = scalar.GetPortalConstControl().Get(i2);
s = (s-sMin)/sDiff;
color = ct.MapRGB(s);
glColor3fv(color.Components);
glVertex3f(p2[0],p2[1],p2[2]);
s = scalar.GetPortalConstControl().Get(i3);
s = (s-sMin)/sDiff;
color = ct.MapRGB(s);
glColor3fv(color.Components);
glVertex3f(p3[0],p3[1],p3[2]);
}
glEnd();
vtkm::Float32 sMin = vtkm::Float32(scalarBounds[0]);
vtkm::Float32 sMax = vtkm::Float32(scalarBounds[1]);
vtkm::Float32 sDiff = sMax-sMin;
glBegin(GL_TRIANGLES);
for (int i = 0; i < numTri; i++)
{
vtkm::Vec<vtkm::Id, 4> idx = indices.GetPortalConstControl().Get(i);
vtkm::Vec<vtkm::Float32, 3> p1 = verts.GetPortalConstControl().Get(idx[1]);
vtkm::Vec<vtkm::Float32, 3> p2 = verts.GetPortalConstControl().Get(idx[2]);
vtkm::Vec<vtkm::Float32, 3> p3 = verts.GetPortalConstControl().Get(idx[3]);
vtkm::Float32 s = scalar.GetPortalConstControl().Get(i1);
s = (s-sMin)/sDiff;
Color color = ct.MapRGB(s);
glColor3fv(color.Components);
glVertex3f(p1[0],p1[1],p1[2]);
s = scalar.GetPortalConstControl().Get(i2);
s = (s-sMin)/sDiff;
color = ct.MapRGB(s);
glColor3fv(color.Components);
glVertex3f(p2[0],p2[1],p2[2]);
s = scalar.GetPortalConstControl().Get(i3);
s = (s-sMin)/sDiff;
color = ct.MapRGB(s);
glColor3fv(color.Components);
glVertex3f(p3[0],p3[1],p3[2]);
}
glEnd();
}
private:
};
}} //namespace vtkm::rendering
......
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