Public Types | Public Member Functions

sal3d::COP Class Reference
[Core3D]

Cloud of Points defining a 3D surface. More...

#include <COP.hpp>

List of all members.

Public Types

typedef Array2D< float > Component

Public Member Functions

 COP (int width, int height, bool fillWithNaN=false)
 Constructor from size. Creates an empty cloud of points.
 COP (const std::string &fileName)
 Constructor from file. Loads a cloud of points from a file.
 COP (sal3d_cop cop)
 Constructor from a C sal3d_cop. Creates a new C++ object that holds it.
 COP (const COP &cop)
 Copy constructor.
 COP (const COP &cop, const Movement3D &movement)
 Constructor from a moved COP.
 COP (const Profile &profile, const Metric::Config &metricConfig)
 Constructor from a profile. It converts the profile to a cloud of points using the metric config provided.
 COP (const RangeMap &rangeMap, const Metric::Config &metricConfig)
 Constructor from a range map. It converts the range map to a cloud of points using the metric config provided.
 COP (const sal3d::RangeMap &rm, const sal3d::AngularMetric::Config &metricConfig, float initialAngle, float angleStep)
 Constructor from a range map. It converts the range map to a cloud of points using the angular metric config provided.
 COP (const Frame &frame, const Metric::Config &metricConfig)
 Constructor from a frame. It converts the frame to a cloud of points using the metric config provided.
 ~COP ()
 Destructor.
COP copy () const
 Get a deep copy of the COP.
sal3d_cop c_cop () const
 Returns the pointer to the internal C cop.
void fillRow (int row, const Profile &profile, const Metric::Config &config)
 Fills a row of the COP with the points converted from the profile with the given metric config.
const Component getX () const
 Gets the cloud of points' const X component.
Component getX ()
 Gets the cloud of points' X component.
const Component getY () const
 Gets the cloud of points' const Y component.
Component getY ()
 Gets the cloud of points' Y component.
const Component getZ () const
 Gets the cloud of points' const Z component.
Component getZ ()
 Gets the cloud of points' Z component.
sal3d::Point3D getPoint3D (int u, int v) const
 Gets the metric coordinates of the point at u, v.
int height () const
 Gets the number of rows.
COPoperator= (const COP &rhs)
 Assignment operator.
int width () const
 Gets the length of the rows in the COP.
ZMapFactors getZMapFactors () const
 Gets the default ZMap factors for this COP. This function returns a set of factors to create a ZMap the same size as the COP, with a ROI set to fit all the object in the ZMap.
void saveToFile (const std::string &fileName) const
 Saves the cloud of points to a file.
void exportToBinaryPLY (const std::string &fileName) const
 Exports the COP to a PLY in binary format. The format is explained in PLY File Format.
void exportToAsciiPLY (const std::string &fileName) const
 Exports the COP to a PLY in ASCII format. The format is explained in PLY File Format.
void glPaintPoints () const
void glPaintPolygons () const
void glPaintRandomPoints (int numberPoints) const
 Paints numberPoints random points of the COP. Useful in a sceneario where you wish to paint a simplified version of the COP for transitions for example.
void glPaintColourPoints (const sal3d::Frame &rgbFrame) const
void glPaintColourPolygons (const sal3d::Frame &rgbFrame) const
void crop (const Projection2D &projection, const AxesAlignedRectangle &rectangle, bool keepInsidePoints=true)
 Crop the COP as defined by a rectangle aligned to the world axes.
void crop (const Projection2D &projection, const Polygon2D &polygon2d, bool keepInsidePoints=true)
 Crop the COP as defined by a Polygon2D.

Detailed Description

Cloud of Points defining a 3D surface.

This class requires linking with core3d.lib (import library for core3d.dll).

A COP can be obtained in several ways. It is possible to convert an accumulation of profiles, either in the form of a RangeMap or a Frame, to a COP, by means of a Metric::Config (from the Metric module). If one has a source of 3D data, it is also possible to create an empty COP of the desired size and fill it with the data.

This Cloud of Points holds the metric coordinates for each point defined. When using the peak finder, that is for every point where the laser was detected and given a g value in the profile. The points not defined are represented with the special value NaN. The size of the COP can be retrieved through height(), corresponding to the u coordinate or number of Profiles in the RangeMap, and width(), corresponding to v or the length of those Profiles.

