CUGL
Cornell University Game Library
Public Member Functions | List of all members
cugl::PathOutliner Class Reference

#include <CUPathOutliner.h>

Public Member Functions

 PathOutliner ()
 
 PathOutliner (const std::vector< Vec2 > &points)
 
 PathOutliner (const Poly2 &poly)
 
 ~PathOutliner ()
 
void set (const Poly2 &poly)
 
void set (const std::vector< Vec2 > &points)
 
void reset ()
 
void clear ()
 
void calculate (PathTraversal traversal)
 
std::vector< unsigned short > getPath ()
 
size_t getPath (std::vector< unsigned short > &buffer)
 
Poly2 getPolygon ()
 
Poly2getPolygon (Poly2 *buffer)
 

Detailed Description

This class is a factory for producing wireframe Poly2 objects from a set of vertices.

This class provides three types of traversals: open, closed, and interior. An interior traversal first triangulates the polygon, and then creates a wireframe traversal of that triangulation.

As with all factories, the methods are broken up into three phases: initialization, calculation, and materialization. To use the factory, you first set the data (in this case a set of vertices or another Poly2) with the initialization methods. You then call the calculation method. Finally, you use the materialization methods to access the data in several different ways.

This division allows us to support multithreaded calculation if the data generation takes too long. However, note that this factory is not thread safe in that you cannot access data while it is still in mid-calculation.

Constructor & Destructor Documentation

cugl::PathOutliner::PathOutliner ( )
inline

Creates an outliner with no vertex data.

cugl::PathOutliner::PathOutliner ( const std::vector< Vec2 > &  points)
inline

Creates an outliner with the given vertex data.

The vertex data is copied. The outliner does not retain any references to the original data.

Parameters
pointsThe vertices to outline
cugl::PathOutliner::PathOutliner ( const Poly2 poly)
inline

Creates an outliner with the given vertex data.

The outline only uses the vertex data from the polygon. It ignores any existing indices.

The vertex data is copied. The outliner does not retain any references to the original data.

Parameters
polyThe vertices to outline
cugl::PathOutliner::~PathOutliner ( )
inline

Deletes this outliner, releasing all resources.

Member Function Documentation

void cugl::PathOutliner::calculate ( PathTraversal  traversal)

Performs a path calculation of the current vertex data.

The path takes the provided traversal. See Traversal for more information.

Parameters
traversalThe traversal type.
void cugl::PathOutliner::clear ( )
inline

Clears all internal data, the initial vertex data.

When this method is called, you will need to set a new vertices before calling calculate.

std::vector<unsigned short> cugl::PathOutliner::getPath ( )

Returns a list of indices representing the path outline.

The indices represent positions in the original vertex list. If you have modified that list, these indices may no longer be valid.

The outliner does not retain a reference to the returned list; it is safe to modify it.

If the calculation is not yet performed, this method will return the empty list.

Returns
a list of indices representing the path outline.
size_t cugl::PathOutliner::getPath ( std::vector< unsigned short > &  buffer)

Stores the path outline indices in the given buffer.

The indices represent positions in the original vertex list. If you have modified that list, these indices may no longer be valid.

The indices will be appended to the provided vector. You should clear the vector first if you do not want to preserve the original data.

If the calculation is not yet performed, this method will do nothing.

Returns
the number of elements added to the buffer
Poly2 cugl::PathOutliner::getPolygon ( )

Returns a polygon representing the path outline.

The polygon contains the original vertices together with the new indices defining the wireframe path. The outliner does not maintain references to this polygon and it is safe to modify it.

If the calculation is not yet performed, this method will return the empty polygon.

Returns
a polygon representing the path outline.
Poly2* cugl::PathOutliner::getPolygon ( Poly2 buffer)

Stores the path outline in the given buffer.

This method will add both the original vertices, and the corresponding indices to the new buffer. If the buffer is not empty, the indices will be adjusted accordingly. You should clear the buffer first if you do not want to preserve the original data.

If the calculation is not yet performed, this method will do nothing.

Parameters
bufferThe buffer to store the outlined polygon
Returns
a reference to the buffer for chaining.
void cugl::PathOutliner::reset ( )
inline

Clears all internal data, but still maintains the initial vertex data.

void cugl::PathOutliner::set ( const Poly2 poly)
inline

Sets the vertex data for this outliner.

The outline only uses the vertex data from the polygon. It ignores any existing indices.

The vertex data is copied. The outliner does not retain any references to the original data.

This method resets all interal data. You will need to reperform the calculation before accessing data.

Parameters
polyThe vertices to outline
void cugl::PathOutliner::set ( const std::vector< Vec2 > &  points)
inline

Sets the vertex data for this outliner.

The vertex data is copied. The outliner does not retain any references to the original data.

This method resets all interal data. You will need to reperform the calculation before accessing data.

Parameters
pointsThe vertices to outline

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