xmsgrid  1.0
xms::TrTinImpl Class Reference

Class to encapsulate a tin made simply of arrays of points, triangles and adjacency information. Also methods to manipulate it. More...

Inheritance diagram for xms::TrTinImpl:
xms::TrTin

Public Member Functions

 TrTinImpl ()
 constructor
 
virtual ~TrTinImpl ()
 destructor
 
virtual void SetPoints (BSHP< VecPt3d > a_pts) override
 Sets the tin points. More...
 
virtual void SetTriangles (BSHP< VecInt > a_tris) override
 Sets the tin triangles. More...
 
virtual void SetTrianglesAdjacentToPoints (BSHP< VecInt2d > a_trisAdjToPts) override
 Sets the adjacency info of triangles adjacent to points. More...
 
virtual void SetGeometry (BSHP< VecPt3d > a_pts, BSHP< VecInt > a_tris, BSHP< VecInt2d > a_trisAdjToPts) override
 Set all the tin geometry at once (points, triangles, adjacency). More...
 
virtual VecPt3dPoints () override
 Return the tin points. More...
 
virtual VecIntTriangles () override
 Return 0-based indices of triangle points (grouped by 3s). More...
 
virtual VecInt2dTrisAdjToPts () override
 Returns triangles adjacent to points (0-based). More...
 
virtual const VecPt3dPoints () const override
 Return the tin points. More...
 
virtual const VecIntTriangles () const override
 Return 0-based indices of triangle points (grouped by 3s). More...
 
virtual const VecInt2dTrisAdjToPts () const override
 Returns triangles adjacent to points (0-based). More...
 
virtual BSHP< VecPt3dPointsPtr () override
 Return the pointer to tin points. More...
 
virtual BSHP< VecIntTrianglesPtr () override
 Return the pointer to tin triangles. More...
 
virtual int NumPoints () const override
 Return the number of points. More...
 
virtual int NumTriangles () const override
 Return the number of triangles. More...
 
virtual bool TriangleFromEdge (int a_pt1, int a_pt2, int &a_tri, int &a_idx1, int &a_idx2) const override
 Finds the triangle with the edge defined by a_pt1 and a_pt2 and the local index of those points. Compare to trTinTriFromEdge. More...
 
virtual int TriangleAdjacentToEdge (int a_pt1, int a_pt2) const override
 Returns the triangle adjacent to the edge defined by a_pt1 and a_pt2. Compare to trTriangleAdjacentToEdge. More...
 
virtual int LocalIndex (int a_tri, int a_pt) const override
 Returns index (0-2) of point within triangle given global index. Compare to trIndex. More...
 
virtual int GlobalIndex (int a_triIdx, int a_localVtxIdx) const override
 Returns index into m_pts of a_localPt which is 0-2. More...
 
virtual bool VerticesAreAdjacent (int a_pt1, int a_pt2) const override
 Return true if vertices form the edge of a triangle. Compare to vrVerticesAreAdjacent. More...
 
virtual int CommonEdgeIndex (int a_tri, int a_adjTri) const override
 Return index of common edge between triangle and neighbor. Edge index is 0-2 based on a_tri. Compare to trCommonEdgeIndex. More...
 
virtual int AdjacentTriangle (int a_triIdx, int a_edgeIdx) const override
 Returns the triangle adjacent to a_triIdx across a_edgeIdx (0-2). Compare to trAdjacentTriangle. Example: a_edgeIdx 2 returns triangle adjacent to edge c. More...
 
virtual Pt3d TriangleCentroid (int a_tri) const override
 Calculate and return the centroid of a triangle. More...
 
virtual double TriangleArea (int a_tri) const override
 Calculate and return the area of a triangle. More...
 
virtual int NextBoundaryPoint (int a_point) const override
 Returns the next point CW from point on the boundary. CCW if in an inside hole. Compare to trNextBoundaryVertex (or trPreviousBoundaryVertex since order here is CW, not CCW). More...
 
virtual int PreviousBoundaryPoint (int a_point) const override
 Returns the previous point CCW from point on the boundary. CW if in an inside hole. Compare to trPreviousBoundaryVertex (or trNextBoundaryVertex since order here is CW, not CCW). More...
 
virtual void GetBoundaryPoints (VecInt &a_boundaryPoints) const override
 Gives the 0-based indices of all points on any boundary, in no particular order. More...
 
virtual void GetBoundaryPolys (VecInt2d &a_polys) const override
 Gets exterior boundary and all interior voids as polygons of 0-based point indices. First point is not repeated as the last point. More...
 
virtual bool GetExtents (Pt3d &a_mn, Pt3d &a_mx) const override
 Computes the extents (min, max) of the tin. More...
 
virtual void ExportTinFile (std::ostream &a_os) const override
 Export in the .tin file format. Useful for debugging. More...
 
virtual bool SwapEdge (int a_triA, int a_triB, bool a_checkAngle=true) override
 Swap edges if triangles combine to form convex quad. Compare to trSwapEdge. More...
 
virtual void DeleteTriangles (const SetInt &a_trisToDelete) override
 Deletes the triangles specified in a_trisToDelete and updates and renumbers triangle adjacency info. More...
 
virtual void DeletePoints (const SetInt &a_points) override
 Deletes the points and any attached triangles, updates adjacency and renumbers things. More...
 
virtual bool OptimizeTriangulation () override
 Swaps triangle edges until they are a Delauney triangulation. More...
 
virtual bool RemoveLongThinTrianglesOnPerimeter (const double a_ratio) override
 Removes long thin triangles on the boundary of the TIN. More...
 
virtual void Clear () override
 Delete the memory.
 
virtual void BuildTrisAdjToPts () override
 Build array of triangles adjacent to points.
 
virtual std::string ToString () const override
 Use boost archive to get the TrTin as text. More...
 
virtual void FromString (const std::string &) override
 Use boost archive to turn the text into a TrTin. More...
 
template<typename Archive >
void serialize (Archive &archive, const unsigned int version)
 Boost serialize function. More...
 
- Public Member Functions inherited from xms::TrTin
virtual ~TrTin ()
 destructor
 

Private Member Functions

void InsertAdjacentTriangle (int a_pt, int a_tri)
 Adds a_tri as an adjacent triangle to a_pt and updates m_trisAdjToPts. More...
 
void DeleteAdjacentTriangle (int a_pt, int a_tri)
 Removes a_tri from a_pt's adjacent triangles. Compare to vrDeleteAdjacentTrianglePtr. More...
 
bool TriIndexFound (const int &a_triPt) const
 Predicate used in remove_if to get the index of the current item in the vector. More...
 
bool PointIndexFound (const Pt3d &a_point) const
 Predicate used in remove_if to get the index of the current item in the vector. More...
 
bool AdjacentIndexFound (const VecInt &a_point) const
 Predicate used in remove_if to get the index of the current item in the vector. More...
 
bool CheckAndSwap (int a_triA, int a_triB, bool a_propagate, const VecInt &a_flags)
 Swap edges if triangles combine to form convex quad. Compare to trCheckAndSwap. More...
 
bool PointIsInCircumcircle (int a_tri1, int a_tri2, int id)
 Returns true if a_localPt of a_tri2 is inside a_tri1's circumcircle. More...
 
void BuildTrisAdjToPtsConst () const
 A const function used only internally and needed to modify m_trisAdjToPts which is mutable.
 
void CheckTriangle (const int a_tri, const int a_index, const double a_ratio, VecInt &a_flags, SetInt &a_trisToDelete) const
 If triangle is long and thin (index edge is long compared to sum of other two edges) the triangle is marked for deletion and the triangles adjacent to the other two edges are checked. More...
 
int AdjacentTriangleIndex (const int a_currTri, const int a_adjTri) const
 finds the index of adjacent triangle that points to the current triangle More...
 

Private Attributes

BSHP< VecPt3dm_pts
 tin points
 
BSHP< VecIntm_tris
 triangles, 0-based indices to m_pts, grouped by 3s
 
BSHP< VecInt2dm_trisAdjToPts
 triangles adjacent to points. 1st dim = size of m_pts
 
boost::unordered_set< int > m_toDelete
 Used only when deleting stuff.
 

Additional Inherited Members

- Static Public Member Functions inherited from xms::TrTin
static BSHP< TrTinNew ()
 Create a TrTinImpl object. More...
 
- Protected Member Functions inherited from xms::TrTin
 TrTin ()
 constructor
 

Detailed Description

Class to encapsulate a tin made simply of arrays of points, triangles and adjacency information. Also methods to manipulate it.

Definition at line 55 of file TrTin.cpp.

Member Function Documentation

◆ AdjacentIndexFound()

bool xms::TrTinImpl::AdjacentIndexFound ( const VecInt a_adj) const
private

Predicate used in remove_if to get the index of the current item in the vector.

See also
http://stackoverflow.com/questions/23122555/ This could be a lamda defined where it's used if we could figure out how to get that to work.
Parameters
[in]a_adjTriangles adjacent to a point.
Returns
true if found, else false.

Definition at line 980 of file TrTin.cpp.

References m_toDelete.

Referenced by DeletePoints().

◆ AdjacentTriangle()

int xms::TrTinImpl::AdjacentTriangle ( int  a_triIdx,
int  a_edgeIdx 
) const
overridevirtual

Returns the triangle adjacent to a_triIdx across a_edgeIdx (0-2). Compare to trAdjacentTriangle. Example: a_edgeIdx 2 returns triangle adjacent to edge c.

///              2
///             / \
///          c /   \ b
///           /     \
///          0-------1
///              a
/// 
Parameters
a_triIdxTriangle index (0-based).
a_edgeIdxLocal edge index (0-2) in a_tri.
Returns
Triangle adjacent to a_tri along it's a_edge or XM_NONE if there is no triangle adjacent to the edge.

Definition at line 633 of file TrTin.cpp.

References TriangleFromEdge(), xms::trIncrementIndex(), and XM_NONE.

Referenced by AdjacentTriangleIndex(), CheckAndSwap(), CheckTriangle(), CommonEdgeIndex(), GetBoundaryPoints(), NextBoundaryPoint(), OptimizeTriangulation(), PreviousBoundaryPoint(), and RemoveLongThinTrianglesOnPerimeter().

◆ AdjacentTriangleIndex()

int xms::TrTinImpl::AdjacentTriangleIndex ( const int  a_currTri,
const int  a_adjTri 
) const
private

finds the index of adjacent triangle that points to the current triangle

Parameters
[in]a_currTriThe index of the triangle to check.
[in]a_adjTriThe index of the adjacent triangle.
Returns
The index of the adjacent triangle that points to the current triangle or XM_NONE if the triangles are not adjacent

Definition at line 1154 of file TrTin.cpp.

References AdjacentTriangle(), and XM_NONE.

Referenced by CheckTriangle().

◆ CheckAndSwap()

bool xms::TrTinImpl::CheckAndSwap ( int  a_triA,
int  a_triB,
bool  a_propagate,
const VecInt a_flags 
)
private

Swap edges if triangles combine to form convex quad. Compare to trCheckAndSwap.

a_triA and a_triB must be adjacent triangles.

           b2 * top
             / \
            /   \   a_triB
        b3 / --> \ b1
      lft *-------* rgt
           \ <-- / a3
            \   /   a_triA
             \ /
          btm * a2
Parameters
a_triAFirst triangle.
a_triBSecond triangle.
a_propagateIf true, recursively checks adjacent triangles, which will happen even if false if adjacent triangles flag is not zero.
a_flagsFlags to keep track of visited triangles.
Returns
true if swap was successful.

Definition at line 517 of file TrTin.cpp.

References AdjacentTriangle(), CommonEdgeIndex(), GlobalIndex(), LocalIndex(), PointIsInCircumcircle(), SwapEdge(), xms::trDecrementIndex(), xms::trIncrementIndex(), XM_ENSURE_TRUE_NO_ASSERT, and XM_NONE.

Referenced by OptimizeTriangulation().

◆ CheckTriangle()

void xms::TrTinImpl::CheckTriangle ( const int  a_tri,
const int  a_index,
const double  a_ratio,
VecInt a_flags,
SetInt a_trisToDelete 
) const
private

If triangle is long and thin (index edge is long compared to sum of other two edges) the triangle is marked for deletion and the triangles adjacent to the other two edges are checked.

Parameters
[in]a_triThe index of the triangle to check.
[in]a_indexThe index of the triangle's edge to check.
[in]a_ratioThe ratio of one edge length compared to the sum of the other two edge lengths. If the length ratio of a triangle is greater then or equal to this given ratio, the triangle is marked for deletion.
[in,out]a_flagsFlags for each of the triangles.
[out]a_trisToDeleteTriangles to be deleted that are long and thin.

Definition at line 1181 of file TrTin.cpp.

References AdjacentTriangle(), AdjacentTriangleIndex(), xms::gmXyDistance(), m_pts, m_tris, xms::trIncrementIndex(), and XM_NONE.

Referenced by RemoveLongThinTrianglesOnPerimeter().

◆ CommonEdgeIndex()

int xms::TrTinImpl::CommonEdgeIndex ( int  a_tri,
int  a_adjTri 
) const
overridevirtual

Return index of common edge between triangle and neighbor. Edge index is 0-2 based on a_tri. Compare to trCommonEdgeIndex.

a_triIdx must be adjacent to neighbor.

Parameters
a_triTriangle index (0-based).
a_adjTriAdjacent triangle index (0-based).
Returns
Index of edge (0-2) in a_tri between a_tri and a_adTri, or XM_NONE if not adjacent.

Definition at line 598 of file TrTin.cpp.

References AdjacentTriangle(), xms::trIncrementIndex(), and XM_NONE.

Referenced by CheckAndSwap(), and SwapEdge().

◆ DeleteAdjacentTriangle()

void xms::TrTinImpl::DeleteAdjacentTriangle ( int  a_pt,
int  a_tri 
)
private

Removes a_tri from a_pt's adjacent triangles. Compare to vrDeleteAdjacentTrianglePtr.

Parameters
[in]a_ptThe point from which we are removing an adjacent triangle.
[in]a_triThe triangle we are removing as an adjacent from point.

Definition at line 917 of file TrTin.cpp.

Referenced by SwapEdge().

◆ DeletePoints()

void xms::TrTinImpl::DeletePoints ( const SetInt a_points)
overridevirtual

Deletes the points and any attached triangles, updates adjacency and renumbers things.

Parameters
[in]a_pointsThe set of points to delete.

Definition at line 1060 of file TrTin.cpp.

References AdjacentIndexFound(), DeleteTriangles(), m_toDelete, m_tris, m_trisAdjToPts, PointIndexFound(), and xms::trRenumberOnDelete().

◆ DeleteTriangles()

void xms::TrTinImpl::DeleteTriangles ( const SetInt a_trisToDelete)
overridevirtual

Deletes the triangles specified in a_trisToDelete and updates and renumbers triangle adjacency info.

Parameters
[in]a_trisToDeleteTriangles to be deleted.

Definition at line 990 of file TrTin.cpp.

References m_toDelete, NumTriangles(), TriIndexFound(), and XM_ENSURE_TRUE_VOID_NO_ASSERT.

Referenced by DeletePoints(), and RemoveLongThinTrianglesOnPerimeter().

◆ ExportTinFile()

void xms::TrTinImpl::ExportTinFile ( std::ostream &  a_os) const
overridevirtual

Export in the .tin file format. Useful for debugging.

Parameters
[out]a_osThe stream to export to.

Definition at line 876 of file TrTin.cpp.

References NumTriangles(), and STRstd().

◆ FromString()

void xms::TrTinImpl::FromString ( const std::string &  a_text)
overridevirtual

Use boost archive to turn the text into a TrTin.

Parameters
[in]a_textThe string.

Definition at line 1279 of file TrTin.cpp.

◆ GetBoundaryPoints()

void xms::TrTinImpl::GetBoundaryPoints ( VecInt a_boundaryPoints) const
overridevirtual

Gives the 0-based indices of all points on any boundary, in no particular order.

Parameters
[out]a_boundaryPointsThe 0-based indices of all points on the boundary.

Definition at line 776 of file TrTin.cpp.

References AdjacentTriangle(), BuildTrisAdjToPtsConst(), m_tris, xms::trIncrementIndex(), TrisAdjToPts(), and XM_NONE.

Referenced by GetBoundaryPolys().

◆ GetBoundaryPolys()

void xms::TrTinImpl::GetBoundaryPolys ( VecInt2d a_polys) const
overridevirtual

Gets exterior boundary and all interior voids as polygons of 0-based point indices. First point is not repeated as the last point.

Parameters
[out]a_polysOuter polygon is CW, inner polys are CCW. First point is repeated at the end.

Definition at line 810 of file TrTin.cpp.

References xmlog::debug, GetBoundaryPoints(), NextBoundaryPoint(), and XM_LOG.

◆ GetExtents()

bool xms::TrTinImpl::GetExtents ( Pt3d a_mn,
Pt3d a_mx 
) const
overridevirtual

Computes the extents (min, max) of the tin.

Parameters
[out]a_mnMinimum xyz.
[out]a_mxMaximum xyz.
Returns
true if there are any points and the extents were computed.

Definition at line 857 of file TrTin.cpp.

References xms::gmAddToExtents().

◆ GlobalIndex()

int xms::TrTinImpl::GlobalIndex ( int  a_triIdx,
int  a_localPt 
) const
overridevirtual

Returns index into m_pts of a_localPt which is 0-2.

Parameters
a_triIdx= Triangle index (0-based).
a_localPt= Local index (0-2) of point within the triangle.
Returns
Global index into m_pts of a_localPt.

Definition at line 935 of file TrTin.cpp.

References m_tris, XM_ENSURE_TRUE, and XM_NONE.

Referenced by CheckAndSwap(), NextBoundaryPoint(), PointIsInCircumcircle(), PreviousBoundaryPoint(), and SwapEdge().

◆ InsertAdjacentTriangle()

void xms::TrTinImpl::InsertAdjacentTriangle ( int  a_pt,
int  a_tri 
)
private

Adds a_tri as an adjacent triangle to a_pt and updates m_trisAdjToPts.

Parameters
[in]a_ptThe point that a_tri is adjacent to.
[in]a_triThe triangle adjacent to a_pt to add to list of adjacents.

Definition at line 905 of file TrTin.cpp.

References XM_ENSURE_TRUE_VOID.

Referenced by SwapEdge().

◆ LocalIndex()

int xms::TrTinImpl::LocalIndex ( int  a_tri,
int  a_pt 
) const
overridevirtual

Returns index (0-2) of point within triangle given global index. Compare to trIndex.

Parameters
a_triTriangle index (0-based).
a_ptGlobal point index (0-based).
Returns
The local index (0-2) of the point a_pt in the triangle a_tri or XM_NONE if a_pt is not on a_tri.

Definition at line 361 of file TrTin.cpp.

References m_tris, and XM_NONE.

Referenced by CheckAndSwap(), NextBoundaryPoint(), PreviousBoundaryPoint(), SwapEdge(), TriangleAdjacentToEdge(), and TriangleFromEdge().

◆ NextBoundaryPoint()

int xms::TrTinImpl::NextBoundaryPoint ( int  a_point) const
overridevirtual

Returns the next point CW from point on the boundary. CCW if in an inside hole. Compare to trNextBoundaryVertex (or trPreviousBoundaryVertex since order here is CW, not CCW).

Point must be on the boundary.

Parameters
[in]a_pointThe starting point.
Returns
The point index or XM_NONE if not found.

Definition at line 710 of file TrTin.cpp.

References AdjacentTriangle(), GlobalIndex(), LocalIndex(), m_trisAdjToPts, xms::trDecrementIndex(), XM_ENSURE_TRUE_NO_ASSERT, and XM_NONE.

Referenced by GetBoundaryPolys().

◆ NumPoints()

int xms::TrTinImpl::NumPoints ( ) const
overridevirtual

Return the number of points.

Returns
Number of points.

Definition at line 280 of file TrTin.cpp.

◆ NumTriangles()

int xms::TrTinImpl::NumTriangles ( ) const
overridevirtual

Return the number of triangles.

Returns
Number of triangles.

Definition at line 288 of file TrTin.cpp.

Referenced by DeleteTriangles(), ExportTinFile(), OptimizeTriangulation(), and RemoveLongThinTrianglesOnPerimeter().

