xmsmesh  1.0
xms::MePolyPatcherImpl Class Reference

Generates an adaptive patch mesh from a polygon. More...

Inheritance diagram for xms::MePolyPatcherImpl:
xms::MePolyPatcher

Public Member Functions

virtual bool MeshIt (int a_polyId, const VecPt3d &a_outPoly, const VecInt &a_polyCorners, double a_xytol, VecPt3d &a_points, VecInt &a_cells) override
 Perform MESH_PATCH meshing on a polygon. Return the mesh points through a_points and a_cells (mix of quad/tri). More...
 
size_t PolyCornerClosestToTopLeft (const VecPt3d &a_oPoly, const VecInt &a_idx, const Pt3d &a_topLeft)
 puts the polygon points in the More...
 
void PolyPtsToSides (const VecPt3d &a_outPoly, const VecInt &a_polyCorners)
 puts the polygon points in the More...
 
void OrderPoints ()
 checks that the points are ordered in the expected order More...
 
bool QuadPatchErrors (const VecPt3d &a_outPoly, const VecInt &a_polyCorners)
 Checks the polygon to make sure that each side of the polygon has the same number of segments. More...
 
void QuadPatch (const VecPt3d &a_outPoly, const VecInt &a_polyCorners)
 Creates mesh cells using the patch algorithm for triangles. More...
 
bool SetupSideInfo ()
 Set up some variables based on the points being setup. More...
 
bool AdjustNodesInCol3a (VecInt &a_nodesincol, int flag)
 performs adjustments to the nodes to make the correct desired transitions from column to column. Both odd and even numbers of nodes transition better to an even number of nodes. More...
 
void GetPercentages (int a_np, const VecPt3d &a_pts, VecDbl &pcnts)
 returns the real percentage for each point across the line. More...
 
void PointsFromPercentages (const VecPt3d &a_pts, const VecDbl &a_pcnts, int a_np_new, VecPt3d &a_ptsNew)
 reinterpolates the array of points a_pts to a new array of points a_ptsNew. The interpolation is performed based on the spacing of the original a_pts. More...
 
void InterpolatePercentages (const VecDbl &a_pcnt_in, VecDbl &a_pcnt_out)
 gets the new percentages, interpolated from old percentages More...
 
void CalcPointPercentages ()
 Calculates percentages that are used to determine the locations of the mesh points.
 
void GenerateMeshPts ()
 Creates the mesh pts.
 
void SetUpColumnForRectPatch3a (int a_j, VecPt3d &a_newcol)
 initialize an array of nodes for a column of patch nodes More...
 
void GenerateMeshCells ()
 Creates the mesh cells and puts the mesh pts into 1 vector.
 
void ValidateMeshCells ()
 Ensures that the generated mesh cells are valid (no ill formed cells)
 
bool CellOverlapsAdj (int a_cellIdx, DynBitset &a_cellFlags)
 Checks to see if the cells overlaps with any adjacent cells. More...
 
void CreateCellAdjacencyInfo ()
 Creates arrays with cell adjacency information.
 
void GetCellPtInfo (int a_cellIdx, VecInt &a_ptIdxs, VecInt &a_adjCellIdx, VecInt2d &a_adjPts)
 Gets the points that make up the cell and points from adjacent cells. More...
 

Public Attributes

VecPt3d2d m_pts
 polygon points divided into 4 sides
 
VecPt3d2d m_side1pts
 1 side of polygon points
 
VecPt3d2d m_side2pts
 1 side of polygon points
 
VecPt3d2d m_end1pts
 1 side of polygon points
 
VecPt3d2d m_end2pts
 1 side of polygon points
 
int m_n0
 variable refactored out of patch code
 
int m_n1
 variable refactored out of patch code
 
int m_dn
 variable refactored out of patch code
 
int m_np_end
 variable refactored out of patch code
 
int m_m0
 variable refactored out of patch code
 
int m_m1
 variable refactored out of patch code
 
int m_dm
 variable refactored out of patch code
 
int m_np_side
 variable refactored out of patch code
 
VecInt m_nodesinrow
 number of nodes in a row
 
VecInt m_nodesincol
 number of nodes in a column
 
VecDbl m_side1pcnt
 percentage of node location along side
 
VecDbl m_side2pcnt
 percentage of node location along side
 
VecDbl m_end1pcnt
 percentage of node location along side
 
VecDbl m_end2pcnt
 percentage of node location along side
 
VecDbl2d m_newside1pcnt
 percentage of node location along side
 
VecDbl2d m_newside2pcnt
 percentage of node location along side
 
VecDbl2d m_newend1pcnt
 percentage of node location along side
 
VecDbl2d m_newend2pcnt
 percentage of node location along side
 
BSHP< GmPtSearchm_ptSearch
 spatial index for searching points
 
BSHP< VecPt3dm_meshPts
 generated mesh nodes
 
VecInt m_ptIdxToRemove
 mesh nodes that will be removed
 
VecInt m_meshCells
 generated mesh cells
 
VecInt2d m_nodeIdx
 index to m_meshPts identifying mesh nodes
 
double m_xytol
 tolerance for geometry comparison
 
VecInt m_ptCellCnt
 number of cells connected to each point
 
VecInt m_ptCellIdx
 index into cell adjacency array for each point
 
VecInt m_ptAdjCells
 adjacent cells for each point
 
VecInt m_cellIdx
 location of each cell in m_meshCells
 
int m_polyId
 id of the polygon
 

Private Attributes

friend MePolyPatcherUnitTests
 tests the class
 

Additional Inherited Members

- Static Public Member Functions inherited from xms::MePolyPatcher
static BSHP< MePolyPatcherNew ()
 Creates a new instance of this class. More...
 

Detailed Description

Generates an adaptive patch mesh from a polygon.

Definition at line 51 of file MePolyPatcher.cpp.

Member Function Documentation

◆ AdjustNodesInCol3a()

bool xms::MePolyPatcherImpl::AdjustNodesInCol3a ( VecInt a_nodesincol,
int  a_flag 
)

performs adjustments to the nodes to make the correct desired transitions from column to column. Both odd and even numbers of nodes transition better to an even number of nodes.

Parameters
[in]a_nodesincolArray of the number of nodes in each column
[in]a_flagTo adjust just one side, do this.
Returns
true if no errors encountered

Definition at line 489 of file MePolyPatcher.cpp.

References xmlog::debug, m_polyId, xms::meModifyMessageWithPolygonId(), Mmax(), XM_ENSURE_TRUE, and XM_LOG.

Referenced by SetupSideInfo().

◆ CellOverlapsAdj()

bool xms::MePolyPatcherImpl::CellOverlapsAdj ( int  a_cellIdx,
DynBitset a_cellFlags 
)

Checks to see if the cells overlaps with any adjacent cells.

Parameters
[in]a_cellIdxCell index
[in]a_cellFlagsFlag to tell if cell has already been checked
Returns
True if the cell overlaps any adjacent cell

Definition at line 1020 of file MePolyPatcher.cpp.

References xmlog::error, GetCellPtInfo(), gmLinesIntersect(), gmPointInPolygon2D(), m_meshPts, m_polyId, xms::meModifyMessageWithPolygonId(), and XM_LOG.

Referenced by ValidateMeshCells().

◆ GetCellPtInfo()

void xms::MePolyPatcherImpl::GetCellPtInfo ( int  a_cellIdx,
VecInt a_ptIdxs,
VecInt a_adjCellIdx,
VecInt2d a_adjPts 
)

Gets the points that make up the cell and points from adjacent cells.

Parameters
[in]a_cellIdxindex to the cell
[out]a_ptIdxsthe point indexes for the points that make up this cell
[out]a_adjCellIdxthe indexes to the adjacent cells
[out]a_adjPtsthe point indexes from adjacent cells

Definition at line 1148 of file MePolyPatcher.cpp.

References m_cellIdx, m_meshCells, m_ptAdjCells, m_ptCellCnt, and m_ptCellIdx.

Referenced by CellOverlapsAdj().

◆ GetPercentages()

void xms::MePolyPatcherImpl::GetPercentages ( int  a_np,
const VecPt3d a_pts,
VecDbl a_pcnts 
)

returns the real percentage for each point across the line.

Parameters
[in]a_npThe number of points.
[in]a_ptsThe point locations
[out]a_pcntsThe percentage of each point

Definition at line 541 of file MePolyPatcher.cpp.

References Mdist(), and XM_ENSURE_TRUE.

Referenced by CalcPointPercentages().

◆ InterpolatePercentages()

void xms::MePolyPatcherImpl::InterpolatePercentages ( const VecDbl a_pcnt_in,
VecDbl a_pcnt_out 
)

gets the new percentages, interpolated from old percentages

| y-axis = % along string | ___+ (from the function | _+___/ paiGetPercentages()) | ____/ | __+/ | __/ | _+/ | / | _/ | / |/_____________________________ | | | | node1 node2 node3 node4 node5

x-axis = % of points (always an even distribution)

Parameters
[in]a_pcnt_inThe input percentages
[in]a_pcnt_outThe input percentages

Definition at line 632 of file MePolyPatcher.cpp.

Referenced by PointsFromPercentages().

◆ MeshIt()

bool xms::MePolyPatcherImpl::MeshIt ( int  a_polyId,
const VecPt3d a_outPoly,
const VecInt a_polyCorners,
double  a_xytol,
VecPt3d a_points,
VecInt a_cells 
)
overridevirtual

Perform MESH_PATCH meshing on a polygon. Return the mesh points through a_points and a_cells (mix of quad/tri).

Parameters
[in]a_polyIdId of the polygon or -1
[in]a_outPolyArray of points defining the polygon
[in]a_polyCornersIndices of corner points in a_outPoly
[in]a_xytolTolerance for geometric comparisons.
[out]a_pointsComputed mesh points.
[out]a_cellsComputed mesh cells, a mix of quads and tris.
Returns
true on success.

Definition at line 160 of file MePolyPatcher.cpp.

References xmlog::error, m_meshCells, m_meshPts, m_polyId, m_xytol, xms::meModifyMessageWithPolygonId(), QuadPatch(), and XM_LOG.

Referenced by MePolyPatcherUnitTests::testBug9226(), and MePolyPatcherUnitTests::testPatch00().

◆ OrderPoints()

void xms::MePolyPatcherImpl::OrderPoints ( )

checks that the points are ordered in the expected order

///                           pts[3]
///                  |  ----------------->  |
///                  |                      |
///                  |                      |
///                  |                      |
///                  |                      |
///           pts[0] |                      | pts[2]
///                  |                      |
///                  |                      |
///                  |                      |
///                  |                      |
///                  |                      |
///                  v  ----------------->  v
///                           pts[1]
///
///             However, this function makes sure that the following
///             conditions hold true:
///               1. np[0] <= np[2]
///               2. np[3] <= np[1]
///               3. if (np[2] - np[0]) == 0 then (np[3] - np[1]) == 0 also.
///                  Otherwise, edges & sides will be swapped to get
///                  pts[1] == pts[3].
///               4. (np[2] - np[0]) >= (np[1] - np[3]).
/// 

Definition at line 303 of file MePolyPatcher.cpp.

References m_pts.

Referenced by QuadPatch().

◆ PointsFromPercentages()

void xms::MePolyPatcherImpl::PointsFromPercentages ( const VecPt3d a_pts,
const VecDbl a_pcnt,
int  a_np_new,
VecPt3d a_ptsNew 
)

reinterpolates the array of points a_pts to a new array of points a_ptsNew. The interpolation is performed based on the spacing of the original a_pts.

Parameters
[in]a_ptsThe point locations
[in]a_pcntThe percentage of each point in a_pts
[in]a_np_newNumber of new points
[out]a_ptsNewThe interpolated point locations

Definition at line 572 of file MePolyPatcher.cpp.

References InterpolatePercentages().

Referenced by CalcPointPercentages().

