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

Namespaces

namespace  MeshProcessing3D
 
namespace  Navigation
 
namespace  Navigation3D
 
namespace  Polygons
 

Classes

class  CMesh2D
 
class  CMesh3D
 
struct  Edge
 
struct  Element
 
struct  Face
 
class  LocalBoundary
 Boundary primitive IDs for a single element. More...
 
class  LocalMesh
 
class  LocalRelaxationData
 
class  Mesh
 Abstract mesh class to capture 2d/3d conforming and non-conforming meshes. More...
 
class  Mesh2D
 
class  Mesh3D
 
class  Mesh3DStorage
 
struct  Mesh_Quality
 
class  MeshNodes
 
class  NCMesh2D
 
class  NCMesh3D
 
class  Obstacle
 
class  PhysicsRemesher
 
class  PhysicsTetRemesher
 
class  PhysicsTriRemesher
 
class  Remesher
 
class  SizingFieldRemesher
 
class  TetOperationCache
 
class  TriOperationCache
 
struct  Vertex
 
class  WildRemesher
 

Typedefs

typedef std::function< void(const Eigen::MatrixXd &, Eigen::MatrixXd &, int)> EvalParametersFunc
 
typedef std::function< std::tuple< int, int, bool >(int, int)> GetAdjacentLocalEdge
 
using SizingFieldTriRemesher = SizingFieldRemesher< wmtk::TriMesh >
 
using SizingFieldTetRemesher = SizingFieldRemesher< wmtk::TetMesh >
 
using TriMesh = WildRemesher< wmtk::TriMesh >
 
using TetMesh = WildRemesher< wmtk::TetMesh >
 
using WildTriRemesher = WildRemesher< wmtk::TriMesh >
 
using WildTetRemesher = WildRemesher< wmtk::TetMesh >
 
using Tuple = WildTetRemesher::Tuple
 

Enumerations

enum class  CollisionProxyTessellation { REGULAR , IRREGULAR }
 
enum class  BoundaryType {
  TRI_LINE , QUAD_LINE , 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 , UNDEFINED
}
 Type of Element, check [Poly-Spline Finite Element Method] for a complete description. More...
 
enum class  MeshType {
  TRI = 0 , QUA , H_SUR , TET ,
  HYB , HEX
}
 
enum class  CollapseEdgeTo { V0 , V1 , MIDPOINT , ILLEGAL }
 

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 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 files.
 
