27#ifndef EASY3D_CORE_POLYHEDRAL_MESH_H
28#define EASY3D_CORE_POLYHEDRAL_MESH_H
30#include <easy3d/core/model.h>
34#include <easy3d/core/types.h>
35#include <easy3d/core/property.h>
70 int idx()
const {
return idx_; }
89 return idx_ == _rhs.idx_;
98 return idx_ != _rhs.idx_;
107 return idx_ < _rhs.idx_;
142 std::ostream&
operator<<(std::ostream& os)
const {
return os <<
'v' <<
idx(); }
160 std::ostream&
operator<<(std::ostream& os)
const {
return os <<
'e' <<
idx(); }
178 std::ostream&
operator<<(std::ostream& os)
const {
return os <<
'h' <<
idx(); }
196 std::ostream&
operator<<(std::ostream& os)
const {
return os <<
'f' <<
idx(); }
214 std::ostream&
operator<<(std::ostream& os)
const {
return os <<
'c' <<
idx(); }
233 void read(std::istream& in);
238 void write(std::ostream& out)
const;
253 void read(std::istream& in);
258 void write(std::ostream& out)
const;
274 void read(std::istream& in);
279 void write(std::ostream& out)
const;
294 void read(std::istream& in);
299 void write(std::ostream& out)
const;
551 return (hnd_==rhs.hnd_);
615 return (hnd_==rhs.hnd_);
680 return (hnd_==rhs.hnd_);
745 return (hnd_==rhs.hnd_);
810 return (hnd_==rhs.hnd_);
1036 bool read(
const std::string& filename);
1044 bool write(
const std::string& filename)
const;
1085 Cell
add_tetra(Vertex v0, Vertex v1, Vertex v2, Vertex v3);
1112 Cell
add_hexa(Vertex v0, Vertex v1, Vertex v2, Vertex v3, Vertex v4, Vertex v5, Vertex v6, Vertex v7);
1151 unsigned int n_vertices()
const {
return (
unsigned int) vprops_.size(); }
1156 unsigned int n_edges()
const {
return (
unsigned int) eprops_.size(); }
1161 unsigned int n_halffaces()
const {
return (
unsigned int) hprops_.size(); }
1166 unsigned int n_faces()
const {
return (
unsigned int) fprops_.size(); }
1171 unsigned int n_cells()
const {
return (
unsigned int) cprops_.size(); }
1188 void resize(
unsigned int nv,
unsigned int ne,
unsigned int nf,
unsigned int nc) {
1191 hprops_.resize(2 * nf);
1530 return vprops_.rename(old_name, new_name);
1539 return hprops_.rename(old_name, new_name);
1548 return fprops_.rename(old_name, new_name);
1557 return eprops_.rename(old_name, new_name);
1566 return cprops_.rename(old_name, new_name);
1575 return mprops_.rename(old_name, new_name);
1584 return vprops_.get_type(
name);
1592 return eprops_.get_type(
name);
1600 return hprops_.get_type(
name);
1608 return fprops_.get_type(
name);
1616 return cprops_.get_type(
name);
1624 return mprops_.get_type(
name);
1633 return vprops_.properties();
1640 return eprops_.properties();
1647 return hprops_.properties();
1654 return fprops_.properties();
1661 return cprops_.properties();
1668 return mprops_.properties();
1816 return vconn_[v].vertices_;
1827 return HalfFace(
static_cast<int>((f.
idx() << 1) + i));
1845 return hconn_[h].opposite_;
1856 return econn_[e].vertices_[i];
1866 return hconn_[h].vertices_;
1884 return cconn_[c].vertices_;
1893 return vconn_[v].edges_;
1902 return hconn_[h].edges_;
1911 return cconn_[c].edges_;
1920 return vconn_[v].halffaces_;
1929 return econn_[e].halffaces_;
1938 return cconn_[c].halffaces_;
1947 return vconn_[v].cells_;
1956 return econn_[e].cells_;
1965 return hconn_[h].cell_;
2026 Edge
find_edge(Vertex a, Vertex b)
const;
2065 const std::vector<vec3>&
points()
const override {
return vpoint_.vector(); }
2071 std::vector<vec3>&
points()
override {
return vpoint_.vector(); }
2109 return Vertex(
static_cast<int>(
n_vertices()-1));
2113 Edge new_edge(Vertex s, Vertex t)
2117 Edge e = Edge(
static_cast<int>(
n_edges() - 1));
2118 econn_[e].vertices_ = {s, t};
2119 vconn_[s].edges_.insert(e);
2120 vconn_[t].edges_.insert(e);
2121 vconn_[s].vertices_.insert(t);
2122 vconn_[t].vertices_.insert(s);
2129 fprops_.push_back();
2130 hprops_.push_back();
2131 hprops_.push_back();
2135 hconn_[h0].opposite_ = h1;
2136 hconn_[h1].opposite_ = h0;
2144 cprops_.push_back();
2150 PropertyContainer vprops_;
2151 PropertyContainer eprops_;
2152 PropertyContainer hprops_;
2153 PropertyContainer fprops_;
2154 PropertyContainer cprops_;
2155 PropertyContainer mprops_;
2171 return (os <<
'v' << v.
idx());
2177 return (os <<
'e' << e.
idx());
2183 return (os <<
'h' << h.
idx());
2189 return (os <<
'f' << f.
idx());
2195 return (os <<
'c' << c.
idx());
const std::string & name() const
The name of a model.
Definition model.h:61
Model(const std::string &name="unknown")
Default constructor. The parameter name is optional, but it is useful for handling multiple models wi...
Definition model.cpp:33
bool operator!=(const BaseHandle &_rhs) const
Are two handles different?
Definition poly_mesh.h:97
bool is_valid() const
Return whether the handle is valid, i.e., the index is not equal to -1.
Definition poly_mesh.h:81
int idx() const
Return the index of the handle.
Definition poly_mesh.h:70
bool operator<(const BaseHandle &_rhs) const
Compare operator useful for sorting handles.
Definition poly_mesh.h:106
bool operator==(const BaseHandle &_rhs) const
Are two handles equal?
Definition poly_mesh.h:88
void reset()
Reset handle to be invalid (index = -1).
Definition poly_mesh.h:75
BaseHandle(int _idx=-1)
Constructor.
Definition poly_mesh.h:64
This helper class is a container for iterating through all cells using C++11 range-based for-loops.
Definition poly_mesh.h:967
CellIterator begin() const
Get the beginning iterator.
Definition poly_mesh.h:979
CellIterator end() const
Get the ending iterator.
Definition poly_mesh.h:984
CellContainer(CellIterator _begin, CellIterator _end)
Constructor.
Definition poly_mesh.h:974
Cell iterator for PolyMesh. This class iterates linearly over all cells.
Definition poly_mesh.h:789
bool operator==(const CellIterator &rhs) const
Are two iterators equal?
Definition poly_mesh.h:809
bool operator!=(const CellIterator &rhs) const
Are two iterators different?
Definition poly_mesh.h:818
CellIterator & operator--()
Pre-decrement iterator.
Definition poly_mesh.h:836
Cell operator*() const
Get the cell the iterator refers to.
Definition poly_mesh.h:802
CellIterator & operator++()
Pre-increment iterator.
Definition poly_mesh.h:826
CellIterator(Cell c=Cell(), const PolyMesh *m=nullptr)
Default constructor.
Definition poly_mesh.h:796
Cell property of type T.
Definition poly_mesh.h:454
Property< T >::const_reference operator[](Cell c) const
Access the data stored for cell c.
Definition poly_mesh.h:480
CellProperty(Property< T > p)
Constructor with property.
Definition poly_mesh.h:464
Property< T >::reference operator[](Cell c)
Access the data stored for cell c.
Definition poly_mesh.h:471
CellProperty()=default
Default constructor.
This helper class is a container for iterating through all edges using C++11 range-based for-loops.
Definition poly_mesh.h:883
EdgeIterator begin() const
Get the beginning iterator.
Definition poly_mesh.h:895
EdgeIterator end() const
Get the ending iterator.
Definition poly_mesh.h:900
EdgeContainer(EdgeIterator _begin, EdgeIterator _end)
Constructor.
Definition poly_mesh.h:890
Edge iterator for PolyMesh. This class iterates linearly over all edges.
Definition poly_mesh.h:594
bool operator!=(const EdgeIterator &rhs) const
Are two iterators different?
Definition poly_mesh.h:623
EdgeIterator & operator++()
Pre-increment iterator.
Definition poly_mesh.h:631
Edge operator*() const
Get the edge the iterator refers to.
Definition poly_mesh.h:607
bool operator==(const EdgeIterator &rhs) const
Are two iterators equal?
Definition poly_mesh.h:614
EdgeIterator(Edge e=Edge(), const PolyMesh *m=nullptr)
Default constructor.
Definition poly_mesh.h:601
EdgeIterator & operator--()
Pre-decrement iterator.
Definition poly_mesh.h:641
Edge property of type T.
Definition poly_mesh.h:346
EdgeProperty()=default
Default constructor.
Property< T >::reference operator[](Edge e)
Access the data stored for edge e.
Definition poly_mesh.h:363
Property< T >::const_reference operator[](Edge e) const
Access the data stored for edge e.
Definition poly_mesh.h:372
EdgeProperty(Property< T > p)
Constructor with property.
Definition poly_mesh.h:356
This helper class is a container for iterating through all faces using C++11 range-based for-loops.
Definition poly_mesh.h:939
FaceContainer(FaceIterator _begin, FaceIterator _end)
Constructor.
Definition poly_mesh.h:946
FaceIterator begin() const
Get the beginning iterator.
Definition poly_mesh.h:951
FaceIterator end() const
Get the ending iterator.
Definition poly_mesh.h:956
Face iterator for PolyMesh. This class iterates linearly over all faces.
Definition poly_mesh.h:724
bool operator!=(const FaceIterator &rhs) const
Are two iterators different?
Definition poly_mesh.h:753
bool operator==(const FaceIterator &rhs) const
Are two iterators equal?
Definition poly_mesh.h:744
FaceIterator & operator--()
Pre-decrement iterator.
Definition poly_mesh.h:771
FaceIterator(Face f=Face(), const PolyMesh *m=nullptr)
Default constructor.
Definition poly_mesh.h:731
Face operator*() const
Get the face the iterator refers to.
Definition poly_mesh.h:737
FaceIterator & operator++()
Pre-increment iterator.
Definition poly_mesh.h:761
Face property of type T.
Definition poly_mesh.h:418
Property< T >::reference operator[](Face f)
Access the data stored for face f.
Definition poly_mesh.h:435
FaceProperty(Property< T > p)
Constructor with property.
Definition poly_mesh.h:428
FaceProperty()=default
Default constructor.
Property< T >::const_reference operator[](Face f) const
Access the data stored for face f.
Definition poly_mesh.h:444
HalfFace iterator for PolyMesh. This class iterates linearly over all halffaces.
Definition poly_mesh.h:659
HalfFaceIterator & operator++()
Pre-increment iterator.
Definition poly_mesh.h:696
HalfFaceIterator(HalfFace h=HalfFace(), const PolyMesh *m=nullptr)
Default constructor.
Definition poly_mesh.h:666
HalfFaceIterator & operator--()
Pre-decrement iterator.
Definition poly_mesh.h:706
bool operator!=(const HalfFaceIterator &rhs) const
Are two iterators different?
Definition poly_mesh.h:688
HalfFace operator*() const
Get the halfface the iterator refers to.
Definition poly_mesh.h:672
bool operator==(const HalfFaceIterator &rhs) const
Are two iterators equal?
Definition poly_mesh.h:679
HalfFace property of type T.
Definition poly_mesh.h:382
Property< T >::const_reference operator[](HalfFace h) const
Access the data stored for halfface h.
Definition poly_mesh.h:408
HalfFaceProperty(Property< T > p)
Constructor with property.
Definition poly_mesh.h:392
Property< T >::reference operator[](HalfFace h)
Access the data stored for halfface h.
Definition poly_mesh.h:399
HalfFaceProperty()=default
Default constructor.
This helper class is a container for iterating through all halffaces using C++11 range-based for-loop...
Definition poly_mesh.h:911
HalfFaceIterator end() const
Get the ending iterator.
Definition poly_mesh.h:928
HalfFaceIterator begin() const
Get the beginning iterator.
Definition poly_mesh.h:923
HalffaceContainer(HalfFaceIterator _begin, HalfFaceIterator _end)
Constructor.
Definition poly_mesh.h:918
Model property of type T.
Definition poly_mesh.h:491
ModelProperty()=default
Default constructor.
ModelProperty(Property< T > p)
Constructor with property.
Definition poly_mesh.h:501
Property< T >::const_reference operator[](size_t idx) const
Access the data stored for the mesh.
Definition poly_mesh.h:517
Property< T >::reference operator[](size_t idx)
Access the data stored for the mesh.
Definition poly_mesh.h:508
This helper class is a container for iterating through all vertices using C++11 range-based for-loops...
Definition poly_mesh.h:855
VertexContainer(VertexIterator _begin, VertexIterator _end)
Constructor.
Definition poly_mesh.h:862
VertexIterator begin() const
Get the beginning iterator.
Definition poly_mesh.h:867
VertexIterator end() const
Get the ending iterator.
Definition poly_mesh.h:872
Vertex iterator for PolyMesh. This class iterates linearly over all vertices.
Definition poly_mesh.h:530
VertexIterator(Vertex v=Vertex(), const PolyMesh *m=nullptr)
Default constructor.
Definition poly_mesh.h:537
Vertex operator*() const
Get the vertex the iterator refers to.
Definition poly_mesh.h:543
bool operator==(const VertexIterator &rhs) const
Are two iterators equal?
Definition poly_mesh.h:550
VertexIterator & operator--()
Pre-decrement iterator.
Definition poly_mesh.h:577
bool operator!=(const VertexIterator &rhs) const
Are two iterators different?
Definition poly_mesh.h:559
VertexIterator & operator++()
Pre-increment iterator.
Definition poly_mesh.h:567
Vertex property of type T.
Definition poly_mesh.h:310
VertexProperty(Property< T > p)
Constructor with property.
Definition poly_mesh.h:320
Property< T >::const_reference operator[](Vertex v) const
Access the data stored for vertex v.
Definition poly_mesh.h:336
Property< T >::reference operator[](Vertex v)
Access the data stored for vertex v.
Definition poly_mesh.h:327
VertexProperty()=default
Default constructor.
Data structure representing a polyhedral mesh.
Definition poly_mesh.h:49
const vec3 & position(Vertex v) const
Returns the position of a vertex.
Definition poly_mesh.h:2059
const std::set< HalfFace > & halffaces(Edge e) const
Returns the set of halffaces around edge e.
Definition poly_mesh.h:1928
HalfFace opposite(HalfFace h) const
Returns the twin halfface of halfface h.
Definition poly_mesh.h:1844
bool is_border(Vertex v) const
Returns whether v is a boundary vertex, i.e., at least one of its incident halffaces is not associate...
Definition poly_mesh.h:1986
EdgeContainer edges() const
Returns a container for range-based iteration over edges.
Definition poly_mesh.h:1728
HalfFace find_half_face(const std::vector< Vertex > &vertices) const
Definition poly_mesh.cpp:417
const std::type_info & get_vertex_property_type(const std::string &name) const
Get the type information of the vertex property name.
Definition poly_mesh.h:1583
unsigned int n_faces() const
Returns number of faces in the mesh.
Definition poly_mesh.h:1166
void extract_boundary(std::vector< std::vector< Vertex > > &faces) const
Definition poly_mesh.cpp:686
const std::vector< Vertex > & vertices(Face f) const
Returns the set of vertices around face f.
Definition poly_mesh.h:1874
bool remove_vertex_property(const std::string &n)
Remove the vertex property named n.
Definition poly_mesh.h:1456
const std::set< Edge > & edges(Cell c) const
Returns the set of edges around cell c.
Definition poly_mesh.h:1910
EdgeIterator edges_end() const
Returns an iterator to the end of the edges.
Definition poly_mesh.h:1720
HalfFace add_triangle(Vertex v0, Vertex v1, Vertex v2)
Add a new triangle face connecting vertices v0, v1, v2.
Definition poly_mesh.h:1128
CellIterator cells_begin() const
Returns an iterator to the beginning of the cells.
Definition poly_mesh.h:1784
unsigned int n_edges() const
Returns number of edges in the mesh.
Definition poly_mesh.h:1156
bool is_valid(Edge e) const
Return whether edge e is valid, i.e. the index is stored within the array bounds.
Definition poly_mesh.h:1209
bool rename_vertex_property(const std::string &old_name, const std::string &new_name)
Rename a vertex property given its name.
Definition poly_mesh.h:1529
const std::vector< Vertex > & vertices(HalfFace h) const
Returns the set of vertices around halfface h. The vertices are ordered in a way such that its normal...
Definition poly_mesh.h:1865
std::vector< std::string > halfface_properties() const
Get the names of all halfface properties.
Definition poly_mesh.h:1646
HalfFaceProperty< T > add_halfface_property(const std::string &name, const T t=T())
Add a halfface property of type T with name name and default value t.
Definition poly_mesh.h:1275
const std::set< Cell > & cells(Vertex v) const
Returns the set of cells around vertex v.
Definition poly_mesh.h:1946
PolyMesh()
Default constructor.
Definition poly_mesh.cpp:133
HalfFaceIterator halffaces_begin() const
Returns an iterator to the beginning of the halffaces.
Definition poly_mesh.h:1736
VertexContainer vertices() const
Returns a container for range-based iteration over vertices.
Definition poly_mesh.h:1704
FaceProperty< T > get_face_property(const std::string &name) const
Get the face property with name name of type T.
Definition poly_mesh.h:1349
const std::set< Cell > & cells(Edge e) const
Returns the set of cells around edge e.
Definition poly_mesh.h:1955
const std::type_info & get_edge_property_type(const std::string &name) const
Get the type information of the edge property name.
Definition poly_mesh.h:1591
bool remove_halfface_property(HalfFaceProperty< T > &p)
Remove the halfface property p.
Definition poly_mesh.h:1476
HalfFace add_quad(Vertex v0, Vertex v1, Vertex v2, Vertex v3)
Add a new quad face connecting vertices v0, v1, v2, v3.
Definition poly_mesh.h:1138
bool rename_face_property(const std::string &old_name, const std::string &new_name)
Rename a face property given its name.
Definition poly_mesh.h:1547
const std::vector< HalfFace > & halffaces(Cell c) const
Returns the set of halffaces around cell c.
Definition poly_mesh.h:1937
VertexProperty< T > vertex_property(const std::string &name, const T t=T())
If a vertex property of type T with name name exists, it is returned. Otherwise, this property is add...
Definition poly_mesh.h:1384
const std::set< Vertex > & vertices(Vertex v) const
Returns the vertices around vertex v.
Definition poly_mesh.h:1815
std::vector< std::string > face_properties() const
Get the names of all face properties.
Definition poly_mesh.h:1653
const std::set< Edge > & edges(HalfFace h) const
Returns the set of edges around halfface h.
Definition poly_mesh.h:1901
const std::set< Vertex > & vertices(Cell c) const
Returns the set of vertices around cell c.
Definition poly_mesh.h:1883
FaceContainer faces() const
Returns a container for range-based iteration over faces.
Definition poly_mesh.h:1776
ModelProperty< T > get_model_property(const std::string &name) const
Gets the model property named name of type T.
Definition poly_mesh.h:1372
std::vector< std::string > vertex_properties() const
Get the names of all vertex properties.
Definition poly_mesh.h:1632
void update_face_normals()
Computes face normals by calling compute_face_normal(HalfFace) for each face.
Definition poly_mesh.cpp:549
vec3 compute_face_normal(Face f) const
Computes the normal vector of face f.
Definition poly_mesh.cpp:572
EdgeProperty< T > get_edge_property(const std::string &name) const
Get the edge property with name name of type T.
Definition poly_mesh.h:1331
const std::type_info & get_face_property_type(const std::string &name) const
Get the type information of the face property name.
Definition poly_mesh.h:1607
Cell add_hexa(Vertex v0, Vertex v1, Vertex v2, Vertex v3, Vertex v4, Vertex v5, Vertex v6, Vertex v7)
Add a new hexahedron connecting vertices v0, v1, v2, v3, v4, v5, v6, v7.
Definition poly_mesh.cpp:519
EdgeIterator edges_begin() const
Returns an iterator to the beginning of the edges.
Definition poly_mesh.h:1712
HalfFaceIterator halffaces_end() const
Returns an iterator to the end of the halffaces.
Definition poly_mesh.h:1744
FaceIterator faces_begin() const
Returns an iterator to the beginning of the faces.
Definition poly_mesh.h:1760
Cell add_cell(const std::vector< HalfFace > &faces)
Add a new cell defined by faces.
Definition poly_mesh.cpp:479
VertexProperty< T > get_vertex_property(const std::string &name) const
Get the vertex property with name name of type T.
Definition poly_mesh.h:1322
bool remove_face_property(const std::string &n)
Remove the face property named n.
Definition poly_mesh.h:1495
void resize(unsigned int nv, unsigned int ne, unsigned int nf, unsigned int nc)
Resizes space for vertices, edges, halffaces, and their currently associated properties.
Definition poly_mesh.h:1188
const std::set< Edge > & edges(Vertex v) const
Returns the set of edges around vertex v.
Definition poly_mesh.h:1892
Edge find_edge(Vertex a, Vertex b) const
Definition poly_mesh.cpp:408
std::vector< std::string > edge_properties() const
Get the names of all edge properties.
Definition poly_mesh.h:1639
bool read(const std::string &filename)
Read mesh from a PM file filename.
Definition poly_mesh.cpp:220
std::vector< std::string > model_properties() const
Get the names of all model properties.
Definition poly_mesh.h:1667
bool is_tetraheral_mesh() const
Returns whether the mesh is a tetrahedral mesh, i.e., every cell is a tetrahedron.
Definition poly_mesh.cpp:670
CellContainer cells() const
Returns a container for range-based iteration over cells.
Definition poly_mesh.h:1800
bool is_border(HalfFace h) const
Returns whether h is a boundary halfface, i.e., it is not associated with a cell.
Definition poly_mesh.h:2007
bool rename_edge_property(const std::string &old_name, const std::string &new_name)
Rename an edge property given its name.
Definition poly_mesh.h:1556
HalffaceContainer halffaces() const
Returns a container for range-based iteration over halffaces.
Definition poly_mesh.h:1752
bool remove_halfface_property(const std::string &n)
Remove the halfface property named n.
Definition poly_mesh.h:1482
const std::type_info & get_model_property_type(const std::string &name) const
Get the type information of the model property name.
Definition poly_mesh.h:1623
std::vector< vec3 > & points() override
Returns a modifiable vector of all vertex positions.
Definition poly_mesh.h:2071
CellProperty< T > cell_property(const std::string &name, const T t=T())
If a cell property of type T with name name exists, it is returned. Otherwise, this property is added...
Definition poly_mesh.h:1428
bool remove_face_property(FaceProperty< T > &p)
Remove the face property p.
Definition poly_mesh.h:1489
const std::type_info & get_halfface_property_type(const std::string &name) const
Get the type information of the halfface property name.
Definition poly_mesh.h:1599
bool remove_edge_property(const std::string &n)
Remove the edge property named n.
Definition poly_mesh.h:1469
ModelProperty< T > model_property(const std::string &name, const T t=T())
If a model property of type T with name name exists, it is returned. Otherwise, this property is adde...
Definition poly_mesh.h:1439
bool remove_cell_property(const std::string &n)
Remove the cell property named n.
Definition poly_mesh.h:1508
Cell cell(HalfFace h) const
Returns the cell associated with halfface h.
Definition poly_mesh.h:1964
VertexProperty< T > add_vertex_property(const std::string &name, const T t=T())
Add a vertex property of type T with name name and default value t.
Definition poly_mesh.h:1253
bool remove_model_property(ModelProperty< T > &p)
Remove the model property p.
Definition poly_mesh.h:1515
PolyMesh & assign(const PolyMesh &rhs)
Assign rhs to *this. Does not copy custom properties.
Definition poly_mesh.cpp:179
FaceProperty< T > face_property(const std::string &name, const T t=T())
If a face property of type T with name name exists, it is returned. Otherwise, this property is added...
Definition poly_mesh.h:1417
PolyMesh & operator=(const PolyMesh &rhs)
Assign rhs to *this. Performs a deep copy of all properties.
Definition poly_mesh.cpp:151
FaceProperty< T > add_face_property(const std::string &name, const T t=T())
Add a face property of type T with name name and default value t.
Definition poly_mesh.h:1286
bool is_valid(HalfFace h) const
Return whether halfface h is valid, i.e. the index is stored within the array bounds.
Definition poly_mesh.h:1217
bool remove_cell_property(CellProperty< T > &p)
Remove the cell property p.
Definition poly_mesh.h:1502
bool rename_model_property(const std::string &old_name, const std::string &new_name)
Rename a model property given its name.
Definition poly_mesh.h:1574
unsigned int n_halffaces() const
Returns number of halffaces in the mesh.
Definition poly_mesh.h:1161
ModelProperty< T > add_model_property(const std::string &name, const T t=T())
Adds a model property of type T with name name and default value t.
Definition poly_mesh.h:1312
HalfFace add_face(const std::vector< Vertex > &vertices)
Add a new face connecting vertices.
Definition poly_mesh.cpp:450
CellProperty< T > get_cell_property(const std::string &name) const
Get the cell property with name name of type T.
Definition poly_mesh.h:1358
CellProperty< T > add_cell_property(const std::string &name, const T t=T())
Add a cell property of type T with name name and default value t.
Definition poly_mesh.h:1297
PolyMesh(const PolyMesh &rhs)
Copy constructor: copies rhs to *this. Performs a deep copy of all properties.
Definition poly_mesh.h:1009
HalfFaceProperty< T > get_halfface_property(const std::string &name) const
Get the halfface property with name name of type T.
Definition poly_mesh.h:1340
bool write(const std::string &filename) const
Write mesh to a PM file filename.
Definition poly_mesh.cpp:263
Vertex add_vertex(const vec3 &p)
Add a new vertex.
Definition poly_mesh.h:1057
bool is_valid(Face f) const
Return whether face f is valid, i.e. the index is stored within the array bounds.
Definition poly_mesh.h:1225
CellIterator cells_end() const
Returns an iterator to the end of the cells.
Definition poly_mesh.h:1792
Face face(HalfFace h) const
Returns the face of HalfFace h.
Definition poly_mesh.h:1835
bool is_border(Face f) const
Returns whether f is a boundary face, i.e., it is incident to only one cell.
Definition poly_mesh.h:2016
EdgeProperty< T > edge_property(const std::string &name, const T t=T())
If an edge property of type T with name name exists, it is returned. Otherwise, this property is adde...
Definition poly_mesh.h:1395
bool remove_edge_property(EdgeProperty< T > &p)
Remove the edge property p.
Definition poly_mesh.h:1463
HalfFaceProperty< T > halfface_property(const std::string &name, const T t=T())
If a halfface property of type T with name name exists, it is returned. Otherwise,...
Definition poly_mesh.h:1406
void property_stats(std::ostream &output) const override
Prints the names of all properties to an output stream (e.g., std::cout).
Definition poly_mesh.cpp:343
void update_vertex_normals()
Computes vertex normals for each vertex.
Definition poly_mesh.cpp:599
FaceIterator faces_end() const
Returns an iterator to the end of the faces.
Definition poly_mesh.h:1768
const std::type_info & get_cell_property_type(const std::string &name) const
Get the type information of the cell property name.
Definition poly_mesh.h:1615
HalfFace halfface(Face f, unsigned int i) const
Returns the i'th halfface of face f. i has to be 0 or 1.
Definition poly_mesh.h:1825
void clear()
Removes all vertices, edges, halffaces, faces, cells and properties.
Definition poly_mesh.cpp:311
bool rename_halfface_property(const std::string &old_name, const std::string &new_name)
Rename a halfface property given its name.
Definition poly_mesh.h:1538
bool rename_cell_property(const std::string &old_name, const std::string &new_name)
Rename a cell property given its name.
Definition poly_mesh.h:1565
bool remove_model_property(const std::string &n)
Remove the model property named n.
Definition poly_mesh.h:1521
float edge_length(Edge e) const
Computes the length of edge e.
Definition poly_mesh.cpp:633
EdgeProperty< T > add_edge_property(const std::string &name, const T t=T())
Add an edge property of type T with name name and default value t.
Definition poly_mesh.h:1264
bool is_border(Edge e) const
Returns whether e is a boundary edge, i.e., at least one of its incident halffaces is not associated ...
Definition poly_mesh.h:1997
VertexIterator vertices_begin() const
Returns an iterator to the beginning of the vertices.
Definition poly_mesh.h:1689
std::vector< std::string > cell_properties() const
Get the names of all cell properties.
Definition poly_mesh.h:1660
bool remove_vertex_property(VertexProperty< T > &p)
Remove the vertex property p.
Definition poly_mesh.h:1450
bool is_degenerate(Face f) const
Returns whether face f is degenerate, i.e., if it has collinear or coincident vertices.
Definition poly_mesh.cpp:642
VertexIterator vertices_end() const
Returns an iterator to the end of the vertices.
Definition poly_mesh.h:1697
bool is_valid(Vertex v) const
Return whether vertex v is valid, i.e. the index is stored within the array bounds.
Definition poly_mesh.h:1201
Vertex vertex(Edge e, unsigned int i) const
Returns the i'th vertex of edge e. i has to be 0 or 1.
Definition poly_mesh.h:1854
Cell add_tetra(HalfFace f0, HalfFace f1, HalfFace f2, HalfFace f3)
Add a new tetrahedron defined by its faces.
Definition poly_mesh.h:1074
unsigned int n_cells() const
Returns number of cells in the mesh.
Definition poly_mesh.h:1171
bool is_valid(Cell c) const
Return whether cell c is valid, i.e. the index is stored within the array bounds.
Definition poly_mesh.h:1233
~PolyMesh() override=default
Destructor.
const std::vector< vec3 > & points() const override
Returns a read-only vector of all vertex positions.
Definition poly_mesh.h:2065
unsigned int n_vertices() const
Returns number of vertices in the mesh.
Definition poly_mesh.h:1151
const std::set< HalfFace > & halffaces(Vertex v) const
Returns the set of halffaces around vertex v.
Definition poly_mesh.h:1919
void push_back()
Adds a new element to each vector.
Definition property.h:771
PropertyArray< T >::const_reference const_reference
The const reference type of the property.
Definition property.h:329
virtual reference operator[](size_t i)
Accesses the i-th element.
Definition property.h:365
Property(PropertyArray< T > *p=nullptr)
Constructor.
Definition property.h:338
PropertyArray< T >::reference reference
The reference type of the property.
Definition property.h:328
Definition collider.cpp:182
Vec< 3, float > vec3
A 3D point/vector of float type.
Definition types.h:44
std::ostream & operator<<(std::ostream &os, Graph::Vertex v)
Output stream support for Graph::Vertex.
Definition graph.h:1300
Helper structure to be able to use std::unordered_map.
Definition poly_mesh.h:113
std::size_t operator()(const BaseHandle &h) const
Hash function for BaseHandle.
Definition poly_mesh.h:119
Definition poly_mesh.h:286
std::set< Edge > edges_
The edges incident to this cell.
Definition poly_mesh.h:288
std::vector< HalfFace > halffaces_
The halffaces incident to this cell.
Definition poly_mesh.h:289
void write(std::ostream &out) const
Writes the cell connectivity to an output stream.
Definition poly_mesh.cpp:126
void read(std::istream &in)
Reads the cell connectivity from an input stream.
Definition poly_mesh.cpp:119
std::set< Vertex > vertices_
The vertices connected to this cell.
Definition poly_mesh.h:287
Definition poly_mesh.h:203
std::ostream & operator<<(std::ostream &os) const
Output stream support for Cell.
Definition poly_mesh.h:214
Cell(int _idx=-1)
Default constructor (with invalid index).
Definition poly_mesh.h:208
Definition poly_mesh.h:245
std::set< Cell > cells_
The cells incident to this edge.
Definition poly_mesh.h:248
std::vector< Vertex > vertices_
The vertices connected to this edge.
Definition poly_mesh.h:246
void write(std::ostream &out) const
Writes the edge connectivity to an output stream.
Definition poly_mesh.cpp:96
void read(std::istream &in)
Reads the edge connectivity from an input stream.
Definition poly_mesh.cpp:89
std::set< HalfFace > halffaces_
The halffaces incident to this edge.
Definition poly_mesh.h:247
Definition poly_mesh.h:149
std::ostream & operator<<(std::ostream &os) const
Output stream support for Edge.
Definition poly_mesh.h:160
Edge(int _idx=-1)
Default constructor (with invalid index).
Definition poly_mesh.h:154
Definition poly_mesh.h:185
Face(int _idx=-1)
Default constructor (with invalid index).
Definition poly_mesh.h:190
std::ostream & operator<<(std::ostream &os) const
Output stream support for Face.
Definition poly_mesh.h:196
Definition poly_mesh.h:265
std::set< Edge > edges_
The edges incident to this halfface.
Definition poly_mesh.h:267
HalfFace opposite_
The opposite halfface.
Definition poly_mesh.h:269
Cell cell_
The cell incident to this halfface.
Definition poly_mesh.h:268
std::vector< Vertex > vertices_
The vertices connected to this halfface.
Definition poly_mesh.h:266
void write(std::ostream &out) const
Writes the halfface connectivity to an output stream.
Definition poly_mesh.cpp:111
void read(std::istream &in)
Reads the halfface connectivity from an input stream.
Definition poly_mesh.cpp:103
Definition poly_mesh.h:167
std::ostream & operator<<(std::ostream &os) const
Output stream support for HalfFace.
Definition poly_mesh.h:178
HalfFace(int _idx=-1)
Default constructor (with invalid index).
Definition poly_mesh.h:172
Definition poly_mesh.h:224
std::set< Cell > cells_
The cells incident to this vertex.
Definition poly_mesh.h:228
std::set< Edge > edges_
The edges incident to this vertex.
Definition poly_mesh.h:226
void write(std::ostream &out) const
Writes the edge connectivity to an output stream.
Definition poly_mesh.cpp:81
void read(std::istream &in)
Definition poly_mesh.cpp:73
std::set< Vertex > vertices_
The vertices connected to this vertex.
Definition poly_mesh.h:225
std::set< HalfFace > halffaces_
The halffaces incident to this vertex.
Definition poly_mesh.h:227
Definition poly_mesh.h:131
std::ostream & operator<<(std::ostream &os) const
Output stream support for Vertex.
Definition poly_mesh.h:142
Vertex(int _idx=-1)
Default constructor (with invalid index).
Definition poly_mesh.h:136