VTK-m  2.0
SuperArcVolumetricComparator.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 // Copyright (c) 2018, The Regents of the University of California, through
11 // Lawrence Berkeley National Laboratory (subject to receipt of any required approvals
12 // from the U.S. Dept. of Energy). All rights reserved.
13 //
14 // Redistribution and use in source and binary forms, with or without modification,
15 // are permitted provided that the following conditions are met:
16 //
17 // (1) Redistributions of source code must retain the above copyright notice, this
18 // list of conditions and the following disclaimer.
19 //
20 // (2) Redistributions in binary form must reproduce the above copyright notice,
21 // this list of conditions and the following disclaimer in the documentation
22 // and/or other materials provided with the distribution.
23 //
24 // (3) Neither the name of the University of California, Lawrence Berkeley National
25 // Laboratory, U.S. Dept. of Energy nor the names of its contributors may be
26 // used to endorse or promote products derived from this software without
27 // specific prior written permission.
28 //
29 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
30 // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
31 // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
32 // IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
33 // INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
34 // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
35 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
36 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
37 // OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
38 // OF THE POSSIBILITY OF SUCH DAMAGE.
39 //
40 //=============================================================================
41 //
42 // This code is an extension of the algorithm presented in the paper:
43 // Parallel Peak Pruning for Scalable SMP Contour Tree Computation.
44 // Hamish Carr, Gunther Weber, Christopher Sewell, and James Ahrens.
45 // Proceedings of the IEEE Symposium on Large Data Analysis and Visualization
46 // (LDAV), October 2016, Baltimore, Maryland.
47 //
48 // The PPP2 algorithm and software were jointly developed by
49 // Hamish Carr (University of Leeds), Gunther H. Weber (LBNL), and
50 // Oliver Ruebel (LBNL)
51 //==============================================================================
52 
53 #ifndef vtk_m_worklet_contourtree_augmented_process_contourtree_inc_superarc_volumetric_comperator_h
54 #define vtk_m_worklet_contourtree_augmented_process_contourtree_inc_superarc_volumetric_comperator_h
55 
56 #include <vtkm/Pair.h>
57 #include <vtkm/Types.h>
58 #include <vtkm/cont/ArrayHandle.h>
61 
62 namespace vtkm
63 {
64 namespace worklet
65 {
66 namespace contourtree_augmented
67 {
68 namespace process_contourtree_inc
69 {
70 
72 { // SuperArcVolumetricComparatorImpl
73 public:
76 
80 
81  // constructor
83  const EdgePairArray& SuperarcList,
84  bool PairsAtLowEnd,
86  vtkm::cont::Token& token)
87  : pairsAtLowEnd(PairsAtLowEnd)
88  { // constructor
89  weightPortal = Weight.PrepareForInput(device, token);
90  superarcListPortal = SuperarcList.PrepareForInput(device, token);
91 
92  } // constructor
93 
94  // () operator - gets called to do comparison
95  VTKM_EXEC
96  bool operator()(const vtkm::Id& i1, const vtkm::Id& i2) const
97  { // operator()
98  // get local references to the edge details
99  EdgePair e1 = superarcListPortal.Get(i1);
100  EdgePair e2 = superarcListPortal.Get(i2);
101 
102  if (pairsAtLowEnd)
103  { // pairs at low end
104  // test by low end ID
105  if (e1.first < e2.first)
106  return true;
107  if (e1.first > e2.first)
108  return false;
109 
110  // test by volumetric measure
111  if (weightPortal.Get(i1) < weightPortal.Get(i2))
112  return true;
113  if (weightPortal.Get(i1) > weightPortal.Get(i2))
114  return false;
115 
116  // test by ID (persistence)
117  if (e1.second < e2.second)
118  return true;
119  if (e1.second > e2.second)
120  return false;
121 
122  // fallback
123  return false;
124  } // pairs at low end
125  else
126  { // pairs at high end
127  // test by high end ID
128  if (e1.second < e2.second)
129  return true;
130  if (e1.second > e2.second)
131  return false;
132 
133  // test by volumetric measure
134  if (weightPortal.Get(i1) < weightPortal.Get(i2))
135  return true;
136  if (weightPortal.Get(i1) > weightPortal.Get(i2))
137  return false;
138 
139  // test by ID (persistence)
140  // Note the reversal from above - we want the greatest difference, not
141  // the greatest value
142  if (e1.first > e2.first)
143  return true;
144  if (e1.first < e2.first)
145  return false;
146 
147  // fallback
148  return false;
149  } // pairs at high end
150  } // operator()
151 }; // SuperArcVolumetricComparatorImpl
152 
154 { // SuperArcVolumetricComparator
155 public:
156  // constructor
158  const EdgePairArray& superArcList,
159  bool pairsAtLowEnd)
160  : Weight(weight)
161  , SuperArcList(superArcList)
162  , PairsAtLowEnd(pairsAtLowEnd)
163  {
164  }
165 
167  vtkm::cont::Token& token)
168  {
170  this->Weight, this->SuperArcList, this->PairsAtLowEnd, device, token);
171  }
172 
173 private:
177 }; // SuperArcVolumetricComparator
178 
179 } // namespace process_contourtree_inc
180 } // namespace contourtree_augmented
181 } // namespace worklet
182 } // namespace vtkm
183 
184 #endif
vtkm::cont::ArrayHandle< vtkm::Id >
ArrayHandle.h
VTKM_EXEC
#define VTKM_EXEC
Definition: ExportMacros.h:51
vtkm
Groups connected points that have the same field value.
Definition: Atomic.h:19
Types.h
vtkm::worklet::contourtree_augmented::process_contourtree_inc::SuperArcVolumetricComparatorImpl::IdPortalType
vtkm::cont::ArrayHandle< vtkm::Id >::ReadPortalType IdPortalType
Definition: SuperArcVolumetricComparator.h:74
vtkm::cont::ArrayHandle::PrepareForInput
VTKM_CONT ReadPortalType PrepareForInput(vtkm::cont::DeviceAdapterId device, vtkm::cont::Token &token) const
Prepares this array to be used as an input to an operation in the execution environment.
Definition: ArrayHandle.h:574
Pair.h
vtkm::worklet::contourtree_augmented::process_contourtree_inc::SuperArcVolumetricComparatorImpl::weightPortal
IdPortalType weightPortal
Definition: SuperArcVolumetricComparator.h:77
vtkm::worklet::contourtree_augmented::process_contourtree_inc::SuperArcVolumetricComparatorImpl::pairsAtLowEnd
bool pairsAtLowEnd
Definition: SuperArcVolumetricComparator.h:78
vtkm::worklet::contourtree_augmented::process_contourtree_inc::SuperArcVolumetricComparator::SuperArcList
EdgePairArray SuperArcList
Definition: SuperArcVolumetricComparator.h:175
vtkm::worklet::contourtree_augmented::process_contourtree_inc::SuperArcVolumetricComparatorImpl::superarcListPortal
EdgePairArrayPortalType superarcListPortal
Definition: SuperArcVolumetricComparator.h:79
vtkm::cont::ArrayHandle::ReadPortalType
typename StorageType::ReadPortalType ReadPortalType
Definition: ArrayHandle.h:294
vtkm::Id
vtkm::Int32 Id
Represents an ID (index into arrays).
Definition: Types.h:191
vtkm::worklet::contourtree_augmented::process_contourtree_inc::SuperArcVolumetricComparatorImpl::SuperArcVolumetricComparatorImpl
SuperArcVolumetricComparatorImpl(const IdArrayType &Weight, const EdgePairArray &SuperarcList, bool PairsAtLowEnd, vtkm::cont::DeviceAdapterId device, vtkm::cont::Token &token)
Definition: SuperArcVolumetricComparator.h:82
vtkm::worklet::contourtree_augmented::process_contourtree_inc::SuperArcVolumetricComparatorImpl
Definition: SuperArcVolumetricComparator.h:71
vtkm::cont::Token
A token to hold the scope of an ArrayHandle or other object.
Definition: Token.h:35
vtkm::worklet::contourtree_augmented::process_contourtree_inc::SuperArcVolumetricComparatorImpl::operator()
VTKM_EXEC bool operator()(const vtkm::Id &i1, const vtkm::Id &i2) const
Definition: SuperArcVolumetricComparator.h:96
vtkm::worklet::contourtree_augmented::process_contourtree_inc::SuperArcVolumetricComparator
Definition: SuperArcVolumetricComparator.h:153
vtkm::Pair::first
FirstType first
The pair's first object.
Definition: Pair.h:50
Types.h
VTKM_CONT
#define VTKM_CONT
Definition: ExportMacros.h:57
vtkm::worklet::contourtree_augmented::process_contourtree_inc::SuperArcVolumetricComparator::PairsAtLowEnd
bool PairsAtLowEnd
Definition: SuperArcVolumetricComparator.h:176
vtkm::worklet::contourtree_augmented::process_contourtree_inc::SuperArcVolumetricComparator::SuperArcVolumetricComparator
SuperArcVolumetricComparator(const IdArrayType &weight, const EdgePairArray &superArcList, bool pairsAtLowEnd)
Definition: SuperArcVolumetricComparator.h:157
vtkm::cont::ExecutionObjectBase
Base ExecutionObjectBase for execution objects to inherit from so that you can use an arbitrary objec...
Definition: ExecutionObjectBase.h:31
vtkm::cont::DeviceAdapterId
Definition: DeviceAdapterTag.h:52
vtkm::worklet::contourtree_augmented::process_contourtree_inc::SuperArcVolumetricComparator::Weight
IdArrayType Weight
Definition: SuperArcVolumetricComparator.h:174
ExecutionObjectBase.h
vtkm::Pair
A vtkm::Pair is essentially the same as an STL pair object except that the methods (constructors and ...
Definition: Pair.h:29
vtkm::worklet::contourtree_augmented::process_contourtree_inc::SuperArcVolumetricComparator::PrepareForExecution
VTKM_CONT SuperArcVolumetricComparatorImpl PrepareForExecution(vtkm::cont::DeviceAdapterId device, vtkm::cont::Token &token)
Definition: SuperArcVolumetricComparator.h:166
vtkm::Pair::second
SecondType second
The pair's second object.
Definition: Pair.h:55
vtkm::worklet::contourtree_augmented::process_contourtree_inc::SuperArcVolumetricComparatorImpl::EdgePairArrayPortalType
EdgePairArray::ReadPortalType EdgePairArrayPortalType
Definition: SuperArcVolumetricComparator.h:75