libatomprobe
Library for Atom Probe Tomography (APT) computation
Public Member Functions | Public Attributes | List of all members
AtomProbe::Mesh Class Reference

Simple mesh class for storing and manipulating meshes consisting of 2 and 3D simplexes (triangles or tetrahedra) More...

#include <mesh.h>

Collaboration diagram for AtomProbe::Mesh:
Collaboration graph
[legend]

Public Member Functions

void setNode (unsigned int index, Point3D node)
 Set the nodes value. More...
 
void resizeNodes (unsigned int newSize)
 Resize the node vector. More...
 
Point3D getNodes (unsigned int index)
 Retrieve an object. More...
 
unsigned int loadGmshMesh (const char *meshfile, unsigned int &curLine, bool allowBadMeshes=true)
 
unsigned int saveGmshMesh (const char *meshfile) const
 
size_t elementCount () const
 
void setTriangleMesh (const std::vector< float > &ptsA, const std::vector< float > &ptsB, const std::vector< float > &ptsC)
 
void reassignGroups (unsigned int i)
 reassign the physical groups to a single number More...
 
void removeDuplicateTris ()
 Remove exact duplicate triangles. More...
 
void mergeDuplicateVertices (float tolerance)
 
bool isSane (bool output=false, std::ostream &outStream=std::cerr) const
 Perform various sanity tests on mesh. Should return true if your mesh is sane. More...
 
void getBounds (BoundCube &b) const
 Get the Axis aligned bounding box for this mesh. More...
 
unsigned int countTriNodes () const
 Count the number of unique nodes shared by triangles. More...
 
void translate ()
 Translate mesh around node centroid. More...
 
void translate (const Point3D &origin)
 Translate mesh to specified position. More...
 
void scale (const Point3D &origin, float scaleFactor)
 Scale the mesh around a specified origin. More...
 
void scale (float scaleFactor)
 Scale the mesh around origin. More...
 
void rotate (const Point3D &axis, const Point3D &origin, float angle)
 Rotate mesh. More...
 
float getVolume () const
 Obtain the volume of the triangulated space. More...
 
void clear ()
 Clear the mesh. More...
 
void getContainedNodes (const BoundCube &b, std::vector< size_t > &nodes) const
 Return all the nodes that are contained within specified bounding box. More...
 
void getIntersectingPrimitives (std::vector< size_t > &searchNodes, std::vector< size_t > &lines, std::vector< size_t > &triangles, std::vector< size_t > &tetrahedra) const
 Return all primitives that are WHOLLY contained withing bounding box. More...
 
unsigned int divideMeshSurface (float divisionAngle, unsigned int newPhysGroupStart, const std::vector< size_t > &physGroupsToSplit)
 
void getCurPhysGroups (std::vector< std::pair< unsigned int, size_t > > &curPhys) const
 
void erasePhysGroup (unsigned int group, unsigned int typeMask)
 
unsigned int numDupVertices (float tolerance) const
 obtain the number of duplicate vertices in the mesh More...
 
unsigned int numDupTris () const
 Obtain the number of duplicate triangles in the mesh. More...
 
void print (std::ostream &o) const
 Print some statistics about the mesh data. More...
 
bool isOrientedCoherently () const
 Returns true if the mesh is coherently oriented. More...
 
void killOrphanNodes ()
 Kill specified orphan nodes within this dataset. More...
 
void pointsInside (const std::vector< Point3D > &p, std::vector< bool > &meshResults, unsigned int &prog) const
 Find the points that lie inside a this mesh. More...
 
void pointsInside (const std::vector< Point3D > &p, std::vector< bool > &meshResults) const
 Convenience wraper for pointsInside. More...
 
size_t getNearestTri (const Point3D &p, float &distance) const
 Find the nearest triangle to a particular point. More...
 
void getTriNormal (size_t tri, Point3D &normal) const
 

Public Attributes

std::vector< Point3Dnodes
 Point storage for 3D Data (nodes/coords/vertices..) More...
 
