VR-Forces 4.6 Class Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
ssClosestIntersectionFunctor.h
Go to the documentation of this file.
1 /*********************************************************************
2 ** Copyright (c) 2005 MAK Technologies, Inc.
3 ** All rights reserved.
4 *********************************************************************/
5 /*********************************************************************
6 ** $RCSfile: ssClosestIntersectionFunctor.h,v $ $Revision: 1.5 $ $State: Exp $
7 *********************************************************************/
8 #ifndef ssClosestIntersectionFunctor_H_
9 #define ssClosestIntersectionFunctor_H_
10 
11 #include <vlutil/vlConfig.h>
13 #include "geometry/ssFunctor.h"
14 
16 #include "gdb/gdbNode.h"
17 #include <assert.h>
18 
19 //
20 // A functor intended for use with the spatial subdivision set of classes. It's
21 // primary usage is to intersect the first parameter into the second. Results
22 // of the intersection are reported in the record type specified in the third
23 // template parameter.
24 //
25 // Expected usage:
26 // When passed to the intersection objects intersection functions, this fucntor
27 // intersects the first item into the second one. Used primarily for intersecting the
28 // different spatial sorted elements into their appropriate spatial subdivisions.
29 // For an example, see the gdbNode intersecter class.
30 //
31 template <typename TypeToIntersect, typename Container, typename T_IntersectionRecordType>
32 class DtSsClosestIntersectionFunctor : public DtSsFunctor<TypeToIntersect, Container>
33 {
34 public:
35  // Constructor
37 
38  // Destructor
40 
41 private:
42  // not implemented
45 
46 public:
47  // Function operator - when applied intersects the first element with the
48  // second element.
49  // @param itemToIntersect The item to intersect into the second parameter.
50  // @param container The container of elements into which to intersect the first
51  // parameter.
52  //
53  // @returns Always returns false as it is never done processing - it can
54  // always continue intersecting elements.
55  virtual bool operator()(TypeToIntersect& itemToIntersect, Container& container);
56 
57  virtual T_IntersectionRecordType* intersectionRecord() const;
58 
59  virtual void setIntersectionRecord(T_IntersectionRecordType* newIntersectionRecord);
60 
62 
63  virtual void setIntersectionRecordType(
64  DtGdbNode::DtIntersectRecordType& newIntersectionRecordType);
65 
66 
67 private:
68 
69  T_IntersectionRecordType* myIntersectionRecord;
71 };
72 
73 
74 //------------------------------------------------------
75 // INLINE METHODS
76 //------------------------------------------------------
77 template <typename TypeToIntersect, typename Container, typename T_IntersectionRecordType>
79 : DtSsFunctor<TypeToIntersect, Container>()
80 , myIntersectionRecord(0)
81 , myIntersectionRecordType(DtGdbNode::IRT_IPOINT)
82 {
83 }
84 
85 
86 template <typename TypeToIntersect, typename Container, typename T_IntersectionRecordType>
88 {
89 }
90 
91 template <typename TypeToIntersect, typename Container, typename T_IntersectionRecordType>
93  (TypeToIntersect& itemToIntersect, Container& containerToIntersect)
94 {
95  bool retVal = false;
96 
97  assert(myIntersectionRecord != 0);
98 
99  typename Container::iterator iter = containerToIntersect.begin();
100  typename Container::iterator endIter = containerToIntersect.end();
101  for (; iter != endIter; ++iter)
102  {
103  if ((*iter)->intersect(itemToIntersect, *myIntersectionRecord, myIntersectionRecordType))
104  {
105  assert(myIntersectionRecord->intersectionFound());
106  retVal = true;
107  }
108  }
109 
110  return retVal;
111 }
112 
113 
114 template <typename TypeToIntersect, typename Container, typename T_IntersectionRecordType>
115 T_IntersectionRecordType*
117 {
118  return myIntersectionRecord;
119 }
120 
121 
122 template <typename TypeToIntersect, typename Container, typename T_IntersectionRecordType>
124 setIntersectionRecord(T_IntersectionRecordType* newIntersectionRecord)
125 {
126  assert(newIntersectionRecord != 0);
127  myIntersectionRecord = newIntersectionRecord;
128 }
129 
130 
131 template <typename TypeToIntersect, typename Container, typename T_IntersectionRecordType>
134 {
135  return myIntersectionRecordType;
136 }
137 
138 template <typename TypeToIntersect, typename Container, typename T_IntersectionRecordType>
141 {
142  myIntersectionRecordType = newIntersectionRecordType;
143 }
144 
145 #endif
146 
147 

Document ID: Generated on Thu Apr 12 03:15:37 EDT 2018 from SVN revision 187986
Copyright © 2005-2018 VT MÄK. All Rights Reserved (www.mak.com)