BRL-CAD
FittingSurface Class Reference

Fitting a B-Spline surface to 3D point-clouds using point-distance-minimization Based on paper: TODO. More...

#include <opennurbs_fit.h>

Collaboration diagram for FittingSurface:
[legend]

Data Structures

class  myvec
 
struct  Parameter
 Parameters for fitting. More...
 

Public Member Functions

 FittingSurface (NurbsDataSurface *data, const ON_NurbsSurface &ns)
 Constructor initializing with the B-Spline surface given in argument 2. More...
 
 FittingSurface (int order, NurbsDataSurface *data, ON_3dVector z=ON_3dVector(0.0, 0.0, 1.0))
 Constructor initializing B-Spline surface using initNurbsPCA(...). More...
 
void refine (int dim)
 Refines surface by inserting a knot in the middle of each element. More...
 
virtual void assemble (Parameter param=Parameter())
 Assemble the system of equations for fitting. More...
 
virtual void solve (double damp=1.0)
 Solve system of equations using Eigen or UmfPack (can be defined in on_nurbs.cmake), and updates B-Spline surface if a solution can be obtained. More...
 
virtual void updateSurf (double damp)
 Update surface according to the current system of equations. More...
 
void setInvMapParams (unsigned in_max_steps, double in_accuracy)
 Set parameters for inverse mapping. More...
 
void setQuiet (bool val)
 Enable/Disable debug outputs in console. More...
 

Static Public Member Functions

static std::vector< double > getElementVector (const ON_NurbsSurface &nurbs, int dim)
 Get the elements of a B-Spline surface. More...
 
static ON_2dPoint inverseMapping (const ON_NurbsSurface &nurbs, const ON_3dPoint &pt, const ON_2dPoint &hint, double &error, ON_3dPoint &p, ON_3dVector &tu, ON_3dVector &tv, int maxSteps=100, double accuracy=1e-6, bool quiet=true)
 Inverse mapping / point inversion: Given a point pt, this function finds the closest point on the B-Spline surface using Newtons method and point-distance (L2-, Euclidean norm). More...
 
static ON_2dPoint findClosestElementMidPoint (const ON_NurbsSurface &nurbs, const ON_3dPoint &pt)
 Given a point pt, the function finds the closest midpoint of the elements of the surface. More...
 
static ON_2dPoint inverseMappingBoundary (const ON_NurbsSurface &nurbs, const ON_3dPoint &pt, double &error, ON_3dPoint &p, ON_3dVector &tu, ON_3dVector &tv, int maxSteps=100, double accuracy=1e-6, bool quiet=true)
 Inverse mapping / point inversion: Given a point pt, this function finds the closest point on the boundary of the B-Spline surface using Newtons method and point-distance (L2-, Euclidean norm). More...
 
static ON_2dPoint inverseMappingBoundary (const ON_NurbsSurface &nurbs, const ON_3dPoint &pt, int side, double hint, double &error, ON_3dPoint &p, ON_3dVector &tu, ON_3dVector &tv, int maxSteps=100, double accuracy=1e-6, bool quiet=true)
 Inverse mapping / point inversion: Given a point pt, this function finds the closest point on one side of the boundary of the B-Spline surface using Newtons method and point-distance (L2-, Euclidean norm). More...
 
static ON_NurbsSurface initNurbs4Corners (int order, ON_3dPoint ll, ON_3dPoint lr, ON_3dPoint ur, ON_3dPoint ul)
 Initializing a B-Spline surface using 4 corners. More...
 
static ON_NurbsSurface initNurbsPCA (int order, NurbsDataSurface *data, ON_3dVector z=ON_3dVector(0.0, 0.0, 1.0))
 Initializing a B-Spline surface using principal-component-analysis and eigen values. More...
 
static ON_NurbsSurface initNurbsPCABoundingBox (int order, NurbsDataSurface *data, ON_3dVector z=ON_3dVector(0.0, 0.0, 1.0))
 Initializing a B-Spline surface using principal-component-analysis and bounding box of points. More...
 

Data Fields

ON_NurbsSurface m_nurbs
 
NurbsDataSurfacem_data
 

