VTK-m  2.0
ExternalFaces.h
Go to the documentation of this file.
1 //============================================================================
2 // Copyright (c) Kitware, Inc.
3 // All rights reserved.
4 // See LICENSE.txt for details.
5 //
6 // This software is distributed WITHOUT ANY WARRANTY; without even
7 // the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
8 // PURPOSE. See the above copyright notice for more information.
9 //============================================================================
10 
11 #ifndef vtkm_filter_entity_extraction_ExternalFaces_h
12 #define vtkm_filter_entity_extraction_ExternalFaces_h
13 
15 #include <vtkm/filter/entity_extraction/vtkm_filter_entity_extraction_export.h>
16 
17 namespace vtkm
18 {
19 namespace worklet
20 {
21 struct ExternalFaces;
22 }
23 namespace filter
24 {
25 namespace entity_extraction
26 {
35 class VTKM_FILTER_ENTITY_EXTRACTION_EXPORT ExternalFaces : public vtkm::filter::FilterField
36 {
37 public:
38  ExternalFaces();
39  ~ExternalFaces() override;
40 
41  // New Design: I am too lazy to make this filter thread-safe. Let's use it as an example of
42  // thread un-safe filter.
43  bool CanThread() const override { return false; }
44 
45  // When CompactPoints is set, instead of copying the points and point fields
46  // from the input, the filter will create new compact fields without the
47  // unused elements
48  VTKM_CONT
49  bool GetCompactPoints() const { return this->CompactPoints; }
50  VTKM_CONT
51  void SetCompactPoints(bool value) { this->CompactPoints = value; }
52 
53  // When PassPolyData is set (the default), incoming poly data (0D, 1D, and 2D cells)
54  // will be passed to the output external faces data set.
55  VTKM_CONT
56  bool GetPassPolyData() const { return this->PassPolyData; }
57  VTKM_CONT
58  void SetPassPolyData(bool value);
59 
60 private:
61  VTKM_CONT vtkm::cont::DataSet DoExecute(const vtkm::cont::DataSet& input) override;
62 
63  vtkm::cont::DataSet GenerateOutput(const vtkm::cont::DataSet& input,
64  vtkm::cont::CellSetExplicit<>& outCellSet);
65 
66  VTKM_CONT bool MapFieldOntoOutput(vtkm::cont::DataSet& result, const vtkm::cont::Field& field);
67 
68  bool CompactPoints = false;
69  bool PassPolyData = true;
70 
71  // Note: This shared state as a data member requires us to explicitly implement the
72  // constructor and destructor in the .cxx file, after the compiler actually have
73  // seen the definition of worklet:ExternalFaces, even if the implementation of
74  // the cstr/dstr is just = default. Otherwise the compiler does not know how to
75  // allocate/free storage for the std::unique_ptr.
76  std::unique_ptr<vtkm::worklet::ExternalFaces> Worklet;
77 };
78 } // namespace entity_extraction
79 } // namespace filter
80 } // namespace vtkm
81 
82 #endif // vtkm_filter_entity_extraction_ExternalFaces_h
vtkm
Groups connected points that have the same field value.
Definition: Atomic.h:19
vtkm::filter::entity_extraction::ExternalFaces::Worklet
std::unique_ptr< vtkm::worklet::ExternalFaces > Worklet
Definition: ExternalFaces.h:76
vtkm::cont::DataSet
Definition: DataSet.h:34
vtkm::filter::entity_extraction::ExternalFaces::SetCompactPoints
VTKM_CONT void SetCompactPoints(bool value)
Definition: ExternalFaces.h:51
vtkm::filter::entity_extraction::ExternalFaces::CanThread
bool CanThread() const override
Definition: ExternalFaces.h:43
vtkm::filter::entity_extraction::ExternalFaces
Extract external faces of a geometry.
Definition: ExternalFaces.h:35
FilterField.h
vtkm::filter::FilterField
Definition: FilterField.h:21
vtkm::cont::Field
A Field encapsulates an array on some piece of the mesh, such as the points, a cell set,...
Definition: cont/Field.h:31
VTKM_CONT
#define VTKM_CONT
Definition: ExportMacros.h:57
vtkm::cont::CellSetExplicit
Definition: CastAndCall.h:36
vtkm::filter::entity_extraction::ExternalFaces::GetCompactPoints
VTKM_CONT bool GetCompactPoints() const
Definition: ExternalFaces.h:49
vtkm::filter::entity_extraction::ExternalFaces::GetPassPolyData
VTKM_CONT bool GetPassPolyData() const
Definition: ExternalFaces.h:56