25#ifndef EASY3D_CORE_SURFACE_MESH_H
26#define EASY3D_CORE_SURFACE_MESH_H
28#include <easy3d/core/model.h>
29#include <easy3d/core/types.h>
30#include <easy3d/core/property.h>
67 int idx()
const {
return idx_; }
77 return idx_ == _rhs.idx_;
82 return idx_ != _rhs.idx_;
87 return idx_ < _rhs.idx_;
92 std::size_t operator()(
const BaseHandle& h)
const {
return h.
idx(); }
107 std::ostream& operator<<(std::ostream& os)
const {
return os <<
'v' <<
idx(); }
117 std::ostream& operator<<(std::ostream& os)
const {
return os <<
'h' <<
idx(); }
127 std::ostream& operator<<(std::ostream& os)
const {
return os <<
'e' <<
idx(); }
137 std::ostream& operator<<(std::ostream& os)
const {
return os <<
'f' <<
idx(); }
295 typename Property<T>::const_reference
operator[](
size_t idx)
const
324 return (hnd_==rhs.hnd_);
376 return (hnd_==rhs.hnd_);
428 return (hnd_==rhs.hnd_);
480 return (hnd_==rhs.hnd_);
600 : mesh_(m), active_(true)
609 return (active_ && (mesh_==rhs.mesh_) && (halfedge_==rhs.halfedge_));
639 return mesh_->
target(halfedge_);
643 operator bool()
const {
return halfedge_.
is_valid(); }
683 : mesh_(m), active_(true)
692 return (active_ && (mesh_==rhs.mesh_) && (halfedge_==rhs.halfedge_));
722 operator bool()
const {
return halfedge_.
is_valid(); }
759 : mesh_(m), active_(true)
773 return (active_ && (mesh_==rhs.mesh_) && (halfedge_==rhs.halfedge_));
785 assert(mesh_ && halfedge_.
is_valid());
796 assert(mesh_ && halfedge_.
is_valid());
806 assert(mesh_ && halfedge_.
is_valid());
807 return mesh_->
face(halfedge_);
811 operator bool()
const {
return halfedge_.
is_valid(); }
848 : mesh_(m), active_(true)
850 if (mesh_) halfedge_ = mesh_->
halfedge(f);
857 return (active_ && (mesh_==rhs.mesh_) && (halfedge_==rhs.halfedge_));
869 assert(mesh_ && halfedge_.
is_valid());
870 halfedge_ = mesh_->
next(halfedge_);
878 assert(mesh_ && halfedge_.
is_valid());
879 halfedge_ = mesh_->
prev(halfedge_);
886 assert(mesh_ && halfedge_.
is_valid());
887 return mesh_->
target(halfedge_);
925 : mesh_(m), active_(true)
927 if (mesh_) halfedge_ = mesh_->
halfedge(f);
934 return (active_ && (mesh_==rhs.mesh_) && (halfedge_==rhs.halfedge_));
946 assert(mesh_ && halfedge_.
is_valid());
947 halfedge_ = mesh_->
next(halfedge_);
955 assert(mesh_ && halfedge_.
is_valid());
956 halfedge_ = mesh_->
prev(halfedge_);
1020 bool read(
const std::string& filename);
1025 bool write(
const std::string& filename)
const;
1049 Face
add_quad(Vertex v1, Vertex v2, Vertex v3, Vertex v4);
1064 unsigned int edges_size()
const {
return (
unsigned int) eprops_.size(); }
1066 unsigned int faces_size()
const {
return (
unsigned int) fprops_.size(); }
1084 void reserve(
unsigned int nvertices,
1085 unsigned int nedges,
1086 unsigned int nfaces );
1091 void resize(
unsigned int nv,
unsigned int ne,
unsigned int nf) {
1093 hprops_.resize(2 * ne);
1109 return vdeleted_[v];
1115 return edeleted_[
edge(h)];
1121 return edeleted_[e];
1127 return fdeleted_[f];
1166 return vconn_[v].halfedge_;
1172 vconn_[v].halfedge_ = h;
1203 while (++hit!=hend);
1213 return hconn_[h].vertex_;
1225 hconn_[h].vertex_ = v;
1231 return hconn_[h].face_;
1237 hconn_[h].face_ = f;
1243 return hconn_[h].next_;
1249 hconn_[h].next_ = nh;
1250 hconn_[nh].prev_ = h;
1256 return hconn_[h].prev_;
1310 return Halfedge(
static_cast<int>((e.
idx() << 1) + i));
1337 return fconn_[f].halfedge_;
1343 fconn_[f].halfedge_ = h;
1525 return vprops_.rename(old_name, new_name);
1530 return fprops_.rename(old_name, new_name);
1535 return eprops_.rename(old_name, new_name);
1540 return hprops_.rename(old_name, new_name);
1545 return mprops_.rename(old_name, new_name);
1553 return vprops_.get_type(
name);
1559 return hprops_.get_type(
name);
1565 return eprops_.get_type(
name);
1571 return fprops_.get_type(
name);
1577 return mprops_.get_type(
name);
1584 return vprops_.properties();
1589 return hprops_.properties();
1594 return eprops_.properties();
1599 return fprops_.properties();
1604 return mprops_.properties();
1781 void split(Face f, Vertex v);
1803 Halfedge
split(Edge e, Vertex v);
1888 void stitch(Halfedge h0, Halfedge h1);
1893 unsigned int valence(Vertex v)
const;
1896 unsigned int valence(Face f)
const;
1902 Edge
find_edge(Vertex a, Vertex b)
const;
1934 const std::vector<vec3>&
points()
const override {
return vpoint_.vector(); }
1937 std::vector<vec3>&
points()
override {
return vpoint_.vector(); }
1965 vprops_.push_back();
1970 Halfedge new_edge(Vertex start, Vertex end)
1972 assert(start != end);
1974 eprops_.push_back();
1975 hprops_.push_back();
1976 hprops_.push_back();
1990 fprops_.push_back();
1991 return Face(
static_cast<int>(
faces_size()-1));
2003 void adjust_outgoing_halfedges();
2007 void adjust_outgoing_halfedge(Vertex v);
2010 void remove_edge(Halfedge h);
2013 void remove_loop(Halfedge h);
2017 bool can_merge_vertices(Halfedge h0, Halfedge h1)
const;
2021 PropertyContainer vprops_;
2022 PropertyContainer hprops_;
2023 PropertyContainer eprops_;
2024 PropertyContainer fprops_;
2025 PropertyContainer mprops_;
2027 VertexProperty<VertexConnectivity> vconn_;
2028 HalfedgeProperty<HalfedgeConnectivity> hconn_;
2029 FaceProperty<FaceConnectivity> fconn_;
2031 VertexProperty<bool> vdeleted_;
2032 EdgeProperty<bool> edeleted_;
2033 FaceProperty<bool> fdeleted_;
2035 VertexProperty<vec3> vpoint_;
2036 VertexProperty<vec3> vnormal_;
2037 FaceProperty<vec3> fnormal_;
2039 unsigned int deleted_vertices_;
2040 unsigned int deleted_edges_;
2041 unsigned int deleted_faces_;
2045 typedef std::pair<Halfedge, Halfedge> NextCacheEntry;
2046 typedef std::vector<NextCacheEntry> NextCache;
2047 std::vector<Vertex> add_face_vertices_;
2048 std::vector<Halfedge> add_face_halfedges_;
2049 std::vector<bool> add_face_is_new_;
2050 std::vector<bool> add_face_needs_adjust_;
2051 NextCache add_face_next_cache_;
2053 friend class SurfaceMeshBuilder;
2062 return (os <<
'v' << v.
idx());
2068 return (os <<
'h' << h.
idx());
2074 return (os <<
'e' << e.
idx());
2080 return (os <<
'f' << f.
idx());
The base class of renderable 3D models.
Definition: model.h:49
const std::string & name() const
The name of a model.
Definition: model.h:60
Implementation of a generic property.
Definition: property.h:253
Definition: surface_mesh.h:60
bool operator!=(const BaseHandle &_rhs) const
are two handles different?
Definition: surface_mesh.h:81
bool is_valid() const
return whether the handle is valid, i.e., the index is not equal to -1.
Definition: surface_mesh.h:73
int idx() const
Get the underlying index of this handle.
Definition: surface_mesh.h:67
bool operator<(const BaseHandle &_rhs) const
compare operator useful for sorting handles
Definition: surface_mesh.h:86
bool operator==(const BaseHandle &_rhs) const
are two handles equal?
Definition: surface_mesh.h:76
void reset()
reset handle to be invalid (index=-1)
Definition: surface_mesh.h:70
BaseHandle(int _idx=-1)
constructor
Definition: surface_mesh.h:64
Definition: surface_mesh.h:550
Definition: surface_mesh.h:413
bool operator!=(const EdgeIterator &rhs) const
are two iterators different?
Definition: surface_mesh.h:432
EdgeIterator & operator++()
pre-increment iterator
Definition: surface_mesh.h:438
Edge operator*() const
get the edge the iterator refers to
Definition: surface_mesh.h:423
bool operator==(const EdgeIterator &rhs) const
are two iterators equal?
Definition: surface_mesh.h:426
EdgeIterator(Edge e=Edge(), const SurfaceMesh *m=nullptr)
Default constructor.
Definition: surface_mesh.h:417
EdgeIterator & operator--()
pre-decrement iterator
Definition: surface_mesh.h:447
Definition: surface_mesh.h:233
EdgeProperty()=default
default constructor
Property< T >::reference operator[](Edge e)
access the data stored for edge e
Definition: surface_mesh.h:241
Property< T >::const_reference operator[](Edge e) const
access the data stored for edge e
Definition: surface_mesh.h:247
Definition: surface_mesh.h:754
bool operator!=(const FaceAroundVertexCirculator &rhs) const
are two circulators different?
Definition: surface_mesh.h:777
bool operator==(const FaceAroundVertexCirculator &rhs) const
are two circulators equal?
Definition: surface_mesh.h:770
FaceAroundVertexCirculator & operator++()
pre-increment (rotates counter-clockwise)
Definition: surface_mesh.h:783
Face operator*() const
get the face the circulator refers to
Definition: surface_mesh.h:804
FaceAroundVertexCirculator(const SurfaceMesh *m=nullptr, Vertex v=Vertex())
construct with mesh and vertex (vertex should not be isolated!)
Definition: surface_mesh.h:758
FaceAroundVertexCirculator & operator--()
pre-decrement (rotate clockwise)
Definition: surface_mesh.h:794
Definition: surface_mesh.h:565
Definition: surface_mesh.h:465
bool operator!=(const FaceIterator &rhs) const
are two iterators different?
Definition: surface_mesh.h:484
bool operator==(const FaceIterator &rhs) const
are two iterators equal?
Definition: surface_mesh.h:478
FaceIterator & operator--()
pre-decrement iterator
Definition: surface_mesh.h:499
FaceIterator(Face f=Face(), const SurfaceMesh *m=nullptr)
Default constructor.
Definition: surface_mesh.h:469
Face operator*() const
get the face the iterator refers to
Definition: surface_mesh.h:475
FaceIterator & operator++()
pre-increment iterator
Definition: surface_mesh.h:490
Definition: surface_mesh.h:257
Property< T >::reference operator[](Face f)
access the data stored for face f
Definition: surface_mesh.h:265
FaceProperty()=default
default constructor
Property< T >::const_reference operator[](Face f) const
access the data stored for face f
Definition: surface_mesh.h:271
Definition: surface_mesh.h:920
Halfedge operator*() const
get the halfedge the circulator refers to
Definition: surface_mesh.h:961
HalfedgeAroundFaceCirculator & operator--()
pre-decrement (rotates clockwise)
Definition: surface_mesh.h:953
bool operator==(const HalfedgeAroundFaceCirculator &rhs) const
are two circulators equal?
Definition: surface_mesh.h:931
bool operator!=(const HalfedgeAroundFaceCirculator &rhs) const
are two circulators different?
Definition: surface_mesh.h:938
HalfedgeAroundFaceCirculator(const SurfaceMesh *m=nullptr, Face f=Face())
default constructor
Definition: surface_mesh.h:924
HalfedgeAroundFaceCirculator & operator++()
pre-increment (rotates counter-clockwise)
Definition: surface_mesh.h:944
Definition: surface_mesh.h:678
bool operator==(const HalfedgeAroundVertexCirculator &rhs) const
are two circulators equal?
Definition: surface_mesh.h:689
Halfedge operator*() const
get the halfedge the circulator refers to
Definition: surface_mesh.h:719
HalfedgeAroundVertexCirculator & operator++()
pre-increment (rotate counter-clockwise)
Definition: surface_mesh.h:702
bool operator!=(const HalfedgeAroundVertexCirculator &rhs) const
are two circulators different?
Definition: surface_mesh.h:696
HalfedgeAroundVertexCirculator & operator--()
pre-decrement (rotate clockwise)
Definition: surface_mesh.h:711
HalfedgeAroundVertexCirculator(const SurfaceMesh *m=nullptr, Vertex v=Vertex())
default constructor
Definition: surface_mesh.h:682
Definition: surface_mesh.h:535
Definition: surface_mesh.h:361
HalfedgeIterator & operator--()
pre-decrement iterator
Definition: surface_mesh.h:395
Halfedge operator*() const
get the halfedge the iterator refers to
Definition: surface_mesh.h:371
HalfedgeIterator(Halfedge h=Halfedge(), const SurfaceMesh *m=nullptr)
Default constructor.
Definition: surface_mesh.h:365
HalfedgeIterator & operator++()
pre-increment iterator
Definition: surface_mesh.h:386
bool operator==(const HalfedgeIterator &rhs) const
are two iterators equal?
Definition: surface_mesh.h:374
bool operator!=(const HalfedgeIterator &rhs) const
are two iterators different?
Definition: surface_mesh.h:380
Definition: surface_mesh.h:209
Property< T >::reference operator[](Halfedge h)
access the data stored for halfedge h
Definition: surface_mesh.h:217
Property< T >::const_reference operator[](Halfedge h) const
access the data stored for halfedge h
Definition: surface_mesh.h:223
HalfedgeProperty()=default
default constructor
Definition: surface_mesh.h:281
ModelProperty()=default
default constructor
Property< T >::const_reference operator[](size_t idx) const
access the data stored for the mesh
Definition: surface_mesh.h:295
Property< T >::reference operator[](size_t idx)
access the data stored for the mesh
Definition: surface_mesh.h:289
Definition: surface_mesh.h:843
VertexAroundFaceCirculator(const SurfaceMesh *m=nullptr, Face f=Face())
default constructor
Definition: surface_mesh.h:847
bool operator!=(const VertexAroundFaceCirculator &rhs) const
are two circulators different?
Definition: surface_mesh.h:861
Vertex operator*() const
get the vertex the circulator refers to
Definition: surface_mesh.h:884
bool operator==(const VertexAroundFaceCirculator &rhs) const
are two circulators equal?
Definition: surface_mesh.h:854
VertexAroundFaceCirculator & operator--()
pre-decrement (rotates clockwise)
Definition: surface_mesh.h:876
VertexAroundFaceCirculator & operator++()
pre-increment (rotates counter-clockwise)
Definition: surface_mesh.h:867
Definition: surface_mesh.h:595
bool operator!=(const VertexAroundVertexCirculator &rhs) const
are two circulators different?
Definition: surface_mesh.h:613
VertexAroundVertexCirculator & operator++()
pre-increment (rotate counter-clockwise)
Definition: surface_mesh.h:619
Vertex operator*() const
get the vertex the circulator refers to
Definition: surface_mesh.h:636
VertexAroundVertexCirculator(const SurfaceMesh *m=nullptr, Vertex v=Vertex())
default constructor
Definition: surface_mesh.h:599
bool operator==(const VertexAroundVertexCirculator &rhs) const
are two circulators equal?
Definition: surface_mesh.h:606
VertexAroundVertexCirculator & operator--()
pre-decrement (rotate clockwise)
Definition: surface_mesh.h:628
Halfedge halfedge() const
return current halfedge
Definition: surface_mesh.h:646
Definition: surface_mesh.h:520
Definition: surface_mesh.h:309
Vertex operator*() const
get the vertex the iterator refers to
Definition: surface_mesh.h:319
bool operator==(const VertexIterator &rhs) const
are two iterators equal?
Definition: surface_mesh.h:322
VertexIterator & operator--()
pre-decrement iterator
Definition: surface_mesh.h:343
bool operator!=(const VertexIterator &rhs) const
are two iterators different?
Definition: surface_mesh.h:328
VertexIterator(Vertex v=Vertex(), const SurfaceMesh *m=nullptr)
Default constructor.
Definition: surface_mesh.h:313
VertexIterator & operator++()
pre-increment iterator
Definition: surface_mesh.h:334
Definition: surface_mesh.h:185
Property< T >::const_reference operator[](Vertex v) const
access the data stored for vertex v
Definition: surface_mesh.h:199
Property< T >::reference operator[](Vertex v)
access the data stored for vertex v
Definition: surface_mesh.h:193
VertexProperty()=default
default constructor
A halfedge data structure for polygonal meshes of 2-manifold.
Definition: surface_mesh.h:52
const vec3 & position(Vertex v) const
position of a vertex (read only)
Definition: surface_mesh.h:1928
bool is_border(Vertex v) const
returns whether v is a boundary vertex
Definition: surface_mesh.h:1176
bool is_quad_mesh() const
Definition: surface_mesh.cpp:896
EdgeContainer edges() const
returns edge container for C++11 range-based for-loops
Definition: surface_mesh.h:1667
const std::type_info & get_vertex_property_type(const std::string &name) const
Definition: surface_mesh.h:1551
Vertex source(Halfedge h) const
returns the vertex the halfedge h emanates from
Definition: surface_mesh.h:1217
unsigned int n_faces() const
returns number of faces in the mesh
Definition: surface_mesh.h:1076
bool remove_vertex_property(const std::string &n)
remove the vertex property named n
Definition: surface_mesh.h:1493
EdgeIterator edges_end() const
returns end iterator for edges
Definition: surface_mesh.h:1661
unsigned int n_halfedges() const
returns number of halfedge in the mesh
Definition: surface_mesh.h:1072
unsigned int halfedges_size() const
returns number of (deleted and valid)halfedge in the mesh
Definition: surface_mesh.h:1062
void set_next(Halfedge h, Halfedge nh)
sets the next halfedge of h within the face to nh
Definition: surface_mesh.h:1247
VertexAroundVertexCirculator vertices(Vertex v) const
returns circulator for vertices around vertex v
Definition: surface_mesh.h:1691
bool is_valid(Halfedge h) const
return whether halfedge h is valid, i.e. the index is stores it within the array bounds.
Definition: surface_mesh.h:1137
HalfedgeAroundFaceCirculator halfedges(Face f) const
returns circulator for halfedges of face f
Definition: surface_mesh.h:1715
unsigned int n_edges() const
returns number of edges in the mesh
Definition: surface_mesh.h:1074
bool is_valid(Edge e) const
return whether edge e is valid, i.e. the index is stores it within the array bounds.
Definition: surface_mesh.h:1142
void triangulate()
Definition: surface_mesh.cpp:908
bool rename_vertex_property(const std::string &old_name, const std::string &new_name)
rename a vertex property given its name
Definition: surface_mesh.h:1524
unsigned int valence(Vertex v) const
Definition: surface_mesh.cpp:834
HalfedgeProperty< T > add_halfedge_property(const std::string &name, const T t=T())
Definition: surface_mesh.h:1381
Face add_face(const std::vector< Vertex > &vertices)
Definition: surface_mesh.cpp:518
bool remove_halfedge_property(HalfedgeProperty< T > &p)
remove the halfedge property p
Definition: surface_mesh.h:1497
VertexContainer vertices() const
returns vertex container for C++11 range-based for-loops
Definition: surface_mesh.h:1631
void stitch(Halfedge h0, Halfedge h1)
Stitch two halfedges h0 and h1. Precondition: h0 and h1 are both on the border and point in reversed ...
Definition: surface_mesh.cpp:1651
Halfedge opposite(Halfedge h) const
returns the opposite halfedge of h
Definition: surface_mesh.h:1260
FaceProperty< T > get_face_property(const std::string &name) const
Definition: surface_mesh.h:1435
const std::type_info & get_edge_property_type(const std::string &name) const
Definition: surface_mesh.h:1563
bool is_collapse_ok(Halfedge h) const
Definition: surface_mesh.cpp:1759
const std::type_info & get_halfedge_property_type(const std::string &name) const
Definition: surface_mesh.h:1557
void delete_face(Face f)
Definition: surface_mesh.cpp:1999
bool has_garbage() const
are there deleted vertices, edges or faces?
Definition: surface_mesh.h:1099
Halfedge halfedge(Edge e, unsigned int i) const
returns the i'th halfedge of edge e. i has to be 0 or 1.
Definition: surface_mesh.h:1307
Halfedge insert_vertex(Edge e, Vertex v)
Definition: surface_mesh.h:1826
bool rename_face_property(const std::string &old_name, const std::string &new_name)
rename a face property given its name
Definition: surface_mesh.h:1529
Edge find_edge(Vertex a, Vertex b) const
find the edge (a, b)
Definition: surface_mesh.cpp:436
VertexProperty< T > vertex_property(const std::string &name, const T t=T())
Definition: surface_mesh.h:1457
unsigned int edges_size() const
returns number of (deleted and valid)edges in the mesh
Definition: surface_mesh.h:1064
std::vector< std::string > face_properties() const
returns the names of all face properties
Definition: surface_mesh.h:1597
bool is_flip_ok(Edge e) const
Definition: surface_mesh.cpp:1488
FaceContainer faces() const
returns face container for C++11 range-based for-loops
Definition: surface_mesh.h:1685
ModelProperty< T > get_model_property(const std::string &name) const
Gets the model property named name of type T.
Definition: surface_mesh.h:1449
~SurfaceMesh() override=default
destructor (is virtual, since we inherit from Geometry_representation)
std::vector< std::string > vertex_properties() const
returns the names of all vertex properties
Definition: surface_mesh.h:1582
void update_face_normals()
compute face normals by calling compute_face_normal(Face) for each face.
Definition: surface_mesh.cpp:1011
vec3 compute_face_normal(Face f) const
compute normal vector of face f.
Definition: surface_mesh.cpp:1035
SurfaceMesh(const SurfaceMesh &rhs)
copy constructor: copies rhs to *this. performs a deep copy of all properties.
Definition: surface_mesh.h:989
Halfedge insert_vertex(Edge e, const vec3 &p)
Definition: surface_mesh.h:1814
EdgeProperty< T > get_edge_property(const std::string &name) const
Definition: surface_mesh.h:1429
void set_halfedge(Face f, Halfedge h)
sets the halfedge of face f to h
Definition: surface_mesh.h:1341
const std::type_info & get_face_property_type(const std::string &name) const
Definition: surface_mesh.h:1569
EdgeIterator edges_begin() const
returns start iterator for edges
Definition: surface_mesh.h:1655
VertexAroundFaceCirculator vertices(Face f) const
returns circulator for vertices of face f
Definition: surface_mesh.h:1709
FaceIterator faces_begin() const
returns start iterator for faces
Definition: surface_mesh.h:1673
Halfedge find_halfedge(Vertex start, Vertex end) const
find the halfedge from start to end
Definition: surface_mesh.cpp:411
VertexProperty< T > get_vertex_property(const std::string &name) const
Definition: surface_mesh.h:1417
bool remove_face_property(const std::string &n)
remove the face property named n
Definition: surface_mesh.h:1514
bool is_stitch_ok(Halfedge h0, Halfedge h1)
Definition: surface_mesh.cpp:1609
Vertex split(Face f, const vec3 &p)
Definition: surface_mesh.h:1775
void reverse_orientation()
Reverses the orientation of the entire mesh.
Definition: surface_mesh.cpp:923
std::vector< std::string > edge_properties() const
returns the names of all edge properties
Definition: surface_mesh.h:1592
bool read(const std::string &filename)
Read mesh from a SM file filename. Mainly for quick debug purposes. Client code should use SurfaceMes...
Definition: surface_mesh.cpp:203
bool is_deleted(Vertex v) const
Definition: surface_mesh.h:1107
void set_face(Halfedge h, Face f)
sets the incident face to halfedge h to f
Definition: surface_mesh.h:1235
SurfaceMesh()
default constructor
Definition: surface_mesh.cpp:33
std::vector< std::string > model_properties() const
returns the names of all model properties
Definition: surface_mesh.h:1602
Vertex target(Halfedge h) const
returns the vertex the halfedge h points to
Definition: surface_mesh.h:1211
Halfedge halfedge(Face f) const
returns a halfedge of face f
Definition: surface_mesh.h:1335
bool is_deleted(Face f) const
Definition: surface_mesh.h:1125
HalfedgeContainer halfedges() const
returns halfedge container for C++11 range-based for-loops
Definition: surface_mesh.h:1649
void collect_garbage()
remove deleted vertices/edges/faces
Definition: surface_mesh.cpp:2113
SurfaceMesh & operator=(const SurfaceMesh &rhs)
assign rhs to *this. performs a deep copy of all properties.
Definition: surface_mesh.cpp:55
bool rename_edge_property(const std::string &old_name, const std::string &new_name)
rename an edge property given its name
Definition: surface_mesh.h:1534
void resize(unsigned int nv, unsigned int ne, unsigned int nf)
Definition: surface_mesh.h:1091
bool is_deleted(Edge e) const
Definition: surface_mesh.h:1119
Halfedge split(Edge e, const vec3 &p)
Definition: surface_mesh.h:1792
Halfedge prev_around_source(Halfedge h) const
Definition: surface_mesh.h:1267
Halfedge insert_edge(Halfedge h0, Halfedge h1)
Definition: surface_mesh.cpp:1447
const std::type_info & get_model_property_type(const std::string &name) const
Definition: surface_mesh.h:1575
Halfedge prev(Halfedge h) const
returns the previous halfedge within the incident face
Definition: surface_mesh.h:1254
void set_target(Halfedge h, Vertex v)
sets the vertex the halfedge h points to to v
Definition: surface_mesh.h:1223
Halfedge next_around_target(Halfedge h) const
Definition: surface_mesh.h:1288
std::vector< vec3 > & points() override
vector of vertex positions
Definition: surface_mesh.h:1937
SurfaceMesh & join(const SurfaceMesh &other)
Merges another surface mesh into the current one. Shifts the indices of vertices of the other mesh by...
Definition: surface_mesh.cpp:93
bool is_closed() const
returns whether the mesh closed (i.e., no boundary edges)
Definition: surface_mesh.cpp:869
bool remove_face_property(FaceProperty< T > &p)
remove the face property p
Definition: surface_mesh.h:1511
bool remove_edge_property(const std::string &n)
remove the edge property named n
Definition: surface_mesh.h:1507
ModelProperty< T > model_property(const std::string &name, const T t=T())
Definition: surface_mesh.h:1482
Face add_quad(Vertex v1, Vertex v2, Vertex v3, Vertex v4)
Definition: surface_mesh.cpp:504
VertexProperty< T > add_vertex_property(const std::string &name, const T t=T())
Definition: surface_mesh.h:1374
bool remove_model_property(ModelProperty< T > &p)
remove the model property p
Definition: surface_mesh.h:1518
FaceProperty< T > face_property(const std::string &name, const T t=T())
Definition: surface_mesh.h:1475
FaceProperty< T > add_face_property(const std::string &name, const T t=T())
Definition: surface_mesh.h:1395
FaceAroundVertexCirculator faces(Vertex v) const
returns circulator for faces around vertex v
Definition: surface_mesh.h:1703
std::vector< std::string > halfedge_properties() const
returns the names of all halfedge properties
Definition: surface_mesh.h:1587
Face add_triangle(Vertex v1, Vertex v2, Vertex v3)
Definition: surface_mesh.cpp:491
bool rename_model_property(const std::string &old_name, const std::string &new_name)
rename a model property given its name
Definition: surface_mesh.h:1544
bool is_triangle_mesh() const
Definition: surface_mesh.cpp:882
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: surface_mesh.h:1409
bool can_join_edges(Vertex v) const
Definition: surface_mesh.cpp:2324
HalfedgeIterator halfedges_begin() const
returns start iterator for halfedges
Definition: surface_mesh.h:1637
vec3 compute_vertex_normal(Vertex v) const
Definition: surface_mesh.cpp:1170
HalfedgeProperty< T > get_halfedge_property(const std::string &name) const
Definition: surface_mesh.h:1423
bool write(const std::string &filename) const
Write mesh to a SM file filename. Mainly for quick debug purposes. Client code should use SurfaceMesh...
Definition: surface_mesh.cpp:250
SurfaceMesh & operator+=(const SurfaceMesh &other)
Merges another surface mesh into the current one. Shifts the indices of vertices of the other mesh by...
Definition: surface_mesh.h:1000
Vertex add_vertex(const vec3 &p)
add a new vertex with position p
Definition: surface_mesh.h:1034
bool is_valid(Face f) const
return whether face f is valid, i.e. the index is stores it within the array bounds.
Definition: surface_mesh.h:1147
bool is_border(Face f) const
returns whether f is a boundary face, i.e., it one of its edges is a boundary edge.
Definition: surface_mesh.h:1347
EdgeProperty< T > edge_property(const std::string &name, const T t=T())
Definition: surface_mesh.h:1469
Halfedge prev_around_target(Halfedge h) const
Definition: surface_mesh.h:1281
Face face(Halfedge h) const
returns the face incident to halfedge h
Definition: surface_mesh.h:1229
bool remove_edge_property(EdgeProperty< T > &p)
remove the edge property p
Definition: surface_mesh.h:1504
void property_stats(std::ostream &output) const override
prints the names of all properties to an output stream (e.g., std::cout).
Definition: surface_mesh.cpp:354
void delete_edge(Edge e)
Definition: surface_mesh.cpp:1985
void update_vertex_normals()
compute vertex normals by calling compute_vertex_normal(Vertex) for each vertex.
Definition: surface_mesh.cpp:1093
FaceIterator faces_end() const
returns end iterator for faces
Definition: surface_mesh.h:1679
SurfaceMesh & assign(const SurfaceMesh &rhs)
assign rhs to *this. does not copy custom properties.
Definition: surface_mesh.cpp:149
void collapse(Halfedge h)
Definition: surface_mesh.cpp:1821
void flip(Edge e)
Definition: surface_mesh.cpp:1514
HalfedgeProperty< T > halfedge_property(const std::string &name, const T t=T())
Definition: surface_mesh.h:1463
bool is_manifold(Vertex v) const
returns whether v is a manifold vertex (not incident to several patches)
Definition: surface_mesh.h:1189
void clear()
Removes all vertices, edges, faces, and properties (and resets garbage state).
Definition: surface_mesh.cpp:302
Halfedge next_around_source(Halfedge h) const
Definition: surface_mesh.h:1274
bool rename_halfedge_property(const std::string &old_name, const std::string &new_name)
rename a halfedge property given its name
Definition: surface_mesh.h:1539
bool remove_halfedge_property(const std::string &n)
remove the halfedge property named n
Definition: surface_mesh.h:1500
bool is_isolated(Vertex v) const
returns whether v is isolated, i.e., not incident to any face
Definition: surface_mesh.h:1183
vec3 & position(Vertex v)
position of a vertex
Definition: surface_mesh.h:1931
bool is_deleted(Halfedge h) const
Definition: surface_mesh.h:1113
HalfedgeAroundVertexCirculator halfedges(Vertex v) const
returns circulator for outgoing halfedges around vertex v
Definition: surface_mesh.h:1697
unsigned int vertices_size() const
returns number of (deleted and valid) vertices in the mesh
Definition: surface_mesh.h:1060
Edge edge(Halfedge h) const
return the edge that contains halfedge h as one of its two halfedges.
Definition: surface_mesh.h:1294
bool remove_model_property(const std::string &n)
remove the model property named n
Definition: surface_mesh.h:1521
float edge_length(Edge e) const
compute the length of edge e.
Definition: surface_mesh.cpp:1228
EdgeProperty< T > add_edge_property(const std::string &name, const T t=T())
Definition: surface_mesh.h:1388
unsigned int faces_size() const
returns number of (deleted and valid)faces in the mesh
Definition: surface_mesh.h:1066
Halfedge next(Halfedge h) const
returns the next halfedge within the incident face
Definition: surface_mesh.h:1241
Face face(Edge e, unsigned int i) const
returns the face incident to the i'th halfedge of edge e. i has to be 0 or 1.
Definition: surface_mesh.h:1321
Halfedge out_halfedge(Vertex v) const
Definition: surface_mesh.h:1164
void delete_vertex(Vertex v)
Definition: surface_mesh.cpp:1951
bool is_border(Edge e) const
Definition: surface_mesh.h:1329
VertexIterator vertices_begin() const
returns start iterator for vertices
Definition: surface_mesh.h:1619
HalfedgeIterator halfedges_end() const
returns end iterator for halfedges
Definition: surface_mesh.h:1643
bool remove_vertex_property(VertexProperty< T > &p)
remove the vertex property p
Definition: surface_mesh.h:1490
bool is_degenerate(Face f) const
returns whether f is degenerate
Definition: surface_mesh.cpp:2260
VertexIterator vertices_end() const
returns end iterator for vertices
Definition: surface_mesh.h:1625
bool is_valid(Vertex v) const
return whether vertex v is valid, i.e. the index is stores it within the array bounds.
Definition: surface_mesh.h:1132
Vertex vertex(Edge e, unsigned int i) const
returns the i'th vertex of edge e. i has to be 0 or 1.
Definition: surface_mesh.h:1314
bool is_border(Halfedge h) const
returns whether h is a boundary halfedge, i.e., if its face does not exist.
Definition: surface_mesh.h:1300
void reserve(unsigned int nvertices, unsigned int nedges, unsigned int nfaces)
reserves memory (mainly used in file readers)
Definition: surface_mesh.cpp:339
bool join_edges(Vertex v)
Definition: surface_mesh.cpp:2340
const std::vector< vec3 > & points() const override
vector of vertex positions (read only)
Definition: surface_mesh.h:1934
unsigned int n_vertices() const
returns number of vertices in the mesh
Definition: surface_mesh.h:1070
void set_out_halfedge(Vertex v, Halfedge h)
set the outgoing halfedge of vertex v to h
Definition: surface_mesh.h:1170
Definition: collider.cpp:182
std::ostream & operator<<(std::ostream &os, Graph::Vertex v)
Definition: graph.h:920
helper structure to be able to use std::unordered_map
Definition: surface_mesh.h:91
Definition: surface_mesh.h:124
Edge(int _idx=-1)
default constructor (with invalid index)
Definition: surface_mesh.h:126
Definition: surface_mesh.h:172
Halfedge halfedge_
a halfedge that is part of the face
Definition: surface_mesh.h:174
Definition: surface_mesh.h:134
Face(int _idx=-1)
default constructor (with invalid index)
Definition: surface_mesh.h:136
Definition: surface_mesh.h:157
Vertex vertex_
vertex the halfedge points to
Definition: surface_mesh.h:161
Halfedge next_
next halfedge within a face (or along a boundary)
Definition: surface_mesh.h:163
Face face_
face incident to halfedge
Definition: surface_mesh.h:159
Halfedge prev_
previous halfedge within a face (or along a boundary)
Definition: surface_mesh.h:165
Definition: surface_mesh.h:114
Halfedge(int _idx=-1)
default constructor (with invalid index)
Definition: surface_mesh.h:116
Definition: surface_mesh.h:148
Halfedge halfedge_
an outgoing halfedge per vertex (it will be a boundary halfedge for boundary vertices)
Definition: surface_mesh.h:150
Definition: surface_mesh.h:104
Vertex(int _idx=-1)
default constructor (with invalid index)
Definition: surface_mesh.h:106