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

Support for explicit cell sets.

parent 98837735
......@@ -422,7 +422,7 @@ MakeTestDataSet::Make3DExplicitDataSet4()
CoordType(2, 1, 1), //10
CoordType(2, 1, 0) //11
};
vtkm::Float64 vars[nVerts] = {10.1f, 20.1f, 30.2f, 40.2f, 50.3f, 60.2f, 70.2f, 80.3f, 90.f, 10.f, 11.f, 12.f};
vtkm::Float32 vars[nVerts] = {10.1f, 20.1f, 30.2f, 40.2f, 50.3f, 60.2f, 70.2f, 80.3f, 90.f, 10.f, 11.f, 12.f};
dataSet.AddCoordinateSystem(
vtkm::cont::CoordinateSystem("coordinates", 1, coordinates, nVerts));
......@@ -470,7 +470,7 @@ MakeTestDataSet::Make3DExplicitDataSet3()
vtkm::cont::DataSet dataSet;
const int nVerts = 4;
typedef vtkm::Vec<vtkm::Float64,3> CoordType;
typedef vtkm::Vec<vtkm::Float32,3> CoordType;
CoordType coordinates[nVerts] = {
CoordType(0, 0, 0),
CoordType(1, 0, 0),
......
......@@ -749,4 +749,4 @@ public:
};
}} // namespace vtkm::rendering
#endif //vtk_m_rendering_Rasterizer_h
\ No newline at end of file
#endif //vtk_m_rendering_Rasterizer_h
......@@ -21,6 +21,8 @@
#define vtk_m_rendering_SceneRendererOSMesa_h
#include <vtkm/cont/DataSet.h>
#include <vtkm/cont/CoordinateSystem.h>
#include <vtkm/cont/DynamicArrayHandle.h>
#include <vtkm/rendering/SceneRenderer.h>
#include <vtkm/rendering/ColorTable.h>
#include <vtkm/rendering/View.h>
......@@ -50,31 +52,44 @@ public:
const vtkm::rendering::ColorTable &colorTable,
vtkm::Float64 *scalarBounds)
{
vtkm::cont::DynamicArrayHandleCoordinateSystem dcoords = coords.GetData();
if (!dcoords.IsSameType(vtkm::cont::ArrayHandleUniformPointCoordinates()))
{
std::cout<<"Only uniform coordinates supported..."<<std::endl;
return;
}
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;
//printSummary_ArrayHandle(indices, std::cout);
vtkm::cont::ArrayHandle<vtkm::Float32> sf;
sf = scalarField.GetData().Cast<vtkm::cont::ArrayHandle<vtkm::Float32> >();
//printSummary_ArrayHandle(sf, std::cout);
vtkm::cont::DynamicArrayHandleCoordinateSystem dcoords = coords.GetData();
vtkm::cont::ArrayHandleUniformPointCoordinates uVerts;
uVerts = dcoords.Cast<vtkm::cont::ArrayHandleUniformPointCoordinates>();
vtkm::rendering::ColorTable ct = colorTable;
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);
}
glFinish();
glFlush();
}
template <typename PtType>
VTKM_CONT_EXPORT
void RenderTriangles(vtkm::Id numTri, const PtType &verts,
const vtkm::cont::ArrayHandle< vtkm::Vec<vtkm::Id, 4> > &indices,
const vtkm::cont::ArrayHandle<vtkm::Float32> &scalar,
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++)
{
......@@ -84,42 +99,30 @@ public:
vtkm::Id i2 = indices.GetPortalConstControl().Get(i)[2];
vtkm::Id i3 = indices.GetPortalConstControl().Get(i)[3];
vtkm::Vec<vtkm::Float32, 3> p1 = uVerts.GetPortalConstControl().Get(i1);
vtkm::Vec<vtkm::Float32, 3> p2 = uVerts.GetPortalConstControl().Get(i2);
vtkm::Vec<vtkm::Float32, 3> p3 = uVerts.GetPortalConstControl().Get(i3);
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 = sf.GetPortalConstControl().Get(si);
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<<" color= "<<color.Components[0]<<" "<<color.Components[1]<<" "<<color.Components[2]<<std::endl;
s = sf.GetPortalConstControl().Get(i1);
vtkm::Float32 s = scalar.GetPortalConstControl().Get(i1);
s = (s-sMin)/sDiff;
color = ct.MapRGB(s);
color.Components[0] = 0;
Color color = ct.MapRGB(s);
glColor3fv(color.Components);
glVertex3f(p1[0],p1[1],p1[2]);
s = sf.GetPortalConstControl().Get(i2);
s = scalar.GetPortalConstControl().Get(i2);
s = (s-sMin)/sDiff;
color = ct.MapRGB(s);
color.Components[0] = 0;
glColor3fv(color.Components);
glVertex3f(p2[0],p2[1],p2[2]);
s = sf.GetPortalConstControl().Get(i3);
s = scalar.GetPortalConstControl().Get(i3);
s = (s-sMin)/sDiff;
color = ct.MapRGB(s);
color.Components[0] = 0;
glColor3fv(color.Components);
glVertex3f(p3[0],p3[1],p3[2]);
}
glEnd();
glFinish();
glFlush();
}
private:
......
......@@ -424,9 +424,7 @@ public:
flags.Allocate(outputTriangles);
vtkm::worklet::DispatcherMapField< MemSet< vtkm::UInt8 > >( MemSet< vtkm::UInt8>( 1 ) )
.Invoke( flags );
//Unique triangles will have a flag = 1
std::cout<<"Number of tris "<<outputTriangles<<std::endl;
vtkm::worklet::DispatcherMapField< UniqueTriangles >()
.Invoke( vtkm::exec::ExecutionWholeArrayConst< vtkm::Vec<vtkm::Id,4> >(outputIndices),
vtkm::exec::ExecutionWholeArray< vtkm::UInt8 >(flags));
......@@ -435,7 +433,7 @@ public:
vtkm::cont::DeviceAdapterAlgorithm<DeviceAdapter>::StreamCompact(outputIndices,
flags,
subset);
std::cout<<"Number of tris after"<<subset.GetNumberOfValues()<<std::endl;
std::cout<<"Number of tris after "<<subset.GetNumberOfValues()<<std::endl;
outputIndices = subset;
outputTriangles = subset.GetNumberOfValues();
}
......@@ -502,4 +500,4 @@ public:
}
}; // class Triangulator
}}//namespace vtkm::rendering
#endif //vtk_m_rendering_Triangulator_h
\ No newline at end of file
#endif //vtk_m_rendering_Triangulator_h
......@@ -33,8 +33,6 @@ void TestSceneRendererOSMesa()
{
vtkm::cont::testing::MakeTestDataSet maker;
vtkm::cont::DataSet regularGrid = maker.Make3DRegularDataSet0();
regularGrid.PrintSummary(std::cout);
vtkm::cont::Field scalarField = regularGrid.GetField("pointvar");
const vtkm::cont::CoordinateSystem coords = regularGrid.GetCoordinateSystem();
vtkm::rendering::SceneRendererOSMesa<VTKM_DEFAULT_DEVICE_ADAPTER_TAG> sceneRenderer;
......@@ -67,15 +65,20 @@ void TestSceneRendererOSMesa()
sceneRenderer.SetActiveColorTable(colorTable);
sceneRenderer.SetView(view);
//sceneRenderer.RenderCells(regularGrid.GetCellSet(), coords, scalarField, colorTable);
vtkm::cont::DataSet expDS = maker.Make3DExplicitDataSet4();
//New way.
vtkm::rendering::Scene3D scene;
vtkm::rendering::Color bg(0.2f, 0.2f, 0.2f, 1.0f);
vtkm::rendering::RenderSurfaceOSMesa surface(512,512,bg);
scene.plots.push_back(vtkm::rendering::Plot(regularGrid.GetCellSet(),
coords,
scalarField,
regularGrid.GetCoordinateSystem(),
regularGrid.GetField("pointvar"),
colorTable));
scene.plots.push_back(vtkm::rendering::Plot(expDS.GetCellSet(),
expDS.GetCoordinateSystem(),
expDS.GetField("pointvar"),
colorTable));
vtkm::rendering::Window3D<vtkm::rendering::SceneRendererOSMesa<VTKM_DEFAULT_DEVICE_ADAPTER_TAG>,
......
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