17 #ifndef vtkToDax_Contour_h
18 #define vtkToDax_Contour_h
31 #include <dax/cont/DispatcherGenerateInterpolatedCells.h>
32 #include <dax/cont/DispatcherMapCell.h>
33 #include <dax/worklet/MarchingCubes.h>
34 #include <dax/worklet/MarchingTetrahedra.h>
38 template <
typename T>
struct MarchingCubesOuputType
40 typedef dax::CellTagTriangle
type;
51 template<
class InGridType,
61 const dax::cont::ArrayHandle<ValueType,Container1,Adapter> &,
64 vtkGenericWarningMacro(
65 <<
"Not calling Dax, GridType-CellType combination not supported");
72 template<
class InGridType,
78 const InGridType &inDaxGrid,
80 OutGridType &outDaxGeom,
83 const dax::cont::ArrayHandle<ValueType,Container1,Adapter> &mcHandle,
86 dax::Scalar isoValueT(isoValue);
88 dax::worklet::MarchingCubesCount countWorklet(isoValueT);
89 dax::worklet::MarchingCubesGenerate generateWorklet(isoValueT);
91 return this->DispatchWork(inDaxGrid,
101 template<
class GridCellContainer,
102 class GridPointContainer,
108 const dax::cont::UnstructuredGrid<
109 dax::CellTagTetrahedron,GridCellContainer,GridPointContainer,Adapter>
112 OutGridType &outDaxGeom,
115 const dax::cont::ArrayHandle<ValueType,Container1,Adapter> &mcHandle,
118 dax::Scalar isoValueT(isoValue);
120 dax::worklet::MarchingTetrahedraCount countWorklet(isoValueT);
121 dax::worklet::MarchingTetrahedraGenerate generateWorklet(isoValueT);
123 return this->DispatchWork(inDaxGrid,
133 template<
class InGridType,
138 class CountWorkletType,
139 class GenerateWorkletType>
141 const InGridType &inDaxGrid,
143 OutGridType &outDaxGeom,
145 CountWorkletType &countWorklet,
146 GenerateWorkletType &generateWorklet,
147 const dax::cont::ArrayHandle<ValueType,Container1,Adapter> &mcHandle,
155 typedef dax::cont::DispatcherGenerateInterpolatedCells<
157 dax::cont::ArrayHandle< dax::Id >,
158 Adapter > DispatchIC;
160 typedef typename DispatchIC::CountHandleType CountHandleType;
162 dax::cont::DispatcherMapCell<CountWorkletType,Adapter>
163 dispatchCount( countWorklet );
165 CountHandleType count;
166 dispatchCount.Invoke(inDaxGrid, mcHandle, count);
169 DispatchIC generateSurface(count, generateWorklet);
170 generateSurface.SetRemoveDuplicatePoints(
true);
171 generateSurface.Invoke(inDaxGrid,outDaxGeom,mcHandle);
186 for (
int arrayIndex = 0;
187 arrayIndex < pd->GetNumberOfArrays();
191 if (array == NULL) {
continue; }
193 compactDispatcher.
Go(array);
197 for (
int attributeType = 0;
201 vtkDataArray *attribute = pd->GetAttribute(attributeType);
202 if (attribute == NULL) {
continue; }
208 catch(
const dax::cont::ErrorControlOutOfMemory& error)
210 std::cerr <<
"Ran out of memory trying to use the GPU" << std::endl;
211 std::cerr << error.GetMessage() << std::endl;
214 catch(
const dax::cont::ErrorExecution& error)
216 std::cerr <<
"Got ErrorExecution from Dax." << std::endl;
217 std::cerr << error.GetMessage() << std::endl;
224 template<
typename FieldType_>
230 typedef typename FieldType::ValueType
T;
236 ComputeScalars(computeScalars),
251 template<
typename LHS,
typename RHS>
259 typedef typename MarchingCubesOuputType< typename VTKCellTypeStruct::DaxCellType >::type OutCellType;
262 typedef typename DataSetTypeToTypeStruct::DaxDataSetType InputDataSetType;
269 dax::cont::UnstructuredGrid<OutCellType,
274 DataSetTypeToTypeStruct());
277 int result = mc(inputDaxData,
283 this->ComputeScalars);
297 #endif //vtkToDax_Contour_h
Contour(const FieldType &f, T value, bool computeScalars)
void dataSetConverter(const dax::cont::UniformGrid<> &grid, vtkImageData *output)
represent and manipulate point attribute data
void Add(Functor fun)
Add in a functor that is mapped to the template SomeLhs parameter.
abstract class to specify dataset behavior
dynamic, self-adjusting array of float
concrete dataset represents vertices, lines, polygons, and triangle strips
dynamic, self-adjusting array of double
vtkPointData * GetPointData()
Return a pointer to this dataset's point data.
void setFieldName(const char *name)
abstract superclass for arrays of numeric data
int DispatchWork(const InGridType &inDaxGrid, vtkDataSet *inVTKGrid, OutGridType &outDaxGeom, vtkPolyData *outVTKGrid, CountWorkletType &countWorklet, GenerateWorkletType &generateWorklet, const dax::cont::ArrayHandle< ValueType, Container1, Adapter > &mcHandle, bool computeScalars)
void setOutputGrid(vtkPolyData *grid)
virtual char * GetName()
Set/get array's name.
Dispatch to functor based on a pointer type.
int operator()(LHS &dataSet, const RHS &) const
ReturnType Go(BaseLhs *lhs)
Given a pointer to an object that derives from the BaseLhs we find the matching functor that was adde...
int operator()(const InGridType &inDaxGrid, vtkDataSet *inVTKGrid, OutGridType &outDaxGeom, vtkPolyData *outVTKGrid, ValueType isoValue, const dax::cont::ArrayHandle< ValueType, Container1, Adapter > &mcHandle, bool computeScalars)
int SetActiveAttribute(const char *name, int attributeType)
Make the array with the given name the active attribute.
int operator()(const dax::cont::UnstructuredGrid< dax::CellTagTetrahedron, GridCellContainer, GridPointContainer, Adapter > &inDaxGrid, vtkDataSet *inVTKGrid, OutGridType &outDaxGeom, vtkPolyData *outVTKGrid, ValueType isoValue, const dax::cont::ArrayHandle< ValueType, Container1, Adapter > &mcHandle, bool computeScalars)
VTKDataSetType::DaxDataSetType dataSetConverter(vtkImageData *input, VTKDataSetType)
int operator()(const InGridType &, vtkDataSet *, OutGridType &, vtkPolyData *, ValueType, const dax::cont::ArrayHandle< ValueType, Container1, Adapter > &, bool)