G+Smo  23.12.0
Geometry + Simulation Modules
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
gsHFitting< d, T > Class Template Reference

Detailed Description

template<short_t d, class T>
class gismo::gsHFitting< d, T >

This class applies hierarchical fitting of parametrized point clouds.

Template Parameters
Tcoefficient type
+ Inheritance diagram for gsHFitting< d, T >:
+ Collaboration diagram for gsHFitting< d, T >:

Public Member Functions

void applySmoothing (T lambda, gsSparseMatrix< T > &A_mat)
 
void assembleSystem (gsSparseMatrix< T > &A_mat, gsMatrix< T > &B)
 Assembles system for the least square fit.
 
void compute (T lambda=0)
 Computes the least squares fit for a gsBasis.
 
void computeApproxError (T &error, int type=0) const
 Computes the approximation error of the fitted curve to the original point cloud.
 
void computeErrors ()
 Computes the euclidean error for each point.
 
void computeMaxNormErrors ()
 Computes the maximum norm error for each point.
 
void get_Error (std::vector< T > &errors, int type=0) const
 return the errors for each point
 
const std::vector< unsigned > & get_extension () const
 Returns the chosen cell extension.
 
const gsBasis< T > & getBasis () const
 Returns the basis of the approximation.
 
std::vector< index_tgetBoxes (const std::vector< T > &errors, const T threshold)
 Returns boxes which define refinment area.
 
getRefPercentage () const
 Return the refinement percentage.
 
gsMatrix< T > & getreturnParamValues ()
 returns the parameter values
 
 gsHFitting ()
 Default constructor.
 
 gsHFitting (gsMatrix< T > const &param_values, gsMatrix< T > const &points, gsHTensorBasis< d, T > &basis, T refin, const std::vector< unsigned > &extension, T lambda=0)
 Main constructor of the fitting class. More...
 
void iterativeCompute (T const &tolerance, unsigned const &num_iters=10)
 Computes the least squares fit for a gsBasis.
 
void iterativeRefine (int iterations, T tolerance, T err_threshold=-1)
 iterative_refine iteratively refine the basis More...
 
maxPointError () const
 Returns the maximum point-wise error from the pount cloud (or zero if not fitted)
 
minPointError () const
 Returns the minimum point-wise error from the pount cloud (or zero if not fitted)
 
const gsMappedSpline< 2, T > & mresult () const
 gives back the computed approximation for multipatch geometry
 
bool nextIteration (T tolerance, T err_threshold, index_t maxPcIter=0)
 nextIteration One step of the refinement of iterative_refine(...); More...
 
bool nextIteration (T tolerance, T err_threshold, const std::vector< boxSide > &fixedSides, index_t maxPcIter=0)
 Like nextIteration without fixedSides but keeping the values on these sides unchanged throughout the fit.
 
size_t numPointsBelow (T threshold) const
 Computes the number of points below the error threshold (or zero if not fitted)
 
const std::vector< T > & pointWiseErrors () const
 Return the errors for each point.
 
gsGeometry< T > * result () const
 gives back the computed approximation
 
gsMatrix< T > returnPoints () const
 returns the points
 
void setConstraints (const gsSparseMatrix< T > &lhs, const gsMatrix< T > &rhs)
 
void setConstraints (const std::vector< index_t > &indices, const std::vector< gsMatrix< T > > &coefs)
 
void setConstraints (const std::vector< boxSide > &fixedSides)
 
void setConstraints (const std::vector< boxSide > &fixedSides, const std::vector< gsBSpline< T > > &fixedCurves)
 
void setExtension (std::vector< unsigned > const &extension)
 Sets the cell extension.
 
void setRefPercentage (double refPercent)
 Sets the refinement percentage.
 

Protected Member Functions

virtual void appendBox (std::vector< index_t > &boxes, std::vector< index_t > &cells, const gsVector< T > &parameter)
 
setRefineThreshold (const std::vector< T > &errors)
 Identifies the threshold from where we should refine.
 

Static Protected Member Functions

static void append (std::vector< index_t > &boxes, const gsVector< index_t > &box)
 Appends a box to the end of boxes (This function also works for cells)
 
static bool isCellAlreadyInserted (const gsVector< index_t, d > &a_cell, const std::vector< index_t > &cells)
 Checks if a_cell is already inserted in container of cells.
 

Protected Attributes

gsFunctionSet< T > * m_basis
 Pointer keeping the basis.
 
gsSparseMatrix< T > m_constraintsLHS
 
gsMatrix< T > m_constraintsRHS
 
std::vector< unsigned > m_ext
 Size of the extension.
 
m_lambda
 Smoothing parameter.
 
m_max_error
 Maximum point-wise error.
 
m_min_error
 Minimum point-wise error.
 
gsMappedSpline< 2, T > m_mresult
 Pointer keeping the resulting multipatch geometry.
 
gsMatrix< T > m_param_values
 the parameter values of the point cloud
 
gsMatrix< T > m_points
 the points of the point cloud
 
m_ref
 How many % to refine - 0-1 interval.
 
gsGeometry< T > * m_result
 Pointer keeping the resulting geometry.
 

Constructor & Destructor Documentation

gsHFitting ( gsMatrix< T > const &  param_values,
gsMatrix< T > const &  points,
gsHTensorBasis< d, T > &  basis,
refin,
const std::vector< unsigned > &  extension,
lambda = 0 
)
inline

Main constructor of the fitting class.

Parameters
param_valuesa matrix containing the parameter values that parametrize the points
pointsThe points to be fitted
basisHiearchical basis to use for fitting
refinPercentage of errors to refine (if this strategy is chosen)
extensionExtension to apply to marked cells
lambdaSmoothing parameter

Member Function Documentation

void appendBox ( std::vector< index_t > &  boxes,
std::vector< index_t > &  cells,
const gsVector< T > &  parameter 
)
protectedvirtual

Appends a box around parameter to the boxes only if the box is not already in boxes

void applySmoothing ( lambda,
gsSparseMatrix< T > &  A_mat 
)
inherited

Adds to the matrix A_mat terms for minimization of second derivative, weighted with parameter lambda.

void iterativeRefine ( int  iterations,
tolerance,
err_threshold = -1 
)

iterative_refine iteratively refine the basis

Parameters
iterationsmaximum number of iterations
tolerance(>=0) if the max error is below the tolerance the refinement stops
err_thresholdif non negative all cells with errors bigger than the threshold are refined / If it is equal to -1 the m_ref percentage is used 0 = global refinement
bool nextIteration ( tolerance,
err_threshold,
index_t  maxPcIter = 0 
)

nextIteration One step of the refinement of iterative_refine(...);

Parameters
tolerance(>=0) if the maximum error is below the tolerance the refinement stops;
err_thresholdthe same as in iterative_refine(...).
void setConstraints ( const gsSparseMatrix< T > &  lhs,
const gsMatrix< T > &  rhs 
)
inlineinherited

Sets constraints that the coefficients of the resulting geometry have to conform to. More precisely, denoting the coefficient vector by x, it enforces lhs * x = rhs.

void setConstraints ( const std::vector< index_t > &  indices,
const std::vector< gsMatrix< T > > &  coefs 
)
inherited

Sets constraints on that the coefficients of the resulting geometry have to conform to.

Parameters
indicesindices (in the coefficient vector) of the prescribed coefficients.
coefsprescribed coefficients.
void setConstraints ( const std::vector< boxSide > &  fixedSides)
inherited

Sets constraints in such a way that the previous values at fixedSides of the geometry remain intact.

void setConstraints ( const std::vector< boxSide > &  fixedSides,
const std::vector< gsBSpline< T > > &  fixedCurves 
)
inherited

Set constraints in such a way that the resulting geometry on each of fixedSides will coincide with the corresponding curve in fixedCurves.

Member Data Documentation

gsSparseMatrix<T> m_constraintsLHS
protectedinherited

Left hand-side of the constraints that the coefficients of the resulting geometry have to conform to. This corresponds to matrix D in Prautzch, Boehm, Paluszny: Bezier and B-spline techniques, Section 4.7.

gsMatrix<T> m_constraintsRHS
protectedinherited

Right hand-side of the constraints that the coefficients of the resulting geometry have to conform to. This corresponds to vector q in Prautzch, Boehm, Paluszny: Bezier and B-spline techniques, Section 4.7.