xmsmesh  1.0
xms::MeRelaxerImpl Class Reference

Relaxes mesh points. Moves them around to form a better mesh. More...

Inheritance diagram for xms::MeRelaxerImpl:
xms::MeRelaxer

Public Types

enum  RelaxFlagEnum { RELAX_RELAX = 1 }
 Point flags.
 
enum  RelaxTypeEnum { RELAXTYPE_AREA, RELAXTYPE_ANGLE, RELAXTYPE_SPRING }
 Types of relaxation, or the relaxation algorithms.
 

Public Member Functions

virtual void Relax (const VecInt &a_fixedPoints, BSHP< TrTin > a_tin) override
 Moves interior mesh points to create a better mesh. More...
 
virtual bool SetRelaxationMethod (const std::string &a_relaxMethod) override
 Sets the relaxation method. More...
 
virtual void SetPointSizer (BSHP< MePolyRedistributePts > a_sizer) override
 Sets size function used by the spring relaxation method. More...
 
void ComputeCentroids ()
 Computes the centroids of each triangle.
 
void RelaxMarkedPoints (RelaxTypeEnum a_relaxType, int a_iteration, int a_numiterations)
 Relaxes the points marked by m_flags. Compare to rlRelaxMarkedNodes. More...
 
void AreaRelax (int a_point, Pt3d &a_newLocation)
 Relax a point using area of surrounding triangles. Trys to move point to the center of the area. Compare to rliAreaRelax. More...
 
void AngleRelax (int a_point, Pt3d &a_newLocation)
 Relax a point using angles. Moves point to equalize the angles between the edges touching the point. Compare to rliAngleRelax. More...
 
void SpringRelaxSinglePoint (int a_point, Pt3d &a_newLocation)
 Relax a point using spring method. More...
 
void SetupNeighbors ()
 Set up neighbor point information to be used by the spring relax algorithm.
 
void SetupPointSizes ()
 Set up point sizes to be used by the spring relax algorithm.
 
bool NewLocationIsValid (size_t a_idx, Pt3d &a_newLocation)
 Checks if a new relaxed location results in valid triangle (area is positive) More...
 
bool AllTrianglesHavePositiveArea (BSHP< TrTin > a_tin)
 Checks if all triangles have a positive area. More...
 

Public Attributes

BSHP< TrTinm_tin
 triangles connecting points (mesh elements)
 
const VecIntm_fixedPoints
 locations that may not be relaxed
 
VecPt3d m_centroids
 The triangle centroids.
 
double m_slideangle
 Used on boundary relaxation. Not sure how to document this one.
 
VecInt m_flags
 Flags for points of type RelaxFlagEnum.
 
RelaxTypeEnum m_relaxType
 the type of relaxation to perform. See RelaxTypeEnum
 
BSHP< MePolyRedistributePtsm_sizer
 size function used by the spring relax method
 
VecDbl m_pointSizes
 sizer size at each mesh point
 
VecInt2d m_pointNeighbors
 neighbor points for spring relaxation
 
VecInt m_pointsToDelete
 indexes of points that must be removed
 

Additional Inherited Members

- Static Public Member Functions inherited from xms::MeRelaxer
static BSHP< MeRelaxerNew ()
 Creates a new instance of the class. More...
 
- Protected Member Functions inherited from xms::MeRelaxer
 MeRelaxer ()
 Constructor.
 
virtual ~MeRelaxer ()
 Destructor.
 

Detailed Description

Relaxes mesh points. Moves them around to form a better mesh.

Definition at line 50 of file MeRelaxer.cpp.

Member Function Documentation

◆ AllTrianglesHavePositiveArea()

bool xms::MeRelaxerImpl::AllTrianglesHavePositiveArea ( BSHP< TrTin a_tin)

Checks if all triangles have a positive area.

Parameters
[in]a_tinthe tin
Returns
true if the triangles all have positive area

Definition at line 540 of file MeRelaxer.cpp.

Referenced by Relax(), and MeRelaxerUnitTests::testAllTrianglesHavePositiveArea().

◆ AngleRelax()

void xms::MeRelaxerImpl::AngleRelax ( int  a_point,
Pt3d a_newLocation 
)

Relax a point using angles. Moves point to equalize the angles between the edges touching the point. Compare to rliAngleRelax.

Parameters
[in]a_pointThe point index to be relaxed.
[out]a_newLocationThe location after point is relaxed (moved).

Definition at line 340 of file MeRelaxer.cpp.

References m_tin, sqr(), trDecrementIndex(), trIncrementIndex(), xms::Pt2< T >::x, xms::Pt3< T >::x, XM_ASSERT, XM_PI, xms::Pt2< T >::y, and xms::Pt3< T >::y.

Referenced by RelaxMarkedPoints().

◆ AreaRelax()

void xms::MeRelaxerImpl::AreaRelax ( int  a_point,
Pt3d a_newLocation 
)

Relax a point using area of surrounding triangles. Trys to move point to the center of the area. Compare to rliAreaRelax.

Parameters
[in]a_pointThe point index to be relaxed.
[out]a_newLocationThe location after point is relaxed (moved).

Definition at line 319 of file MeRelaxer.cpp.

References m_centroids, m_tin, xms::Pt3< T >::x, and xms::Pt3< T >::y.

Referenced by RelaxMarkedPoints().

◆ NewLocationIsValid()

bool xms::MeRelaxerImpl::NewLocationIsValid ( size_t  a_idx,
Pt3d a_newLocation 
)

Checks if a new relaxed location results in valid triangle (area is positive)

Parameters
[in]a_idxthe index to the point
[in]a_newLocationx,y,z new coordinates
Returns
true if the new location will give valid triangles

Definition at line 518 of file MeRelaxer.cpp.

References GT_EPS(), and m_tin.

Referenced by RelaxMarkedPoints(), MeRelaxerUnitTests::testNewLocationIsValid(), MeRelaxerUnitTests::testSpringRelaxSinglePoint(), MeRelaxerUnitTests::testSpringRelaxSinglePoint2(), and MeRelaxerUnitTests::testSpringRelaxSinglePoint3().

◆ Relax()

void xms::MeRelaxerImpl::Relax ( const VecInt a_fixedPoints,
BSHP< TrTin a_tin 
)
overridevirtual

Moves interior mesh points to create a better mesh.

Iteratively relaxes the interior nodes. Also swaps edges to maintain the Delauney criterion after each set of relaxations. Also merges triangles. Compare to myiRelaxSwapAndMerge.

Parameters
a_tinThe tin with triangles.
a_fixedPointsPoints that shouldn't be moved (boundaries, breaklines). 0-based point indices.
Todo:
Save the MeshPolyEnum

Definition at line 134 of file MeRelaxer.cpp.

References AllTrianglesHavePositiveArea(), ComputeCentroids(), m_fixedPoints, m_flags, m_pointNeighbors, m_pointSizes, m_pointsToDelete, m_relaxType, m_sizer, m_tin, RelaxMarkedPoints(), SetupNeighbors(), SetupPointSizes(), xmlog::warning, XM_ASSERT, XM_ENSURE_TRUE_VOID, XM_ENSURE_TRUE_VOID_NO_ASSERT, and XM_LOG.

◆ RelaxMarkedPoints()

void xms::MeRelaxerImpl::RelaxMarkedPoints ( RelaxTypeEnum  a_relaxType,
int  a_iteration,
int  a_numiterations 
)

Relaxes the points marked by m_flags. Compare to rlRelaxMarkedNodes.

Parameters
a_relaxTypeRelaxTypeEnum.
a_iterationCurrent iteration (for progress).
a_numiterationsTotal iterations we will do (for progress).

Definition at line 259 of file MeRelaxer.cpp.

References AngleRelax(), AreaRelax(), m_flags, m_pointSizes, m_pointsToDelete, m_sizer, m_tin, NewLocationIsValid(), SpringRelaxSinglePoint(), XM_ASSERT, and xms::Pt3< T >::z.

Referenced by Relax().

◆ SetPointSizer()

virtual void xms::MeRelaxerImpl::SetPointSizer ( BSHP< MePolyRedistributePts a_sizer)
inlineoverridevirtual

Sets size function used by the spring relaxation method.

Parameters
a_sizerThe size function class

Definition at line 74 of file MeRelaxer.cpp.

References m_sizer.

◆ SetRelaxationMethod()

bool xms::MeRelaxerImpl::SetRelaxationMethod ( const std::string &  a_relaxType)
overridevirtual

Sets the relaxation method.

Parameters
[in]a_relaxTypeCase insensitive string that identifies the type of relaxation. Acceptable values include: "spring_relax"
Returns
true if the relaxtype could be set

Definition at line 230 of file MeRelaxer.cpp.

References m_relaxType, and stToLowerCopy().

◆ SpringRelaxSinglePoint()

void xms::MeRelaxerImpl::SpringRelaxSinglePoint ( int  a_point,
Pt3d a_newLocation 
)

Relax a point using spring method.

Parameters
[in]a_pointThe point index to be relaxed.
[out]a_newLocationThe location after point is relaxed (moved).
Returns
true if there were no errors.
Todo:
: * this->get_adjust_factor(p0, p1)

Definition at line 423 of file MeRelaxer.cpp.

References gmCreateVector(), m_pointNeighbors, m_pointSizes, m_tin, Mdist(), xms::Pt3< T >::x, and xms::Pt3< T >::y.

Referenced by RelaxMarkedPoints(), MeRelaxerUnitTests::testSpringRelaxSinglePoint(), MeRelaxerUnitTests::testSpringRelaxSinglePoint2(), and MeRelaxerUnitTests::testSpringRelaxSinglePoint3().


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