The 3D data of the points is stored in separated planes x, y and z. The user can access this data by planes, each of which having width() x height() points, through the functions getX(), getY() and getZ(), or can get the metric coordinates of a single point using getPoint3D(), and providing its u, v coordinates.

An example of how to manually populate a COP from a given set of points is given in How to Populate a COP Object.


Member Typedef Documentation

A 2D array holding the values corresponding to one of the coordinates (X, Y or Z) of the COP.


Constructor & Destructor Documentation

sal3d::COP::COP ( int  width,
int  height,
bool  fillWithNaN = false 
) [inline]

Constructor from size. Creates an empty cloud of points.

Parameters:
[in]widthThe width of the COP.
[in]heightThe height of the COP.
[in]fillWithNaNWhether to initialize the COP with NaN values in all the Components.
Exceptions:
std::bad_alloc()if there is an error getting memory to create the COP.
std::invalid_argument()if the parameters supplied are incorrect
std::runtime_error()if there is an error creating the COP.

Referenced by copy().

sal3d::COP::COP ( const std::string &  fileName ) [inline, explicit]

Constructor from file. Loads a cloud of points from a file.

Parameters:
[in]fileNameThe filename to use to load the cloud of points.
Exceptions:
std::bad_alloc()if there is an error getting memory to create the COP.
InvalidFile()if the given file is invalid.
std::runtime_error()if there is an error creating the COP.
sal3d::COP::COP ( sal3d_cop  cop ) [inline, explicit]

Constructor from a C sal3d_cop. Creates a new C++ object that holds it.

Warning:
The new C++ COP object will get the ownership of the cop. That means that you should not call sal3d_cop_release() on this cop, otherwise it would be called twice.
Parameters:
[in]copThe C sal3d_cop used to create this object.
sal3d::COP::COP ( const COP cop ) [inline]

Copy constructor.

Parameters:
[in]copThe cloud of points to copy from.
sal3d::COP::COP ( const COP cop,
const Movement3D movement 
) [inline]

Constructor from a moved COP.

Parameters:
[in]copThe original COP to be moved.
[in]movementThe Movement3D matrix that specifies the transformation to be applied to the cop.
Exceptions:
std::bad_alloc()if there is an error getting memory to create the COP.
std::runtime_error()if there is an error creating the COP.

References c_cop(), and sal3d::Movement3D::c_movement_3d().

sal3d::COP::COP ( const Profile profile,
const Metric::Config metricConfig 
) [inline]

Constructor from a profile. It converts the profile to a cloud of points using the metric config provided.

Parameters:
[in]profileThe profile to create the cloud of points from.
[in]metricConfigThe metric configuration to use to convert the profile's (u, v, g) values to metric (x, y, z).
Exceptions:
std::bad_alloc()if there is an error getting memory to create the COP.
std::runtime_error()if there is an error creating the COP.

References sal3d::Metric::Config::c_metric_config(), and sal3d::Profile::c_profile().

sal3d::COP::COP ( const RangeMap rangeMap,
const Metric::Config metricConfig 
) [inline]

Constructor from a range map. It converts the range map to a cloud of points using the metric config provided.

Parameters:
[in]rangeMapThe range map to create the cloud of points from.
[in]metricConfigThe metric configuration to use to convert the range map's (u, v, g) values to metric (x, y, z).
Exceptions:
std::bad_alloc()if there is an error getting memory to create the COP.
std::runtime_error()if there is an error creating the COP.

References sal3d::Metric::Config::c_metric_config(), and sal3d::RangeMap::c_range_map().

sal3d::COP::COP ( const sal3d::RangeMap rm,
const sal3d::AngularMetric::Config metricConfig,
float  initialAngle,
float  angleStep 
) [inline]

Constructor from a range map. It converts the range map to a cloud of points using the angular metric config provided.

Parameters:
[in]rmThe range map to create the cloud of points from.
[in]metricConfigThe angular metric configuration to use to convert the range map's (u, v, g) values to metric (x, y, z).
[in]initialAngle
[in]angleStep
Exceptions:
std::bad_alloc()if there is an error getting memory to create the COP.
InvalidPatternRangeMap()if the given rangemap is not valid.
std::runtime_error()if there is an error creating the COP.

