PolyFEM
Loading...
Searching...
No Matches
polyfem::mesh Namespace Reference

Namespaces

namespace  MeshProcessing3D
 
namespace  Navigation
 
namespace  Navigation3D
 
namespace  Polygons
 

Classes

class  ArrayRow
 Contiguous view of one row of a JaggedArray (like std::span). More...
 
struct  CellDescriptor
 Local facets of a standard cell: for each facet, its local vertices, ordered so that the facet normal points outside the cell. More...
 
class  CMesh2D
 Conforming 2D mesh of arbitrary polygons, stored in a PolygonMesh. More...
 
class  CMesh3D
 Conforming 3D mesh of tetrahedra, hexahedra, prisms, pyramids and general polyhedra, stored in a Mesh3DStorage. More...
 
class  GeometryLoader
 Applies geometry JSON semantics while delegating all decoding to MeshLoader. More...
 
class  JaggedArray
 Rows of different lengths stored contiguously (compressed rows): row i is data[offsets[i], offsets[i + 1]). More...
 
class  LoadedGeometry
 
class  LocalBoundary
 Boundary primitive IDs for a single element. More...
 
class  Mesh
 Abstract mesh class to capture 2d/3d conforming and non-conforming meshes. More...
 
class  Mesh2D
 2D mesh interface: the elements are the faces (polygons) and the boundary elements are the edges. More...
 
class  Mesh3D
 3D mesh interface: the elements are the cells (tetrahedra, hexahedra, prisms, pyramids or general polyhedra) and the boundary elements are the faces. More...
 
class  Mesh3DStorage
 Topology of a conforming 3D mesh (used by CMesh3D), stored as flat arrays indexed by entity id. More...
 
struct  Mesh_Quality
 
class  MeshData
 Format-independent input used to construct a runtime Mesh. More...
 
class  MeshLoader
 The only non-legacy decoder from a logical resource path to mesh data. More...
 
class  MeshNodes
 
class  MeshReader
 Stateless format decoders used exclusively by MeshLoader and in-memory adapters. More...
 
struct  MeshWithID
 
class  NCMesh2D
 Non-conforming 2D triangle mesh with hanging nodes, for adaptive h-refinement: refine_element() splits a triangle into 4, and the edges of a refined neighbor become "followers" of the coarse "leader" edge. More...
 
class  NCMesh3D
 Non-conforming 3D tetrahedral mesh with hanging nodes, for adaptive h-refinement: refine_element() splits a tetrahedron into 8, and the edges/faces of a refined neighbor become "followers" of the coarse "leader" edge/face. More...
 
class  Obstacle
 
class  PolygonMesh
 Minimal polygonal surface mesh used as the storage of CMesh2D. More...
 
class  SortedIds
 Set of ids stored as a sorted vector: iterates in increasing order like std::set<int>, but uses a fraction of its memory for the short element lists of the non-conforming meshes. More...
 
struct  StandardCell
 A standard cell referencing global vertex indices. More...
 
class  SurfaceMeshData
 

Typedefs

typedef std::function< void(const Eigen::MatrixXd &, Eigen::MatrixXd &, int)> EvalParametersFunc
 
typedef std::function< std::tuple< int, int, bool >(int, int)> GetAdjacentLocalEdge
 
using SurfaceMesh = SurfaceMeshData
 
template<typename T , int MaxSize>
using InlineVector = Eigen::Matrix< T, Eigen::Dynamic, 1, Eigen::ColMajor, MaxSize, 1 >
 Small vector stored inline (no heap allocation), with the VectorXi / VectorXd API; used for the per-entity data of the non-conforming meshes.
 

Enumerations

enum class  CollisionProxyTessellation { REGULAR , IRREGULAR }
 
enum class  BoundaryType {
  TRI_LINE , QUAD_LINE , PRISM , PYRAMID ,
  TRI , QUAD , POLYGON , POLYHEDRON ,
  INVALID
}
 
enum class  ElementType {
  SIMPLEX = 0 , REGULAR_INTERIOR_CUBE , SIMPLE_SINGULAR_INTERIOR_CUBE , MULTI_SINGULAR_INTERIOR_CUBE ,
  REGULAR_BOUNDARY_CUBE , SIMPLE_SINGULAR_BOUNDARY_CUBE , MULTI_SINGULAR_BOUNDARY_CUBE , INTERFACE_CUBE ,
  INTERIOR_POLYTOPE , BOUNDARY_POLYTOPE , PRISM , PYRAMID ,
  UNDEFINED
}
 Type of Element, check [Poly-Spline Finite Element Method] for a complete description. More...
 
enum class  StandardCellType { TET , HEX , PRISM , PYRAMID }
 Standard volume cell types with a fixed local facet layout. More...
 
enum class  MeshType {
  TRI = 0 , QUA , H_SUR , TET ,
  HYB , HEX
}
 

Functions

void build_collision_proxy (const std::vector< basis::ElementBases > &bases, const std::vector< basis::ElementBases > &geom_bases, const std::vector< LocalBoundary > &total_local_boundary, const int n_bases, const int dim, const double max_edge_length, Eigen::MatrixXd &proxy_vertices, Eigen::MatrixXi &proxy_faces, std::vector< Eigen::Triplet< double > > &displacement_map_entries, const CollisionProxyTessellation tessellation)
 
void build_collision_proxy_displacement_map (const std::vector< basis::ElementBases > &bases, const std::vector< basis::ElementBases > &geom_bases, const std::vector< mesh::LocalBoundary > &total_local_boundary, const int n_bases, const int dim, const Eigen::MatrixXd &proxy_vertices, std::vector< Eigen::Triplet< double > > &displacement_map)
 Build a collision proxy displacement map for a given mesh and proxy mesh.
 
void load_collision_proxy (const io::ResourceIO &resources, const std::string &mesh_filename, const std::string &weights_filename, const Eigen::VectorXi &in_node_to_node, const json &transformation, Eigen::MatrixXd &vertices, Eigen::VectorXi &codim_vertices, Eigen::MatrixXi &edges, Eigen::MatrixXi &faces, std::vector< Eigen::Triplet< double > > &displacement_map_entries)
 Load a collision proxy mesh and displacement map from resources.
 
void load_collision_proxy_mesh (const io::ResourceIO &resources, const std::string &mesh_filename, const json &transformation, Eigen::MatrixXd &vertices, Eigen::VectorXi &codim_vertices, Eigen::MatrixXi &edges, Eigen::MatrixXi &faces)
 Load a collision proxy mesh from a resource.
 
void load_collision_proxy_displacement_map (const io::ResourceIO &resources, const std::string &weights_filename, const Eigen::VectorXi &in_node_to_node, const size_t num_proxy_vertices, std::vector< Eigen::Triplet< double > > &displacement_map_entries)
 Load a collision proxy displacement map from a resource.
 
 NLOHMANN_JSON_SERIALIZE_ENUM (CollisionProxyTessellation, {{CollisionProxyTessellation::REGULAR, "regular"}, {CollisionProxyTessellation::IRREGULAR, "irregular"}})
 
void build_collision_proxy (const std::vector< basis::ElementBases > &bases, const std::vector< basis::ElementBases > &geom_bases, const std::vector< mesh::LocalBoundary > &total_local_boundary, const int n_bases, const int dim, const double max_edge_length, Eigen::MatrixXd &proxy_vertices, Eigen::MatrixXi &proxy_faces, std::vector< Eigen::Triplet< double > > &displacement_map, const CollisionProxyTessellation tessellation=CollisionProxyTessellation::REGULAR)
 Build a collision proxy mesh by upsampling a given mesh.
 
