mirror of
https://gitlab.kitware.com/vtk/vtk-m
synced 2024-09-16 17:22:55 +00:00
Add filters and tests for ExtractPoints and ExtractGeometry, by id only.
This commit is contained in:
parent
54171e1d87
commit
9f0c99920c
@ -24,6 +24,8 @@ set(headers
|
||||
Clip.h
|
||||
ContourTreeUniform.h
|
||||
ExternalFaces.h
|
||||
ExtractGeometry.h
|
||||
ExtractPoints.h
|
||||
FieldMetadata.h
|
||||
FilterCell.h
|
||||
FilterDataSet.h
|
||||
@ -33,6 +35,7 @@ set(headers
|
||||
Gradient.h
|
||||
Histogram.h
|
||||
MarchingCubes.h
|
||||
#Mask.h
|
||||
MaskPoints.h
|
||||
PointAverage.h
|
||||
PointElevation.h
|
||||
@ -53,6 +56,8 @@ set(header_template_sources
|
||||
Clip.hxx
|
||||
ContourTreeUniform.hxx
|
||||
ExternalFaces.hxx
|
||||
ExtractGeometry.hxx
|
||||
ExtractPoints.hxx
|
||||
FilterCell.hxx
|
||||
FilterDataSet.hxx
|
||||
FilterDataSetWithField.hxx
|
||||
@ -60,6 +65,7 @@ set(header_template_sources
|
||||
Gradient.hxx
|
||||
Histogram.hxx
|
||||
MarchingCubes.hxx
|
||||
#Mask.hxx
|
||||
MaskPoints.hxx
|
||||
PointAverage.hxx
|
||||
PointElevation.hxx
|
||||
|
90
vtkm/filter/ExtractGeometry.h
Normal file
90
vtkm/filter/ExtractGeometry.h
Normal file
@ -0,0 +1,90 @@
|
||||
//============================================================================
|
||||
// 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.
|
||||
//
|
||||
// Copyright 2014 Sandia Corporation.
|
||||
// Copyright 2014 UT-Battelle, LLC.
|
||||
// Copyright 2014 Los Alamos National Security.
|
||||
//
|
||||
// Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
|
||||
// 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.
|
||||
//============================================================================
|
||||
|
||||
#ifndef vtk_m_filter_ExtractGeometry_h
|
||||
#define vtk_m_filter_ExtractGeometry_h
|
||||
|
||||
#include <vtkm/filter/FilterDataSet.h>
|
||||
#include <vtkm/filter/CleanGrid.h>
|
||||
#include <vtkm/worklet/ExtractGeometry.h>
|
||||
#include <vtkm/ImplicitFunctions.h>
|
||||
|
||||
namespace vtkm {
|
||||
namespace filter {
|
||||
|
||||
class ExtractGeometry : public vtkm::filter::FilterDataSet<ExtractGeometry>
|
||||
{
|
||||
public:
|
||||
VTKM_CONT
|
||||
ExtractGeometry();
|
||||
|
||||
// When CompactPoints is set, instead of copying the points and point fields
|
||||
// from the input, the filter will create new compact fields without the unused elements
|
||||
VTKM_CONT
|
||||
bool GetCompactPoints() const { return this->CompactPoints; }
|
||||
VTKM_CONT
|
||||
void SetCompactPoints(bool value) { this->CompactPoints = value; }
|
||||
|
||||
// Set the list of point ids to extract
|
||||
VTKM_CONT
|
||||
vtkm::cont::ArrayHandle<vtkm::Id> GetCellIds() const { return this->CellIds; }
|
||||
VTKM_CONT
|
||||
void SetCellIds(vtkm::cont::ArrayHandle<vtkm::Id> &cellIds);
|
||||
|
||||
// Set the volume of interest to extract
|
||||
/*
|
||||
VTKM_CONT
|
||||
vtkm::ImplicitFunction GetVolumeOfInterest() const { return this->VolumeOfInterest; }
|
||||
VTKM_CONT
|
||||
void SetVolumeOfInterest(vtkm::ImplicitFunction &implicitFunction);
|
||||
*/
|
||||
|
||||
template<typename DerivedPolicy, typename DeviceAdapter>
|
||||
VTKM_CONT
|
||||
vtkm::filter::ResultDataSet DoExecute(const vtkm::cont::DataSet& input,
|
||||
const vtkm::filter::PolicyBase<DerivedPolicy>& policy,
|
||||
const DeviceAdapter& tag);
|
||||
|
||||
//Map a new field onto the resulting dataset after running the filter
|
||||
template<typename T, typename StorageType, typename DerivedPolicy, typename DeviceAdapter>
|
||||
VTKM_CONT
|
||||
bool DoMapField(vtkm::filter::ResultDataSet& result,
|
||||
const vtkm::cont::ArrayHandle<T, StorageType>& input,
|
||||
const vtkm::filter::FieldMetadata& fieldMeta,
|
||||
const vtkm::filter::PolicyBase<DerivedPolicy>& policy,
|
||||
const DeviceAdapter& tag);
|
||||
|
||||
|
||||
private:
|
||||
int ExtractType;
|
||||
vtkm::cont::ArrayHandle<vtkm::Id> CellIds;
|
||||
//vtkm::ImplicitFunction VolumeOfInterest;
|
||||
|
||||
bool CompactPoints;
|
||||
vtkm::filter::CleanGrid Compactor;
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace vtkm::filter
|
||||
|
||||
|
||||
#include <vtkm/filter/ExtractGeometry.hxx>
|
||||
|
||||
#endif // vtk_m_filter_ExtractGeometry_h
|
178
vtkm/filter/ExtractGeometry.hxx
Normal file
178
vtkm/filter/ExtractGeometry.hxx
Normal file
@ -0,0 +1,178 @@
|
||||
//============================================================================
|
||||
// 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.
|
||||
//
|
||||
// Copyright 2014 Sandia Corporation.
|
||||
// Copyright 2014 UT-Battelle, LLC.
|
||||
// Copyright 2014 Los Alamos National Security.
|
||||
//
|
||||
// Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
|
||||
// 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.
|
||||
//============================================================================
|
||||
|
||||
namespace
|
||||
{
|
||||
class AddPermutationCellSet
|
||||
{
|
||||
vtkm::cont::DataSet* Output;
|
||||
vtkm::cont::ArrayHandle<vtkm::Id>* ValidIds;
|
||||
public:
|
||||
AddPermutationCellSet(vtkm::cont::DataSet& data,
|
||||
vtkm::cont::ArrayHandle<vtkm::Id>& validIds):
|
||||
Output(&data),
|
||||
ValidIds(&validIds)
|
||||
{ }
|
||||
|
||||
template<typename CellSetType>
|
||||
void operator()(const CellSetType& cellset ) const
|
||||
{
|
||||
typedef vtkm::cont::CellSetPermutation<CellSetType> PermutationCellSetType;
|
||||
|
||||
PermutationCellSetType permCellSet(*this->ValidIds, cellset,
|
||||
cellset.GetName());
|
||||
|
||||
this->Output->AddCellSet(permCellSet);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
namespace vtkm {
|
||||
namespace filter {
|
||||
|
||||
const int BY_IDS = 0;
|
||||
const int BY_VOI = 1;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
inline VTKM_CONT
|
||||
void ExtractGeometry::SetCellIds(vtkm::cont::ArrayHandle<vtkm::Id> &cellIds)
|
||||
{
|
||||
this->CellIds = cellIds;
|
||||
this->ExtractType = BY_IDS;
|
||||
}
|
||||
|
||||
/*
|
||||
inline VTKM_CONT
|
||||
void ExtractGeometry::SetVolumeOfInterest(vtkm::ImplicitFunction &implicitFunction)
|
||||
{
|
||||
this->VolumeOfInterest = implicitFunction;
|
||||
this->ExtractType = BY_VOI;
|
||||
}
|
||||
*/
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
inline VTKM_CONT
|
||||
ExtractGeometry::ExtractGeometry():
|
||||
vtkm::filter::FilterDataSet<ExtractGeometry>(),
|
||||
CellIds(),
|
||||
CompactPoints(false)
|
||||
{
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
template<typename DerivedPolicy,
|
||||
typename DeviceAdapter>
|
||||
inline VTKM_CONT
|
||||
vtkm::filter::ResultDataSet ExtractGeometry::DoExecute(
|
||||
const vtkm::cont::DataSet& input,
|
||||
const vtkm::filter::PolicyBase<DerivedPolicy>& policy,
|
||||
const DeviceAdapter& device)
|
||||
{
|
||||
// extract the input cell set and coordinates
|
||||
const vtkm::cont::DynamicCellSet& cells =
|
||||
input.GetCellSet(this->GetActiveCellSetIndex());
|
||||
/*
|
||||
const vtkm::cont::CoordinateSystem& coords =
|
||||
input.GetCoordinateSystem(this->GetActiveCoordinateSystemIndex());
|
||||
*/
|
||||
|
||||
switch (this->ExtractType)
|
||||
{
|
||||
case BY_IDS:
|
||||
{
|
||||
break;
|
||||
}
|
||||
case BY_VOI:
|
||||
{
|
||||
/*
|
||||
vtkm::cont::ArrayHandle<bool> passFlags;
|
||||
|
||||
// Worklet output will be a boolean passFlag array
|
||||
typedef vtkm::worklet::ExtractGeometry::ExtractCellsByVOI<ImplicitFunction> ExtractCellsWorklet;
|
||||
ExtractCellsWorklet worklet(implicitFunction);
|
||||
DispatcherMapTopology<ExtractCellsWorklet, DeviceAdapter> dispatcher(worklet);
|
||||
dispatcher.Invoke(cellSet,
|
||||
coordinates,
|
||||
passFlags);
|
||||
|
||||
vtkm::cont::ArrayHandleCounting<vtkm::Id> indices =
|
||||
vtkm::cont::make_ArrayHandleCounting(vtkm::Id(0), vtkm::Id(1), passFlags.GetNumberOfValues());
|
||||
vtkm::cont::DeviceAdapterAlgorithm<DeviceAdapter>
|
||||
::CopyIf(indices, passFlags, this->ValidCellIds);
|
||||
*/
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
// create the output dataset
|
||||
vtkm::cont::DataSet output;
|
||||
output.AddCoordinateSystem(input.GetCoordinateSystem(this->GetActiveCoordinateSystemIndex()));
|
||||
|
||||
AddPermutationCellSet addCellSet(output, this->CellIds);
|
||||
vtkm::cont::CastAndCall(vtkm::filter::ApplyPolicy(cells, policy),
|
||||
addCellSet);
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
template<typename T,
|
||||
typename StorageType,
|
||||
typename DerivedPolicy,
|
||||
typename DeviceAdapter>
|
||||
inline VTKM_CONT
|
||||
bool ExtractGeometry::DoMapField(
|
||||
vtkm::filter::ResultDataSet& result,
|
||||
const vtkm::cont::ArrayHandle<T, StorageType>& input,
|
||||
const vtkm::filter::FieldMetadata& fieldMeta,
|
||||
const vtkm::filter::PolicyBase<DerivedPolicy>& policy,
|
||||
const DeviceAdapter&)
|
||||
{
|
||||
// point data is copied as is because it was not collapsed
|
||||
if(fieldMeta.IsPointField())
|
||||
{
|
||||
result.GetDataSet().AddField(fieldMeta.AsField(input));
|
||||
return true;
|
||||
}
|
||||
|
||||
if(fieldMeta.IsCellField())
|
||||
{
|
||||
//todo: We need to generate a new output policy that replaces
|
||||
//the original storage tag with a new storage tag where everything is
|
||||
//wrapped in ArrayHandlePermutation.
|
||||
typedef vtkm::cont::ArrayHandlePermutation<
|
||||
vtkm::cont::ArrayHandle<vtkm::Id>,
|
||||
vtkm::cont::ArrayHandle<T, StorageType> > PermutationType;
|
||||
|
||||
PermutationType permutation =
|
||||
vtkm::cont::make_ArrayHandlePermutation(this->CellIds, input);
|
||||
|
||||
result.GetDataSet().AddField( fieldMeta.AsField(permutation) );
|
||||
return true;
|
||||
}
|
||||
|
||||
// cell data does not apply
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
90
vtkm/filter/ExtractPoints.h
Normal file
90
vtkm/filter/ExtractPoints.h
Normal file
@ -0,0 +1,90 @@
|
||||
//============================================================================
|
||||
// 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.
|
||||
//
|
||||
// Copyright 2014 Sandia Corporation.
|
||||
// Copyright 2014 UT-Battelle, LLC.
|
||||
// Copyright 2014 Los Alamos National Security.
|
||||
//
|
||||
// Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
|
||||
// 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.
|
||||
//============================================================================
|
||||
|
||||
#ifndef vtk_m_filter_ExtractPoints_h
|
||||
#define vtk_m_filter_ExtractPoints_h
|
||||
|
||||
#include <vtkm/filter/FilterDataSet.h>
|
||||
#include <vtkm/filter/CleanGrid.h>
|
||||
#include <vtkm/worklet/ExtractPoints.h>
|
||||
#include <vtkm/ImplicitFunctions.h>
|
||||
|
||||
namespace vtkm {
|
||||
namespace filter {
|
||||
|
||||
class ExtractPoints : public vtkm::filter::FilterDataSet<ExtractPoints>
|
||||
{
|
||||
public:
|
||||
VTKM_CONT
|
||||
ExtractPoints();
|
||||
|
||||
// When CompactPoints is set, instead of copying the points and point fields
|
||||
// from the input, the filter will create new compact fields without the unused elements
|
||||
VTKM_CONT
|
||||
bool GetCompactPoints() const { return this->CompactPoints; }
|
||||
VTKM_CONT
|
||||
void SetCompactPoints(bool value) { this->CompactPoints = value; }
|
||||
|
||||
// Set the list of point ids to extract
|
||||
VTKM_CONT
|
||||
vtkm::cont::ArrayHandle<vtkm::Id> GetPointIds() const { return this->PointIds; }
|
||||
VTKM_CONT
|
||||
void SetPointIds(vtkm::cont::ArrayHandle<vtkm::Id> &pointIds);
|
||||
|
||||
// Set the volume of interest to extract
|
||||
/*
|
||||
VTKM_CONT
|
||||
vtkm::ImplicitFunction GetVolumeOfInterest() const { return this->VolumeOfInterest; }
|
||||
VTKM_CONT
|
||||
void SetVolumeOfInterest(vtkm::ImplicitFunction &implicitFunction);
|
||||
*/
|
||||
|
||||
template<typename DerivedPolicy, typename DeviceAdapter>
|
||||
VTKM_CONT
|
||||
vtkm::filter::ResultDataSet DoExecute(const vtkm::cont::DataSet& input,
|
||||
const vtkm::filter::PolicyBase<DerivedPolicy>& policy,
|
||||
const DeviceAdapter& tag);
|
||||
|
||||
//Map a new field onto the resulting dataset after running the filter
|
||||
template<typename T, typename StorageType, typename DerivedPolicy, typename DeviceAdapter>
|
||||
VTKM_CONT
|
||||
bool DoMapField(vtkm::filter::ResultDataSet& result,
|
||||
const vtkm::cont::ArrayHandle<T, StorageType>& input,
|
||||
const vtkm::filter::FieldMetadata& fieldMeta,
|
||||
const vtkm::filter::PolicyBase<DerivedPolicy>& policy,
|
||||
const DeviceAdapter& tag);
|
||||
|
||||
|
||||
private:
|
||||
int ExtractType;
|
||||
vtkm::cont::ArrayHandle<vtkm::Id> PointIds;
|
||||
//vtkm::ImplicitFunction VolumeOfInterest;
|
||||
|
||||
bool CompactPoints;
|
||||
vtkm::filter::CleanGrid Compactor;
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace vtkm::filter
|
||||
|
||||
|
||||
#include <vtkm/filter/ExtractPoints.hxx>
|
||||
|
||||
#endif // vtk_m_filter_ExtractPoints_h
|
166
vtkm/filter/ExtractPoints.hxx
Normal file
166
vtkm/filter/ExtractPoints.hxx
Normal file
@ -0,0 +1,166 @@
|
||||
//============================================================================
|
||||
// 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.
|
||||
//
|
||||
// Copyright 2014 Sandia Corporation.
|
||||
// Copyright 2014 UT-Battelle, LLC.
|
||||
// Copyright 2014 Los Alamos National Security.
|
||||
//
|
||||
// Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
|
||||
// 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.
|
||||
//============================================================================
|
||||
|
||||
namespace
|
||||
{
|
||||
|
||||
// Needed to CompactPoints
|
||||
template <typename BasePolicy>
|
||||
struct CellSetSingleTypePolicy : public BasePolicy
|
||||
{
|
||||
using AllCellSetList = vtkm::cont::CellSetListTagUnstructured;
|
||||
};
|
||||
|
||||
template <typename DerivedPolicy>
|
||||
inline vtkm::filter::PolicyBase<CellSetSingleTypePolicy<DerivedPolicy>>
|
||||
GetCellSetSingleTypePolicy(const vtkm::filter::PolicyBase<DerivedPolicy>&)
|
||||
{
|
||||
return vtkm::filter::PolicyBase<CellSetSingleTypePolicy<DerivedPolicy>>();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
namespace vtkm {
|
||||
namespace filter {
|
||||
|
||||
const int BY_IDS = 0;
|
||||
const int BY_VOI = 1;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
inline VTKM_CONT
|
||||
void ExtractPoints::SetPointIds(vtkm::cont::ArrayHandle<vtkm::Id> &pointIds)
|
||||
{
|
||||
this->PointIds = pointIds;
|
||||
this->ExtractType = BY_IDS;
|
||||
}
|
||||
|
||||
/*
|
||||
inline VTKM_CONT
|
||||
void ExtractPoints::SetVolumeOfInterest(vtkm::ImplicitFunction &implicitFunction)
|
||||
{
|
||||
this->VolumeOfInterest = implicitFunction;
|
||||
this->ExtractType = BY_VOI;
|
||||
}
|
||||
*/
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
inline VTKM_CONT
|
||||
ExtractPoints::ExtractPoints():
|
||||
vtkm::filter::FilterDataSet<ExtractPoints>(),
|
||||
CompactPoints(false)
|
||||
{
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
template<typename DerivedPolicy,
|
||||
typename DeviceAdapter>
|
||||
inline VTKM_CONT
|
||||
vtkm::filter::ResultDataSet ExtractPoints::DoExecute(
|
||||
const vtkm::cont::DataSet& input,
|
||||
const vtkm::filter::PolicyBase<DerivedPolicy>& policy,
|
||||
const DeviceAdapter& device)
|
||||
{
|
||||
// extract the input cell set and coordinates
|
||||
const vtkm::cont::DynamicCellSet& cells =
|
||||
input.GetCellSet(this->GetActiveCellSetIndex());
|
||||
/*
|
||||
const vtkm::cont::CoordinateSystem& coords =
|
||||
input.GetCoordinateSystem(this->GetActiveCoordinateSystemIndex());
|
||||
*/
|
||||
|
||||
// run the worklet on the cell set
|
||||
vtkm::cont::CellSetSingleType<> outCellSet(cells.GetName());
|
||||
vtkm::worklet::ExtractPoints worklet;
|
||||
|
||||
switch (this->ExtractType)
|
||||
{
|
||||
case BY_IDS:
|
||||
{
|
||||
outCellSet = worklet.Run(vtkm::filter::ApplyPolicy(cells, policy),
|
||||
this->PointIds,
|
||||
device);
|
||||
break;
|
||||
}
|
||||
case BY_VOI:
|
||||
{
|
||||
/*
|
||||
outCellSet = worklet.Run(vtkm::filter::ApplyPolicy(cells, policy),
|
||||
vtkm::filter::ApplyPolicy(coords, policy),
|
||||
this->implicitFunction,
|
||||
device);
|
||||
*/
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
// create the output dataset
|
||||
vtkm::cont::DataSet output;
|
||||
output.AddCellSet(outCellSet);
|
||||
output.AddCoordinateSystem(input.GetCoordinateSystem(this->GetActiveCoordinateSystemIndex()));
|
||||
|
||||
// compact the unused points in the output dataset
|
||||
if (this->CompactPoints)
|
||||
{
|
||||
this->Compactor.SetCompactPointFields(true);
|
||||
return this->Compactor.DoExecute(output,
|
||||
GetCellSetSingleTypePolicy(policy),
|
||||
DeviceAdapter());
|
||||
}
|
||||
else
|
||||
{
|
||||
return vtkm::filter::ResultDataSet(output);
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
template<typename T,
|
||||
typename StorageType,
|
||||
typename DerivedPolicy,
|
||||
typename DeviceAdapter>
|
||||
inline VTKM_CONT
|
||||
bool ExtractPoints::DoMapField(
|
||||
vtkm::filter::ResultDataSet& result,
|
||||
const vtkm::cont::ArrayHandle<T, StorageType>& input,
|
||||
const vtkm::filter::FieldMetadata& fieldMeta,
|
||||
const vtkm::filter::PolicyBase<DerivedPolicy>& policy,
|
||||
const DeviceAdapter&)
|
||||
{
|
||||
// point data is copied as is because it was not collapsed
|
||||
if(fieldMeta.IsPointField())
|
||||
{
|
||||
if (this->CompactPoints)
|
||||
{
|
||||
return this->Compactor.DoMapField(result, input, fieldMeta, policy, DeviceAdapter());
|
||||
}
|
||||
else
|
||||
{
|
||||
result.GetDataSet().AddField(fieldMeta.AsField(input));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// cell data does not apply
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -110,7 +110,7 @@ ThresholdPoints::ThresholdPoints():
|
||||
LowerValue(0),
|
||||
UpperValue(0),
|
||||
ThresholdType(THRESHOLD_BETWEEN),
|
||||
CompactPoints(true)
|
||||
CompactPoints(false)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -24,6 +24,8 @@ set(unit_tests
|
||||
UnitTestClipFilter.cxx
|
||||
UnitTestContourTreeUniformFilter.cxx
|
||||
UnitTestExternalFacesFilter.cxx
|
||||
UnitTestExtractGeometryFilter.cxx
|
||||
UnitTestExtractPointsFilter.cxx
|
||||
UnitTestFieldMetadata.cxx
|
||||
UnitTestGradient.cxx
|
||||
UnitTestHistogramFilter.cxx
|
||||
|
75
vtkm/filter/testing/UnitTestExtractGeometryFilter.cxx
Normal file
75
vtkm/filter/testing/UnitTestExtractGeometryFilter.cxx
Normal file
@ -0,0 +1,75 @@
|
||||
//============================================================================
|
||||
// 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.
|
||||
//
|
||||
// Copyright 2014 Sandia Corporation.
|
||||
// Copyright 2014 UT-Battelle, LLC.
|
||||
// Copyright 2014 Los Alamos National Security.
|
||||
//
|
||||
// Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
|
||||
// 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.
|
||||
//============================================================================
|
||||
|
||||
#include <vtkm/cont/testing/MakeTestDataSet.h>
|
||||
#include <vtkm/cont/testing/Testing.h>
|
||||
|
||||
#include <vtkm/filter/ExtractGeometry.h>
|
||||
|
||||
using vtkm::cont::testing::MakeTestDataSet;
|
||||
|
||||
namespace {
|
||||
|
||||
|
||||
class TestingExtractGeometry
|
||||
{
|
||||
public:
|
||||
void TestUniformById() const
|
||||
{
|
||||
std::cout << "Testing extract points structured by id:" << std::endl;
|
||||
vtkm::cont::DataSet dataset = MakeTestDataSet().Make3DUniformDataSet1();
|
||||
vtkm::filter::ResultDataSet result;
|
||||
|
||||
// Cells to extract
|
||||
const int nCells = 5;
|
||||
vtkm::Id cellids[nCells] = {0, 4, 5, 10, 15};
|
||||
vtkm::cont::ArrayHandle<vtkm::Id> cellIds =
|
||||
vtkm::cont::make_ArrayHandle(cellids, nCells);
|
||||
|
||||
// Setup and run filter to extract by point ids
|
||||
vtkm::filter::ExtractGeometry extractGeometry;
|
||||
extractGeometry.SetCellIds(cellIds);
|
||||
extractGeometry.SetCompactPoints(true);
|
||||
|
||||
result = extractGeometry.Execute(dataset);
|
||||
|
||||
// Only point data can be transferred to result
|
||||
for (vtkm::IdComponent i = 0; i < dataset.GetNumberOfFields(); ++i)
|
||||
{
|
||||
extractGeometry.MapFieldOntoOutput(result, dataset.GetField(i));
|
||||
}
|
||||
|
||||
vtkm::cont::DataSet output = result.GetDataSet();
|
||||
VTKM_TEST_ASSERT(test_equal(output.GetCellSet().GetNumberOfCells(), nCells),
|
||||
"Wrong result for ExtractGeometry");
|
||||
}
|
||||
|
||||
void operator()() const
|
||||
{
|
||||
this->TestUniformById();
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
int UnitTestExtractGeometryFilter(int, char *[])
|
||||
{
|
||||
return vtkm::cont::testing::Testing::Run(TestingExtractGeometry());
|
||||
}
|
75
vtkm/filter/testing/UnitTestExtractPointsFilter.cxx
Normal file
75
vtkm/filter/testing/UnitTestExtractPointsFilter.cxx
Normal file
@ -0,0 +1,75 @@
|
||||
//============================================================================
|
||||
// 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.
|
||||
//
|
||||
// Copyright 2014 Sandia Corporation.
|
||||
// Copyright 2014 UT-Battelle, LLC.
|
||||
// Copyright 2014 Los Alamos National Security.
|
||||
//
|
||||
// Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
|
||||
// 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.
|
||||
//============================================================================
|
||||
|
||||
#include <vtkm/cont/testing/MakeTestDataSet.h>
|
||||
#include <vtkm/cont/testing/Testing.h>
|
||||
|
||||
#include <vtkm/filter/ExtractPoints.h>
|
||||
|
||||
using vtkm::cont::testing::MakeTestDataSet;
|
||||
|
||||
namespace {
|
||||
|
||||
|
||||
class TestingExtractPoints
|
||||
{
|
||||
public:
|
||||
void TestUniformById() const
|
||||
{
|
||||
std::cout << "Testing extract points structured by id:" << std::endl;
|
||||
vtkm::cont::DataSet dataset = MakeTestDataSet().Make3DUniformDataSet1();
|
||||
vtkm::filter::ResultDataSet result;
|
||||
|
||||
// Points to extract
|
||||
const int nPoints = 13;
|
||||
vtkm::Id pointids[nPoints] = {0, 1, 2, 3, 4, 5, 10, 15, 20, 25, 50, 75, 100};
|
||||
vtkm::cont::ArrayHandle<vtkm::Id> pointIds =
|
||||
vtkm::cont::make_ArrayHandle(pointids, nPoints);
|
||||
|
||||
// Setup and run filter to extract by point ids
|
||||
vtkm::filter::ExtractPoints extractPoints;
|
||||
extractPoints.SetPointIds(pointIds);
|
||||
extractPoints.SetCompactPoints(true);
|
||||
|
||||
result = extractPoints.Execute(dataset);
|
||||
|
||||
// Only point data can be transferred to result
|
||||
for (vtkm::IdComponent i = 0; i < dataset.GetNumberOfFields(); ++i)
|
||||
{
|
||||
extractPoints.MapFieldOntoOutput(result, dataset.GetField(i));
|
||||
}
|
||||
|
||||
vtkm::cont::DataSet output = result.GetDataSet();
|
||||
VTKM_TEST_ASSERT(test_equal(output.GetCellSet().GetNumberOfCells(), nPoints),
|
||||
"Wrong result for ExtractPoints");
|
||||
}
|
||||
|
||||
void operator()() const
|
||||
{
|
||||
this->TestUniformById();
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
int UnitTestExtractPointsFilter(int, char *[])
|
||||
{
|
||||
return vtkm::cont::testing::Testing::Run(TestingExtractPoints());
|
||||
}
|
@ -39,7 +39,6 @@ public:
|
||||
|
||||
vtkm::filter::ThresholdPoints thresholdPoints;
|
||||
thresholdPoints.SetThresholdBetween(40.0f, 71.0f);
|
||||
thresholdPoints.SetCompactPoints(false);
|
||||
|
||||
result = thresholdPoints.Execute(dataset, dataset.GetField("pointvar"));
|
||||
|
||||
@ -66,6 +65,8 @@ public:
|
||||
|
||||
vtkm::filter::ThresholdPoints thresholdPoints;
|
||||
thresholdPoints.SetThresholdAbove(1.0f);
|
||||
thresholdPoints.SetCompactPoints(true);
|
||||
|
||||
result = thresholdPoints.Execute(dataset, std::string("pointvar"));
|
||||
|
||||
thresholdPoints.MapFieldOntoOutput(result, dataset.GetField("pointvar") );
|
||||
@ -91,6 +92,8 @@ public:
|
||||
|
||||
vtkm::filter::ThresholdPoints thresholdPoints;
|
||||
thresholdPoints.SetThresholdBelow(50.0);
|
||||
thresholdPoints.SetCompactPoints(true);
|
||||
|
||||
result = thresholdPoints.Execute(dataset, std::string("pointvar"));
|
||||
|
||||
thresholdPoints.MapFieldOntoOutput(result, dataset.GetField("pointvar") );
|
||||
|
@ -30,6 +30,7 @@ set(headers
|
||||
DispatcherStreamingMapField.h
|
||||
ExternalFaces.h
|
||||
ExtractGeometry.h
|
||||
ExtractPoints.h
|
||||
FieldHistogram.h
|
||||
FieldStatistics.h
|
||||
Gradient.h
|
||||
@ -38,6 +39,7 @@ set(headers
|
||||
Magnitude.h
|
||||
MarchingCubes.h
|
||||
MarchingCubesDataTables.h
|
||||
Mask.h
|
||||
MaskPoints.h
|
||||
PointAverage.h
|
||||
PointElevation.h
|
||||
|
@ -40,34 +40,6 @@ class ExtractGeometry
|
||||
public:
|
||||
struct BoolType : vtkm::ListTagBase<bool> {};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////
|
||||
// Worklet to identify points within volume of interest
|
||||
template<typename ImplicitFunction>
|
||||
class ExtractPointsByVOI : public vtkm::worklet::WorkletMapField
|
||||
{
|
||||
public:
|
||||
typedef void ControlSignature(FieldIn<Vec3> coordinates,
|
||||
FieldOut<BoolType> passFlags);
|
||||
typedef _2 ExecutionSignature(_1);
|
||||
|
||||
VTKM_CONT
|
||||
ExtractPointsByVOI(const ImplicitFunction &function) :
|
||||
Function(function) {}
|
||||
|
||||
VTKM_CONT
|
||||
bool operator()(const vtkm::Vec<vtkm::Float64,3> &coordinate) const
|
||||
{
|
||||
bool pass = true;
|
||||
vtkm::Float64 value = this->Function.Value(coordinate);
|
||||
if (value > 0)
|
||||
pass = false;
|
||||
return pass;
|
||||
}
|
||||
|
||||
private:
|
||||
ImplicitFunction Function;
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////
|
||||
// Worklet to identify cells within volume of interest
|
||||
template <typename ImplicitFunction>
|
||||
@ -106,69 +78,11 @@ public:
|
||||
ImplicitFunction Function;
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////
|
||||
// Extract points by id creates new cellset of vertex cells
|
||||
template <typename CellSetType,
|
||||
typename DeviceAdapter>
|
||||
vtkm::cont::CellSetSingleType<> RunExtractPoints(
|
||||
const CellSetType &cellSet,
|
||||
const vtkm::cont::ArrayHandle<vtkm::Id> &pointIds,
|
||||
const vtkm::cont::CoordinateSystem &coordinates,
|
||||
DeviceAdapter device)
|
||||
{
|
||||
typedef typename vtkm::cont::DeviceAdapterAlgorithm<DeviceAdapter> DeviceAlgorithm;
|
||||
DeviceAlgorithm::Copy(pointIds, this->ValidPointIds);
|
||||
|
||||
// Make CellSetSingleType with VERTEX at each point id
|
||||
vtkm::cont::CellSetSingleType< > outCellSet("cells");
|
||||
outCellSet.Fill(this->ValidPointIds.GetNumberOfValues(),
|
||||
vtkm::CellShapeTagVertex::Id,
|
||||
1,
|
||||
this->ValidPointIds);
|
||||
|
||||
return outCellSet;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////
|
||||
// Extract points by implicit function
|
||||
template <typename CellSetType,
|
||||
typename ImplicitFunction,
|
||||
typename DeviceAdapter>
|
||||
vtkm::cont::CellSetSingleType<> RunExtractPoints(
|
||||
const CellSetType &cellSet,
|
||||
const ImplicitFunction &implicitFunction,
|
||||
const vtkm::cont::CoordinateSystem &coordinates,
|
||||
DeviceAdapter device)
|
||||
{
|
||||
typedef typename vtkm::cont::DeviceAdapterAlgorithm<DeviceAdapter> DeviceAlgorithm;
|
||||
|
||||
vtkm::cont::ArrayHandle<bool> passFlags;
|
||||
|
||||
// Worklet output will be a boolean passFlag array
|
||||
typedef ExtractPointsByVOI<ImplicitFunction> ExtractPointsWorklet;
|
||||
ExtractPointsWorklet worklet(implicitFunction);
|
||||
DispatcherMapField<ExtractPointsWorklet, DeviceAdapter> dispatcher(worklet);
|
||||
dispatcher.Invoke(coordinates, passFlags);
|
||||
|
||||
vtkm::cont::ArrayHandleCounting<vtkm::Id> indices =
|
||||
vtkm::cont::make_ArrayHandleCounting(vtkm::Id(0), vtkm::Id(1), passFlags.GetNumberOfValues());
|
||||
DeviceAlgorithm::CopyIf(indices, passFlags, this->ValidPointIds);
|
||||
|
||||
// Make CellSetSingleType with VERTEX at each point id
|
||||
vtkm::cont::CellSetSingleType< > outCellSet("cells");
|
||||
outCellSet.Fill(this->ValidPointIds.GetNumberOfValues(),
|
||||
vtkm::CellShapeTagVertex::Id,
|
||||
1,
|
||||
this->ValidPointIds);
|
||||
|
||||
return outCellSet;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////
|
||||
// Extract cells by ids permutes input data
|
||||
template <typename CellSetType,
|
||||
typename DeviceAdapter>
|
||||
vtkm::cont::CellSetPermutation<CellSetType> RunExtractCells(
|
||||
vtkm::cont::CellSetPermutation<CellSetType> Run(
|
||||
CellSetType &cellSet,
|
||||
const vtkm::cont::ArrayHandle<vtkm::Id> &cellIds,
|
||||
DeviceAdapter device)
|
||||
@ -186,7 +100,7 @@ public:
|
||||
template <typename CellSetType,
|
||||
typename ImplicitFunction,
|
||||
typename DeviceAdapter>
|
||||
vtkm::cont::CellSetPermutation<CellSetType> RunExtractCells(
|
||||
vtkm::cont::CellSetPermutation<CellSetType> Run(
|
||||
CellSetType &cellSet,
|
||||
const ImplicitFunction &implicitFunction,
|
||||
const vtkm::cont::CoordinateSystem &coordinates,
|
||||
@ -250,7 +164,6 @@ public:
|
||||
|
||||
private:
|
||||
vtkm::cont::ArrayHandle<vtkm::Id> ValidCellIds;
|
||||
vtkm::cont::ArrayHandle<vtkm::Id> ValidPointIds;
|
||||
};
|
||||
|
||||
}
|
||||
|
133
vtkm/worklet/ExtractPoints.h
Normal file
133
vtkm/worklet/ExtractPoints.h
Normal file
@ -0,0 +1,133 @@
|
||||
//============================================================================
|
||||
// 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.
|
||||
//
|
||||
// Copyright 2014 Sandia Corporation.
|
||||
// Copyright 2014 UT-Battelle, LLC.
|
||||
// Copyright 2014 Los Alamos National Security.
|
||||
//
|
||||
// Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
|
||||
// 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.
|
||||
//============================================================================
|
||||
#ifndef vtkm_m_worklet_ExtractPoints_h
|
||||
#define vtkm_m_worklet_ExtractPoints_h
|
||||
|
||||
#include <vtkm/worklet/WorkletMapField.h>
|
||||
#include <vtkm/worklet/WorkletMapTopology.h>
|
||||
#include <vtkm/worklet/DispatcherMapField.h>
|
||||
#include <vtkm/worklet/DispatcherMapTopology.h>
|
||||
|
||||
#include <vtkm/cont/DataSet.h>
|
||||
#include <vtkm/cont/ArrayHandle.h>
|
||||
#include <vtkm/cont/CoordinateSystem.h>
|
||||
#include <vtkm/ImplicitFunctions.h>
|
||||
|
||||
namespace vtkm {
|
||||
namespace worklet {
|
||||
|
||||
class ExtractPoints
|
||||
{
|
||||
public:
|
||||
struct BoolType : vtkm::ListTagBase<bool> {};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////
|
||||
// Worklet to identify points within volume of interest
|
||||
template<typename ImplicitFunction>
|
||||
class ExtractPointsByVOI : public vtkm::worklet::WorkletMapField
|
||||
{
|
||||
public:
|
||||
typedef void ControlSignature(FieldIn<Vec3> coordinates,
|
||||
FieldOut<BoolType> passFlags);
|
||||
typedef _2 ExecutionSignature(_1);
|
||||
|
||||
VTKM_CONT
|
||||
ExtractPointsByVOI(const ImplicitFunction &function) :
|
||||
Function(function) {}
|
||||
|
||||
VTKM_CONT
|
||||
bool operator()(const vtkm::Vec<vtkm::Float64,3> &coordinate) const
|
||||
{
|
||||
bool pass = true;
|
||||
vtkm::Float64 value = this->Function.Value(coordinate);
|
||||
if (value > 0)
|
||||
pass = false;
|
||||
return pass;
|
||||
}
|
||||
|
||||
private:
|
||||
ImplicitFunction Function;
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////
|
||||
// Extract points by id creates new cellset of vertex cells
|
||||
template <typename CellSetType,
|
||||
typename DeviceAdapter>
|
||||
vtkm::cont::CellSetSingleType<> Run(
|
||||
const CellSetType &cellSet,
|
||||
const vtkm::cont::ArrayHandle<vtkm::Id> &pointIds,
|
||||
DeviceAdapter device)
|
||||
{
|
||||
typedef typename vtkm::cont::DeviceAdapterAlgorithm<DeviceAdapter> DeviceAlgorithm;
|
||||
DeviceAlgorithm::Copy(pointIds, this->ValidPointIds);
|
||||
|
||||
// Make CellSetSingleType with VERTEX at each point id
|
||||
vtkm::cont::CellSetSingleType< > outCellSet(cellSet.GetName());
|
||||
outCellSet.Fill(cellSet.GetNumberOfPoints(),
|
||||
vtkm::CellShapeTagVertex::Id,
|
||||
1,
|
||||
this->ValidPointIds);
|
||||
|
||||
return outCellSet;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////
|
||||
// Extract points by implicit function
|
||||
template <typename CellSetType,
|
||||
typename ImplicitFunction,
|
||||
typename DeviceAdapter>
|
||||
vtkm::cont::CellSetSingleType<> Run(
|
||||
const CellSetType &cellSet,
|
||||
const vtkm::cont::CoordinateSystem &coordinates,
|
||||
const ImplicitFunction &implicitFunction,
|
||||
DeviceAdapter device)
|
||||
{
|
||||
typedef typename vtkm::cont::DeviceAdapterAlgorithm<DeviceAdapter> DeviceAlgorithm;
|
||||
|
||||
vtkm::cont::ArrayHandle<bool> passFlags;
|
||||
|
||||
// Worklet output will be a boolean passFlag array
|
||||
typedef ExtractPointsByVOI<ImplicitFunction> ExtractPointsWorklet;
|
||||
ExtractPointsWorklet worklet(implicitFunction);
|
||||
DispatcherMapField<ExtractPointsWorklet, DeviceAdapter> dispatcher(worklet);
|
||||
dispatcher.Invoke(coordinates, passFlags);
|
||||
|
||||
vtkm::cont::ArrayHandleCounting<vtkm::Id> indices =
|
||||
vtkm::cont::make_ArrayHandleCounting(vtkm::Id(0), vtkm::Id(1), passFlags.GetNumberOfValues());
|
||||
DeviceAlgorithm::CopyIf(indices, passFlags, this->ValidPointIds);
|
||||
|
||||
// Make CellSetSingleType with VERTEX at each point id
|
||||
vtkm::cont::CellSetSingleType< > outCellSet(cellSet.GetName());
|
||||
outCellSet.Fill(cellSet.GetNumberOfPoints(),
|
||||
vtkm::CellShapeTagVertex::Id,
|
||||
1,
|
||||
this->ValidPointIds);
|
||||
|
||||
return outCellSet;
|
||||
}
|
||||
|
||||
private:
|
||||
vtkm::cont::ArrayHandle<vtkm::Id> ValidPointIds;
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace vtkm::worklet
|
||||
|
||||
#endif // vtkm_m_worklet_ExtractPoints_h
|
@ -95,7 +95,7 @@ public:
|
||||
vtkm::cont::ArrayHandle<vtkm::Id> pointIds = PointScatter.GetOutputToInputMap();
|
||||
|
||||
// Make CellSetSingleType with VERTEX at each point id
|
||||
vtkm::cont::CellSetSingleType< > outCellSet("cells");
|
||||
vtkm::cont::CellSetSingleType< > outCellSet(cellSet.GetName());
|
||||
outCellSet.Fill(numberOfInputPoints,
|
||||
vtkm::CellShapeTagVertex::Id,
|
||||
1,
|
||||
|
@ -25,13 +25,14 @@ set(unit_tests
|
||||
UnitTestClipping.cxx
|
||||
UnitTestContourTreeUniform.cxx
|
||||
UnitTestExternalFaces.cxx
|
||||
UnitTestExtractCells.cxx
|
||||
UnitTestExtractGeometry.cxx
|
||||
UnitTestExtractPoints.cxx
|
||||
UnitTestFieldHistogram.cxx
|
||||
UnitTestFieldStatistics.cxx
|
||||
UnitTestKeys.cxx
|
||||
UnitTestMagnitude.cxx
|
||||
UnitTestMarchingCubes.cxx
|
||||
UnitTestMask.cxx
|
||||
UnitTestMaskPoints.cxx
|
||||
UnitTestPointElevation.cxx
|
||||
UnitTestPointGradient.cxx
|
||||
|
@ -33,7 +33,7 @@
|
||||
using vtkm::cont::testing::MakeTestDataSet;
|
||||
|
||||
template <typename DeviceAdapter>
|
||||
class TestingExtractCells
|
||||
class TestingExtractGeometry
|
||||
{
|
||||
public:
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
@ -61,9 +61,9 @@ public:
|
||||
// Output data set with cell set containing extracted cells and all points
|
||||
vtkm::worklet::ExtractGeometry extractGeometry;
|
||||
OutCellSetType outCellSet =
|
||||
extractGeometry.RunExtractCells(cellSet,
|
||||
cellIds,
|
||||
DeviceAdapter());
|
||||
extractGeometry.Run(cellSet,
|
||||
cellIds,
|
||||
DeviceAdapter());
|
||||
|
||||
vtkm::cont::Field cellField =
|
||||
extractGeometry.ProcessCellField(dataset.GetField("cellvar"));
|
||||
@ -100,10 +100,10 @@ public:
|
||||
// Output data set with cell set containing extracted cells and all points
|
||||
vtkm::worklet::ExtractGeometry extractGeometry;
|
||||
OutCellSetType outCellSet =
|
||||
extractGeometry.RunExtractCells(cellSet,
|
||||
box,
|
||||
dataset.GetCoordinateSystem("coordinates"),
|
||||
DeviceAdapter());
|
||||
extractGeometry.Run(cellSet,
|
||||
box,
|
||||
dataset.GetCoordinateSystem("coordinates"),
|
||||
DeviceAdapter());
|
||||
|
||||
vtkm::cont::Field cellField =
|
||||
extractGeometry.ProcessCellField(dataset.GetField("cellvar"));
|
||||
@ -141,9 +141,9 @@ public:
|
||||
// Output data set permutation of with only extracted cells
|
||||
vtkm::worklet::ExtractGeometry extractGeometry;
|
||||
OutCellSetType outCellSet =
|
||||
extractGeometry.RunExtractCells(cellSet,
|
||||
cellIds,
|
||||
DeviceAdapter());
|
||||
extractGeometry.Run(cellSet,
|
||||
cellIds,
|
||||
DeviceAdapter());
|
||||
|
||||
vtkm::cont::Field cellField =
|
||||
extractGeometry.ProcessCellField(dataset.GetField("cellvar"));
|
||||
@ -181,9 +181,9 @@ public:
|
||||
// Output data set with cell set containing extracted cells and all points
|
||||
vtkm::worklet::ExtractGeometry extractGeometry;
|
||||
OutCellSetType outCellSet =
|
||||
extractGeometry.RunExtractCells(cellSet,
|
||||
cellIds,
|
||||
DeviceAdapter());
|
||||
extractGeometry.Run(cellSet,
|
||||
cellIds,
|
||||
DeviceAdapter());
|
||||
|
||||
vtkm::cont::Field cellField =
|
||||
extractGeometry.ProcessCellField(dataset.GetField("cellvar"));
|
||||
@ -220,10 +220,10 @@ public:
|
||||
// Output data set with cell set containing extracted points
|
||||
vtkm::worklet::ExtractGeometry extractGeometry;
|
||||
OutCellSetType outCellSet =
|
||||
extractGeometry.RunExtractCells(cellSet,
|
||||
box,
|
||||
dataset.GetCoordinateSystem("coords"),
|
||||
DeviceAdapter());
|
||||
extractGeometry.Run(cellSet,
|
||||
box,
|
||||
dataset.GetCoordinateSystem("coords"),
|
||||
DeviceAdapter());
|
||||
|
||||
vtkm::cont::Field cellField =
|
||||
extractGeometry.ProcessCellField(dataset.GetField("cellvar"));
|
||||
@ -260,10 +260,10 @@ public:
|
||||
// Output data set with cell set containing extracted cells
|
||||
vtkm::worklet::ExtractGeometry extractGeometry;
|
||||
OutCellSetType outCellSet =
|
||||
extractGeometry.RunExtractCells(cellSet,
|
||||
sphere,
|
||||
dataset.GetCoordinateSystem("coords"),
|
||||
DeviceAdapter());
|
||||
extractGeometry.Run(cellSet,
|
||||
sphere,
|
||||
dataset.GetCoordinateSystem("coords"),
|
||||
DeviceAdapter());
|
||||
|
||||
vtkm::cont::Field cellField =
|
||||
extractGeometry.ProcessCellField(dataset.GetField("cellvar"));
|
||||
@ -287,8 +287,8 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
int UnitTestExtractCells(int, char *[])
|
||||
int UnitTestExtractGeometry(int, char *[])
|
||||
{
|
||||
return vtkm::cont::testing::Testing::Run(
|
||||
TestingExtractCells<VTKM_DEFAULT_DEVICE_ADAPTER_TAG>());
|
||||
TestingExtractGeometry<VTKM_DEFAULT_DEVICE_ADAPTER_TAG>());
|
||||
}
|
@ -18,7 +18,7 @@
|
||||
// this software.
|
||||
//============================================================================
|
||||
|
||||
#include <vtkm/worklet/ExtractGeometry.h>
|
||||
#include <vtkm/worklet/ExtractPoints.h>
|
||||
|
||||
#include <vtkm/cont/testing/MakeTestDataSet.h>
|
||||
#include <vtkm/cont/testing/Testing.h>
|
||||
@ -46,7 +46,7 @@ public:
|
||||
vtkm::cont::DataSet dataset = MakeTestDataSet().Make3DUniformDataSet1();
|
||||
|
||||
// Points to extract
|
||||
const int nPoints = 18;
|
||||
const int nPoints = 13;
|
||||
vtkm::Id pointids[nPoints] = {0, 1, 2, 3, 4, 5, 10, 15, 20, 25, 50, 75, 100};
|
||||
vtkm::cont::ArrayHandle<vtkm::Id> pointIds =
|
||||
vtkm::cont::make_ArrayHandle(pointids, nPoints);
|
||||
@ -56,12 +56,11 @@ public:
|
||||
outDataSet.AddCoordinateSystem(dataset.GetCoordinateSystem(0));
|
||||
|
||||
// Output data set with cell set containing extracted points
|
||||
vtkm::worklet::ExtractGeometry extractGeometry;
|
||||
vtkm::worklet::ExtractPoints extractPoints;
|
||||
OutCellSetType outCellSet =
|
||||
extractGeometry.RunExtractPoints(dataset.GetCellSet(0),
|
||||
pointIds,
|
||||
dataset.GetCoordinateSystem("coords"),
|
||||
DeviceAdapter());
|
||||
extractPoints.Run(dataset.GetCellSet(0),
|
||||
pointIds,
|
||||
DeviceAdapter());
|
||||
outDataSet.AddCellSet(outCellSet);
|
||||
|
||||
VTKM_TEST_ASSERT(test_equal(outCellSet.GetNumberOfCells(), nPoints), "Wrong result for ExtractPoints");
|
||||
@ -86,12 +85,12 @@ public:
|
||||
outDataSet.AddCoordinateSystem(dataset.GetCoordinateSystem(0));
|
||||
|
||||
// Output data set with cell set containing extracted points
|
||||
vtkm::worklet::ExtractGeometry extractGeometry;
|
||||
vtkm::worklet::ExtractPoints extractPoints;
|
||||
OutCellSetType outCellSet =
|
||||
extractGeometry.RunExtractPoints(dataset.GetCellSet(0),
|
||||
box,
|
||||
dataset.GetCoordinateSystem("coords"),
|
||||
DeviceAdapter());
|
||||
extractPoints.Run(dataset.GetCellSet(0),
|
||||
dataset.GetCoordinateSystem("coords"),
|
||||
box,
|
||||
DeviceAdapter());
|
||||
outDataSet.AddCellSet(outCellSet);
|
||||
|
||||
VTKM_TEST_ASSERT(test_equal(outCellSet.GetNumberOfCells(), 27), "Wrong result for ExtractPoints");
|
||||
@ -116,12 +115,12 @@ public:
|
||||
outDataSet.AddCoordinateSystem(dataset.GetCoordinateSystem(0));
|
||||
|
||||
// Output data set with cell set containing extracted points
|
||||
vtkm::worklet::ExtractGeometry extractGeometry;
|
||||
vtkm::worklet::ExtractPoints extractPoints;
|
||||
OutCellSetType outCellSet =
|
||||
extractGeometry.RunExtractPoints(dataset.GetCellSet(0),
|
||||
sphere,
|
||||
dataset.GetCoordinateSystem("coords"),
|
||||
DeviceAdapter());
|
||||
extractPoints.Run(dataset.GetCellSet(0),
|
||||
dataset.GetCoordinateSystem("coords"),
|
||||
sphere,
|
||||
DeviceAdapter());
|
||||
outDataSet.AddCellSet(outCellSet);
|
||||
|
||||
VTKM_TEST_ASSERT(test_equal(outCellSet.GetNumberOfCells(), 27), "Wrong result for ExtractPoints");
|
||||
@ -146,12 +145,12 @@ public:
|
||||
outDataSet.AddCoordinateSystem(dataset.GetCoordinateSystem(0));
|
||||
|
||||
// Output data set with cell set containing extracted points
|
||||
vtkm::worklet::ExtractGeometry extractGeometry;
|
||||
vtkm::worklet::ExtractPoints extractPoints;
|
||||
OutCellSetType outCellSet =
|
||||
extractGeometry.RunExtractPoints(dataset.GetCellSet(0),
|
||||
box,
|
||||
dataset.GetCoordinateSystem("coordinates"),
|
||||
DeviceAdapter());
|
||||
extractPoints.Run(dataset.GetCellSet(0),
|
||||
dataset.GetCoordinateSystem("coordinates"),
|
||||
box,
|
||||
DeviceAdapter());
|
||||
outDataSet.AddCellSet(outCellSet);
|
||||
|
||||
VTKM_TEST_ASSERT(test_equal(outCellSet.GetNumberOfCells(), 8), "Wrong result for ExtractPoints");
|
||||
@ -178,12 +177,11 @@ public:
|
||||
outDataSet.AddCoordinateSystem(dataset.GetCoordinateSystem(0));
|
||||
|
||||
// Output data set with cell set containing extracted points
|
||||
vtkm::worklet::ExtractGeometry extractGeometry;
|
||||
vtkm::worklet::ExtractPoints extractPoints;
|
||||
OutCellSetType outCellSet =
|
||||
extractGeometry.RunExtractPoints(dataset.GetCellSet(0),
|
||||
pointIds,
|
||||
dataset.GetCoordinateSystem("coordinates"),
|
||||
DeviceAdapter());
|
||||
extractPoints.Run(dataset.GetCellSet(0),
|
||||
pointIds,
|
||||
DeviceAdapter());
|
||||
outDataSet.AddCellSet(outCellSet);
|
||||
|
||||
VTKM_TEST_ASSERT(test_equal(outCellSet.GetNumberOfCells(), nPoints), "Wrong result for ExtractPoints");
|
||||
|
Loading…
Reference in New Issue
Block a user