MOAB: Mesh Oriented datABase  (version 5.2.1)
HiReconstruction.hpp
Go to the documentation of this file.
00001 /*! \file HiReconstruction.hpp
00002  * This class implements a high order surface/curve reconstruction method which takes a
00003  * surface/curve mesh as input and compute local polynomial fittings (in monomial basis) around user
00004  * specified vertices. Little noise is allowed and least square will be used in such case. This
00005  * method assumes the underlying geometry of input mesh is smooth. The local fitting results could
00006  * be used for estimate the exact geometry of the surface. For instance, if mesh refinement is
00007  * perform on the input mesh, then the position of new vertices introduced by refinement could be
00008  * estimated by the local fitting, rather than using linear interpolation.
00009  * Implementations are based on the WALF method in paper:
00010  * Jiao, Xiangmin, and Duo Wang. "Reconstructing high-order surfaces for meshing." Engineering with
00011  * Computers 28.4 (2012): 361-373.
00012  */
00013 
00014 #ifndef HI_RECONSTRUCTION_HPP
00015 #define HI_RECONSTRUCTION_HPP
00016 
00017 #include "moab/Range.hpp"
00018 #include "moab/HalfFacetRep.hpp"
00019 
00020 #ifdef MOAB_HAVE_MPI
00021 #include "moab/ParallelComm.hpp"
00022 #endif
00023 
00024 #include <vector>
00025 
00026 namespace moab
00027 {
00028 enum GEOMTYPE
00029 {
00030     HISURFACE,
00031     HI3DCURVE,
00032     HI2DCURVE
00033 };
00034 
00035 class Core;
00036 class HalfFaceRep;
00037 class ParallelComm;
00038 
00039 class HiReconstruction
00040 {
00041   public:
00042     HiReconstruction( Core* impl, ParallelComm* comm = 0, EntityHandle meshIn = 0, int minpnts = 5,
00043                       bool recwhole = true );
00044 
00045     ~HiReconstruction();
00046 
00047     ErrorCode initialize( bool recwhole );
00048 
00049     //! \brief Reconstruct a high order surface on given surface mesh
00050     /** Given a mesh, compute vertex based polynomial fittings for all vertices hosted by current
00051      * processor. The result will be stored interally for later usage of evalution. The inputs are:
00052      * a) degree, which is the order of polynomial used for vertex based fitting. b) interp, if it's
00053      * true, then interpolation will be applied for local fitting, otherwise it's least square
00054      * fitting. c) safeguard, specifies whether to use safeguarded numeric method. d) reset, if
00055      * fittings have been computed and stored in current object, then reset=true will recompute the
00056      * fittings based on user input and replace the existing one. \param degree Integer, order of
00057      * polynomials used for local fittings. \param interp Boolean, true=Interpolation, false=least
00058      * square fitting. \param safeguard Boolean, true=using safe guarded method in numerical
00059      * computing. \param reset Boolean, reset=true will recompute the fittings based on user input
00060      * and replace the existing one.
00061      */
00062     ErrorCode reconstruct3D_surf_geom( int degree, bool interp, bool safeguard, bool reset = false );
00063 
00064     //! \brief Reconstruct a high order surface on given surface mesh
00065     /** Given a mesh, compute vertex based polynomial fittings for all vertices hosted by current
00066      * processor. User could specify various degrees for different vertices. It assumes that the
00067      * input degrees for vertices stored in the same order as that this class stores vertices: 1)
00068      * reconstruction will be only performed at vertices hosted by current processor, thus input
00069      * npts should match the number of hosted vertices. 2) all hosted vertices will be stored in a
00070      * MOAB::Range object, degrees for all these vertices should be stored in degrees as the same
00071      * order in the MOAB::Range object The result will be stored interally for later usage of
00072      * evalution. \param npts Integer size of array pointed by degrees, used for check \param
00073      * degrees Integer arrray, order of polynomials for local fitting at all hosted vertices \param
00074      * interp Boolean, true=Interpolation, false=least square fitting. \param safeguard Boolean,
00075      * true=using safe guarded method in numerical computing. \param reset Boolean, reset=true will
00076      * recompute the fittings based on user input and replace the existing one.
00077      */
00078     ErrorCode reconstruct3D_surf_geom( size_t npts, int* degrees, bool* interps, bool safeguard, bool reset = false );
00079 
00080     //! \brief Reconstruct a high order curve on given curve mesh
00081     /** Given a curve mesh, compute vertex based polynomail fittings for all vertices hosted by
00082      * current processor. The vertex based fitting is done by perfoming three one-parameter fittings
00083      * along each axis, i.e. x,y,z. The result will be stored interally for later usage of
00084      * evalution. \param degree Integer, order of polynomials used for local fittings. \param interp
00085      * Boolean, true=Interpolation, false=least square fitting. \param safeguard Boolean, true=using
00086      * safe guarded method in numerical computing. \param reset Boolean, reset=true will recompute
00087      * the fittings based on user input and replace the existing one.
00088      */
00089     ErrorCode reconstruct3D_curve_geom( int degree, bool interp, bool safeguard, bool reset = false );
00090 
00091     //! \brief Reconstruct a high order curve on given curve mesh
00092     /** Given a curve mesh, compute vertex based polynomail fittings for all vertices hosted by
00093      * current processor. The vertex based fitting is done by perfoming three one-parameter fittings
00094      * along each axis, i.e. x,y,z. User could specify various degrees for different vertices. It
00095      * assumes that the input degrees for vertices stored in the same order as that this class
00096      * stores vertices: 1) reconstruction will be only performed at vertices hosted by current
00097      * processor, thus input npts should match the number of hosted vertices. 2) all hosted vertices
00098      * will be stored in a MOAB::Range object, degrees for all these vertices should be stored in
00099      * degrees as the same order in the MOAB::Range object The result will be stored interally for
00100      * later usage of evalution. \param npts Integer size of array pointed by degrees, used for
00101      * check \param degrees Integer arrray, order of polynomials for local fitting at all hosted
00102      * vertices. \param interp Boolean, true=Interpolation, false=least square fitting. \param
00103      * safeguard Boolean, true=using safe guarded method in numerical computing. \param reset
00104      * Boolean, reset=true will recompute the fittings based on user input and replace the existing
00105      * one.
00106      */
00107     ErrorCode reconstruct3D_curve_geom( size_t npts, int* degrees, bool* interps, bool safeguard, bool reset = false );
00108 
00109     //! \brief Construct vertex based polynomial fitting on a surface mesh
00110     /** Given a vertex on a surface mesh, construct a local fitting around this vertex. Stencils
00111      * around this vertex will be selected according to input degree and if data is noise. Local
00112      * uv-plane will be the estimated tangent plane at this vertex. minpnts will be used to specify
00113      * the minimum number allowed in the local stencil. The result will be returned to user by
00114      * preallocated memory coords, degree_out, coeffs. \param vid EntityHandle, the fitting will be
00115      * performed around this vertex for the local height function over the uv-plane. \param interp
00116      * Boolean, true=Interpolation, false=least square fitting. \param degree Integer, order of
00117      * polynomials used for local fittings. \param minpnts Integer, the allowed minimum number of
00118      * vertices in local stencil. If too small, the resulted fitting might be low order accurate. If
00119      * too large, it may introduce overfitting. \param safeguard Boolean, true=using safe guarded
00120      * method in numerical computing. \param coords Pointer to double, preallocated memory by user,
00121      * should have at least 9 doubles; stores the global coordinates of local coordinates system uvw
00122      * directions. \param degree_out Pointer to integer, used to store the degree of resulted
00123      * fitting \param coeffs, Pointer to double, preallocated memory for coefficients of local
00124      * fittings, should have at least (degree+2)(degree+1)/2 doubles.
00125      */
00126     ErrorCode polyfit3d_walf_surf_vertex( const EntityHandle vid, const bool interp, int degree, int minpnts,
00127                                           const bool safeguard, const int ncoords, double* coords, int* degree_out,
00128                                           const int ncoeffs, double* coeffs );
00129 
00130     //! \brief Construct vertex based polynomial fitting on a curve mesh
00131     /** Given a vertex on a curve mesh, construct three one-parameter local fittings for each
00132      * coordinates axis around this vertex. Stencils around this vertex will be selected according
00133      * to input degree and if data is noise. Local u-line, or the single parameter will be the
00134      * estimated tangent line at this vertex. On each axis of xyz, a polynomial fitting will be
00135      * performed according to user input. minpnts will be used to specify the minimum number allowed
00136      * in the local stencil. The result will be returned to user by preallocated memory coords,
00137      * degree_out, coeffs. \param vid EntityHandle, the fittings will be performed around this
00138      * vertex. \param interp Boolean, true=Interpolation, false=least square fitting. \param degree
00139      * Integer, order of polynomials used for local fittings. \param minpnts Integer, the allowed
00140      * minimum number of vertices in local stencil. If too small, the resulted fitting might be low
00141      * order accurate. If too large, it may introduce overfitting. \param safeguard Boolean,
00142      * true=using safe guarded method in numerical computing. \param coords Pointer to double,
00143      * preallocated memory by user, should have at least 3 doubles; stores the global coordinates of
00144      * local coordinate system u direction. \param degree_out Pointer to integer, used to store the
00145      * degree of resulted fitting \param coeffs, Pointer to double, preallocated memory for
00146      * coefficients of local fittings, should have at least 3*(degree+1) doubles.
00147      */
00148     ErrorCode polyfit3d_walf_curve_vertex( const EntityHandle vid, const bool interp, int degree, int minpnts,
00149                                            const bool safeguard, const int ncoords, double* coords, int* degree_out,
00150                                            const int ncoeffs, double* coeffs );
00151 
00152     //! \brief Perform high order projection of points in an element, using estimated geometry by
00153     //! reconstruction class
00154     /** Given an element on the input mesh, and new points in this element, represented as natural
00155      * coordinates in element, estimate their position in surface. This is done by weighted
00156      * averaging of local fittings: for each vertex of this elment, a fitting has been computed and
00157      * the new points could be projected by this fitting. The final result of projection is the
00158      * weighted average of these projections, weights are chosen as the barycentric coordinates of
00159      * the point in this element. The result will be returned to the user preallocated memory \param
00160      * elem EntityHandle, the element on which to perform high order projection. \param nvpe
00161      * Integer, number of nodes of this element, triangle is 3, quad is four. \param npts2fit
00162      * Integer, number of points lying in elem to be projected. \param naturalcoords2fit Pointer to
00163      * array of doubles, size=nvpe*npts2fit, natural coordinates in elem of points to be projected.
00164      * \param newcoords Pointer to array of doubles, preallocated by user, size=3*npts2fit,
00165      * estimated positions of input points.
00166      */
00167     ErrorCode hiproj_walf_in_element( EntityHandle elem, const int nvpe, const int npts2fit,
00168                                       const double* naturalcoords2fit, double* newcoords );
00169 
00170     //! \brief Perform high order projection of points around a vertex, using estimated geometry by
00171     //! reconstruction class
00172     /** Given an vertex on the input mesh, and new points around this vertex, estimate their
00173      * position in surface. This is done by first projecting input points onto the local uv-plane
00174      * around this vertex and use the precomputed local fitting to estimate the ideal position of
00175      * input points. The result will be returned to the user preallocated memory \param vid
00176      * EntityHandle, the vertex around which to perform high order projection. \param npts2fit
00177      * Integer, number of points lying around vid to be fitted. \param coords2fit Pointer to array
00178      * of doubles, size=3*npts2fit, current coordinates of points to be projected. \param newcoords
00179      * Pointer to array of doubles, preallocated by user, size=3*npts2fit, estimated positions of
00180      * input points.
00181      */
00182     ErrorCode hiproj_walf_around_vertex( EntityHandle vid, const int npts2fit, const double* coords2fit,
00183                                          double* hiproj_new );
00184 
00185     //! \brief Perform high order projection of points around a center vertex, assume geometry is
00186     //! surface
00187     /** Given a vertex position and the local fitting parameter around this vertex, estimate the
00188      * ideal position of input position according to the local fitting. This is done by first
00189      * projecting input points onto the local uv-plane around this vertex and use the given fitting
00190      * to estimate the ideal position of input points. The result will be returned to user
00191      * preallocated memory \param local_origin Pointer to 3 doubles, coordinates of the center
00192      * vertex \param local_coords Pointer to 9 doubles, global coordinates of directions of local
00193      * uvw coordinates axis at center vertex \param local_deg Integer, order of local polynomial
00194      * fitting \param local_coeffs Pointer to array of doubles, size=(local_deg+2)(local_deg+1)/2,
00195      * coefficients of local polynomial fittings, in monomial basis \param interp Boolean,
00196      * true=local fitting is interpolation, false=local fitting is least square fitting \param
00197      * npts2fit Integer, number of points to be estimated, around the center vertices \param
00198      * coords2fit Pointer to array of doubles, size=3*npts2fit, current coordinates of points to be
00199      * estimated \param hiproj_new Pointer to array of doubles, size=3*npts2fit, memory preallocated
00200      * by user to store the fitting/estimated positions of input points.
00201      */
00202     void walf3d_surf_vertex_eval( const double* local_origin, const double* local_coords, const int local_deg,
00203                                   const double* local_coeffs, const bool interp, const int npts2fit,
00204                                   const double* coords2fit, double* hiproj_new );
00205 
00206     //! \brief Perform high order projection of points around a center vertex, assume geometry is
00207     //! curve
00208     /** Given a vertex position and the local one-parameter fittings parameter around this vertex,
00209      * estimate the ideal position of input position according to the local fittings. This is done
00210      * by first projecting input points onto the local u-direction at this vertex and then use the
00211      * value u as parameter for the three fittings, one for each coordinates axis of xyz. The result
00212      * will be returned to user preallocated memory \param local_origin Pointer to 3 doubles,
00213      * coordinates of the center vertex \param local_coords Pointer to 3 doubles, global coordinates
00214      * of direction of local u coordinate axis at center vertex \param local_deg Integer, order of
00215      * local polynomial fitting \param local_coeffs Pointer to array of doubles,
00216      * size=3*(local_deg+1), coefficients of three local polynomial fittings, in monomial basis. For
00217      * each fitting, local_deg+1 parameters. \param interp Boolean, true=local fitting is
00218      * interpolation, false=local fitting is least square fitting \param npts2fit Integer, number of
00219      * points to be estimated, around the center vertices \param coords2fit Pointer to array of
00220      * doubles, size=3*npts2fit, current coordinates of points to be estimated \param hiproj_new
00221      * Pointer to array of doubles, size=3*npts2fit, memory preallocated by user to store the
00222      * fitting/estimated positions of input points.
00223      */
00224     void walf3d_curve_vertex_eval( const double* local_origin, const double* local_coords, const int local_deg,
00225                                    const double* local_coeffs, const bool interp, const int npts2fit,
00226                                    const double* coords2fit, double* hiproj_new );
00227 
00228     //! \brief Get interally stored fitting results
00229     /** Get fittings results of a vertex, stored internally, results will be writtend to user
00230      * provided memory \param vid EntityHandle, a vertex in _verts2rec \param geomtype GEOMTYPE, one
00231      * of HISURFACE,HI3DCURVE,HI2DCURVE \param coords vector, global coordinates of local uvw
00232      * coordinate system axis directions will be appended to the end of coords \param degree_out
00233      * Reference to Integer, order of polynomial fittings for vid \param coeffs vector, coefficients
00234      * of local polynomial fittings in monomial basis will be appended to the end of coeffs \param
00235      * interp Reference to Boolean, true =  interpolation
00236      */
00237     bool get_fittings_data( EntityHandle vid, GEOMTYPE& geomtype, std::vector< double >& coords, int& degree_out,
00238                             std::vector< double >& coeffs, bool& interp );
00239 
00240     // Helper function: estimate require number of ghost layers in parallel setting
00241     static int estimate_num_ghost_layers( int degree, bool interp = false )
00242     {
00243         return 1 + ( interp ? ( ( degree + 1 ) >> 1 ) + ( ( degree + 1 ) & 1 )
00244                             : ( ( degree + 2 ) >> 1 ) + ( ( degree + 2 ) & 1 ) );
00245     };
00246 
00247   protected:
00248     Core* mbImpl;
00249     ParallelComm* pcomm;
00250     HalfFacetRep* ahf;
00251     // prevent copying
00252     HiReconstruction( const HiReconstruction& source );
00253     HiReconstruction& operator=( const HiReconstruction& right );
00254 
00255     // mesh on which to perform reconstruction
00256     EntityHandle _mesh2rec;
00257     //_verts2rec all locally hosted vertices, in parallel might be different from _invert which is
00258     // all the vertices in _mesh2rec, including ghost vertices
00259     Range _verts2rec, _inverts, _inedges, _infaces, _incells;
00260     size_t _nv2rec;  // size of _verts2rec
00261 
00262     int _MAXPNTS, _MINPNTS;
00263     double _MINEPS;
00264 
00265     // in curve mesh, _hasderiv=true means vertex tangent vectors have been computed over _verts2rec
00266     // in surface mesh, _hasderiv=true means vertex normals have been computed over _verts2rec
00267     bool _hasderiv;
00268 
00269     GEOMTYPE _geom;
00270     int _dim;
00271     bool _hasfittings;
00272     bool _initfittings;
00273     std::vector< double > _local_coords;
00274     std::vector< double > _local_fit_coeffs;
00275     std::vector< size_t > _vertID2coeffID;
00276     std::vector< int > _degrees_out;
00277     std::vector< bool > _interps;
00278 
00279     // Estimate stencil size
00280     int estimate_num_rings( int degree, bool interp );
00281 
00282     //! \brief Given a vertex, return the incident elements with dimension elemdim
00283     /** Wrapper of MOAB Core->get_adjacencies and HalfRep->get_up_adjacencies, depends on if USE_AHF
00284      * is defined \param vid EntityHandle of vertex \param elemdim Integer, dimension of elements
00285      * incidented in vid \param adjents vector<EntityHandle>, container which push incident elements
00286      * in
00287      */
00288     ErrorCode vertex_get_incident_elements( const EntityHandle& vid, const int elemdim,
00289                                             std::vector< EntityHandle >& adjents );
00290 
00291     //! \brief Get n-ring neighbor vertices, assuming curve/surface mesh, not volume mesh
00292     /** Given a vertex, find its n-ring neighbor vertices including itself in _mesrh2rec.
00293      * 1-ring neighbor vertices of a vertex are the vertices connected with this vertex with an edge
00294      * n-ring vertices are obtained first get the 1-ring vertices and then get the 1-ring of these
00295      * vertices, and so on \param vid EntityHandle, vertex around which to get n-ring vertices
00296      * \param ring Integer, number of rings
00297      * \param minpnts Integer, number of minimum vertices to obtain, if the input ring could not
00298      * provide enough vertices, i.e. more than minpnts, then expand the number of rings \param ngbvs
00299      * Range, the n-ring vertices of vid, including vid. If too many points found, i.e. more than
00300      * _MAXPNTS, then terminate early.
00301      */
00302     ErrorCode obtain_nring_ngbvs( const EntityHandle vid, int ring, const int minpnts, Range& ngbvs );
00303 
00304     /** Initialize the storage for fitting results over _mesh2rec, curve/surface mesh
00305      * Two options are provided: a) use uniform degree for all vertices b) use customized degrees
00306      * for different vertices After calling of initializing functions, _initfitting is set to be
00307      * true, the fitting result could be stored internally
00308      */
00309     void initialize_surf_geom( const int degree );
00310     void initialize_surf_geom( const size_t npts, const int* degrees );
00311     void initialize_3Dcurve_geom( const int degree );
00312     void initialize_3Dcurve_geom( const size_t npts, const int* degrees );
00313 
00314     /** Save fitting results of a vertex into internal storage
00315      * \param vid EntityHandle, a vertex in _mesh2rec, in _verts2rec
00316      * \param coords Pointer to double array, global coordinates of local uvw coordinate system axis
00317      * directions \param degree_out Integer, order of polynomial fittings for vid \param coeffs
00318      * Pointer to double array, coefficients of local polynomial fittings in monomial basis \param
00319      * interp Boolean, true =  interpolation
00320      */
00321     // ErrorCode set_geom_data_surf(const EntityHandle vid, const double* coords, const double
00322     // degree_out, const double* coeffs, bool interp); ErrorCode set_geom_data_3Dcurve(const
00323     // EntityHandle vid, const double* coords, const double degree_out, const double* coeffs, bool
00324     // interp);
00325 
00326     /** Compute area weighted average vertex normals for given vertex, assuming surface mesh
00327      * For arbitrary polygon mesh, use incident two edges of each incident polygon of this vertex to
00328      * form a triangle, then use these incident "triangles" to compute area weighted average vertex
00329      * normals \param vid EntityHandle, vertex in _mesh2rec, might be ghost vertex \param nrm
00330      * Pointer to 3-doubles array, preallocated by user
00331      */
00332     ErrorCode average_vertex_normal( const EntityHandle vid, double* nrm );
00333 
00334     /** Compute weighted average vertex normals for all vertices in _verts2rec, not including ghost
00335      * vertices, results are stored interally in _local_coords
00336      */
00337     ErrorCode compute_average_vertex_normals_surf();
00338 
00339     /** Return the normals of given vertices in a Range, writing to preallocated memory
00340      * If normals have been computed and stored, just access them
00341      * If not, compute on the fly
00342      * \param vertsh Range, EntityHandles of vertices
00343      * \param nrms Pointer of array of doubles, size = 3*vertsh.size()
00344      */
00345     ErrorCode get_normals_surf( const Range& vertsh, double* nrms );
00346 
00347     /** Compute area weighted average vertex tangent vector for given vertex, assuming curve mesh
00348      * Use incident two edges of vertex as estimatation of tangent vectors, weighted by length
00349      * \param vid EntityHandle, vertex in _mesh2rec, might be ghost vertex
00350      * \param tang Pointer to 3-doubles array, preallocated by user
00351      */
00352     ErrorCode average_vertex_tangent( const EntityHandle vid, double* tang );
00353 
00354     /** Compute weighted average vertex tangent vectors for all vertices in _verts2rec, not
00355      * including ghost vertices, results are stored interally in _local_coords
00356      */
00357     ErrorCode compute_average_vertex_tangents_curve();
00358 
00359     /** Return the tangent vectors of given vertices in a Range, writing to preallocated memory
00360      * If tangent vectors have been computed and stored, just access them
00361      * If not, compute on the fly
00362      * \param vertsh Range, EntityHandles of vertices
00363      * \param tangs Pointer of array of doubles, size = 3*vertsh.size()
00364      */
00365     ErrorCode get_tangents_curve( const Range& vertsh, double* tangs );
00366 
00367     //! \brief Compute local coordinates system of a vertex, and perform vertex based polynomial
00368     //! fittings of local height function
00369     /** This function take the first vertex of input as center, and build local uv-plane by
00370      * estimating vertex normals and tangent planes Then other vertices forms vectors starting from
00371      * center and then are projectd onto this uv-plane to form a local height function. Local
00372      * fitting of this local height function is performed in WLS sense, according if interpolation
00373      * required or not. \param nverts Integer, number of vertices of input \param ngbcors Pointer to
00374      * array of doubles, size = 3*nverts, coordinates of input vertices, first will be center \param
00375      * ngbnrms Pointer to array of doubles, size = 3*nverts, vertex normals of input vertices \param
00376      * degree Integer, user specified fitting degree \param interp Boolean, user input,
00377      * interpolation or not \param safeguard Boolean, true = use safeguarded numerical method in
00378      * computing \param ncoords Integer, size of *coords, should be 9, used for check \param coords
00379      * Pointer to array of doubles, preallocated memory for storing the glocal coordinates of local
00380      * uvw axis directions \param ncoeffs Integer, size of *coeffs, should be
00381      * (degree+2)(degree+1)/2, used for check \param coeffs Pointer to array of doubles,
00382      * preallocated memory for storing coefficients of local fittings in monomial basis \param
00383      * degree_out Pointer to integer, order of resulted polynomial of fitting, could be downgraded
00384      * due to numerical issues \param degree_pnt Pointer to integer, polynomial fitting order
00385      * determined by stencil size/number of points \param degree_qr Pointer to integer, polynomial
00386      * fitting order determined by Vandermonde system condition number
00387      */
00388     void polyfit3d_surf_get_coeff( const int nverts, const double* ngbcors, const double* ngbnrms, int degree,
00389                                    const bool interp, const bool safeguard, const int ncoords, double* coords,
00390                                    const int ncoeffs, double* coeffs, int* degree_out, int* degree_pnt,
00391                                    int* degree_qr );
00392     //! \brief Form and solve Vandermonde system of bi-variables
00393     void eval_vander_bivar_cmf( const int npts2fit, const double* us, const int ndim, double* bs, int degree,
00394                                 const double* ws, const bool interp, const bool safeguard, int* degree_out,
00395                                 int* degree_pnt, int* degree_qr );
00396 
00397     //! \brief Compute local single variable coordinate system of a vertex, and perform vertex based
00398     //! polynomial fittings of three global coordinates axis
00399     /** This function take the first vertex of input as center, and build local u-line by estimating
00400      * tangent vector Then other vertices form vectors originating from center and vectors then are
00401      * projectd onto this u-plane to form three local height functions, one for each coordinates
00402      * axis. Local fitting of these local height functions are performed in WLS sense, according if
00403      * interpolation required or not. \param nverts Integer, number of vertices of input \param
00404      * ngbcors Pointer to array of doubles, size = 3*nverts, coordinates of input vertices, first
00405      * will be center \param ngbtangs Pointer to array of doubles, size = 3*nverts, vertex tangent
00406      * vectors of input vertices \param degree Integer, user specified fitting degree \param interp
00407      * Boolean, user input, interpolation or not \param safeguard Boolean, true = use safeguarded
00408      * numerical method in computing \param ncoords Integer, size of *coords, should be 3, used for
00409      * check \param coords Pointer to array of doubles, preallocated memory for storing the glocal
00410      * coordinates of local u axis direction \param ncoeffs Integer, size of *coeffs, should be
00411      * 3*(degree+1), used for check \param coeffs Pointer to array of doubles, preallocated memory
00412      * for storing coefficients of local fittings in monomial basis \param degree_out Pointer to
00413      * integer, order of resulted polynomial of fitting, could be downgraded due to numerical issues
00414      */
00415     void polyfit3d_curve_get_coeff( const int nverts, const double* ngbcors, const double* ngbtangs, int degree,
00416                                     const bool interp, const bool safeguard, const int ncoords, double* coords,
00417                                     const int ncoeffs, double* coeffs, int* degree_out );
00418     //! \brief Form and solve Vandermonde system of single-variables
00419     void eval_vander_univar_cmf( const int npts2fit, const double* us, const int ndim, double* bs, int degree,
00420                                  const double* ws, const bool interp, const bool safeguard, int* degree_out );
00421     //! \brief Compute weights for points selected in weighted least square fittigns
00422     int compute_weights( const int nrows, const int ncols, const double* us, const int nngbs, const double* ngbnrms,
00423                          const int degree, const double toler, double* ws );
00424     //! \brief Check the correctness of barycentric coordination, wi>=0 and sum(wi)=1
00425     bool check_barycentric_coords( const int nws, const double* naturalcoords );
00426 };  // class HiReconstruction
00427 }  // namespace moab
00428 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines