VR-Forces 4.2 Class Documentation
featureDuplicateRemover.h
Go to the documentation of this file.
1 /*******************************************************************************
2 ** Copyright (c) 2013 MAK Technologies, Inc.
3 ** All rights reserved.
4 *******************************************************************************/
5 
9 
11 
12 #include <boost/unordered/unordered_set.hpp>
13 #include <boost/tuple/tuple.hpp>
14 
15 #pragma once
16 
17 namespace MAKVRinTerra
18 {
20  {
21  public:
22  typedef boost::unordered_set<DtFeatureGeometry::Hash> HashSet;
23 
24  bool has(DtFeatureGeometry g) const
25  {
26  return myHashSet.find(g.hash()) != myHashSet.end();
27  }
28 
30  {
31  HashSet::iterator iter;
32  bool inserted;
33  boost::tie(iter, inserted) = myHashSet.insert(g.hash());
34 
35  return inserted;
36  }
37 
38  protected:
40  };
41 
42  template <typename F>
44  {
45  public:
46  typedef boost::function<void (const F&)> ForEachFunction;
47 
49  : myFunc(func)
50  {
51  }
52 
54  {
55  myFunc = func;
56  }
57 
58  bool isDuplicate(const F& feature) const
59  {
60  return !const_cast<DtFeatureDuplicateRemover*>(this)->insert(feature.geometry());
61  }
62 
63  void operator()(const F& feature)
64  {
65  if (!isDuplicate(feature) && myFunc)
66  myFunc(feature);
67  }
68 
69  void call(ForEachFunction func, const F& feature) const
70  {
71  if (!isDuplicate(feature))
72  func(feature);
73  }
74 
75  protected:
77  };
78 
79  template <typename FS>
80  class DtDeduplicatingFeatureSet : public FS::ScopedWrapper
81  {
82  public:
83  typedef typename FS::ScopedWrapper Parent;
84  typedef typename FS::Feature Feature;
85  typedef typename FS::ForEachFunction ForEachFunction;
86 
88  : Parent(fs)
89  {
90  }
91 
92  void forEachFeature(ForEachFunction func, DtWaitType wait) const
93  {
95  Parent::forEachFeature(boost::ref(dedupe), wait);
96  }
97 
99  {
101  forEachFeature(func, wait);
102  }
103 
105  {
106  return new DtDeduplicatingFeatureSet(Parent::filter(query, load));
107  }
108 
110  {
111  return new DtDeduplicatingFeatureSet(*this);
112  }
113 
114  protected:
116  : Parent(fs.mySet->clone())
117  {
118  }
119  };
120 }
121 

Document ID: Generated on Sun Nov 24 19:49:21 EST 2013 from SVN revision 133924
Copyright © 2005-2013 VT MÄK. All Rights Reserved (www.mak.com)