|
xmsgeom
1.0
|
Class to encapsulate a tin made simply of arrays of points, triangles and adjacency information. Also methods to manipulate it. More...
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 VecPt3d & | Points () override |
| Return the tin points. More... | |
| virtual VecInt & | Triangles () override |
| Return 0-based indices of triangle points (grouped by 3s). More... | |
| virtual VecInt2d & | TrisAdjToPts () override |
| Returns triangles adjacent to points (0-based). More... | |
| virtual const VecPt3d & | Points () const override |
| Return the tin points. More... | |
| virtual const VecInt & | Triangles () const override |
| Return 0-based indices of triangle points (grouped by 3s). More... | |
| virtual const VecInt2d & | TrisAdjToPts () const override |
| Returns triangles adjacent to points (0-based). More... | |
| virtual BSHP< VecPt3d > | PointsPtr () override |
| Return the pointer to tin points. More... | |
| virtual BSHP< VecInt > | TrianglesPtr () 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 next 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 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. | |
Private Attributes | |
| BSHP< VecPt3d > | m_pts |
| tin points | |
| BSHP< VecInt > | m_tris |
| triangles, 0-based indices to m_pts, grouped by 3s | |
| BSHP< VecInt2d > | m_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< TrTin > | New () |
| Create a TrTinImpl object. More... | |
Protected Member Functions inherited from xms::TrTin | |
| TrTin () | |
| constructor | |
Class to encapsulate a tin made simply of arrays of points, triangles and adjacency information. Also methods to manipulate it.
|
private |
Predicate used in remove_if to get the index of the current item in the vector.
| [in] | a_adj | Triangles adjacent to a point. |
Definition at line 977 of file TrTin.cpp.
References m_toDelete.
Referenced by DeletePoints().
|
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 ///
| a_triIdx | Triangle index (0-based). |
| a_edgeIdx | Local edge index (0-2) in a_tri. |
Definition at line 630 of file TrTin.cpp.
References TriangleFromEdge(), and XM_NONE.
Referenced by CheckAndSwap(), CommonEdgeIndex(), GetBoundaryPoints(), NextBoundaryPoint(), OptimizeTriangulation(), and PreviousBoundaryPoint().
|
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
| a_triA | First triangle. |
| a_triB | Second triangle. |
| a_propagate | If true, recursively checks adjacent triangles, which will happen even if false if adjacent triangles flag is not zero. |
| a_flags | Flags to keep track of visited triangles. |
Definition at line 514 of file TrTin.cpp.
References AdjacentTriangle(), CommonEdgeIndex(), GlobalIndex(), LocalIndex(), PointIsInCircumcircle(), SwapEdge(), XM_ENSURE_TRUE_NO_ASSERT, and XM_NONE.
Referenced by OptimizeTriangulation().
|
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.
| a_tri | Triangle index (0-based). |
| a_adjTri | Adjacent triangle index (0-based). |
Definition at line 595 of file TrTin.cpp.
References AdjacentTriangle(), and XM_NONE.
Referenced by CheckAndSwap(), and SwapEdge().
|
private |
Removes a_tri from a_pt's adjacent triangles. Compare to vrDeleteAdjacentTrianglePtr.
| [in] | a_pt | The point from which we are removing an adjacent triangle. |
| [in] | a_tri | The triangle we are removing as an adjacent from point. |
Definition at line 914 of file TrTin.cpp.
Referenced by SwapEdge().
|
overridevirtual |
Deletes the points and any attached triangles, updates adjacency and renumbers things.
| [in] | a_points | The set of points to delete. |
Definition at line 1057 of file TrTin.cpp.
References AdjacentIndexFound(), DeleteTriangles(), m_toDelete, m_tris, m_trisAdjToPts, and PointIndexFound().
|
overridevirtual |
Deletes the triangles specified in a_trisToDelete and updates and renumbers triangle adjacency info.
| [in] | a_trisToDelete | Triangles to be deleted. |
Definition at line 987 of file TrTin.cpp.
References m_toDelete, NumTriangles(), TriIndexFound(), and XM_ENSURE_TRUE_VOID_NO_ASSERT.
Referenced by DeletePoints().
|
overridevirtual |
Export in the .tin file format. Useful for debugging.
| [out] | a_os | The stream to export to. |
Definition at line 873 of file TrTin.cpp.
References NumTriangles(), and xms::STRstd().
|
overridevirtual |
|
overridevirtual |
Gives the 0-based indices of all points on any boundary, in no particular order.
| [out] | a_boundaryPoints | The 0-based indices of all points on the boundary. |
Definition at line 773 of file TrTin.cpp.
References AdjacentTriangle(), BuildTrisAdjToPtsConst(), m_tris, TrisAdjToPts(), and XM_NONE.
Referenced by GetBoundaryPolys().
|
overridevirtual |
Gets exterior boundary and all interior voids as polygons of 0-based point indices. First point is not repeated as the last point.
| [out] | a_polys | Outer polygon is CW, inner polys are CCW. First point is repeated at the end. |
Definition at line 807 of file TrTin.cpp.
References GetBoundaryPoints(), NextBoundaryPoint(), xmlog::warning, and XM_LOG.
Computes the extents (min, max) of the tin.
| [out] | a_mn | Minimum xyz. |
| [out] | a_mx | Maximum xyz. |
Definition at line 854 of file TrTin.cpp.
References xms::XM_DBL_HIGHEST, and xms::XM_DBL_LOWEST.
|
overridevirtual |
Returns index into m_pts of a_localPt which is 0-2.
| a_triIdx | = Triangle index (0-based). |
| a_localPt | = Local index (0-2) of point within the triangle. |
Definition at line 932 of file TrTin.cpp.
References m_tris, XM_ENSURE_TRUE, and XM_NONE.
Referenced by CheckAndSwap(), NextBoundaryPoint(), PointIsInCircumcircle(), PreviousBoundaryPoint(), and SwapEdge().
|
private |
Adds a_tri as an adjacent triangle to a_pt and updates m_trisAdjToPts.
| [in] | a_pt | The point that a_tri is adjacent to. |
| [in] | a_tri | The triangle adjacent to a_pt to add to list of adjacents. |
Definition at line 902 of file TrTin.cpp.
References XM_ENSURE_TRUE_VOID.
Referenced by SwapEdge().
|
overridevirtual |
Returns index (0-2) of point within triangle given global index. Compare to trIndex.
| a_tri | Triangle index (0-based). |
| a_pt | Global point index (0-based). |
Definition at line 358 of file TrTin.cpp.
References m_tris, and XM_NONE.
Referenced by CheckAndSwap(), NextBoundaryPoint(), PreviousBoundaryPoint(), SwapEdge(), TriangleAdjacentToEdge(), and TriangleFromEdge().
|
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.
| [in] | a_point | The starting point. |
Definition at line 707 of file TrTin.cpp.
References AdjacentTriangle(), GlobalIndex(), LocalIndex(), m_trisAdjToPts, XM_ENSURE_TRUE_NO_ASSERT, and XM_NONE.
Referenced by GetBoundaryPolys().
|
overridevirtual |
|
overridevirtual |
Return the number of triangles.
Definition at line 285 of file TrTin.cpp.
Referenced by DeleteTriangles(), ExportTinFile(), and OptimizeTriangulation().
|
overridevirtual |
Swaps triangle edges until they are a Delauney triangulation.
Definition at line 1103 of file TrTin.cpp.
References AdjacentTriangle(), CheckAndSwap(), NumTriangles(), and XM_NONE.
|
private |
Predicate used in remove_if to get the index of the current item in the vector.
| [in] | a_point | A point in a tin. |
Definition at line 962 of file TrTin.cpp.
References m_toDelete.
Referenced by DeletePoints().
|
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.
| a_tri1 | Triangle (0-based) adjacent to a_tri2. |
| a_tri2 | Triangle (0-based) adjacent to a_tri1. |
| a_localPt | Local index (0-2) of the point in a_tri2 that is opposite a_tri1. |
/// /// *------------* /// | / | /// | a_tri1 / | /// | / | /// | / | /// | / a_tri2 | /// *------------* /// a_localPt ///
Definition at line 579 of file TrTin.cpp.
References GlobalIndex(), and m_pts.
Referenced by CheckAndSwap().
|
overridevirtual |
|
overridevirtual |
|
overridevirtual |
Returns the next 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.
| [in] | a_point | The starting point. |
Definition at line 742 of file TrTin.cpp.
References AdjacentTriangle(), GlobalIndex(), LocalIndex(), m_trisAdjToPts, XM_ENSURE_TRUE_NO_ASSERT, and XM_NONE.
| void xms::TrTinImpl::serialize | ( | Archive & | archive, |
| const unsigned int | version | ||
| ) |
Boost serialize function.
| archive | The archive. |
| version | Version number. |
Definition at line 1193 of file TrTin.cpp.
References m_pts, m_tris, and m_trisAdjToPts.
|
overridevirtual |
Set all the tin geometry at once (points, triangles, adjacency).
| [in] | a_pts | The tin points. |
| [in] | a_tris | 0-based indices of triangle points (grouped by 3s) |
| [in] | a_trisAdjToPts | 0-based indices of triangles adjacent to points. |
Definition at line 203 of file TrTin.cpp.
References m_pts, m_tris, and m_trisAdjToPts.
|
overridevirtual |
Sets the adjacency info of triangles adjacent to points.
| [in] | a_trisAdjToPts | 0-based indices of triangles adjacent to points. |
Definition at line 193 of file TrTin.cpp.
References m_trisAdjToPts.
|
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
| a_triA | First triangle. |
| a_triB | Second triangle. |
| a_checkAngle | If true, won't swap if very thin triangle would be created. |
Definition at line 416 of file TrTin.cpp.
References CommonEdgeIndex(), DeleteAdjacentTriangle(), xmlog::error, GlobalIndex(), InsertAdjacentTriangle(), LocalIndex(), m_pts, m_tris, XM_ENSURE_TRUE_NO_ASSERT, XM_LOG, and XM_PI.
Referenced by CheckAndSwap().
|
overridevirtual |
|
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.
| a_pt1 | First edge point index (0-based). |
| a_pt2 | Second edge point index (0-based). |
Definition at line 331 of file TrTin.cpp.
References LocalIndex(), m_tris, and XM_NONE.
|
overridevirtual |
|
overridevirtual |
|
overridevirtual |
Finds the triangle with the edge defined by a_pt1 and a_pt2 and the local index of those points. Compare to trTinTriFromEdge.
| [in] | a_pt1 | First edge point index (0-based). |
| [in] | a_pt2 | Second edge point index (0-based). |
| [out] | a_tri | Index of triangle or XM_NONE if not found. |
| [out] | a_localPt1 | Local pt (0-2) of a_pt1 in a_tri. |
| [out] | a_localPt2 | Local pt (0-2) of a_pt2 in a_tri. |
Definition at line 299 of file TrTin.cpp.
References LocalIndex(), m_tris, and XM_NONE.
Referenced by AdjacentTriangle().
|
overridevirtual |
|
overridevirtual |
|
private |
Predicate used in remove_if to get the index of the current item in the vector.
| [in] | a_triPt | Index of a point on a triangle. |
Definition at line 947 of file TrTin.cpp.
References m_toDelete.
Referenced by DeleteTriangles().
|
overridevirtual |
Returns triangles adjacent to points (0-based).
Definition at line 229 of file TrTin.cpp.
References m_trisAdjToPts.
Referenced by GetBoundaryPoints().
|
overridevirtual |
Returns triangles adjacent to points (0-based).
Definition at line 253 of file TrTin.cpp.
References m_trisAdjToPts.
|
overridevirtual |