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