PolyFEM
Loading...
Searching...
No Matches
polyfem::mesh::PolygonMesh Class Reference

Minimal polygonal surface mesh used as the storage of CMesh2D. More...

#include <PolygonMesh.hpp>

Classes

struct  Point
 3D point. More...
 

Public Member Functions

void clear ()
 Removes all vertices, facets and edges.
 
int n_vertices () const
 
const Point & point (const int v) const
 
Point & point (const int v)
 
int create_vertices (int n)
 Appends n vertices at the origin and returns the index of the first one.
 
int create_vertex (const Point &p)
 Appends a vertex and returns its index.
 
void bounding_box (Point &min, Point &max) const
 Bounding box of the vertices (min/max are initialized to the largest and lowest doubles, as geogram's get_bbox does).
 
int n_facets () const
 
int n_facet_vertices (const int f) const
 
int facet_vertex (const int f, const int lv) const
 
int n_corners () const
 
int corners_begin (const int f) const
 
int corners_end (const int f) const
 
int facet_corner (const int f, const int lv) const
 
int corner_vertex (const int c) const
 
int corner_adjacent_facet (const int c) const
 Facet across the edge from corner c to the next corner of its facet, or -1.
 
int next_corner_around_facet (const int f, const int c) const
 
int prev_corner_around_facet (const int f, const int c) const
 
int create_polygon (const std::vector< int > &vertices)
 Appends a polygon (not glued to its neighbors) and returns its index.
 
void flip_facet (int f)
 Reverses the orientation of facet f (its vertex list is reversed).
 
void clear_facets ()
 Removes all facets, keeping the vertices and the edges.
 
void delete_facets (const std::vector< bool > &to_delete)
 Removes the facets f with to_delete[f], keeping all vertices, and renumbers the remaining facets (and the corner adjacency) in order.
 
void connect_facets ()
 Glues every corner without neighbor to the facet sharing its edge in opposite orientation (already glued corners are kept).
 
int connected_components (std::vector< int > &component) const
 Assigns to each facet the index of its connected component (through the corner adjacency) and returns the number of components.
 
int n_edges () const
 
int edge_vertex (const int e, const int lv) const
 
int create_edge (int v0, int v1)
 
void clear_edges ()
 

Public Attributes

std::vector< int > corner_edge
 Index of the edge starting at each corner.
 
std::vector< bool > boundary_edge
 Whether each edge is on the boundary.
 
std::vector< bool > boundary_vertex
 Whether each vertex is on the boundary.
 

Private Attributes

std::vector< Point > points_
 
std::vector< int > facet_ptr_ = {0}
 
std::vector< int > corner_vertex_
 
std::vector< int > corner_adjacent_facet_
 
std::vector< std::array< int, 2 > > edges_
 

Detailed Description

Minimal polygonal surface mesh used as the storage of CMesh2D.

Vertices carry 3D positions (z = 0 for planar meshes), facets are polygons stored as contiguous ranges of corners, and each corner knows the facet across the edge that starts at it. Edges and boundary flags are derived data filled by Navigation::prepare_mesh().

The connectivity semantics (facet gluing, facet flipping and deletion) and the point arithmetic follow geogram's GEO::Mesh, which this class replaces, so that meshes built with it are identical to the ones PolyFEM used to build.

Definition at line 19 of file PolygonMesh.hpp.

Member Function Documentation

◆ bounding_box()

void polyfem::mesh::PolygonMesh::bounding_box ( Point &  min,
Point &  max 
) const

Bounding box of the vertices (min/max are initialized to the largest and lowest doubles, as geogram's get_bbox does).

Definition at line 37 of file PolygonMesh.cpp.

References points_.

Referenced by polyfem::mesh::CMesh2D::bounding_box(), and polyfem::mesh::CMesh2D::normalize().

Here is the caller graph for this function:

◆ clear()

void polyfem::mesh::PolygonMesh::clear ( )

Removes all vertices, facets and edges.

Definition at line 10 of file PolygonMesh.cpp.

References boundary_edge, boundary_vertex, corner_adjacent_facet_, corner_edge, corner_vertex_, edges_, facet_ptr_, and points_.

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

Here is the caller graph for this function:

◆ clear_edges()

void polyfem::mesh::PolygonMesh::clear_edges ( )

Definition at line 205 of file PolygonMesh.cpp.

References boundary_edge, and edges_.

Referenced by polyfem::mesh::refine_polygonal_mesh(), and polyfem::mesh::refine_triangle_mesh().

Here is the caller graph for this function:

◆ clear_facets()

void polyfem::mesh::PolygonMesh::clear_facets ( )

Removes all facets, keeping the vertices and the edges.

Definition at line 85 of file PolygonMesh.cpp.

References corner_adjacent_facet_, corner_edge, corner_vertex_, and facet_ptr_.

Referenced by polyfem::mesh::refine_polygonal_mesh(), and polyfem::mesh::refine_triangle_mesh().

Here is the caller graph for this function:

◆ connect_facets()

void polyfem::mesh::PolygonMesh::connect_facets ( )

Glues every corner without neighbor to the facet sharing its edge in opposite orientation (already glued corners are kept).

Definition at line 126 of file PolygonMesh.cpp.

References corner_adjacent_facet_, corner_vertex_, corners_begin(), corners_end(), n_corners(), n_facets(), n_vertices(), next_corner_around_facet(), and prev_corner_around_facet().

Here is the call graph for this function:

◆ connected_components()

int polyfem::mesh::PolygonMesh::connected_components ( std::vector< int > &  component) const

Assigns to each facet the index of its connected component (through the corner adjacency) and returns the number of components.

Definition at line 168 of file PolygonMesh.cpp.

References corner_adjacent_facet_, corners_begin(), corners_end(), and n_facets().

Here is the call graph for this function:

◆ corner_adjacent_facet()

int polyfem::mesh::PolygonMesh::corner_adjacent_facet ( const int  c) const
inline

Facet across the edge from corner c to the next corner of its facet, or -1.

Definition at line 77 of file PolygonMesh.hpp.

◆ corner_vertex()

int polyfem::mesh::PolygonMesh::corner_vertex ( const int  c) const
inline

Definition at line 75 of file PolygonMesh.hpp.

◆ corners_begin()

int polyfem::mesh::PolygonMesh::corners_begin ( const int  f) const
inline

Definition at line 72 of file PolygonMesh.hpp.

Referenced by connect_facets(), connected_components(), delete_facets(), and flip_facet().

Here is the caller graph for this function:

◆ corners_end()

int polyfem::mesh::PolygonMesh::corners_end ( const int  f) const
inline

Definition at line 73 of file PolygonMesh.hpp.

Referenced by connect_facets(), connected_components(), and delete_facets().

Here is the caller graph for this function:

◆ create_edge()

int polyfem::mesh::PolygonMesh::create_edge ( int  v0,
int  v1 
)

Definition at line 198 of file PolygonMesh.cpp.

References boundary_edge, and edges_.

◆ create_polygon()

int polyfem::mesh::PolygonMesh::create_polygon ( const std::vector< int > &  vertices)

Appends a polygon (not glued to its neighbors) and returns its index.

Definition at line 54 of file PolygonMesh.cpp.

References corner_adjacent_facet_, corner_edge, corner_vertex_, facet_ptr_, n_facets(), and n_vertices().

Referenced by polyfem::mesh::CMesh2D::append(), polyfem::mesh::CMesh2D::build_topology(), polyfem::mesh::refine_polygonal_mesh(), and polyfem::mesh::refine_triangle_mesh().

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

◆ create_vertex()

int polyfem::mesh::PolygonMesh::create_vertex ( const Point &  p)

Appends a vertex and returns its index.

Definition at line 30 of file PolygonMesh.cpp.

References create_vertices(), and points_.

Here is the call graph for this function:

◆ create_vertices()

int polyfem::mesh::PolygonMesh::create_vertices ( int  n)

Appends n vertices at the origin and returns the index of the first one.

Definition at line 22 of file PolygonMesh.cpp.

References boundary_vertex, n_vertices(), and points_.

Referenced by polyfem::mesh::CMesh2D::append(), polyfem::mesh::CMesh2D::build_topology(), and create_vertex().

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

◆ delete_facets()

void polyfem::mesh::PolygonMesh::delete_facets ( const std::vector< bool > &  to_delete)

Removes the facets f with to_delete[f], keeping all vertices, and renumbers the remaining facets (and the corner adjacency) in order.

Definition at line 93 of file PolygonMesh.cpp.

References corner_adjacent_facet_, corner_edge, corner_vertex_, corners_begin(), corners_end(), facet_ptr_, and n_facets().

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

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

◆ edge_vertex()

int polyfem::mesh::PolygonMesh::edge_vertex ( const int  e,
const int  lv 
) const
inline

Definition at line 105 of file PolygonMesh.hpp.

Referenced by polyfem::mesh::CMesh2D::edge_barycenter(), polyfem::mesh::CMesh2D::edge_length(), polyfem::mesh::CMesh2D::edge_vertex(), and polyfem::mesh::CMesh2D::refine().

Here is the caller graph for this function:

◆ facet_corner()

int polyfem::mesh::PolygonMesh::facet_corner ( const int  f,
const int  lv 
) const
inline

Definition at line 74 of file PolygonMesh.hpp.

◆ facet_vertex()

int polyfem::mesh::PolygonMesh::facet_vertex ( const int  f,
const int  lv 
) const
inline

Definition at line 69 of file PolygonMesh.hpp.

Referenced by polyfem::mesh::CMesh2D::append(), polyfem::mesh::CMesh2D::attach_higher_order_nodes(), polyfem::mesh::CMesh2D::cell_vertex(), polyfem::mesh::CMesh2D::face_vertex(), polyfem::mesh::refine_polygonal_mesh(), and polyfem::mesh::refine_triangle_mesh().

Here is the caller graph for this function:

◆ flip_facet()

void polyfem::mesh::PolygonMesh::flip_facet ( int  f)

Reverses the orientation of facet f (its vertex list is reversed).

Definition at line 68 of file PolygonMesh.cpp.

References corner_adjacent_facet_, corner_vertex_, corners_begin(), and n_facet_vertices().

Here is the call graph for this function:

◆ n_corners()

int polyfem::mesh::PolygonMesh::n_corners ( ) const
inline

Definition at line 71 of file PolygonMesh.hpp.

Referenced by connect_facets().

Here is the caller graph for this function:

◆ n_edges()

int polyfem::mesh::PolygonMesh::n_edges ( ) const
inline

Definition at line 104 of file PolygonMesh.hpp.

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

Here is the caller graph for this function:

◆ n_facet_vertices()

int polyfem::mesh::PolygonMesh::n_facet_vertices ( const int  f) const
inline

Definition at line 68 of file PolygonMesh.hpp.

Referenced by polyfem::mesh::CMesh2D::append(), flip_facet(), polyfem::mesh::CMesh2D::n_face_vertices(), polyfem::mesh::refine_polygonal_mesh(), and polyfem::mesh::refine_triangle_mesh().

Here is the caller graph for this function:

◆ n_facets()

int polyfem::mesh::PolygonMesh::n_facets ( ) const
inline

Definition at line 67 of file PolygonMesh.hpp.

Referenced by connect_facets(), connected_components(), create_polygon(), delete_facets(), polyfem::mesh::CMesh2D::n_faces(), polyfem::mesh::refine_polygonal_mesh(), polyfem::mesh::refine_triangle_mesh(), and polyfem::mesh::CMesh2D::remove_elements().

Here is the caller graph for this function:

◆ n_vertices()

int polyfem::mesh::PolygonMesh::n_vertices ( ) const
inline

Definition at line 52 of file PolygonMesh.hpp.

Referenced by polyfem::mesh::CMesh2D::append(), connect_facets(), create_polygon(), create_vertices(), polyfem::mesh::CMesh2D::n_vertices(), polyfem::mesh::CMesh2D::normalize(), polyfem::mesh::CMesh2D::refine(), polyfem::mesh::refine_polygonal_mesh(), and polyfem::mesh::refine_triangle_mesh().

Here is the caller graph for this function:

◆ next_corner_around_facet()

int polyfem::mesh::PolygonMesh::next_corner_around_facet ( const int  f,
const int  c 
) const
inline

Definition at line 78 of file PolygonMesh.hpp.

Referenced by connect_facets().

Here is the caller graph for this function:

◆ point() [1/2]

Point & polyfem::mesh::PolygonMesh::point ( const int  v)
inline

Definition at line 54 of file PolygonMesh.hpp.

◆ point() [2/2]

const Point & polyfem::mesh::PolygonMesh::point ( const int  v) const
inline

Definition at line 53 of file PolygonMesh.hpp.

Referenced by polyfem::mesh::CMesh2D::build_topology(), polyfem::mesh::CMesh2D::normalize(), polyfem::mesh::CMesh2D::point(), and polyfem::mesh::CMesh2D::set_point().

Here is the caller graph for this function:

◆ prev_corner_around_facet()

int polyfem::mesh::PolygonMesh::prev_corner_around_facet ( const int  f,
const int  c 
) const
inline

Definition at line 79 of file PolygonMesh.hpp.

Referenced by connect_facets().

Here is the caller graph for this function:

Member Data Documentation

◆ boundary_edge

std::vector<bool> polyfem::mesh::PolygonMesh::boundary_edge

Whether each edge is on the boundary.

Definition at line 112 of file PolygonMesh.hpp.

Referenced by clear(), clear_edges(), create_edge(), and polyfem::mesh::CMesh2D::is_boundary_edge().

◆ boundary_vertex

std::vector<bool> polyfem::mesh::PolygonMesh::boundary_vertex

Whether each vertex is on the boundary.

Definition at line 114 of file PolygonMesh.hpp.

Referenced by clear(), create_vertices(), and polyfem::mesh::CMesh2D::is_boundary_vertex().

◆ corner_adjacent_facet_

std::vector<int> polyfem::mesh::PolygonMesh::corner_adjacent_facet_
private

◆ corner_edge

std::vector<int> polyfem::mesh::PolygonMesh::corner_edge

Index of the edge starting at each corner.

Definition at line 110 of file PolygonMesh.hpp.

Referenced by clear(), clear_facets(), create_polygon(), and delete_facets().

◆ corner_vertex_

std::vector<int> polyfem::mesh::PolygonMesh::corner_vertex_
private

◆ edges_

std::vector<std::array<int, 2> > polyfem::mesh::PolygonMesh::edges_
private

Definition at line 121 of file PolygonMesh.hpp.

Referenced by clear(), clear_edges(), and create_edge().

◆ facet_ptr_

std::vector<int> polyfem::mesh::PolygonMesh::facet_ptr_ = {0}
private

Definition at line 118 of file PolygonMesh.hpp.

Referenced by clear(), clear_facets(), create_polygon(), and delete_facets().

◆ points_

std::vector<Point> polyfem::mesh::PolygonMesh::points_
private

Definition at line 117 of file PolygonMesh.hpp.

Referenced by bounding_box(), clear(), create_vertex(), and create_vertices().


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