void stitch_mesh (const Eigen::MatrixXd &V, const Eigen::MatrixXi &F, Eigen::MatrixXd &V_out, Eigen::MatrixXi &F_out, const double epsilon=1e-5)
 Stitch a triangle mesh (V, F) together by removing duplicate vertices.
 
void stitch_mesh (const Eigen::MatrixXd &V, const Eigen::MatrixXi &F, const std::vector< Eigen::Triplet< double > > &W, Eigen::MatrixXd &V_out, Eigen::MatrixXi &F_out, std::vector< Eigen::Triplet< double > > &W_out, const double epsilon=1e-5)
 Stitch a triangle mesh (V, F) together by removing duplicate vertices.
 
double max_edge_length (const Eigen::MatrixXd &V, const Eigen::MatrixXi &F)
 Compute the maximum edge length of a triangle mesh (V, F)
 
void regular_grid_triangle_barycentric_coordinates (const int n, Eigen::MatrixXd &V, Eigen::MatrixXi &F)
 Compute the barycentric coordinates of a regular grid of triangles.
 
void regular_grid_tessellation (const Eigen::MatrixXd &V, const Eigen::MatrixXi &F, const double max_edge_length, Eigen::MatrixXd &V_out, Eigen::MatrixXi &F_out)
 Tessilate a triangle mesh (V, F) with regular grids of triangles of maximum edge length.
 
Eigen::MatrixXd refine_edge (const VectorNd &a, const VectorNd &b, const double max_edge_length)
 Refine an edge (a, b) so each refined edge has length at most max_edge_length.
 
void refine_triangle_edges (const VectorNd &a, const VectorNd &b, const VectorNd &c, const double max_edge_len, Eigen::MatrixXd &V, Eigen::MatrixXi &E)
 Refine the edges of a triangle (a, b, c) so each refined edge has length at most max_edge_length.
 
void irregular_triangle (const Eigen::Vector3d &a, const Eigen::Vector3d &b, const Eigen::Vector3d &c, const double max_edge_length, Eigen::MatrixXd &V, Eigen::MatrixXi &F)
 Refine a triangle (a, b, c) into a well shaped triangle mesh.
 
void irregular_triangle_barycentric_coordinates (const Eigen::Vector3d &a, const Eigen::Vector3d &b, const Eigen::Vector3d &c, const double max_edge_length, Eigen::MatrixXd &UV, Eigen::MatrixXi &F)
 Refine a triangle (a, b, c) into a well shaped triangle mesh.
 
void irregular_tessellation (const Eigen::MatrixXd &V, const Eigen::MatrixXi &F, const double max_edge_length, Eigen::MatrixXd &V_out, Eigen::MatrixXi &F_out)
 Tessilate a triangle mesh (V, F) with well shaped triangles.
 
std::ostream & operator<< (std::ostream &os, const LocalBoundary &lb)
 
int find (const Eigen::VectorXi &vec, int x)
 
double line_weight (const Eigen::Matrix< double, 2, 2 > &e, const InlineVector< double, 3 > &v)
 
void clip_polygon_by_half_plane (const Eigen::MatrixXd &P, const Eigen::RowVector2d &q1, const Eigen::RowVector2d &q2, Eigen::MatrixXd &result)
 Clip a polygon by a half-plane.
 
void compute_visibility_kernel (const Eigen::MatrixXd &IV, Eigen::MatrixXd &OV)
 Determine the kernel of the given polygon.
 
bool is_star_shaped (const Eigen::MatrixXd &IV, Eigen::RowVector3d &bary)
 Determine whether a polygon is star-shaped or not.
 
void offset_polygon (const Eigen::MatrixXd &IV, Eigen::MatrixXd &OV, double eps)
 Compute offset polygon.
 
int is_inside (const Eigen::MatrixXd &IV, const Eigen::MatrixXd &Q, std::vector< bool > &inside)
 Compute whether points are inside a polygon.
 
void sample_polygon (const Eigen::MatrixXd &IV, int num_samples, Eigen::MatrixXd &S)
 Sample equal-arclength interval midpoints, starting at the lexicographically smallest polygon vertex.
 
void edge_adjacency_graph (const Eigen::MatrixXi &Q, Eigen::MatrixXi &edge_index, std::vector< std::vector< int > > &adj, std::vector< std::pair< int, int > > *pairs_of_edges=nullptr, std::vector< std::pair< int, int > > *pairs_of_quads=nullptr, Eigen::MatrixXi *quad_index=nullptr)
 
bool instantiate_pattern (const Eigen::MatrixXd &IV, const Eigen::MatrixXi &IF, const Eigen::MatrixXd &PV, const Eigen::MatrixXi &PF, Eigen::MatrixXd &OV, Eigen::MatrixXi &OF, Eigen::VectorXi *SF=nullptr, EvalParametersFunc evalFunc=nullptr, GetAdjacentLocalEdge getAdjLocalEdge=nullptr)
 
void refine_quad_mesh (const Eigen::MatrixXd &IV, const Eigen::MatrixXi &IF, Eigen::MatrixXd &OV, Eigen::MatrixXi &OF)
 
void refine_polygonal_mesh (const PolygonMesh &M_in, PolygonMesh &M_out, Polygons::SplitFunction split_func)
 Refine a polygonal mesh.
 
void refine_triangle_mesh (const PolygonMesh &M_in, PolygonMesh &M_out)
 Refine a triangle mesh.
 
void refine_polygonal_mesh (const PolygonMesh &M_in, PolygonMesh &M_out, bool refine_polygons=false, double t=0.5)
 
const CellDescriptor & cell_descriptor (StandardCellType type)
 Local vertex and facet conventions of each cell type.
 
std::vector< std::array< int, 6 > > connect_cells (const std::vector< StandardCell > &cells, int n_vertices)
 Computes cell-to-cell adjacency across facets.
 
PolygonMesh::Point mesh_vertex (const PolygonMesh &M, int v)
 Retrieve a 3D vector with the position of a given vertex.
 
PolygonMesh::Point facet_barycenter (const PolygonMesh &M, int f)
 
int mesh_create_vertex (PolygonMesh &M, const PolygonMesh::Point &p)
 
void compute_element_tags (const PolygonMesh &M, std::vector< ElementType > &element_tags)
 Compute the type of each facet in a surface mesh.
 
void orient_normals_2d (PolygonMesh &M)
 Orient facets of a 2D mesh so that each connected component has positive volume.
 
void reorder_mesh (Eigen::MatrixXd &V, Eigen::MatrixXi &F, const Eigen::VectorXi &C, Eigen::VectorXi &R)
 Reorder vertices of a mesh using color tags, so that vertices are ordered by increasing colors.
 
void offset_surface_vertices (const Eigen::MatrixXd &V, const Eigen::MatrixXi &F, const Eigen::RowVector3d &interior_point, double distance, Eigen::MatrixXd &offset)
 Offset along area-weighted surface normals, using the direction away from an interior point where incident normals cancel.
 
void signed_squared_distances (const Eigen::MatrixXd &V, const Eigen::MatrixXi &F, const Eigen::MatrixXd &P, Eigen::VectorXd &D)
 Computes the signed squared distance from a list of points to a triangle mesh.
 
double signed_volume (const Eigen::MatrixXd &V, const Eigen::MatrixXi &F)
 Compute the signed volume of a surface mesh.
 
void orient_closed_surface (const Eigen::MatrixXd &V, Eigen::MatrixXi &F, bool positive=true)
 Orient a triangulated surface to have positive volume.
 
std::vector< std::pair< Navigation::Index, Navigation::Index > > compute_mesh_interface (const Mesh2D &first, const Mesh2D &second)
 Pair coincident boundary edges, including nonconforming leader/follower edges.
 
std::vector< std::pair< Navigation3D::Index, Navigation3D::Index > > compute_mesh_interface (const Mesh3D &first, const Mesh3D &second)
 Pair coincident boundary faces, including nonconforming leader/follower faces.
 
void extract_parent_edges (const Eigen::MatrixXd &IV, const Eigen::MatrixXi &IE, const Eigen::MatrixXd &BV, const Eigen::MatrixXi &BE, Eigen::MatrixXi &OE)
 Extract a set of edges that are overlap with a set given set of parent edges, using vertices positions to discriminate.
 
void find_triangle_surface_from_tets (const Eigen::MatrixXi &tets, Eigen::MatrixXi &faces)
 Boundary triangles of a tet mesh, indexing the tets' vertices.
 
void extract_triangle_surface_from_tets (const Eigen::MatrixXd &vertices, const Eigen::MatrixXi &tets, Eigen::MatrixXd &surface_vertices, Eigen::MatrixXi &tris)
 Extract triangular surface from a tetmesh.
 
bool is_planar (const Eigen::MatrixXd &V, const double tol=1e-5)
 Determine if the given V x (2|3) vertices are planar (2D or z-range below tol).
 
int count_faces (const int dim, const Eigen::MatrixXi &cells)
 Count the number of boundary elements (triangles for tetmesh and edges for triangle mesh)
 
void generate_edges (PolygonMesh &M)
 Creates the edges of M (sorted by vertex pair) if it has none yet.
 
double point_triangle_squared_distance (const double *p, const double *v0, const double *v1, const double *v2)
 Squared distance between a point and a triangle.
 
bool apply_slim (const Eigen::MatrixXd &V, const Eigen::MatrixXi &F, const Eigen::MatrixXd &V_new, Eigen::MatrixXd &V_smooth, const int max_iters)
 

Variables

constexpr long MESH_SCHEMA_VERSION = 1
 The canonical typed mesh schema shared by HDF5 bundles and checkpoints.
 

Typedef Documentation

◆ EvalParametersFunc

typedef std::function<void(const Eigen::MatrixXd &, Eigen::MatrixXd &, int)> polyfem::mesh::EvalParametersFunc

Definition at line 30 of file Refinement.hpp.

◆ GetAdjacentLocalEdge

typedef std::function<std::tuple<int, int, bool>(int, int)> polyfem::mesh::GetAdjacentLocalEdge

Definition at line 31 of file Refinement.hpp.

◆ InlineVector

template<typename T , int MaxSize>
using polyfem::mesh::InlineVector = typedef Eigen::Matrix<T, Eigen::Dynamic, 1, Eigen::ColMajor, MaxSize, 1>

Small vector stored inline (no heap allocation), with the VectorXi / VectorXd API; used for the per-entity data of the non-conforming meshes.

Definition at line 13 of file NCMeshStorage.hpp.

◆ SurfaceMesh

Definition at line 12 of file MeshLoader.hpp.

Enumeration Type Documentation

◆ BoundaryType

enum class polyfem::mesh::BoundaryType
strong
Enumerator
TRI_LINE 

Boundary of a triangle in 2D.

QUAD_LINE 

Boundary of a quad in 2D.

PRISM 
PYRAMID 
TRI 
QUAD 
POLYGON 
POLYHEDRON 
INVALID 

Definition at line 12 of file LocalBoundary.hpp.

◆ CollisionProxyTessellation

Enumerator
REGULAR 

Regular tessellation of the mesh.

IRREGULAR 

Irregular tessellation of the mesh (requires POLYFEM_WITH_TRIANGLE)

Definition at line 17 of file CollisionProxy.hpp.

◆ ElementType

enum class polyfem::mesh::ElementType
strong

Type of Element, check [Poly-Spline Finite Element Method] for a complete description.

NOTE: For the purpose of the tagging, elements (facets in 2D, cells in 3D) adjacent to a polytope are tagged as boundary, and vertices incident to a polytope are also considered as boundary.

Enumerator
SIMPLEX 
REGULAR_INTERIOR_CUBE 

Triangle/tet element.

SIMPLE_SINGULAR_INTERIOR_CUBE 

Regular quad/hex inside a 3^n patch.

MULTI_SINGULAR_INTERIOR_CUBE 

Quad/hex incident to exactly 1 singular vertex (in 2D) or edge (in 3D)

REGULAR_BOUNDARY_CUBE 

Quad/Hex incident to more than 1 singular vertices (should not happen in 2D)

SIMPLE_SINGULAR_BOUNDARY_CUBE 

Boundary quad/hex, where all boundary vertices/edges are incident to at most 2 quads/hexes.

MULTI_SINGULAR_BOUNDARY_CUBE 

Quad incident to exactly 1 singular vertex (in 2D); hex incident to exactly 1 singular interior edge, 0 singular boundary edge, 1 boundary face (in 3D)

INTERFACE_CUBE 

Boundary hex that is not regular nor SimpleSingularBoundaryCube.

INTERIOR_POLYTOPE 

Quad/hex that is at the interface with a polytope (if a cube has both external boundary and and interface with a polytope, it is marked as interface)

BOUNDARY_POLYTOPE 

Interior polytope.

PRISM 

Boundary polytope.

PYRAMID 

Prism.

UNDEFINED 

Pyramid.

Definition at line 30 of file Mesh.hpp.

◆ MeshType

enum class polyfem::mesh::MeshType
strong
Enumerator
TRI 
QUA 
H_SUR 
TET 
HYB 
HEX 

Definition at line 137 of file Mesh3DStorage.hpp.

◆ StandardCellType

Standard volume cell types with a fixed local facet layout.

Enumerator
TET 
HEX 
PRISM 
PYRAMID 

Definition at line 9 of file CellConnectivity.hpp.

Function Documentation

◆ apply_slim()

bool polyfem::mesh::apply_slim ( const Eigen::MatrixXd &  V,
const Eigen::MatrixXi &  F,
const Eigen::MatrixXd &  V_new,
Eigen::MatrixXd &  V_smooth,
const int  max_iters 
)

Definition at line 11 of file SlimSmooth.cpp.

References polyfem::adjoint_logger(), polyfem::F, polyfem::utils::is_flipped(), polyfem::logger(), and V.

Referenced by polyfem::solver::AdjointNLProblem::after_line_search_custom_operation(), and polyfem::solver::AdjointNLProblem::is_step_valid().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ build_collision_proxy() [1/2]

void polyfem::mesh::build_collision_proxy ( const std::vector< basis::ElementBases > &  bases,
const std::vector< basis::ElementBases > &  geom_bases,
const std::vector< LocalBoundary > &  total_local_boundary,
const int  n_bases,
const int  dim,
const double  max_edge_length,
Eigen::MatrixXd &  proxy_vertices,
Eigen::MatrixXi &  proxy_faces,
std::vector< Eigen::Triplet< double > > &  displacement_map_entries,
const CollisionProxyTessellation  tessellation 
)

