Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038 #ifndef SEQUENTIAL_FITTER_H
00039 #define SEQUENTIAL_FITTER_H
00040
00041
00042
00043
00044
00045
00046 #undef True
00047 #undef False
00048 #undef None
00049 #undef Status
00050
00051 #include <pcl/surface/on_nurbs/fitting_surface_pdm.h>
00052 #include <pcl/surface/on_nurbs/nurbs_data.h>
00053
00054 #include <pcl/pcl_base.h>
00055 #include <pcl/point_types.h>
00056
00057
00058
00059 namespace pcl
00060 {
00061 namespace on_nurbs
00062 {
00063 class SequentialFitter
00064 {
00065 public:
00066 struct Parameter
00067 {
00068 int order;
00069 int refinement;
00070 int iterationsQuad;
00071 int iterationsBoundary;
00072 int iterationsAdjust;
00073 int iterationsInterior;
00074 double forceBoundary;
00075 double forceBoundaryInside;
00076 double forceInterior;
00077 double stiffnessBoundary;
00078 double stiffnessInterior;
00079 int resolution;
00080 Parameter (int order = 3, int refinement = 1, int iterationsQuad = 5, int iterationsBoundary = 5,
00081 int iterationsAdjust = 5, int iterationsInterior = 2, double forceBoundary = 200.0,
00082 double forceBoundaryInside = 400.0, double forceInterior = 1.0, double stiffnessBoundary = 20.0,
00083 double stiffnessInterior = 0.1, int resolution = 16);
00084 };
00085
00086 private:
00087 Parameter m_params;
00088
00089 NurbsDataSurface m_data;
00090 ON_NurbsSurface m_nurbs;
00091
00092 ON_3dPoint m_corners[4];
00093 pcl::PointCloud<pcl::PointXYZRGB>::Ptr m_cloud;
00094 pcl::PointIndices::Ptr m_boundary_indices;
00095 pcl::PointIndices::Ptr m_interior_indices;
00096
00097 Eigen::Matrix4d m_intrinsic;
00098 Eigen::Matrix4d m_extrinsic;
00099
00100 bool m_have_cloud;
00101 bool m_have_corners;
00102
00103 int m_surf_id;
00104
00105 void
00106 compute_quadfit ();
00107 void
00108 compute_refinement (FittingSurface* fitting);
00109 void
00110 compute_boundary (FittingSurface* fitting);
00111 void
00112 compute_interior (FittingSurface* fitting);
00113
00114 Eigen::Vector2d
00115 project (const Eigen::Vector3d &pt);
00116
00117 bool
00118 is_back_facing (const Eigen::Vector3d &v0,
00119 const Eigen::Vector3d &v1,
00120 const Eigen::Vector3d &v2,
00121 const Eigen::Vector3d &v3);
00122
00123 public:
00124 SequentialFitter (Parameter p = Parameter ());
00125
00126 inline void
00127 setParams (const Parameter &p)
00128 {
00129 m_params = p;
00130 }
00131
00133 void
00134 setInputCloud (pcl::PointCloud<pcl::PointXYZRGB>::Ptr &pcl_cloud);
00135
00137 void
00138 setBoundary (pcl::PointIndices::Ptr &pcl_cloud_indices);
00139
00141 void
00142 setInterior (pcl::PointIndices::Ptr &pcl_cloud_indices);
00143
00145 void
00146 setCorners (pcl::PointIndices::Ptr &corners, bool flip_on_demand = true);
00147
00151 void
00152 setProjectionMatrix (const Eigen::Matrix4d &intrinsic,
00153 const Eigen::Matrix4d &extrinsic);
00154
00156 ON_NurbsSurface
00157 compute (bool assemble = false);
00158
00161 ON_NurbsSurface
00162 compute_boundary (const ON_NurbsSurface &nurbs);
00163
00166 ON_NurbsSurface
00167 compute_interior (const ON_NurbsSurface &nurbs);
00168
00170 inline ON_NurbsSurface
00171 getNurbs ()
00172 {
00173 return m_nurbs;
00174 }
00175
00177 void
00178 getInteriorError (std::vector<double> &error);
00179
00181 void
00182 getBoundaryError (std::vector<double> &error);
00183
00185 void
00186 getInteriorParams (std::vector<Eigen::Vector2d, Eigen::aligned_allocator<Eigen::Vector2d> > ¶ms);
00187
00189 void
00190 getBoundaryParams (std::vector<Eigen::Vector2d, Eigen::aligned_allocator<Eigen::Vector2d> > ¶ms);
00191
00193 void
00194 getInteriorNormals (std::vector<Eigen::Vector3d, Eigen::aligned_allocator<Eigen::Vector3d> > &normal);
00195
00197 void
00198 getBoundaryNormals (std::vector<Eigen::Vector3d, Eigen::aligned_allocator<Eigen::Vector3d> > &normals);
00199
00206 static void
00207 getClosestPointOnNurbs (ON_NurbsSurface nurbs,
00208 const Eigen::Vector3d &pt,
00209 Eigen::Vector2d& params,
00210 int maxSteps = 100,
00211 double accuracy = 1e-4);
00212
00214 ON_NurbsSurface
00215 grow (float max_dist = 1.0f, float max_angle = M_PI_4, unsigned min_length = 0, unsigned max_length = 10);
00216
00218 static unsigned
00219 PCL2ON (pcl::PointCloud<pcl::PointXYZRGB>::Ptr &pcl_cloud, const std::vector<int> &indices, vector_vec3d &cloud);
00220
00221 public:
00222 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
00223 };
00224
00225 }
00226 }
00227
00228 #endif