MarchingCubes is now able to not generate normals.

This commit is contained in:
Robert Maynard 2016-01-04 16:53:46 -05:00
parent 502e7c28f2
commit 82a573f712
2 changed files with 24 additions and 16 deletions

@ -129,9 +129,11 @@ public:
VTKM_CONT_EXPORT
IsosurfaceGenerate(FieldType isovalue,
bool generateNormals,
const vtkm::worklet::ScatterCounting& scatter,
IdPortalConstType edgeTable) : EdgeTable(edgeTable),
Isovalue(isovalue),
GenerateNormals(generateNormals),
Scatter(scatter) { }
template<typename CellShapeTag,
@ -185,25 +187,35 @@ public:
vertexOut[triVertex] = vtkm::Lerp(coords[edgeVertex0],
coords[edgeVertex1],
interpolant);
const vtkm::Vec<vtkm::FloatDefault,3> edgePCoord0 =
vtkm::exec::ParametricCoordinatesPoint(
fieldIn.GetNumberOfComponents(), edgeVertex0, shape, *this);
const vtkm::Vec<vtkm::FloatDefault,3> edgePCoord1 =
vtkm::exec::ParametricCoordinatesPoint(
fieldIn.GetNumberOfComponents(), edgeVertex1, shape, *this);
const vtkm::Vec<vtkm::FloatDefault,3> interpPCoord =
vtkm::Lerp(edgePCoord0, edgePCoord1, interpolant);
normalsOut[triVertex] =
vtkm::Normal(vtkm::exec::CellDerivative(
fieldIn, coords, interpPCoord, shape, *this));
interpolationIds[triVertex][0] = indices[edgeVertex0];
interpolationIds[triVertex][1] = indices[edgeVertex1];
interpolationWeights[triVertex] = interpolant;
//conditionally do these only if we want to generate normals
if(this->GenerateNormals)
{
const vtkm::Vec<vtkm::FloatDefault,3> edgePCoord0 =
vtkm::exec::ParametricCoordinatesPoint(
fieldIn.GetNumberOfComponents(), edgeVertex0, shape, *this);
const vtkm::Vec<vtkm::FloatDefault,3> edgePCoord1 =
vtkm::exec::ParametricCoordinatesPoint(
fieldIn.GetNumberOfComponents(), edgeVertex1, shape, *this);
const vtkm::Vec<vtkm::FloatDefault,3> interpPCoord =
vtkm::Lerp(edgePCoord0, edgePCoord1, interpolant);
normalsOut[triVertex] =
vtkm::Normal(vtkm::exec::CellDerivative(
fieldIn, coords, interpPCoord, shape, *this));
}
}
}
private:
const FieldType Isovalue;
bool GenerateNormals;
ScatterType Scatter;
};
@ -271,6 +283,7 @@ public:
vtkm::worklet::ScatterCounting scatter(numOutputTrisPerCell, DeviceAdapter());
IsosurfaceGenerate isosurface(isovalue,
true, //always generate normals.
scatter,
edgeTable.PrepareForInput(DeviceAdapter()));

@ -137,11 +137,6 @@ struct SubtractToVisitIndexKernel : vtkm::exec::FunctorBase
///
struct ScatterCounting
{
VTKM_CONT_EXPORT
ScatterCounting()
{
}
template<typename CountArrayType, typename Device>
VTKM_CONT_EXPORT
ScatterCounting(const CountArrayType &countArray, Device)