Protected Member Functions

void init ()
 Initialisation of member variables. More...
 
virtual void assembleInterior (double wInt, unsigned &row)
 Assemble point-to-surface constraints for interior points. More...
 
virtual void assembleBoundary (double wBnd, unsigned &row)
 Assemble point-to-surface constraints for boundary points. More...
 
virtual void addPointConstraint (const ON_2dVector &params, const ON_3dPoint &point, double weight, unsigned &row)
 Add minimization constraint: point-to-surface distance (point-distance-minimization). More...
 
virtual void addCageInteriorRegularisation (double weight, unsigned &row)
 Add minimization constraint: interior smoothness by control point regularisation. More...
 
virtual void addCageBoundaryRegularisation (double weight, int side, unsigned &row)
 Add minimization constraint: boundary smoothness by control point regularisation. More...
 
virtual void addCageCornerRegularisation (double weight, unsigned &row)
 Add minimization constraint: corner smoothness by control point regularisation. More...
 
virtual void addInteriorRegularisation (int order, int resU, int resV, double weight, unsigned &row)
 Add minimization constraint: interior smoothness by derivatives regularisation. More...
 
virtual void addBoundaryRegularisation (int order, int resU, int resV, double weight, unsigned &row)
 Add minimization constraint: boundary smoothness by derivatives regularisation. More...
 
int grc2gl (int I, int J)
 
int lrc2gl (int E, int F, int i, int j)
 
int gl2gr (int A)
 
int gl2gc (int A)
 

Protected Attributes

NurbsSolve m_solver
 
bool m_quiet
 
std::vector< double > m_elementsU
 
std::vector< double > m_elementsV
 
double m_minU
 
double m_minV
 
double m_maxU
 
double m_maxV
 
int in_max_steps
 
double in_accuracy
 

Detailed Description

Fitting a B-Spline surface to 3D point-clouds using point-distance-minimization Based on paper: TODO.

Author
Thomas Moerwald

Definition at line 314 of file opennurbs_fit.h.

Constructor & Destructor Documentation

FittingSurface ( NurbsDataSurface data,
const ON_NurbsSurface &  ns 
)

Constructor initializing with the B-Spline surface given in argument 2.

Parameters
[in]datapointer to the 3D point-cloud data to be fit.
[in]nsB-Spline surface used for fitting.

Definition at line 406 of file opennurbs_fit.cpp.

References FittingSurface::init(), FittingSurface::m_data, and FittingSurface::m_nurbs.

Here is the call graph for this function:

FittingSurface ( int  order,
NurbsDataSurface data,
ON_3dVector  z = ON_3dVector(0.0, 0.0, 1.0) 
)

Constructor initializing B-Spline surface using initNurbsPCA(...).

Parameters
[in]orderthe polynomial order of the B-Spline surface.
[in]datapointer to the 2D point-cloud data to be fit.
[in]zvector defining front face of surface.

Definition at line 392 of file opennurbs_fit.cpp.

References FittingSurface::init(), FittingSurface::initNurbsPCA(), FittingSurface::m_data, and FittingSurface::m_nurbs.

Here is the call graph for this function:

Member Function Documentation

void refine ( int  dim)

Refines surface by inserting a knot in the middle of each element.

Parameters
[in]dimdimension of refinement (0, 1)

Definition at line 418 of file opennurbs_fit.cpp.

References FittingSurface::getElementVector(), FittingSurface::m_elementsU, FittingSurface::m_elementsV, FittingSurface::m_maxU, FittingSurface::m_maxV, FittingSurface::m_minU, FittingSurface::m_minV, and FittingSurface::m_nurbs.

Referenced by main().

Here is the call graph for this function:

void solve ( double  damp = 1.0)
virtual

Solve system of equations using Eigen or UmfPack (can be defined in on_nurbs.cmake), and updates B-Spline surface if a solution can be obtained.

Definition at line 535 of file opennurbs_fit.cpp.

References FittingSurface::m_solver, NurbsSolve::solve(), and FittingSurface::updateSurf().

Referenced by main().

Here is the call graph for this function:

void updateSurf ( double  damp)
virtual

