Libcurvecollection: Difference between revisions
No edit summary |
|||
| Line 20: | Line 20: | ||
<tt>libcurvecollection</tt> provides a unified interface for handling these various formats, while simplifying access to the information in memory by presenting it in a object-oriented fashion. | <tt>libcurvecollection</tt> provides a unified interface for handling these various formats, while simplifying access to the information in memory by presenting it in a object-oriented fashion. | ||
==Installation== | |||
The Curve Collection library can be found under <tt>[[$G]]/common/libcurvecollection/</tt>. To install it, run <code>make clean all</code>, then <code>make install</code>. ''<span style="color:red">???</span>'' | |||
To use the library after it has been installed, include the line <code>#include <brain/curveCollection.h</code> near the top of your file. | |||
==Structure== | ==Structure== | ||
| Line 39: | Line 44: | ||
A vertex instantiated using a copy constructor will have the same coordinates and properties as the source, but will not belong to any Curve. Thus, the properties can only be accessed by calling <code>property(int)</code> (and not <code>property(string)</code>). | A vertex instantiated using a copy constructor will have the same coordinates and properties as the source, but will not belong to any Curve. Thus, the properties can only be accessed by calling <code>property(int)</code> (and not <code>property(string)</code>). | ||
===Accessors=== | |||
<code>double x() const</code> | |||
<code>double y() const</code> | |||
<code>double z() const</code> | |||
===Property accessors & mutators=== | |||
<code>double & property([http://www.sgi.com/tech/stl/basic_string.html std::string] const & name)</code> | |||
<code>double const & property([http://www.sgi.com/tech/stl/basic_string.html std::string] const & name) const</code> | |||
Looks up the given property name and returns a reference to the vertex property (in the current CurveVertex) that it identifies. Because the return value is a reference, you can modify the stored property value (assuming you called the non-<tt>const</tt> version of the function). | |||
Note that the Curve Collection library stores property names only at the highest level (i.e., in a CurveCollection). Therefore, the CurveVertex in question must be in a Curve, and that Curve must be in a CurveCollection before you can call this method. If you call it before this happens, the program will exit with a <tt>runtime_error</tt> ('''CurveVertex::checkForContainer: ...'''). | |||
If the lookup fails (i.e., the given string '''name''' was not found in the CurveCollection), the method will throw an <tt>invalid_argument</tt> exception. | |||
Revision as of 21:19, 18 June 2010
The Curve Collection Library (libcurvecollection) provides a representation streamlines/curves in memory and an interface to access this information in a convenient but memory-safe manner. It can also read and write to disk, freely converting between several file formats.
Currently, the supported formats are:
- DTK/TrackVis
- Tubegen's custom format (.data and .nocr files)
- CCF
Introduction
Tubegen represents streamlines/tubes in several different formats in memory and on disk, which are distinct from the representations used by well-established third parties, for example FSL, Camino, and DTK. The core of any representation, though, is quite simple: a collection of streamlines, in which each streamline is just an ordered list of vertex points in 3-space. The tricky bit is that we want to be able to associate scalars with these datasets at various levels:
- each individual streamline (ex: the length of the streamline)
- each vertex point of each streamline (ex: the interpolated FA value at that point)
Some of the data formats also include a description (i.e., a string) for each scalar value.
libcurvecollection provides a unified interface for handling these various formats, while simplifying access to the information in memory by presenting it in a object-oriented fashion.
Installation
The Curve Collection library can be found under $G/common/libcurvecollection/. To install it, run make clean all, then make install. ???
To use the library after it has been installed, include the line #include <brain/curveCollection.h near the top of your file.
Structure
The library consists of three mutually dependent components, each with a header (.h) and a .cpp file:
CurveVertex
A CurveVertex represents a point in 3D space. It holds the point's coordinates and any metadata (in the form of doubles) that the point may have.
Constructors
CurveVertex(double, double, double)
The main constructor takes three doubles: the x, y, and z coordinates of the point.
CurveVertex(CurveVertex const & v)
A vertex instantiated using a copy constructor will have the same coordinates and properties as the source, but will not belong to any Curve. Thus, the properties can only be accessed by calling property(int) (and not property(string)).
Accessors
double x() const
double y() const
double z() const
Property accessors & mutators
double & property(std::string const & name)
double const & property(std::string const & name) const
Looks up the given property name and returns a reference to the vertex property (in the current CurveVertex) that it identifies. Because the return value is a reference, you can modify the stored property value (assuming you called the non-const version of the function).
Note that the Curve Collection library stores property names only at the highest level (i.e., in a CurveCollection). Therefore, the CurveVertex in question must be in a Curve, and that Curve must be in a CurveCollection before you can call this method. If you call it before this happens, the program will exit with a runtime_error (CurveVertex::checkForContainer: ...).
If the lookup fails (i.e., the given string name was not found in the CurveCollection), the method will throw an invalid_argument exception.