xmsmesh
1.0
|
Generates an adaptive patch mesh from a polygon. More...
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< GmPtSearch > | m_ptSearch |
spatial index for searching points | |
BSHP< VecPt3d > | m_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< MePolyPatcher > | New () |
Creates a new instance of this class. More... | |
Generates an adaptive patch mesh from a polygon.
Definition at line 51 of file MePolyPatcher.cpp.
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.
[in] | a_nodesincol | Array of the number of nodes in each column |
[in] | a_flag | To adjust just one side, do this. |
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().
bool xms::MePolyPatcherImpl::CellOverlapsAdj | ( | int | a_cellIdx, |
DynBitset & | a_cellFlags | ||
) |
Checks to see if the cells overlaps with any adjacent cells.
[in] | a_cellIdx | Cell index |
[in] | a_cellFlags | Flag to tell if cell has already been checked |
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().
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.
[in] | a_cellIdx | index to the cell |
[out] | a_ptIdxs | the point indexes for the points that make up this cell |
[out] | a_adjCellIdx | the indexes to the adjacent cells |
[out] | a_adjPts | the 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().
returns the real percentage for each point across the line.
[in] | a_np | The number of points. |
[in] | a_pts | The point locations |
[out] | a_pcnts | The percentage of each point |
Definition at line 541 of file MePolyPatcher.cpp.
References Mdist(), and XM_ENSURE_TRUE.
Referenced by CalcPointPercentages().
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)
[in] | a_pcnt_in | The input percentages |
[in] | a_pcnt_out | The input percentages |
Definition at line 632 of file MePolyPatcher.cpp.
Referenced by PointsFromPercentages().
|
overridevirtual |
Perform MESH_PATCH meshing on a polygon. Return the mesh points through a_points and a_cells (mix of quad/tri).
[in] | a_polyId | Id of the polygon or -1 |
[in] | a_outPoly | Array of points defining the polygon |
[in] | a_polyCorners | Indices of corner points in a_outPoly |
[in] | a_xytol | Tolerance for geometric comparisons. |
[out] | a_points | Computed mesh points. |
[out] | a_cells | Computed mesh cells, a mix of quads and tris. |
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().
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().
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.
[in] | a_pts | The point locations |
[in] | a_pcnt | The percentage of each point in a_pts |
[in] | a_np_new | Number of new points |
[out] | a_ptsNew | The interpolated point locations |
Definition at line 572 of file MePolyPatcher.cpp.
References InterpolatePercentages().
Referenced by CalcPointPercentages().
size_t xms::MePolyPatcherImpl::PolyCornerClosestToTopLeft | ( | const VecPt3d & | a_oPoly, |
const VecInt & | a_idx, | ||
const Pt3d & | a_topLeft | ||
) |
puts the polygon points in the
[in] | a_oPoly | Array of points defining the polygon |
[in] | a_idx | Indices of corner points in a_outPoly |
[out] | a_topLeft | The location of point closest to top left |
Definition at line 201 of file MePolyPatcher.cpp.
References MdistSq(), xms::Pt3< T >::x, and xms::Pt3< T >::y.
Referenced by PolyPtsToSides().
void xms::MePolyPatcherImpl::PolyPtsToSides | ( | const VecPt3d & | a_outPoly, |
const VecInt & | a_polyCorners | ||
) |
puts the polygon points in the
[in] | a_outPoly | Array of points defining the polygon |
[in] | a_polyCorners | Indices 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().
Creates mesh cells using the patch algorithm for triangles.
[in] | a_outPoly | Array of points defining the polygon |
[in] | a_polyCorners | Indices 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().
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.
[in] | a_outPoly | Array of points defining the polygon |
[in] | a_polyCorners | Indices of corner points in a_outPoly |
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().
void xms::MePolyPatcherImpl::SetUpColumnForRectPatch3a | ( | int | a_j, |
VecPt3d & | a_newcol | ||
) |
initialize an array of nodes for a column of patch nodes
[in] | a_j | The column index |
[out] | a_newcol | The 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().
bool xms::MePolyPatcherImpl::SetupSideInfo | ( | ) |
Set up some variables based on the points being setup.
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().