iRoCS Toolbox  1.1.0
Public Types | Public Member Functions | Friends
atb::Polyline< Dim > Class Template Reference

The Polyline class provides a simple polyline representation of a BSpline for fast point to spline distance approximations. More...

#include <ATBPolyline.hh>

Collaboration diagram for atb::Polyline< Dim >:

Public Types

typedef std::map< double, PointT >::const_iterator PointConstIteratorT
 
typedef std::map< double, PointT >::iterator PointIteratorT
 
typedef blitz::TinyVector< double, Dim > PointT
 

Public Member Functions

 Polyline ()
 Default constructor. More...
 
 Polyline (Polyline< Dim > const &polyline)
 Copy constructor. More...
 
 ~Polyline ()
 Destructor. More...
 
double curveIntegral (double uStart=0.0, double uEnd=1.0) const
 Compute the curve integral along the poly line. More...
 
double distance (PointT const &point, double &uOpt) const
 Project the given point onto the polyline and get the distance to the polyline and the projected position along the curve parameterization. More...
 
void fitToSpline (BSpline< PointT > const &spline, double eps=1e-4)
 Make this polyline optimally fit the given BSpline. More...
 
void load (std::string const &fileName, std::string const &groupName, bool throwExceptions=false)
 Load the polyline with corresponding meta-data from an hdf5 file with given name, using the groupName provided. More...
 
void load (BlitzH5File const &inFile, std::string const &groupName)
 Load the polyline with corresponding meta-data from an hdf5 file with given name, using the groupName provided. More...
 
PointT operator() (double u) const
 Get the polyline position at curve length u. More...
 
Polyline< Dim > & operator= (Polyline< Dim > const &polyline)
 Copy assignment operator. More...
 
void save (std::string const &fileName, std::string const &groupName, bool throwExceptions=false) const
 Save the polyline with corresponding meta-data to an hdf5 file with given name, using the groupName provided. More...
 
void save (BlitzH5File &outFile, std::string const &groupName) const
 Save the polyline with corresponding meta-data to an hdf5 file with given name, using the groupName provided. More...
 

Friends

template<int Dim1>
std::ostream & operator<< (std::ostream &, Polyline< Dim1 > const &)
 

Detailed Description

template<int Dim>
class atb::Polyline< Dim >

The Polyline class provides a simple polyline representation of a BSpline for fast point to spline distance approximations.

Definition at line 53 of file ATBPolyline.hh.

Member Typedef Documentation

◆ PointT

template<int Dim>
typedef blitz::TinyVector<double,Dim> atb::Polyline< Dim >::PointT

Definition at line 58 of file ATBPolyline.hh.

◆ PointIteratorT

template<int Dim>
typedef std::map<double,PointT>::iterator atb::Polyline< Dim >::PointIteratorT

Definition at line 59 of file ATBPolyline.hh.

◆ PointConstIteratorT

template<int Dim>
typedef std::map<double,PointT>::const_iterator atb::Polyline< Dim >::PointConstIteratorT

Definition at line 61 of file ATBPolyline.hh.

Constructor & Destructor Documentation

◆ Polyline() [1/2]

template<int Dim>
atb::Polyline< Dim >::Polyline ( )

Default constructor.

This constructor generates an empty polyline.

◆ Polyline() [2/2]

template<int Dim>
atb::Polyline< Dim >::Polyline ( Polyline< Dim > const &  polyline)

Copy constructor.

Parameters
polylineThe Polyline object to copy

◆ ~Polyline()

template<int Dim>
atb::Polyline< Dim >::~Polyline ( )

Destructor.

Member Function Documentation

◆ operator=()

template<int Dim>
Polyline<Dim>& atb::Polyline< Dim >::operator= ( Polyline< Dim > const &  polyline)

Copy assignment operator.

Parameters
polylineChange the nodes of this polyline to the nodes of the polyline given.
Returns
A reference to this updated polyline for operator chaining

