VR-Forces 5.0.2 Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
ssAllIntersectionsFunctor.h
Go to the documentation of this file.
1 /*********************************************************************
2 ** Copyright (c) 2005 MAK Technologies, Inc.
3 ** All rights reserved.
4 *********************************************************************/
5 /*********************************************************************
6 ** $RCSfile: ssAllIntersectionsFunctor.h,v $ $Revision: 1.5 $ $State: Exp $
7 *********************************************************************/
8 #ifndef ssAllIntersectionsFunctor_H_
9 #define ssAllIntersectionsFunctor_H_
10 
11 #include <vlutil/vlConfig.h>
13 #include "geometry/ssFunctor.h"
14 
16 #include "gdb/gdbNode.h"
18 #include <assert.h>
19 
20 //
21 // A functor intended for use with the spatial subdivision set of classes. It's
22 // primary usage is to intersect the first parameter into the second.
23 //
24 // Expected usage:
25 // When passed to the intersection objects intersection functions, this fucntor
26 // intersects the first item into the second one. Used primarily for intersecting the
27 // different spatial sorted elements into their appropriate spatial subdivisions.
28 // For an example, see the gdbNode intersecter class.
29 //
30 template <typename TypeToIntersect, typename Container>
31 class DtSsAllIntersectionsFunctor : public DtSsFunctor<TypeToIntersect, Container>
32 {
33 public:
34  // Constructor
36 
37  // Destructor
39 
40 private:
41  // not implemented
44 
45 public:
46  // Function operator - when applied intersects the first element with the
47  // second element.
48  // @param itemToIntersect The item to intersect into the second parameter.
49  // @param container The container of elements into which to intersect the first
50  // parameter.
51  //
52  // @returns Always returns false as it is never done processing - it can
53  // always continue intersecting elements.
54  virtual bool operator()(TypeToIntersect& itemToIntersect, Container& container);
55 
57 
58  virtual void setIntersectionRecordContainer(
59  DtChordIntersectRecordList* newIntersectionRecordContainer);
60 
62 
63  virtual void setIntersectionRecordType(
64  DtGdbNode::DtIntersectRecordType& newIntersectionRecordType);
65 
66 
67 private:
68 
71 };
72 
73 
74 //------------------------------------------------------
75 // INLINE METHODS
76 //------------------------------------------------------
77 template <typename TypeToIntersect, typename Container>
79 : DtSsFunctor<TypeToIntersect, Container>()
80 , myIntersectionRecordContainer(0)
81 , myIntersectionRecordType(DtGdbNode::IRT_IPOINT)
82 {
83 }
84 
85 
86 template <typename TypeToIntersect, typename Container>
88 {
89 }
90 
91 template <typename TypeToIntersect, typename Container>
93  (TypeToIntersect& itemToIntersect, Container& containerToIntersect)
94 {
95  // Use our record type to determine whether we should keep looking
96  bool retVal = false;
97 
98  assert(myIntersectionRecordContainer != 0);
99 
100  typename Container::iterator iter = containerToIntersect.begin();
101  typename Container::iterator endIter = containerToIntersect.end();
102  for (; iter != endIter; ++iter)
103  {
104  if ((*iter)->allIntersectsAlongChord(itemToIntersect,
105  *myIntersectionRecordContainer, myIntersectionRecordType))
106  {
107  assert(myIntersectionRecordContainer->count() != 0);
108  // Ok I found one. Is that all I'm looking for?
109  // If our intersection record is IRT_ALL_DATA_TERRAIN or
110  // IRT_VECTOR_DATA_ALONG_CHORD or IRT_ALL_DATA_ALONG_CHORD
111  // we are looking for all possible hits so keep looking even
112  // if one interesection is found.
113  if ( myIntersectionRecordType == 0x07 ||
114  myIntersectionRecordType == 0x20 ||
115  myIntersectionRecordType == 0x27)
116  {
117  // We should keep looking for more
118  retVal = false;
119  }
120  else
121  {
122  // We're done, we found the intersection we were looking for
123  retVal = true;
124  }
125  }
126  }
127 
128  return retVal;
129 }
130 
131 
132 template <typename TypeToIntersect, typename Container>
135 {
136  return myIntersectionRecordContainer;
137 }
138 
139 
140 template <typename TypeToIntersect, typename Container>
143 {
144  assert(newIntersectionRecordContainer != 0);
145  myIntersectionRecordContainer = newIntersectionRecordContainer;
146 }
147 
148 
149 template <typename TypeToIntersect, typename Container>
152 {
153  return myIntersectionRecordType;
154 }
155 
156 
157 template <typename TypeToIntersect, typename Container>
160 {
161  myIntersectionRecordType = newIntersectionRecordType;
162 }
163 
164 
165 
166 #endif
167 
168 
virtual DtGdbNode::DtIntersectRecordType intersectionRecordType() const
Definition: ssAllIntersectionsFunctor.h:151
virtual DtChordIntersectRecordList * intersectionRecordContainer() const
Definition: ssAllIntersectionsFunctor.h:134
Definition: chordIntersectRecordList.h:29
Definition: gdbNode.h:44
virtual void setIntersectionRecordContainer(DtChordIntersectRecordList *newIntersectionRecordContainer)
Definition: ssAllIntersectionsFunctor.h:142
DtIntersectRecordType
Definition: gdbNode.h:74
virtual ~DtSsAllIntersectionsFunctor()
Definition: ssAllIntersectionsFunctor.h:87
virtual bool operator()(TypeToIntersect &itemToIntersect, Container &container)
Definition: ssAllIntersectionsFunctor.h:93
Definition: ssAllIntersectionsFunctor.h:31
DtGdbNode::DtIntersectRecordType myIntersectionRecordType
Definition: ssAllIntersectionsFunctor.h:70
Definition: ssFunctor.h:46
DtSsAllIntersectionsFunctor()
Definition: ssAllIntersectionsFunctor.h:78
DtSsAllIntersectionsFunctor & operator=(const DtSsAllIntersectionsFunctor &original)
DtChordIntersectRecordList * myIntersectionRecordContainer
Definition: ssAllIntersectionsFunctor.h:69
virtual void setIntersectionRecordType(DtGdbNode::DtIntersectRecordType &newIntersectionRecordType)
Definition: ssAllIntersectionsFunctor.h:159

Document ID: Generated on Sun Dec 4 20:22:03 EST 2022 from SVN revision 249613
Copyright © 2005-2021 MAK Technologies. All Rights Reserved (www.mak.com)