std::vector< std::string > physGroupNames
 Physical group storage. More...
 
std::vector< TETRAHEDRONtetrahedra
 Storage for node connectivity in tetrahedral form. More...
 
std::vector< TRIANGLEtriangles
 Storage for node connectivity in triangle form (take in groups of 3) More...
 
std::vector< LINElines
 Storage for line segments. .size()%2 should always==0. More...
 
std::vector< unsigned long long > points
 points More...
 

Detailed Description

Simple mesh class for storing and manipulating meshes consisting of 2 and 3D simplexes (triangles or tetrahedra)

Definition at line 78 of file mesh.h.

Member Function Documentation

◆ clear()

void AtomProbe::Mesh::clear ( )

Clear the mesh.

Definition at line 936 of file mesh.cpp.

References lines, nodes, physGroupNames, points, tetrahedra, and triangles.

Referenced by setTriangleMesh().

◆ countTriNodes()

unsigned int AtomProbe::Mesh::countTriNodes ( ) const

Count the number of unique nodes shared by triangles.

Definition at line 1350 of file mesh.cpp.

References triangles.

◆ divideMeshSurface()

unsigned int AtomProbe::Mesh::divideMeshSurface ( float  divisionAngle,
unsigned int  newPhysGroupStart,
const std::vector< size_t > &  physGroupsToSplit 
)

◆ elementCount()

size_t AtomProbe::Mesh::elementCount ( ) const

Definition at line 1977 of file mesh.cpp.

References lines, points, tetrahedra, and triangles.

Referenced by loadGmshMesh().

◆ erasePhysGroup()

void AtomProbe::Mesh::erasePhysGroup ( unsigned int  group,
unsigned int  typeMask 
)

◆ getBounds()

void AtomProbe::Mesh::getBounds ( BoundCube b) const

Get the Axis aligned bounding box for this mesh.

Definition at line 1532 of file mesh.cpp.

References ASSERT, nodes, AtomProbe::BoundCube::setBounds(), and triangles.

Here is the call graph for this function:

◆ getContainedNodes()

void AtomProbe::Mesh::getContainedNodes ( const BoundCube b,
std::vector< size_t > &  nodes 
) const

Return all the nodes that are contained within specified bounding box.

Definition at line 1761 of file mesh.cpp.

References ASSERT, AtomProbe::BoundCube::containsPt(), and nodes.

Here is the call graph for this function:

◆ getCurPhysGroups()

void AtomProbe::Mesh::getCurPhysGroups ( std::vector< std::pair< unsigned int, size_t > > &  curPhys) const

Definition at line 1829 of file mesh.cpp.

References tetrahedra, and triangles.

◆ getIntersectingPrimitives()

void AtomProbe::Mesh::getIntersectingPrimitives ( std::vector< size_t > &  searchNodes,
std::vector< size_t > &  lines,
std::vector< size_t > &  triangles,
std::vector< size_t > &  tetrahedra 
) const

Return all primitives that are WHOLLY contained withing bounding box.

Definition at line 1772 of file mesh.cpp.

References ASSERT, lines, tetrahedra, and triangles.

◆ getNearestTri()

size_t AtomProbe::Mesh::getNearestTri ( const Point3D p,
float &  distance 
) const

Find the nearest triangle to a particular point.

returns index of nearest triangle, and distance (reference)

Definition at line 2126 of file mesh.cpp.

References getTriNormal(), nodes, AtomProbe::signedDistanceToFacet(), and triangles.

Referenced by AtomProbe::TRIANGLE::edgesMismatch(), and main().

Here is the call graph for this function:

◆ getNodes()

Point3D AtomProbe::Mesh::getNodes ( unsigned int  index)

Retrieve an object.

Definition at line 863 of file mesh.cpp.

References nodes.

◆ getTriNormal()

void AtomProbe::Mesh::getTriNormal ( size_t  tri,
Point3D normal 
) const

Definition at line 1753 of file mesh.cpp.

References ASSERT, AtomProbe::Point3D::crossProd(), nodes, AtomProbe::Point3D::normalise(), and triangles.

Referenced by divideMeshSurface(), and getNearestTri().

Here is the call graph for this function:

◆ getVolume()

float AtomProbe::Mesh::getVolume ( ) const

Obtain the volume of the triangulated space.

Definition at line 1946 of file mesh.cpp.

References ASSERT, AtomProbe::Point3D::crossProd(), AtomProbe::Point3D::dotProd(), isOrientedCoherently(), isSane(), nodes, AtomProbe::TRIANGLE::p, and triangles.

Here is the call graph for this function:

◆ isOrientedCoherently()

bool AtomProbe::Mesh::isOrientedCoherently ( ) const

Returns true if the mesh is coherently oriented.

Definition at line 2152 of file mesh.cpp.

References ASSERT, isSane(), and triangles.

Referenced by AtomProbe::TRIANGLE::edgesMismatch(), getVolume(), and pointsInside().

Here is the call graph for this function:

◆ isSane()

bool AtomProbe::Mesh::isSane ( bool  output = false,
std::ostream &  outStream = std::cerr 
) const

Perform various sanity tests on mesh. Should return true if your mesh is sane.

Definition at line 572 of file mesh.cpp.

References lines, nodes, tetrahedra, and triangles.

Referenced by AtomProbe::TRIANGLE::edgesMismatch(), getVolume(), isOrientedCoherently(), killOrphanNodes(), loadGmshMesh(), mergeDuplicateVertices(), numDupTris(), print(), removeDuplicateTris(), saveGmshMesh(), and setTriangleMesh().

◆ killOrphanNodes()

void AtomProbe::Mesh::killOrphanNodes ( )

Kill specified orphan nodes within this dataset.

Definition at line 820 of file mesh.cpp.

References ASSERT, isSane(), lines, nodes, points, tetrahedra, and triangles.

Referenced by mergeDuplicateVertices(), and print().

Here is the call graph for this function:

◆ loadGmshMesh()

unsigned int AtomProbe::Mesh::loadGmshMesh ( const char *  meshfile,
unsigned int &  curLine,
bool  allowBadMeshes = true 
)

◆ mergeDuplicateVertices()

void AtomProbe::Mesh::mergeDuplicateVertices ( float  tolerance)

Definition at line 738 of file mesh.cpp.

References ASSERT, AtomProbe::findNearVerticies(), isSane(), killOrphanNodes(), lines, nodes, points, tetrahedra, and triangles.

Referenced by main().

Here is the call graph for this function:

◆ numDupTris()

unsigned int AtomProbe::Mesh::numDupTris ( ) const

Obtain the number of duplicate triangles in the mesh.

Definition at line 868 of file mesh.cpp.

References ASSERT, isSane(), nodes, and triangles.

Here is the call graph for this function:

◆ numDupVertices()

unsigned int AtomProbe::Mesh::numDupVertices ( float  tolerance) const

obtain the number of duplicate vertices in the mesh

Definition at line 911 of file mesh.cpp.

References nodes.

◆ pointsInside() [1/2]

void AtomProbe::Mesh::pointsInside ( const std::vector< Point3D > &  p,
std::vector< bool > &  meshResults,
unsigned int &  prog 
) const

Find the points that lie inside a this mesh.

Definition at line 1989 of file mesh.cpp.

References ASSERT, AtomProbe::BoundCube::containsPt(), AtomProbe::intersect_RayTriangle(), isOrientedCoherently(), nodes, AtomProbe::PROGRESS_REDUCE, AtomProbe::BoundCube::setBounds(), tetrahedra, and triangles.

Referenced by main(), and pointsInside().

Here is the call graph for this function:

◆ pointsInside() [2/2]

void AtomProbe::Mesh::pointsInside ( const std::vector< Point3D > &  p,
std::vector< bool > &  meshResults 
) const

Convenience wraper for pointsInside.

Definition at line 2119 of file mesh.cpp.

References pointsInside().

Here is the call graph for this function:

◆ print()

void AtomProbe::Mesh::print ( std::ostream &  o) const

Print some statistics about the mesh data.

Definition at line 445 of file mesh.cpp.

References ASSERT, isSane(), killOrphanNodes(), lines, nodes, AtomProbe::TRIANGLE::p, points, AtomProbe::BoundCube::setBounds(), tetrahedra, and triangles.

Here is the call graph for this function:

◆ reassignGroups()

void AtomProbe::Mesh::reassignGroups ( unsigned int  i)

reassign the physical groups to a single number

Definition at line 1375 of file mesh.cpp.

References lines, tetrahedra, and triangles.

◆ removeDuplicateTris()

void AtomProbe::Mesh::removeDuplicateTris ( )

Remove exact duplicate triangles.

Definition at line 691 of file mesh.cpp.

References ASSERT, isSane(), nodes, and triangles.

Here is the call graph for this function:

◆ resizeNodes()

void AtomProbe::Mesh::resizeNodes ( unsigned int  newSize)

Resize the node vector.

Definition at line 858 of file mesh.cpp.

References nodes.

◆ rotate()

void AtomProbe::Mesh::rotate ( const Point3D axis,
const Point3D origin,
float  angle 
)

Rotate mesh.

Definition at line 1453 of file mesh.cpp.

References AtomProbe::Point3f::fx, AtomProbe::Point3f::fy, AtomProbe::Point3f::fz, nodes, AtomProbe::quat_get_rot_quat(), and AtomProbe::quat_rot_apply_quat().

Here is the call graph for this function:

◆ saveGmshMesh()

unsigned int AtomProbe::Mesh::saveGmshMesh ( const char *  meshfile) const

◆ scale() [1/2]

void AtomProbe::Mesh::scale ( const Point3D origin,
float  scaleFactor 
)

Scale the mesh around a specified origin.

Definition at line 1514 of file mesh.cpp.

References nodes.

◆ scale() [2/2]

void AtomProbe::Mesh::scale ( float  scaleFactor)

Scale the mesh around origin.

Definition at line 1525 of file mesh.cpp.

References nodes.

◆ setNode()

void AtomProbe::Mesh::setNode ( unsigned int  index,
Point3D  node 
)

Set the nodes value.

Definition at line 853 of file mesh.cpp.

References nodes.

◆ setTriangleMesh()

void AtomProbe::Mesh::setTriangleMesh ( const std::vector< float > &  ptsA,
const std::vector< float > &  ptsB,
const std::vector< float > &  ptsC 
)

Definition at line 946 of file mesh.cpp.

References ASSERT, clear(), AtomProbe::findNearVerticies(), isSane(), nodes, AtomProbe::TRIANGLE::p, and triangles.

Here is the call graph for this function:

◆ translate() [1/2]

void AtomProbe::Mesh::translate ( )

Translate mesh around node centroid.

Definition at line 1496 of file mesh.cpp.

References nodes.

◆ translate() [2/2]

void AtomProbe::Mesh::translate ( const Point3D origin)

Translate mesh to specified position.

Definition at line 1507 of file mesh.cpp.

References nodes.

Member Data Documentation

◆ lines

std::vector<LINE> AtomProbe::Mesh::lines

Storage for line segments. .size()%2 should always==0.

Definition at line 123 of file mesh.h.

Referenced by clear(), elementCount(), getIntersectingPrimitives(), isSane(), killOrphanNodes(), loadGmshMesh(), mergeDuplicateVertices(), print(), reassignGroups(), and saveGmshMesh().

◆ nodes

std::vector<Point3D> AtomProbe::Mesh::nodes

◆ physGroupNames

std::vector<std::string> AtomProbe::Mesh::physGroupNames

Physical group storage.

Definition at line 113 of file mesh.h.

Referenced by clear().

◆ points

std::vector<unsigned long long> AtomProbe::Mesh::points

◆ tetrahedra

std::vector<TETRAHEDRON> AtomProbe::Mesh::tetrahedra

◆ triangles

std::vector<TRIANGLE> AtomProbe::Mesh::triangles

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