Commit 23d8d585 authored by Dave Pugmire's avatar Dave Pugmire
Browse files

Add explicit 1D rendering. Also added some data model suport.

parent db522c4c
......@@ -439,11 +439,11 @@ public:
virtual void PrintSummary(std::ostream &out) const
{
out << " ExplicitCellSet: " << this->Name << std::endl;
out << " PointToCell: " << std::endl;
this->PointToCell.PrintSummary(out);
out << " CellToPoint: " << std::endl;
this->CellToPoint.PrintSummary(out);
out << " ExplicitCellSet: " << this->Name << std::endl;
out << " PointToCell: " << std::endl;
this->PointToCell.PrintSummary(out);
out << " CellToPoint: " << std::endl;
this->CellToPoint.PrintSummary(out);
}
template<typename FromTopology, typename ToTopology>
......
......@@ -171,6 +171,21 @@ public:
this->PointToCell.IndexOffsetsValid = true;
}
VTKM_CONT
vtkm::Id GetCellTypeAsId() const
{
return this->CellTypeAsId;
}
virtual void PrintSummary(std::ostream &out) const
{
out << " ExplicitSingleCellSet: " << this->Name << " Type "<<this->CellTypeAsId<<std::endl;
out << " PointToCell: " << std::endl;
this->PointToCell.PrintSummary(out);
out << " CellToPoint: " << std::endl;
this->CellToPoint.PrintSummary(out);
}
private:
template< typename CellShapeTag>
void DetermineNumberOfPoints(CellShapeTag,
......
......@@ -51,6 +51,23 @@ public:
//TODO
//Zoo explicit cell
template<typename T>
VTKM_CONT
static
vtkm::cont::DataSet
Create(const std::vector<T> &xVals,
const std::vector<vtkm::UInt8> &shapes,
const std::vector<vtkm::IdComponent> &numIndices,
const std::vector<vtkm::Id> &connectivity,
const std::string &coordsNm="coords",
const std::string &cellNm="cells")
{
std::vector<T> yVals(xVals.size(),0), zVals(xVals.size(),0);
return DataSetBuilderExplicit::Create(xVals,yVals,zVals,
shapes,numIndices,connectivity,
coordsNm,cellNm);
}
template<typename T>
VTKM_CONT
static
......@@ -452,7 +469,6 @@ DataSetBuilderExplicitIterative::Create()
}
#if 0
template<typename T, typename CellType>
vtkm::cont::DataSet
......
......@@ -37,6 +37,8 @@ class MakeTestDataSet
public:
// 1D uniform datasets.
vtkm::cont::DataSet Make1DUniformDataSet0();
// 1D explicit datasets.
vtkm::cont::DataSet Make1DExplicitDataSet0();
// 2D uniform datasets.
vtkm::cont::DataSet Make2DUniformDataSet0();
......@@ -63,27 +65,47 @@ public:
};
//Make a simple 1D dataset.
inline vtkm::cont::DataSet
MakeTestDataSet::Make1DUniformDataSet0()
{
vtkm::cont::DataSetBuilderUniform dsb;
vtkm::Id dimension = 6;
vtkm::cont::DataSet dataSet = dsb.Create(dimension);
vtkm::cont::DataSetBuilderUniform dsb;
const vtkm::Id nVerts = 6;
vtkm::cont::DataSet dataSet = dsb.Create(nVerts);
vtkm::cont::DataSetFieldAdd dsf;
const vtkm::Id nVerts = 6;
vtkm::Float32 var[nVerts] = {-1.0f, .5f, -.2f, 1.7f, -.1f, .8f};
vtkm::cont::DataSetFieldAdd dsf;
vtkm::Float32 var[nVerts] = {-1.0f, .5f, -.2f, 1.7f, -.1f, .8f};
dsf.AddPointField(dataSet, "pointvar", var, nVerts);
return dataSet;
}
dsf.AddPointField(dataSet, "pointvar", var, nVerts);
inline vtkm::cont::DataSet
MakeTestDataSet::Make1DExplicitDataSet0()
{
const int nVerts = 5;
typedef vtkm::Vec<vtkm::Float32,3> CoordType;
std::vector<CoordType> coords(nVerts);
coords[0] = CoordType(0,0,0);
coords[1] = CoordType(1,0,0);
coords[2] = CoordType(1.1,0,0);
coords[3] = CoordType(1.2,0,0);
coords[4] = CoordType(4,0,0);
const vtkm::Id nCells = 6;
vtkm::Float32 cellvar[nCells] = {100.1f, 200.1f, 300.1f, 400.1f, 500.1f};
dsf.AddCellField(dataSet, "cellvar", cellvar, nCells, "cells");
std::vector<vtkm::Id> conn;
for (int i = 0; i < nVerts; i++)
conn.push_back(i);
return dataSet;
}
vtkm::cont::DataSet dataSet;
vtkm::cont::DataSetBuilderExplicit dsb;
dataSet = dsb.Create(coords, vtkm::CellShapeTagLine(), conn, "coordinates", "cells");
vtkm::cont::DataSetFieldAdd dsf;
vtkm::Float32 var[nVerts] = {-1.0f, .5f, -.2f, 1.7f, .8f};
dsf.AddPointField(dataSet, "pointvar", var, nVerts);
return dataSet;
}
//Make a simple 2D, 2 cell uniform dataset.
......
......@@ -96,7 +96,6 @@ void CanvasGL::SetViewToWorldSpace(const vtkm::rendering::Camera &camera,
void CanvasGL::SetViewToScreenSpace(const vtkm::rendering::Camera &camera,
bool clip)
{
std::cout<<"SetViewToScreenSpace"<<std::endl;
vtkm::Float32 oglP[16] = {0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0};
vtkm::Float32 oglM[16] = {0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0};
......
......@@ -168,11 +168,28 @@ struct MapColorAndVerticesInvokeFunctor
template<typename PtType>
VTKM_CONT
void RenderLineSegments(MapperGL &vtkmNotUsed(mapper),
vtkm::Id numVerts, const PtType &verts,
const vtkm::cont::ArrayHandle<vtkm::Float32> &scalar,
const vtkm::Range &vtkmNotUsed(scalarRange),
const vtkm::rendering::Camera &vtkmNotUsed(camera))
void RenderStructuredLineSegments(vtkm::Id numVerts, const PtType &verts,
const vtkm::cont::ArrayHandle<vtkm::Float32> &scalar)
{
glDisable(GL_DEPTH_TEST);
glDisable(GL_LIGHTING);
glLineWidth(1);
glColor3f(1.0, 1.0, 1.0);
glBegin(GL_LINE_STRIP);
for (int i = 0; i < numVerts; i++)
{
vtkm::Vec<vtkm::Float32, 3> pt = verts.GetPortalConstControl().Get(i);
vtkm::Float32 s = scalar.GetPortalConstControl().Get(i);
glVertex3f(pt[0], s, 0.0f);
}
glEnd();
}
template<typename PtType>
VTKM_CONT
void RenderExplicitLineSegments(vtkm::Id numVerts, const PtType &verts,
const vtkm::cont::ArrayHandle<vtkm::Float32> &scalar)
{
glDisable(GL_DEPTH_TEST);
glDisable(GL_LIGHTING);
......@@ -187,7 +204,6 @@ void RenderLineSegments(MapperGL &vtkmNotUsed(mapper),
glVertex3f(pt[0], s, 0.0f);
}
glEnd();
glFlush();
}
template<typename PtType>
......@@ -207,25 +223,6 @@ void RenderTriangles(MapperGL &mapper,
std::cout << "ERROR: " << glewGetErrorString(GlewInitResult) << std::endl;
mapper.loaded = true;
//DRP
/*
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);
std::cout<<i<<": <"<<p1[0]<<" "<<p1[1]<<" "<<p1[2]<<">"<<std::endl;
std::cout<<" : <"<<p2[0]<<" "<<p2[1]<<" "<<p2[2]<<">"<<std::endl;
std::cout<<" : <"<<p3[0]<<" "<<p3[1]<<" "<<p3[2]<<">"<<std::endl;
}
*/
vtkm::Float32 sMin = vtkm::Float32(scalarRange.Min);
vtkm::Float32 sMax = vtkm::Float32(scalarRange.Max);
vtkm::cont::ArrayHandle<vtkm::Float32> out_vertices, out_color;
......@@ -400,49 +397,57 @@ void MapperGL::RenderCells(const vtkm::cont::DynamicCellSet &cellset,
vtkm::cont::ArrayHandle<vtkm::Float32> sf;
sf = scalarField.GetData().Cast<vtkm::cont::ArrayHandle<vtkm::Float32> >();
vtkm::cont::DynamicArrayHandleCoordinateSystem dcoords = coords.GetData();
if (cellset.IsSameType(vtkm::cont::CellSetStructured<1>()))
{
vtkm::cont::ArrayHandleUniformPointCoordinates verts;
verts = dcoords.Cast<vtkm::cont::ArrayHandleUniformPointCoordinates>();
vtkm::Id numVerts = coords.GetData().GetNumberOfValues();
RenderLineSegments(*this, numVerts, verts, sf, scalarRange, camera);
glFinish();
glFlush();
return;
}
vtkm::cont::ArrayHandle< vtkm::Vec<vtkm::Id, 4> > indices;
vtkm::Id numTri;
vtkm::rendering::internal::RunTriangulator(cellset, indices, numTri);
vtkm::cont::ArrayHandleUniformPointCoordinates uVerts;
vtkm::cont::ArrayHandle< vtkm::Vec<vtkm::Float32,3> > eVerts;
vtkm::Id numVerts = coords.GetData().GetNumberOfValues();
if(dcoords.IsSameType(vtkm::cont::ArrayHandleUniformPointCoordinates()))
//Handle 1D cases.
if (cellset.IsSameType(vtkm::cont::CellSetStructured<1>()))
{
uVerts = dcoords.Cast<vtkm::cont::ArrayHandleUniformPointCoordinates>();
RenderTriangles(*this, numTri, uVerts, indices, sf, colorTable, scalarRange, camera);
vtkm::cont::ArrayHandleUniformPointCoordinates verts;
verts = dcoords.Cast<vtkm::cont::ArrayHandleUniformPointCoordinates>();
RenderStructuredLineSegments(numVerts, verts, sf);
}
else if(dcoords.IsSameType(vtkm::cont::ArrayHandle< vtkm::Vec<vtkm::Float32,3> >()))
else if (cellset.IsSameType(vtkm::cont::CellSetSingleType<>()) &&
cellset.Cast<vtkm::cont::CellSetSingleType<> >().GetCellTypeAsId() ==
vtkm::CELL_SHAPE_LINE)
{
eVerts = dcoords.Cast<vtkm::cont::ArrayHandle< vtkm::Vec<vtkm::Float32,3> > > ();
RenderTriangles(*this, numTri, eVerts, indices, sf, colorTable, scalarRange, camera);
vtkm::cont::ArrayHandle< vtkm::Vec<vtkm::Float32,3> > verts;
verts = dcoords.Cast<vtkm::cont::ArrayHandle< vtkm::Vec<vtkm::Float32,3> > > ();
RenderExplicitLineSegments(numVerts, verts, sf);
}
else if(dcoords.IsSameType(vtkm::cont::ArrayHandleCartesianProduct<
vtkm::cont::ArrayHandle<vtkm::FloatDefault>,
vtkm::cont::ArrayHandle<vtkm::FloatDefault>,
vtkm::cont::ArrayHandle<vtkm::FloatDefault> >()))
else
{
vtkm::cont::ArrayHandleCartesianProduct<
vtkm::cont::ArrayHandle< vtkm::Vec<vtkm::Id, 4> > indices;
vtkm::Id numTri;
vtkm::rendering::internal::RunTriangulator(cellset, indices, numTri);
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(*this, numTri, uVerts, indices, sf, colorTable, scalarRange, camera);
}
else if(dcoords.IsSameType(vtkm::cont::ArrayHandle< vtkm::Vec<vtkm::Float32,3> >()))
{
eVerts = dcoords.Cast<vtkm::cont::ArrayHandle< vtkm::Vec<vtkm::Float32,3> > > ();
RenderTriangles(*this, numTri, eVerts, indices, sf, colorTable, scalarRange, camera);
}
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<
rVerts = dcoords.Cast<vtkm::cont::ArrayHandleCartesianProduct<
vtkm::cont::ArrayHandle<vtkm::FloatDefault>,
vtkm::cont::ArrayHandle<vtkm::FloatDefault>,
vtkm::cont::ArrayHandle<vtkm::FloatDefault> > > ();
RenderTriangles(*this, numTri, rVerts, indices, sf, colorTable, scalarRange, camera);
RenderTriangles(*this, numTri, rVerts, indices, sf, colorTable, scalarRange, camera);
}
}
glFinish();
glFlush();
......
......@@ -68,7 +68,6 @@ SetCamera<vtkm::rendering::View2D>(vtkm::rendering::Camera &camera,
camera.SetViewport(-0.7f, +0.7f, -0.7f, +0.7f);
}
//DRP
template <>
inline void
SetCamera<vtkm::rendering::View1D>(vtkm::rendering::Camera &camera,
......@@ -119,7 +118,6 @@ Render(const vtkm::cont::DataSet &ds,
Render<MapperType, CanvasType, ViewType>(view, outputFile);
}
//DRP
template <typename MapperType,typename CanvasType, typename ViewType>
void
Render(const vtkm::cont::DataSet &ds,
......@@ -140,7 +138,6 @@ Render(const vtkm::cont::DataSet &ds,
ds.GetField(fieldNm));
ViewType view(scene, mapper, canvas, camera,
vtkm::rendering::Color(0.2f, 0.2f, 0.2f, 1.0f));
Render<MapperType, CanvasType, ViewType>(view, outputFile);
}
......
......@@ -42,8 +42,7 @@ void RenderTests()
vtkm::cont::testing::MakeTestDataSet maker;
vtkm::rendering::ColorTable colorTable("thermal");
/*
vtkm::rendering::testing::Render<M,C,V3>(maker.Make3DRegularDataSet0(),
"pointvar", colorTable, "reg3D.pnm");
vtkm::rendering::testing::Render<M,C,V3>(maker.Make3DRectilinearDataSet0(),
......@@ -52,9 +51,10 @@ void RenderTests()
"pointvar", colorTable, "expl3D.pnm");
vtkm::rendering::testing::Render<M,C,V2>(maker.Make2DRectilinearDataSet0(),
"pointvar", colorTable, "rect2D.pnm");
*/
vtkm::rendering::testing::Render<M,C,V1>(maker.Make1DUniformDataSet0(),
"pointvar", "uniform1D.pnm");
vtkm::rendering::testing::Render<M,C,V1>(maker.Make1DExplicitDataSet0(),
"pointvar", "expl1D.pnm");
}
} //namespace
......
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