◆ operator()()

template<int Dim>
PointT atb::Polyline< Dim >::operator() ( double  u) const

Get the polyline position at curve length u.

Parameters
uThe position along the curve parameterization to evaluate the polyline at
Returns
The polyline point at the given curve parameter

◆ distance()

template<int Dim>
double atb::Polyline< Dim >::distance ( PointT const &  point,
double &  uOpt 
) const

Project the given point onto the polyline and get the distance to the polyline and the projected position along the curve parameterization.

Parameters
pointThe point to project onto the polyline
uOptThe projected position along the curve parameterization
Returns
The point-to-polyline distance

◆ curveIntegral()

template<int Dim>
double atb::Polyline< Dim >::curveIntegral ( double  uStart = 0.0,
double  uEnd = 1.0 
) const

Compute the curve integral along the poly line.

You can give the lower and upper bounds of the length computation, if you only want to measure the length of a part of the polyline.

Parameters
uStartThe lower bound curve parameter
uEndThe upper bound curve parameter
Returns
The length of the polyline from uStart to uEnd

◆ fitToSpline()

template<int Dim>
void atb::Polyline< Dim >::fitToSpline ( BSpline< PointT > const &  spline,
double  eps = 1e-4 
)

Make this polyline optimally fit the given BSpline.

The Polyline is initialized with the spline's knot positions and iteratively subdivided along the segment with greatest error of fit until the tolerance is reached.

Parameters
splineThe spline to fit this polyline to
epsThe tolerance below which the fit is not further refined

◆ save() [1/2]

template<int Dim>
void atb::Polyline< Dim >::save ( std::string const &  fileName,
std::string const &  groupName,
bool  throwExceptions = false 
) const

Save the polyline with corresponding meta-data to an hdf5 file with given name, using the groupName provided.

Parameters
fileNameThe HDF5 file name. If a file of that name already exists, the polyline structures will be added, otherwise a new file will be created
groupNameThe HDF5 group to write the polyline data to
throwExceptionsIf this flag is given the method throws exceptions if something goes wrong, otherwise it will report a warning via standard out and return to the caller
Exceptions
BlitzH5ErrorIf the throwExceptions flag is set this error is thrown

◆ load() [1/2]

template<int Dim>
void atb::Polyline< Dim >::load ( std::string const &  fileName,
std::string const &  groupName,
bool  throwExceptions = false 
)

Load the polyline with corresponding meta-data from an hdf5 file with given name, using the groupName provided.

Parameters
fileNameThe HDF5 file name.
groupNameThe HDF5 group to read the polyline data from
throwExceptionsIf this flag is given the method throws exceptions if something goes wrong, otherwise it will report a warning via standard out and return to the caller
Exceptions
BlitzH5ErrorIf the throwExceptions flag is set this error is thrown

◆ save() [2/2]

template<int Dim>
void atb::Polyline< Dim >::save ( BlitzH5File outFile,
std::string const &  groupName 
) const

Save the polyline with corresponding meta-data to an hdf5 file with given name, using the groupName provided.

Parameters
outFileThe HDF5 file object the polyline structures will be written to.
groupNameThe HDF5 group to write the polyline data to
Exceptions
BlitzH5ErrorIf the save fails, this error is thrown

◆ load() [2/2]

template<int Dim>
void atb::Polyline< Dim >::load ( BlitzH5File const &  inFile,
std::string const &  groupName 
)

Load the polyline with corresponding meta-data from an hdf5 file with given name, using the groupName provided.

Parameters
inFileThe HDF5 file object.
groupNameThe HDF5 group to read the polyline data from
Exceptions
BlitzH5ErrorOn load error this error is thrown

Friends And Related Function Documentation

◆ operator<<

template<int Dim>
template<int Dim1>
std::ostream& operator<< ( std::ostream &  ,
Polyline< Dim1 > const &   
)
friend

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