searchTree.cc
Go to the documentation of this file.
1 /*
2  * searchTree implementation
3  *
4  * Copyright (C) Jan Elseberg, Andreas Nuechter
5  *
6  * Released under the GPL version 3.
7  *
8  */
9 
17 #include "slam6d/searchTree.h"
18 #include "slam6d/globals.icc"
19 
20 void SearchTree::getPtPairs(vector <PtPair> *pairs,
21  double *source_alignxf, // source
22  double * const *q_points, unsigned int startindex, unsigned int endindex, // target
23  int thread_num,
24  int rnd, double max_dist_match2, double &sum,
25  double *centroid_m, double *centroid_d)
26 {
27  // prepare this tree for resource access in FindClosest
28  lock();
29 
30  double local_alignxf_inv[16];
31  M4inv(source_alignxf, local_alignxf_inv);
32 
33  // t is the original point from target, s is the (inverted) query point from target and then
34  // the closest point in source
35  double t[3], s[3];
36  for (unsigned int i = startindex; i < endindex; i++) {
37  if (rnd > 1 && rand(rnd) != 0) continue; // take about 1/rnd-th of the numbers only
38 
39  t[0] = q_points[i][0];
40  t[1] = q_points[i][1];
41  t[2] = q_points[i][2];
42 
43  transform3(local_alignxf_inv, t, s);
44 
45  double *closest = this->FindClosest(s, max_dist_match2, thread_num);
46  if (closest) {
47  transform3(source_alignxf, closest, s);
48 
49  // This should be right, model=Source=First=not moving
50  centroid_m[0] += s[0];
51  centroid_m[1] += s[1];
52  centroid_m[2] += s[2];
53  centroid_d[0] += t[0];
54  centroid_d[1] += t[1];
55  centroid_d[2] += t[2];
56 
57  PtPair myPair(s, t);
58  double p12[3] = {
59  myPair.p1.x - myPair.p2.x,
60  myPair.p1.y - myPair.p2.y,
61  myPair.p1.z - myPair.p2.z };
62  sum += Len2(p12);
63 
64  pairs->push_back(myPair);
65  /*cout << "PTPAIR" << i << " "
66  << p[0] << " "
67  << p[1] << " "
68  << p[2] << " - "
69  << q_points[i][0] << " "
70  << q_points[i][1] << " "
71  << q_points[i][2] << " " << Len2(p12) << endl; */
72  }
73 
74  }
75 
76  // release resource access lock
77  unlock();
78 
79  return;
80 }
81 
82 void SearchTree::getPtPairs(vector <PtPair> *pairs,
83  double *source_alignxf, // source
84  const DataXYZ& xyz_r, unsigned int startindex, unsigned int endindex, // target
85  int thread_num,
86  int rnd, double max_dist_match2, double &sum,
87  double *centroid_m, double *centroid_d)
88 {
89  // prepare this tree for resource access in FindClosest
90  lock();
91 
92  double local_alignxf_inv[16];
93  M4inv(source_alignxf, local_alignxf_inv);
94 
95  // t is the original point from target, s is the (inverted) query point from target and then
96  // the closest point in source
97  double t[3], s[3];
98  for (unsigned int i = startindex; i < endindex; i++) {
99  if (rnd > 1 && rand(rnd) != 0) continue; // take about 1/rnd-th of the numbers only
100 
101  t[0] = xyz_r[i][0];
102  t[1] = xyz_r[i][1];
103  t[2] = xyz_r[i][2];
104 
105  transform3(local_alignxf_inv, t, s);
106 
107  double *closest = this->FindClosest(s, max_dist_match2, thread_num);
108  if (closest) {
109  transform3(source_alignxf, closest, s);
110 
111  // This should be right, model=Source=First=not moving
112  centroid_m[0] += s[0];
113  centroid_m[1] += s[1];
114  centroid_m[2] += s[2];
115  centroid_d[0] += t[0];
116  centroid_d[1] += t[1];
117  centroid_d[2] += t[2];
118 
119  PtPair myPair(s, t);
120  double p12[3] = {
121  myPair.p1.x - myPair.p2.x,
122  myPair.p1.y - myPair.p2.y,
123  myPair.p1.z - myPair.p2.z };
124  sum += Len2(p12);
125 
126  pairs->push_back(myPair);
127  /*cout << "PTPAIR" << i << " "
128  << p[0] << " "
129  << p[1] << " "
130  << p[2] << " - "
131  << q_points[i][0] << " "
132  << q_points[i][1] << " "
133  << q_points[i][2] << " " << Len2(p12) << endl; */
134  }
135 
136  }
137 
138  // release resource access lock
139  unlock();
140 
141  return;
142 }
searchTree.h
Representation of a general search trees.
SearchTree::FindClosest
virtual double * FindClosest(double *_p, double maxdist2, int threadNum=0) const =0
SearchTree::lock
virtual void lock()
Definition: searchTree.h:64
PtPair
Representing point pairs.
Definition: ptpair.h:21
PtPair::p2
Point p2
The two points forming the pair.
Definition: ptpair.h:35
Point::z
double z
z coordinate in 3D space
Definition: point.h:103
SearchTree::getPtPairs
virtual void getPtPairs(vector< PtPair > *pairs, double *source_alignxf, double *const *q_points, unsigned int startindex, unsigned int endindex, int thread_num, int rnd, double max_dist_match2, double &sum, double *centroid_m, double *centroid_d)
Definition: searchTree.cc:20
Point::x
double x
x coordinate in 3D space
Definition: point.h:99
SearchTree::unlock
virtual void unlock()
Definition: searchTree.h:69
Point::y
double y
y coordinate in 3D space
Definition: point.h:101
PtPair::p1
Point p1
The two points forming the pair.
Definition: ptpair.h:34
TripleArray
Definition: data_types.h:135


lvr2
Author(s): Thomas Wiemann , Sebastian Pütz , Alexander Mock , Lars Kiesow , Lukas Kalbertodt , Tristan Igelbrink , Johan M. von Behren , Dominik Feldschnieders , Alexander Löhr
autogenerated on Wed Mar 2 2022 00:37:25