2016-01-19 14:59:31 +00:00
|
|
|
//============================================================================
|
|
|
|
// 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.
|
|
|
|
//
|
2017-09-20 21:33:44 +00:00
|
|
|
// Copyright 2014 National Technology & Engineering Solutions of Sandia, LLC (NTESS).
|
2016-01-19 14:59:31 +00:00
|
|
|
// Copyright 2014 UT-Battelle, LLC.
|
|
|
|
// Copyright 2014 Los Alamos National Security.
|
|
|
|
//
|
2017-09-20 21:33:44 +00:00
|
|
|
// Under the terms of Contract DE-NA0003525 with NTESS,
|
2016-01-19 14:59:31 +00:00
|
|
|
// the U.S. Government retains certain rights in this software.
|
|
|
|
//
|
|
|
|
// Under the terms of Contract DE-AC52-06NA25396 with Los Alamos National
|
|
|
|
// Laboratory (LANL), the U.S. Government retains certain rights in
|
|
|
|
// this software.
|
|
|
|
//============================================================================
|
|
|
|
|
2017-05-18 14:29:41 +00:00
|
|
|
namespace vtkm
|
|
|
|
{
|
|
|
|
namespace filter
|
|
|
|
{
|
2016-01-19 14:59:31 +00:00
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
2017-05-18 14:29:41 +00:00
|
|
|
inline VTKM_CONT ExternalFaces::ExternalFaces()
|
|
|
|
: vtkm::filter::FilterDataSet<ExternalFaces>()
|
|
|
|
, CompactPoints(false)
|
2017-07-31 14:06:33 +00:00
|
|
|
, Worklet()
|
2016-01-19 14:59:31 +00:00
|
|
|
{
|
2017-08-03 15:19:22 +00:00
|
|
|
this->SetPassPolyData(true);
|
2017-03-07 14:48:59 +00:00
|
|
|
}
|
|
|
|
|
2017-05-18 14:29:41 +00:00
|
|
|
namespace
|
|
|
|
{
|
2017-03-07 14:48:59 +00:00
|
|
|
|
|
|
|
template <typename BasePolicy>
|
|
|
|
struct CellSetExplicitPolicy : public BasePolicy
|
|
|
|
{
|
|
|
|
using AllCellSetList = vtkm::cont::CellSetListTagExplicitDefault;
|
|
|
|
};
|
2016-01-19 14:59:31 +00:00
|
|
|
|
2017-03-07 14:48:59 +00:00
|
|
|
template <typename DerivedPolicy>
|
2017-05-18 14:29:41 +00:00
|
|
|
inline vtkm::filter::PolicyBase<CellSetExplicitPolicy<DerivedPolicy>> GetCellSetExplicitPolicy(
|
|
|
|
const vtkm::filter::PolicyBase<DerivedPolicy>&)
|
2017-03-07 14:48:59 +00:00
|
|
|
{
|
|
|
|
return vtkm::filter::PolicyBase<CellSetExplicitPolicy<DerivedPolicy>>();
|
2016-01-19 14:59:31 +00:00
|
|
|
}
|
|
|
|
|
2017-03-07 14:48:59 +00:00
|
|
|
} // anonymous namespace
|
|
|
|
|
2016-01-19 14:59:31 +00:00
|
|
|
//-----------------------------------------------------------------------------
|
2017-05-18 14:29:41 +00:00
|
|
|
template <typename DerivedPolicy, typename DeviceAdapter>
|
2018-04-02 21:58:21 +00:00
|
|
|
inline VTKM_CONT vtkm::cont::DataSet ExternalFaces::DoExecute(
|
2017-05-26 17:53:28 +00:00
|
|
|
const vtkm::cont::DataSet& input,
|
|
|
|
const vtkm::filter::PolicyBase<DerivedPolicy>& policy,
|
2017-05-18 14:29:41 +00:00
|
|
|
const DeviceAdapter&)
|
2016-01-19 14:59:31 +00:00
|
|
|
{
|
|
|
|
//1. extract the cell set
|
2017-05-18 14:29:41 +00:00
|
|
|
const vtkm::cont::DynamicCellSet& cells = input.GetCellSet(this->GetActiveCellSetIndex());
|
2016-01-19 14:59:31 +00:00
|
|
|
|
2017-03-02 21:09:03 +00:00
|
|
|
//2. using the policy convert the dynamic cell set, and run the
|
2016-01-19 14:59:31 +00:00
|
|
|
// external faces worklet
|
2017-03-02 21:09:03 +00:00
|
|
|
vtkm::cont::CellSetExplicit<> outCellSet(cells.GetName());
|
2017-07-19 19:35:31 +00:00
|
|
|
|
|
|
|
if (cells.IsSameType(vtkm::cont::CellSetStructured<3>()))
|
2017-08-03 20:08:06 +00:00
|
|
|
{
|
2017-07-31 14:06:33 +00:00
|
|
|
this->Worklet.Run(cells.Cast<vtkm::cont::CellSetStructured<3>>(),
|
|
|
|
input.GetCoordinateSystem(this->GetActiveCoordinateSystemIndex()),
|
|
|
|
outCellSet,
|
|
|
|
DeviceAdapter());
|
2017-08-03 20:08:06 +00:00
|
|
|
}
|
2017-07-19 19:35:31 +00:00
|
|
|
else
|
2017-08-03 20:08:06 +00:00
|
|
|
{
|
2017-07-31 14:06:33 +00:00
|
|
|
this->Worklet.Run(
|
|
|
|
vtkm::filter::ApplyPolicyUnstructured(cells, policy), outCellSet, DeviceAdapter());
|
2017-08-03 20:08:06 +00:00
|
|
|
}
|
2016-01-19 14:59:31 +00:00
|
|
|
|
2017-08-03 21:32:34 +00:00
|
|
|
//3. Check the fields of the dataset to see what kinds of fields are present so
|
|
|
|
// we can free the cell mapping array if it won't be needed.
|
2017-07-31 14:06:33 +00:00
|
|
|
const vtkm::Id numFields = input.GetNumberOfFields();
|
|
|
|
bool hasCellFields = false;
|
|
|
|
for (vtkm::Id fieldIdx = 0; fieldIdx < numFields && !hasCellFields; ++fieldIdx)
|
|
|
|
{
|
|
|
|
auto f = input.GetField(fieldIdx);
|
2018-05-18 20:10:15 +00:00
|
|
|
if (f.GetAssociation() == vtkm::cont::Field::Association::CELL_SET)
|
2017-07-31 14:06:33 +00:00
|
|
|
{
|
|
|
|
hasCellFields = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!hasCellFields)
|
|
|
|
{
|
|
|
|
this->Worklet.ReleaseCellMapArrays();
|
|
|
|
}
|
2017-08-03 21:32:34 +00:00
|
|
|
|
|
|
|
//4. create the output dataset
|
|
|
|
vtkm::cont::DataSet output;
|
|
|
|
output.AddCellSet(outCellSet);
|
|
|
|
output.AddCoordinateSystem(input.GetCoordinateSystem(this->GetActiveCoordinateSystemIndex()));
|
|
|
|
|
|
|
|
if (this->CompactPoints)
|
|
|
|
{
|
|
|
|
this->Compactor.SetCompactPointFields(true);
|
|
|
|
return this->Compactor.DoExecute(output, GetCellSetExplicitPolicy(policy), DeviceAdapter());
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-04-02 21:58:21 +00:00
|
|
|
return output;
|
2017-08-03 21:32:34 +00:00
|
|
|
}
|
2016-01-19 14:59:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
2017-05-18 14:29:41 +00:00
|
|
|
template <typename T, typename StorageType, typename DerivedPolicy, typename DeviceAdapter>
|
|
|
|
inline VTKM_CONT bool ExternalFaces::DoMapField(
|
2018-04-02 21:58:21 +00:00
|
|
|
vtkm::cont::DataSet& result,
|
2017-05-26 17:53:28 +00:00
|
|
|
const vtkm::cont::ArrayHandle<T, StorageType>& input,
|
2017-05-18 14:29:41 +00:00
|
|
|
const vtkm::filter::FieldMetadata& fieldMeta,
|
2017-05-26 17:53:28 +00:00
|
|
|
const vtkm::filter::PolicyBase<DerivedPolicy>& policy,
|
2017-07-31 14:06:33 +00:00
|
|
|
const DeviceAdapter& device)
|
2016-01-19 14:59:31 +00:00
|
|
|
{
|
2017-03-03 16:30:35 +00:00
|
|
|
if (fieldMeta.IsPointField())
|
|
|
|
{
|
2017-03-07 14:48:59 +00:00
|
|
|
if (this->CompactPoints)
|
|
|
|
{
|
|
|
|
return this->Compactor.DoMapField(result, input, fieldMeta, policy, DeviceAdapter());
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-04-02 21:58:21 +00:00
|
|
|
result.AddField(fieldMeta.AsField(input));
|
2017-03-07 14:48:59 +00:00
|
|
|
return true;
|
|
|
|
}
|
2017-03-03 16:30:35 +00:00
|
|
|
}
|
2017-07-31 14:06:33 +00:00
|
|
|
else if (fieldMeta.IsCellField())
|
|
|
|
{
|
|
|
|
vtkm::cont::ArrayHandle<T> fieldArray;
|
|
|
|
fieldArray = this->Worklet.ProcessCellField(input, device);
|
2018-04-02 21:58:21 +00:00
|
|
|
result.AddField(fieldMeta.AsField(fieldArray));
|
2017-07-31 14:06:33 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2017-03-03 16:30:35 +00:00
|
|
|
|
2017-03-07 14:48:59 +00:00
|
|
|
return false;
|
2016-01-19 14:59:31 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|