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 NURBS_OPTIMIZATION_H
00039 #define NURBS_OPTIMIZATION_H
00040
00041 #include <pcl/surface/on_nurbs/nurbs_tools.h>
00042 #include <pcl/surface/on_nurbs/nurbs_data.h>
00043 #include <pcl/surface/on_nurbs/nurbs_solve.h>
00044
00045 namespace pcl
00046 {
00047 namespace on_nurbs
00048 {
00049
00055 class GlobalOptimization
00056 {
00057 public:
00058
00060 struct Parameter
00061 {
00062 double interior_weight;
00063 double interior_smoothness;
00064
00065 double boundary_weight;
00066 double boundary_smoothness;
00067
00068 double closing_weight;
00069 double closing_sigma;
00070 unsigned closing_samples;
00071
00072 double common_weight;
00073
00074 Parameter (double intW = 1.0, double intS = 1e-6, double bndW = 0.0, double bndS = 1e-6, double cloW = 0.0,
00075 double cloSig = 0.0, unsigned cloSam = 0, double comW = 0.0) :
00076 interior_weight (intW), interior_smoothness (intS), boundary_weight (bndW), boundary_smoothness (bndS),
00077 closing_weight (cloW), closing_sigma (cloSig), closing_samples (cloSam), common_weight (comW)
00078 {
00079 }
00080 };
00081
00085 GlobalOptimization (const std::vector<NurbsDataSurface*> &data, const std::vector<ON_NurbsSurface*> &nurbs);
00086
00090 void
00091 setCommonBoundary (const vector_vec3d &boundary, const vector_vec2i &nurbs_indices);
00092
00096 virtual void
00097 assemble (Parameter params = Parameter ());
00098
00101 virtual void
00102 solve (double damp = 1.0);
00103
00106 virtual void
00107 updateSurf (double damp);
00108
00112 void
00113 setInvMapParams (double im_max_steps, double im_accuracy);
00114
00118 void
00119 refine (unsigned id, int dim);
00120
00121 inline void
00122 setQuiet (bool val)
00123 {
00124 m_quiet = val;
00125 m_solver.setQuiet (val);
00126 }
00127
00128 protected:
00129
00130 std::vector<NurbsDataSurface*> m_data;
00131 std::vector<ON_NurbsSurface*> m_nurbs;
00132
00133 void
00134 assembleCommonParams (unsigned id1, double weight, unsigned &row);
00135
00137 virtual void
00138 assembleCommonBoundaries (unsigned id1, double weight, unsigned &row);
00139
00141 virtual void
00142 assembleClosingBoundaries (unsigned id, unsigned samples, double sigma, double weight, unsigned &row);
00143
00145 virtual void
00146 assembleInteriorPoints (unsigned id, int ncps, double weight, unsigned &row);
00147
00149 virtual void
00150 assembleBoundaryPoints (unsigned id, int ncps, double weight, unsigned &row);
00151
00153 virtual void
00154 assembleRegularisation (unsigned id, int ncps, double wCageRegInt, double wCageRegBnd, unsigned &row);
00155
00157 virtual void
00158 addParamConstraint (const Eigen::Vector2i &id, const Eigen::Vector2d ¶ms1, const Eigen::Vector2d ¶ms2,
00159 double weight, unsigned &row);
00160
00162 virtual void
00163 addPointConstraint (unsigned id, int ncps, const Eigen::Vector2d ¶ms, const Eigen::Vector3d &point,
00164 double weight, unsigned &row);
00165
00167 virtual void
00168 addCageInteriorRegularisation (unsigned id, int ncps, double weight, unsigned &row);
00169
00171 virtual void
00172 addCageBoundaryRegularisation (unsigned id, int ncps, double weight, int side, unsigned &row);
00173
00175 virtual void
00176 addCageCornerRegularisation (unsigned id, int ncps, double weight, unsigned &row);
00177
00178 protected:
00179 NurbsSolve m_solver;
00180 bool m_quiet;
00181 unsigned m_ncols, m_nrows;
00182 int im_max_steps;
00183 double im_accuracy;
00184
00185
00186 int
00187 grc2gl (const ON_NurbsSurface &nurbs, int I, int J)
00188 {
00189 return nurbs.CVCount (1) * I + J;
00190 }
00191 int
00192 lrc2gl (const ON_NurbsSurface &nurbs, int E, int F, int i, int j)
00193 {
00194 return grc2gl (nurbs, E + i, F + j);
00195 }
00196 int
00197 gl2gr (const ON_NurbsSurface &nurbs, int A)
00198 {
00199 return (static_cast<int> (A / nurbs.CVCount (1)));
00200 }
00201 int
00202 gl2gc (const ON_NurbsSurface &nurbs, int A)
00203 {
00204 return (static_cast<int> (A % nurbs.CVCount (1)));
00205 }
00206 };
00207
00208 }
00209 }
00210 #endif
00211