void load_collision_proxy_mesh (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 file.
 
void load_collision_proxy_displacement_map (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 files.
 
 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::unique_ptr< Meshread_fem_mesh (const Units &units, const json &j_mesh, const std::string &root_path, const bool non_conforming=false)
 read a FEM mesh from a geometry JSON
 
std::unique_ptr< Meshread_fem_geometry (const Units &units, const json &geometry, const std::string &root_path, const std::vector< std::string > &names=std::vector< std::string >(), const std::vector< Eigen::MatrixXd > &vertices=std::vector< Eigen::MatrixXd >(), const std::vector< Eigen::MatrixXi > &cells=std::vector< Eigen::MatrixXi >(), const bool non_conforming=false)
 read FEM meshes from a geometry JSON array (or single)
 
void read_obstacle_mesh (const Units &units, const json &j_mesh, const std::string &root_path, const int dim, Eigen::MatrixXd &vertices, Eigen::VectorXi &codim_vertices, Eigen::MatrixXi &codim_edges, Eigen::MatrixXi &faces)
 read a obstacle mesh from a geometry JSON
 
Obstacle read_obstacle_geometry (const Units &units, const json &geometry, const std::vector< json > &displacements, const std::vector< json > &dirichlets, const std::string &root_path, const int dim, const std::vector< std::string > &names=std::vector< std::string >(), const std::vector< Eigen::MatrixXd > &vertices=std::vector< Eigen::MatrixXd >(), const std::vector< Eigen::MatrixXi > &cells=std::vector< Eigen::MatrixXi >(), const bool non_conforming=false)
 read a FEM mesh from a geometry JSON
 
void construct_affine_transformation (const double unit_scale, const json &transform, const VectorNd &mesh_dimensions, MatrixNd &A, VectorNd &b)
 Construct an affine transformation \(Ax+b\).
 
std::ostream & operator<< (std::ostream &os, const LocalBoundary &lb)
 
int find (const Eigen::VectorXi &vec, int x)
 
double line_weight (Eigen::Matrix< double, 2, 2 > &e, Eigen::VectorXd &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 points on a polygon, evenly spaced from each other.
 
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 GEO::Mesh &M_in, GEO::Mesh &M_out, Polygons::SplitFunction split_func)
 Refine a polygonal mesh.
 
void refine_triangle_mesh (const GEO::Mesh &M_in, GEO::Mesh &M_out)
 Refine a triangle mesh.
 
void refine_polygonal_mesh (const GEO::Mesh &M_in, GEO::Mesh &M_out, bool refine_polygons=false, double t=0.5)
 
void singular_vertices (const GEO::Mesh &M, Eigen::VectorXi &V, int regular_degree=4, bool ignore_border=true)
 
void singular_edges (const GEO::Mesh &M, const Eigen::VectorXi &V, Eigen::MatrixX2i &E)
 
void singularity_graph (const GEO::Mesh &M, Eigen::VectorXi &V, Eigen::MatrixX2i &E, int regular_degree=4, bool ignore_border=true)
 
void create_patch_around_singularities (GEO::Mesh &M, const Eigen::VectorXi &V, const Eigen::MatrixX2i &E, double t=0.5)
 
GEO::vec3 mesh_vertex (const GEO::Mesh &M, GEO::index_t v)
 Retrieve a 3D vector with the position of a given vertex.
 
GEO::vec3 facet_barycenter (const GEO::Mesh &M, GEO::index_t f)
 
GEO::index_t mesh_create_vertex (GEO::Mesh &M, const GEO::vec3 &p)
 
void compute_element_tags (const GEO::Mesh &M, std::vector< ElementType > &element_tags)
 Compute the type of each facet in a surface mesh.
 
void orient_normals_2d (GEO::Mesh &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 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.
 
void to_geogram_mesh (const Eigen::MatrixXd &V, const Eigen::MatrixXi &F, GEO::Mesh &M)
 Converts a triangle mesh to a Geogram mesh.
 
void from_geogram_mesh (const GEO::Mesh &M, Eigen::MatrixXd &V, Eigen::MatrixXi &F, Eigen::MatrixXi &T)
 Extract simplices from a Geogram mesh.
 
void to_geogram_mesh (const Mesh3D &mesh, GEO::Mesh &M)
 Converts a hex mesh to a Geogram 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.
 
void extract_polyhedra (const Mesh3D &mesh, std::vector< std::unique_ptr< GEO::Mesh > > &polys, bool triangulated=false)
 Extract polyhedra from a 3D volumetric mesh.
 
void tertrahedralize_star_shaped_surface (const Eigen::MatrixXd &V, const Eigen::MatrixXi &F, const Eigen::RowVector3d &kernel, Eigen::MatrixXd &OV, Eigen::MatrixXi &OF, Eigen::MatrixXi &OT)
 Tetrahedralize a star-shaped mesh, with a given point in its kernel.
 
void sample_surface (const Eigen::MatrixXd &V, const Eigen::MatrixXi &F, int num_samples, Eigen::MatrixXd &P, Eigen::MatrixXd *N=nullptr, int num_lloyd=10, int num_newton=10)
 Samples points on a surface.
 
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 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 read_surface_mesh (const std::string &mesh_path, Eigen::MatrixXd &vertices, Eigen::VectorXi &codim_vertices, Eigen::MatrixXi &codim_edges, Eigen::MatrixXi &faces)
 read a surface mesh
 
bool is_planar (const GEO::Mesh &M, const double tol=1e-5)
 Determine if the given mesh is planar (2D or tiny z-range).
 
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 (GEO::Mesh &M)
 assing edges to M
 
Eigen::MatrixXd unconstrained_L2_projection (const Eigen::SparseMatrix< double > &M, const Eigen::SparseMatrix< double > &A, const Eigen::Ref< const Eigen::MatrixXd > &y)
 
void reduced_L2_projection (const Eigen::MatrixXd &M, const Eigen::MatrixXd &A, const Eigen::Ref< const Eigen::MatrixXd > &y, const std::vector< int > &boundary_nodes, Eigen::Ref< Eigen::MatrixXd > x)
 
Eigen::VectorXd constrained_L2_projection (std::shared_ptr< polysolve::nonlinear::Solver > nl_solver, const Eigen::SparseMatrix< double > &M, const Eigen::SparseMatrix< double > &A, const Eigen::VectorXd &y, const Eigen::MatrixXd &rest_positions, const Eigen::MatrixXi &elements, const int dim, const ipc::CollisionMesh &collision_mesh, const double dhat, const double barrier_stiffness, const bool use_convergent_formulation, const ipc::BroadPhaseMethod broad_phase_method, const double ccd_tolerance, const int ccd_max_iterations, const std::vector< int > &boundary_nodes, const size_t obstacle_ndof, const Eigen::VectorXd &target_x, const Eigen::VectorXd &x0)
 
void unique_facet_tuples (const wmtk::TriMesh &m, std::vector< wmtk::TriMesh::Tuple > &tuples)
 
void unique_facet_tuples (const wmtk::TetMesh &m, std::vector< wmtk::TetMesh::Tuple > &tuples)
 
void add_solver_timings (decltype(Remesher::timings) &timings, const polyfem::json &solver_info)
 
template<class WMTKMesh >
double get_quality (const WildRemesher< WMTKMesh > &m, const typename WMTKMesh::Tuple &t)
 
template<class WMTKMesh >
void project_local_quantities (WildRemesher< WMTKMesh > &m, LocalMesh< WildRemesher< WMTKMesh > > &old_local_mesh, LocalMesh< WildRemesher< WMTKMesh > > &new_local_mesh)
 
double compute_valence_energy (const WildTriRemesher &m, std::string op, const WildTriRemesher::Tuple &t)
 
double compute_area_ratio_energy (const WildTriRemesher &m, std::string op, const WildTriRemesher::Tuple &t)
 
template<typename WMTKMesh >
Remesher::EdgeMap< typename WildRemesher< WMTKMesh >::EdgeAttributes::EnergyRank > rank_edges (const Remesher::EdgeMap< double > &edge_energy, const json &args)
 

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.

◆ SizingFieldTetRemesher

Definition at line 70 of file SizingFieldRemesher.hpp.

◆ SizingFieldTriRemesher

Definition at line 69 of file SizingFieldRemesher.hpp.

◆ TetMesh

using polyfem::mesh::TetMesh = typedef WildRemesher<wmtk::TetMesh>

Definition at line 36 of file LocalMesh.cpp.

◆ TriMesh

using polyfem::mesh::TriMesh = typedef WildRemesher<wmtk::TriMesh>

Definition at line 35 of file LocalMesh.cpp.

◆ Tuple

◆ WildTetRemesher

using polyfem::mesh::WildTetRemesher = typedef WildRemesher<wmtk::TetMesh>

Definition at line 428 of file WildRemesher.hpp.

◆ WildTriRemesher

using polyfem::mesh::WildTriRemesher = typedef WildRemesher<wmtk::TriMesh>

Definition at line 427 of file WildRemesher.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.

TRI 
QUAD 
POLYGON 
POLYHEDRON 
INVALID 

Definition at line 12 of file LocalBoundary.hpp.

◆ CollapseEdgeTo

enum class polyfem::mesh::CollapseEdgeTo
strong
Enumerator
V0 
V1 
MIDPOINT 
ILLEGAL 

Definition at line 14 of file WildRemesher.hpp.

◆ CollisionProxyTessellation

Enumerator
REGULAR 

Regular tessellation of the mesh.

IRREGULAR 

Irregular tessellation of the mesh (requires POLYFEM_WITH_TRIANGLE)

Definition at line 12 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.

UNDEFINED 

Boundary polytope.

Definition at line 22 of file Mesh.hpp.

◆ MeshType

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

Definition at line 53 of file Mesh3DStorage.hpp.

Function Documentation

◆ add_solver_timings()

void polyfem::mesh::add_solver_timings ( decltype(Remesher::timings) &  timings,
const polyfem::json solver_info 
)

Definition at line 11 of file LocalRelaxation.cpp.

References polyfem::utils::StringUtils::startswith().

Here is the call 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 73 of file CollisionProxy.cpp.

References polyfem::basis::ElementBases::bases, polyfem::basis::ElementBases::eval_geom_mapping(), 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::State::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 168 of file CollisionProxy.cpp.

References polyfem::log_and_throw_error().

Here is the call graph for this function:

◆ 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 50 of file PolygonUtils.cpp.

Referenced by compute_visibility_kernel().

Here is the caller graph for this function:

◆ compute_area_ratio_energy()

double polyfem::mesh::compute_area_ratio_energy ( const WildTriRemesher m,
std::string  op,
const WildTriRemesher::Tuple t 
)

Definition at line 207 of file Swap.cpp.

References compute_area_ratio_energy(), and polyfem::mesh::WildRemesher< WMTKMesh >::element_volume().

Referenced by compute_area_ratio_energy().

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

◆ compute_element_tags()

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

Compute the type of each facet in a surface mesh.

Parameters
[in]MInput surface mesh
[out]element_tagsTypes of each facet element

Definition at line 97 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_valence_energy()

double polyfem::mesh::compute_valence_energy ( const WildTriRemesher m,
std::string  op,
const WildTriRemesher::Tuple t 
)

Definition at line 182 of file Swap.cpp.

References compute_valence_energy(), and polyfem::mesh::WildRemesher< WMTKMesh >::is_boundary_vertex().

Referenced by compute_valence_energy(), and polyfem::mesh::PhysicsTriRemesher::swap_edges().

Here is the call graph for this function:
Here is the caller 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 120 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:

◆ constrained_L2_projection()

Eigen::VectorXd polyfem::mesh::constrained_L2_projection ( std::shared_ptr< polysolve::nonlinear::Solver >  nl_solver,
const Eigen::SparseMatrix< double > &  M,
const Eigen::SparseMatrix< double > &  A,
const Eigen::VectorXd &  y,
const Eigen::MatrixXd &  rest_positions,
const Eigen::MatrixXi &  elements,
const int  dim,
const ipc::CollisionMesh &  collision_mesh,
const double  dhat,
const double  barrier_stiffness,
const bool  use_convergent_formulation,
const ipc::BroadPhaseMethod  broad_phase_method,
const double  ccd_tolerance,
const int  ccd_max_iterations,
const std::vector< int > &  boundary_nodes,
const size_t  obstacle_ndof,
const Eigen::VectorXd &  target_x,
const Eigen::VectorXd &  x0 
)

Definition at line 70 of file L2Projection.cpp.

References polyfem::solver::ALSolver::solve_al(), polyfem::utils::unflatten(), x, and y.

Referenced by polyfem::mesh::Remesher::project_quantities().

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

◆ construct_affine_transformation()

void polyfem::mesh::construct_affine_transformation ( const double  unit_scale,
const json transform,
const VectorNd mesh_dimensions,
MatrixNd A,
VectorNd b 
)

Construct an affine transformation \(Ax+b\).

Parameters
[in]transformJSON object with the mesh data
[in]mesh_dimensionsDimensions of the mesh (i.e., width, height, depth)
[out]AMultiplicative matrix component of transformation
[out]bAdditive translation component of transformation

Definition at line 688 of file GeometryReader.cpp.

References construct_affine_transformation(), polyfem::utils::deg2rad(), polyfem::log_and_throw_error(), and polyfem::utils::to_rotation_matrix().

Referenced by construct_affine_transformation(), load_collision_proxy_mesh(), read_fem_mesh(), and read_obstacle_mesh().

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 1194 of file MeshUtils.cpp.

◆ create_patch_around_singularities()

void polyfem::mesh::create_patch_around_singularities ( GEO::Mesh &  M,
const Eigen::VectorXi &  V,
const Eigen::MatrixX2i &  E,
double  t = 0.5 
)

Definition at line 84 of file Singularities.cpp.

References facet_barycenter(), mesh_create_vertex(), mesh_vertex(), and V.

Here is the call graph for this function:

◆ 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 946 of file MeshUtils.cpp.

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

Here is the caller graph for this function:

◆ extract_polyhedra()

void polyfem::mesh::extract_polyhedra ( const Mesh3D mesh,
std::vector< std::unique_ptr< GEO::Mesh > > &  polys,
bool  triangulated = false 
)

Extract polyhedra from a 3D volumetric mesh.

Parameters
[in]meshInput volume mesh
[out]polysExtracted polyhedral surfaces

Definition at line 715 of file MeshUtils.cpp.

References polyfem::mesh::Mesh3D::get_index_from_element(), polyfem::mesh::Mesh::is_polytope(), polyfem::mesh::Mesh3D::kernel(), polyfem::mesh::Mesh3D::n_cell_faces(), polyfem::mesh::Mesh::n_cell_vertices(), polyfem::mesh::Mesh::n_cells(), polyfem::mesh::Mesh::n_face_vertices(), polyfem::mesh::Mesh::n_faces(), polyfem::mesh::Mesh::n_vertices(), polyfem::mesh::Mesh3D::next_around_face(), and polyfem::mesh::Mesh::point().

Here is the call 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 1052 of file MeshUtils.cpp.

References find_triangle_surface_from_tets().

Referenced by read_surface_mesh().

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

◆ facet_barycenter()

GEO::vec3 polyfem::mesh::facet_barycenter ( const GEO::Mesh &  M,
GEO::index_t  f 
)

Definition at line 64 of file MeshUtils.cpp.

References mesh_vertex().

Referenced by create_patch_around_singularities(), and 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 289 of file NCMesh2D.cpp.

References vec, and x.

Referenced by polyfem::mesh::MeshProcessing3D::build_connectivity(), polyfem::mesh::NCMesh2D::build_element_vertex_adjacency(), polyfem::mesh::Navigation3D::get_index_from_element_face(), polyfem::mesh::CMesh3D::load(), polyfem::mesh::MeshProcessing3D::refine_catmul_clark_polar(), and polyfem::mesh::NCMesh2D::switch_edge().

Here is the caller graph for this function:

◆ from_geogram_mesh()

void polyfem::mesh::from_geogram_mesh ( const GEO::Mesh &  M,
Eigen::MatrixXd &  V,
Eigen::MatrixXi &  F,
Eigen::MatrixXi &  T 
)

Extract simplices from a Geogram mesh.

Parameters
[in]MInput Geogram mesh
[out]VV x 3 output mesh vertices
[out]FF x 3 output mesh faces
[out]T#T x 4 output mesh tets

Definition at line 639 of file MeshUtils.cpp.

References V.

◆ generate_edges()

void polyfem::mesh::generate_edges ( GEO::Mesh &  M)

assing edges to M

Parameters
[in/out]M geogram mesh to appen edges to

Definition at line 1244 of file MeshUtils.cpp.

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

Here is the caller graph for this function:

◆ get_quality()

template<class WMTKMesh >
double polyfem::mesh::get_quality ( const WildRemesher< WMTKMesh > &  m,
const typename WMTKMesh::Tuple &  t 
)

Definition at line 16 of file Smooth.cpp.

References polyfem::mesh::WildRemesher< WMTKMesh >::element_vids(), and polyfem::mesh::WildRemesher< WMTKMesh >::vertex_attrs.

Referenced by polyfem::mesh::WildRemesher< WMTKMesh >::smooth_after(), and polyfem::mesh::WildRemesher< WMTKMesh >::smooth_vertices().

Here is the call graph for this function:
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 278 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 242 of file PolygonUtils.cpp.

◆ is_planar()

bool polyfem::mesh::is_planar ( const GEO::Mesh &  M,
const double  tol = 1e-5 
)

Determine if the given mesh is planar (2D or tiny z-range).

Definition at line 31 of file MeshUtils.cpp.

Referenced by polyfem::mesh::Mesh::create(), and read_surface_mesh().

Here is the caller graph for this function:

◆ 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]baryThe barycenter of the kernel
Returns
True if star shaped, False otherwise.

Definition at line 150 of file PolygonUtils.cpp.

References compute_visibility_kernel().

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 ( Eigen::Matrix< double, 2, 2 > &  e,
Eigen::VectorXd &  v 
)

Definition at line 364 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 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 files.

Parameters
[in]mesh_filenameMesh filename
[in]weights_filenameWeights filename
[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 315 of file CollisionProxy.cpp.

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

Referenced by polyfem::State::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 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 files.

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

Definition at line 361 of file CollisionProxy.cpp.

References load_collision_proxy_displacement_map().

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 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 file.

Parameters
[in]mesh_filenameMesh filename
[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 330 of file CollisionProxy.cpp.

References construct_affine_transformation(), faces, load_collision_proxy_mesh(), and read_surface_mesh().

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(), polyfem::mesh::WildRemesher< WMTKMesh >::collapse_edge_before(), 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()

GEO::index_t polyfem::mesh::mesh_create_vertex ( GEO::Mesh &  M,
const GEO::vec3 &  p 
)

Definition at line 77 of file MeshUtils.cpp.

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

Here is the caller graph for this function:

◆ mesh_vertex()

GEO::vec3 polyfem::mesh::mesh_vertex ( const GEO::Mesh &  M,
GEO::index_t  v 
)

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

Contrary to geogram's version, this function works with both single and double precision meshes, as well as 2D meshes too.

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

Definition at line 44 of file MeshUtils.cpp.

Referenced by create_patch_around_singularities(), 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 178 of file PolygonUtils.cpp.

◆ operator<<()

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

Definition at line 49 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 702 of file MeshUtils.cpp.

References 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 ( GEO::Mesh &  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 304 of file MeshUtils.cpp.

Referenced by polyfem::mesh::CMesh2D::build_from_matrices(), polyfem::mesh::NCMesh2D::build_from_matrices(), polyfem::mesh::CMesh2D::load(), and polyfem::mesh::NCMesh2D::load().

Here is the caller graph for this function:

◆ project_local_quantities()

template<class WMTKMesh >
void polyfem::mesh::project_local_quantities ( WildRemesher< WMTKMesh > &  m,
LocalMesh< WildRemesher< WMTKMesh > > &  old_local_mesh,
LocalMesh< WildRemesher< WMTKMesh > > &  new_local_mesh 
)

Definition at line 44 of file Smooth.cpp.

References POLYFEM_REMESHER_SCOPED_TIMER.

Referenced by polyfem::mesh::WildRemesher< WMTKMesh >::smooth_after().

Here is the caller graph for this function:

◆ rank_edges()

template<typename WMTKMesh >
Remesher::EdgeMap< typename WildRemesher< WMTKMesh >::EdgeAttributes::EnergyRank > polyfem::mesh::rank_edges ( const Remesher::EdgeMap< double > &  edge_energy,
const json args 
)

Definition at line 47 of file WildRemesher.cpp.

◆ read_fem_geometry()

std::unique_ptr< Mesh > polyfem::mesh::read_fem_geometry ( const Units units,
const json geometry,
const std::string &  root_path,
const std::vector< std::string > &  names = std::vector< std::string >(),
const std::vector< Eigen::MatrixXd > &  vertices = std::vector< Eigen::MatrixXd >(),
const std::vector< Eigen::MatrixXi > &  cells = std::vector< Eigen::MatrixXi >(),
const bool  non_conforming = false 
)

read FEM meshes from a geometry JSON array (or single)

Parameters
[in]geometrygeometry JSON object(s)
[in]root_pathroot path of JSON
Returns
created Mesh object

Definition at line 230 of file GeometryReader.cpp.

References polyfem::log_and_throw_error(), read_fem_geometry(), and read_fem_mesh().

Referenced by polyfem::State::load_mesh(), and read_fem_geometry().

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

◆ read_fem_mesh()

std::unique_ptr< Mesh > polyfem::mesh::read_fem_mesh ( const Units units,
const json j_mesh,
const std::string &  root_path,
const bool  non_conforming = false 
)

read a FEM mesh from a geometry JSON

Parameters
[in]j_meshgeometry JSON
[in]root_pathroot path of JSON
[in]non_conformingif true, the mesh will be non-conforming
Returns
created Mesh object

Definition at line 25 of file GeometryReader.cpp.

References polyfem::utils::Selection::build_selections(), construct_affine_transformation(), polyfem::Units::convert(), polyfem::mesh::Mesh::create(), polyfem::utils::is_param_valid(), polyfem::Units::length(), polyfem::log_and_throw_error(), polyfem::logger(), and polyfem::utils::resolve_path().

Referenced by read_fem_geometry().

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

◆ read_obstacle_geometry()

Obstacle polyfem::mesh::read_obstacle_geometry ( const Units units,
const json geometry,
const std::vector< json > &  displacements,
const std::vector< json > &  dirichlets,
const std::string &  root_path,
const int  dim,
const std::vector< std::string > &  names = std::vector< std::string >(),
const std::vector< Eigen::MatrixXd > &  vertices = std::vector< Eigen::MatrixXd >(),
const std::vector< Eigen::MatrixXi > &  cells = std::vector< Eigen::MatrixXi >(),
const bool  non_conforming = false 
)

read a FEM mesh from a geometry JSON

Parameters
[in]geometrygeometry JSON object(s)
[in]displacementsdisplacements JSON object(s)
[in]dirichletsdirichlet bc JSON object(s)
[in]root_pathroot path of JSON
Returns
created Obstacle object

Definition at line 438 of file GeometryReader.cpp.

References polyfem::mesh::Obstacle::append_mesh(), polyfem::mesh::Obstacle::append_mesh_sequence(), polyfem::mesh::Obstacle::append_plane(), faces, polyfem::utils::is_param_valid(), polyfem::log_and_throw_error(), read_obstacle_geometry(), read_obstacle_mesh(), polyfem::utils::resolve_path(), and polyfem::mesh::Obstacle::set_units().

Referenced by polyfem::State::load_mesh(), polyfem::State::load_mesh(), and read_obstacle_geometry().

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

◆ read_obstacle_mesh()

void polyfem::mesh::read_obstacle_mesh ( const Units units,
const json j_mesh,
const std::string &  root_path,
const int  dim,
Eigen::MatrixXd &  vertices,
Eigen::VectorXi &  codim_vertices,
Eigen::MatrixXi &  codim_edges,
Eigen::MatrixXi &  faces 
)

read a obstacle mesh from a geometry JSON

Parameters
[in]j_meshgeometry JSON
[in]root_pathroot path of JSON
[out]verticesV x 3/2 output vertices positions
[out]codim_verticesindicies in vertices for the codimensional vertices
[out]codim_edgesindicies in vertices for the codimensional edges
[out]facesindicies in vertices for the surface faces

Definition at line 327 of file GeometryReader.cpp.

References construct_affine_transformation(), faces, polyfem::utils::is_param_valid(), polyfem::Units::length(), polyfem::log_and_throw_error(), read_obstacle_mesh(), read_surface_mesh(), and polyfem::utils::resolve_path().

Referenced by read_obstacle_geometry(), and read_obstacle_mesh().

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

◆ read_surface_mesh()

bool polyfem::mesh::read_surface_mesh ( const std::string &  mesh_path,
Eigen::MatrixXd &  vertices,
Eigen::VectorXi &  codim_vertices,
Eigen::MatrixXi &  codim_edges,
Eigen::MatrixXi &  faces 
)

read a surface mesh

Parameters
[in]mesh_pathpath to mesh file
[out]verticesV x 3/2 output vertices positions
[out]codim_verticesindicies in vertices for the codimensional vertices
[out]codim_edgesindicies in vertices for the codimensional edges
[out]facesindicies in vertices for the surface faces

Definition at line 1091 of file MeshUtils.cpp.

References polyfem::utils::StringUtils::endswith(), extract_triangle_surface_from_tets(), faces, find_codim_vertices(), is_planar(), polyfem::io::MshReader::load(), polyfem::logger(), and polyfem::io::OBJReader::read().

Referenced by load_collision_proxy_mesh(), and read_obstacle_mesh().

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

◆ reduced_L2_projection()

void polyfem::mesh::reduced_L2_projection ( const Eigen::MatrixXd &  M,
const Eigen::MatrixXd &  A,
const Eigen::Ref< const Eigen::MatrixXd > &  y,
const std::vector< int > &  boundary_nodes,
Eigen::Ref< Eigen::MatrixXd >  x 
)

Definition at line 48 of file L2Projection.cpp.

References x, and y.

◆ 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 GEO::Mesh &  M_in,
GEO::Mesh &  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 GEO::Mesh &  M_in,
GEO::Mesh &  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 620 of file Refinement.cpp.

References polyfem::mesh::Navigation::Index::edge, polyfem::F, facet_barycenter(), polyfem::mesh::Navigation::get_index_from_face(), mesh_create_vertex(), mesh_vertex(), polyfem::mesh::Navigation::next_around_face(), polyfem::mesh::Navigation::switch_edge(), polyfem::mesh::Navigation::switch_vertex(), V, and polyfem::mesh::Navigation::Index::vertex.

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 507 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 GEO::Mesh &  M_in,
GEO::Mesh &  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 736 of file Refinement.cpp.

References polyfem::mesh::Navigation::Index::edge, polyfem::mesh::Navigation::get_index_from_face(), mesh_create_vertex(), mesh_vertex(), polyfem::mesh::Navigation::next_around_face(), polyfem::mesh::Navigation::switch_edge(), polyfem::mesh::Navigation::switch_vertex(), and polyfem::mesh::Navigation::Index::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 325 of file MeshUtils.cpp.

References V.

◆ sample_polygon()

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

Sample points on a polygon, evenly spaced from each other.

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 264 of file PolygonUtils.cpp.

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

Here is the caller graph for this function:

◆ sample_surface()

void polyfem::mesh::sample_surface ( const Eigen::MatrixXd &  V,
const Eigen::MatrixXi &  F,
int  num_samples,
Eigen::MatrixXd &  P,
Eigen::MatrixXd *  N = nullptr,
int  num_lloyd = 10,
int  num_newton = 10 
)

Samples points on a surface.

Parameters
[in]VV x 3 input mesh vertices
[in]FF x 3 input mesh facets
[in]num_samplesNumber of desired samples
[out]Pnum_samples x 3 sample points positions
[out]Nnum_samples x 3 of normals estimated from the original surface (optional argument)
[in]num_lloydNumber of Lloyd iterations
[in]num_newtonNumber of Newton iterations

Definition at line 884 of file MeshUtils.cpp.

References to_geogram_mesh(), and V.

Here is the call 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 669 of file MeshUtils.cpp.

References to_geogram_mesh(), and V.

Here is the call graph for this function:

◆ 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 681 of file MeshUtils.cpp.

References V.

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

Here is the caller graph for this function:

◆ singular_edges()

void polyfem::mesh::singular_edges ( const GEO::Mesh &  M,
const Eigen::VectorXi &  V,
Eigen::MatrixX2i &  E 
)

Definition at line 48 of file Singularities.cpp.

References V.

Referenced by singularity_graph().

Here is the caller graph for this function:

◆ singular_vertices()

void polyfem::mesh::singular_vertices ( const GEO::Mesh &  M,
Eigen::VectorXi &  V,
int  regular_degree = 4,
bool  ignore_border = true 
)

Definition at line 8 of file Singularities.cpp.

References V.

Referenced by singularity_graph().

Here is the caller graph for this function:

◆ singularity_graph()

void polyfem::mesh::singularity_graph ( const GEO::Mesh &  M,
Eigen::VectorXi &  V,
Eigen::MatrixX2i &  E,
int  regular_degree = 4,
bool  ignore_border = true 
)

Definition at line 75 of file Singularities.cpp.

References singular_edges(), singular_vertices(), and V.

Here is the call 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:

◆ tertrahedralize_star_shaped_surface()

void polyfem::mesh::tertrahedralize_star_shaped_surface ( const Eigen::MatrixXd &  V,
const Eigen::MatrixXi &  F,
const Eigen::RowVector3d &  kernel,
Eigen::MatrixXd &  OV,
Eigen::MatrixXi &  OF,
Eigen::MatrixXi &  OT 
)

Tetrahedralize a star-shaped mesh, with a given point in its kernel.

Parameters
[in]VV x 3 input mesh vertices
[in]FF x 3 input mesh triangles
[in]kernelA point in the kernel
[out]OV#OV x 3 output mesh vertices
[out]OF#OF x 3 output mesh surface triangles
[out]OT#OT x 4 output mesh tetrahedra

Definition at line 869 of file MeshUtils.cpp.

References V.

Referenced by polyfem::quadrature::PolyhedronQuadrature::get_quadrature().

Here is the caller graph for this function:

◆ to_geogram_mesh() [1/2]

void polyfem::mesh::to_geogram_mesh ( const Eigen::MatrixXd &  V,
const Eigen::MatrixXi &  F,
GEO::Mesh &  M 
)

Converts a triangle mesh to a Geogram mesh.

Parameters
[in]VV x 3 input mesh vertices
[in]FF x 3 input mesh surface
[out]MOutput Geogram mesh

Definition at line 575 of file MeshUtils.cpp.

References V.

Referenced by polyfem::mesh::CMesh2D::build_from_matrices(), polyfem::mesh::NCMesh2D::build_from_matrices(), sample_surface(), polyfem::mesh::CMesh3D::save(), and signed_squared_distances().

Here is the caller graph for this function:

◆ to_geogram_mesh() [2/2]

void polyfem::mesh::to_geogram_mesh ( const Mesh3D mesh,
GEO::Mesh &  M 
)

Converts a hex mesh to a Geogram mesh.

Parameters
[in]meshInput mesh
[out]MOutput Geogram mesh

Definition at line 811 of file MeshUtils.cpp.

References polyfem::mesh::Mesh::face_vertex(), polyfem::mesh::Mesh3D::get_ordered_vertices_from_hex(), polyfem::mesh::Mesh::is_boundary_face(), polyfem::mesh::Mesh::is_cube(), polyfem::mesh::Mesh::n_cells(), polyfem::mesh::Mesh::n_face_vertices(), polyfem::mesh::Mesh::n_faces(), polyfem::mesh::Mesh::n_vertices(), and polyfem::mesh::Mesh::point().

Here is the call graph for this function:

◆ unconstrained_L2_projection()

Eigen::MatrixXd polyfem::mesh::unconstrained_L2_projection ( const Eigen::SparseMatrix< double > &  M,
const Eigen::SparseMatrix< double > &  A,
const Eigen::Ref< const Eigen::MatrixXd > &  y 
)

Definition at line 18 of file L2Projection.cpp.

References polyfem::logger(), x, and y.

Referenced by polyfem::mesh::Remesher::project_quantities().

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

◆ unique_facet_tuples() [1/2]

void polyfem::mesh::unique_facet_tuples ( const wmtk::TetMesh &  m,
std::vector< wmtk::TetMesh::Tuple > &  tuples 
)

Definition at line 43 of file LocalMesh.cpp.

◆ unique_facet_tuples() [2/2]

void polyfem::mesh::unique_facet_tuples ( const wmtk::TriMesh &  m,
std::vector< wmtk::TriMesh::Tuple > &  tuples 
)

Definition at line 38 of file LocalMesh.cpp.

Referenced by polyfem::mesh::LocalMesh< M >::LocalMesh().

Here is the caller graph for this function: