Rhino C++ API  8.13
Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
ON_TriangleMesh Class Reference

#include <opennurbs_plus_trimesh.h>

Public Member Functions

 ON_TriangleMesh ()
 
 ON_TriangleMesh (const ON_TriangleMesh &)
 
 ~ON_TriangleMesh ()
 
bool Create (const class ON_Mesh *mesh, bool bPersistentMeshReference)
 
bool CreateTriangleRTree (class ON_RTree &rtree) const
 
void Destroy ()
 
void DestroyCachedInformation ()
 
bool EvNormal (const struct ON_TriangleMeshPoint *triangle_point, double normal[3]) const
 
bool EvNormal (unsigned int triangle_index, const double tri_bc[3], double normal[3]) const
 
bool EvNormal (unsigned int triangle_index, double a, double b, double c, double normal[3]) const
 
bool EvPoint (const struct ON_TriangleMeshPoint *triangle_point, double point[3]) const
 
bool EvPoint (unsigned int triangle_index, const double tri_bc[3], double point[3]) const
 
bool EvPoint (unsigned int triangle_index, double a, double b, double c, double point[3]) const
 
bool EvPointAndNormal (const struct ON_TriangleMeshPoint *triangle_point, double point[3], double normal[3]) const
 
bool EvPointAndNormal (unsigned int triangle_index, const double tri_bc[3], double point[3], double normal[3]) const
 
bool EvPointAndNormal (unsigned int triangle_index, double a, double b, double c, double point[3], double normal[3]) const
 
bool GetClosestPoint (const class ON_3dPoint *test_point, double maximum_distance_tolerance, unsigned int *triangle_index, double triangle_bc[3]) const
 
bool IntersectLine (const double p0[3], const double p1[3], double tolerance, bool ON_CALLBACK_CDECL resultCallback(void *context, const double line_t[2], const struct ON_TriangleMeshPoint tri_t[2], struct ON_RTreeCapsule *capsule), void *context) const
 
class ON_MeshMeshForm (class ON_Mesh *mesh) const
 
const class ON_MeshMeshReference () const
 
bool OffsetMesh (double offset_distance)
 
bool OffsetMesh (double offset_distance, const double(*N)[3], double(*offset_V)[3]) const
 
bool OffsetMesh (double offset_distance, const float(*N)[3], double(*offset_V)[3]) const
 
ON_TriangleMeshoperator= (const ON_TriangleMesh &)
 
const class ON_TrianglePlanePlaneEquation (unsigned int triangle_index) const
 
void SetStatus (unsigned int triangle_index, unsigned int status)
 
unsigned int Status (unsigned int triangle_index) const
 
const unsigned int * StatusArray () const
 
unsigned int StatusCount () const
 
const class ON_RTreeTriangleRTree () const
 
const unsigned int * VertexMap () const
 
const ON_3dPointVertexPoints () const
 

Static Public Member Functions

static bool BarycentricTriToQuad (unsigned int T_flags, const double tri_bc[3], double quad_bc[4])
 
static bool BarycentricTriToQuad (unsigned int T_flags, double a, double b, double c, double quad_bc[4])
 
static int CompareLocation (const double a[3], const double b[3])
 

Public Attributes

const double(* m_N )[3]
 optional vertex unit normals More...
 
const unsigned int(* m_T )[3]
 
unsigned int m_T_count
 number of triangles in m_T[] More...
 
const unsigned int * m_T_flags
 
const unsigned int * m_T_id
 
const double(* m_V )[3]
 vertex locations More...
 
unsigned int m_V_count
 number of vertices in m_V[] More...
 

Constructor & Destructor Documentation

◆ ON_TriangleMesh() [1/2]

ON_TriangleMesh::ON_TriangleMesh ( )

◆ ON_TriangleMesh() [2/2]

ON_TriangleMesh::ON_TriangleMesh ( const ON_TriangleMesh )

◆ ~ON_TriangleMesh()

ON_TriangleMesh::~ON_TriangleMesh ( )

Member Function Documentation

◆ BarycentricTriToQuad() [1/2]

static bool ON_TriangleMesh::BarycentricTriToQuad ( unsigned int  T_flags,
const double  tri_bc[3],
double  quad_bc[4] 
)
static

