TorusPrimitiveShape.h
Go to the documentation of this file.
1 #ifndef TORUSPRIMITIVESHAPE_HEADER
2 #define TORUSPRIMITIVESHAPE_HEADER
3 #include "BitmapPrimitiveShape.h"
4 #include "Torus.h"
7 
8 #ifndef DLL_LINKAGE
9 #define DLL_LINKAGE
10 #endif
11 
13  : public BitmapPrimitiveShape
14 {
15 public:
17  TorusPrimitiveShape() : m_parametrization(m_torus) {}
18  TorusPrimitiveShape(const Torus& torus);
20  size_t Identifier() const;
21  unsigned int RequiredSamples() const
22  {
24  }
25  PrimitiveShape* Clone() const;
26  float Distance(const Vec3f& p) const;
27  float SignedDistance(const Vec3f& p) const;
28  float NormalDeviation(const Vec3f& p, const Vec3f& n) const;
29  void DistanceAndNormalDeviation(const Vec3f& p,
30  const Vec3f& n, std::pair< float, float >* dn) const;
31  void Project(const Vec3f& p, Vec3f* pp) const;
32  void Normal(const Vec3f& p, Vec3f* n) const;
33  unsigned int ConfidenceTests(unsigned int numTests, float epsilon,
34  float normalThresh, float rms, const PointCloud& pc,
35  const MiscLib::Vector< size_t >& indices) const;
36  void Description(std::string* s) const;
37  // refitting
38  bool Fit(const PointCloud& pc, float epsilon,
39  float normalThresh,
42  PrimitiveShape* LSFit(const PointCloud& pc, float epsilon,
43  float normalThresh, MiscLib::Vector< size_t >::const_iterator begin,
45  std::pair< size_t, float >* score) const;
47  void Serialize(std::ostream* o, bool binary = true) const;
48  void Deserialize(std::istream* i, bool binary);
49  size_t SerializedSize() const;
50  virtual void Serialize(float* array) const
51  {
52  m_torus.Serialize(array);
53  }
54  virtual size_t SerializedFloatSize() const
55  {
56  return m_torus.SerializedFloatSize();
57  }
58  void Transform(float scale, const Vec3f& translate);
59  void Visit(PrimitiveShapeVisitor* visitor) const;
62  MiscLib::Vector< size_t >::const_iterator end, float distThresh,
65  size_t begin, size_t end, float epsilon);
66  bool Similar(float tolerance, const TorusPrimitiveShape& shape) const;
67 
68  // implementation of BitmapPrimitiveShape
69  void Parameters(const Vec3f& p,
70  std::pair< float, float >* param) const;
75  MiscLib::Vector< std::pair< float, float > >* bmpParams) const;
80  MiscLib::Vector< std::pair< float, float > >* bmpParams) const;
81  bool InSpace(float u, float v, Vec3f* p, Vec3f* n) const;
82  void BitmapExtent(float epsilon,
84  MiscLib::Vector< std::pair< float, float > >* params,
85  size_t* uextent, size_t* vextent);
86  void InBitmap(const std::pair< float, float >& param,
87  float epsilon, const GfxTL::AABox< GfxTL::Vector2Df >& bbox,
88  size_t uextent, size_t vextent,
89  std::pair< int, int >* inBmp) const;
91  float epsilon, bool* uwrap, bool* vwrap) const;
93  float epsilon, size_t uextent, size_t vextent,
94  MiscLib::Vector< int >* componentImg,
95  MiscLib::Vector< std::pair< int, size_t > >* labels) const;
96  void SetExtent(const GfxTL::AABox< GfxTL::Vector2Df >& bbox,
97  const MiscLib::Vector< int >& componentsImg, size_t uextent,
98  size_t vextent, float epsilon, int label);
99  bool InSpace(size_t u, size_t v, float epsilon,
100  const GfxTL::AABox< GfxTL::Vector2Df >& bbox, size_t uextent,
101  size_t vextent, Vec3f* p, Vec3f* n) const;
102  const Torus& Internal() const
103  {
104  return m_torus;
105  }
106 
107 private:
108  template< class IteratorT >
109  void ParametersImpl(IteratorT begin, IteratorT end,
110  MiscLib::Vector< std::pair< float, float > >* bmpParams) const;
111 
112 private:
113  Torus m_torus;
114  ParametrizationType m_parametrization;
115 };
116 
117 template< class IteratorT >
118 void TorusPrimitiveShape::ParametersImpl(IteratorT begin, IteratorT end,
119  MiscLib::Vector< std::pair< float, float > >* bmpParams) const
120 {
121  bmpParams->resize(end - begin);
122  size_t j = 0;
123  for (IteratorT i = begin; i != end; ++i, ++j)
124  {
125  m_parametrization.Parameters(*i, &(*bmpParams)[j]);
126  }
127 }
128 
130  : public LevMarFunc< float >
131 {
132 public:
134  : m_torus(t)
135  {}
136 
137  float operator()(const float* x) const
138  {
139  return m_torus.SignedDistance(*((const Vec3f*)x));
140  }
141 
142  void operator()(const float* x, float* gradient) const
143  {
144  m_torus.Normal(*((const Vec3f*)x), (Vec3f*)gradient);
145  }
146 
147 private:
148  Torus m_torus;
149 };
150 
151 #endif
GfxTL::IndexedIterator
Definition: IndexedIterator.h:8
TorusPrimitiveShape::Internal
const Torus & Internal() const
Definition: TorusPrimitiveShape.h:102
TorusPrimitiveShape::SerializedFloatSize
virtual size_t SerializedFloatSize() const
Definition: TorusPrimitiveShape.h:54
LevMarFunc< float >
PrimitiveShape::Identifier
virtual size_t Identifier() const =0
PrimitiveShape::Project
virtual void Project(const Vec3f &p, Vec3f *pp) const =0
PrimitiveShape::Fit
virtual bool Fit(const PointCloud &pc, float epsilon, float normalThresh, MiscLib::Vector< size_t >::const_iterator begin, MiscLib::Vector< size_t >::const_iterator end)=0
Vec3f
Definition: basic.h:16
Torus.h
PrimitiveShape::SignedDistance
virtual float SignedDistance(const Vec3f &p) const =0
Torus
Definition: Torus.h:18
BitmapPrimitiveShape
Definition: BitmapPrimitiveShape.h:30
TorusPrimitiveShape
Definition: TorusPrimitiveShape.h:12
Torus::RequiredSamples
@ RequiredSamples
Definition: Torus.h:21
BitmapPrimitiveShape::InSpace
virtual bool InSpace(float u, float v, Vec3f *p, Vec3f *n) const =0
PrimitiveShape
PrimtiveShape is a shape primitive in conjunction with a parametrization.
Definition: PrimitiveShape.h:32
PrimitiveShape::Normal
virtual void Normal(const Vec3f &p, Vec3f *n) const =0
LowStretchTorusParametrization::Parameters
void Parameters(const Vec3f &p, std::pair< float, float > *param) const
Definition: LowStretchTorusParametrization.h:52
LowStretchTorusParametrization
Definition: LowStretchTorusParametrization.h:13
PrimitiveShape::NormalDeviation
virtual float NormalDeviation(const Vec3f &p, const Vec3f &n) const =0
PrimitiveShape::LSFit
virtual 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 =0
TorusLevMarFunc::operator()
float operator()(const float *x) const
Definition: TorusPrimitiveShape.h:137
PrimitiveShape::Distance
virtual float Distance(const Vec3f &p) const =0
MiscLib::Vector< size_t >
PrimitiveShape::SerializedSize
virtual size_t SerializedSize() const =0
TorusPrimitiveShape::RequiredSamples
unsigned int RequiredSamples() const
Definition: TorusPrimitiveShape.h:21
MiscLib::Vector< Point >::const_iterator
const typedef Point * const_iterator
Definition: Vector.h:26
PrimitiveShape::Description
virtual void Description(std::string *s) const =0
PrimitiveShape::SuggestSimplifications
virtual 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: PrimitiveShape.h:93
PrimitiveShape::DistanceAndNormalDeviation
virtual void DistanceAndNormalDeviation(const Vec3f &p, const Vec3f &n, std::pair< float, float > *dn) const =0
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
PrimitiveShapeVisitor
Definition: PrimitiveShapeVisitor.h:14
PrimitiveShape::OptimizeParametrization
virtual void OptimizeParametrization(const PointCloud &pc, size_t begin, size_t end, float epsilon)
Definition: PrimitiveShape.h:97
SimpleTorusParametrization.h
TorusLevMarFunc
Definition: TorusPrimitiveShape.h:129
BitmapPrimitiveShape.h
BasePrimitiveShape::ConfidenceTests
unsigned int ConfidenceTests(unsigned int numTests, float epsilon, float normalThresh, float rms, const PointCloud &pc, const MiscLib::Vector< size_t > &indices) const
Definition: BasePrimitiveShape.h:17
MiscLib::RefCountPtr< PrimitiveShape >
PointCloud
Definition: PointCloud.h:69
TorusLevMarFunc::operator()
void operator()(const float *x, float *gradient) const
Definition: TorusPrimitiveShape.h:142
armarx::ctrlutil::v
double v(double t, double v0, double a0, double j)
Definition: CtrlUtil.h:39
TorusLevMarFunc::TorusLevMarFunc
TorusLevMarFunc(const Torus &t)
Definition: TorusPrimitiveShape.h:133
BitmapPrimitiveShape::Parameters
virtual void Parameters(const Vec3f &p, std::pair< float, float > *param) const =0
TorusPrimitiveShape::Serialize
virtual void Serialize(float *array) const
Definition: TorusPrimitiveShape.h:50
TorusPrimitiveShape
class DLL_LINKAGE TorusPrimitiveShape
Definition: PrimitiveShapeVisitor.h:12
BitmapPrimitiveShape::BitmapExtent
virtual void BitmapExtent(float epsilon, GfxTL::AABox< GfxTL::Vector2Df > *bbox, MiscLib::Vector< std::pair< float, float > > *params, size_t *uextent, size_t *vextent)=0
DLL_LINKAGE
#define DLL_LINKAGE
Definition: basic.h:11
BitmapPrimitiveShape::InBitmap
virtual 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 =0
PrimitiveShape::Transform
virtual void Transform(float scale, const Vec3f &translate)=0
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
TorusPrimitiveShape::ParametrizationType
LowStretchTorusParametrization ParametrizationType
Definition: TorusPrimitiveShape.h:16
BitmapPrimitiveShape::WrapComponents
virtual 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: BitmapPrimitiveShape.cpp:19
PrimitiveShape::Serialize
virtual void Serialize(std::ostream *o, bool binary=true) const =0
This is the one and only serialization function It stores all the parameters of the shape as well as ...
armarx::ctrlutil::s
double s(double t, double s0, double v0, double a0, double j)
Definition: CtrlUtil.h:33
IndexIterator
Definition: IndexIterator.h:9
GfxTL::AABox
Definition: AABox.h:18
PrimitiveShape::SignedDistanceFunc
virtual LevMarFunc< float > * SignedDistanceFunc() const =0
LowStretchTorusParametrization.h
BitmapPrimitiveShape::WrapBitmap
virtual void WrapBitmap(const GfxTL::AABox< GfxTL::Vector2Df > &bbox, float epsilon, bool *uwrap, bool *vwrap) const =0
TorusPrimitiveShape::TorusPrimitiveShape
TorusPrimitiveShape()
Definition: TorusPrimitiveShape.h:17
PrimitiveShape::Clone
virtual PrimitiveShape * Clone() const =0
PrimitiveShape::Visit
virtual void Visit(PrimitiveShapeVisitor *visitor) const =0