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) 2025 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() override;
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,
54  ContainedType &itemToAccumulate) override;
55 
56  // Get/Set the container of accumulated items
57  // @{
59  virtual void setContainer(DtAccumulationContainer& newContainer);
60  // @}
61 
62 private:
64 };
65 
66 
67 //------------------------------------------------------
68 // INLINE METHODS
69 //------------------------------------------------------
70 template <typename IgnoredType, typename ContainedType>
72 : DtSsFunctor<IgnoredType, ContainedType>()
73 , myContainer()
74 {
75 }
76 
77 
78 template <typename IgnoredType, typename ContainedType>
80 {
81 }
82 
83 
84 template <typename IgnoredType, typename ContainedType>
85 bool DtSsAccumulationFunctor<IgnoredType, ContainedType>::operator()(IgnoredType& ignoredItem, ContainedType& itemToAccumulate)
86 {
87  // Ignore the first parameter as this functor only accumulates the second.
88  container().insert(container().end(), &itemToAccumulate);
89 
90  // Always returns false, as it is never "done" processing.
91  return false;
92 }
93 
94 
95 template <typename IgnoredType, typename ContainedType>
97 {
98  return myContainer;
99 };
100 
101 
102 template <typename IgnoredType, typename ContainedType>
104 {
105  myContainer = newContainer;
106 };
107 
108 #endif
109 
110 
Definition: ssAccumulationFunctor.h:27
std::vector< ContainedType * > DtAccumulationContainer
Definition: ssAccumulationFunctor.h:32
virtual ~DtSsAccumulationFunctor() override
Definition: ssAccumulationFunctor.h:79
virtual DtAccumulationContainer & container()
Definition: ssAccumulationFunctor.h:96
DtSsAccumulationFunctor & operator=(const DtSsAccumulationFunctor &original)
virtual bool operator()(IgnoredType &ignoredItem, ContainedType &itemToAccumulate) override
Definition: ssAccumulationFunctor.h:85
DtAccumulationContainer myContainer
Definition: ssAccumulationFunctor.h:63
Definition: ssFunctor.h:46
virtual void setContainer(DtAccumulationContainer &newContainer)
Definition: ssAccumulationFunctor.h:103
DtSsAccumulationFunctor()
Definition: ssAccumulationFunctor.h:71

Document ID: Generated on Thu Oct 23 22:29:17 EDT 2025 from SVN revision 280951
Copyright © 2005-2024 MAK Technologies. All Rights Reserved (www.mak.com)