Description: Convert triangle barycentric coordinates to quad barycentric coordinates. Parameters: T_flags - [in] The value of (0x1F & Tflags) specifies the correspondence between the corners of the triangle and the corners of the quad. A table of the values and correspondences is in the description of the m_T_flags member variable above. tri_bc - [in] Three triangle barycentric coordinates quad_bc - [out] For quad barycentric coordinates. The corner of the quad that does not correspond to a triangle corner will have value of 0.0. Returns: True if the value of (0x1F & Tflags) was a valid and quad_bc was set from tri_bc. False if the value of (0x1F & Tflags) was not valid and quad_bc was set to (0.0,0.0,0.0,0.0).

◆ BarycentricTriToQuad() [2/2]

static bool ON_TriangleMesh::BarycentricTriToQuad ( unsigned int  T_flags,
double  a,
double  b,
double  c,
double  quad_bc[4] 
)
static

Description: Convert triangle barycentric coordinates to quad barycentric coordinates. Parameters: T_flags - [in] The value of (0x1F & Tflags) specifies the correspondence between the corners of the triangle and the corners of the quad. A table of the values and correspondences is in the description of the m_T_flags member variable above. a - [in] b - [in] c - [in] (a,b,c) are the triangle barycentric coordinates quad_bc - [out] For quad barycentric coordinates. The corner of the quad that does not correspond to a triangle corner will have value of 0.0. Returns: True if the value of (0x1F & Tflags) was a valid and quad_bc was set from tri_bc. False if the value of (0x1F & Tflags) was not valid and quad_bc was set to (0.0,0.0,0.0,0.0).

◆ CompareLocation()

static int ON_TriangleMesh::CompareLocation ( const double  a[3],
const double  b[3] 
)
static

Parameters: a - [in] b - [in] Returns: < 0: a < b in dictionary ordering = 0: a = b < 0: a > b in dictionary ordering Remarks: null pointers are considered less than non-null pointers.

◆ Create()

bool ON_TriangleMesh::Create ( const class ON_Mesh mesh,
bool  bPersistentMeshReference 
)

Description: Create a double precision triangle mesh from an ON_Mesh. Parameters: mesh - [in] Mesh to use for triangle references. bPersistentMeshReference - in If bPersistentMeshReference is true, then the caller is responsible for making sure "mesh" persists unchanged for the life of this ON_TriangleMesh class and as much mesh information as possible will be referenced. If bPersistentMeshReference is false, all information will be copied to heap managed by this ON_TriangleMesh class. Remarks: The index of the ON_Mesh::m_F[] facet used to generate the triangle is m_T[][3].
If ON_Mesh::m_F[fi] facet is a quad, then two triangles will be made using one of the following vertex sets from ON_MeshFace::vi[] array. (0,1,2,fi) and (0,2,3,fi), or (1,2,3,fi) and (1,3,0,fi)

◆ CreateTriangleRTree()

bool ON_TriangleMesh::CreateTriangleRTree ( class ON_RTree rtree) const

Description: Get an r-tree made from triangle bounding boxes and their indices that is managed by the caller.

◆ Destroy()

void ON_TriangleMesh::Destroy ( )

◆ DestroyCachedInformation()

void ON_TriangleMesh::DestroyCachedInformation ( )

Description: Deletes any cached bounding box, triangle plane, R-tree or Vmap information. Remarks: If you modify the length or values of the m_V[] of m_T[] arrays, then any cached bounding box, triangle plane, R-tree or Vmap information may be invalid and should be destroyed.

◆ EvNormal() [1/3]

bool ON_TriangleMesh::EvNormal ( const struct ON_TriangleMeshPoint triangle_point,
double  normal[3] 
) const

◆ EvNormal() [2/3]

bool ON_TriangleMesh::EvNormal ( unsigned int  triangle_index,
const double  tri_bc[3],
double  normal[3] 
) const

Description: Evaluate normal on the triangle mesh. Parameters: triangle_index - [in] index of the triangle tri_bc - [in] barycentric coordinates of the point a, b, c - [in] barycentric coordinates of the point

◆ EvNormal() [3/3]

bool ON_TriangleMesh::EvNormal ( unsigned int  triangle_index,
double  a,
double  b,
double  c,
double  normal[3] 
) const

◆ EvPoint() [1/3]

bool ON_TriangleMesh::EvPoint ( const struct ON_TriangleMeshPoint triangle_point,
double  point[3] 
) const

◆ EvPoint() [2/3]

