fitting_surface_pdm.h
Go to the documentation of this file.
00001 /*
00002  * Software License Agreement (BSD License)
00003  *
00004  *  Copyright (c) 2012-, Open Perception, Inc.
00005  *  All rights reserved.
00006  *
00007  *  Redistribution and use in source and binary forms, with or without
00008  *  modification, are permitted provided that the following conditions
00009  *  are met:
00010  *
00011  *   * Redistributions of source code must retain the above copyright
00012  *     notice, this list of conditions and the following disclaimer.
00013  *   * Redistributions in binary form must reproduce the above
00014  *     copyright notice, this list of conditions and the following
00015  *     disclaimer in the documentation and/or other materials provided
00016  *     with the distribution.
00017  *   * Neither the name of the copyright holder(s) nor the names of its
00018  *     contributors may be used to endorse or promote products derived
00019  *     from this software without specific prior written permission.
00020  *
00021  *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00022  *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00023  *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
00024  *  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
00025  *  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
00026  *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
00027  *  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00028  *  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00029  *  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00030  *  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
00031  *  ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00032  *  POSSIBILITY OF SUCH DAMAGE.
00033  *
00034  * 
00035  *
00036  */
00037 
00038 #ifndef NURBS_FITTING_PATCH_H
00039 #define NURBS_FITTING_PATCH_H
00040 
00041 #include <pcl/pcl_exports.h>
00042 #include <pcl/surface/on_nurbs/nurbs_tools.h>
00043 #include <pcl/surface/on_nurbs/nurbs_data.h>
00044 #include <pcl/surface/on_nurbs/nurbs_solve.h>
00045 
00046 namespace pcl
00047 {
00048   namespace on_nurbs
00049   {
00055     class PCL_EXPORTS FittingSurface
00056     {
00057     public:
00058       ON_NurbsSurface m_nurbs;
00059       NurbsDataSurface *m_data;
00060 
00061       class myvec
00062       {
00063       public:
00064         int side;
00065         double hint;
00066 
00067         myvec (int side, double hint)
00068         {
00069           this->side = side;
00070           this->hint = hint;
00071         }
00072       };
00073 
00075       struct Parameter
00076       {
00077         double interior_weight;
00078         double interior_smoothness;
00079         double interior_regularisation;
00080 
00081         double boundary_weight;
00082         double boundary_smoothness;
00083         double boundary_regularisation;
00084 
00085         unsigned regularisation_resU;
00086         unsigned regularisation_resV;
00087 
00088         Parameter (double intW = 1.0, double intS = 0.000001, double intR = 0.0, double bndW = 1.0,
00089                    double bndS = 0.000001, double bndR = 0.0, unsigned regU = 0, unsigned regV = 0) :
00090           interior_weight (intW), interior_smoothness (intS), interior_regularisation (intR), boundary_weight (bndW),
00091               boundary_smoothness (bndS), boundary_regularisation (bndR), regularisation_resU (regU),
00092               regularisation_resV (regV)
00093         {
00094         }
00095       };
00096 
00101       FittingSurface (NurbsDataSurface *data, const ON_NurbsSurface &ns);
00102 
00108       FittingSurface (int order, NurbsDataSurface *data, Eigen::Vector3d z = Eigen::Vector3d (0.0, 0.0, 1.0));
00109 
00113       void
00114       refine (int dim);
00115 
00116       static void
00117       refine (ON_NurbsSurface &nurbs, int dim);
00118 
00123       virtual void
00124       assemble (Parameter param = Parameter ());
00125 
00129       virtual void
00130       solve (double damp = 1.0);
00131 
00135       virtual void
00136       updateSurf (double damp);
00137 
00142       void
00143       setInvMapParams (unsigned in_max_steps, double in_accuracy);
00144 
00146       static std::vector<double>
00147       getElementVector (const ON_NurbsSurface &nurbs, int dim);
00148 
00162       static Eigen::Vector2d
00163       inverseMapping (const ON_NurbsSurface &nurbs, const Eigen::Vector3d &pt, const Eigen::Vector2d &hint,
00164                       double &error, Eigen::Vector3d &p, Eigen::Vector3d &tu, Eigen::Vector3d &tv, int maxSteps = 100,
00165                       double accuracy = 1e-6, bool quiet = true);
00166 
00167       static Eigen::Vector2d
00168       inverseMapping (const ON_NurbsSurface &nurbs, const Eigen::Vector3d &pt, const Eigen::Vector2d &hint,
00169                       Eigen::Vector3d &p, int maxSteps, double accuracy, bool quiet);
00170 
00176       static Eigen::Vector2d
00177       findClosestElementMidPoint (const ON_NurbsSurface &nurbs, const Eigen::Vector3d &pt);
00178 
00191       static Eigen::Vector2d
00192       inverseMappingBoundary (const ON_NurbsSurface &nurbs, const Eigen::Vector3d &pt, double &error,
00193                               Eigen::Vector3d &p, Eigen::Vector3d &tu, Eigen::Vector3d &tv, int maxSteps = 100,
00194                               double accuracy = 1e-6, bool quiet = true);
00195 
00211       static Eigen::Vector2d
00212       inverseMappingBoundary (const ON_NurbsSurface &nurbs, const Eigen::Vector3d &pt, int side, double hint,
00213                               double &error, Eigen::Vector3d &p, Eigen::Vector3d &tu, Eigen::Vector3d &tv,
00214                               int maxSteps = 100, double accuracy = 1e-6, bool quiet = true);
00215 
00217       static ON_NurbsSurface
00218       initNurbs4Corners (int order, ON_3dPoint ll, ON_3dPoint lr, ON_3dPoint ur, ON_3dPoint ul);
00219 
00221       static ON_NurbsSurface
00222       initNurbsPCA (int order, NurbsDataSurface *data, Eigen::Vector3d z = Eigen::Vector3d (0.0, 0.0, 1.0));
00223 
00225       static ON_NurbsSurface
00226       initNurbsPCABoundingBox (int order, NurbsDataSurface *data, Eigen::Vector3d z = Eigen::Vector3d (0.0, 0.0, 1.0));
00227 
00229       inline void
00230       setQuiet (bool val)
00231       {
00232         m_quiet = val;
00233         m_solver.setQuiet (val);
00234       }
00235 
00236     protected:
00237 
00239       void
00240       init ();
00241 
00243       virtual void
00244       assembleInterior (double wInt, unsigned &row);
00245 
00247       virtual void
00248       assembleBoundary (double wBnd, unsigned &row);
00249 
00251       virtual void
00252       addPointConstraint (const Eigen::Vector2d &params, const Eigen::Vector3d &point, double weight, unsigned &row);
00253       //  void addBoundaryPointConstraint(double paramU, double paramV, double weight, unsigned &row);
00254 
00256       virtual void
00257       addCageInteriorRegularisation (double weight, unsigned &row);
00258 
00260       virtual void
00261       addCageBoundaryRegularisation (double weight, int side, unsigned &row);
00262 
00264       virtual void
00265       addCageCornerRegularisation (double weight, unsigned &row);
00266 
00268       virtual void
00269       addInteriorRegularisation (int order, int resU, int resV, double weight, unsigned &row);
00270 
00272       virtual void
00273       addBoundaryRegularisation (int order, int resU, int resV, double weight, unsigned &row);
00274 
00275       NurbsSolve m_solver;
00276 
00277       bool m_quiet;
00278 
00279       std::vector<double> m_elementsU;
00280       std::vector<double> m_elementsV;
00281 
00282       double m_minU;
00283       double m_minV;
00284       double m_maxU;
00285       double m_maxV;
00286 
00287       int in_max_steps;
00288       double in_accuracy;
00289 
00290       // index routines
00291       int
00292       grc2gl (int I, int J)
00293       {
00294         return m_nurbs.CVCount (1) * I + J;
00295       } // global row/col index to global lexicographic index
00296       int
00297       lrc2gl (int E, int F, int i, int j)
00298       {
00299         return grc2gl (E + i, F + j);
00300       } // local row/col index to global lexicographic index
00301       int
00302       gl2gr (int A)
00303       {
00304         return (static_cast<int> (A / m_nurbs.CVCount (1)));
00305       } // global lexicographic in global row index
00306       int
00307       gl2gc (int A)
00308       {
00309         return (static_cast<int> (A % m_nurbs.CVCount (1)));
00310       } // global lexicographic in global col index
00311     };
00312 
00313   } // namespace on_nurbs
00314 } // namespace pcl
00315 
00316 #endif    // PATCHFITTING_H_


pcl
Author(s): Open Perception
autogenerated on Wed Aug 26 2015 15:24:10