2016-11-06 22:15:22 +00:00
|
|
|
//============================================================================
|
|
|
|
// Copyright (c) Kitware, Inc.
|
|
|
|
// All rights reserved.
|
|
|
|
// See LICENSE.txt for details.
|
2019-04-15 23:24:21 +00:00
|
|
|
//
|
2016-11-06 22:15:22 +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_CleanGrid_h
|
|
|
|
#define vtk_m_filter_CleanGrid_h
|
|
|
|
|
2020-08-19 23:20:43 +00:00
|
|
|
#include <vtkm/filter/vtkm_filter_common_export.h>
|
2019-09-09 13:39:23 +00:00
|
|
|
|
2016-11-06 22:15:22 +00:00
|
|
|
#include <vtkm/filter/FilterDataSet.h>
|
|
|
|
|
2019-01-28 14:24:48 +00:00
|
|
|
#include <vtkm/worklet/PointMerge.h>
|
2019-02-15 16:40:07 +00:00
|
|
|
#include <vtkm/worklet/RemoveDegenerateCells.h>
|
2016-11-06 22:15:22 +00:00
|
|
|
#include <vtkm/worklet/RemoveUnusedPoints.h>
|
|
|
|
|
2017-05-18 14:29:41 +00:00
|
|
|
namespace vtkm
|
|
|
|
{
|
|
|
|
namespace filter
|
|
|
|
{
|
2016-11-06 22:15:22 +00:00
|
|
|
|
|
|
|
/// \brief Clean a mesh to an unstructured grid
|
|
|
|
///
|
|
|
|
/// This filter takes a data set and essentially copies it into a new data set.
|
|
|
|
/// The newly constructed data set will have the same cells as the input and
|
|
|
|
/// the topology will be stored in a \c CellSetExplicit<>. The filter will also
|
|
|
|
/// optionally remove all unused points.
|
|
|
|
///
|
|
|
|
/// Note that the result of \c CleanGrid is not necessarily smaller than the
|
|
|
|
/// input. For example, "cleaning" a data set with a \c CellSetStructured
|
|
|
|
/// topology will actually result in a much larger data set.
|
|
|
|
///
|
|
|
|
/// \todo Add a feature to merge points that are coincident or within a
|
|
|
|
/// tolerance.
|
|
|
|
///
|
2019-09-09 13:39:23 +00:00
|
|
|
class VTKM_ALWAYS_EXPORT CleanGrid : public vtkm::filter::FilterDataSet<CleanGrid>
|
2016-11-06 22:15:22 +00:00
|
|
|
{
|
|
|
|
public:
|
2020-08-19 23:20:43 +00:00
|
|
|
VTKM_FILTER_COMMON_EXPORT
|
2016-11-06 22:15:22 +00:00
|
|
|
CleanGrid();
|
|
|
|
|
|
|
|
/// When the CompactPointFields flag is true, the filter will identify any
|
|
|
|
/// points that are not used by the topology. This is on by default.
|
|
|
|
///
|
2019-01-28 14:24:48 +00:00
|
|
|
VTKM_CONT bool GetCompactPointFields() const { return this->CompactPointFields; }
|
|
|
|
VTKM_CONT void SetCompactPointFields(bool flag) { this->CompactPointFields = flag; }
|
|
|
|
|
|
|
|
/// When the MergePoints flag is true, the filter will identify any coincident
|
|
|
|
/// points and merge them together. The distance two points can be to considered
|
|
|
|
/// coincident is set with the tolerance flags. This is on by default.
|
|
|
|
///
|
|
|
|
VTKM_CONT bool GetMergePoints() const { return this->MergePoints; }
|
|
|
|
VTKM_CONT void SetMergePoints(bool flag) { this->MergePoints = flag; }
|
|
|
|
|
|
|
|
/// Defines the tolerance used when determining whether two points are considered
|
|
|
|
/// coincident. If the ToleranceIsAbsolute flag is false (the default), then this
|
|
|
|
/// tolerance is scaled by the diagonal of the points.
|
|
|
|
///
|
|
|
|
VTKM_CONT vtkm::Float64 GetTolerance() const { return this->Tolerance; }
|
|
|
|
VTKM_CONT void SetTolerance(vtkm::Float64 tolerance) { this->Tolerance = tolerance; }
|
|
|
|
|
|
|
|
/// When ToleranceIsAbsolute is false (the default) then the tolerance is scaled
|
|
|
|
/// by the diagonal of the bounds of the dataset. If true, then the tolerance is
|
|
|
|
/// taken as the actual distance to use.
|
|
|
|
///
|
|
|
|
VTKM_CONT bool GetToleranceIsAbsolute() const { return this->ToleranceIsAbsolute; }
|
|
|
|
VTKM_CONT void SetToleranceIsAbsolute(bool flag) { this->ToleranceIsAbsolute = flag; }
|
|
|
|
|
2019-02-15 16:40:07 +00:00
|
|
|
/// Determine whether a cell is degenerate (that is, has repeated points that drops
|
|
|
|
/// its dimensionalit) and removes them. This is on by default.
|
|
|
|
///
|
|
|
|
VTKM_CONT bool GetRemoveDegenerateCells() const { return this->RemoveDegenerateCells; }
|
|
|
|
VTKM_CONT void SetRemoveDegenerateCells(bool flag) { this->RemoveDegenerateCells = flag; }
|
|
|
|
|
2019-01-28 14:24:48 +00:00
|
|
|
/// When FastMerge is true (the default), some corners are cut when computing
|
|
|
|
/// coincident points. The point merge will go faster but the tolerance will not
|
|
|
|
/// be strictly followed.
|
|
|
|
///
|
|
|
|
VTKM_CONT bool GetFastMerge() const { return this->FastMerge; }
|
|
|
|
VTKM_CONT void SetFastMerge(bool flag) { this->FastMerge = flag; }
|
2016-11-06 22:15:22 +00:00
|
|
|
|
2018-08-30 15:53:18 +00:00
|
|
|
template <typename Policy>
|
2018-04-02 21:58:21 +00:00
|
|
|
VTKM_CONT vtkm::cont::DataSet DoExecute(const vtkm::cont::DataSet& inData,
|
2018-08-30 15:53:18 +00:00
|
|
|
vtkm::filter::PolicyBase<Policy> policy);
|
2016-11-06 22:15:22 +00:00
|
|
|
|
2020-08-19 23:20:43 +00:00
|
|
|
VTKM_FILTER_COMMON_EXPORT
|
2020-02-05 04:44:10 +00:00
|
|
|
VTKM_CONT bool MapFieldOntoOutput(vtkm::cont::DataSet& result, const vtkm::cont::Field& field);
|
2019-09-09 13:39:23 +00:00
|
|
|
|
2020-02-05 04:44:10 +00:00
|
|
|
template <typename DerivedPolicy>
|
|
|
|
VTKM_CONT bool MapFieldOntoOutput(vtkm::cont::DataSet& result,
|
|
|
|
const vtkm::cont::Field& field,
|
|
|
|
vtkm::filter::PolicyBase<DerivedPolicy>)
|
2019-09-09 13:39:23 +00:00
|
|
|
{
|
2020-02-05 04:44:10 +00:00
|
|
|
return this->MapFieldOntoOutput(result, field);
|
2019-09-09 13:39:23 +00:00
|
|
|
}
|
2016-11-06 22:15:22 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
bool CompactPointFields;
|
2019-01-28 14:24:48 +00:00
|
|
|
bool MergePoints;
|
|
|
|
vtkm::Float64 Tolerance;
|
|
|
|
bool ToleranceIsAbsolute;
|
2019-02-15 16:40:07 +00:00
|
|
|
bool RemoveDegenerateCells;
|
2019-01-28 14:24:48 +00:00
|
|
|
bool FastMerge;
|
2016-11-06 22:15:22 +00:00
|
|
|
|
2020-08-19 23:20:43 +00:00
|
|
|
VTKM_FILTER_COMMON_EXPORT vtkm::cont::DataSet GenerateOutput(
|
2019-09-09 13:39:23 +00:00
|
|
|
const vtkm::cont::DataSet& inData,
|
|
|
|
vtkm::cont::CellSetExplicit<>& outputCellSet);
|
|
|
|
|
2016-11-06 22:15:22 +00:00
|
|
|
vtkm::worklet::RemoveUnusedPoints PointCompactor;
|
2019-02-15 16:40:07 +00:00
|
|
|
vtkm::worklet::RemoveDegenerateCells CellCompactor;
|
2019-01-28 14:24:48 +00:00
|
|
|
vtkm::worklet::PointMerge PointMerger;
|
2016-11-06 22:15:22 +00:00
|
|
|
};
|
2019-09-09 13:39:23 +00:00
|
|
|
|
|
|
|
#ifndef vtkm_filter_CleanGrid_cxx
|
|
|
|
VTKM_FILTER_EXPORT_EXECUTE_METHOD(CleanGrid);
|
|
|
|
#endif
|
2016-11-06 22:15:22 +00:00
|
|
|
}
|
|
|
|
} // namespace vtkm::filter
|
|
|
|
|
2019-10-07 19:39:02 +00:00
|
|
|
#include <vtkm/filter/CleanGrid.hxx>
|
|
|
|
|
2016-11-06 22:15:22 +00:00
|
|
|
#endif //vtk_m_filter_CleanGrid_h
|