bool ON_TriangleMesh::EvPoint ( unsigned int  triangle_index,
const double  tri_bc[3],
double  point[3] 
) const

Description: Evaluate point on the triangle mesh. Parameters: triangle_index - [in] index of the triangle tri_bc - [in] barycentric coordinates of the point a, b, c - [in] barycentric coordinates of the point

◆ EvPoint() [3/3]

bool ON_TriangleMesh::EvPoint ( unsigned int  triangle_index,
double  a,
double  b,
double  c,
double  point[3] 
) const

◆ EvPointAndNormal() [1/3]

bool ON_TriangleMesh::EvPointAndNormal ( const struct ON_TriangleMeshPoint triangle_point,
double  point[3],
double  normal[3] 
) const

◆ EvPointAndNormal() [2/3]

bool ON_TriangleMesh::EvPointAndNormal ( unsigned int  triangle_index,
const double  tri_bc[3],
double  point[3],
double  normal[3] 
) const

Description: Evaluate normal on the triangle mesh. Parameters: triangle_index - [in] index of the triangle tri_bc - [in] barycentric coordinates of the point a, b, c - [in] barycentric coordinates of the point

◆ EvPointAndNormal() [3/3]

bool ON_TriangleMesh::EvPointAndNormal ( unsigned int  triangle_index,
double  a,
double  b,
double  c,
double  point[3],
double  normal[3] 
) const

◆ GetClosestPoint()

bool ON_TriangleMesh::GetClosestPoint ( const class ON_3dPoint test_point,
double  maximum_distance_tolerance,
unsigned int *  triangle_index,
double  triangle_bc[3] 
) const

Description: Find a point on the triangle mesh that is closest to test_point. Parameters: test_point - [in] maximum_distance_tolerance - [in] If maximum_distance_tolerance >= 0.0, then an answer is returned only if the distance from the point on the triangle mesh to test_point is <= maximum_distance_tolerance. Otherwise the closest point is returned. triangle_index - [out] triangle_bc - [out] If the return value is true, then triangle_index identifies a triangle on the mesh that is closest to test_point.
The barycentric coordinates of the point on this triangle are returned in triangle_bc[0,1,2]. If the return value is false, then triangle_index is set to 0xFFFFFFFF and t is set to (ON_UNSET_VALUE,ON_UNSET_VALUE,ON_UNSET_VALUE).

◆ IntersectLine()

bool ON_TriangleMesh::IntersectLine ( const double  p0[3],
const double  p1[3],
double  tolerance,
bool ON_CALLBACK_CDECL   resultCallbackvoid *context, const double line_t[2], const struct ON_TriangleMeshPoint tri_t[2], struct ON_RTreeCapsule *capsule,
void *  context 
) const

Description: Find the intersection points of a line segment and the triangle mesh. Parameters: p0 - [in] p1 - [in] The line segment begins at p0 and ends at p1. tolerance - [in] The distance between the returned points on the line segment and the mesh will be <= tolerance. resultCallback - [in] Each time an intersection point is found, resultCallback is called. If resultCallback() returns true, the search for additional intersection points continues. If resultCallback() returns false, the search is terminated. The "line_t" and "tri"t" parameters provide the location of the intersection point. If the intersection is a single point, then line_t[0] = line_t[1] and tri_t[0] = tri_t[1]. If the line and triangle overlap, then 0 <= line_t[0] < line_t[1] <= 1. The capsule parameter may be shrunk as needed to speed searching in applications like ray shooting. See ON_RTree::Search() for more details about capsule shrinking. context - [in] This pointer is passed as the first argument to resultCallback(). Returns: True if intersection points were found.

◆ MeshForm()

class ON_Mesh* ON_TriangleMesh::MeshForm ( class ON_Mesh mesh) const

Description: Get an ON_Mesh that looks like this triangle mesh. Parameters: mesh - [in] null or the mesh to store the result. Returns: Null if this mesh is not valid, otherwise a pointer to an ON_Mesh class that looks like this triangle mesh. If the mesh input parameter is null, then the returned mesh is on the heap and must be managed by the caller.

◆ MeshReference()

const class ON_Mesh* ON_TriangleMesh::MeshReference ( ) const

◆ OffsetMesh() [1/3]

bool ON_TriangleMesh::OffsetMesh ( double  offset_distance)

◆ OffsetMesh() [2/3]

bool ON_TriangleMesh::OffsetMesh ( double  offset_distance,
const double(*)  N[3],
double(*)  offset_V[3] 
) const

