//============================================================================ // 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. //============================================================================ #include #include #include #include #include #include namespace vtkm { namespace filter { //----------------------------------------------------------------------------- inline VTKM_CONT Streamline::Streamline() : vtkm::filter::FilterDataSetWithField() , Worklet() { } //----------------------------------------------------------------------------- inline VTKM_CONT void Streamline::SetSeeds( vtkm::cont::ArrayHandle>& seeds) { this->Seeds = seeds; } //----------------------------------------------------------------------------- template inline VTKM_CONT vtkm::cont::DataSet Streamline::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(this->GetActiveCellSetIndex()); const vtkm::cont::CoordinateSystem& coords = input.GetCoordinateSystem(this->GetActiveCoordinateSystemIndex()); if (!fieldMeta.IsPointField()) { throw vtkm::cont::ErrorFilterExecution("Point field expected."); } //todo: add check for rectilinear. using FieldHandle = vtkm::cont::ArrayHandle, StorageType>; using GridEvalType = vtkm::worklet::particleadvection::GridEvaluator; using RK4Type = vtkm::worklet::particleadvection::RK4Integrator; GridEvalType eval(coords, cells, field); RK4Type rk4(eval, static_cast(this->StepSize)); vtkm::worklet::Streamline streamline; vtkm::worklet::StreamlineResult res; vtkm::cont::ArrayHandle> seedArray; vtkm::cont::ArrayCopy(this->Seeds, seedArray); res = Worklet.Run(rk4, seedArray, this->NumberOfSteps); vtkm::cont::DataSet outData; vtkm::cont::CoordinateSystem outputCoords("coordinates", res.positions); outData.AddCellSet(res.polyLines); outData.AddCoordinateSystem(outputCoords); return outData; } //----------------------------------------------------------------------------- template inline VTKM_CONT bool Streamline::DoMapField(vtkm::cont::DataSet&, const vtkm::cont::ArrayHandle&, const vtkm::filter::FieldMetadata&, vtkm::filter::PolicyBase) { return false; } } } // namespace vtkm::filter