Definition at line 75 of file CollisionProxy.cpp.

References polyfem::basis::ElementBases::bases, IRREGULAR, irregular_triangle_barycentric_coordinates(), polyfem::log_and_throw_error(), max_edge_length(), REGULAR, regular_grid_triangle_barycentric_coordinates(), stitch_mesh(), TRI, and x.

Referenced by polyfem::varform::NonlinearElasticVarForm::build_collision_mesh().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ build_collision_proxy() [2/2]

void polyfem::mesh::build_collision_proxy ( const std::vector< basis::ElementBases > &  bases,
const std::vector< basis::ElementBases > &  geom_bases,
const std::vector< mesh::LocalBoundary > &  total_local_boundary,
const int  n_bases,
const int  dim,
const double  max_edge_length,
Eigen::MatrixXd &  proxy_vertices,
Eigen::MatrixXi &  proxy_faces,
std::vector< Eigen::Triplet< double > > &  displacement_map,
const CollisionProxyTessellation  tessellation = CollisionProxyTessellation::REGULAR 
)

Build a collision proxy mesh by upsampling a given mesh.

Parameters
[in]basesBases for elements
[in]geom_basesGeometry bases for elements
[in]total_local_boundaryLocal boundaries for elements
[in]n_basesNumber of bases (nodes)
[in]dimDimension of the mesh
[in]max_edge_lengthMaximum edge length of the proxy mesh
[out]proxy_verticesOutput vertices of the proxy mesh
[out]proxy_facesOutput faces of the proxy mesh
[out]displacement_mapOutput displacement map from proxy mesh to original mesh
[in]tessellationType of tessellation to use

◆ build_collision_proxy_displacement_map()

void polyfem::mesh::build_collision_proxy_displacement_map ( const std::vector< basis::ElementBases > &  bases,
const std::vector< basis::ElementBases > &  geom_bases,
const std::vector< mesh::LocalBoundary > &  total_local_boundary,
const int  n_bases,
const int  dim,
const Eigen::MatrixXd &  proxy_vertices,
std::vector< Eigen::Triplet< double > > &  displacement_map 
)

Build a collision proxy displacement map for a given mesh and proxy mesh.

Parameters
[in]basesBases for elements
[in]geom_basesGeometry bases for elements
[in]total_local_boundaryLocal boundaries for elements
[in]n_basesNumber of bases (nodes)
[in]dimDimension of the mesh
[in]proxy_verticesVertices of the proxy mesh
[out]displacement_mapOutput displacement map from proxy mesh to original mesh

Definition at line 170 of file CollisionProxy.cpp.

References polyfem::log_and_throw_error().

Here is the call graph for this function:

◆ cell_descriptor()

const CellDescriptor & polyfem::mesh::cell_descriptor ( StandardCellType  type)

Local vertex and facet conventions of each cell type.

These are the conventions of geogram's MeshCellDescriptors, which PolyFEM used to build its volume meshes (local vertex order of hexes, facet order and facet vertex order all follow them).

Definition at line 187 of file CellConnectivity.cpp.

References HEX, PRISM, PYRAMID, and TET.

◆ clip_polygon_by_half_plane()

void polyfem::mesh::clip_polygon_by_half_plane ( const Eigen::MatrixXd &  P,
const Eigen::RowVector2d &  q1,
const Eigen::RowVector2d &  q2,
Eigen::MatrixXd &  result 
)

Clip a polygon by a half-plane.

https://github.com/alicevision/geogram/blob/cfbc0a5827d71d59f8bcf0369cc1731ef12f82ef/src/examples/graphics/demo_Delaunay2d/main.cpp#L677

Parameters
[in]PInput polygon
[in]q1First endpoint of the clipping line
[in]q2Second endpoint of the clipping line
[out]resultClipped polygon

Definition at line 61 of file PolygonUtils.cpp.

Referenced by compute_visibility_kernel().

Here is the caller graph for this function:

◆ compute_element_tags()

void polyfem::mesh::compute_element_tags ( const PolygonMesh &  M,
std::vector< ElementType > &  element_tags 
)

Compute the type of each facet in a surface mesh.

Parameters
[in]MInput surface mesh (with boundary flags, see Navigation::prepare_mesh)
[out]element_tagsTypes of each facet element

Definition at line 65 of file MeshUtils.cpp.

Referenced by polyfem::mesh::CMesh2D::compute_elements_tag(), and polyfem::mesh::CMesh2D::update_elements_tag().

Here is the caller graph for this function:

◆ compute_mesh_interface() [1/2]

std::vector< std::pair< polyfem::mesh::Navigation::Index, polyfem::mesh::Navigation::Index > > polyfem::mesh::compute_mesh_interface ( const Mesh2D &  first,
const Mesh2D &  second 
)

Pair coincident boundary edges, including nonconforming leader/follower edges.

Definition at line 949 of file MeshUtils.cpp.

References polyfem::mesh::Mesh2D::get_index_from_face(), polyfem::mesh::Mesh::is_boundary_edge(), polyfem::mesh::Mesh::n_face_vertices(), polyfem::mesh::Mesh::n_faces(), polyfem::mesh::Mesh2D::next_around_face(), polyfem::mesh::Mesh::point(), and polyfem::mesh::Mesh2D::switch_vertex().

Referenced by polyfem::varform::NavierStokesFSIVarForm::load_mesh().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ compute_mesh_interface() [2/2]

std::vector< std::pair< polyfem::mesh::Navigation3D::Index, polyfem::mesh::Navigation3D::Index > > polyfem::mesh::compute_mesh_interface ( const Mesh3D &  first,
const Mesh3D &  second 
)

Pair coincident boundary faces, including nonconforming leader/follower faces.

Definition at line 995 of file MeshUtils.cpp.

References polyfem::mesh::Mesh3D::cell_face(), polyfem::mesh::Mesh::face_vertex(), faces, polyfem::mesh::Mesh3D::get_index_from_element(), polyfem::mesh::Mesh::is_boundary_face(), polyfem::mesh::Mesh3D::n_cell_faces(), polyfem::mesh::Mesh::n_cells(), polyfem::mesh::Mesh::n_face_vertices(), polyfem::mesh::Mesh3D::next_around_face(), and polyfem::mesh::Mesh::point().

Here is the call graph for this function:

◆ compute_visibility_kernel()

void polyfem::mesh::compute_visibility_kernel ( const Eigen::MatrixXd &  IV,
Eigen::MatrixXd &  OV 
)

Determine the kernel of the given polygon.

Parameters
[in]IV#IV x (2|3) vertex positions around the input polygon
[out]OV#OV x (2|3) vertex positions around the output polygon

Definition at line 130 of file PolygonUtils.cpp.

References clip_polygon_by_half_plane().

Referenced by is_star_shaped().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ connect_cells()

std::vector< std::array< int, 6 > > polyfem::mesh::connect_cells ( const std::vector< StandardCell > &  cells,
int  n_vertices 
)

Computes cell-to-cell adjacency across facets.

Two cell facets are glued when they have the same vertices in opposite orientation. The traversal order (and therefore the choice made for non-manifold facets) reproduces geogram's MeshCells::connect(): tet meshes chain tet corners around vertices, other meshes chain cells around vertices, and candidates are visited from the most recently created cell to the oldest one.

A quadrilateral boundary facet glued to two or more triangular facets (a non-conforming quad/triangle interface) is rejected: geogram used to insert artificial "connector" cells there, which PolyFEM cannot use.

Parameters
[in]cellsInput cells
[in]n_verticesNumber of vertices referenced by the cells
Returns
For each cell and local facet, the adjacent cell or -1.

Definition at line 204 of file CellConnectivity.cpp.

References polyfem::mesh::StandardCell::facet_vertex(), HEX, polyfem::log_and_throw_error(), and TET.

Referenced by polyfem::mesh::CMesh3D::build_storage_from_cells().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ count_faces()

int polyfem::mesh::count_faces ( const int  dim,
const Eigen::MatrixXi &  cells 
)

Count the number of boundary elements (triangles for tetmesh and edges for triangle mesh)

Definition at line 1170 of file MeshUtils.cpp.

◆ edge_adjacency_graph()

void polyfem::mesh::edge_adjacency_graph ( const Eigen::MatrixXi &  Q,
Eigen::MatrixXi &  edge_index,
std::vector< std::vector< int > > &  adj,
std::vector< std::pair< int, int > > *  pairs_of_edges = nullptr,
std::vector< std::pair< int, int > > *  pairs_of_quads = nullptr,
Eigen::MatrixXi *  quad_index = nullptr 
)

Definition at line 16 of file Refinement.cpp.

References adj, x, and y.

Referenced by instantiate_pattern().

Here is the caller graph for this function:

◆ extract_parent_edges()

void polyfem::mesh::extract_parent_edges ( const Eigen::MatrixXd &  IV,
const Eigen::MatrixXi &  IE,
const Eigen::MatrixXd &  BV,
const Eigen::MatrixXi &  BE,
Eigen::MatrixXi &  OE 
)

Extract a set of edges that are overlap with a set given set of parent edges, using vertices positions to discriminate.

Parameters
[in]IV#IV x 3 input vertices positions
[in]IE#IE x 2 input edge indices
[in]BV#BV x 3 base vertices positions to test against
[in]BE#BE x 2 base edge indices to test against
[out]OE#OE x 2 output extracted edges

Definition at line 1057 of file MeshUtils.cpp.

Referenced by polyfem::utils::RefElementSampler::build().

Here is the caller graph for this function:

◆ extract_triangle_surface_from_tets()

void polyfem::mesh::extract_triangle_surface_from_tets ( const Eigen::MatrixXd &  vertices,
const Eigen::MatrixXi &  tets,
Eigen::MatrixXd &  surface_vertices,
Eigen::MatrixXi &  tris 
)

Extract triangular surface from a tetmesh.

Parameters
[in]v,tetstet mesh
[out]s_v,tris{ surface mesh }

Definition at line 1131 of file MeshUtils.cpp.

References find_triangle_surface_from_tets().

Referenced by polyfem::mesh::MeshReader::read_msh_surface().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ facet_barycenter()

polyfem::mesh::PolygonMesh::Point polyfem::mesh::facet_barycenter ( const PolygonMesh &  M,
int  f 
)

Definition at line 46 of file MeshUtils.cpp.

References mesh_vertex().

Referenced by refine_polygonal_mesh().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ find()

int polyfem::mesh::find ( const Eigen::VectorXi &  vec,
int  x 
)

Definition at line 369 of file NCMesh2D.cpp.

References vec, and x.

Referenced by polyfem::mesh::NCMesh2D::build_element_vertex_adjacency(), polyfem::mesh::Navigation3D::get_index_from_element_face(), polyfem::io::ResourceIO::glob(), polyfem::mesh::MeshProcessing3D::refine_catmul_clark_polar(), and polyfem::mesh::NCMesh2D::switch_edge().

Here is the caller graph for this function:

◆ find_triangle_surface_from_tets()

void polyfem::mesh::find_triangle_surface_from_tets ( const Eigen::MatrixXi &  tets,
Eigen::MatrixXi &  faces 
)

Boundary triangles of a tet mesh, indexing the tets' vertices.

Parameters
[in]tets#T x 4 tet indices
[out]facesF x 3 boundary triangle indices

Definition at line 1097 of file MeshUtils.cpp.

References faces.

Referenced by extract_triangle_surface_from_tets(), and polyfem::mesh::MeshReader::read_msh_surface().

Here is the caller graph for this function:

◆ generate_edges()

void polyfem::mesh::generate_edges ( PolygonMesh &  M)

Creates the edges of M (sorted by vertex pair) if it has none yet.

Parameters
[in/out]M mesh to append edges to

Definition at line 1220 of file MeshUtils.cpp.

Referenced by polyfem::mesh::CMesh2D::refine().

Here is the caller graph for this function:

◆ instantiate_pattern()

bool polyfem::mesh::instantiate_pattern ( const Eigen::MatrixXd &  IV,
const Eigen::MatrixXi &  IF,
const Eigen::MatrixXd &  PV,
const Eigen::MatrixXi &  PF,
Eigen::MatrixXd &  OV,
Eigen::MatrixXi &  OF,
Eigen::VectorXi *  SF = nullptr,
EvalParametersFunc  evalFunc = nullptr,
GetAdjacentLocalEdge  getAdjLocalEdge = nullptr 
)

Definition at line 276 of file Refinement.cpp.

References adj, edge_adjacency_graph(), polyfem::F, polyfem::logger(), V, x, and y.

Referenced by refine_quad_mesh().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ irregular_tessellation()

void polyfem::mesh::irregular_tessellation ( const Eigen::MatrixXd &  V,
const Eigen::MatrixXi &  F,
const double  max_edge_length,
Eigen::MatrixXd &  V_out,
Eigen::MatrixXi &  F_out 
)

Tessilate a triangle mesh (V, F) with well shaped triangles.

Note
Uses Triangle to perform the refinement (requires POLYFEM_WITH_TRIANGLE).
Parameters
Vvertices
Ftriangular faces
max_edge_lengthmaximum edge length
V_outtessilated vertices
F_outtessilated faces

Definition at line 288 of file UpsampleMesh.cpp.

References polyfem::F, irregular_triangle(), max_edge_length(), stitch_mesh(), and V.

Here is the call graph for this function:

◆ irregular_triangle()

void polyfem::mesh::irregular_triangle ( const Eigen::Vector3d &  a,
const Eigen::Vector3d &  b,
const Eigen::Vector3d &  c,
const double  max_edge_length,
Eigen::MatrixXd &  V,
Eigen::MatrixXi &  F 
)

Refine a triangle (a, b, c) into a well shaped triangle mesh.

Note
Uses Triangle to perform the refinement (requires POLYFEM_WITH_TRIANGLE).
Parameters
afirst vertex of the triangle
bsecond vertex of the triangle
cthird vertex of the triangle
max_edge_lenmaximum edge length of the refined triangle mesh
Vvertices of the refined triangle
Ffaces of the refined triangle

Definition at line 217 of file UpsampleMesh.cpp.

References polyfem::assembler::cross(), polyfem::F, polyfem::log_and_throw_error(), max_edge_length(), refine_triangle_edges(), polyfem::utils::triangle_area(), V, and z.

Referenced by irregular_tessellation(), and irregular_triangle_barycentric_coordinates().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ irregular_triangle_barycentric_coordinates()

void polyfem::mesh::irregular_triangle_barycentric_coordinates ( const Eigen::Vector3d &  a,
const Eigen::Vector3d &  b,
const Eigen::Vector3d &  c,
const double  max_edge_length,
Eigen::MatrixXd &  UV,
Eigen::MatrixXi &  F 
)

Refine a triangle (a, b, c) into a well shaped triangle mesh.

Note
Uses Triangle to perform the refinement (requires POLYFEM_WITH_TRIANGLE).
Parameters
afirst vertex of the triangle
bsecond vertex of the triangle
cthird vertex of the triangle
max_edge_lenmaximum edge length of the refined triangle mesh
UVbarycentric coordinates of the refined triangle
Ffaces of the refined triangle

Definition at line 266 of file UpsampleMesh.cpp.

References polyfem::F, irregular_triangle(), max_edge_length(), and V.

Referenced by build_collision_proxy().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ is_inside()

int polyfem::mesh::is_inside ( const Eigen::MatrixXd &  IV,
const Eigen::MatrixXd &  Q,
std::vector< bool > &  inside 
)

Compute whether points are inside a polygon.

Parameters
[in]IV#IV x 2 of vertex positions for the input polygon
[in]Q#Q x 2 of query point positions
[out]insideWhether the i-th query point is inside or not
Returns
Number of points inside

Definition at line 256 of file PolygonUtils.cpp.

◆ is_planar()

bool polyfem::mesh::is_planar ( const Eigen::MatrixXd &  V,
const double  tol = 1e-5 
)

Determine if the given V x (2|3) vertices are planar (2D or z-range below tol).

Definition at line 26 of file MeshUtils.cpp.

References V.

◆ is_star_shaped()

bool polyfem::mesh::is_star_shaped ( const Eigen::MatrixXd &  IV,
Eigen::RowVector3d &  bary 
)

Determine whether a polygon is star-shaped or not.

Parameters
[in]IV#IV x (2|3) of vertex positions around the polygon
[out]baryArea centroid of the kernel, or vertex mean for a degenerate kernel
Returns
True if star shaped, False otherwise.

Definition at line 158 of file PolygonUtils.cpp.

References compute_visibility_kernel(), and polyfem::assembler::cross().

Referenced by polyfem::mesh::Polygons::catmul_clark_split(), and polyfem::mesh::Polygons::polar_split().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ line_weight()

double polyfem::mesh::line_weight ( const Eigen::Matrix< double, 2, 2 > &  e,
const InlineVector< double, 3 > &  v 
)

Definition at line 444 of file NCMesh2D.cpp.

Referenced by polyfem::mesh::NCMesh2D::build_element_vertex_adjacency().

Here is the caller graph for this function:

◆ load_collision_proxy()

void polyfem::mesh::load_collision_proxy ( const io::ResourceIO &  resources,
const std::string &  mesh_filename,
const std::string &  weights_filename,
const Eigen::VectorXi &  in_node_to_node,
const json &  transformation,
Eigen::MatrixXd &  vertices,
Eigen::VectorXi &  codim_vertices,
Eigen::MatrixXi &  edges,
Eigen::MatrixXi &  faces,
std::vector< Eigen::Triplet< double > > &  displacement_map_entries 
)

Load a collision proxy mesh and displacement map from resources.

Parameters
[in]mesh_filenameMesh resource path
[in]weights_filenameWeights resource path
[in]in_node_to_nodeMap from input node IDs to node IDs
[in]transformationTransformation to apply to the mesh
[out]verticesOutput vertices of the proxy mesh
[out]codim_verticesOutput codimension vertices of the proxy mesh
[out]edgesOutput edges of the proxy mesh
[out]facesOutput faces of the proxy mesh
[out]displacement_map_entriesOutput displacement map entries

Definition at line 320 of file CollisionProxy.cpp.

References faces, load_collision_proxy(), load_collision_proxy_displacement_map(), and load_collision_proxy_mesh().

Referenced by polyfem::varform::NonlinearElasticVarForm::build_collision_mesh(), and load_collision_proxy().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ load_collision_proxy_displacement_map()

void polyfem::mesh::load_collision_proxy_displacement_map ( const io::ResourceIO &  resources,
const std::string &  weights_filename,
const Eigen::VectorXi &  in_node_to_node,
const size_t  num_proxy_vertices,
std::vector< Eigen::Triplet< double > > &  displacement_map_entries 
)

Load a collision proxy displacement map from a resource.

Parameters
[in]weights_filenameWeights resource path
[in]in_node_to_nodeMap from input node IDs to node IDs
[out]displacement_map_entriesOutput displacement map entries

Definition at line 378 of file CollisionProxy.cpp.

References polyfem::io::ResourceIO::is_group(), load_collision_proxy_displacement_map(), polyfem::log_and_throw_error(), polyfem::io::ResourceIO::materialize(), polyfem::io::ResourceIO::read_double_vector(), polyfem::io::ResourceIO::read_int_vector(), polyfem::io::ResourceIO::read_shape_attribute(), and weights.

Referenced by load_collision_proxy(), and load_collision_proxy_displacement_map().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ load_collision_proxy_mesh()

void polyfem::mesh::load_collision_proxy_mesh ( const io::ResourceIO &  resources,
const std::string &  mesh_filename,
const json &  transformation,
Eigen::MatrixXd &  vertices,
Eigen::VectorXi &  codim_vertices,
Eigen::MatrixXi &  edges,
Eigen::MatrixXi &  faces 
)

Load a collision proxy mesh from a resource.

Parameters
[in]mesh_filenameMesh resource path
[in]transformationTransformation to apply to the mesh
[out]verticesOutput vertices of the proxy mesh
[out]codim_verticesOutput codimension vertices of the proxy mesh
[out]edgesOutput edges of the proxy mesh
[out]facesOutput faces of the proxy mesh

Definition at line 336 of file CollisionProxy.cpp.

References polyfem::mesh::SurfaceMeshData::edges, faces, polyfem::mesh::SurfaceMeshData::faces, load_collision_proxy_mesh(), polyfem::mesh::MeshLoader::load_surface(), polyfem::mesh::SurfaceMeshData::points, and polyfem::mesh::SurfaceMeshData::vertices.

Referenced by load_collision_proxy(), and load_collision_proxy_mesh().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ max_edge_length()

double polyfem::mesh::max_edge_length ( const Eigen::MatrixXd &  V,
const Eigen::MatrixXi &  F 
)

Compute the maximum edge length of a triangle mesh (V, F)

Parameters
Vvertices
Ftriangular faces

Definition at line 87 of file UpsampleMesh.cpp.

References polyfem::F, max_edge_length(), and V.

Referenced by build_collision_proxy(), irregular_tessellation(), irregular_triangle(), irregular_triangle_barycentric_coordinates(), max_edge_length(), refine_edge(), and regular_grid_tessellation().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ mesh_create_vertex()

int polyfem::mesh::mesh_create_vertex ( PolygonMesh &  M,
const PolygonMesh::Point &  p 
)

Definition at line 58 of file MeshUtils.cpp.

Referenced by refine_polygonal_mesh(), and refine_triangle_mesh().

Here is the caller graph for this function:

◆ mesh_vertex()

polyfem::mesh::PolygonMesh::Point polyfem::mesh::mesh_vertex ( const PolygonMesh &  M,
int  v 
)

Retrieve a 3D vector with the position of a given vertex.

Parameters
[in]MInput mesh
[in]vVertex index whose position to retrieve
Returns
Position of the given vertex in 3D

Definition at line 39 of file MeshUtils.cpp.

Referenced by facet_barycenter(), refine_polygonal_mesh(), and refine_triangle_mesh().

Here is the caller graph for this function:

◆ NLOHMANN_JSON_SERIALIZE_ENUM()

polyfem::mesh::NLOHMANN_JSON_SERIALIZE_ENUM ( CollisionProxyTessellation  ,
{{CollisionProxyTessellation::REGULAR, "regular"}, {CollisionProxyTessellation::IRREGULAR, "irregular"}}   
)

References IRREGULAR, and REGULAR.

◆ offset_polygon()

void polyfem::mesh::offset_polygon ( const Eigen::MatrixXd &  IV,
Eigen::MatrixXd &  OV,
double  eps 
)

Compute offset polygon.

Parameters
[in]IV#IV x 2 of vertex positions for the input polygon
[out]OV#OV x 2 of vertex positions for the offset polygon
[in]epsOffset distance

Definition at line 192 of file PolygonUtils.cpp.

◆ offset_surface_vertices()

void polyfem::mesh::offset_surface_vertices ( const Eigen::MatrixXd &  V,
const Eigen::MatrixXi &  F,
const Eigen::RowVector3d &  interior_point,
double  distance,
Eigen::MatrixXd &  offset 
)

Offset along area-weighted surface normals, using the direction away from an interior point where incident normals cancel.

Definition at line 334 of file MeshUtils.cpp.

References F, and V.

◆ operator<<()

std::ostream & polyfem::mesh::operator<< ( std::ostream &  os,
const LocalBoundary &  lb 
)
Parameters
osOutput stream
lbLocalBoundary to print
Returns
Output stream

Definition at line 50 of file LocalBoundary.cpp.

◆ orient_closed_surface()

void polyfem::mesh::orient_closed_surface ( const Eigen::MatrixXd &  V,
Eigen::MatrixXi &  F,
bool  positive = true 
)

Orient a triangulated surface to have positive volume.

Parameters
[in]VV x 3 input mesh vertices
[in]FF x 3 input mesh facets
[in]positiveOrient for positive volume, or negative volume

Definition at line 813 of file MeshUtils.cpp.

References F, signed_volume(), and V.

Referenced by polyfem::basis::PolygonalBasis3d::build_bases().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ orient_normals_2d()

void polyfem::mesh::orient_normals_2d ( PolygonMesh &  M)

Orient facets of a 2D mesh so that each connected component has positive volume.

Parameters
[in,out]MSurface mesh to reorient

Definition at line 272 of file MeshUtils.cpp.

Referenced by polyfem::mesh::CMesh2D::build_topology().

Here is the caller graph for this function:

◆ point_triangle_squared_distance()

double polyfem::mesh::point_triangle_squared_distance ( const double *  p,
const double *  v0,
const double *  v1,
const double *  v2 
)

Squared distance between a point and a triangle.

David Eberly's algorithm (https://www.geometrictools.com), with the exact expressions of geogram's Geom::point_triangle_squared_distance, which PolyFEM used to call through geogram's facet AABB. Like geogram, this file is compiled without floating-point contraction (see CMakeLists.txt), so the results are identical to the former ones.

Parameters
[in]pQuery point (3 coordinates)
[in]v0,v1,v2Triangle vertices (3 coordinates each)
Returns
Squared distance

Definition at line 284 of file PointTriangleDistance.cpp.

References point_triangle_squared_distance().

Referenced by point_triangle_squared_distance().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ refine_edge()

Eigen::MatrixXd polyfem::mesh::refine_edge ( const VectorNd &  a,
const VectorNd &  b,
const double  max_edge_length 
)

Refine an edge (a, b) so each refined edge has length at most max_edge_length.

Parameters
afirst vertex of the edge
bsecond vertex of the edge
max_edge_lengthmaximum edge length
Returns
vertices of the refined edge (in order)

Definition at line 183 of file UpsampleMesh.cpp.

References max_edge_length(), and V.

Referenced by refine_triangle_edges().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ refine_polygonal_mesh() [1/2]

void polyfem::mesh::refine_polygonal_mesh ( const PolygonMesh &  M_in,
PolygonMesh &  M_out,
bool  refine_polygons = false,
double  t = 0.5 
)
inline

Definition at line 137 of file Refinement.hpp.

References polyfem::mesh::Polygons::no_split_func(), polyfem::mesh::Polygons::polar_split_func(), and refine_polygonal_mesh().

Here is the call graph for this function:

◆ refine_polygonal_mesh() [2/2]

void polyfem::mesh::refine_polygonal_mesh ( const PolygonMesh &  M_in,
PolygonMesh &  M_out,
Polygons::SplitFunction  split_func 
)

Refine a polygonal mesh.

Quads and triangles are split into quads. If refine_polygons is set to true, then polygonal facets are also split into a layer of padding quads, and a new polygon is created around the barycenter

Parameters
[in]M_inSurface mesh to subdivide
[out]M_outRefined mesh
[in]split_funcFunctional used to split the new polygon interiors (boundary has already been split)

Definition at line 613 of file Refinement.cpp.

References polyfem::mesh::PolygonMesh::clear_edges(), polyfem::mesh::PolygonMesh::clear_facets(), polyfem::mesh::PolygonMesh::create_polygon(), polyfem::mesh::Navigation::Index::edge, polyfem::F, facet_barycenter(), polyfem::mesh::PolygonMesh::facet_vertex(), polyfem::mesh::Navigation::get_index_from_face(), mesh_create_vertex(), mesh_vertex(), polyfem::mesh::PolygonMesh::n_edges(), polyfem::mesh::PolygonMesh::n_facet_vertices(), polyfem::mesh::PolygonMesh::n_facets(), polyfem::mesh::PolygonMesh::n_vertices(), polyfem::mesh::Navigation::next_around_face(), polyfem::mesh::Navigation::switch_edge(), polyfem::mesh::Navigation::switch_vertex(), and V.

Referenced by polyfem::mesh::CMesh2D::refine(), and refine_polygonal_mesh().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ refine_quad_mesh()

void polyfem::mesh::refine_quad_mesh ( const Eigen::MatrixXd &  IV,
const Eigen::MatrixXi &  IF,
Eigen::MatrixXd &  OV,
Eigen::MatrixXi &  OF 
)

Definition at line 502 of file Refinement.cpp.

References instantiate_pattern().

Here is the call graph for this function:

◆ refine_triangle_edges()

void polyfem::mesh::refine_triangle_edges ( const VectorNd &  a,
const VectorNd &  b,
const VectorNd &  c,
const double  max_edge_len,
Eigen::MatrixXd &  V,
Eigen::MatrixXi &  E 
)

Refine the edges of a triangle (a, b, c) so each refined edge has length at most max_edge_length.

Parameters
afirst vertex of the triangle
bsecond vertex of the triangle
cthird vertex of the triangle
max_edge_lenmaximum edge length
Vvertices of the refined edges
Erefined edges

Definition at line 194 of file UpsampleMesh.cpp.

References refine_edge(), and V.

Referenced by irregular_triangle().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ refine_triangle_mesh()

void polyfem::mesh::refine_triangle_mesh ( const PolygonMesh &  M_in,
PolygonMesh &  M_out 
)

