//============================================================================ // 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 #include #include #include namespace vtkm { namespace filter { //---------------------------------------------------------------------------- template inline VTKM_CONT FilterField::FilterField() : OutputFieldName() , CoordinateSystemIndex(0) , ActiveFieldName() , ActiveFieldAssociation(vtkm::cont::Field::Association::ANY) , UseCoordinateSystemAsField(false) { } //---------------------------------------------------------------------------- template inline VTKM_CONT FilterField::~FilterField() { } //----------------------------------------------------------------------------- template template VTKM_CONT vtkm::cont::DataSet FilterField::PrepareForExecution( const vtkm::cont::DataSet& input, vtkm::filter::PolicyBase policy) { if (this->UseCoordinateSystemAsField) { // we need to state that the field is actually a coordinate system, so that // the filter uses the proper policy to convert the types. return this->PrepareForExecution( input, input.GetCoordinateSystem(this->GetActiveCoordinateSystemIndex()), policy); } else { return this->PrepareForExecution( input, input.GetField(this->GetActiveFieldName(), this->GetActiveFieldAssociation()), policy); } } //----------------------------------------------------------------------------- template template VTKM_CONT vtkm::cont::DataSet FilterField::PrepareForExecution( const vtkm::cont::DataSet& input, const vtkm::cont::Field& field, vtkm::filter::PolicyBase policy) { vtkm::filter::FieldMetadata metaData(field); vtkm::cont::DataSet result; vtkm::cont::CastAndCall( vtkm::filter::ApplyPolicyFieldActive(field, policy, vtkm::filter::FilterTraits()), internal::ResolveFieldTypeAndExecute(), static_cast(this), input, metaData, policy, result); return result; } //----------------------------------------------------------------------------- template template VTKM_CONT vtkm::cont::DataSet FilterField::PrepareForExecution( const vtkm::cont::DataSet& input, const vtkm::cont::CoordinateSystem& field, vtkm::filter::PolicyBase policy) { //We have a special signature just for CoordinateSystem, so that we can ask //the policy for the storage types and value types just for coordinate systems vtkm::filter::FieldMetadata metaData(field); vtkm::cont::DataSet result; using Traits = vtkm::filter::FilterTraits; constexpr bool supportsVec3 = vtkm::ListHas::value; using supportsCoordinateSystem = std::integral_constant; vtkm::cont::ConditionalCastAndCall(supportsCoordinateSystem(), field, internal::ResolveFieldTypeAndExecute(), static_cast(this), input, metaData, policy, result); return result; } } }