2018-02-27 14:24:46 +00:00
|
|
|
//============================================================================
|
|
|
|
// Copyright (c) Kitware, Inc.
|
|
|
|
// All rights reserved.
|
|
|
|
// See LICENSE.txt for details.
|
2019-04-15 23:24:21 +00:00
|
|
|
//
|
2018-02-27 14:24:46 +00:00
|
|
|
// 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_CrossProduct_h
|
|
|
|
#define vtk_m_filter_CrossProduct_h
|
|
|
|
|
|
|
|
#include <vtkm/filter/FilterField.h>
|
|
|
|
#include <vtkm/worklet/CrossProduct.h>
|
|
|
|
|
|
|
|
namespace vtkm
|
|
|
|
{
|
|
|
|
namespace filter
|
|
|
|
{
|
|
|
|
|
|
|
|
class CrossProduct : public vtkm::filter::FilterField<CrossProduct>
|
|
|
|
{
|
|
|
|
public:
|
2020-03-19 22:51:43 +00:00
|
|
|
//CrossProduct filter only works on vec3 data.
|
|
|
|
using SupportedTypes = vtkm::TypeListFieldVec3;
|
2019-08-02 02:03:04 +00:00
|
|
|
|
2018-02-27 14:24:46 +00:00
|
|
|
VTKM_CONT
|
|
|
|
CrossProduct();
|
|
|
|
|
2018-03-26 01:34:43 +00:00
|
|
|
//@{
|
|
|
|
/// Choose the primary field to operate on. In the cross product operation A x B, A is
|
|
|
|
/// the primary field.
|
2018-02-27 14:24:46 +00:00
|
|
|
VTKM_CONT
|
2018-03-25 16:43:49 +00:00
|
|
|
void SetPrimaryField(
|
|
|
|
const std::string& name,
|
2018-05-18 20:10:15 +00:00
|
|
|
vtkm::cont::Field::Association association = vtkm::cont::Field::Association::ANY)
|
2018-03-25 16:43:49 +00:00
|
|
|
{
|
|
|
|
this->SetActiveField(name, association);
|
|
|
|
}
|
|
|
|
|
2018-06-14 18:18:08 +00:00
|
|
|
VTKM_CONT const std::string& GetPrimaryFieldName() const { return this->GetActiveFieldName(); }
|
2018-05-18 20:10:15 +00:00
|
|
|
VTKM_CONT vtkm::cont::Field::Association GetPrimaryFieldAssociation() const
|
2018-03-26 01:34:43 +00:00
|
|
|
{
|
2018-06-14 18:18:08 +00:00
|
|
|
return this->GetActiveFieldAssociation();
|
2018-03-26 01:34:43 +00:00
|
|
|
}
|
|
|
|
//@}
|
|
|
|
|
|
|
|
//@{
|
|
|
|
/// When set to true, uses a coordinate system as the primary field instead of the one selected
|
|
|
|
/// by name. Use SetPrimaryCoordinateSystem to select which coordinate system.
|
|
|
|
VTKM_CONT
|
|
|
|
void SetUseCoordinateSystemAsPrimaryField(bool flag)
|
|
|
|
{
|
|
|
|
this->SetUseCoordinateSystemAsField(flag);
|
|
|
|
}
|
|
|
|
VTKM_CONT
|
|
|
|
bool GetUseCoordinateSystemAsPrimaryField() const
|
|
|
|
{
|
|
|
|
return this->GetUseCoordinateSystemAsField();
|
|
|
|
}
|
|
|
|
//@}
|
|
|
|
|
|
|
|
//@{
|
|
|
|
/// Select the coordinate system index to use as the primary field. This only has an effect when
|
|
|
|
/// UseCoordinateSystemAsPrimaryField is true.
|
|
|
|
VTKM_CONT
|
|
|
|
void SetPrimaryCoordinateSystem(vtkm::Id index) { this->SetActiveCoordinateSystem(index); }
|
|
|
|
VTKM_CONT
|
|
|
|
vtkm::Id GetPrimaryCoordinateSystemIndex() const
|
|
|
|
{
|
|
|
|
return this->GetActiveCoordinateSystemIndex();
|
|
|
|
}
|
|
|
|
//@}
|
|
|
|
|
|
|
|
//@{
|
|
|
|
/// Choose the secondary field to operate on. In the cross product operation A x B, B is
|
|
|
|
/// the secondary field.
|
2018-03-25 16:43:49 +00:00
|
|
|
VTKM_CONT
|
|
|
|
void SetSecondaryField(
|
|
|
|
const std::string& name,
|
2018-05-18 20:10:15 +00:00
|
|
|
vtkm::cont::Field::Association association = vtkm::cont::Field::Association::ANY)
|
2018-03-25 16:43:49 +00:00
|
|
|
{
|
|
|
|
this->SecondaryFieldName = name;
|
|
|
|
this->SecondaryFieldAssociation = association;
|
|
|
|
}
|
2018-02-27 14:24:46 +00:00
|
|
|
|
2018-06-14 18:18:08 +00:00
|
|
|
VTKM_CONT const std::string& GetSecondaryFieldName() const { return this->SecondaryFieldName; }
|
2018-05-18 20:10:15 +00:00
|
|
|
VTKM_CONT vtkm::cont::Field::Association GetSecondaryFieldAssociation() const
|
2018-03-26 01:34:43 +00:00
|
|
|
{
|
2018-06-14 18:18:08 +00:00
|
|
|
return this->SecondaryFieldAssociation;
|
2018-03-26 01:34:43 +00:00
|
|
|
}
|
|
|
|
//@}
|
|
|
|
|
|
|
|
//@{
|
|
|
|
/// When set to true, uses a coordinate system as the primary field instead of the one selected
|
|
|
|
/// by name. Use SetPrimaryCoordinateSystem to select which coordinate system.
|
|
|
|
VTKM_CONT
|
|
|
|
void SetUseCoordinateSystemAsSecondaryField(bool flag)
|
|
|
|
{
|
|
|
|
this->UseCoordinateSystemAsSecondaryField = flag;
|
|
|
|
}
|
|
|
|
VTKM_CONT
|
|
|
|
bool GetUseCoordinateSystemAsSecondaryField() const
|
|
|
|
{
|
|
|
|
return this->UseCoordinateSystemAsSecondaryField;
|
|
|
|
}
|
|
|
|
//@}
|
|
|
|
|
|
|
|
//@{
|
|
|
|
/// Select the coordinate system index to use as the primary field. This only has an effect when
|
|
|
|
/// UseCoordinateSystemAsPrimaryField is true.
|
|
|
|
VTKM_CONT
|
|
|
|
void SetSecondaryCoordinateSystem(vtkm::Id index)
|
|
|
|
{
|
|
|
|
this->SecondaryCoordinateSystemIndex = index;
|
|
|
|
}
|
|
|
|
VTKM_CONT
|
|
|
|
vtkm::Id GetSecondaryCoordinateSystemIndex() const
|
|
|
|
{
|
|
|
|
return this->SecondaryCoordinateSystemIndex;
|
|
|
|
}
|
|
|
|
//@}
|
|
|
|
|
2018-08-30 15:53:18 +00:00
|
|
|
template <typename T, typename StorageType, typename DerivedPolicy>
|
2018-04-02 21:58:21 +00:00
|
|
|
VTKM_CONT vtkm::cont::DataSet DoExecute(
|
2018-02-27 14:24:46 +00:00
|
|
|
const vtkm::cont::DataSet& input,
|
|
|
|
const vtkm::cont::ArrayHandle<vtkm::Vec<T, 3>, StorageType>& field,
|
|
|
|
const vtkm::filter::FieldMetadata& fieldMeta,
|
2018-08-30 15:53:18 +00:00
|
|
|
vtkm::filter::PolicyBase<DerivedPolicy> policy);
|
2018-02-27 14:24:46 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
std::string SecondaryFieldName;
|
2018-05-18 20:10:15 +00:00
|
|
|
vtkm::cont::Field::Association SecondaryFieldAssociation;
|
2018-03-26 01:34:43 +00:00
|
|
|
bool UseCoordinateSystemAsSecondaryField;
|
|
|
|
vtkm::Id SecondaryCoordinateSystemIndex;
|
2018-02-27 14:24:46 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
} // namespace vtkm::filter
|
|
|
|
|
|
|
|
#include <vtkm/filter/CrossProduct.hxx>
|
|
|
|
|
|
|
|
#endif // vtk_m_filter_CrossProduct_h
|