Description: Offset a triangle mesh. Parameters: offset_distance - [in] N - [in] array of m_V_count vertex unit length normals. offset_V - [out] Offset vertex locations are returned here. Pass const_cast< double (*)[3] > m_V if you want to offset this mesh in place. Returns: True if successful. False if input parameters are not valid.

◆ OffsetMesh() [3/3]

bool ON_TriangleMesh::OffsetMesh ( double  offset_distance,
const float(*)  N[3],
double(*)  offset_V[3] 
) const

◆ operator=()

ON_TriangleMesh& ON_TriangleMesh::operator= ( const ON_TriangleMesh )

◆ PlaneEquation()

const class ON_TrianglePlane* ON_TriangleMesh::PlaneEquation ( unsigned int  triangle_index) const

◆ SetStatus()

void ON_TriangleMesh::SetStatus ( unsigned int  triangle_index,
unsigned int  status 
)

◆ Status()

unsigned int ON_TriangleMesh::Status ( unsigned int  triangle_index) const

◆ StatusArray()

const unsigned int* ON_TriangleMesh::StatusArray ( ) const

Returns: nullptr if SetStatus has not been called. Otherwise a pointer to the m_status[] array. If you const_cast<> this array and modify it, then the value returned by SetStatus() will not be reliable.

◆ StatusCount()

unsigned int ON_TriangleMesh::StatusCount ( ) const

Returns: Number of non-zero status values.

◆ TriangleRTree()

const class ON_RTree* ON_TriangleMesh::TriangleRTree ( ) const

Description: Get an r-tree made from triangle bounding boxes and their indices that is managed by the ON_TriangleMesh class.

◆ VertexMap()

const unsigned int* ON_TriangleMesh::VertexMap ( ) const

Description: Get a Returns: A permutation of {0,1, ..., m_V_count-1} such that all ON_TriangleMesh::CompareLocation( Vmap[i], Vmap[i+1] ) <= 0.

◆ VertexPoints()

const ON_3dPoint* ON_TriangleMesh::VertexPoints ( ) const

Returns: Vertex locations as an array of ON_3dPoints saving you the cast operation.

Member Data Documentation

◆ m_N

const double(* ON_TriangleMesh::m_N)[3]

optional vertex unit normals

◆ m_T

const unsigned int(* ON_TriangleMesh::m_T)[3]

triangles m_V[m_T[ti][0]], m_V[m_T[ti][1]], m_V[m_T[ti][2]]

◆ m_T_count

unsigned int ON_TriangleMesh::m_T_count

number of triangles in m_T[]

◆ m_T_flags

const unsigned int* ON_TriangleMesh::m_T_flags

triangle flags m_T_flags can be nullptr. If it is not nullptr, then information about triangle m_T[ti] is encoded in m_T_flags[ti] as follows:

(m_T_flags[ti] & 0x3F): The low six bits (m_T_flags[ti] & 0x3F) specifies how to convert triangle barycentric coordinates (a,b,c) to ON_MeshFace barycentric coordinates. q[ 0x03 & T_flags ] = a q[(0x0C & T_flags)>>2] = b q[(0x30 & T_flags)>>4] = c q[other element] = 0.0 The static function BarycentricTriToQuad() will perform the conversion.

(m_T_flags[ti] & 0x01C0): The next 3 bits are used to indicate when an edge of a triangle is not an edge of the original mesh object. For example, when a quad is split into two triangles, the triangles edges corresponding to the splitting diagonal have their bits set. 0 != (m_T_flags[ti] & 0x0040) means the triangle edge opposite vertex m_T[ti][0] is not an edge in the original mesh. 0 != (m_T_flags[ti] & 0x0080) means the triangle edge opposite vertex m_T[ti][1] is not an edge in the original mesh. 0 != (m_T_flags[ti] & 0x0100) means the triangle edge opposite vertex m_T[ti][2] is not an edge in the original mesh. triangle flags

◆ m_T_id

const unsigned int* ON_TriangleMesh::m_T_id

m_T[i][4] = "id" value used in various ways m_T[i][4] = "id" value used in various ways triangle "id" values depend on context and can set as needed.

◆ m_V

const double(* ON_TriangleMesh::m_V)[3]

vertex locations

◆ m_V_count

unsigned int ON_TriangleMesh::m_V_count

number of vertices in m_V[]