//============================================================================ // Copyright (c) Kitware, Inc. // All rights reserved. // See LICENSE.txt for details. // // This software is distributed WITHOUT ANY WARRANTY; without even // the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // PURPOSE. See the above copyright notice for more information. //============================================================================ #ifndef vtk_m_filter_StreamSurface_hxx #define vtk_m_filter_StreamSurface_hxx #include #include #include #include #include #include #include namespace vtkm { namespace filter { //----------------------------------------------------------------------------- inline VTKM_CONT StreamSurface::StreamSurface() : vtkm::filter::FilterDataSetWithField() , Worklet() { } //----------------------------------------------------------------------------- template inline VTKM_CONT vtkm::cont::DataSet StreamSurface::DoExecute( const vtkm::cont::DataSet& input, const vtkm::cont::ArrayHandle, StorageType>& field, const vtkm::filter::FieldMetadata& fieldMeta, const vtkm::filter::PolicyBase&) { //Check for some basics. if (this->Seeds.GetNumberOfValues() == 0) throw vtkm::cont::ErrorFilterExecution("No seeds provided."); const vtkm::cont::DynamicCellSet& cells = input.GetCellSet(); const vtkm::cont::CoordinateSystem& coords = input.GetCoordinateSystem(this->GetActiveCoordinateSystemIndex()); if (!fieldMeta.IsPointField()) throw vtkm::cont::ErrorFilterExecution("Point field expected."); using FieldHandle = vtkm::cont::ArrayHandle, StorageType>; using GridEvalType = vtkm::worklet::particleadvection::GridEvaluator; using RK4Type = vtkm::worklet::particleadvection::RK4Integrator; //compute streamlines GridEvalType eval(coords, cells, field); RK4Type rk4(eval, this->StepSize); vtkm::worklet::Streamline streamline; vtkm::cont::ArrayHandle seedArray; vtkm::cont::ArrayCopy(this->Seeds, seedArray); auto res = streamline.Run(rk4, seedArray, this->NumberOfSteps); //compute surface from streamlines vtkm::cont::ArrayHandle srfPoints; vtkm::cont::CellSetSingleType<> srfCells; vtkm::cont::CoordinateSystem slCoords("coordinates", res.Positions); this->Worklet.Run(slCoords, res.PolyLines, srfPoints, srfCells); vtkm::cont::DataSet outData; vtkm::cont::CoordinateSystem outputCoords("coordinates", srfPoints); outData.AddCoordinateSystem(outputCoords); outData.SetCellSet(srfCells); return outData; } //----------------------------------------------------------------------------- template inline VTKM_CONT bool StreamSurface::DoMapField(vtkm::cont::DataSet&, const vtkm::cont::ArrayHandle&, const vtkm::filter::FieldMetadata&, vtkm::filter::PolicyBase) { return false; } } } // namespace vtkm::filter #endif