Update surface according to the current system of equations.

Parameters
[in]dampdamping factor from one iteration to the other.

Definition at line 543 of file opennurbs_fit.cpp.

References A, FittingSurface::gl2gc(), FittingSurface::gl2gr(), OSL::Strings::I, FittingSurface::m_nurbs, FittingSurface::m_solver, and NurbsSolve::x().

Referenced by FittingSurface::solve().

Here is the call graph for this function:

void setInvMapParams ( unsigned  in_max_steps,
double  in_accuracy 
)

Set parameters for inverse mapping.

Parameters
[in]in_max_stepsmaximum number of iterations.
[in]in_accuracystops iteration if specified accuracy is reached.

Definition at line 568 of file opennurbs_fit.cpp.

References FittingSurface::in_accuracy, and FittingSurface::in_max_steps.

std::vector< double > getElementVector ( const ON_NurbsSurface &  nurbs,
int  dim 
)
static
ON_2dPoint inverseMapping ( const ON_NurbsSurface &  nurbs,
const ON_3dPoint &  pt,
const ON_2dPoint &  hint,
double &  error,
ON_3dPoint &  p,
ON_3dVector &  tu,
ON_3dVector &  tv,
int  maxSteps = 100,
double  accuracy = 1e-6,
bool  quiet = true 
)
static

Inverse mapping / point inversion: Given a point pt, this function finds the closest point on the B-Spline surface using Newtons method and point-distance (L2-, Euclidean norm).

Parameters
[in]nurbsthe B-Spline surface.
[in]ptthe point to which the closest point on the surface will be computed.
[in]hintthe starting point in parametric domain (warning: may lead to convergence at local minima).
[in]errorthe distance between the point pt and p after convergence.
[in]pclosest point on surface.
[in]tuthe tangent vector at point p in u-direction.
[in]tvthe tangent vector at point p in v-direction.
[in]maxStepsmaximum number of iterations.
[in]accuracyconvergence criteria: if error is lower than accuracy the function returns
Returns
closest point on surface in parametric domain.

Definition at line 1220 of file opennurbs_fit.cpp.

References A, delta, and FittingSurface::getElementVector().

Referenced by FittingSurface::assembleInterior().

Here is the call graph for this function:

ON_2dPoint findClosestElementMidPoint ( const ON_NurbsSurface &  nurbs,
const ON_3dPoint &  pt 
)
static

Given a point pt, the function finds the closest midpoint of the elements of the surface.

Parameters
[in]nurbsthe B-Spline surface.
[in]ptthe point to which the closest midpoint of the elements will be computed. return closest midpoint in parametric domain.

Definition at line 1302 of file opennurbs_fit.cpp.

References FittingSurface::getElementVector().

Referenced by FittingSurface::assembleInterior().

Here is the call graph for this function:

ON_2dPoint inverseMappingBoundary ( const ON_NurbsSurface &  nurbs,
const ON_3dPoint &  pt,
double &  error,
ON_3dPoint &  p,
ON_3dVector &  tu,
ON_3dVector &  tv,
int  maxSteps = 100,
double  accuracy = 1e-6,
bool  quiet = true 
)
static

Inverse mapping / point inversion: Given a point pt, this function finds the closest point on the boundary of the B-Spline surface using Newtons method and point-distance (L2-, Euclidean norm).

Parameters
[in]nurbsthe B-Spline surface.
[in]ptthe point to which the closest point on the surface will be computed.
[in]errorthe distance between the point pt and p after convergence.
[in]pclosest boundary point on surface.
[in]tuthe tangent vector at point p in u-direction.
[in]tvthe tangent vector at point p in v-direction.
[in]maxStepsmaximum number of iterations.
[in]accuracyconvergence criteria: if error is lower than accuracy the function returns
Returns
closest point on surface in parametric domain.

Definition at line 1338 of file opennurbs_fit.cpp.

References on_fit::EAST, FittingSurface::getElementVector(), on_fit::NORTH, on_fit::SOUTH, and on_fit::WEST.

Referenced by FittingSurface::assembleBoundary().

Here is the call graph for this function:

ON_2dPoint inverseMappingBoundary ( const ON_NurbsSurface &  nurbs,
const ON_3dPoint &  pt,
int  side,
double  hint,
double &  error,
ON_3dPoint &  p,
ON_3dVector &  tu,
ON_3dVector &  tv,
int  maxSteps = 100,
double  accuracy = 1e-6,
bool  quiet = true 
)
static

Inverse mapping / point inversion: Given a point pt, this function finds the closest point on one side of the boundary of the B-Spline surface using Newtons method and point-distance (L2-, Euclidean norm).

Parameters
[in]nurbsthe B-Spline surface.
[in]ptthe point to which the closest point on the surface will be computed.
[in]sidethe side of the boundary (NORTH, SOUTH, EAST, WEST)
[in]hintthe starting point in parametric domain (warning: may lead to convergence at local minima).
[in]errorthe distance between the point pt and p after convergence.
[in]pclosest boundary point on surface.
[in]tuthe tangent vector at point p in u-direction.
[in]tvthe tangent vector at point p in v-direction.
[in]maxStepsmaximum number of iterations.
[in]accuracyconvergence criteria: if error is lower than accuracy the function returns
Returns
closest point on surface in parametric domain.

Definition at line 1385 of file opennurbs_fit.cpp.

References delta, on_fit::EAST, FittingSurface::getElementVector(), on_fit::NORTH, on_fit::SOUTH, and on_fit::WEST.

Here is the call graph for this function:

ON_NurbsSurface initNurbs4Corners ( int  order,
ON_3dPoint  ll,
ON_3dPoint  lr,
ON_3dPoint  ur,
ON_3dPoint  ul 
)
static

Initializing a B-Spline surface using 4 corners.

Definition at line 685 of file opennurbs_fit.cpp.

ON_NurbsSurface initNurbsPCA ( int  order,
NurbsDataSurface data,
ON_3dVector  z = ON_3dVector(0.0, 0.0, 1.0) 
)
static

Initializing a B-Spline surface using principal-component-analysis and eigen values.

Definition at line 721 of file opennurbs_fit.cpp.

References NurbsDataSurface::interior, NurbsDataSurface::mean, NurbsTools::pca(), and s.

Referenced by FittingSurface::FittingSurface().

Here is the call graph for this function:

ON_NurbsSurface initNurbsPCABoundingBox ( int  order,
NurbsDataSurface data,
ON_3dVector  z = ON_3dVector(0.0, 0.0, 1.0) 
)
static

Initializing a B-Spline surface using principal-component-analysis and bounding box of points.

Definition at line 777 of file opennurbs_fit.cpp.

References NurbsDataSurface::interior, NurbsDataSurface::interior_param, NurbsDataSurface::mean, NurbsTools::pca(), and s.

Referenced by main().

Here is the call graph for this function:

void setQuiet ( bool  val)
inline

Enable/Disable debug outputs in console.

Definition at line 472 of file opennurbs_fit.h.

References FittingSurface::m_quiet, FittingSurface::m_solver, and NurbsSolve::setQuiet().

Here is the call graph for this function:

void init ( )
protected

Initialisation of member variables.

Definition at line 518 of file opennurbs_fit.cpp.

References FittingSurface::getElementVector(), FittingSurface::in_accuracy, FittingSurface::in_max_steps, FittingSurface::m_elementsU, FittingSurface::m_elementsV, FittingSurface::m_maxU, FittingSurface::m_maxV, FittingSurface::m_minU, FittingSurface::m_minV, FittingSurface::m_nurbs, and FittingSurface::m_quiet.

Referenced by FittingSurface::FittingSurface().

Here is the call graph for this function:

void assembleInterior ( double  wInt,
unsigned &  row 
)
protectedvirtual
void assembleBoundary ( double  wBnd,
unsigned &  row 
)
protectedvirtual
void addPointConstraint ( const ON_2dVector &  params,
const ON_3dPoint &  point,
double  weight,
unsigned &  row 
)
protectedvirtual

Add minimization constraint: point-to-surface distance (point-distance-minimization).

Definition at line 858 of file opennurbs_fit.cpp.

