VR-Forces Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
ssAccumulationFunctor.h
Go to the documentation of this file.
1 /*********************************************************************
2 ** Copyright (c) 2005 MAK Technologies, Inc.
3 ** All rights reserved.
4 *********************************************************************/
5 /*********************************************************************
6 ** $RCSfile: ssAccumulationFunctor.h,v $ $Revision: 1.8 $ $State: Exp $
7 *********************************************************************/
8 #ifndef ssAccumulationFunctor_H_
9 #define ssAccumulationFunctor_H_
10 
11 #include <vlutil/vlConfig.h>
13 #include "geometry/ssFunctor.h"
14 
15 //
16 // A functor intended for use with the spatial subdivision set of classes. It's
17 // primary usage is to accumulate pointers to elements in its internal container,
18 // The type pointed to is the second template parameter of the functor.
19 // Expected usage:
20 // When passed to the intersection functions, it accumulates pointers to the
21 // second parameter to its function operator in its internal container. For example
22 // it will build up a list of all cells that intersect a given primitive when
23 // passed into an ss intersection object. (for example, in the terrain inserter
24 // class.)
25 //
26 template <typename IgnoredType, typename ContainedType>
27 class DtSsAccumulationFunctor: public DtSsFunctor<IgnoredType, ContainedType>
28 {
29 public:
30  // Typedefs used by the functor
31  // This functor currently uses a vector as container of accumulated elements.
32  typedef std::vector<ContainedType*> DtAccumulationContainer;
33 
34  // Constructor
36 
37  // Destructor
38  virtual ~DtSsAccumulationFunctor();
39 
40 private:
41  // not implemented
44 
45 public:
46  // Accumulates the second parameter in the internal container
47  // The first parameter, ignoredItem, is ignored by this functor.
48  //
49  // @returns This functor is never "done processing" and so it always returns false.
50  //
51  // @note This is intended to be used with the spatial subdivision intersectors,
52  // where the second parameter is the subdivision cell result from an intersection test.
53  virtual bool operator()(IgnoredType& ignoredItem, ContainedType& itemToAccumulate);
54 
55  // Get/Set the container of accumulated items
56  // @{
58  virtual void setContainer(DtAccumulationContainer& newContainer);
59  // @}
60 
61 private:
63 };
64 
65 
66 //------------------------------------------------------
67 // INLINE METHODS
68 //------------------------------------------------------
69 template <typename IgnoredType, typename ContainedType>
71 : DtSsFunctor<IgnoredType, ContainedType>()
72 , myContainer()
73 {
74 }
75 
76 
77 template <typename IgnoredType, typename ContainedType>
79 {
80 }
81 
82 
83 template <typename IgnoredType, typename ContainedType>
84 bool DtSsAccumulationFunctor<IgnoredType, ContainedType>::operator()(IgnoredType& ignoredItem, ContainedType& itemToAccumulate)
85 {
86  // Ignore the first parameter as this functor only accumulates the second.
87  container().insert(container().end(), &itemToAccumulate);
88 
89  // Always returns false, as it is never "done" processing.
90  return false;
91 }
92 
93 
94 template <typename IgnoredType, typename ContainedType>
96 {
97  return myContainer;
98 };
99 
100 
101 template <typename IgnoredType, typename ContainedType>
103 {
104  myContainer = newContainer;
105 };
106 
107 #endif
108 
109 
Definition: ssAccumulationFunctor.h:27
std::vector< ContainedType * > DtAccumulationContainer
Definition: ssAccumulationFunctor.h:32
virtual bool operator()(IgnoredType &ignoredItem, ContainedType &itemToAccumulate)
Definition: ssAccumulationFunctor.h:84
virtual DtAccumulationContainer & container()
Definition: ssAccumulationFunctor.h:95
DtSsAccumulationFunctor & operator=(const DtSsAccumulationFunctor &original)
DtAccumulationContainer myContainer
Definition: ssAccumulationFunctor.h:62
Definition: ssFunctor.h:46
virtual ~DtSsAccumulationFunctor()
Definition: ssAccumulationFunctor.h:78
virtual void setContainer(DtAccumulationContainer &newContainer)
Definition: ssAccumulationFunctor.h:102
DtSsAccumulationFunctor()
Definition: ssAccumulationFunctor.h:70

Document ID: Generated on Tue Sep 24 19:28:17 EDT 2024 from SVN revision 269799
Copyright © 2005-2024 MAK Technologies. All Rights Reserved (www.mak.com)