Geometry

A Geometry is a Facet-based representation of a 3D volume. The implementation assumes that a facet-mesh is constructed from a set of points, and a set of facets, where each point and each facet are uniquely identified by a key. Each facet contains the keys to three different points, and a normal. The Geometry additionally contains normals for each point.

The Geometry class offers member functions for manipulations such as rotations, translations and scaling. More advanced tools can be found in the GeometryTools package, I/O is in the GeometryIO package. Conversions to voxel-representation are handled by the Voxelizer. Creating a Geometry out of voxel-data is handled by the SurfaceExtractor.

template <typename T>
class Geometry;

Note: Template parameter T is assumed to be a floating-point type.

Note: MeshLab can be used to correct facet representations or to convert other datatypes to STL.

Interface

value_type
Alias for template parameter T.
point_type
The type of the points.
facet_type
The type of the facets, which is based on indices rather than full points a descibed in the Facet documentation.
vector_type
Type of Vectors, such as the normal of the facets.
const_facet_iterator
A read-only iterator for the set of facets.
const_point_iterator
A read-only iterator for the set of points.
Geometry()
Constructs empty Geometry.
template <typename SortedPointsIterator,
	typename PointIDIterator>
void loadPoints(const SortedPointsIterator pointBegin,
		const SortedPointsIterator pointEnd,
		const PointIDIterator idBegin)
Removes all points and loads a new set of points from the sorted range of unique points pointBegin ... pointEnd. For each newly inserted point from the given range, a point ID is written in the range indicated by idBegin.
template <typename SortedFacetsIterator,
	  typename FacetIDIterator>
void loadFacets(const SortedFacetsIterator facetBegin,
		const SortedFacetsIterator facetEnd,
		const FacetIDIterator idBegin)
Removes all facets and loads a new set of facets from the sorted range of unique facets facetBegin ... facetEnd. For each newly inserted facet from the given range, a facet ID is written in the range indicated by idBegin.
void clear()
Clear to empty geometry.
unsigned nrFacets() const
Get total number of facets.
unsigned nrPoints() const
Get total number of points.
value_type min(const unsigned dim) const
Get minimum coordinates of all points in dimension "dim". Return value is undefined if the geometry doesn't contain any points.
value_type max(const unsigned dim) const
Get maximum coordinates of all points in dimension "dim". Return value is undefined if the geometry doesn't contain any points.
const_point_iterator pointsBegin() const
A read-only iterator to the beginning of a range of all points.
const_point_iterator pointsEnd() const
A read-only iterator to the end of a range of all points.
const_facet_iterator facetsBegin() const
A read-only iterator to the beginning of a range of all facets.
const_facet_iterator facetsEnd() const
A read-only iterator to the end of a range of all facets.
const facet_type &facet(const unsigned key) const
Returns the facet with the given key.
const vector_type &facetNormal(const unsigned key) const
Returns the normal of the facet with the given key.
const vector_type &pointNormal(const unsigned key) const
Returns the normal of the point with the given key.
const point_type &point(const unsigned key) const
Returns a read-only reference to the point with the given key.
const std::set<unsigned>
&facetsHavingPoint(const unsigned key) const
Returns a set of keys of facets that contain the point with the given key.
unsigned addPoint(const value_type &x,
		const value_type &y,
		const value_type &z)
Add a point (x, y, z), returns a key for the new point.
unsigned addPoint(const point_type &p)
Add point p, returns a key.
bool updatePoint(const unsigned key, const point_type &p)
	
Alter the point with the given key to equal p.
bool updatePoint(const unsigned key, const value_type &x,
		 const value_type &y, const value_type &z)
Alter the point with the given key to equal (x, y, z).
bool erasePoint(const unsigned key)
Remove the point with the given key. Fails if the point is part of a facet.
unsigned addFacet(const unsigned a,
		const unsigned b,
		const unsigned c)
Add a facet with points with keys "a", "b" and "c", returns a key for the new facet.
unsigned addFacet(const facet_type &facet)
Add a facet, returns a key for the new facet.
bool updateFacet(const unsigned key, const unsigned a,
		 const unsigned b, const unsigned c)
Update the facet with the given key to contain points with keys "a", "b" and "c".
bool updateFacet(const unsigned key, const facet_type &f)
	
Update the facet with the given key to "f".
bool eraseFacet(const unsigned key)
Erase the facet with the given key.
void center()
Centers the geometry, making sure it is evenly spaced around the Origin, i.e. min(X) = -max(X) etc.
void centerMass()
Centers the geometry such that it's center-of-mass coincides with the Origin.
void scale(const value_type factor)
Scale geometry by multiplying all components of all points by the given factor.
void scaleTo(const value_type size = 1000.0)
Scales such that the geometry will just fit in a "size"-by-"size"-by-"size" box.
template <class Vector>
		void translate(const Vector &v)
Move the geometry along "v".
void translate(const value_type deltaX,
		const value_type deltaY,
		const value_type deltaZ)
Translate over Vector (deltaX, deltaY, deltaZ).
void rotate(const unsigned axis, const value_type angle)
Rotate "angle" radials along "axis".

Example

#include <cvmlcpp/volume/Geometry>
#include <cvmlcpp/volume/GeometryIO>
#include <cvmlcpp/volume/GeometryTools>

using namespace cvmlcpp;

Geometry<float> g1;

readSTL(g1, "tube.stl");
fixGeometry(g1);

g1.scaleTo();
g1.center();
g1.rotate(X, 3.0);