References NurbsSolve::f(), NurbsSolve::K(), FittingSurface::lrc2gl(), FittingSurface::m_nurbs, and FittingSurface::m_solver.

Referenced by FittingSurface::assembleBoundary(), and FittingSurface::assembleInterior().

Here is the call graph for this function:

void addCageInteriorRegularisation ( double  weight,
unsigned &  row 
)
protectedvirtual

Add minimization constraint: interior smoothness by control point regularisation.

Definition at line 893 of file opennurbs_fit.cpp.

References NurbsSolve::f(), FittingSurface::grc2gl(), NurbsSolve::K(), FittingSurface::m_nurbs, and FittingSurface::m_solver.

Referenced by FittingSurface::assemble().

Here is the call graph for this function:

void addCageBoundaryRegularisation ( double  weight,
int  side,
unsigned &  row 
)
protectedvirtual

Add minimization constraint: boundary smoothness by control point regularisation.

Definition at line 915 of file opennurbs_fit.cpp.

References on_fit::EAST, NurbsSolve::f(), FittingSurface::grc2gl(), NurbsSolve::K(), FittingSurface::m_nurbs, FittingSurface::m_solver, on_fit::NORTH, on_fit::SOUTH, and on_fit::WEST.

Referenced by FittingSurface::assemble().

Here is the call graph for this function:

void addCageCornerRegularisation ( double  weight,
unsigned &  row 
)
protectedvirtual

Add minimization constraint: corner smoothness by control point regularisation.

Definition at line 959 of file opennurbs_fit.cpp.

References NurbsSolve::f(), FittingSurface::grc2gl(), NurbsSolve::K(), FittingSurface::m_nurbs, and FittingSurface::m_solver.

Referenced by FittingSurface::assemble().

Here is the call graph for this function:

void addInteriorRegularisation ( int  order,
int  resU,
int  resV,
double  weight,
unsigned &  row 
)
protectedvirtual

Add minimization constraint: interior smoothness by derivatives regularisation.

Definition at line 1025 of file opennurbs_fit.cpp.

References NurbsSolve::f(), FittingSurface::m_maxU, FittingSurface::m_maxV, FittingSurface::m_minU, FittingSurface::m_minV, FittingSurface::m_nurbs, FittingSurface::m_solver, OSL::Strings::u, and OSL::Strings::v.

Referenced by FittingSurface::assemble().

Here is the call graph for this function:

void addBoundaryRegularisation ( int  order,
int  resU,
int  resV,
double  weight,
unsigned &  row 
)
protectedvirtual

Add minimization constraint: boundary smoothness by derivatives regularisation.

Definition at line 1075 of file opennurbs_fit.cpp.

References NurbsSolve::f(), NurbsSolve::K(), FittingSurface::lrc2gl(), FittingSurface::m_maxU, FittingSurface::m_maxV, FittingSurface::m_minU, FittingSurface::m_minV, FittingSurface::m_nurbs, FittingSurface::m_solver, OSL::Strings::u, and OSL::Strings::v.

Referenced by FittingSurface::assemble().

Here is the call graph for this function:

int lrc2gl ( int  E,
int  F,
int  i,
int  j 
)
inlineprotected

Definition at line 539 of file opennurbs_fit.h.

References FittingSurface::grc2gl().

Referenced by FittingSurface::addBoundaryRegularisation(), and FittingSurface::addPointConstraint().

Here is the call graph for this function:

int gl2gr ( int  A)
inlineprotected

Definition at line 544 of file opennurbs_fit.h.

Referenced by FittingSurface::updateSurf().

int gl2gc ( int  A)
inlineprotected

Definition at line 549 of file opennurbs_fit.h.

Referenced by FittingSurface::updateSurf().

Field Documentation

bool m_quiet
protected
std::vector<double> m_elementsU
protected

Definition at line 521 of file opennurbs_fit.h.

Referenced by FittingSurface::init(), and FittingSurface::refine().

std::vector<double> m_elementsV
protected

Definition at line 522 of file opennurbs_fit.h.

Referenced by FittingSurface::init(), and FittingSurface::refine().


The documentation for this class was generated from the following files: