VR-Forces 4.6.1 Class Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
pagingFeatureSet.h
Go to the documentation of this file.
1 
2 
3 
4 
5 #pragma once
6 
7 #include <features/feature.h>
8 #include <features/featureSet.h>
14 #include <features/tileFeature.h>
15 
17 
18 #include <tbb/queuing_rw_mutex.h>
19 #include <tbb/spin_rw_mutex.h>
20 
21 #include <boost/logic/tribool.hpp>
22 
23 namespace MAKVRinTerra
24 {
25  class DtUnusedFeatureTileTracker;
26 
27  template <typename FS>
29 
38  template <typename FS>
40  : public DtFeatureSetWrapper<FS, boost::shared_ptr, DtPagingFeatureSetSubset<FS> >
41  , public DtObjectDebugger< DtPagingFeatureSet<FS> >
42  {
43  public:
44  typedef DtFeatureSetWrapper<FS, boost::shared_ptr, DtPagingFeatureSetSubset<FS> > Base;
45 
46  using Base::filter;
47 
48  template <template <class> class PtrT> class DT_DLL_features GridTemplate;
51  class DT_DLL_features WeakGrid;
53 
54  typedef FS FeatureSet;
55  typedef typename FeatureSet::Feature Feature;
56  typedef typename FeatureSet::ForEachFunction ForEachFunction;
57 
58  typedef boost::shared_ptr<DtPagingFeatureSet> Ptr;
59  typedef boost::shared_ptr<Subset> SubsetPtr;
60  typedef boost::shared_ptr<const Subset> SubsetCPtr;
61  typedef boost::shared_ptr<Grid> GridPtr;
62  typedef boost::shared_ptr<const Grid> GridCPtr;
63  typedef boost::shared_ptr<Leaf> LeafPtr;
64  typedef boost::shared_ptr<const Leaf> LeafCPtr;
65 
69  {
70  public:
71  typedef boost::shared_ptr<Config> Ptr;
73 
75  boost::shared_ptr<FeatureSet> inputFeatureSet;
76 
81 
83  boost::weak_ptr<Queue> taskQueue;
84 
87  boost::shared_ptr<DtFeatureSet::Source> tileFeatures;
88 
90  explicit Config(FeatureSet*);
91 
93  explicit Config(const Config& cfg)
94  : inputFeatureSet(cfg.inputFeatureSet)
95  , unusedTileTracker(cfg.unusedTileTracker)
96  , taskQueue(cfg.taskQueue)
97  , tileFeatures(cfg.tileFeatures)
98  {
99  static_cast<DtTerrainInterfaceConfig&>(*this) = cfg;
100  }
101  };
102 
104 
105  static DtPagingFeatureSet* Make(Config* cfg, const DtProj::Bounds& bounds)
106  {
107  typename Config::Ptr c(cfg);
108  SubsetPtr parentTile(new Grid(c, bounds));
109  return new DtPagingFeatureSet(parentTile);
110  }
111 
112  static DtPagingFeatureSet* Make(const Config& cfg, const DtProj::Bounds& bounds)
113  {
114  return Make(new Config(cfg), bounds);
115  }
117 
118  FS* filter(const DtQuery&, const boost::optional<DtFeatureGeometry>&, DtLoadType) const;
119  DtPagingFeatureSet* clone() const;
120  bool loaded(double) const;
121 
122  bool isCacheable(const boost::optional<DtFeatureGeometry>& area) const;
123  void cacheEstimate(double& time, double& size, const boost::optional<DtFeatureGeometry>& area) const;
124 
125  void cacheData(
126  const boost::optional<DtFeatureGeometry>& area,
127  DtFeatureCacheProgressCallback* progress) const;
128 
129  protected:
130  explicit DtPagingFeatureSet(const SubsetCPtr&);
131  explicit DtPagingFeatureSet(const DtPagingFeatureSet&);
132 
133  typedef tbb::spin_mutex Mutex;
134 
135  mutable Mutex myMutex;
137  };
138 
139  template <typename FS>
141  : virtual public FS
142  , public DtObjectDebugger< DtPagingFeatureSetSubset<FS> >
143  {
144  public:
149 
151 
152  const Config& config() const { return *myInfo; }
153  const FS& input() const { return *config().inputFeatureSet; }
154  DtProj::Bounds bounds() const { return myBounds; }
156  SubsetPtr parent() const { return myParent; }
157  int level() const { return myLevel; }
158 
159  virtual FS* filterCache(
160  const DtQuery&,
161  const boost::optional<DtFeatureGeometry>&,
162  DtLoadType,
163  SubsetCPtr& highestSubset,
164  const DtProj::Bounds::LineSegment* = 0,
165  unsigned indexLevel = 0) const = 0;
166 
167  FS* filter(const DtQuery&, const boost::optional<DtFeatureGeometry>&, DtLoadType) const;
168 
169  virtual boost::optional<unsigned> sizeEstimate() const = 0;
170  virtual void updateStats();
171 
172  protected:
173  DtPagingFeatureSetSubset(const GridCPtr& parent, unsigned i);
174  DtPagingFeatureSetSubset(const typename Config::Ptr&, const DtProj::Bounds&);
175 
176  const typename Config::Ptr myInfo;
177  const int myLevel;
178 
180 
183  };
184 
185  template <typename FS>
186  template <template <class> class PtrT>
188  : public DtPagingFeatureSet<FS>::Subset
189  {
190  public:
191  struct Tile
192  {
193  explicit Tile(const DtProj::Bounds& b, unsigned i);
194 
197 
199  };
200 
201  typedef typename FS::DetachCallback DetachCallback;
202  typedef typename FS::LoadedCallback LoadedCallback;
203 
204  std::string label() const;
205 
206  void forEachFeatureParallel(const ForEachFunction&) const;
207  DetachCallback forEachFeatureAsync(const ForEachFunction&) const;
208 
209  boost::optional<unsigned> sizeEstimate() const;
210  void updateStats();
211 
212  const DtProj::Bounds& subBounds(unsigned) const;
213  const DtFeatureGeometry::Area& subGeometry(unsigned) const;
214 
215  Tile& getSubtile(unsigned);
216  const Tile& getSubtile(unsigned) const;
217 
218  bool loaded(double) const;
219  DetachCallback addLoadedCallback(const LoadedCallback&) const;
220  unsigned numberOfFeatures() const;
221  bool elided() const;
222  bool empty() const;
223 
224  GridTemplate(const typename Config::Ptr& cfg, const DtProj::Bounds&);
225 
226  protected:
227  struct Detacher;
228 
229  GridTemplate(const GridCPtr& parent, unsigned i);
230 
231  typedef tbb::spin_rw_mutex SizeMutex;
233 
238 
239  boost::optional<unsigned> mySizeEstimate;
240  const bool myEmptyFlag;
241  };
242 
243  template <typename FS>
245  : public DtPagingFeatureSet<FS>::template GridTemplate<boost::weak_ptr>
246  , public boost::enable_shared_from_this<typename DtPagingFeatureSet<FS>::Grid>
247  , public DtObjectDebugger<typename DtPagingFeatureSet<FS>::Grid>
248  {
249  public:
250  FS* filterCache(
251  const DtQuery&,
252  const boost::optional<DtFeatureGeometry>&,
253  DtLoadType,
254  SubsetCPtr& highestSubset,
256  unsigned indexLevel) const;
257 
258  void cacheEstimate(double& time, double& size, const boost::optional<DtFeatureGeometry>& area) const;
259 
260  void cacheData(
261  const boost::optional<DtFeatureGeometry>& area,
262  DtFeatureCacheProgressCallback* progress) const;
263 
264  FS* clone() const;
265 
266  Grid(const typename Config::Ptr& cfg, const DtProj::Bounds&);
267 
268  protected:
269  virtual bool makeLeaf(unsigned) const;
270 
271  Grid(const GridCPtr& parent, unsigned i);
272  };
273 
274  template <typename FS>
276  : public DtPagingFeatureSet<FS>::Subset
277  , public DtQueueLoadingFeatureSet<FS>
278  , public DtObjectDebugger<typename DtPagingFeatureSet<FS>::Leaf>
279  {
280  public:
281  typedef typename FS::ForEachFunction ForEachFunction;
282  typedef typename FS::DetachCallback DetachCallback;
283 
284  typedef std::vector<typename Feature::CPtr> FeatureVector;
285 
286  ~Leaf();
287 
288  bool loaded(double = 0) const;
289  unsigned numberOfFeatures() const;
290  bool elided() const;
291  void forEachFeatureParallel(const ForEachFunction&) const;
292  DetachCallback forEachFeatureAsync(const ForEachFunction&) const;
293 
294  FS* filter(const DtQuery&, const boost::optional<DtFeatureGeometry>&, DtLoadType) const;
295 
296  FS* filterCache(
297  const DtQuery&,
298  const boost::optional<DtFeatureGeometry>&,
299  DtLoadType,
300  SubsetCPtr& highestSubset,
302  unsigned indexLevel) const;
303 
304  boost::optional<unsigned> sizeEstimate() const;
305 
306  FS* clone() const;
307 
308  std::string label() const;
309 
310  Leaf(const GridCPtr& parent, unsigned i);
311 
312  LeafPtr shared_from_this();
313  LeafCPtr shared_from_this() const;
314 
315  bool unload();
316 
317  protected:
318  void makeTileFeature(const DtFeatureGeometry& geom, unsigned color);
319 
320  void start(bool wait);
321  bool run(bool wait);
322  FS* createFeatureSet(FS*) const;
323  void inputLoadedCallback();
324 
325  typedef tbb::spin_mutex TileFeatureMutex;
327  std::auto_ptr<DtTileFeature> myTileFeature;
328  };
329 }
330 

Document ID: Generated on Wed Jul 25 16:57:45 EDT 2018 from SVN revision 190790
Copyright © 2005-2018 VT MÄK. All Rights Reserved (www.mak.com)