PrimitiveShape.h
Go to the documentation of this file.
1 #ifndef PRIMITIVESHAPE_HEADER
2 #define PRIMITIVESHAPE_HEADER
3 #include <stdio.h>
4 
5 #include <deque>
6 #include <iostream>
7 #include <string>
8 #include <utility>
9 
10 #include "LevMarFunc.h"
11 #include "PointCloud.h"
12 #include "basic.h"
13 #include <GfxTL/VectorXD.h>
14 #include <MiscLib/NoShrinkVector.h>
15 #include <MiscLib/RefCount.h>
16 #include <MiscLib/RefCountPtr.h>
17 #include <MiscLib/Vector.h>
18 
19 #ifndef DLL_LINKAGE
20 #define DLL_LINKAGE
21 #endif
22 
24 
25 /** PrimtiveShape is a shape primitive in conjunction with a parametrization.
26  The parametrization is used for connected component computations.
27  There are some deprecated serialization functions that do
28  not always store the parametrization (at least for some shape types). These
29  functions should no longer be used anywhere!
30  Note: Computing connected components may change the parametrization! (Some
31  shapes align the parametrization so that the memory for the bitmap is
32  reduced)
33 */
35 {
36 public:
37  // returns a unique identifier of the shape type
38  virtual size_t Identifier() const = 0;
39  // returns the number of point samples required to uniquely determine a shape
40  virtual unsigned int RequiredSamples() const = 0;
41  virtual PrimitiveShape* Clone() const = 0;
42  virtual float Distance(const Vec3f& p) const = 0;
43  virtual float SignedDistance(const Vec3f& p) const = 0;
44  virtual float NormalDeviation(const Vec3f& p, const Vec3f& n) const = 0;
45  // computes the distance to the shape and the deviation of the normal
46  // to the normal at the nearest point on the shape
47  virtual void DistanceAndNormalDeviation(const Vec3f& p,
48  const Vec3f& n,
49  std::pair<float, float>* dn) const = 0;
50  // projects a point p onto the nearest point on the shape
51  virtual void Project(const Vec3f& p, Vec3f* pp) const = 0;
52  // gets the normal of the shape at the projection of p
53  virtual void Normal(const Vec3f& p, Vec3f* n) const = 0;
54  // finds the largest connected component in the points indexed by indices
55  // Upon return the indices of the points that belong to the largest component
56  // have been moved to the front of indices and their number is returned.
57  // The remaining indices are stored at the end of the indices array
58  virtual size_t ConnectedComponent(const PointCloud& pc,
59  float epsilon,
61  bool doFiltering = true,
62  float* borderRatio = 0) = 0;
63  virtual unsigned int ConfidenceTests(unsigned int numTests,
64  float epsilon,
65  float normalThresh,
66  float rms,
67  const PointCloud& pc,
68  const MiscLib::Vector<size_t>& indices) const = 0;
69  // returns descriptive string
70  virtual void Description(std::string* s) const = 0;
71  // refitting
72  virtual bool Fit(const PointCloud& pc,
73  float epsilon,
74  float normalThresh,
77  virtual PrimitiveShape* LSFit(const PointCloud& pc,
78  float epsilon,
79  float normalThresh,
82  std::pair<size_t, float>* score) const = 0;
83  virtual LevMarFunc<float>* SignedDistanceFunc() const = 0;
86  virtual void TrimmingPolygons(const PointCloud& pc,
87  float epsilon,
88  size_t begin,
89  size_t end,
90  std::deque<ComponentPolygons>* polys) const = 0;
91  // generates points on the shape from the primitive's bitmap i.e. where the bitmap is set
92  virtual void GenerateBitmapPoints(const PointCloud& pc,
93  float epsilon,
94  size_t begin,
95  size_t end,
96  PointCloud* bmpPc) const = 0;
97  /** This is the one and only serialization function
98  It stores all the parameters of the shape as well as the parametrization.
99  The first byte written (in both, binary and ascii mode) is the shape identifier */
100  virtual void Serialize(std::ostream* o, bool binary = true) const = 0;
101  virtual size_t SerializedSize() const = 0;
102  // Serialize parameters to float array
103  virtual void Serialize(float* array) const = 0;
104  virtual size_t SerializedFloatSize() const = 0;
105  virtual void Transform(float scale, const Vec3f& translate) = 0;
106  virtual void Visit(PrimitiveShapeVisitor* visitor) const = 0;
107 
108  virtual void
112  float distThresh,
114  {
115  }
116 
117  virtual void
118  OptimizeParametrization(const PointCloud& pc, size_t begin, size_t end, float epsilon)
119  {
120  }
121 
122  // gets the 2D parametrization coordinates of a point p in 3-space (it is projected first)
123  virtual void Parameters(const Vec3f& p, std::pair<float, float>* param) const = 0;
124  // computes the point and normal in 3-space from coordinates in the parametrization
125  virtual bool InSpace(float u, float v, Vec3f* p, Vec3f* n) const = 0;
126 };
127 
128 #endif
LevMarFunc< float >
Vector.h
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:109
Vec3f
Definition: basic.h:17
PrimitiveShape
PrimtiveShape is a shape primitive in conjunction with a parametrization.
Definition: PrimitiveShape.h:34
armarx::skills::gui::Parameters
aron::data::DictPtr Parameters
Definition: SkillManagerWrapper.h:21
PrimitiveShape::BitmapPolygon
MiscLib::Vector< GfxTL::VectorXD< 2, size_t > > BitmapPolygon
Definition: PrimitiveShape.h:84
RefCount.h
magic_enum::detail::n
constexpr auto n() noexcept
Definition: magic_enum.hpp:418
MiscLib::Vector< size_t >
VectorXD.h
LevMarFunc.h
NoShrinkVector.h
RefCountPtr.h
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
PrimitiveShapeVisitor
Definition: PrimitiveShapeVisitor.h:14
PrimitiveShape::OptimizeParametrization
virtual void OptimizeParametrization(const PointCloud &pc, size_t begin, size_t end, float epsilon)
Definition: PrimitiveShape.h:118
MiscLib::RefCountPtr< PrimitiveShape >
PrimitiveShape::ComponentPolygons
MiscLib::Vector< BitmapPolygon > ComponentPolygons
Definition: PrimitiveShape.h:85
PointCloud
Definition: PointCloud.h:85
armarx::ctrlutil::v
double v(double t, double v0, double a0, double j)
Definition: CtrlUtil.h:39
MiscLib::RefCount
Definition: RefCount.h:9
basic.h
PointCloud.h
DLL_LINKAGE
#define DLL_LINKAGE
Definition: basic.h:12
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
armarx::ctrlutil::s
double s(double t, double s0, double v0, double a0, double j)
Definition: CtrlUtil.h:33