◆ OptimizeTriangulation()

bool xms::TrTinImpl::OptimizeTriangulation ( )
overridevirtual

Swaps triangle edges until they are a Delauney triangulation.

Returns
True if modified.

Definition at line 1106 of file TrTin.cpp.

References AdjacentTriangle(), CheckAndSwap(), NumTriangles(), xms::trIncrementIndex(), and XM_NONE.

◆ PointIndexFound()

bool xms::TrTinImpl::PointIndexFound ( const Pt3d a_point) const
private

Predicate used in remove_if to get the index of the current item in the vector.

See also
http://stackoverflow.com/questions/23122555/ This could be a lamda defined where it's used if we could figure out how to get that to work.
Parameters
[in]a_pointA point in a tin.
Returns
true if found, else false.

Definition at line 965 of file TrTin.cpp.

References m_toDelete.

Referenced by DeletePoints().

◆ PointIsInCircumcircle()

bool xms::TrTinImpl::PointIsInCircumcircle ( int  a_tri1,
int  a_tri2,
int  a_localPt 
)
private

Returns true if a_localPt of a_tri2 is inside a_tri1's circumcircle.

SPECIAL CASE - we want all square elements to have a "diagonal" that is connected from lower left to upper right corner, so if a_tri1 and a_tri2 form a square or rectangle, it will return TRUE if the "diagonal" edge is from upper left to lower right corner and FALSE if the "diagonal" edge is from lower left to upper right corner.

Parameters
a_tri1Triangle (0-based) adjacent to a_tri2.
a_tri2Triangle (0-based) adjacent to a_tri1.
a_localPtLocal index (0-2) of the point in a_tri2 that is opposite a_tri1.
Returns
true if a_localPt of a_tri2 is inside a_tri1's circumcircle, else false.
Precondition
Triangles must be adjacent
///
///        *------------*
///        |          / |
///        | a_tri1 /   |
///        |      /     |
///        |    /       |
///        |  /  a_tri2 |
///        *------------*
///                      a_localPt
/// 

Definition at line 582 of file TrTin.cpp.

References GlobalIndex(), xms::gmPtInCircumcircle(), m_pts, and xms::PT_IN.

Referenced by CheckAndSwap().

◆ Points() [1/2]

VecPt3d & xms::TrTinImpl::Points ( )
overridevirtual

Return the tin points.

Returns
The points in the tin.

Definition at line 216 of file TrTin.cpp.

References m_pts.

◆ Points() [2/2]

const VecPt3d & xms::TrTinImpl::Points ( ) const
overridevirtual

Return the tin points.

Returns
The points in the tin.

Definition at line 240 of file TrTin.cpp.

References m_pts.

◆ PointsPtr()

BSHP< VecPt3d > xms::TrTinImpl::PointsPtr ( )
overridevirtual

Return the pointer to tin points.

Returns
Shared pointer to the points vector.

Definition at line 264 of file TrTin.cpp.

References m_pts.

◆ PreviousBoundaryPoint()

int xms::TrTinImpl::PreviousBoundaryPoint ( int  a_point) const
overridevirtual

Returns the previous point CCW from point on the boundary. CW if in an inside hole. Compare to trPreviousBoundaryVertex (or trNextBoundaryVertex since order here is CW, not CCW).

Point must be on the boundary.

Parameters
[in]a_pointThe starting point.
Returns
The point index or XM_NONE if not found.

Definition at line 745 of file TrTin.cpp.

References AdjacentTriangle(), GlobalIndex(), LocalIndex(), m_trisAdjToPts, xms::trIncrementIndex(), XM_ENSURE_TRUE_NO_ASSERT, and XM_NONE.

◆ RemoveLongThinTrianglesOnPerimeter()

bool xms::TrTinImpl::RemoveLongThinTrianglesOnPerimeter ( const double  a_ratio)
overridevirtual

Removes long thin triangles on the boundary of the TIN.

Parameters
[in]a_ratioThe ratio of one edge length compared to the sum of the other two edge lengths. If the length ratio of a triangle is greater then or equal to this given ratio, the triangle is deleted.
Returns
true on success.

Definition at line 1219 of file TrTin.cpp.

