<commit_before>.. _bspline_fitting:

Fitting trimmed B-splines to unordered point clouds
---------------------------------------------------

This tutorial explains how to run a B-spline fitting algorithm on a
point-cloud, to obtain a smooth, parametric surface representation.
The algorithm consists of the following steps:

* Initialization of the B-spline surface by using the Principal Component Analysis (PCA). This
  assumes that the point-cloud has two main orientations, i.e. that it is roughly planar.

* Refinement and fitting of the B-spline surface.

* Circular initialization of the B-spline curve. Here we assume that the point-cloud is
  compact, i.e. no separated clusters.

* Fitting of the B-spline curve.

* Triangulation of the trimmed B-spline surface.

In this video, the algorithm is applied to the frontal scan of the stanford bunny (204800 points):

.. raw:: html

  <iframe title="Trimmed B-spline surface fitting" width="480" height="390" src="http://www.youtube.com/embed/trH2kWELvyw?rel=0" frameborder="0" allowfullscreen></iframe>


Theoretical background
----------------------

Theoretical information on the algorithm can be found in this `report
<http://pointclouds.org/blog/trcs/moerwald/index.php>`_ and in my `PhD thesis
<http://users.acin.tuwien.ac.at/tmoerwald/?site=3>`_.


PCL installation settings
-------------------------

Please note that the modules for NURBS and B-splines are not enabled by default.
Make sure you enable "BUILD_surface_on_nurbs" in your ccmake configuration, by setting it to ON.

If your license permits, also enable "USE_UMFPACK" for sparse linear solving.
This requires SuiteSparse (libsuitesparse-dev in Ubuntu) which is faster, 
allows more degrees of freedom (i.e. control points) and more data points.

The program created during this tutorial is available in 
*pcl/examples/surface/example_nurbs_fitting_surface.cpp* and is built when
"BUILD_examples" is set to ON. This will create the binary called *pcl_example_nurbs_fitting_surface*
in your *bin* folder.


The code
--------

The cpp file used in this tutorial can be found in *pcl/doc/tutorials/content/sources/bspline_fitting/bspline_fitting.cpp*.
You can find the input file at *pcl/test/bunny.pcd*.

.. literalinclude:: sources/bspline_fitting/bspline_fitting.cpp
   :language: cpp
   :linenos:
   :lines: 1-169

<commit_msg>add missing lines of code in bspline_fitting tutorial<commit_after>.. _bspline_fitting:

Fitting trimmed B-splines to unordered point clouds
---------------------------------------------------

This tutorial explains how to run a B-spline fitting algorithm on a
point-cloud, to obtain a smooth, parametric surface representation.
The algorithm consists of the following steps:

* Initialization of the B-spline surface by using the Principal Component Analysis (PCA). This
  assumes that the point-cloud has two main orientations, i.e. that it is roughly planar.

* Refinement and fitting of the B-spline surface.

* Circular initialization of the B-spline curve. Here we assume that the point-cloud is
  compact, i.e. no separated clusters.

* Fitting of the B-spline curve.

* Triangulation of the trimmed B-spline surface.

In this video, the algorithm is applied to the frontal scan of the stanford bunny (204800 points):

.. raw:: html

  <iframe title="Trimmed B-spline surface fitting" width="480" height="390" src="http://www.youtube.com/embed/trH2kWELvyw?rel=0" frameborder="0" allowfullscreen></iframe>


Theoretical background
----------------------

Theoretical information on the algorithm can be found in this `report
<http://pointclouds.org/blog/trcs/moerwald/index.php>`_ and in my `PhD thesis
<http://users.acin.tuwien.ac.at/tmoerwald/?site=3>`_.


PCL installation settings
-------------------------

Please note that the modules for NURBS and B-splines are not enabled by default.
Make sure you enable "BUILD_surface_on_nurbs" in your ccmake configuration, by setting it to ON.

If your license permits, also enable "USE_UMFPACK" for sparse linear solving.
This requires SuiteSparse (libsuitesparse-dev in Ubuntu) which is faster, 
allows more degrees of freedom (i.e. control points) and more data points.

The program created during this tutorial is available in 
*pcl/examples/surface/example_nurbs_fitting_surface.cpp* and is built when
"BUILD_examples" is set to ON. This will create the binary called *pcl_example_nurbs_fitting_surface*
in your *bin* folder.


The code
--------

The cpp file used in this tutorial can be found in *pcl/doc/tutorials/content/sources/bspline_fitting/bspline_fitting.cpp*.
You can find the input file at *pcl/test/bunny.pcd*.

.. literalinclude:: sources/bspline_fitting/bspline_fitting.cpp
   :language: cpp
   :linenos:
   :lines: 1-220


{'fraction_non_alphanumeric': 0.11616161616161616, 'fraction_numerical': 0.008417508417508417, 'mean_word_length': 3.6235408560311284, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6707320', 'n_tokens_mistral': 1459, 'n_tokens_neox': 1356, 'n_words': 547}