Workspace 6.21.5
Public Member Functions | Static Public Member Functions | List of all members
MeshFeatureIdentifier Class Reference

Class for identifying surface features of a mesh.

#include <Mesh/DataStructures/meshfeatureidentifier.h>

Inheritance diagram for MeshFeatureIdentifier:
[legend]

Public Member Functions

 MeshFeatureIdentifier ()
 
 MeshFeatureIdentifier (const MeshFeatureIdentifier &mfi)
 
 ~MeshFeatureIdentifier () override
 
MeshFeatureIdentifierclone () const override
 
double curvature (const Node &node, int normalIndex) const
 
double getFeatureAngle () const
 
double getFreeEdgeCornerAngle () const
 
double getSmallEdgeLength () const
 
double getSmallEdgeLengthSq () const
 
bool isFreeEdgeCorner (const Node &node) const
 
bool isOnFeature (const Node &node, int normalIndex) const
 
bool isOnFeature (double curvature) const
 
MeshFeatureIdentifieroperator= (const MeshFeatureIdentifier &mfi)
 
void setFeatureAngle (double angle)
 
void setFreeEdgeCornerAngle (double angle)
 
void setSmallEdgeLength (double d)
 
void updateTolerances ()
 
- Public Member Functions inherited from ObjectGroup
 ~ObjectGroup () override
 
bool add (const QString &name, DataObject &obj)
 
bool canSerialize () const override
 
ObjectGroupclone () const override=0
 
bool empty () const
 
void ensureGroupHasData ()
 
void erase (int index)
 
DataObjectgetChild (const QString &name)
 
const DataObjectgetChild (const QString &name) const
 
DataObjectgetDataObject (int index)
 
const DataObjectgetDataObject (int index) const
 
int getIndex (const QString &name) const
 
const QString & getName (int index) const
 
virtual QString getPreferedWidget (const QString &name) const
 
bool hasData () const
 
bool haveName (const QString &name) const
 
bool insert (const QString &name, DataObject &obj, int index=-1)
 
bool load (const QJsonDocument &doc)
 
bool load (const SerializedItem &item) override
 
bool save (QJsonDocument &doc) const
 
bool save (SerializedItem &item) const override
 
unsigned size () const
 
- Public Member Functions inherited from Clonable
virtual ~Clonable ()=default
 
virtual Clonableclone () const =0
 
- Public Member Functions inherited from Serialize
virtual ~Serialize ()=default
 
virtual bool canSerialize () const =0
 
virtual bool load (const SerializedItem &item)=0
 
virtual bool save (SerializedItem &item) const =0
 

Static Public Member Functions

static int getNormalsIndex (NodeList &nodes)
 
static bool isOnFreeEdge (const Node &node)
 
static bool updateNormal (Node &node, int normalIndex)
 
static int updateNormals (NodeList &nodes)
 

Additional Inherited Members

- Protected Member Functions inherited from ObjectGroup
 ObjectGroup ()
 
void clear ()
 
ObjectGroupoperator= (const ObjectGroup &rhs)
 
bool operator== (const ObjectGroup &rhs) const
 
void swap (ObjectGroup &rhs)
 

Constructor & Destructor Documentation

◆ MeshFeatureIdentifier() [1/2]

The constructor sets the following default tolerances:

  • feature angle = 15 degrees
  • free edge corner angle = 30 degrees

◆ MeshFeatureIdentifier() [2/2]

Parameters
mfiFeature identifier to copy.

The copy constructor sets the newly created object's tolerances to be the same as mfi.

◆ ~MeshFeatureIdentifier()

~MeshFeatureIdentifier ( )
override

Clean up private implementation.

Member Function Documentation

◆ clone()

MeshFeatureIdentifier * clone ( ) const
overridevirtual
Returns
A clone of this object.
Note
Subclasses would normally return their own type rather than the Clonable type. The C++ language rules allow a more derived type to be returned from a virtual function and the compiler will still treat it as a valid override.

We redeclare this function only so that the more derived return type is available without casting.

Implements ObjectGroup.

◆ curvature()

double curvature ( const Node node,
int  normalIndex 
) const
Parameters
nodeThe node for which the curvature is to be calculated.
normalIndexThe index for the node state called "normal". This is usually obtained from a call to getNormalsIndex() or updateNormals().

This function provides some measure of how curved the area around this node is. For flat areas, it returns 1. For curved areas, it will return less than 1, but more than -1. The further this value is from 1, the greater the curvature at this node.

Precondition
The node normal index must be set before this call.
Returns
$\cos(\theta)$, where $\theta$ is the largest angle between the node normal and all attached shell elements' normals. If this is a free node, the function will return 1.
See also
setNodeNormalIndex

◆ getFeatureAngle()

double getFeatureAngle ( ) const
Returns
The feature angle in degrees.

◆ getFreeEdgeCornerAngle()

double getFreeEdgeCornerAngle ( ) const
Returns
The edge corner angle in degrees.

◆ getNormalsIndex()

int getNormalsIndex ( NodeList nodes)
static
Parameters
nodesThe set of nodes that should support node normals.

Ensures that nodes supports the node normals, which means that the nodes have a state with the name "normal". Once this is done, the index of this state is returned.

Returns
The index of the node normals state.

◆ getSmallEdgeLength()

double getSmallEdgeLength ( ) const
Returns
The distance below which an element edge is considered to effectively have zero length.
See also
setSmallEdgeLength

◆ getSmallEdgeLengthSq()

double getSmallEdgeLengthSq ( ) const
Returns
The square of the distance below which an element edge is considered to effectively have zero length.

Apart from taking the squared value, this function differs from getSmallEdgeLength() in one other important way. It relies on the tolerance having been set by a call to setSmallEdgeLength(), or at least the updateTolerances() function being called after the small edge length tolerance has been changed by some other means. Clients would use getSmallEdgeLengthSq() when they expect to need the squared distance frequently but cannot easily cache the returned value itself. The squared value is explicitly stored internally by the MeshFeatureIdentifier class, so it is made available by this function mostly as a quicker alternative to getSmallEdgeLength.

See also
setSmallEdgeLength

◆ isFreeEdgeCorner()

bool isFreeEdgeCorner ( const Node node) const
Parameters
nodeThe node to test.
Returns
True if node is on a corner of a free edge.

A corner is taken as an edge having an angle of more than the currently set free edge corner angle limit from straight. Note that no attempt is made to test if the edge is planar, so this may influence the angle test.

Precondition
node is assumed to be on a free edge.
The mesh is assumed to be well-formed, meaning that there are no multiple intersects of the shell mesh at this node. Another way of saying this is that there must be exactly two other edge nodes attached to this one via shell elements.
The internal tolerances must be current for this function to work properly. This can be ensured by a call to updateTolerances(), but this is not a trivial function call due to the internal calculations involved. Once it has been called, it does not need to be called again until something modifies the tolerance angles without using the setFreeEdgeCornerAngleRad or setFreeEdgeCornerAngleDeg function.

◆ isOnFeature() [1/2]

bool isOnFeature ( const Node node,
int  normalIndex 
) const
Parameters
nodeThe node whose curvature value is to be tested.
normalIndexThe index for the node state called "normal". This is usually obtained from a call to getNormalsIndex() or updateNormals().
Returns
True if the curvature at node is less than the currently set feature tolerance. The feature tolerance is simply the cosine of the feature angle.
Precondition
The internal tolerances must be current for this function to work properly. This can be ensured by a call to updateTolerances(), but this is not a trivial function call due to the internal calculations involved. Once it has been called, it does not need to be called again until something modifies the tolerance angles without using the setFeatureAngleRad or setFeatureAngleDeg function.

◆ isOnFeature() [2/2]

bool isOnFeature ( double  curvature) const
Parameters
curvatureThe curvature value to test.
Returns
True if curvature is less than the currently set feature tolerance. The feature tolerance is simply the cosine of the feature angle.
Precondition
The internal tolerances must be current for this function to work properly. This can be ensured by a call to updateTolerances(), but this is not a trivial function call due to the internal calculations involved. Once it has been called, it does not need to be called again until something modifies the tolerance angles without using the setFeatureAngleRad or setFeatureAngleDeg function.

◆ isOnFreeEdge()

bool isOnFreeEdge ( const Node node)
static
Returns
True if node is on a free edge. A node with no shell elements attached will return false.

◆ operator=()

MeshFeatureIdentifier & operator= ( const MeshFeatureIdentifier mfi)

◆ setFeatureAngle()

void setFeatureAngle ( double  angle)
Parameters
angleThe feature angle in degrees.

The feature angle defines the largest angle between the node normal and each attached shell element normal before the node is considered to be on a topological feature. Note that this is not the angle between two adjacent shell elements. The default is 15 degrees.

◆ setFreeEdgeCornerAngle()

void setFreeEdgeCornerAngle ( double  angle)
Parameters
angleThe free edge corner angle in degrees.

The free edge corner angle defines the largest angle from straight along a free edge before it is considered a corner. The normals of the shell elements making up the edge are not considered when determining this. The default value is 30 degrees. Smaller angles will result in more edges being deemed to have corner nodes, whereas larger edges will result in more edges being considered straight.

◆ setSmallEdgeLength()

void setSmallEdgeLength ( double  d)
Parameters
dThe distance below which an element edge is considered to effectively have zero length. This tolerance is used to test for two nodes being essentially in the same location, which generally means that an element with those two nodes as an edge has zero area or is a quad that looks like a tri.

◆ updateNormal()

bool updateNormal ( Node node,
int  normalIndex 
)
static
Parameters
nodeThe node for which the normal should be updated.
normalIndexThe index for the node state called "normal". This is usually obtained from a call to getNormalsIndex() or updateNormals().

The node normal is calculated as an angle-weighted average of the attached shell elements' normals. The angle weighting is achieved by multiplying each normal by the vertex angle formed at this node. When the node normal vector is scaled to unit length, the angle-weighting has already been conveniently incorporated into the calculation.

Returns
True if the normal was successfully calculated. It will return false if there were any attached degenerate elements (ie elements with coincident nodes), the node has no shells attached, or the attached shells have normal vectors such that an angle weighted sum results in a zero vector. This last case could occur if elements have normals at 180 degrees to each other, such as being squashed such that all attached elements are in the same plane but some with opposing normals. It will also return false if the node normal index has not been set.

◆ updateNormals()

int updateNormals ( NodeList nodes)
static
Parameters
nodesThe set of nodes whose normals are to be updated.

Update the normal vector for all nodes in nodes. For normals that cannot be calculated, a zero normal is assigned. If necessary, this function adds a state to nodes for node normals.

Returns
The index of the node normals state.

◆ updateTolerances()

void updateTolerances ( )