References AdjacentTriangle(), CheckTriangle(), DeleteTriangles(), NumTriangles(), and XM_NONE.

◆ serialize()

template<typename Archive >
void xms::TrTinImpl::serialize ( Archive &  archive,
const unsigned int  version 
)

Boost serialize function.

Parameters
archiveThe archive.
versionVersion number.

Definition at line 1293 of file TrTin.cpp.

References m_pts, m_tris, and m_trisAdjToPts.

◆ SetGeometry()

void xms::TrTinImpl::SetGeometry ( BSHP< VecPt3d a_pts,
BSHP< VecInt a_tris,
BSHP< VecInt2d a_trisAdjToPts 
)
overridevirtual

Set all the tin geometry at once (points, triangles, adjacency).

Parameters
[in]a_ptsThe tin points.
[in]a_tris0-based indices of triangle points (grouped by 3s)
[in]a_trisAdjToPts0-based indices of triangles adjacent to points.

Definition at line 206 of file TrTin.cpp.

References m_pts, m_tris, and m_trisAdjToPts.

◆ SetPoints()

void xms::TrTinImpl::SetPoints ( BSHP< VecPt3d a_pts)
overridevirtual

Sets the tin points.

Parameters
[in]a_ptsThe points.

Definition at line 180 of file TrTin.cpp.

References m_pts.

◆ SetTriangles()

void xms::TrTinImpl::SetTriangles ( BSHP< VecInt a_tris)
overridevirtual

Sets the tin triangles.

Parameters
[in]a_tris0-based indices of each triangle's points (grouped by 3s)

Definition at line 188 of file TrTin.cpp.

References m_tris.

◆ SetTrianglesAdjacentToPoints()

void xms::TrTinImpl::SetTrianglesAdjacentToPoints ( BSHP< VecInt2d a_trisAdjToPts)
overridevirtual

Sets the adjacency info of triangles adjacent to points.

Parameters
[in]a_trisAdjToPts0-based indices of triangles adjacent to points.

Definition at line 196 of file TrTin.cpp.

References m_trisAdjToPts.

◆ SwapEdge()

bool xms::TrTinImpl::SwapEdge ( int  a_triA,
int  a_triB,
bool  a_checkAngle = true 
)
overridevirtual

Swap edges if triangles combine to form convex quad. Compare to trSwapEdge.

a_triA and a_triB must be adjacent triangles.

           b2 * top
             / \
            /   \   a_triB
        b3 / --> \ b1
      lft *-------* rgt
           \ <-- / a3
            \   /   a_triA
             \ /
          btm * a2
Parameters
a_triAFirst triangle.
a_triBSecond triangle.
a_checkAngleIf true, won't swap if very thin triangle would be created.
Returns
true if swap was successful.

Definition at line 419 of file TrTin.cpp.

References CommonEdgeIndex(), DeleteAdjacentTriangle(), xmlog::error, GlobalIndex(), xms::gmAngleBetweenEdges(), xms::gmCounterClockwiseTri(), InsertAdjacentTriangle(), LocalIndex(), m_pts, m_tris, xms::trArea(), xms::trDecrementIndex(), xms::trIncrementIndex(), XM_ENSURE_TRUE_NO_ASSERT, XM_LOG, and XM_PI.

Referenced by CheckAndSwap().

◆ ToString()

std::string xms::TrTinImpl::ToString ( ) const
overridevirtual

Use boost archive to get the TrTin as text.

Returns
The string.

Definition at line 1266 of file TrTin.cpp.

◆ TriangleAdjacentToEdge()

int xms::TrTinImpl::TriangleAdjacentToEdge ( int  a_pt1,
int  a_pt2 
) const
overridevirtual

Returns the triangle adjacent to the edge defined by a_pt1 and a_pt2. Compare to trTriangleAdjacentToEdge.

Gives triangle on the right side of the edge.

Parameters
a_pt1First edge point index (0-based).
a_pt2Second edge point index (0-based).
Returns
The triangle adjacent to the edge.

Definition at line 334 of file TrTin.cpp.

References LocalIndex(), m_tris, xms::trDecrementIndex(), and XM_NONE.

◆ TriangleArea()