◆ PolyCornerClosestToTopLeft()

size_t xms::MePolyPatcherImpl::PolyCornerClosestToTopLeft ( const VecPt3d a_oPoly,
const VecInt a_idx,
const Pt3d a_topLeft 
)

puts the polygon points in the

Parameters
[in]a_oPolyArray of points defining the polygon
[in]a_idxIndices of corner points in a_outPoly
[out]a_topLeftThe location of point closest to top left
Returns
index to the corner closest to the top left

Definition at line 201 of file MePolyPatcher.cpp.

References MdistSq(), xms::Pt3< T >::x, and xms::Pt3< T >::y.

Referenced by PolyPtsToSides().

◆ PolyPtsToSides()

void xms::MePolyPatcherImpl::PolyPtsToSides ( const VecPt3d a_outPoly,
const VecInt a_polyCorners 
)

puts the polygon points in the

Parameters
[in]a_outPolyArray of points defining the polygon
[in]a_polyCornersIndices of corner points in a_outPoly

Definition at line 224 of file MePolyPatcher.cpp.

References gmEnvelopeOfPts(), m_pts, PolyCornerClosestToTopLeft(), XM_ENSURE_TRUE, and xms::Pt3< T >::y.

Referenced by QuadPatch(), MePolyPatcherUnitTests::testPolyPtsToSides(), and MePolyPatcherUnitTests::testPolyPtsToSides1().

◆ QuadPatch()

void xms::MePolyPatcherImpl::QuadPatch ( const VecPt3d a_outPoly,
const VecInt a_polyCorners 
)

Creates mesh cells using the patch algorithm for triangles.

Parameters
[in]a_outPolyArray of points defining the polygon
[in]a_polyCornersIndices of corner points in a_outPoly

Definition at line 423 of file MePolyPatcher.cpp.

References GenerateMeshCells(), GenerateMeshPts(), OrderPoints(), PolyPtsToSides(), QuadPatchErrors(), SetupSideInfo(), and ValidateMeshCells().

Referenced by MeshIt().

◆ QuadPatchErrors()

bool xms::MePolyPatcherImpl::QuadPatchErrors ( const VecPt3d a_outPoly,
const VecInt a_polyCorners 
)

Checks the polygon to make sure that each side of the polygon has the same number of segments.

Parameters
[in]a_outPolyArray of points defining the polygon
[in]a_polyCornersIndices of corner points in a_outPoly
Returns
true if errors were found.

Definition at line 366 of file MePolyPatcher.cpp.

References xmlog::error, gmAngleBetweenEdges(), m_polyId, xms::meModifyMessageWithPolygonId(), XM_ENSURE_TRUE, XM_LOG, and XM_PI.

Referenced by QuadPatch(), and MePolyPatcherUnitTests::testQuadPatchErrors().

◆ SetUpColumnForRectPatch3a()

void xms::MePolyPatcherImpl::SetUpColumnForRectPatch3a ( int  a_j,
VecPt3d a_newcol 
)

initialize an array of nodes for a column of patch nodes

Parameters
[in]a_jThe column index
[out]a_newcolThe mesh point locations in a_j column

Definition at line 784 of file MePolyPatcher.cpp.

References m_end1pts, m_end2pts, m_newend1pcnt, m_newend2pcnt, m_newside1pcnt, m_newside2pcnt, m_nodesincol, m_nodesinrow, m_np_end, m_side1pts, m_side2pts, Mmin(), xms::Pt3< T >::x, xms::Pt3< T >::y, and xms::Pt3< T >::z.

Referenced by GenerateMeshPts().

◆ SetupSideInfo()

bool xms::MePolyPatcherImpl::SetupSideInfo ( )

Set up some variables based on the points being setup.

Returns
True on success.

Definition at line 439 of file MePolyPatcher.cpp.

References AdjustNodesInCol3a(), m_dm, m_dn, m_m0, m_m1, m_n0, m_n1, m_nodesincol, m_nodesinrow, m_np_end, m_np_side, m_pts, and Mmax().

Referenced by QuadPatch().


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