10 #ifndef EIGEN_BVALGORITHMS_H
11 #define EIGEN_BVALGORITHMS_H
17 #ifndef EIGEN_PARSED_BY_DOXYGEN
18 template<
typename BVH,
typename Intersector>
22 typedef typename BVH::VolumeIterator VolIter;
23 typedef typename BVH::ObjectIterator ObjIter;
25 VolIter vBegin = VolIter(), vEnd = VolIter();
26 ObjIter oBegin = ObjIter(), oEnd = ObjIter();
28 std::vector<Index> todo(1, root);
30 while(!todo.empty()) {
31 tree.getChildren(todo.back(), vBegin, vEnd, oBegin, oEnd);
34 for(; vBegin != vEnd; ++vBegin)
35 if(intersector.intersectVolume(
tree.getVolume(*vBegin)))
36 todo.push_back(*vBegin);
38 for(; oBegin != oEnd; ++oBegin)
39 if(intersector.intersectObject(*oBegin))
44 #endif //not EIGEN_PARSED_BY_DOXYGEN
46 template<
typename Volume1,
typename Object1,
typename Object2,
typename Intersector>
58 template<
typename Volume2,
typename Object2,
typename Object1,
typename Intersector>
78 template<
typename BVH,
typename Intersector>
92 template<
typename BVH1,
typename BVH2,
typename Intersector>
93 void BVIntersect(
const BVH1 &tree1,
const BVH2 &tree2, Intersector &intersector)
99 typedef typename BVH1::VolumeIterator VolIter1;
100 typedef typename BVH1::ObjectIterator ObjIter1;
101 typedef typename BVH2::VolumeIterator VolIter2;
102 typedef typename BVH2::ObjectIterator ObjIter2;
104 VolIter1 vBegin1 = VolIter1(), vEnd1 = VolIter1();
105 ObjIter1 oBegin1 = ObjIter1(), oEnd1 = ObjIter1();
106 VolIter2 vBegin2 = VolIter2(), vEnd2 = VolIter2(), vCur2 = VolIter2();
107 ObjIter2 oBegin2 = ObjIter2(), oEnd2 = ObjIter2(), oCur2 = ObjIter2();
109 std::vector<std::pair<Index1, Index2> > todo(1, std::make_pair(tree1.getRootIndex(), tree2.getRootIndex()));
111 while(!todo.empty()) {
112 tree1.getChildren(todo.back().first, vBegin1, vEnd1, oBegin1, oEnd1);
113 tree2.getChildren(todo.back().second, vBegin2, vEnd2, oBegin2, oEnd2);
116 for(; vBegin1 != vEnd1; ++vBegin1) {
117 const typename BVH1::Volume &vol1 = tree1.getVolume(*vBegin1);
118 for(vCur2 = vBegin2; vCur2 != vEnd2; ++vCur2) {
119 if(intersector.intersectVolumeVolume(vol1, tree2.getVolume(*vCur2)))
120 todo.push_back(std::make_pair(*vBegin1, *vCur2));
123 for(oCur2 = oBegin2; oCur2 != oEnd2; ++oCur2) {
124 Helper1 helper(*oCur2, intersector);
130 for(; oBegin1 != oEnd1; ++oBegin1) {
131 for(vCur2 = vBegin2; vCur2 != vEnd2; ++vCur2) {
132 Helper2 helper(*oBegin1, intersector);
137 for(oCur2 = oBegin2; oCur2 != oEnd2; ++oCur2) {
138 if(intersector.intersectObjectObject(*oBegin1, *oCur2))
147 #ifndef EIGEN_PARSED_BY_DOXYGEN
148 template<
typename BVH,
typename Minimizer>
153 typedef std::pair<Scalar, Index> QueueElement;
154 typedef typename BVH::VolumeIterator VolIter;
155 typedef typename BVH::ObjectIterator ObjIter;
157 VolIter vBegin = VolIter(), vEnd = VolIter();
158 ObjIter oBegin = ObjIter(), oEnd = ObjIter();
159 std::priority_queue<QueueElement, std::vector<QueueElement>, std::greater<QueueElement> > todo;
161 todo.push(std::make_pair(
Scalar(), root));
163 while(!todo.empty()) {
164 tree.getChildren(todo.top().second, vBegin, vEnd, oBegin, oEnd);
167 for(; oBegin != oEnd; ++oBegin)
168 minimum = (
std::min)(minimum, minimizer.minimumOnObject(*oBegin));
170 for(; vBegin != vEnd; ++vBegin) {
171 Scalar val = minimizer.minimumOnVolume(
tree.getVolume(*vBegin));
173 todo.push(std::make_pair(val, *vBegin));
179 #endif //not EIGEN_PARSED_BY_DOXYGEN
182 template<
typename Volume1,
typename Object1,
typename Object2,
typename Minimizer>
195 template<
typename Volume2,
typename Object2,
typename Object1,
typename Minimizer>
218 template<
typename BVH,
typename Minimizer>
234 template<
typename BVH1,
typename BVH2,
typename Minimizer>
242 typedef std::pair<Scalar, std::pair<Index1, Index2> > QueueElement;
243 typedef typename BVH1::VolumeIterator VolIter1;
244 typedef typename BVH1::ObjectIterator ObjIter1;
245 typedef typename BVH2::VolumeIterator VolIter2;
246 typedef typename BVH2::ObjectIterator ObjIter2;
248 VolIter1 vBegin1 = VolIter1(), vEnd1 = VolIter1();
249 ObjIter1 oBegin1 = ObjIter1(), oEnd1 = ObjIter1();
250 VolIter2 vBegin2 = VolIter2(), vEnd2 = VolIter2(), vCur2 = VolIter2();
251 ObjIter2 oBegin2 = ObjIter2(), oEnd2 = ObjIter2(), oCur2 = ObjIter2();
252 std::priority_queue<QueueElement, std::vector<QueueElement>, std::greater<QueueElement> > todo;
255 todo.push(std::make_pair(
Scalar(), std::make_pair(tree1.getRootIndex(), tree2.getRootIndex())));
257 while(!todo.empty()) {
258 tree1.getChildren(todo.top().second.first, vBegin1, vEnd1, oBegin1, oEnd1);
259 tree2.getChildren(todo.top().second.second, vBegin2, vEnd2, oBegin2, oEnd2);
262 for(; oBegin1 != oEnd1; ++oBegin1) {
263 for(oCur2 = oBegin2; oCur2 != oEnd2; ++oCur2) {
264 minimum = (
std::min)(minimum, minimizer.minimumOnObjectObject(*oBegin1, *oCur2));
267 for(vCur2 = vBegin2; vCur2 != vEnd2; ++vCur2) {
268 Helper2 helper(*oBegin1, minimizer);
273 for(; vBegin1 != vEnd1; ++vBegin1) {
274 const typename BVH1::Volume &vol1 = tree1.getVolume(*vBegin1);
276 for(oCur2 = oBegin2; oCur2 != oEnd2; ++oCur2) {
277 Helper1 helper(*oCur2, minimizer);
281 for(vCur2 = vBegin2; vCur2 != vEnd2; ++vCur2) {
282 Scalar val = minimizer.minimumOnVolumeVolume(vol1, tree2.getVolume(*vCur2));
284 todo.push(std::make_pair(val, std::make_pair(*vBegin1, *vCur2)));
293 #endif // EIGEN_BVALGORITHMS_H