double xms::TrTinImpl::TriangleArea ( int  a_tri) const
overridevirtual

Calculate and return the area of a triangle.

Parameters
a_triTriangle index (0-based).
Returns
The area.

Definition at line 665 of file TrTin.cpp.

References m_pts, m_tris, and xms::trArea().

◆ TriangleCentroid()

xms::Pt3d xms::TrTinImpl::TriangleCentroid ( int  a_tri) const
overridevirtual

Calculate and return the centroid of a triangle.

Parameters
a_triTriangle index (0-based).
Returns
The centroid.

Definition at line 652 of file TrTin.cpp.

References m_pts, and m_tris.

◆ TriangleFromEdge()

bool xms::TrTinImpl::TriangleFromEdge ( int  a_pt1,
int  a_pt2,
int &  a_tri,
int &  a_localPt1,
int &  a_localPt2 
) const
overridevirtual

Finds the triangle with the edge defined by a_pt1 and a_pt2 and the local index of those points. Compare to trTinTriFromEdge.

Parameters
[in]a_pt1First edge point index (0-based).
[in]a_pt2Second edge point index (0-based).
[out]a_triIndex of triangle or XM_NONE if not found.
[out]a_localPt1Local pt (0-2) of a_pt1 in a_tri.
[out]a_localPt2Local pt (0-2) of a_pt2 in a_tri.
Returns
true if found.

Definition at line 302 of file TrTin.cpp.

References LocalIndex(), m_tris, xms::trIncrementIndex(), and XM_NONE.

Referenced by AdjacentTriangle().

◆ Triangles() [1/2]

VecInt & xms::TrTinImpl::Triangles ( )
overridevirtual

Return 0-based indices of triangle points (grouped by 3s).

Returns
Triangles as 0-based indices of triangle points (grouped by 3s).

Definition at line 224 of file TrTin.cpp.

References m_tris.

◆ Triangles() [2/2]

const VecInt & xms::TrTinImpl::Triangles ( ) const
overridevirtual

Return 0-based indices of triangle points (grouped by 3s).

Returns
Triangles as 0-based indices of triangle points (grouped by 3s).

Definition at line 248 of file TrTin.cpp.

References m_tris.

◆ TrianglesPtr()

BSHP< VecInt > xms::TrTinImpl::TrianglesPtr ( )
overridevirtual

Return the pointer to tin triangles.

Returns
Shared pointer to the triangle points vector.

Definition at line 272 of file TrTin.cpp.

References m_tris.

◆ TriIndexFound()

bool xms::TrTinImpl::TriIndexFound ( const int &  a_triPt) const
private

Predicate used in remove_if to get the index of the current item in the vector.

See also
http://stackoverflow.com/questions/23122555/ This could be a lamda defined where it's used if we could figure out how to get that to work.
Parameters
[in]a_triPtIndex of a point on a triangle.
Returns
true if found, else false.

Definition at line 950 of file TrTin.cpp.

References m_toDelete.

Referenced by DeleteTriangles().

◆ TrisAdjToPts() [1/2]

VecInt2d & xms::TrTinImpl::TrisAdjToPts ( )
overridevirtual

Returns triangles adjacent to points (0-based).

Returns
2D vector with triangles adjacent to points, size of num points.

Definition at line 232 of file TrTin.cpp.

References m_trisAdjToPts.

Referenced by GetBoundaryPoints().

◆ TrisAdjToPts() [2/2]

const VecInt2d & xms::TrTinImpl::TrisAdjToPts ( ) const
overridevirtual

Returns triangles adjacent to points (0-based).

Returns
2D vector with triangles adjacent to points, size of num points.

Definition at line 256 of file TrTin.cpp.

References m_trisAdjToPts.

◆ VerticesAreAdjacent()

bool xms::TrTinImpl::VerticesAreAdjacent ( int  a_pt1,
int  a_pt2 
) const
overridevirtual

Return true if vertices form the edge of a triangle. Compare to vrVerticesAreAdjacent.

Parameters
a_pt1First point index (0-based).
a_pt2Second point index (0-based).
Returns
true if points are adjacent.

Definition at line 378 of file TrTin.cpp.

References m_tris.


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