The MeshTopoAlgorithm class provides several algorithms to manipulate a mesh. More...
#include <TopoAlgorithm.h>
Public Member Functions | |
void | BeginCache () |
Caching facility. | |
void | Cleanup () |
Removes all invalid marked elements from the mesh structure. | |
void | EndCache () |
void | FillupHoles (int level, AbstractPolygonTriangulator &, const std::list< std::vector< unsigned long > > &aBorders, std::list< std::vector< unsigned long > > &aFailed) |
This is an overloaded method provided for convenience. | |
void | FillupHoles (unsigned long length, int level, AbstractPolygonTriangulator &, std::list< std::vector< unsigned long > > &aFailed) |
Closes holes in the mesh that consists of up to length edges. | |
void | FindComponents (unsigned long count, std::vector< unsigned long > &aInds) |
Find topologic independent components with maximum count facets and returns an array of the indices. | |
void | FindHoles (unsigned long length, std::list< std::vector< unsigned long > > &aBorders) const |
Find holes which consists of up to length edges. | |
void | FlipNormals (void) |
Flips the normals. | |
void | HarmonizeNormals (void) |
Harmonizes the normals. | |
bool | IsSwapEdgeLegal (unsigned long ulFacetPos, unsigned long ulNeighbour) const |
Checks whether a swap edge operation is legel that is fulfilled if the two adjacent facets builds a convex polygon. | |
MeshTopoAlgorithm (MeshKernel &rclM) | |
void | RemoveComponents (unsigned long count) |
Removes topologic independent components with maximum count facets. | |
void | RemoveCorruptedFacet (unsigned long index) |
Removes the corrupted facet at position index from the mesh structure. | |
void | RemoveDegeneratedFacet (unsigned long index) |
Removes the degenerated facet at position index from the mesh structure. | |
bool | ShouldSwapEdge (unsigned long ulFacetPos, unsigned long ulNeighbour, float fMaxAngle) const |
Checks whether the swap edge operation is legal and whether it makes sense. | |
bool | SnapVertex (unsigned long ulFacetPos, const Base::Vector3f &rP) |
Creates a new triangle with neighbour facet ulFacetPos and the vertex rclPoint whereat it must lie outside the given facet. | |
float | SwapEdgeBenefit (unsigned long f, int e) const |
Computes a value for the benefit of swapping the edge. | |
virtual | ~MeshTopoAlgorithm (void) |
Topological Optimization | |
void | AdjustEdgesToCurvatureDirection () |
Tries to adjust the edges to the curvature direction with the minimum absolute value of maximum and minimum curvature. | |
int | DelaunayFlip () |
Overloaded method DelaunayFlip that doesn't use ShouldSwapEdge to check for legal swap edge. | |
void | DelaunayFlip (float fMaxAngle) |
Tries to make a more beautiful mesh by swapping the common edge of two adjacent facets where needed. | |
void | OptimizeTopology () |
void | OptimizeTopology (float fMaxAngle) |
Tries to make a more beautiful mesh by swapping the common edge of two adjacent facets where needed. | |
Topological Operations | |
bool | CollapseEdge (unsigned long ulFacetPos, unsigned long ulNeighbour) |
Collapses the common edge of two adjacent facets. | |
bool | CollapseFacet (unsigned long ulFacetPos) |
Removes the facet with index ulFacetPos and all its neighbour facets. | |
bool | InsertVertex (unsigned long ulFacetPos, const Base::Vector3f &rclPoint) |
Inserts a new vertex in the given triangle so that is splitted into three triangles. | |
bool | InsertVertexAndSwapEdge (unsigned long ulFacetPos, const Base::Vector3f &rclPoint, float fMaxAngle) |
This method is provided for convenience. | |
bool | SplitEdge (unsigned long ulFacetPos, unsigned long ulNeighbour, const Base::Vector3f &rP) |
Splits the common edge of the two adjacent facets with index ulFacetPos and ulNeighbour. | |
void | SplitFacet (unsigned long ulFacetPos, const Base::Vector3f &rP1, const Base::Vector3f &rP2) |
Splits the facet with index ulFacetPos into up to three facets. | |
void | SplitOpenEdge (unsigned long ulFacetPos, unsigned short uSide, const Base::Vector3f &rP) |
Splits the facet with index ulFacetPos on the edge side uSide into two facets. | |
void | SwapEdge (unsigned long ulFacetPos, unsigned long ulNeighbour) |
Swaps the common edge of two adjacent facets even if the operation might be illegal. |
The MeshTopoAlgorithm class provides several algorithms to manipulate a mesh.
It supports various mesh operations like inserting a new vertex, swapping the common edge of two adjacent facets, split a facet, ...
Definition at line 49 of file TopoAlgorithm.h.
MeshTopoAlgorithm::MeshTopoAlgorithm | ( | MeshKernel & | rclM | ) |
Definition at line 45 of file TopoAlgorithm.cpp.
MeshTopoAlgorithm::~MeshTopoAlgorithm | ( | void | ) | [virtual] |
Definition at line 50 of file TopoAlgorithm.cpp.
References Cleanup(), and EndCache().
void MeshTopoAlgorithm::AdjustEdgesToCurvatureDirection | ( | ) |
Tries to adjust the edges to the curvature direction with the minimum absolute value of maximum and minimum curvature.
Definition at line 423 of file TopoAlgorithm.cpp.
References MeshCore::MeshGeomFacet::_aclPoints, MeshCore::MeshFacet::_aulPoints, MeshCore::MeshKernel::CountFacets(), MeshCore::MeshKernel::CountPoints(), Sketcher::Distance, SketcherExample::f, MeshCore::MeshKernel::GetFacets(), Wm4::MeshCurvature< Real >::GetMaxCurvatures(), Wm4::MeshCurvature< Real >::GetMaxDirections(), Wm4::MeshCurvature< Real >::GetMinCurvatures(), Wm4::MeshCurvature< Real >::GetMinDirections(), MeshCore::MeshGeomFacet::GetNormal(), MeshCore::MeshKernel::GetPoints(), MeshCore::MeshPointIterator::Init(), MeshCore::MeshFacet::IsFlag(), IsSwapEdgeLegal(), k, MeshCore::MeshPointIterator::More(), MeshCore::MeshPointIterator::Next(), Base::Vector3< _Precision >::Normalize(), MeshCore::MeshFacetArray::ResetFlag(), MeshCore::MeshFacet::SetFlag(), MeshCore::MeshFacet::Side(), SwapEdge(), MeshCore::MeshFacet::VISIT, Wm4::Vector3< Real >::X(), Wm4::Vector3< Real >::Y(), and Wm4::Vector3< Real >::Z().
Referenced by Mesh::MeshObject::optimizeEdges().
void MeshTopoAlgorithm::BeginCache | ( | ) |
Caching facility.
Definition at line 768 of file TopoAlgorithm.cpp.
References MeshCore::MeshKernel::_aclPointArray.
void MeshTopoAlgorithm::Cleanup | ( | ) |
Removes all invalid marked elements from the mesh structure.
Definition at line 836 of file TopoAlgorithm.cpp.
References MeshCore::MeshKernel::RemoveInvalids().
Referenced by MeshPart::MeshAlgos::offsetSpecial2(), Mesh::MeshObject::offsetSpecial2(), and ~MeshTopoAlgorithm().
bool MeshTopoAlgorithm::CollapseEdge | ( | unsigned long | ulFacetPos, | |
unsigned long | ulNeighbour | |||
) |
Collapses the common edge of two adjacent facets.
This operation removes one common point of the collapsed edge and the facets ulFacetPos and ulNeighbour from the data structure.
Definition at line 842 of file TopoAlgorithm.cpp.
References MeshCore::MeshKernel::_aclFacetArray, MeshCore::MeshKernel::_aclPointArray, MeshCore::MeshFacet::_aulNeighbours, MeshCore::MeshFacet::_aulPoints, MeshCore::MeshFacet::IsValid(), MeshCore::MeshFacet::SetInvalid(), MeshCore::MeshFacet::Side(), and MeshCore::MeshFacet::Transpose().
Referenced by Mesh::MeshObject::collapseEdge().
bool MeshTopoAlgorithm::CollapseFacet | ( | unsigned long | ulFacetPos | ) |
Removes the facet with index ulFacetPos and all its neighbour facets.
The three vertices that are referenced by this facet are replaced by its gravity point.
Definition at line 894 of file TopoAlgorithm.cpp.
References MeshCore::MeshKernel::_aclFacetArray, MeshCore::MeshKernel::_aclPointArray, MeshCore::MeshFacet::_aulNeighbours, MeshCore::MeshFacet::_aulPoints, MeshCore::MeshKernel::GetGravityPoint(), MeshCore::MeshFacet::IsValid(), MeshCore::MeshFacet::SetInvalid(), MeshCore::MeshFacet::Side(), and MeshCore::MeshFacet::Transpose().
Referenced by Mesh::MeshObject::collapseFacet(), Mesh::MeshObject::collapseFacets(), MeshPart::MeshAlgos::offsetSpecial2(), and Mesh::MeshObject::offsetSpecial2().
int MeshTopoAlgorithm::DelaunayFlip | ( | ) |
Overloaded method DelaunayFlip that doesn't use ShouldSwapEdge to check for legal swap edge.
Definition at line 383 of file TopoAlgorithm.cpp.
References MeshCore::MeshKernel::_aclFacetArray, MeshCore::MeshGeomFacet::_aclPoints, MeshCore::MeshFacet::_aulNeighbours, Mod::PartDesign::Scripts::Gear::c1, MeshCore::MeshGeomFacet::CenterOfCircumCircle(), Base::DistanceP2(), MeshCore::MeshKernel::GetFacet(), MeshCore::MeshFacet::IsFlag(), k, MeshCore::MeshFacetArray::ResetFlag(), MeshCore::MeshFacet::SetFlag(), MeshCore::MeshFacet::Side(), SwapEdge(), and MeshCore::MeshFacet::TMP0.
void MeshTopoAlgorithm::DelaunayFlip | ( | float | fMaxAngle | ) |
Tries to make a more beautiful mesh by swapping the common edge of two adjacent facets where needed.
A swap is needed where two adjacent facets don't fulfill the Delaunay condition.
Definition at line 336 of file TopoAlgorithm.cpp.
References MeshCore::MeshKernel::_aclFacetArray, MeshCore::MeshFacet::_aulNeighbours, MeshCore::MeshFacet::_aulPoints, MeshCore::MeshGeomFacet::CenterOfCircumCircle(), Base::DistanceP2(), MeshCore::MeshKernel::GetFacet(), MeshCore::MeshKernel::GetPoint(), ShouldSwapEdge(), MeshCore::MeshFacet::Side(), and SwapEdge().
void MeshTopoAlgorithm::EndCache | ( | ) |
Definition at line 780 of file TopoAlgorithm.cpp.
Referenced by ~MeshTopoAlgorithm().
void MeshTopoAlgorithm::FillupHoles | ( | int | level, | |
AbstractPolygonTriangulator & | cTria, | |||
const std::list< std::vector< unsigned long > > & | aBorders, | |||
std::list< std::vector< unsigned long > > & | aFailed | |||
) |
This is an overloaded method provided for convenience.
It takes as first argument the boundaries which must be filled up.
Definition at line 1291 of file TopoAlgorithm.cpp.
References MeshCore::MeshKernel::_aclPointArray, MeshCore::MeshKernel::_clBoundBox, MeshCore::MeshKernel::AddFacets(), MeshCore::MeshAlgorithm::FillupHole(), and UnitParser::if().
void MeshTopoAlgorithm::FillupHoles | ( | unsigned long | length, | |
int | level, | |||
AbstractPolygonTriangulator & | cTria, | |||
std::list< std::vector< unsigned long > > & | aFailed | |||
) |
Closes holes in the mesh that consists of up to length edges.
In case a fit needs to be done then the points of the neighbours of level rings will be used. Holes for which the triangulation failed are returned in aFailed.
Definition at line 1235 of file TopoAlgorithm.cpp.
References MeshCore::MeshKernel::_aclPointArray, MeshCore::MeshKernel::_clBoundBox, MeshCore::MeshKernel::AddFacets(), MeshCore::MeshAlgorithm::FillupHole(), MeshCore::MeshAlgorithm::GetMeshBorders(), UnitParser::if(), and MeshCore::MeshAlgorithm::SplitBoundaryLoops().
Referenced by Mesh::MeshObject::fillupHoles().
void MeshTopoAlgorithm::FindComponents | ( | unsigned long | count, | |
std::vector< unsigned long > & | aInds | |||
) |
Find topologic independent components with maximum count facets and returns an array of the indices.
Definition at line 1351 of file TopoAlgorithm.cpp.
References Py::long, MeshCore::MeshComponents::OverEdge, MeshCore::MeshComponents::SearchForComponents(), and Mesh2Shape::segments.
Referenced by RemoveComponents().
void MeshTopoAlgorithm::FindHoles | ( | unsigned long | length, | |
std::list< std::vector< unsigned long > > & | aBorders | |||
) | const |
Find holes which consists of up to length edges.
Definition at line 1339 of file TopoAlgorithm.cpp.
References MeshCore::MeshAlgorithm::GetMeshBorders().
void MeshTopoAlgorithm::FlipNormals | ( | void | ) |
Flips the normals.
Definition at line 1378 of file TopoAlgorithm.cpp.
References MeshCore::MeshKernel::_aclFacetArray.
Referenced by Mesh::MeshObject::flipNormals(), SpringbackCorrection::Init(), SpringbackCorrection::Load(), and SpringbackCorrection::SpringbackCorrection().
void MeshTopoAlgorithm::HarmonizeNormals | ( | void | ) |
Harmonizes the normals.
Definition at line 1371 of file TopoAlgorithm.cpp.
References MeshCore::MeshKernel::_aclFacetArray.
Referenced by Mesh::MeshObject::harmonizeNormals(), SpringbackCorrection::Init(), SpringbackCorrection::Load(), and SpringbackCorrection::SpringbackCorrection().
bool MeshTopoAlgorithm::InsertVertex | ( | unsigned long | ulFacetPos, | |
const Base::Vector3f & | rclPoint | |||
) |
Inserts a new vertex in the given triangle so that is splitted into three triangles.
The given point must lie inside the triangle not outside or on an edge.
Definition at line 57 of file TopoAlgorithm.cpp.
References MeshCore::MeshKernel::_aclFacetArray, MeshCore::MeshKernel::_aclPointArray, MeshCore::MeshFacet::_aulNeighbours, and MeshCore::MeshFacet::_aulPoints.
Referenced by Mesh::MeshObject::insertVertex(), and InsertVertexAndSwapEdge().
bool MeshTopoAlgorithm::InsertVertexAndSwapEdge | ( | unsigned long | ulFacetPos, | |
const Base::Vector3f & | rclPoint, | |||
float | fMaxAngle | |||
) |
This method is provided for convenience.
It inserts a new vertex to the mesh and tries to swap the common edges of the newly created facets with their neighbours. Just inserting a new vertex leads to very acute-angled triangles which might be problematic for some algorithms. This method tries to swap the edges to build more well-formed triangles.
Definition at line 516 of file TopoAlgorithm.cpp.
References MeshCore::MeshKernel::_aclFacetArray, MeshCore::MeshFacet::_aulNeighbours, InsertVertex(), ShouldSwapEdge(), and SwapEdge().
Referenced by Mesh::MeshObject::refine().
bool MeshTopoAlgorithm::IsSwapEdgeLegal | ( | unsigned long | ulFacetPos, | |
unsigned long | ulNeighbour | |||
) | const |
Checks whether a swap edge operation is legel that is fulfilled if the two adjacent facets builds a convex polygon.
If this operation is legal true is returned, false is returned if this operation is illegal or if ulFacetPos and ulNeighbour are not adjacent facets.
Definition at line 570 of file TopoAlgorithm.cpp.
References MeshCore::MeshKernel::_aclFacetArray, MeshCore::MeshKernel::_aclPointArray, MeshCore::MeshFacet::_aulPoints, SketcherExample::f, MeshCore::MeshGeomFacet::IsDegenerated(), and MeshCore::MeshFacet::Side().
Referenced by AdjustEdgesToCurvatureDirection(), and ShouldSwapEdge().
void MeshTopoAlgorithm::OptimizeTopology | ( | ) |
Definition at line 296 of file TopoAlgorithm.cpp.
References FemExample::b, MeshCore::MeshKernel::CountFacets(), SketcherExample::f, Mesh2Shape::faces, MeshCore::MeshKernel::GetFacets(), SwapEdge(), and SwapEdgeBenefit().
void MeshTopoAlgorithm::OptimizeTopology | ( | float | fMaxAngle | ) |
Tries to make a more beautiful mesh by swapping the common edge of two adjacent facets where needed.
fMaxAngle is the maximum allowed angle between the normals of two adjacent facets to allow swapping the common edge. A too high value might result into folds on the surface.
Definition at line 144 of file TopoAlgorithm.cpp.
References MeshCore::MeshKernel::_aclFacetArray, MeshCore::MeshFacet::_aulPoints, ShouldSwapEdge(), MeshCore::MeshFacet::Side(), and SwapEdge().
Referenced by Mesh::MeshObject::optimizeTopology().
void MeshTopoAlgorithm::RemoveComponents | ( | unsigned long | count | ) |
Removes topologic independent components with maximum count facets.
Definition at line 1363 of file TopoAlgorithm.cpp.
References MeshCore::MeshKernel::DeleteFacets(), and FindComponents().
void MeshTopoAlgorithm::RemoveCorruptedFacet | ( | unsigned long | index | ) |
Removes the corrupted facet at position index from the mesh structure.
A facet is corrupted if the indices of its corner points are not all different.
Definition at line 1210 of file TopoAlgorithm.cpp.
References MeshCore::MeshKernel::_aclFacetArray, MeshCore::MeshFacet::_aulNeighbours, MeshCore::MeshFacet::_aulPoints, and MeshCore::MeshKernel::DeleteFacet().
Referenced by MeshCore::MeshFixCorruptedFacets::Fixup().
void MeshTopoAlgorithm::RemoveDegeneratedFacet | ( | unsigned long | index | ) |
Removes the degenerated facet at position index from the mesh structure.
A facet is degenerated if its corner points are collinear.
Definition at line 1143 of file TopoAlgorithm.cpp.
References MeshCore::MeshKernel::_aclFacetArray, MeshCore::MeshKernel::_aclPointArray, MeshCore::MeshFacet::_aulNeighbours, MeshCore::MeshFacet::_aulPoints, MeshCore::MeshKernel::DeleteFacet(), SketcherExample::f, and MeshCore::MeshFacet::Side().
Referenced by MeshCore::MeshFixDegeneratedFacets::Fixup().
bool MeshTopoAlgorithm::ShouldSwapEdge | ( | unsigned long | ulFacetPos, | |
unsigned long | ulNeighbour, | |||
float | fMaxAngle | |||
) | const |
Checks whether the swap edge operation is legal and whether it makes sense.
This operation only makes sense if the maximum angle of both facets is decreased and if the angle between the facet normals does not exceed fMaxAngle.
Definition at line 610 of file TopoAlgorithm.cpp.
References MeshCore::MeshKernel::_aclFacetArray, MeshCore::MeshKernel::_aclPointArray, MeshCore::MeshFacet::_aulPoints, Base::Vector3< _Precision >::GetAngle(), MeshCore::MeshGeomFacet::GetNormal(), IsSwapEdgeLegal(), MeshCore::MeshGeomFacet::MaximumAngle(), and MeshCore::MeshFacet::Side().
Referenced by DelaunayFlip(), MeshCore::MeshFixDeformedFacets::Fixup(), InsertVertexAndSwapEdge(), and OptimizeTopology().
bool MeshTopoAlgorithm::SnapVertex | ( | unsigned long | ulFacetPos, | |
const Base::Vector3f & | rP | |||
) |
Creates a new triangle with neighbour facet ulFacetPos and the vertex rclPoint whereat it must lie outside the given facet.
Definition at line 103 of file TopoAlgorithm.cpp.
References MeshCore::MeshKernel::_aclFacetArray, MeshCore::MeshKernel::_aclPointArray, MeshCore::MeshFacet::_aulNeighbours, MeshCore::MeshFacet::_aulPoints, MeshCore::MeshKernel::CountFacets(), Base::DistanceP2(), SketcherExample::f, FLOAT_EPS, MeshCore::MeshKernel::GetNormal(), MeshCore::MeshFacet::HasOpenEdge(), Base::Vector3< _Precision >::Length(), and SplitOpenEdge().
Referenced by Mesh::MeshObject::snapVertex().
bool MeshTopoAlgorithm::SplitEdge | ( | unsigned long | ulFacetPos, | |
unsigned long | ulNeighbour, | |||
const Base::Vector3f & | rP | |||
) |
Splits the common edge of the two adjacent facets with index ulFacetPos and ulNeighbour.
The point rP must lie inside of one the given facets are on the common edge. The two facets get broken into four facets, i.e. that two new facets get created. If rP is coincident with a corner point nothing happens.
Definition at line 669 of file TopoAlgorithm.cpp.
References MeshCore::MeshKernel::_aclFacetArray, MeshCore::MeshKernel::_aclPointArray, MeshCore::MeshFacet::_aulNeighbours, MeshCore::MeshFacet::_aulPoints, and MeshCore::MeshFacet::Side().
Referenced by Mesh::MeshObject::splitEdge(), Mesh::MeshObject::splitEdges(), and SplitFacet().
void MeshTopoAlgorithm::SplitFacet | ( | unsigned long | ulFacetPos, | |
const Base::Vector3f & | rP1, | |||
const Base::Vector3f & | rP2 | |||
) |
Splits the facet with index ulFacetPos into up to three facets.
FIXME: Implement.
The points rP1 and rP2 should lie on two different edges of the facet. This method splits up the both neighbour facets as well. If either rP1 or rP2 (probably due to a previous call of SplitFacet()) is coincident with a corner point then the facet is splitted into two facets. If both points are coincident with corner points of this facet nothing is done.
Definition at line 959 of file TopoAlgorithm.cpp.
References MeshCore::MeshKernel::_aclFacetArray, MeshCore::MeshKernel::_aclPointArray, MeshCore::MeshFacet::_aulNeighbours, MeshCore::MeshFacet::_aulPoints, Base::Distance(), Base::Vector3< _Precision >::DistanceToLine(), SketcherExample::f, FLOAT_MAX, MESH_MIN_EDGE_LEN, SplitEdge(), and SplitOpenEdge().
Referenced by MeshPart::MeshAlgos::cutByCurve(), and Mesh::MeshObject::splitFacet().
void MeshTopoAlgorithm::SplitOpenEdge | ( | unsigned long | ulFacetPos, | |
unsigned short | uSide, | |||
const Base::Vector3f & | rP | |||
) |
Splits the facet with index ulFacetPos on the edge side uSide into two facets.
This side must be an open edge otherwise nothing is done. The point rP must be near to this edge and must not be coincident with any corner vertices of the facet.
Definition at line 723 of file TopoAlgorithm.cpp.
References MeshCore::MeshKernel::_aclFacetArray, MeshCore::MeshKernel::_aclPointArray, MeshCore::MeshFacet::_aulNeighbours, and MeshCore::MeshFacet::_aulPoints.
Referenced by SnapVertex(), and SplitFacet().
void MeshTopoAlgorithm::SwapEdge | ( | unsigned long | ulFacetPos, | |
unsigned long | ulNeighbour | |||
) |
Swaps the common edge of two adjacent facets even if the operation might be illegal.
To be sure that this operation is legal check either with IsSwapEdgeLegal() or ShouldSwapEdge() before. An illegel swap edge operation can produce non-manifolds, degenrated facets or it might create a fold on the surface, i.e. geometric overlaps of several triangles.
Definition at line 643 of file TopoAlgorithm.cpp.
References MeshCore::MeshKernel::_aclFacetArray, MeshCore::MeshFacet::_aulNeighbours, MeshCore::MeshFacet::_aulPoints, and MeshCore::MeshFacet::Side().
Referenced by AdjustEdgesToCurvatureDirection(), DelaunayFlip(), MeshCore::MeshFixDeformedFacets::Fixup(), InsertVertexAndSwapEdge(), OptimizeTopology(), and Mesh::MeshObject::swapEdge().
float MeshTopoAlgorithm::SwapEdgeBenefit | ( | unsigned long | f, | |
int | e | |||
) | const |
Computes a value for the benefit of swapping the edge.
Definition at line 265 of file TopoAlgorithm.cpp.
References Mesh2Shape::faces, MeshCore::MeshKernel::GetFacets(), MeshCore::MeshKernel::GetPoints(), swap_benefit(), and draftlibs::fcgeo::v1().
Referenced by OptimizeTopology().