References sal3d::AngularMetric::Config::c_metric_config(), and sal3d::RangeMap::c_range_map().

sal3d::COP::COP ( const Frame frame,
const Metric::Config metricConfig 
) [inline]

Constructor from a frame. It converts the frame to a cloud of points using the metric config provided.

Parameters:
[in]frameThe frame to create the cloud of points from.
[in]metricConfigThe metric configuration to use to convert the frame's (u, v, g) values to metric (x, y, z).
Exceptions:
std::bad_alloc()if there is an error getting memory to create the COP.
std::runtime_error()if there is an error creating the COP.

References sal3d::Frame::c_frame(), and sal3d::Metric::Config::c_metric_config().

sal3d::COP::~COP (  ) [inline]

Destructor.

If the reference counter reaches zero, the object is destroyed and its memory released.


Member Function Documentation

sal3d_cop sal3d::COP::c_cop (  ) const [inline]

Returns the pointer to the internal C cop.

Warning:
Never ever call sal3d_cop_release() with the pointer returned by this function or the application will fail.
Returns:
The pointer to sal3d's cop C interface.

Referenced by sal3d::Area::areaToRefLine(), COP(), sal3d::Viewer::display(), sal3d::Geometric::fitCOPToSphere(), sal3d::Geometric::getRobustTangentPlane(), sal3d::Match3D::Match3D(), sal3d::Match3DCoarse::Match3DCoarse(), sal3d::Mesh::Mesh(), sal3d::Match3DCoarse::operator()(), sal3d::Match3D::operator()(), and sal3d::ZMap::ZMap().

COP sal3d::COP::copy (  ) const [inline]

Get a deep copy of the COP.

This means that the object and its memory is duplicated. More information about this can be fount at Memory management: reference counting.

Returns:
A cloud of points which is a deep copy of this COP.
Exceptions:
std::bad_alloc()if there is an error getting memory to create the copy.
std::runtime_error()if there is an error creating the copy.

References COP().

void sal3d::COP::crop ( const Projection2D projection,
const AxesAlignedRectangle rectangle,
bool  keepInsidePoints = true 
) [inline]

Crop the COP as defined by a rectangle aligned to the world axes.

This function is mainly targeted at cropping the COP by defining a rectangle in a 2D view. The COP is projected to 2D and what falls outside (when keepInsidePoints is true) the rectangle is removed, and vice versa.

Parameters:
[in]projectionThe projection matrix used to project the COP to 2D.
[in]rectangleThe rectangle to define the desired region.
[in]keepInsidePointsIf true (default), the points that fall outside the polygon are removed, if false they are the ones that are kept.
Exceptions:
std::invalid_argument()if the supplied polygon is not valid.
std::runtime_error()if there is an error creating the copy.
void sal3d::COP::crop ( const Projection2D projection,
const Polygon2D polygon2d,
bool  keepInsidePoints = true 
) [inline]

Crop the COP as defined by a Polygon2D.

This function is mainly targeted at cropping the COP by defining a polygon in a 2D view. The COP is projected to 2D and what falls outside (when keepInsidePoints is true) the polygon is removed, and vice versa.

Parameters:
[in]projectionThe projection matrix used to project the COP to 2D.
[in]polygon2dThe polygon to define the desired region.
[in]keepInsidePointsIf true (default), the points that fall outside the polygon are removed, if false they are the ones that are kept.
Exceptions:
std::invalid_argument()if the supplied polygon is not valid.
std::runtime_error()if there is an error creating the copy.

References sal3d::Polygon2D::c_polygon_2d().

void sal3d::COP::exportToAsciiPLY ( const std::string &  fileName ) const [inline]

Exports the COP to a PLY in ASCII format. The format is explained in PLY File Format.

Parameters:
[in]fileNameThe name of the file to store the PLY.
Exceptions:
InvalidFile()if there is an error writing to the file.
std::runtime_error()if there is an unknown error.
void sal3d::COP::exportToBinaryPLY ( const std::string &  fileName ) const [inline]

