Commit 82a573f7 authored by Robert Maynard's avatar Robert Maynard
Browse files

MarchingCubes is now able to not generate normals.

parent 502e7c28
......@@ -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)
......
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