Refine a triangle mesh.

Each input triangle is split into 4 new triangles

Parameters
[in]M_inInput surface mesh
[out]M_outOutput surface mesh

Definition at line 739 of file Refinement.cpp.

References polyfem::mesh::PolygonMesh::clear_edges(), polyfem::mesh::PolygonMesh::clear_facets(), polyfem::mesh::PolygonMesh::create_polygon(), polyfem::mesh::Navigation::Index::edge, polyfem::mesh::PolygonMesh::facet_vertex(), polyfem::mesh::Navigation::get_index_from_face(), mesh_create_vertex(), mesh_vertex(), polyfem::mesh::PolygonMesh::n_edges(), polyfem::mesh::PolygonMesh::n_facet_vertices(), polyfem::mesh::PolygonMesh::n_facets(), polyfem::mesh::PolygonMesh::n_vertices(), polyfem::mesh::Navigation::next_around_face(), polyfem::mesh::Navigation::switch_edge(), and polyfem::mesh::Navigation::switch_vertex().

Referenced by polyfem::mesh::CMesh2D::refine().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ regular_grid_tessellation()

void polyfem::mesh::regular_grid_tessellation ( const Eigen::MatrixXd &  V,
const Eigen::MatrixXi &  F,
const double  max_edge_length,
Eigen::MatrixXd &  V_out,
Eigen::MatrixXi &  F_out 
)

Tessilate a triangle mesh (V, F) with regular grids of triangles of maximum edge length.

Parameters
Vvertices
Ftriangular faces
max_edge_lengthmaximum edge length
V_outtessilated vertices
F_outtessilated faces

Definition at line 148 of file UpsampleMesh.cpp.

References polyfem::F, max_edge_length(), regular_grid_triangle_barycentric_coordinates(), stitch_mesh(), and V.

Here is the call graph for this function:

◆ regular_grid_triangle_barycentric_coordinates()

void polyfem::mesh::regular_grid_triangle_barycentric_coordinates ( const int  n,
Eigen::MatrixXd &  V,
Eigen::MatrixXi &  F 
)

Compute the barycentric coordinates of a regular grid of triangles.

Parameters
[in]nNumber of triangles along each edge
[out]VVertices of the regular grid
[out]FFaces of the regular grid

Definition at line 104 of file UpsampleMesh.cpp.

References polyfem::F, and V.

Referenced by build_collision_proxy(), and regular_grid_tessellation().

Here is the caller graph for this function:

◆ reorder_mesh()

void polyfem::mesh::reorder_mesh ( Eigen::MatrixXd &  V,
Eigen::MatrixXi &  F,
const Eigen::VectorXi &  C,
Eigen::VectorXi &  R 
)

Reorder vertices of a mesh using color tags, so that vertices are ordered by increasing colors.

Parameters
[in,out]VV x d input mesh vertices
[in,out]FF x k input mesh faces
[in]CV per vertex color tag
[out]Rmax(C)+1 vector of starting indices for each colors (last value is the total number of vertices)

Definition at line 292 of file MeshUtils.cpp.

References F, and V.

◆ sample_polygon()

void polyfem::mesh::sample_polygon ( const Eigen::MatrixXd &  IV,
int  num_samples,
Eigen::MatrixXd &  S 
)

Sample equal-arclength interval midpoints, starting at the lexicographically smallest polygon vertex.

Parameters
[in]IV#IV x 2 vertex positions for the input polygon
[in]num_samplesDesired number of samples
[out]S#S x 2 output sample positions

Definition at line 278 of file PolygonUtils.cpp.

Referenced by polyfem::basis::PolygonalBasis2d::build_bases().

Here is the caller graph for this function:

◆ signed_squared_distances()

void polyfem::mesh::signed_squared_distances ( const Eigen::MatrixXd &  V,
const Eigen::MatrixXi &  F,
const Eigen::MatrixXd &  P,
Eigen::VectorXd &  D 
)

Computes the signed squared distance from a list of points to a triangle mesh.

This function build a AABB tree of the input mesh, computes the distance for each query point to the closest triangle, and then determines the sign by casting a vertical ray from the query point and counting the number of intersections with the input mesh

Parameters
[in]VV x 3 input mesh vertices
[in]FF x 3 input mesh faces
[in]P#P x 3 query points
D#P x 1 computed signed distances, negative inside, positive outside

Definition at line 765 of file MeshUtils.cpp.

References F, and V.

◆ signed_volume()

double polyfem::mesh::signed_volume ( const Eigen::MatrixXd &  V,
const Eigen::MatrixXi &  F 
)

Compute the signed volume of a surface mesh.

Parameters
[in]VV x 3 input mesh vertices
[in]FF x 3 input mesh facets
Returns
Signed volume of the surface

Definition at line 792 of file MeshUtils.cpp.

References F, and V.

Referenced by orient_closed_surface(), and polyfem::mesh::MeshProcessing3D::refine_red_refinement_tet().

Here is the caller graph for this function:

◆ stitch_mesh() [1/2]

void polyfem::mesh::stitch_mesh ( const Eigen::MatrixXd &  V,
const Eigen::MatrixXi &  F,
const std::vector< Eigen::Triplet< double > > &  W,
Eigen::MatrixXd &  V_out,
Eigen::MatrixXi &  F_out,
std::vector< Eigen::Triplet< double > > &  W_out,
const double  epsilon = 1e-5 
)

Stitch a triangle mesh (V, F) together by removing duplicate vertices.

Also removes weights in W that correspond to duplicate vertices.

Parameters
[in]VInput vertices
[in]FInput faces
[in]WInput weights
[out]V_outOutput vertices (duplicate vertices removed)
[out]F_outOutput faces (updated to use V_out)
[out]W_outOutput weights (updated to use V_out)
[in]epsilonTolerance for duplicate vertices

indices: #V_out by 1 list of indices so V_out = V(indices,:) inverse: V by 1 list of indices so V = V_out(inverse,:)

Definition at line 46 of file UpsampleMesh.cpp.

References polyfem::F, polyfem::utils::inverse(), and V.

Here is the call graph for this function:

◆ stitch_mesh() [2/2]

void polyfem::mesh::stitch_mesh ( const Eigen::MatrixXd &  V,
const Eigen::MatrixXi &  F,
Eigen::MatrixXd &  V_out,
Eigen::MatrixXi &  F_out,
const double  epsilon = 1e-5 
)

Stitch a triangle mesh (V, F) together by removing duplicate vertices.

Parameters
[in]VInput vertices
[in]FInput faces
[out]V_outOutput vertices (duplicate vertices removed)
[out]F_outOutput faces (updated to use V_out)
[in]epsilonTolerance for duplicate vertices

Definition at line 35 of file UpsampleMesh.cpp.

References polyfem::F, stitch_mesh(), and V.

Referenced by build_collision_proxy(), irregular_tessellation(), regular_grid_tessellation(), and stitch_mesh().

Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ MESH_SCHEMA_VERSION

constexpr long polyfem::mesh::MESH_SCHEMA_VERSION = 1
inlineconstexpr

The canonical typed mesh schema shared by HDF5 bundles and checkpoints.

Definition at line 10 of file MeshLoader.hpp.

Referenced by polyfem::mesh::MeshLoader::validate_group(), and polyfem::io::CheckpointWriter::write_mesh().