Exports the COP to a PLY in binary format. The format is explained in PLY File Format.

Parameters:
[in]fileNameThe name of the file to store the PLY.
Exceptions:
InvalidFile()if there is an error writing to the file.
std::runtime_error()if there is an unknown error.
void sal3d::COP::fillRow ( int  row,
const Profile profile,
const Metric::Config config 
) [inline]

Fills a row of the COP with the points converted from the profile with the given metric config.

Parameters:
[in]rowThe row number that is to be filled.
[in]profileThe profile to be added to the COP, once transformed with the metric config.
[in]configThe metric config to convert the points in the profile to 3D points.
Exceptions:
std::invalid_argument()if any of the given arguments are wrong.
std::runtime_error()if there is an error adding the profile.

References sal3d::Metric::Config::c_metric_config(), and sal3d::Profile::c_profile().

sal3d::Point3D sal3d::COP::getPoint3D ( int  u,
int  v 
) const [inline]

Gets the metric coordinates of the point at u, v.

Returns:
A Point3D with the coordinates at position u, v in the Cloud of Points.

References getX(), getY(), and getZ().

const Component sal3d::COP::getX (  ) const [inline]

Gets the cloud of points' const X component.

Returns:
The const X component of the cloud of points.
Exceptions:
std::runtime_error()if there is an error getting the component.

References height(), and width().

Referenced by getPoint3D(), and getX().

Component sal3d::COP::getX (  ) [inline]

Gets the cloud of points' X component.

Returns:
The X component of the cloud of points.
Exceptions:
std::runtime_error()if there is an error getting the component.

References getX().

const Component sal3d::COP::getY (  ) const [inline]

Gets the cloud of points' const Y component.

Returns:
The const Y component of the cloud of points.
Exceptions:
std::runtime_error()if there is an error getting the component.

References height(), and width().

Referenced by getPoint3D(), and getY().

Component sal3d::COP::getY (  ) [inline]

Gets the cloud of points' Y component.

Returns:
The Y component of the cloud of points.
Exceptions:
std::runtime_error()if there is an error getting the component.

References getY().

const Component sal3d::COP::getZ (  ) const [inline]

Gets the cloud of points' const Z component.

Returns:
The const Z component of the cloud of points.
Exceptions:
std::runtime_error()if there is an error getting the component.

References height(), and width().

Referenced by getPoint3D(), and getZ().

Component sal3d::COP::getZ (  ) [inline]

Gets the cloud of points' Z component.

Returns:
The Z component of the cloud of points.
Exceptions:
std::runtime_error()if there is an error getting the component.

References getZ().

ZMapFactors sal3d::COP::getZMapFactors (  ) const [inline]

Gets the default ZMap factors for this COP. This function returns a set of factors to create a ZMap the same size as the COP, with a ROI set to fit all the object in the ZMap.

Warning:
These values should only be taken as a reference. Due to the perspective correction, it is very likely to get the "undefined lines" effect described in Undefined lines on the ZMap when using them.
Returns:
The default ZMapFactors for this COP.
Exceptions:
std::runtime_error()if there is an error getting the factors.
int sal3d::COP::height (  ) const [inline]

Gets the number of rows.

Returns:
The number of rows the cloud of points has.

Referenced by sal3d::Geometric::getRobustTangentPlane(), getX(), getY(), and getZ().

COP& sal3d::COP::operator= ( const COP rhs ) [inline]

Assignment operator.

Parameters:
[in]rhsThe cloud of points to copy from.
Returns:
A reference to this object.
void sal3d::COP::saveToFile ( const std::string &  fileName ) const [inline]

Saves the cloud of points to a file.

Parameters:
[in]fileNameThe name of the file to store the cloud of points. The used extension is .cop.
Exceptions:
std::bad_alloc()if there is a memory error.
InvalidFile()if there is an error writing to the file.
std::runtime_error()if there is an unknown error.
int sal3d::COP::width (  ) const [inline]

Gets the length of the rows in the COP.

Returns:
The length of each cloud of points' rows. All rows have the same length.

Referenced by sal3d::Geometric::getRobustTangentPlane(), getX(), getY(), and getZ().


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