xmsmesh  1.0
xms::MeMultiPolyMesherImpl Class Reference

Creates a mesh from multiple polygons that will honor polygon boundaries. More...

Inheritance diagram for xms::MeMultiPolyMesherImpl:
xms::MeMultiPolyMesher

Public Member Functions

 MeMultiPolyMesherImpl ()
 Constructor.
 
virtual bool MeshIt (MeMultiPolyMesherIo &a_io) override
 Creates a triangle mesh from the input polygons. The polygons can not overlap. More...
 
virtual void CheckForIntersections (const MeMultiPolyMesherIo &a_io, std::string &a_errors) const override
 Checks input to see if anything intersects. Will not catch polys entirely inside or outside of where they are supposed to be. More...
 

Private Member Functions

void AppendMesh (VecPt3d &a_points, const VecInt &a_triangles, VecInt &a_cells)
 Adds new points and triangles to existing mesh, hashing points and renumbering. More...
 
void AddUniquePoints (const VecPt3d &a_points, VecInt &a_oldDups, VecInt &a_newDups)
 Adds new mesh points that aren't in old mesh, to old mesh. More...
 
void RenumberNewMesh (int a_oldNumPts, size_t a_numNewPts, const VecInt &a_oldDups, const VecInt &a_newDups, VecInt &a_cells) const
 Renumber points referred to in the new mesh to remove duplicate points and to start new mesh numbering at size of existing mesh. More...
 
void AppendNewCells (const VecInt &a_cells)
 Append the new cells to the existing cells. More...
 
void ReportUnusedRefinePts (const MeMultiPolyMesherIo &a_io, const VecPt3d &a_usedPts)
 Reports refine points that were not used. More...
 
void EnsureProperPolygonInputs (MeMultiPolyMesherIo &a_io)
 Remove last point of polygon if it is the same as the first point and make sure the polygon points are ordered correctly. More...
 
bool ValidateInput (const MeMultiPolyMesherIo &a_io)
 Make sure the input makes sense. More...
 
bool ExtentsOverlap (const Pt3d &oneMn, const Pt3d &oneMx, const Pt3d &two1, const Pt3d &two2) const
 Given extents of one segment, and another segment, return true if the extents of the two segments overlap. More...
 

Private Attributes

BSHP< VecPt3dm_pts
 Mesh points. BSHP because of PtSearch::VectorThatGrowsToSearch.
 
VecInt m_cells
 Mesh cells as a stream.
 
int m_cellCount
 Number of cells.
 
boost::unordered_map< std::pair< double, double >, int > m_ptHash
 hashes points
 

Additional Inherited Members

- Static Public Member Functions inherited from xms::MeMultiPolyMesher
static boost::shared_ptr< MeMultiPolyMesherNew ()
 Creates a class. More...
 

Detailed Description

Creates a mesh from multiple polygons that will honor polygon boundaries.

Definition at line 51 of file MeMultiPolyMesher.cpp.

Member Function Documentation

◆ AddUniquePoints()

void xms::MeMultiPolyMesherImpl::AddUniquePoints ( const VecPt3d a_points,
VecInt a_oldDups,
VecInt a_newDups 
)
private

Adds new mesh points that aren't in old mesh, to old mesh.

Also gives back lists of duplicate points found (if any) in a_oldDups and a_newDups which are the same size and correspond with each other (a_oldDups[3] => a_newDups[3])

Parameters
a_pointsNew mesh points.
a_oldDupsIndices in m_pts (old mesh) of duplicate points.
a_newDupsIndices in a_points (new mesh) of duplicate points.

Definition at line 689 of file MeMultiPolyMesher.cpp.

References m_ptHash, m_pts, and XM_ENSURE_TRUE_VOID_NO_ASSERT.

Referenced by AppendMesh().

◆ AppendMesh()

void xms::MeMultiPolyMesherImpl::AppendMesh ( VecPt3d a_points,
const VecInt a_triangles,
VecInt a_cells 
)
private

Adds new points and triangles to existing mesh, hashing points and renumbering.

Parameters
a_pointsNew mesh points.
a_trianglesNew mesh triangle cells.
a_cellsNew mesh cells.

Definition at line 618 of file MeMultiPolyMesher.cpp.

References AddUniquePoints(), AppendNewCells(), m_cellCount, m_cells, m_ptHash, m_pts, and RenumberNewMesh().

Referenced by MeshIt().

◆ AppendNewCells()

void xms::MeMultiPolyMesherImpl::AppendNewCells ( const VecInt a_cells)
private

Append the new cells to the existing cells.

Parameters
a_cellsNew cells to append to existing mesh.

Definition at line 777 of file MeMultiPolyMesher.cpp.

References m_cells.

Referenced by AppendMesh().

◆ CheckForIntersections()

void xms::MeMultiPolyMesherImpl::CheckForIntersections ( const MeMultiPolyMesherIo a_io,
std::string &  a_errors 
) const
overridevirtual

Checks input to see if anything intersects. Will not catch polys entirely inside or outside of where they are supposed to be.

We check by intersecting every line segment on every poly with every other line segment on every other poly, if the extents overlap. This can be slow.

Parameters
a_ioMesher input/output
a_errorsError string that may get appended to.

Definition at line 411 of file MeMultiPolyMesher.cpp.

References ExtentsOverlap(), gmAddToExtents(), gmEqualPointsXY(), gmIntersectLineSegmentsWithTol(), gmXyTol(), xms::SegmentLocation::m_inPoly, xms::SegmentLocation::m_inPolySeg, xms::MePolyInput::m_insidePolys, xms::MePolyInput::m_outPoly, xms::SegmentLocation::m_poly, xms::MeMultiPolyMesherIo::m_polys, xms::SegmentLocation::m_polySeg, xms::Pt3< T >::x, and xms::Pt3< T >::y.

Referenced by ValidateInput().

◆ EnsureProperPolygonInputs()

void xms::MeMultiPolyMesherImpl::EnsureProperPolygonInputs ( MeMultiPolyMesherIo a_io)
private

Remove last point of polygon if it is the same as the first point and make sure the polygon points are ordered correctly.

Parameters
a_ioThe input/output parameters.

Definition at line 287 of file MeMultiPolyMesher.cpp.

References gmEqualPointsXY(), gmPolygonArea(), xms::MePolyInput::m_insidePolys, xms::MePolyInput::m_outPoly, and xms::MeMultiPolyMesherIo::m_polys.

Referenced by MeshIt().

◆ ExtentsOverlap()

bool xms::MeMultiPolyMesherImpl::ExtentsOverlap ( const Pt3d a_oneMn,
const Pt3d a_oneMx,
const Pt3d a_two1,
const Pt3d a_two2 
) const
private

Given extents of one segment, and another segment, return true if the extents of the two segments overlap.

Parameters
a_oneMnMin extents of first segment.
a_oneMxMax extents of first segment.
a_two1First point defining second segment.
a_two2Second point defining second segment.
Returns
true if overlap, else false.

Definition at line 585 of file MeMultiPolyMesher.cpp.

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

Referenced by CheckForIntersections().

◆ MeshIt()

bool xms::MeMultiPolyMesherImpl::MeshIt ( MeMultiPolyMesherIo a_io)
overridevirtual

Creates a triangle mesh from the input polygons. The polygons can not overlap.

Parameters
[in]a_ioInput/output of polygons and options for generating a mesh. MeMultiPolyMesherIo::m_returnCellPolygons is true.
Returns
true if successful.

Definition at line 230 of file MeMultiPolyMesher.cpp.

References AppendMesh(), EnsureProperPolygonInputs(), m_cellCount, xms::MeMultiPolyMesherIo::m_cellPolygons, m_cells, xms::MeMultiPolyMesherIo::m_cells, xms::MeMultiPolyMesherIo::m_points, xms::MeMultiPolyMesherIo::m_polys, m_ptHash, m_pts, xms::MeMultiPolyMesherIo::m_returnCellPolygons, xms::MePolyMesher::New(), ReportUnusedRefinePts(), and ValidateInput().

◆ RenumberNewMesh()

void xms::MeMultiPolyMesherImpl::RenumberNewMesh ( int  a_oldNumPts,
size_t  a_numNewPts,
const VecInt a_oldDups,
const VecInt a_newDups,
VecInt a_cells 
) const
private

Renumber points referred to in the new mesh to remove duplicate points and to start new mesh numbering at size of existing mesh.

Parameters
a_oldNumPtsNumber of points we had before adding this mesh.
a_numNewPtsNumber of new, unique points
a_oldDupsIndices in m_pts of duplicate points.
a_newDupsIndices in a_points of duplicate points.
a_cellsCells of mesh (same format as vtk cell stream)

Definition at line 728 of file MeMultiPolyMesher.cpp.

References XM_ENSURE_TRUE_VOID_NO_ASSERT.

Referenced by AppendMesh().

◆ ReportUnusedRefinePts()

void xms::MeMultiPolyMesherImpl::ReportUnusedRefinePts ( const MeMultiPolyMesherIo a_io,
const VecPt3d a_usedPts 
)
private

Reports refine points that were not used.

Parameters
a_ioMeMultiPolyMesherIo class that was provided to generate the mesh.
a_usedPtsThe locations of points that were processed.

Definition at line 787 of file MeMultiPolyMesher.cpp.

References xms::MeMultiPolyMesherIo::m_refPts, xmlog::warning, and XM_LOG.

Referenced by MeshIt().

◆ ValidateInput()

bool xms::MeMultiPolyMesherImpl::ValidateInput ( const MeMultiPolyMesherIo a_io)
private

Make sure the input makes sense.

Parameters
a_ioThe input/output parameters.
Returns
true if OK, false if there are errors in the input.

Definition at line 337 of file MeMultiPolyMesher.cpp.

References CheckForIntersections(), xms::MeMultiPolyMesherIo::m_checkTopology, xms::MePolyInput::m_insidePolys, xms::MePolyInput::m_outPoly, xms::MePolyInput::m_polyCorners, xms::MePolyInput::m_polyId, xms::MeMultiPolyMesherIo::m_polys, xmlog::warning, XM_ASSERT, and XM_LOG.

Referenced by MeshIt().


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