SMTK  @SMTK_VERSION@
Simulation Modeling Tool Kit
Public Types | Public Member Functions | Static Public Member Functions | Protected Attributes | List of all members
smtk::model::Tessellation Class Reference

Store geometric information related to model entities. More...

#include <Tessellation.h>

Collaboration diagram for smtk::model::Tessellation:
[legend]

Public Types

typedef int size_type
 

Public Member Functions

std::vector< double > & coords ()
 Direct access to the underlying point-coordinate storage.
 
std::vector< double > const & coords () const
 Direct access to the underlying point-coordinate storage.
 
std::vector< int > & conn ()
 Direct access to the underlying connectivity storage.
 
std::vector< int > const & conn () const
 Direct access to the underlying connectivity storage.
 
int addCoords (const double *a)
 Add a 3-D point coordinate to the tessellation, but not a vertex record.
 
TessellationaddCoords (double x, double y, double z)
 Add a 3-D point coordinate to the tessellation, but not a vertex record.
 
TessellationaddPoint (const double *a)
 Add a 3-D point coordinate to the tessellation plus a vertex record.
 
TessellationaddLine (const double *a, const double *b)
 Add two 3-D point coordinates to the tessellation plus a line-segment record.
 
TessellationaddTriangle (const double *a, const double *b, const double *c)
 Add three 3-D point coordinates to the tessellation plus a triangle record.
 
TessellationaddQuad (const double *a, const double *b, const double *c, const double *d)
 Add four 3-D point coordinates to the tessellation plus a quadrilateral record.
 
TessellationaddPoint (int ai)
 Add a vertex record using a pre-existing point coordinate (referenced by ID).
 
TessellationaddLine (int ai, int bi)
 Add a line-segment record using 2 pre-existing point coordinates (referenced by ID).
 
TessellationaddTriangle (int ai, int bi, int ci)
 Add a triangle record using 3 pre-existing point coordinates (referenced by ID).
 
TessellationaddQuad (int ai, int bi, int ci, int di)
 Add a quadrilateral record using 4 pre-existing point coordinates (referenced by ID).
 
void setPoint (std::size_t id, const double *points)
 given the id of points, set points into coords
 
Tessellationreset ()
 Erase all point coordinates and tessellation primitive records.
 
size_type begin () const
 Return an offset-style iterator for traversing the tessellation-primitive-record connectivity array. More...
 
size_type end () const
 Return an offset-style end iterator for traversing the tessellation-primitive-record connectivity array. More...
 
size_type nextCellOffset (size_type curOffset) const
 Advance an offset into the connectivity record to the next cell.
 
size_type cellType (size_type offset) const
 Return the type of tessellation primitive stored at the given offset. More...
 
size_type numberOfCellVertices (size_type offset, size_type *cellTypeOut) const
 Return the number of vertices in the tessellation primitive stored at the given offset. More...
 
size_type vertexIdsOfCell (size_type offset, std::vector< int > &cellConn) const
 Return the vertex IDs of the points defining the tessellation primitive at the given offset in cellConn. More...
 
size_type materialIdOfCell (size_type offset) const
 Return the material ID of the primitive at the given offset.
 
bool vertexIdsOfPolylineEndpoints (size_type offset, int &first, int &last) const
 Populate first and last with the vertex IDs at each end of a polyline at offset. More...
 
size_type insertNextCell (std::vector< int > &cellConn)
 Insert by specifying exactly the values to be appended to the end of the connectivity array. More...
 
size_type insertNextCell (size_type connLen, const int *cellConn)
 Insert by specifying exactly the values to be appended to the end of the connectivity array. More...
 
bool insertCell (size_type offset, std::vector< int > &cellConn)
 Insert a cell by specifying exactly the values to be inserted into the connectivity array. More...
 
bool insertCell (size_type offset, size_type connLen, const int *cellConn)
 Insert a cell by specifying exactly the values to be inserted into the connectivity array. More...
 
bool getBoundingBox (double bbox[6]) const
 Compute the bounding box of the tessellation. More...
 

Static Public Member Functions

static size_type cellShapeFromType (size_type)
 Given a cell type, return just the bits that represent its shape.
 
static int numCellPropsFromType (size_type cellType)
 Given a cell type, return the number of per-cell IDs stored in the connectivity array.
 
static int numVertexPropsFromType (size_type cellType)
 Given a cell type, return the number of per-vertex property IDs (not including vertex IDs) stored in the connectivity array.
 
static void invalidBoundingBox (double bbox[6])
 Fill bbox with standard "invalid" bounds.
 

Protected Attributes

std::vector< double > m_coords
 
std::vector< int > m_conn
 

Detailed Description

Store geometric information related to model entities.

This is currently used to store coordinates and connectivity of a triangulation of the model entity for rendering. However, it may also evolve to store information about the underlying geometric construct being approximated.

Each instance stores point coordinates and connectivity in two different arrays. These arrays are organized for maximum compatibility with ThreeJS but extended to allow additional primitive types (mainly vertices and polylines, but also others).

Although ThreeJS bit values are used to indicate additional values stored in the connectivity (such as normal vector, color, and uv-coordinate IDs), there is no storage for additional properties (i.e., no normals, colors, or uv-coordinates). That may change in the future.

Member Function Documentation

◆ begin()

Tessellation::size_type smtk::model::Tessellation::begin ( ) const

Return an offset-style iterator for traversing the tessellation-primitive-record connectivity array.

The integer that is returned can be used as an offset into the connectivity array that marks the beginning of a tessellation primitive (vertex, line segment, triangle, quad, etc.).

◆ cellType()

Tessellation::size_type smtk::model::Tessellation::cellType ( size_type  offset) const

Return the type of tessellation primitive stored at the given offset.

Note that the cell type includes both its shape plus flags used by Three.js to indicate what per-cell and/or per-vertex properties are stored in addition to coordinates (e.g., normals, color, material).

◆ end()

Tessellation::size_type smtk::model::Tessellation::end ( ) const

Return an offset-style end iterator for traversing the tessellation-primitive-record connectivity array.

This is just a special invalid value that makes offsets into the connectivity array appear to be usable as iterators.

◆ getBoundingBox()

bool smtk::model::Tessellation::getBoundingBox ( double  bbox[6]) const

Compute the bounding box of the tessellation.

This computes the per-axis bounds of all the point coordinates, whether they are referenced by connectivity entries or not. The return value is true when the tessellation has at least 1 point and false otherwise. If false is returned, bbox is unmodified so that multiple calls to getBoundingBox will only increase and never reset bounds; this way the bbox for a collection can be obtained by calling getBoundingBox() on each tessellation – whether it is empty or not.

◆ insertCell() [1/2]

bool smtk::model::Tessellation::insertCell ( size_type  offset,
size_type  conn_length,
const int *  cellConn 
)

Insert a cell by specifying exactly the values to be inserted into the connectivity array.

Note that this is not simply a list of point coordinate IDs to serve as corner vertices for the primitive; rather, it starts with the cell type, then includes the number of vertices in the cell (but only when the cell type requires it – see TESS_VARYING_VERT_CELL), followed by the vertex IDs, the material ID (if the TESS_FACE_MATERIAL bit is set in the cell type), the per-cell UV coordinate ID (if the TESS_FACE_UV bit is set), the per-vertex UV coordinate IDs (if the TESS_FACE_VERTEX_UV bit is set), the per-cell normal vector ID (if the TESS_FACE_NORMAL bit is set), the per-vertex normal vector IDs (if the TESS_FACE_VERTEX_NORMAL bit is set), the per-cell color ID (if the TESS_FACE_COLOR bit is set), and the per-vertex color IDs (if the TESS_FACE_VERTEX_COLOR bit is set).

◆ insertCell() [2/2]

bool smtk::model::Tessellation::insertCell ( size_type  offset,
std::vector< int > &  cellConn 
)

Insert a cell by specifying exactly the values to be inserted into the connectivity array.

This variant accepts vectors of integers rather than a pointer.

◆ insertNextCell() [1/2]

Tessellation::size_type smtk::model::Tessellation::insertNextCell ( size_type  connLen,
const int *  cellConn 
)

Insert by specifying exactly the values to be appended to the end of the connectivity array.

This simply calls insertCell with the proper offset.

◆ insertNextCell() [2/2]

Tessellation::size_type smtk::model::Tessellation::insertNextCell ( std::vector< int > &  cellConn)

Insert by specifying exactly the values to be appended to the end of the connectivity array.

This simply calls insertCell with the proper offset.

◆ numberOfCellVertices()

Tessellation::size_type smtk::model::Tessellation::numberOfCellVertices ( size_type  offset,
size_type *  cellTypeOut 
) const

Return the number of vertices in the tessellation primitive stored at the given offset.

You may optionally pass the address of cellTypeOut to obtain the cell's type at the same time (since it must be fetched in order to determine the number of vertices.

◆ vertexIdsOfCell()

Tessellation::size_type smtk::model::Tessellation::vertexIdsOfCell ( size_type  offset,
std::vector< int > &  cellConn 
) const

Return the vertex IDs of the points defining the tessellation primitive at the given offset in cellConn.

Note that this is not the same as the vector of integers you must pass the insertCell or insertNextCell methods! This call populates cellConn with just the vertex IDs, not the cell type, the number of vertices, or any non-vertex IDs stored in the connectivity (such as normal-vector IDs, color IDs, material IDs, etc.).

◆ vertexIdsOfPolylineEndpoints()

bool smtk::model::Tessellation::vertexIdsOfPolylineEndpoints ( size_type  offset,
int &  first,
int &  last 
) const

Populate first and last with the vertex IDs at each end of a polyline at offset.

Note that when the cell at offset is not a polyline (or when the polyline is degenerate by virtue of having 0 or 1 vertices), this method will return false and first and last will be undefined.


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