ConePrimitiveShape.cpp
Go to the documentation of this file.
1 #include "ConePrimitiveShape.h"
3 #include "ScoreComputer.h"
4 #include "Bitmap.h"
5 #include <GfxTL/NullClass.h>
6 #include <GfxTL/MathHelper.h>
7 #include <limits>
8 #include <algorithm>
9 #include <iostream>
10 #include <MiscLib/Performance.h>
11 #include "TorusPrimitiveShape.h"
12 #include "CylinderPrimitiveShape.h"
13 #include "SpherePrimitiveShape.h"
14 #include "PlanePrimitiveShape.h"
15 
17 #undef max
18 #undef min
19 
21  : m_cone(cone)
22 {}
23 
25 {
26  return 3;
27 }
28 
30 {
31  return new ConePrimitiveShape(*this);
32 }
33 
34 float ConePrimitiveShape::Distance(const Vec3f& p) const
35 {
36  return m_cone.Distance(p);
37 }
38 
40 {
41  return m_cone.SignedDistance(p);
42 }
43 
44 float ConePrimitiveShape::NormalDeviation(const Vec3f& p, const Vec3f& n) const
45 {
46  Vec3f normal;
47  m_cone.Normal(p, &normal);
48  return n.dot(normal);
49 }
50 
52  const Vec3f& p, const Vec3f& n, std::pair< float, float >* dn) const
53 {
54  Vec3f normal;
55  dn->first = m_cone.DistanceAndNormal(p, &normal);
56  dn->second = n.dot(normal);
57 }
58 
59 void ConePrimitiveShape::Project(const Vec3f& p, Vec3f* pp) const
60 {
61  m_cone.Project(p, pp);
62 }
63 
64 void ConePrimitiveShape::Normal(const Vec3f& p, Vec3f* n) const
65 {
66  m_cone.Normal(p, n);
67 }
68 
69 unsigned int ConePrimitiveShape::ConfidenceTests(unsigned int numTests,
70  float epsilon, float normalThresh, float rms, const PointCloud& pc,
72 {
73  return BasePrimitiveShape::ConfidenceTests< Cone >(numTests, epsilon,
74  normalThresh, rms, pc, indices);
75 }
76 
77 void ConePrimitiveShape::Description(std::string* s) const
78 {
79  *s = "Cone";
80 }
81 
82 bool ConePrimitiveShape::Fit(const PointCloud& pc, float epsilon,
83  float normalThresh, MiscLib::Vector< size_t >::const_iterator begin,
85 {
86  Cone fit = m_cone;
87  if (fit.LeastSquaresFit(pc, begin, end))
88  {
89  m_cone = fit;
90  return true;
91  }
92  return false;
93 
94 }
95 
97  float normalThresh, MiscLib::Vector< size_t >::const_iterator begin,
99  std::pair< size_t, float >* score) const
100 {
101  Cone fit = m_cone;
102  if (fit.LeastSquaresFit(pc, begin, end))
103  {
104  score->first = -1;
105  return new ConePrimitiveShape(fit);
106  }
107  score->first = 0;
108  return NULL;
109 }
110 
112 {
113  return new ConeLevMarFunc(m_cone);
114 }
115 
116 void ConePrimitiveShape::Serialize(std::ostream* o, bool binary) const
117 {
118  if (binary)
119  {
120  const char id = 3;
121  (*o) << id;
122  }
123  else
124  {
125  (*o) << "3" << " ";
126  }
127  m_cone.Serialize(binary, o);
128  if (!binary)
129  {
130  (*o) << std::endl;
131  }
132 }
133 
135 {
136  return m_cone.SerializedSize() + 1;
137 }
138 
140  std::pair< float, float >* param) const
141 {
142  m_cone.Parameters(p, param); // this gives us length and angle
143  // select parametrization with smaller stretch
144  if (m_cone.Angle() < float(M_PI / 4)) // angle of cone less than 45 degrees
145  {
146  // parameterize in the following way:
147  // u = length
148  // v = arc length
149  float r = m_cone.RadiusAtLength(param->first);
150  param->second = (param->second - float(M_PI)) * r; // convert to arc length and centralize
151  }
152  else
153  {
154  float l = param->first;
155  param->first = std::sin(param->second) * l;
156  param->second = std::cos(param->second) * l;
157  }
158 }
159 
164  MiscLib::Vector< std::pair< float, float > >* bmpParams) const
165 {
166  ParametersImpl(begin, end, bmpParams);
167 }
168 
173  MiscLib::Vector< std::pair< float, float > >* bmpParams) const
174 {
175  ParametersImpl(begin, end, bmpParams);
176 }
177 
178 void ConePrimitiveShape::Transform(float scale, const Vec3f& translate)
179 {
180  m_cone.Transform(scale, translate);
181 }
182 
184  const GfxTL::Vector3Df& trans)
185 {
186  m_cone.Transform(rot, trans);
187 }
188 
190 {
191  visitor->Visit(*this);
192 }
193 
196  MiscLib::Vector< size_t >::const_iterator end, float distThresh,
198 {
199  // sample the bounding box in parameter space at 25 locations
200  // these points are used to estimate the other shapes
201  // if the shapes succeed the suggestion is returned
202  MiscLib::Vector< Vec3f > samples(2 * 25);
203  float uStep = (m_extBbox.Max()[0] - m_extBbox.Min()[0]) / 4;
204  float vStep = (m_extBbox.Max()[1] - m_extBbox.Min()[1]) / 4;
205  float u = m_extBbox.Min()[0];
206  for (unsigned int i = 0; i < 5; ++i, u += uStep)
207  {
208  float v = m_extBbox.Min()[1];
209  for (unsigned int j = 0; j < 5; ++j, v += vStep)
210  {
211  float bmpu, bmpv;
212  if (m_cone.Angle() >= M_PI / 4)
213  {
214  bmpu = std::sin(v) * u;
215  bmpv = std::cos(v) * u;
216  }
217  else
218  {
219  bmpu = u;
220  float r = m_cone.RadiusAtLength(u);
221  bmpv = (v - float(M_PI)) * r;
222  }
223  InSpace(bmpu, bmpv, &samples[i * 5 + j],
224  &samples[i * 5 + j + 25]);
225  }
226  }
227  size_t c = samples.size() / 2;
228  // now check all the shape types
229  Cylinder cylinder;
230  if (cylinder.InitAverage(samples))
231  {
232  cylinder.LeastSquaresFit(samples.begin(), samples.begin() + c);
233  bool failed = false;
234  for (size_t i = 0; i < c; ++i)
235  if (cylinder.Distance(samples[i]) > distThresh)
236  {
237  failed = true;
238  break;
239  }
240  if (!failed)
241  {
242  suggestions->push_back(new CylinderPrimitiveShape(cylinder));
243  suggestions->back()->Release();
244  }
245  }
246  Sphere sphere;
247  if (sphere.Init(samples))
248  {
249  sphere.LeastSquaresFit(samples.begin(), samples.begin() + c);
250  bool failed = false;
251  for (size_t i = 0; i < c; ++i)
252  if (sphere.Distance(samples[i]) > distThresh)
253  {
254  failed = true;
255  break;
256  }
257  if (!failed)
258  {
259  suggestions->push_back(new SpherePrimitiveShape(sphere));
260  suggestions->back()->Release();
261  }
262  }
263  Plane plane;
264  if (plane.LeastSquaresFit(samples.begin(), samples.begin() + c))
265  {
266  bool failed = false;
267  for (size_t i = 0; i < c; ++i)
268  if (plane.Distance(samples[i]) > distThresh)
269  {
270  failed = true;
271  break;
272  }
273  if (!failed)
274  {
275  suggestions->push_back(new PlanePrimitiveShape(plane));
276  suggestions->back()->Release();
277  }
278  }
279 
280  /*// simpler shapes are suggested if the maximal curvature of the cone
281  // is small compared to the extend in relation to the distThresh
282 
283  float meanRadius, length, meanLength, radialExtent;
284  // the cone is parameterized as length and angle
285  // in this case the cone is parametrized as length and arclength
286  meanRadius = (m_cone.RadiusAtLength(m_extBbox.Min()[0])
287  + m_cone.RadiusAtLength(m_extBbox.Max()[0])) / 2;
288  length = m_extBbox.Max()[0] - m_extBbox.Min()[0];
289  meanLength = (m_extBbox.Max()[0] + m_extBbox.Min()[0]) / 2;
290  // the radial extent
291  radialExtent = m_extBbox.Max()[1] - m_extBbox.Min()[1];
292  // We suggest a cylinder if the opening angle of the cone is so small
293  // that over the whole height the difference is less than distThresh
294  if(std::sin(m_cone.Angle()) * length / 2 < distThresh)
295  {
296  // construct the cylinder
297  // it has the same axis as the cone
298  // and we use the average radius of the cone
299  Cylinder cylinder(m_cone.AxisDirection(), m_cone.Center(),
300  meanRadius);
301  suggestions->push_back(new CylinderPrimitiveShape(cylinder));
302  suggestions->back()->Release();
303  }
304 
305  // We suggest a sphere if a curvature of mean radius along the height
306  // does not introduce too large an error
307  float sphereRadius = std::tan(m_cone.Angle()) * meanLength;
308  float radiusDiff = (std::sqrt(sphereRadius * sphereRadius + length * length / 4)
309  - sphereRadius) / 2;
310  if(radiusDiff < distThresh)
311  {
312  // the center of the sphere is given as the point on the axis
313  // with the height of the mean length
314  Vec3f center = (meanLength / std::cos(m_cone.Angle()))
315  * m_cone.AxisDirection() + m_cone.Center();
316  Sphere sphere(center, sphereRadius + radiusDiff);
317  suggestions->push_back(new SpherePrimitiveShape(sphere));
318  suggestions->back()->Release();
319  }
320 
321  // We suggest a plane if the mean radius causes only a small error
322  // for this we need the angular extent in the curved direction of the cone
323  radiusDiff = meanRadius - std::sin(radialExtent) * meanRadius;
324  if(radiusDiff < distThresh)
325  {
326  GfxTL::Vector2Df bboxCenter;
327  m_extBbox.Center(&bboxCenter);
328  Vec3f pos, normal;
329  InSpace(bboxCenter[0], bboxCenter[1] * m_cone.RadiusAtLength(bboxCenter[0]),
330  &pos, &normal);
331  Plane plane(pos, normal);
332  suggestions->push_back(new PlanePrimitiveShape(plane));
333  suggestions->back()->Release();
334  }*/
335 }
336 
337 bool ConePrimitiveShape::Similar(float tolerance,
338  const ConePrimitiveShape& shape) const
339 {
340  return m_cone.Angle() <= (1.f + tolerance) * shape.m_cone.Angle()
341  && (1.f + tolerance) * m_cone.Angle() >= shape.m_cone.Angle();
342 }
343 
346  MiscLib::Vector< std::pair< float, float > >* params,
347  size_t* uextent, size_t* vextent)
348 {
349  *uextent = std::ceil((bbox->Max()[0] - bbox->Min()[0]) / epsilon); // no wrappig along u direction
350  *vextent = std::ceil((bbox->Max()[1] - bbox->Min()[1]) / epsilon) + 1; // add one for wrapping
351  if ((*vextent) * (*uextent) > 1e6 && m_cone.Angle() < float(M_PI / 4))
352  {
353  // try to reparameterize
354  // try to find cut in the outer regions
355  MiscLib::Vector< float > angularParams;//(params->size());
356  angularParams.reserve(params->size());
357  float outer = 3.f * std::max(abs(bbox->Min()[0]), abs(bbox->Max()[0])) / 4.f;
358  for (size_t i = 0; i < params->size(); ++i)
359  if ((*params)[i].first > outer)
360  angularParams.push_back(((*params)[i].second
361  / m_cone.RadiusAtLength((*params)[i].first)) + float(M_PI));
362  std::sort(angularParams.begin(), angularParams.end());
363  // try to find a large gap
364  float maxGap = 0;
365  float lower, upper;
366  for (size_t i = 1; i < angularParams.size(); ++i)
367  {
368  float gap = angularParams[i] - angularParams[i - 1];
369  if (gap > maxGap)
370  {
371  maxGap = gap;
372  lower = angularParams[i - 1];
373  upper = angularParams[i];
374  }
375  }
376  // reparameterize with new angular cut
377  float newCut = (lower + upper) / 2.f;
378  m_cone.RotateAngularDirection(newCut);
379  bbox->Min()[1] = std::numeric_limits< float >::infinity();
380  bbox->Max()[1] = -std::numeric_limits< float >::infinity();
381  for (size_t i = 0; i < params->size(); ++i)
382  {
383  float r = m_cone.RadiusAtLength((*params)[i].first);
384  (*params)[i].second = ((*params)[i].second / r) + float(M_PI) - newCut;
385  if ((*params)[i].second < 0)
386  {
387  (*params)[i].second = 2 * float(M_PI) + (*params)[i].second;
388  }
389  (*params)[i].second = ((*params)[i].second - float(M_PI)) * r;
390  if ((*params)[i].second < bbox->Min()[1])
391  {
392  bbox->Min()[1] = (*params)[i].second;
393  }
394  if ((*params)[i].second > bbox->Max()[1])
395  {
396  bbox->Max()[1] = (*params)[i].second;
397  }
398  }
399  *vextent = std::floor((bbox->Max()[1] - bbox->Min()[1]) / epsilon) + 1;
400  }
401 }
402 
403 void ConePrimitiveShape::InBitmap(const std::pair< float, float >& param,
404  float epsilon, const GfxTL::AABox< GfxTL::Vector2Df >& bbox,
405  size_t uextent, size_t vextent, std::pair< int, int >* inBmp) const
406 {
407  // convert u = length and v = arc length into bitmap coordinates
408  inBmp->first = std::floor((param.first - bbox.Min()[0]) / epsilon);
409  inBmp->second = std::floor((param.second - bbox.Min()[1]) / epsilon);
410 }
411 
413  const GfxTL::AABox< GfxTL::Vector2Df >& bbox, float epsilon,
414  size_t uextent, size_t vextent, MiscLib::Vector< char >* bmp) const
415 {
416  if (m_cone.Angle() >= float(M_PI / 4))
417  {
418  return;
419  }
420  // for wrapping we copy the first pixel to the last one in each v column
421  for (size_t u = 0; u < uextent; ++u)
422  {
423  // determine the coordinates of the last pixel in the column
424  // get the radius of the column
425  float r = m_cone.RadiusAtLength(u * epsilon + bbox.Min()[0]);
426  size_t v = std::floor((2 * float(M_PI) * r - bbox.Min()[1]) / epsilon) + 1;
427  if (v >= vextent)
428  {
429  continue;
430  }
431  if ((*bmp)[u])
432  {
433  (*bmp)[v * uextent + u] = (*bmp)[u]; // do the wrap
434  }
435  // if(!(*bmp)[u * vextent + v])
436  // (*bmp)[u * vextent + v] = (*bmp)[u * vextent]; // do the wrap
437  }
438 }
439 
441  const GfxTL::AABox< GfxTL::Vector2Df >& bbox, float epsilon, bool* uwrap,
442  bool* vwrap) const
443 {
444  *uwrap = *vwrap = false;
445 }
446 
449  float epsilon, size_t uextent, size_t vextent,
450  MiscLib::Vector< int >* componentImg,
451  MiscLib::Vector< std::pair< int, size_t > >* labels) const
452 {
453  if (m_cone.Angle() >= float(M_PI / 4))
454  {
455  return;
456  }
457  // for wrapping we copy the first pixel to the last one in each v column
458  for (size_t u = 0; u < uextent; ++u)
459  {
460  // determine the coordinates of the last pixel in the column
461  // get the radius of the column
462  float r = m_cone.RadiusAtLength(u * epsilon + bbox.Min()[0]);
463  size_t v = std::floor((2 * float(M_PI) * r - bbox.Min()[1]) / epsilon) + 1;
464  if (v >= vextent)
465  {
466  continue;
467  }
468  if ((*componentImg)[u])
469  {
470  (*componentImg)[v * uextent + u] = (*componentImg)[u]; // do the wrap
471  }
472  }
473  // relabel the components
474  MiscLib::Vector< std::pair< int, size_t > > tempLabels(*labels);
475  int curLabel = tempLabels.size() - 1;
476  for (size_t u = 0; u < uextent; ++u)
477  {
478  float r = m_cone.RadiusAtLength(u * epsilon + bbox.Min()[0]);
479  size_t v = std::floor((2 * float(M_PI) * r - bbox.Min()[1]) / epsilon) + 1;
480  if (v >= vextent)
481  {
482  continue;
483  }
484  if (!(*componentImg)[v * uextent + u])
485  {
486  continue;
487  }
488  // get the neighbors
489  int n[8];
490  size_t i = 0;
491  if (v >= 1)
492  {
493  size_t prevRow = (v - 1) * uextent;
494  if (u >= 1)
495  {
496  n[i++] = (*componentImg)[prevRow + u - 1];
497  }
498  n[i++] = (*componentImg)[prevRow + u];
499  if (u < uextent - 1)
500  {
501  n[i++] = (*componentImg)[prevRow + u + 1];
502  }
503  }
504  size_t row = v * uextent;
505  if (u >= 1)
506  {
507  n[i++] = (*componentImg)[row + u - 1];
508  }
509  if (u < uextent - 1)
510  {
511  n[i++] = (*componentImg)[row + u + 1];
512  }
513  if (v < vextent - 1)
514  {
515  size_t nextRow = (v + 1) * uextent;
516  if (u >= 1)
517  {
518  n[i++] = (*componentImg)[nextRow + u - 1];
519  }
520  n[i++] = (*componentImg)[nextRow + u];
521  if (u < uextent - 1)
522  {
523  n[i++] = (*componentImg)[nextRow + u + 1];
524  }
525  }
526  // associate labels
527  int l = (*componentImg)[v * uextent + u];
528  for (size_t j = 0; j < i; ++j)
529  if (n[j])
530  {
531  AssociateLabel(l, n[j], &tempLabels);
532  }
533  }
534  // condense labels
535  for (size_t i = tempLabels.size() - 1; i > 0; --i)
536  {
537  tempLabels[i].first = ReduceLabel(i, tempLabels);
538  }
539  MiscLib::Vector< int > condensed(tempLabels.size());
540  labels->clear();
541  labels->reserve(condensed.size());
542  int count = 0;
543  for (size_t i = 0; i < tempLabels.size(); ++i)
544  if (i == tempLabels[i].first)
545  {
546  labels->push_back(std::make_pair(count, tempLabels[i].second));
547  condensed[i] = count;
548  ++count;
549  }
550  else
551  (*labels)[condensed[tempLabels[i].first]].second
552  += tempLabels[i].second;
553  // set new component ids
554  for (size_t i = 0; i < componentImg->size(); ++i)
555  (*componentImg)[i] =
556  condensed[tempLabels[(*componentImg)[i]].first];
557 }
558 
560  const MiscLib::Vector< int >& componentsImg, size_t uextent,
561  size_t vextent, float epsilon, int label)
562 {}
563 
564 bool ConePrimitiveShape::InSpace(float length, float arcLength, Vec3f* p,
565  Vec3f* n) const
566 {
567  float angle;
568  if (m_cone.Angle() >= float(M_PI / 4))
569  {
570  //angle = std::atan2(arcLength, length);
571  angle = std::atan2(length, arcLength);
572  length = std::sqrt(length * length + arcLength * arcLength);
573  // angle = std::acos(GfxTL::Math< float >::Clamp(arcLength / length, -1.f, 1.f));
574  }
575  else
576  {
577  angle = (arcLength / m_cone.RadiusAtLength(length)) + float(M_PI);
578  }
580  q.RotationRad(angle, m_cone.AxisDirection()[0],
581  m_cone.AxisDirection()[1], m_cone.AxisDirection()[2]);
582  Vec3f vvec;
583  q.Rotate(m_cone.AngularDirection(), &vvec);
584  *p = std::sin(m_cone.Angle()) * abs(length) * vvec +
585  std::cos(m_cone.Angle()) * length * m_cone.AxisDirection() +
586  m_cone.Center();
587  m_cone.Normal(*p, n);
588  return true;
589 }
590 
591 bool ConePrimitiveShape::InSpace(size_t u, size_t v, float epsilon,
592  const GfxTL::AABox< GfxTL::Vector2Df >& bbox, size_t uextent,
593  size_t vextent, Vec3f* p, Vec3f* n) const
594 {
595  float length, angle;
596  if (m_cone.Angle() >= float(M_PI / 4))
597  {
598  float uf = ((float(u) + .5f) * epsilon) + bbox.Min()[0];
599  float vf = ((float(v) + .5f) * epsilon) + bbox.Min()[1];
600  length = std::sqrt(uf * uf + vf * vf);
601  //angle = std::atan2(vf, uf);
602  angle = std::atan2(uf, vf);
603  //angle = std::acos(GfxTL::Math< float >::Clamp(vf / length, -1.f, 1.f));
604  }
605  else
606  {
607  length = ((float(u) + .5f) * epsilon) + bbox.Min()[0];
608  float arcLength = ((float(v) + .5f) * epsilon) + bbox.Min()[1];
609  angle = (arcLength / m_cone.RadiusAtLength(length)) + float(M_PI);
610  }
611  if (angle > 2 * float(M_PI))
612  {
613  return false;
614  }
615  //float angle = ((v * epsilon) / m_cone.RadiusAtLength(std::max(abs(bbox.Min()[0]), abs(bbox.Max()[0])))
616  // + bbox.Min()[1]);
618  q.RotationRad(angle, m_cone.AxisDirection()[0],
619  m_cone.AxisDirection()[1], m_cone.AxisDirection()[2]);
620  Vec3f vvec;
621  q.Rotate(m_cone.AngularDirection(), &vvec);
622  *p = std::sin(m_cone.Angle()) * abs(length) * vvec +
623  std::cos(m_cone.Angle()) * length * m_cone.AxisDirection() +
624  m_cone.Center();
625  // TODO: this is very lazy and should be optimized!
626  m_cone.Normal(*p, n);
627  return true;
628 }
GfxTL::IndexedIterator
Definition: IndexedIterator.h:8
PrimitiveShapeVisitor::Visit
virtual void Visit(const PlanePrimitiveShape &plane)=0
GfxTL::sqrt
VectorXD< D, T > sqrt(const VectorXD< D, T > &a)
Definition: VectorXD.h:662
ConePrimitiveShape::ConePrimitiveShape
ConePrimitiveShape(const Cone &cone)
Definition: ConePrimitiveShape.cpp:20
LevMarFunc< float >
GfxTL::VectorXD
Definition: MatrixXX.h:21
ConePrimitiveShape::LSFit
PrimitiveShape * LSFit(const PointCloud &pc, float epsilon, float normalThresh, MiscLib::Vector< size_t >::const_iterator begin, MiscLib::Vector< size_t >::const_iterator end, std::pair< size_t, float > *score) const
Definition: ConePrimitiveShape.cpp:96
GfxTL::AABox::Max
Point & Max()
Definition: AABox.hpp:74
SpherePrimitiveShape.h
MiscLib::Vector::begin
T * begin()
Definition: Vector.h:460
ConePrimitiveShape::WrapComponents
void WrapComponents(const GfxTL::AABox< GfxTL::Vector2Df > &bbox, float epsilon, size_t uextent, size_t vextent, MiscLib::Vector< int > *componentImg, MiscLib::Vector< std::pair< int, size_t > > *labels) const
Definition: ConePrimitiveShape.cpp:447
ReduceLabel
int ReduceLabel(int a, const MiscLib::Vector< std::pair< int, size_t > > &labels)
Definition: Bitmap.cpp:921
PlanePrimitiveShape.h
Vec3f
Definition: basic.h:16
MiscLib::Vector::push_back
void push_back(const T &v)
Definition: Vector.h:346
Performance.h
TorusPrimitiveShape.h
Sphere::Distance
float Distance(const Vec3f &p) const
Definition: Sphere.h:219
ConePrimitiveShape::SuggestSimplifications
void SuggestSimplifications(const PointCloud &pc, MiscLib::Vector< size_t >::const_iterator begin, MiscLib::Vector< size_t >::const_iterator end, float distThresh, MiscLib::Vector< MiscLib::RefCountPtr< PrimitiveShape > > *suggestions) const
Definition: ConePrimitiveShape.cpp:194
ConePrimitiveShape::Parameters
void Parameters(const Vec3f &p, std::pair< float, float > *param) const
Definition: ConePrimitiveShape.cpp:139
Cone::Distance
float Distance(const Vec3f &p) const
Definition: Cone.h:219
ConePrimitiveShape
Definition: ConePrimitiveShape.h:11
Plane::LeastSquaresFit
bool LeastSquaresFit(const PointCloud &pc, MiscLib::Vector< size_t >::const_iterator begin, MiscLib::Vector< size_t >::const_iterator end)
Definition: Plane.cpp:179
Cone::Project
void Project(const Vec3f &p, Vec3f *pp) const
Definition: Cone.cpp:431
Cone::RotateAngularDirection
void RotateAngularDirection(float radians)
Definition: Cone.cpp:551
Bitmap.h
Cone::Normal
void Normal(const Vec3f &p, Vec3f *n) const
Definition: Cone.h:245
ConePrimitiveShape::NormalDeviation
float NormalDeviation(const Vec3f &p, const Vec3f &n) const
Definition: ConePrimitiveShape.cpp:44
ConePrimitiveShape::WrapBitmap
void WrapBitmap(const GfxTL::AABox< GfxTL::Vector2Df > &bbox, float epsilon, bool *uwrap, bool *vwrap) const
Definition: ConePrimitiveShape.cpp:440
c
constexpr T c
Definition: UnscentedKalmanFilterTest.cpp:43
PrimitiveShape
PrimtiveShape is a shape primitive in conjunction with a parametrization.
Definition: PrimitiveShape.h:32
ConePrimitiveShape::Identifier
size_t Identifier() const
Definition: ConePrimitiveShape.cpp:24
ConePrimitiveShape::Visit
void Visit(PrimitiveShapeVisitor *visitor) const
Definition: ConePrimitiveShape.cpp:189
GfxTL::Quaternion
Definition: VectorXD.h:707
Cone::DistanceAndNormal
float DistanceAndNormal(const Vec3f &p, Vec3f *n) const
Definition: Cone.h:255
totalTime_coneConnected
MiscLib::performance_t totalTime_coneConnected
GfxTL::MatrixXX
Definition: MatrixXX.h:25
ConePrimitiveShape::Serialize
void Serialize(std::ostream *o, bool binary=true) const
This is the one and only serialization function It stores all the parameters of the shape as well as ...
Definition: ConePrimitiveShape.cpp:116
MiscLib::Vector< size_t >
ConePrimitiveShape::SignedDistance
float SignedDistance(const Vec3f &p) const
Definition: ConePrimitiveShape.cpp:39
PrimitiveShapeVisitor.h
Cylinder::Distance
float Distance(const Vec3f &p) const
Definition: Cylinder.h:180
MiscLib::Vector< Point >::const_iterator
const typedef Point * const_iterator
Definition: Vector.h:26
ConePrimitiveShape::DistanceAndNormalDeviation
void DistanceAndNormalDeviation(const Vec3f &p, const Vec3f &n, std::pair< float, float > *dn) const
Definition: ConePrimitiveShape.cpp:51
ConePrimitiveShape::ConfidenceTests
unsigned int ConfidenceTests(unsigned int numTests, float epsilon, float normalThresh, float rms, const PointCloud &pc, const MiscLib::Vector< size_t > &indices) const
Definition: ConePrimitiveShape.cpp:69
CylinderPrimitiveShape
class DLL_LINKAGE CylinderPrimitiveShape
Definition: PrimitiveShapeVisitor.h:10
MiscLib::Vector::size
size_type size() const
Definition: Vector.h:212
armarx::abs
std::vector< T > abs(const std::vector< T > &v)
Definition: VectorHelpers.h:253
ConePrimitiveShape::PreWrapBitmap
void PreWrapBitmap(const GfxTL::AABox< GfxTL::Vector2Df > &bbox, float epsilon, size_t uextent, size_t vextent, MiscLib::Vector< char > *bmp) const
Definition: ConePrimitiveShape.cpp:412
M_PI
#define M_PI
Definition: MathTools.h:17
pcl::graph::indices
pcl::PointIndices::Ptr indices(const PCG &g)
Retrieve the indices of the points of the point cloud stored in a point cloud graph that actually bel...
Definition: point_cloud_graph.h:737
Plane::Distance
float Distance(const Vec3f &pos) const
Definition: Plane.h:34
Cylinder::LeastSquaresFit
bool LeastSquaresFit(const PointCloud &pc, MiscLib::Vector< size_t >::const_iterator begin, MiscLib::Vector< size_t >::const_iterator end)
Definition: Cylinder.cpp:422
Cone
Definition: Cone.h:22
PrimitiveShapeVisitor
Definition: PrimitiveShapeVisitor.h:14
Cone::SignedDistance
float SignedDistance(const Vec3f &p) const
Definition: Cone.h:290
MiscLib::performance_t
clock_t performance_t
Definition: Performance.h:27
Cylinder::InitAverage
bool InitAverage(const MiscLib::Vector< Vec3f > &samples)
Definition: Cylinder.cpp:93
CylinderPrimitiveShape.h
SpherePrimitiveShape
class DLL_LINKAGE SpherePrimitiveShape
Definition: PrimitiveShapeVisitor.h:9
ConePrimitiveShape::Fit
bool Fit(const PointCloud &pc, float epsilon, float normalThresh, MiscLib::Vector< size_t >::const_iterator begin, MiscLib::Vector< size_t >::const_iterator end)
Definition: ConePrimitiveShape.cpp:82
ConePrimitiveShape::InSpace
bool InSpace(float u, float v, Vec3f *p, Vec3f *n) const
Definition: ConePrimitiveShape.cpp:564
Cone::Parameters
void Parameters(const Vec3f &p, std::pair< float, float > *param) const
Definition: Cone.cpp:463
Cone::Angle
float Angle() const
Definition: Cone.h:351
ConePrimitiveShape::Transform
void Transform(float scale, const Vec3f &translate)
Definition: ConePrimitiveShape.cpp:178
MiscLib::Vector::end
T * end()
Definition: Vector.h:470
Cone::Serialize
void Serialize(bool binary, std::ostream *o) const
Definition: Cone.cpp:692
max
T max(T t1, T t2)
Definition: gdiam.h:48
ConeLevMarFunc
Definition: ConePrimitiveShape.h:142
BitmapPrimitiveShape::m_extBbox
GfxTL::AABox< GfxTL::Vector2Df > m_extBbox
Definition: BitmapPrimitiveShape.h:98
ConePrimitiveShape::Similar
bool Similar(float tolerance, const ConePrimitiveShape &shape) const
Definition: ConePrimitiveShape.cpp:337
Cone::Center
const Vec3f & Center() const
Definition: Cone.h:356
Cone::Transform
void Transform(float scale, const Vec3f &translate)
Definition: Cone.cpp:743
Cone::RadiusAtLength
float RadiusAtLength(float length) const
Definition: Cone.h:371
MiscLib::RefCountPtr< PrimitiveShape >
q
#define q
Sphere::Init
bool Init(const MiscLib::Vector< Vec3f > &samples)
Definition: Sphere.cpp:172
ConePrimitiveShape::Project
void Project(const Vec3f &p, Vec3f *pp) const
Definition: ConePrimitiveShape.cpp:59
ConePrimitiveShape::SignedDistanceFunc
LevMarFunc< float > * SignedDistanceFunc() const
Definition: ConePrimitiveShape.cpp:111
PointCloud
Definition: PointCloud.h:69
ConePrimitiveShape::InBitmap
void InBitmap(const std::pair< float, float > &param, float epsilon, const GfxTL::AABox< GfxTL::Vector2Df > &bbox, size_t uextent, size_t vextent, std::pair< int, int > *inBmp) const
Definition: ConePrimitiveShape.cpp:403
Cone::SerializedSize
static size_t SerializedSize()
Definition: Cone.cpp:710
ConePrimitiveShape::SetExtent
void SetExtent(const GfxTL::AABox< GfxTL::Vector2Df > &bbox, const MiscLib::Vector< int > &componentsImg, size_t uextent, size_t vextent, float epsilon, int label)
Definition: ConePrimitiveShape.cpp:559
MiscLib::Vector::reserve
void reserve(size_type s)
Definition: Vector.h:187
armarx::ctrlutil::v
double v(double t, double v0, double a0, double j)
Definition: CtrlUtil.h:39
Vec3f::dot
float dot(const Vec3f &v) const
Definition: basic.h:92
float
#define float
Definition: 16_Level.h:22
GfxTL::AABox::Min
Point & Min()
Definition: AABox.hpp:62
ConePrimitiveShape::SerializedSize
size_t SerializedSize() const
Definition: ConePrimitiveShape.cpp:134
NullClass.h
ConePrimitiveShape::Description
void Description(std::string *s) const
Definition: ConePrimitiveShape.cpp:77
Plane
Definition: Plane.h:16
ConePrimitiveShape::Normal
void Normal(const Vec3f &p, Vec3f *n) const
Definition: ConePrimitiveShape.cpp:64
angle
double angle(const Point &a, const Point &b, const Point &c)
Definition: point.hpp:100
ScoreComputer.h
Sphere
Definition: Sphere.h:27
Sphere::LeastSquaresFit
bool LeastSquaresFit(const PointCloud &pc, MiscLib::Vector< size_t >::const_iterator begin, MiscLib::Vector< size_t >::const_iterator end)
Definition: Sphere.cpp:389
pc
Introduction Thank you for taking interest in our work and downloading this software This library implements the algorithm described in the paper R R R Klein Efficient RANSAC for Point Cloud Shape in Computer Graphics Blackwell June If you use this software you should cite the aforementioned paper in any resulting publication Please send comments or bug reports to Ruwen Roland BUT NOT LIMITED THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY OR CONSEQUENTIAL WHETHER IN STRICT OR EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE Example usage This section shows how to use the library to detect the shapes in a point cloud PointCloud pc
Definition: ReadMe.txt:68
Cylinder
Definition: Cylinder.h:20
AssociateLabel
void AssociateLabel(int a, int b, MiscLib::Vector< std::pair< int, size_t > > *labels)
Definition: Bitmap.cpp:895
ConePrimitiveShape.h
MathHelper.h
ConePrimitiveShape::Clone
PrimitiveShape * Clone() const
Definition: ConePrimitiveShape.cpp:29
Cone::AngularDirection
const Vec3f AngularDirection() const
Definition: Cone.h:366
armarx::ctrlutil::s
double s(double t, double s0, double v0, double a0, double j)
Definition: CtrlUtil.h:33
IndexIterator
Definition: IndexIterator.h:9
ConePrimitiveShape::Distance
float Distance(const Vec3f &p) const
Definition: ConePrimitiveShape.cpp:34
GfxTL::AABox
Definition: AABox.h:18
PlanePrimitiveShape
class DLL_LINKAGE PlanePrimitiveShape
Definition: PrimitiveShapeVisitor.h:8
Cone::AxisDirection
const Vec3f & AxisDirection() const
Definition: Cone.h:361
ConePrimitiveShape::BitmapExtent
void BitmapExtent(float epsilon, GfxTL::AABox< GfxTL::Vector2Df > *bbox, MiscLib::Vector< std::pair< float, float > > *params, size_t *uextent, size_t *vextent)
Definition: ConePrimitiveShape.cpp:344
Cone::LeastSquaresFit
bool LeastSquaresFit(const PointCloud &pc, MiscLib::Vector< size_t >::const_iterator begin, MiscLib::Vector< size_t >::const_iterator end)
Definition: Cone.cpp:667